akhauriyash/Code-Regression huggingface dataset:
s=input()
q=int(input())
i=0
x=z=""
for _ in range(q):
    a=list(input().split())
    if a[0]=="1":
        i+=1
    else:
        if a[1]=="1" and i%2==1:
            z=z+a[2]
        elif a[1]=="1" and i%2==0:     
            x=a[2]+x
        elif a[1]=="2" and i%2==1:  
            x=a[2]+x
        else:
            z=z+a[2]
print(z[::-1]+s[::-1]+x[::-1] if i%2 else x+s+z)

Measured memory_bytes: 4444
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            int[] ans = new int[N];
            for(int i = 1; i < N / 5; i++)
            {
                for(int j = 1; j < N / 5; j++)
                {
                    for (int k = 1; k < N / 5; k++)
                    {
                        int sum = i * i + j * j + k * k + i * j + j * k + i * k;
                        if (sum <= N) { ans[sum - 1]++;
                    }
                        else break;
                    }
                }
            }
            for(int i = 0; i < N; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



Measured memory_bytes: 27332
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    long long n;
    while(~scanf("%lld",&n))
    {if(n==1)
         printf("1\n");
        for(long long  i=2; i<=n ;i++)
        {
            if(i*i>n)
                {printf("%lld\n",(i-1)*(i-1));
        break;
        }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<double> p(n),v(n);
    for(int i=0;i<n;i++){
        double a;
        cin>>a;
        p[i]=(a+1)/2;
    }

    double ans=0;
    v[0]=p[0];
    for(int i=1;i<n;i++){
        v[i]=v[i-1]+p[i];
    }
    for(int i=0;i<n-k;i++){
        ans=max(ans,v[i+k]-v[i]);
    }
    if(n==k) ans=v[n-1];
    printf("%.10f\n",ans);
}

Measured memory_bytes: 6360
// 深さ優先探索
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func paint(currentNode, usedColor, parentNode int, edges [][]int, colors map[int]int) {
	color := 1
	for _, childNode := range edges[currentNode] {
		if childNode == parentNode {
			continue
		}
		if color == usedColor {
			color++
		}
		colors[genid(currentNode, childNode)] = color
		paint(childNode, color, currentNode, edges, colors)
		color++
	}
}

func genid(a, b int) int {
	if b < a {
		a, b = b, a
	}
	return a*100000 + b
}

func main() {
	defer flush()

	N := readInt()

	ab := make([][2]int, N-1)
	edges := make([][]int, N)
	for i := 0; i < N-1; i++ {
		a := readInt() - 1
		b := readInt() - 1
		ab[i][0], ab[i][1] = a, b
		edges[a] = append(edges[a], b)
		edges[b] = append(edges[b], a)
	}

	colors := make(map[int]int)
	paint(0, -1, -1, edges, colors)

	K := -1
	for i := 0; i < N; i++ {
		t := len(edges[i])
		if t > K {
			K = t
		}
	}
	println(K)

	for i := 0; i < N-1; i++ {
		println(colors[genid(ab[i][0], ab[i][1])])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 31872
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn = null;
		int count = 0;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				for(int i = 0; i < str.length(); i++){
					if( Character.isDigit(str.charAt(i)) ){
						int start = i;
						int end = i;
						while( end < str.length() && Character.isDigit(str.charAt(end)) ){
							end++;
						}
						int x = Integer.parseInt(str.substring(start, end));
						count += x;
						i = end;
					}
				}			
			}
			System.out.println(count);
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
 
 
 
int main(){
    
    string s;
    char c;
    ll ans=0;
    
    cin>>s;
    c=s[0];
    rep(i,1,s.size()){
        if(s[i]!=c){
            ans++;
            c=s[i];
        }
    }    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] arr = new int[n];
		
		//???????????´??°????´?
		for(int i=0; i<n; i++) {
			arr[i] = scan.nextInt();
		}
		//??????????????????????´?????????¨????????????????????????
		for(int j=n-1; j>0; j--) {
			System.out.print(arr[j] + " ");
		}
		System.out.println(arr[0]);
  }
}

Measured memory_bytes: 26284
def insertionSort( nums, n, g )
	cnt = 0
	for i in ( g ... nums.length )
	    v = nums[i]
	    j = i - g
	    while 0 <= j && v < nums[j]
	        nums[ j+g ] = nums[j]
	        j -= g
	        cnt += 1
	    end
	    nums[ j+g ] = v
	end
	
	return cnt
end

def shellSort( nums, n )
	cnt = 0
	g = []
	val =0
	for i in ( 0 ... n )
		val = 3*val+1
		break if  n < val
		g.push( val )
	end
	g.reverse!
	m = g.length
	puts( m )
	puts( g.join( " " ) )
	for i in ( 0 ... m )
		cnt += insertionSort( nums, n, g[i] )
	end
    puts( cnt )
end

n = gets.to_i
nums = []
for i in ( 0 ... n )
	nums.push( gets.to_i )
end

shellSort( nums, n )
nums.each { |val| puts( val ) }

Measured memory_bytes: 15948
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    vector<lli> A(N);
    int check = 0;
    int c = 0;
    REP(i, 0, N) {

        cin >> A[i];
        if (A[i] > c) {
            check = 1;
        }
        if (i != 0 && A[i - 1] + 1 < A[i]) {
            check = 1;
        }

        if (A[i] == 0) {
            c = 0;
        }
        c++;
    }

    if (check) {
        cout << -1 << endl;
        return 0;
    }

    lli ans = 0;
    lli cnt = 0;
    REP(i, 0, N) {
        if (A[i] == 0) {
            cnt = 0;
        } else {
            if (A[i] == cnt + 1) {
                ans++;
                cnt++;
            } else {
                ans += A[i];
                cnt = A[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    caddi2018c()
}

fun caddi2018c() {
    val (n, p) = readLine()!!.split(" ").map { it.toLong() }

    val primes = primeFactorization(p)

    var answer = 1L
    for (prime in primes) {
        for (i in 0 until prime.value / n) answer *= prime.key
    }

    println(answer)
}

//素因数分解
private fun primeFactorization(n: Long): Map<Long, Long> {
    val factors = mutableMapOf<Long, Long>()
    var temp = n
    var i = 2L
    while (i * i <= temp) {
        while (temp % i == 0L) {
            factors[i] = (factors[i] ?: 0) + 1
            temp /= i
        }
        i++
    }
    // 素数が残った場合、それも含めるように(1は素数でないので含めない)
    if (temp > 1) factors[temp] = 1
    return factors
}


Measured memory_bytes: 37896
#include <bits/stdc++.h>
using namespace std;
string s,t;
int n;
char rev(char c)
{
	return c=='S'?'W':'S';
}
bool check(string str)
{
	bool ok=true;
	for(int i=0;i<n;i++)
	{
		char cl=str[(i+n-1)%n];
		char cr=str[(i+1)%n];
		if(s[i]=='o' && str[i]=='S')ok&=cl==cr;
		else if(s[i]=='x' && str[i]=='S')ok&=cl!=cr;
		else if(s[i]=='o' && str[i]=='W')ok&=cl!=cr;
		else ok&=cl==cr;
	}
	return ok;
}
void process(string str)
{
	t=str;
	t.resize(n);
	for(int i=1;i<n-1;i++)
	{
		if(t[i]=='S' && s[i]=='o')t[i+1]=t[i-1];
		else if(t[i]=='S' && s[i]=='x')t[i+1]=rev(t[i-1]);
		else if(t[i]=='W' && s[i]=='o')t[i+1]=rev(t[i-1]);
		else t[i+1]=t[i-1];
	}
//	cout<<t<<endl;
	if(check(t))
	{
		cout<<t<<endl;
		exit(0);
	}
}
int main()
{
	cin>>n;
	cin>>s;
	process("SS");
	process("SW");
	process("WS");
	process("WW");
	puts("-1");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,K,X;
  cin >> N >> K;
X=1;
  for( int i=0; i < N; i++){
  if(X<=K){
    X *=2;}
  else{
    X +=K;}
  }
  cout << X << endl;
}

Measured memory_bytes: 3552
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

answer = 0
for i in range(N):
    taosu = min(A[i], B[i])
    answer += taosu
    A[i] -= taosu
    B[i] -= taosu
    taosu = min(A[i+1], B[i])
    answer += taosu
    A[i+1] -= taosu
    B[i] -= taosu

print(answer)

Measured memory_bytes: 18476
//Be Name Khorgraph, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#include <fstream>


using namespace std;

int r;
double c = 3.14159265359;

int main()
{
	cin >> r;
	r = 2 * r;
	cout << setprecision(6) <<  r * c << endl;


}




Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int N,M, ans;

int main()
{
    cin >> N >> M;
    vector<vector<int>> maze(N, vector<int>(M, 1));
    for (int i = 0; i < N;i++)
        for (int j = 0; j < M;j++){
            char a;
            cin >> a;
            if(a == '.')
                maze[i][j] = 0;
        }

    vector<vector<int>> G(N * M,vector<int>(0));
    for (int i = 0; i < N;i++)
        for (int j = 0; j < M;j++){
            if(i > 0 && maze[i][j] == 0 && maze[i-1][j] == 0){
                G[i * M + j].push_back((i - 1) * M + j);
                G[(i - 1) * M + j].push_back(i * M + j);
            }
            if (j > 0 && maze[i][j] == 0 && maze[i][j-1] == 0){
                G[i * M + j].push_back(i * M + j - 1);
                G[i * M + (j - 1)].push_back(i*M + j);
            }
        }

    ans = 0;
    for (int i = 0; i < N*M;i++){
        if(G[i].size() == 0)
            continue;
        vector<int> dist(N*M, -1);
        queue<int> que;
        dist[i] = 0;
        que.push(i);

        while(!que.empty()){
            int v = que.front();
            que.pop();

            for(int nv:G[v]){
                if(dist[nv] != -1)
                    continue;
                dist[nv] = dist[v] + 1;
                que.push(nv);
            }
        }
        sort(dist.begin(), dist.end());
        if(dist[N*M-1] > ans)
            ans = dist[N*M-1];
    }
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> arr1(n);
    vector<ll> arr2(m);

    for (int i=0;i<n;i++) cin >> arr1[i];
    for (int i=0;i<m;i++) cin >> arr2[i];

    vector<ll> pa(n+1, 0);
    vector<ll> pb(m+1, 0);

    for (int i=1;i<=n;i++)
        pa[i] = pa[i-1] + arr1[i-1];
    for (int i=1;i<=m;i++)
        pb[i] = pb[i-1] + arr2[i-1];
    
    int ans = 0;
    int j = m;
    for (int i=0;i<=n;i++) {
        if (pa[i] > k)
            break;
        
        while (j >= 0 && k - pa[i] < pb[j])
            j--;
        
        ans = max(ans, i + j);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 9496
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[] S = new String[N];
    int C0 = 0;
    int C1 = 0;
    int C2 = 0;
    int C3 = 0;
    for(int i=0; i<N; i++){
      S[i] = sc.next();
      
      if(S[i].equals("AC")) {
        C0++;
      } else if(S[i].equals("WA")) {
        C1++;
      } else if(S[i].equals("TLE")) {
        C2++;
      } else if(S[i].equals("RE")) {
        C3++;
      } else {
        continue;
      }
    }
       System.out.println("AC x " + C0);
       System.out.println("WA x " + C1);
       System.out.println("TLE x " + C2);
       System.out.println("RE x " + C3);
  }
}


Measured memory_bytes: 65264
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b,c,d,e,f,g=0;
  cin>>a>>b>>c;
  if(a==b&&b==c&&a%2==0)
    cout<<-1<<endl;
  else{
    while(1){
      if(a%2==0&&b%2==0&&c%2==0){
        g++;
        d=a/2;
        e=b/2;
        f=c/2;
        a=d+e;
        b=e+f;
        c=f+d;
      }
      else
        break;
    }
    cout<<g<<endl;
  }
}


Measured memory_bytes: 256
import sys

d = [int(i) for i in sys.stdin.read().split('\n') if i != '']
k = d[5]
d = d[:5][::-1]


def check(k, d):
    for i in range(len(d[:4])):
        for j in range(i, len(d)):
            if d[i] - d[j] > k:
                return False
    return True


if check(k, d):
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lps(i,j,n) for(int i=j;i<n;i++)
#define lp(i,n) lps(i,0,n)
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long

signed main(){
  while(1){
    int t,d,l;
    cin>>t>>d>>l;
    if(t==0&&d==0&&l==0) break;
    int stat=INF,ans=0;
    lps(i,1,t+1){
      if(stat<d) ans++;
      int a;
      cin>>a;
      if(a>=l) stat=0;
      else stat++;
      // cout<<stat<<endl;
    }
    cout<<ans<<endl;
  }
  return 0;
  
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;



int main(){
    int h,w;cin >> h >> w;
    vector<string> maze(h);
    rep(i,h) cin >> maze[i];

    int para[h][w];
    int parp[h][w];

    int cnt = 0;
    rep(i,h)rep(j,w){
        if(maze[i][j]=='#') {
            para[i][j] = 0;
            continue;
        }
        if(j == w-1 || maze[i][j+1]=='#') {
            para[i][j] = cnt+1;
            rep(k,cnt) para[i][j-1-k] = cnt+1;
            cnt = 0;
        }else {
            cnt++;
            para[i][j]=cnt;
        }
    }
    cnt = 0;
    rep(i,w)rep(j,h){
        if(maze[j][i]=='#') {
            parp[j][i] = 0;
            continue;
        }
        if(j == h-1 || maze[j+1][i]=='#') {
            parp[j][i] = cnt+1;
            rep(k,cnt) parp[j-1-k][i] = cnt+1;
            cnt = 0;
        }else {
            cnt++;
            parp[j][i]=cnt;
        }
    }

    int ans = 0;
    rep(i,h)rep(j,w) ans = max(ans,para[i][j]+parp[i][j]);
    cout << ans-1 << endl;
}

Measured memory_bytes: 42432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  vector<int> a(n+2);
  for(int i=1;i<n+1;i++){
    cin >> a.at(i);
  }
  a.at(0)=0;
  a.at(n+1)=0;
  int ans=abs(a.at(0));
  for(int i=0;i<n+1;i++){
    ans+=abs(a.at(i+1)-a.at(i));
  }
  for(int i=1;i<n+1;i++){
    int copy=ans;
    copy-=abs(a.at(i)-a.at(i-1))+abs(a.at(i+1)-a.at(i));
    copy+=abs(a.at(i+1)-a.at(i-1));
    cout << copy << endl;
  }
}

Measured memory_bytes: 1664
class MathUtil:
    # calculate {m+n}C{n}
    def egcd(self, a: int, b: int):
        if a == 0:
            return b, 0, 1
        else:
            g, y, x = self.egcd(b % a, a)
            return g, x - (b // a) * y, y

    def modinv(self, a: int, m: int):
        g, x, y = self.egcd(a, m)
        if g != 1:
            raise Exception('modular inverse does not exist')
        else:
            return x % m

    def combination(self, n: int, r: int, mod: int = 10**9+7) -> int:
        r = min(r, n-r)
        res = 1
        for i in range(r):
            res = res * (n-i) * self.modinv(i+1, mod) % mod
        return res


x, y = map(int, input().split())


m = - x + 2*y
n = 2*x - y

if m % 3 != 0 or n % 3 != 0 or m < 0 or n < 0:
    print(0)
else:
    m //= 3
    n //= 3

    print(MathUtil().combination(m+n, n))


Measured memory_bytes: 92248
#include <stdio.h>
#define N 1000000
 
int main(void){
  int p[N];
  int i,j,n;
 
  p[0]=0; p[1]=0; p[2]=1;
  for( i=3;i<N;i++ ){
    p[i] = i%2;
  }
   
  for( i=2;i<N;i++ ){
    if( p[i]==1 ){
      for( j=i*2;j<N;j+=i )
    p[j]=0;
    }
  }
   
  for( i=1;i<N;i++ )
    p[i] += p[i-1];
  // p[i] : number of primes that is smaller than i
 
  while( 1 ){
    if( scanf("%d ",&n)!=1 )
      break;
    printf("%d\n",p[n] );
  }
 
 
  return 0;
}

Measured memory_bytes: 4504
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    int n;cin>>n;
    int x[102],y[102],h[102];
    rep(i,n)cin>>x[i]>>y[i]>>h[i];
    rep(i,101){
        rep(j,101){
            bool flag = 1;
            int H;
            rep(k,n){
              if(h[k]==0)continue;
              H = h[k]+max(i-x[k],x[k]-i)+max(j-y[k],y[k]-j);
              break;
            }
            rep(k,n){
              if(h[k] == 0 && max(i-x[k],x[k]-i)+max(j-y[k],y[k]-j)>H)continue;
                if(H != h[k]+max(i-x[k],x[k]-i)+max(j-y[k],y[k]-j)){flag=0;break;}
                }
            if(flag){cout<<i<<" "<<j<<" "<<H<<endl;return 0;}
            }
        }   
}

Measured memory_bytes: 256
// Problem : C - Walk on Multiplication Table
// Contest : AtCoder - AtCoder Beginner Contest 144
// URL : https://atcoder.jp/contests/abc144/tasks/abc144_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int ans = n-1;
	for(int i=1;i<=sqrt(n);i++)
	{
		if(n%i == 0)
		{
			ans = min(ans,i-1+(n/i)-1);
		}
	}
	cout << ans ;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int d[100010],x[100010],ans[100010],_[100010];ll ANS[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<=n;++i)x[i]=gi();
	int m=gi(),p;ll k=gi();
	for(int i=1;i<=n;++i)d[i]=ans[i]=i;
	for(int i=1;i<=m;++i)p=gi(),std::swap(d[p],d[p+1]);
	while(k){
		if(k&1){
			memcpy(_,ans,sizeof _);
			for(int i=1;i<=n;++i)ans[i]=d[_[i]];
		}
		k>>=1;
		memcpy(_,d,sizeof _);
		for(int i=1;i<=n;++i)d[i]=_[_[i]];
	}
	for(int i=1;i<=n;++i)printf("%lld\n",ANS[i]=ANS[i-1]+x[ans[i]]-x[ans[i]-1]);
	return 0;
}


Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int> > a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i].first;
        a[i].second = i;
    }

    sort(a.begin(), a.end());
    int ans = 0;
    for(int i=0; i<n; ++i){
        if(i % 2 != a[i].second % 2)
            ++ ans;
    }
    ans /= 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
using namespace std;

int main(void) {
	int n, m;
	int flag=0;
	char a[51][51], b[51][51];
	cin >> n >> m;
	FOR(i, 0, n-1) {
		cin >> a[i];
	}
	FOR(i, 0, m-1) {
		cin >> b[i];
	}
	FOR(i, 0, n-m) {
		FOR(t, 0, n-m) {
			if (a[i][t] == b[0][0]) {
				FOR(s, 0, m-1) {
					FOR(p, 0, m-1) {
						if (a[i+s][t+p] != b[s][p]) {
							p = m ;
							s = m ;
						}
						if ((s == m-1) && (p == m-1)) {
							flag = 1;
						}
					}
				}
			}
		}
	}
	if (flag == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
 
int d[200][200],s[200],n,m,r,M=INT_MAX,c;
int main() {
	cin>>n>>m>>r;
	memset(d,0x3f,sizeof(d));
	rep(i,r)scanf("%d",&s[i]),s[i]--;sort(s,s+r);
	rep(i,m){int a,b,c;cin>>a>>b>>c;d[--a][--b]=d[b][a]=c;}
	rep(k,n)rep(i,n)rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	do{int c=0;rep(i,r-1)c+=d[s[i]][s[i+1]];M=min(M,c);}while(next_permutation(s,s+r));
	printf("%d",M);
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N, M, k, val, sum;
    int *p;

    scanf("%d", &N);
    p = malloc(sizeof(int) * N);
    for(int i = 0; i < N; i++) scanf("%d", &p[i]);

    scanf("%d", &M);
    for(int i = 0; i < M; i++){
        scanf("%d", &k);
        scanf("%d", &val);

        sum = 0;
        for(int j = 0; j < N; j++){
            if(j == k - 1){
                sum += val;
            }else{
                sum += p[j];
            }
        }

        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int result = 0;
  for(int i = 0; i <= 100;i ++){
    if(i >= a && i < b && i >= c && i < d)
      result ++;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const ll inf = ll(1e18)+1;

int main() {
	ll n,k;
	cin >> n >>k;

	vector<ll> p(n);

	rep (i,n) {
		cin >> p[i];
	}

	ll ma = 0;

	rep(i,k) {
		ma += p[i];
	}

	ll Max = ma;

	rep(i, n-k) {
		ma += p[i+k];
		ma -= p[i];
		Max = max(Max, ma);
	}

	Max += k;
	double e = Max;
	cout << fixed << setprecision(6) << e/2 << endl;
	return 0;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch MustBeRectangular | diff MustBeRectangular.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address MustBeRectangular.cpp && ./a.out

/*
 
 6/22/2019
 
 6:23-6:40 give up
 
 6/23/2019
 
 14:40- read editorials
 
 */

const int MAX_N=1e5+1;
int X[MAX_N],Y[MAX_N];
int N;

int viz[2*MAX_N];
VI G[2*MAX_N];

set<int> A,B;
void dfs(int u) {
  if(viz[u]) return;
  viz[u]=1;
  if(u<MAX_N) A.emplace(u);
  else B.emplace(u);
  FORR(v, G[u]) dfs(v);
}

void solve() {
  REP(i,N) {
    int x=X[i],y=Y[i];
    G[MAX_N+x].push_back(y);
    G[y].push_back(MAX_N+x);
  }
  LL res=0;
  REP(i,MAX_N) if(!viz[i]) {
    A.clear(),B.clear();
    dfs(i);
    if(SZ(A)>1&&SZ(B)>1) {
//      dumpc(A);
//      dumpc(B);
      LL a=(LL)SZ(A)*SZ(B);
      FORR(x,A) a-=SZ(G[x]);
      res+=a;
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) {
    cin>>X[i]>>Y[i];
    --X[i],--Y[i];
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 18944
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n, m, ans = 0;
    string s[105], t[105];
    cin >> n;
    for (int i = 0; i < n; i++)cin >> s[i];
    cin >> m;
    for (int i = 0; i < m; i++)cin >> t[i];
    for (int i = 0; i < n; i++) {
        string tt = s[i];
        int plus = 0, minus = 0;
        for (int i = 0; i < n; i++) if (s[i] == tt)plus++;
        for (int i = 0; i < m; i++) if (t[i] == tt)minus++;
        if (ans <= plus - minus) ans = plus - minus;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;


fn main() {
    let s = read_one::<String>();
    println!("{}", &s[0..(s.len() - 8)]);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
S = gets.chomp.split("") + [nil]
current_mode = "R"
output = Array.new(S.length - 1) { 0 } # 末尾にnilを足してるので-1
index_rl = nil
count_even = 0
count_odd  = 0

S.map.with_index do |char, i|
  if current_mode == "L" && char == "R" || char.nil?
    # Lが続いていたけどRに切り替わった状態。
    # つまり書き換え処理が発生するタイミング。
    if index_rl.even?
      output[index_rl]   = count_even
      output[index_rl+1] = count_odd
    else
      output[index_rl]   = count_odd
      output[index_rl+1] = count_even
    end
    count_even = 0
    count_odd  = 0
    index_rl = nil
    current_mode = "R"
  elsif current_mode == "R" && char == "L"
    # Rが続いていたけどLに切り替わった状態。
    index_rl = i - 1 # この1つ前のRとこのLでRLを構成していることになる。
    current_mode = "L" # モードを切り替える
  # elsif current_mode == "R" && char == "R"
  #   # Rが続いている状態。
  # elsif current_mode == "L" && char == "L"
  #   # Lが続いている状態
  end

  if i.even?
    count_even += 1
  else
    count_odd += 1
  end
end

puts output.join(" ")


Measured memory_bytes: 12284
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int coudp[100001];

int main() {
	int N;
	cin >> N;
	bool judge = false;
	for (int i = 0;i <= N / 4;++i) {
		for (int j = 0;j <= N / 7;++j) {
			int value = 4 * i + 7 * j;
			if (value == N) judge = true;
		}
	}
	if (judge)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, K;
VL A;
map<ll, ll> memo;

int main() {
    cin >> N >> K;
    REP(i, N) {
        A.emplace_back(IN());
        memo[A[i]]++;
    }
    ll sub = *min_element(All(A));
    cout << ceil((double)(N - sub) / (K - 1)) << "\n";
}


Measured memory_bytes: 7284
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC111_B solver = new ABC111_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC111_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            while ((n % 111) != 0) {
                n++;
            }
            out.print(n);
        }

    }
}



Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;


int main()
{
    int n;
    cin >> n;
    i64 ret = n;
    if(ret%2 != 0) ret *= 2;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  for(long long i=0;i<n;i++){
    cin >> a[i];
    int x = a[i];
    b[x-1] += 1;
  }
  long long ans=0;
  for(long long j=0;j<n;j++){
    if(b[j]>1) ans += b[j]*(b[j]-1)/2;
  }
  /*for(int j=0;j<n;j++){
    cout << b[j] << endl;
  }*/
  for(long long i=0;i<n;i++){
    int x = a[i];
    if(b[x-1]<2) cout << ans << endl;
    else{
      ans -= b[x-1]-1;
      cout << ans << endl;
      ans += b[x-1]-1;
    }
  }
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll a,b,k; cin>>a>>b>>k;
	if(k<=a)a-=k;
	else{
		ll dif=k-a;
		a=0;
		(dif>=b)?b=0:b-=dif;
	}
	cout<<a<<' '<<b<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;





public class Main {

    static MyScanner in = new MyScanner();
    static   PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    int N;
    static int max = 200001;
    static int [] dr = {1,-1,0,0};
    static int [] dc={0,0,-1,1};
    static boolean [][] grid;
    static int [] bishopr = {-1,1,-1,1};
    static int [] bishopc = {1,1,-1,-1};
    static long H,W,cnt;
    public static void main(String args[]) throws IOException {
           long N = in.nextLong();
           String temp = "";
            while(N>0){
                N--;
                temp+=(char)('a'+N%26);
                N/=26;
            }
            for(int i=temp.length()-1;i>=0;i--){
                out.print(temp.charAt(i));
            }
        out.flush();
        }
       static boolean isValid (int r, int c){
           if(r>=0&&r<H&&c>=0&&c<W){
               return true;
           }
           return false;
       }
        private static void dfs(int r, int c) {
            for(int i=0;i<4;i++){
                int nr = bishopr[i] +r;
                int nc = bishopc[i]+c;
                if(isValid(nr, nc)&&!grid[nr][nc]){
                    cnt++;
                    grid[nr][nc] = true;
                    dfs(nr, nc);
                }
            }
        }

        static boolean isEven(long a) {
            return (a&1)==0;
        }
       static  void swap (int a, int b){

        int temmp = b;
        b=a;
        a = temmp;
        }
    

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

Measured memory_bytes: 37156
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin >> n >> m;

    int a[n][m],b[m];

    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }

    rep(i,m){
        cin >> b[i];
    }

    int c[n];
    
    rep(i,n){
        c[i]=0;
    }

    rep(i,n){
        rep(k,m){
            c[i] += a[i][k]*b[k];
        }
        cout << c[i] << endl;
    }
    


    return 0;

}


Measured memory_bytes: 3140
#include<bits/stdc++.h>

using namespace std;
int n;
int arr[100009][4];
int dp[100009][4];

int dp_na_pari(int ind, int pos)
{
    if(ind==n-1)
        return arr[ind][pos];
    if(ind>=n)
        return 0;
    if(dp[ind][pos]!=-1)
        return dp[ind][pos];
    int ans=INT_MIN;
    if(pos==0)
    {
        ans=max(arr[ind][pos]+dp_na_pari(ind+1,1),arr[ind][pos]+dp_na_pari(ind+1,2));
    }
    else if(pos==1)
    {
        ans=max(arr[ind][pos]+dp_na_pari(ind+1,2),arr[ind][pos]+dp_na_pari(ind+1,0));
    }
    else
    {
        ans=max(arr[ind][pos]+dp_na_pari(ind+1,1),arr[ind][pos]+dp_na_pari(ind+1,0));
    }
    return dp[ind][pos]=ans;
}
int main()
{
    memset(dp,-1,sizeof dp);
   cin>>n;

   for(int i=0;i<n;i++)
   {
       for(int j=0;j<3;j++)
        cin>>arr[i][j];
   }
   int ans=INT_MIN;
   for(int i=0;i<3;i++)
    ans=max(ans,dp_na_pari(0,i));
   cout<<ans<<endl;

}


Measured memory_bytes: 12992
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;

  if ( a < b )
    cout << "a < b" << endl;
  else if ( a > b )
    cout << "a > b" << endl;
  else
    cout << "a == b" << endl;

  return 0;
}

Measured memory_bytes: 1156
n, m, k = map(int, input().split())
MOD = 998244353
ans = 0
p = 1
px = 1
py = 1
for i in range(k + 1):
    x = m * pow(m - 1, n - 1 - i, MOD) % MOD
    ans += p * x % MOD
    ans %= MOD

    px *= pow(i + 1, MOD - 2, MOD)
    py *= n - i - 1
    px %= MOD
    py %= MOD
    p = px * py % MOD
print(ans)


Measured memory_bytes: 9072
c = [list(map(int,input().split())) for i in range(3)]
if c[0][1]-c[0][0] == c[1][1]-c[1][0] == c[2][1]-c[2][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] == c[2][2]-c[2][1] and c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2] and c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2]:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
 int N[100];
 int i,n;

 scanf("%d",&n);
 
 for(i=0;i<n-1;i++){
   scanf("%d ",&N[i]);
  }
   scanf("%d",&N[n-1]);

 for(i=n-1;i>0;i--){
   printf("%d ",N[i]);
  }
   printf("%d\n",N[0]);

return 0;
}

Measured memory_bytes: 596
// atcoder/abc052/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    cout << max(a * b, c * d) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;

    int n;
    cin>>n;
    int i;
    // std::vector<int> v(n);
    int br=0;
    for (i=0;i<n;i++) {
        
        int broj;
        cin>>broj;
        if (((i+1)&1) && (broj&1))
            br++;
    }
    cout<<br<<"\n";

    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
const int LIMIT = 1e9 + 7;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define all(v) (v).begin(), (v).end()

namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}

int main(){
	ll N,D;cin>>N>>D;

  int ans = 0;
  rep(i,N){
    ll p,q;cin>>p>>q;

    if(p*p+q*q <= D*D)ans++;
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#define max 7368800
using namespace std;
int main(void){
  int m,n;
  while(1){
    cin>>m>>n;
    if(m==0)break;
    vector<bool> ans(max,true);
    int answer,t=m;
    while(n!=0){
      if(ans[t]){
	n--;
	int k=1;
	while(k*t<max){
	  ans[k*t]=false;
	  k++;
	}	
      }
      t++;
    }
    for(int i=t;i<max;i++)
      {if(ans[i]){
	  answer=i;
	  break;
	}
      }
    cout<<answer<<endl;
  }
  return 0;
}

Measured memory_bytes: 4000
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

// A - ABD
int main(){
    int N;
    cin >> N;
    
    string ans;
    if(N<=999){
        ans = "ABC";
    }else{
        ans = "ABD";
    }

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
 
int main(){
  int n;
  int t;
  int max=0;
  int min=1000000000;
  cin >> n;
  for(int i = 0; i < n; i++){
  	cin >> t; 
    if (max < t) {
      max = t;
    }
    if (min > t) {
      min = t;
    }
  }
  cout << max - min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' )
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            System.out.println(s.substring(0, 1) + (s.length() - 2) + s.substring(s.length() - 1, s.length()));
        }
    }
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main{

	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);

		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();

		long cc=b/c-(a-1)/c; //cで割り切れるもの
		long dd=b/d-(a-1)/d; //dで割り切れるもの
		long abcd=b/lcm(c,d)-(a-1)/lcm(c,d); //cとdで割り切れるもの
		System.out.println(b-a+1-cc-dd+abcd);
	}

	public static long lcm(long a,long b){
		long c=a*b;
		long temp;
		while((temp=a%b)!=0){
			a=b;
			b=temp;
		}
		return c/b;
	}
}


Measured memory_bytes: 21972