akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int n,m,s[200][2],t[1000][2],i,j,k,x,y;
int main()
{
	for(;scanf("%d",&m),m;)
	{
		for(i=0;i<m;i++)
			scanf("%d%d",&s[i][0],&s[i][1]);
		scanf("%d",&n);
		for(i=0;i<n;i++)
			scanf("%d%d",&t[i][0],&t[i][1]);
		for(i=0;i<n;i++)
		{
			x=t[i][0]-s[0][0],y=t[i][1]-s[0][1];
			for(j=1;j<m;j++)
			{
				for(k=0;k<n;k++)
					if(s[j][0]+x==t[k][0]&&s[j][1]+y==t[k][1])
						break;
				if(k==n)
					break;
			}
			if(j==m)
			{
				printf("%d %d\n",x,y);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 608
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var zahyous = createLongTuppleList(N);

			var normal = zahyous.Select(x => x.Item1 + x.Item2);
			var normalMax = normal.Max() - normal.Min();

			var cross = zahyous.Select(x => x.Item1 - x.Item2);
			var crossMax = cross.Max() - cross.Min();

			//答えの出力
			var ans = Math.Max(normalMax,crossMax);
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

Measured memory_bytes: 55076
#include<stdio.h>

int main(void){
	int A[3];
	int i = 0;
	int t, flag = 0;
	scanf("%d %d %d", &A[0], &A[1], &A[2]);
	while(1){
		if(A[0] <= A[1] && A[1] <= A[2]) break;
		if(A[i] > A[i+1]){
			t = A[i];
			A[i] = A[i+1];
			A[i+1] = t;
		}
		i++;
		if(i == 2) i = 0;
	}
	printf("%d %d %d\n", A[0], A[1], A[2]);
	return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define IFOR(i,a) for(int i=(a);;i++)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INPUT \
FILE *fp; \
fp=fopen("input.text","r");



int main() {
    int N, M, L;
    cin >> N >> M >> L;
    int a_mat[N][M],b_mat[M][L];
    long long ans[N][L];
    FOR(row, 0, N){
        FOR(column, 0, L){
            ans[row][column]=0;
        }
    }
    
    FOR(row, 0, N){
        FOR(column, 0, M){
            cin >> a_mat[row][column];
    
        }
    }
    
    FOR(row, 0, M){
        FOR(column, 0, L){
            cin >> b_mat[row][column];
        }
    }

    FOR(row, 0, N){
        FOR(column, 0, M){
            FOR(bcolumn, 0, L){
                ans[row][bcolumn] += a_mat[row][column]*b_mat[column][bcolumn];
            }
        }
    }
    FOR(row, 0, N){
        FOR(column, 0, L){
            if (column != L-1) {
                cout << ans[row][column] << " ";
            }
            else cout << ans[row][column] << endl;
        }
    }

    return 0;
}





Measured memory_bytes: 3240
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <string>
#include <iterator>
#include <tuple>
#include <regex>
using namespace std;

#define W 0
#define E 1

int main()
{
    int N, count = 0;
    string S;
    cin >> N;
    int ppl[N];
    cin >> S;
    for (int i = 0; i < N; i++) {
        switch(S[i]) {
            case 'W':
                ppl[i] = W;
                break;
            case 'E':
                ppl[i] = E;
                count++;
                break;
            default:
                cout << "ERROR" << endl;
                return 1;
        }
    }
    if (E == ppl[0]) count--;
    int rt = count;
    for (int i = 0; i < N - 1; i++) {
        if (E == ppl[i + 1]) {
            count--;
        }
        if (W == ppl[i]) {
            count++;
        }
        rt = min(rt, count);
    }
    cout << rt << endl;
    return 0;
}


Measured memory_bytes: 1796
'use strict'
 
function main(n) {
  let num = n.split("\n")[0]*1;
  let t = n.split("\n")[1].split(" ")[0]*1;
  let A = n.split("\n")[1].split(" ")[1]*1;
  let H = n.split("\n")[2].split(" ").map((e)=>{return (Math.abs(t - e*0.006 - A))});
  let ans = 0;
  let Min =Math.min(...H);
  ans = H.indexOf(Min);
  console.log(ans+1);
  
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void){
	bool ch[30],flag=true;
	int i;
	string str;
	char c;
	cin >> str;
	fill(ch,ch+30,false);
	for(i=str.size()-1; i>=0; i--){
		c = str[i]-'a';
		if(ch[c]){
			flag=false;
			break;
		}else{
			ch[c]=true;
		}
	}
	cout << ((flag)?"yes":"no") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll sum = 0;
  int res = 0;
  vector<int> dif;
  for (int i = 0; i < n; i++) {
    if (a[i] < b[i]) sum += b[i] - a[i], res++;
    else dif.emplace_back(a[i] - b[i]);
  }
  sort(dif.begin(), dif.end(), greater<int>());
  ll s = 0;
  int cnt = 0;
  for (auto e : dif) {
    cnt++;
    s += e;
    if (s >= sum) break;
  }
  if (s < sum) {
    cout << -1 << endl;
  } else {
    cout << res + (res == 0 ? 0 : cnt) << endl;
  }
  return 0;
} 

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
long N,D,A,i,x,h,cnt,ans,nowh,t;
vector<pair<int,int>>H;
queue<pair<long,int>>P;
int main(){
	cin>>N>>D>>A;
	for(i=0;i<N;i++){
		cin>>x>>h;
		H.push_back(make_pair(x,h));
	}
	sort(H.begin(),H.end());
	for(i=0;i<N;i++){
		while(!P.empty()&&P.front().first<H[i].first){
			cnt-=P.front().second;
			P.pop();
		}
		nowh=H[i].second;
		nowh-=cnt*A;
		if(nowh>0){
			t=(nowh+A-1)/A;
			ans+=t;
			cnt+=t;
			P.push(make_pair(H[i].first+D*2,t));
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3440
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> $1 = new ArrayList<>();
		ArrayList<Integer> $2 = new ArrayList<>();
		ArrayList<Integer> $3 = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			$1.add(sc.nextInt());
		}
		for (int i = 0; i < n; i++) {
			$2.add(sc.nextInt());
		}
		for (int i = 0; i < n; i++) {
			$3.add(sc.nextInt());
		}
		$1.sort(null);
		$3.sort(null);
		long ans = 0L;
		for (int i = 0; i < n; i++) {
			int s = $2.get(i);//中央を全探索
			long ok1 = 0L;
			long ok3 = 0L;
			//lower_bound
			ok1 = Collections.binarySearch($1, s, (x, y) -> (x.compareTo(y) >= 0 ? 1 : -1));
			ok1 = ok1 >= 0 ? ok1 : ~ok1;
			//upper_bound
			ok3 = Collections.binarySearch($3, s, (x, y) -> (x.compareTo(y) > 0 ? 1 : -1));
			ok3 = ok3 >= 0 ? ok3 : ~ok3;
			ok3 = n - ok3;
			//System.out.println(String.format("%sのとき$1は%s  $3は%s", s,ok1,ok3));
			ans += ok1 * ok3;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 99256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    int sum = 0;
    rep(i,n) repf(j,i+1,n) repf(k,j+1,n) {
        if (l[i]+l[j] > l[k])
            if (l[i] != l[j] && l[j] != l[k])
                sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();

		if(U.equals(S))
			A--;
		if(U.equals(T))
			B--;


		System.out.println(A + " " + B);
	}

}

Measured memory_bytes: 22996
import java.util.*;
public class Main{   
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long n = sc.nextLong();
      long m = sc.nextLong();
      char[] s = sc.next().toCharArray();
      char[] t = sc.next().toCharArray();
      long l = lcm(n,m);
      Map<Long,Character> map = new HashMap<>();
      for(long i=0;i<n;i++)map.put((l/n)*i+1,s[(int)i]);
      for(long i=0;i<m;i++){
        if(map.containsKey((l/m)*i+1)&&t[(int)i]!=map.get((l/m)*i+1)){
          System.out.println(-1);
          return;
        }
      }
      System.out.println(l);
    }
    public static long lcm(long x, long y){
      return x*y/gcd(x,y);
    }
    public static long gcd(long x, long y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}
class Pair{
    int a,b;

    Pair(int a, int b){
      this.a = a;
      this.b = b;
    }
}

Measured memory_bytes: 32952
#include<stdio.h>

int main(){
	int card[5],i,j,t;
	
	while(0<=scanf("%d,%d,%d,%d,%d",&card[0],&card[1],&card[2],&card[3],&card[4])){
		
		for(i=0;i<5;i++){
			card[i]=(card[i]+11)%13;
		}
		
		for(i=0;i<5;i++){
			for(j=i;j<5;j++){
				if(card[i]>card[j]){
					t=card[i];
					card[i]=card[j];
					card[j]=t;
				}
			}
		}
		
		if(card[0]==0 && card[1]==1 && card[2]==2 && card[3]==3 && card[4]==12){
			printf("straight\n");
			continue;
		}
		
		
		if(card[0]==card[3] || card[1]==card[4]){
			printf("four card\n");
		}else if((card[0]==card[2] && card[3]==card[4]) || (card[0]==card[1] && card[2]==card[4])){
			printf("full house\n");
		}else if(card[1]-card[0]==1 && card[2]-card[1]==1 && card[3]-card[2]==1 && card[4]-card[3]==1){
			printf("straight\n");
		}else if(card[0]==card[2] || card[1]==card[3] || card[2]==card[4]){
			printf("three card\n");
		}else if((card[0]==card[1]  && (card[3]==card[2] || card[3]==card[4])) || ((card[0]==card[1] || card[1]==card[2])&&card[3]==card[4])){
			printf("two pair\n");
		}else if(card[0]==card[1] || card[1]==card[2] || card[2]==card[3] || card[3]==card[4]){
			printf("one pair\n");
		}else{
			printf("null\n");
		}
		
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

    ll N;
    cin >> N;
    vector<vector<ll>> v(10, vector<ll>(10, 0));

    REP(i, N+1){
        if (i == 0) continue;
        int a = i % 10;
        if (a == 0) continue;
        int b = i;
        while(b >= 10) b /= 10;
        v[a][b]++;
    }
    ll ans = 0;
    for(int i = 1; i <= 9; i++) for(int j = 1; j <= 9; j++){
        ans += v[i][j] * v[j][i];
    }
    cout << ans << endl;
    return 0;
}


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


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int tt=sc.nextInt();
        int[]t=new int[n];
        for(int i=0;i<n;++i)t[i]=sc.nextInt();
        int ans=0;
        int c=t[0];
        for(int i=1;i<n;++i){
            ans+=Math.min(tt,t[i]-c);
            c=t[i];
        }
        out.println(ans+tt);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    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: 45780
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
x=int(input())
print(a[x-1])

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  long long a[n];
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  vector<long long> b(n+1);
  b[0] = 0;
  for(int i = 0; n > i; i++){
    b[i+1] = a[i]+b[i];
  }
  sort(b.begin(),b.end());
  long long nw = 1;
  long long ans = 0;
  for(int i = 1; n >= i; i++){
    if(b[i-1] != b[i]){
      ans += nw*(nw-1)/2;
      nw = 1;
    }else nw++;
  }
  ans += nw*(nw-1)/2;
  cout << ans << endl;
}
  

Measured memory_bytes: 3328
import bisect
import collections
import heapq
import math
import operator as op
from collections import Counter
from functools import reduce

import numpy as np


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():

    N, K = get_inputs(int)
    As = get_inputs(int)
    As = [None, ] + As

    prev = 1
    history = {}
    history[1] = 0
    for n_teles in range(1, K+1):
        cur = As[prev]
        if cur in history:
            # Returned to start
            len_cyc = n_teles - history[cur]
            # print("len_cyc: ", len_cyc)
            # print("K - n_teles: ", K- n_teles)
            for _ in range((K - n_teles) % len_cyc):
                cur = As[cur]
            print(cur)
            return
        else:
            prev = cur
            history[cur] = n_teles
    print(cur)

# def main():
#     N, M, X = get_inputs(int)
#     Cs = np.empty(N, dtype=np.int)
#     A_mat = np.empty((N, M), dtype=np.int)
#     for i in range(N):
#         CAs = get_inputs(int)
#         Cs[i] = CAs[0]
#         for j in range(M):
#             A_mat[i, j] = CAs[j+1]

#     if (np.sum(A_mat, axis=0) >= X).all():
#         ans = float("inf")


#     else:
#         print(-1)


#     # N, M, X = get_inputs()
#     # CAs_arr = []
#     # for _ in range(N):
#     #     CAs = get_inputs(int)
#     #     CAs_arr.append(CAs)

#     # Sums = [0 for _ in range(M)]
#     # for i in range(M):
#     #     for j in range(N):
#     #         Sums[i] += CAs_arr[j][i+1]

#     # if all([Sum >= X for Sum in Sums]):
#     #     pass
#     # else:
#     #     print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 51060
while input = $stdin.gets do
  n = input.to_i
  break if n == 0

  result = Array.new
  n.times do
    data = $stdin.gets.chomp.split(" ").map(&:to_i)
    result << [data[0],(data[1] + data[3] + data[5] + data[7]) * 60 + data[2] + data[4] + data[6] + data[8]]
  end
  rank = result.select{|d| d != nil}
  rank.sort!{|d1, d2| d1[1] <=> d2[1]}
  printf "%d\n", rank[0][0]
  printf "%d\n", rank[1][0]
  printf "%d\n", rank[rank.size - 2][0]
end

Measured memory_bytes: 6220
// Beginner161.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //A
	/*int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << '\n';*/

	//B
	int n, m;
	cin >> n >> m;
	vector<int> a(n);

	int c = 0;
	double t = 1.0 / (4 * m);

	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		double aCoef = a[i] * 1.0 / sum;
		if (aCoef >= t) c++;
	}
	
	cout << (c >= m ? "Yes" : "No");
	
}



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

int main(){
  long long h,i,ans;
  cin >> h;
  i=0;
  ans=0;
  while(h>1){
    ans=ans+pow(2,i);
    h=h/2;
    i++;
  }
  ans=ans+pow(2,i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

void AddNote(int note, vector<int> &ops)
{
    for (int i = 0; i + note < (int)ops.size(); i += 1) {
        ops[i + note] = min(ops[i + note], ops[i] + 1);
    }
}

void AddPowers(int base, vector<int> &ops)
{
    for (int note = base; note < (int)ops.size(); note *= base) {
        AddNote(note, ops);
    }
}

int main()
{
    int n;
    cin >> n;

    vector<int> ops(n + 1, 0);
    iota(ops.begin(), ops.end(), 0);

    AddPowers(6, ops);
    AddPowers(9, ops);

    cout << ops[n] << "\n";
    return 0;
}


Measured memory_bytes: 640
import sys;

def mul_matrix(a, b):
    n = len(a);
    m = len(b);
    l = len(b[0]);
    
    ans = [];

    for i in range(n):
        new_row = [];
        for j in range(l):
            sum = 0;
            for k in range(m):
                sum += a[i][k] * b[k][j];

            new_row.append(sum);

        ans.append(new_row);
    
    return ans;

def main():
    n, m, l = [int(i) for i in sys.stdin.readline().strip().split(' ')];
    
    a = [];
    b = [];
    
    for i in range(n):
        data = [int(j) for j in sys.stdin.readline().strip().split(' ')];
        a.append(data);

    for i in range(m):
        data = [int(j) for j in sys.stdin.readline().strip().split(' ')];
        b.append(data);

    ans = mul_matrix(a, b);

    for i in ans:
        print(' '.join([str(j) for j in i]));
        
if __name__ == '__main__':
    main();


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    if (s.front() == 'S') cout << "Cloudy" << endl;
    else if (s.front() == 'C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for (int i = l; i <= r; ++ i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c;
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("c.in", "r", stdin);
	freopen("c.out", "w", stdout);
}

const int N = 1e5 + 10;
int n, a[N], t1[N], t2[N];

int main() {
	n = read();
	For(i, 1, n) a[i] = read();
	
	int s1 = 0, s2 = 0;
	For(i, 1, n) {
		if (i & 1) ++ t1[a[i]];
		else ++ t2[a[i]];
	}

	int res1 = 0, res2 = 0, max1 = 0, max2 = 0;
	int mx1 = 0, mx2 = 0, tt1 = 0, tt2 = 0;

	For(i, 1, 100000) {
		if (t1[i]) {
			++ s1;
			if (res1 < t1[i]) {
				mx1 = res1, tt1 = max1;
				res1 = t1[i], max1 = i;
			} else if (t1[i] > mx1) {
				mx1 = t1[i], tt1 = i;
			}
		}
		if (t2[i]) {
			++ s2;
			if (res2 < t2[i]) {
				mx2 = res2, tt2 = max2;
				res2 = t2[i], max2 = i;
			} else if (t2[i] > mx2) {
				mx2 = t2[i], tt2 = i;	
			}
		}
	}
	
	int ans;
	if (max1 != max2) {
		ans = n - t1[max1] - t2[max2];	
	} else {
		if (t1[max1] + t2[tt2] > t2[max2] + t1[tt1]) {
			ans = n - t1[max1] - t2[tt2];
		} else ans = n - t1[tt1] - t2[max2];
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
int min(int a,int b){return a<b?a:b;}
bool a[710][710];
int c[710],n,M1,M2;
bool dfs(int x,int f){
	if(c[x])return c[x]!=f;
	c[x]=f;
	M1+=f==2;
	M2+=f==3;
	for(int i=1;i<=n;i++){
		if(a[x][i]&&dfs(i,f^1))return 1;
	}
	return 0;
}
bool t1[710],t2[710];
int s2(int n){return n*(n-1)/2;}
int main(){
	int m,i,j,x,y,ans;
	scanf("%d%d",&n,&m);
	for(i=1;i<n;i++){
		for(j=i+1;j<=n;j++)a[i][j]=a[j][i]=1;
	}
	while(m--){
		scanf("%d%d",&x,&y);
		a[x][y]=a[y][x]=0;
	}
	t1[0]=1;
	for(i=1;i<=n;i++){
		if(!c[i]){
			M1=M2=0;
			if(dfs(i,2)){
				puts("-1");
				return 0;
			}
			memset(t2,0,sizeof(t2));
			for(j=0;j<=n;j++){
				if(t1[j])t2[j+M1]=t2[j+M2]=1;
			}
			memcpy(t1,t2,sizeof(t2));
		}
	}
	ans=2147483647;
	for(i=1;i<n;i++){
		if(t1[i])ans=min(ans,s2(i)+s2(n-i));
	}
	printf("%d",ans);
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//20
        int a = sc.nextInt();//2
        int b = sc.nextInt();//5
//        int n = 20;
//        int a = 2;
//        int b = 5;

        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            int res = 0;
            String str = Integer.toString(i);
            for (int j = 0; j < str.length(); j++) {
                res += Character.getNumericValue(str.charAt(j));
            }
            if(a <= res && res <= b){
                list.add(i);
            }
        }

        int total = 0;
        for (Integer integer : list) {
            total += integer;
        }

        System.out.println(total);
    }
}


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

int mid[200005], ans[200005];
int n,ar[200005];
int main()
{
    int mod = 1e9 + 7;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",ar+i);
    ar[0]=-1;
    ans[0]=1;
    for(int i=1;i<=n;i++){
        ans[i] += ans[i-1];
        ans[i] %= mod;
        if(ar[i] != ar[i-1]){
            ans[i] += mid[ar[i]];
            ans[i] %= mod;
            mid[ar[i]] += ans[i-1];
            mid[ar[i]] %= mod;
        }
    }
    printf("%d\n",ans[n]);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using LL = long long;
using P = pair<int,int>;


int main(){
	LL N;
	cin >> N;
	LL tmp = N;
	int S = 0;
	while(tmp){
		S += tmp%10;
		tmp /= 10;
	}
	if(N%S==0) cout << "Yes" << endl;
	else cout << "No" << endl;

}










Measured memory_bytes: 3584
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//30min
int main(void){
  int n;
  int a, b;
  int p[101];
  int cnt1 = 0, cnt2 = 0, cnt3 = 0;
  int ans = 0;;

  scanf("%d%d%d", &n, &a, &b);

  for(int cnt = 1; cnt <= n; cnt++){
    scanf("%d", &p[cnt]);
    if(p[cnt] <= a){
      cnt1++;
    }else if(p[cnt] < b || p[cnt] <= b){
      cnt2++;
    }else if(p[cnt] > b){
      cnt3++;
    }
  }
  ans = cnt1;
  if(ans > cnt2){
    ans = cnt2;
  }
  if(ans > cnt3){
    ans = cnt3;
  }
  
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int	main()
{
	int	A, B, C;
	int	a, b;
	int	count = 0;

	scanf("%d %d %d\n", &A, &B, &C);
	while (!(A % 2 || B % 2 || C % 2))
	{
		if (A == B && B == C)
		{
			count = -1;
			break ;
		}
		a = A;
		b = B;
		A = (B + C) / 2;
		B = (a + C) / 2;
		C = (a + b) / 2;
		count++;
		//printf("%d %d %d\n", A, B, C);
	}
	printf("%d\n", count);
	return (0);
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
signed main() {
	string s;
	cin >> s;
	if (s.size() < 7)puts("NO");
	else {
		if (s[0] == 'k'&&s[1] == 'e'&&s[2] == 'y'&&s[3] == 'e'&&s[4] == 'n'&&s[5] == 'c'&&s[6] == 'e')puts("YES");
		else if (s[s.size() - 7] == 'k'&&s[s.size() - 6] == 'e'&&s[s.size() - 5] == 'y'&&s[s.size() - 4] == 'e'&&s[s.size() - 3] == 'n'&&s[s.size() - 2] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else if (s[0] == 'k'&&s[s.size() - 6] == 'e'&&s[s.size() - 5] == 'y'&&s[s.size() - 4] == 'e'&&s[s.size() - 3] == 'n'&&s[s.size() - 2] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else if (s[0] == 'k'&&s[1] == 'e'&&s[s.size() - 5] == 'y'&&s[s.size() - 4] == 'e'&&s[s.size() - 3] == 'n'&&s[s.size() - 2] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else if (s[0] == 'k'&&s[1] == 'e'&&s[2] == 'y'&&s[s.size() - 4] == 'e'&&s[s.size() - 3] == 'n'&&s[s.size() - 2] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else if (s[0] == 'k'&&s[1] == 'e'&&s[2] == 'y'&&s[3] == 'e'&&s[s.size() - 3] == 'n'&&s[s.size() - 2] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else if (s[0] == 'k'&&s[1] == 'e'&&s[2] == 'y'&&s[3] == 'e'&&s[4] == 'n'&&s[s.size() - 2] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else if (s[0] == 'k'&&s[1] == 'e'&&s[2] == 'y'&&s[3] == 'e'&&s[4] == 'n'&&s[5] == 'c'&&s[s.size() - 1] == 'e')puts("YES");
		else puts("NO");
	}
	ll
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
	re 0;
}

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

#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
using namespace std;

int main(){
  while(1){
    int r,w,c,g;
    cin>>r>>w>>c>>g;
    if(r==0&&w==0&&c==0&&g==0) break;
    int x=0;
    while(1){
      double a;
      a=r/w;
      if(a>=c) break;
      else{
	r+=g;
	x++;
      }
    }
    cout<<x<<endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int N; cin >> N;
	int AC = 0;
	int WA = 0;
	int TLE = 0;
	int RE = 0;

	for (int i = 0; i < N; i++) {
		string s; cin >> s;
		if (s == "AC") {
			AC++;	
		}else if (s == "WA") {
			WA++;
		}else if (s == "TLE") {
			TLE++;
		}else if (s == "RE") {
			RE++;
		}
	}
	
	cout << "AC x " << AC << endl;
	cout << "WA x " << WA << endl;
	cout << "TLE x " << TLE << endl;
	cout << "RE x " << RE << endl;

	return 0;
}


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

int main()
{
    int N;
    vector<int> H;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        H.push_back(temp);
    }
    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        bool flag = true;
        for (int j = 0; j < i; j++)
        {
            if (H[i] < H[j])
            {
                flag = false;
            }
        }
        cnt += flag ? 1 : 0;
    }
    cout << cnt;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define int long long

int a, b;
signed main(){
    cin >> a >> b;
    string sa, sb;
    rep(i,b) sa.push_back('0'+a);
    rep(i,a) sb.push_back('0'+b);
    cout << min(sa,sb) << endl;
}

Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int N;
    int i;

    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        i = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println(Math.max(1, N - i + 1));
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
//
//  main.cpp
//  B
//
//  Created by 黄宇凡 on 2017/3/18.
//  Copyright © 2017年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <cstdio>

using namespace std;
int X;
int main(int argc, const char * argv[]) {
    cin >> X;
    int i = 0;
    int sum = 0;
    while(true){
        if(sum >= X) break;
        //if(sum > X && ((sum & 1) == (X & 1))) break;
        i++;
        sum += i;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
#define int long long
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
using namespace std;
#define hash hush
typedef long long ll;
typedef long double ld;
signed  main() {
	string a,b;
	cin>>a>>b;
	string ans="";
	for(int i=0;i<b.size();i++){
		ans+=a[i];
		ans+=b[i];
	}
	if(b.size()!=a.size()){
		ans+=a[a.size()-1];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
B = [list(map(int,input().split())) for _ in range(M)]
B.insert(0,0)
for i in range(N):
    a,b = A[i]
    dmin = 10**9
    ind = M
    for j in range(M,0,-1):
        c,d = B[j]
        dist = abs(a-c)+abs(b-d)
        if dist<=dmin:
            dmin = dist
            ind = j
    print(ind)

Measured memory_bytes: 67172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var t = sc.intarr;
        int a = t[0];
        int b = t[1];
        int c = t[2];
        int d = t[3];

        if (Math.Abs(a - c) <= d || (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d))
        {
            wr.wri("Yes");
        }
        else wr.wri("No");


    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
#include<iostream>

using namespace std;

int main(){
  string s1,s2;
  cin>>s1;
  cin>>s2;
  bool flag=(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]);
  string ret=flag?"YES\n":"NO\n";
  cout<<ret;
  return 0;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n+1, 0);
    for (int i = 0, a; i < n-1; ++i) {
        cin >> a;
        v[a]++;
    }

    for (int i = 1; i <= n; ++i)
        cout << v[i] << '\n';

    return 0;
}



Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, tmpa;
    vector<ll> a;
    cin >> n;
    rep(i, n){
        cin >> tmpa;
        a.push_back(tmpa);
    }

    bool flg = true;
    int res = 0;
    while(flg){
        flg = false;
        rep(i, n){
            if(a[i]%2 == 0){
                a[i] /= 2;
                res++;
                flg = true;
                break;
            }
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1e6+5;

const ll mod=1e9+7;

char s[maxn];

int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	ll ans=n/(a+b)*a;
	if(n%(a+b)<=a){
		ans+=n%(a+b);
	}
	else ans+=a;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
class Unionfind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def root (self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def connect(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def isConnect(self, x):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.parents[self.root(x)]

N, K = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
C = list(map(int, input().split()))

INF = 10 ** 18
ans = -INF
dp = [[-INF] * (N + 1) for _ in range(N)]
uf = Unionfind(N)

for i in range(N):
    dp[i][0] = 0
    now = i
    for j in range(min(N, K)):
        now = P[now]
        dp[i][j + 1] = dp[i][j] + C[now]
        uf.connect(i, now)
        ans = max(ans, dp[i][j + 1])

for i in range(N):
    M = uf.size(i)
    if dp[i][M] <= 0:
        continue
    roop = K // M
    move = K % M
    if move == 0:
        roop -= 1
        move = M
    for j in range(move):
        ans = max(ans, dp[i][M] * roop + dp[i][j + 1])

print(ans)


Measured memory_bytes: 271260
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        char[] s = sc.nextLine().toCharArray();
        int ans = 0;
        int tmp = 0;
        for (char c : s) {
            if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
                tmp++;
            } else {
                ans = Math.max(ans, tmp);
                tmp = 0;
            }
        }
        System.out.println(Math.max(ans, tmp));
    }
}


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

int main() {
    string s; cin >> s;
    string ans = "";
    for(int i = s.size()-1; i > 0; i -=2) {
        s.erase(s.begin()+i);
        s.erase(s.begin()+i-1);
        string s1 = "";
        string s2 = "";
        for(int j = 0; j < s.size()/2; j ++) s1 += s[j];
        for(int j = s.size()/2; j < s.size(); j ++) s2 += s[j];
        if(s1==s2) {
            ans = s1;
            break;
        }
    }
    cout << ans.size()*2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int [][] in = new int [N][3];
		int [] out = new int [N];
		int c = 0;
		
		for(int i = 0; i < N; i++){
			out[i] = 0;
		}
		for(int j = 0; j < N; j++){
			for(int k = 0; k < 3; k++){
				in[j][k] = sc.nextInt();
		}
	}
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < N; j++){
				c = 0;
				for(int k = 0; k < N; k++){
					if(j != k){
						if(in[j][i] == in[k][i]){
							in[k][i] = 0;
							c = 1;
						}
						if(k == N-1){
							if(c == 1){
								in[j][i] = 0;
							}
						}
					}
				}
			}
		}
		for(int j = 0; j < 3; j++){
			for(int i = 0; i < N; i++){
				out[i] += in[i][j];
			}
		}
		for(int i = 0; i < N; i++){
			System.out.println(out[i]);
		}
		// TODO Auto-generated method stub
	}

}

Measured memory_bytes: 20828
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		long n = sc.nextLong(),k = sc.nextLong();
		long mod = n%k;
		long ans = Math.min(mod, Math.abs(k-mod));
		out.println(ans);
		out.close();
	}
	static void shuffle(int[] array) {
		Random rand = new Random();
		for (int i = 0; i < array.length; i++) {
			int randomIndexToSwap = rand.nextInt(array.length);
			int temp = array[randomIndexToSwap];
			array[randomIndexToSwap] = array[i];
			array[i] = temp;
		}
	}
	static boolean isPalindrome(String s) {
		int l = s.length();
		char[] sa = s.toCharArray();
		for(int i=0;i<l/2;i++) {
			if(sa[i] != sa[l-i-1])
				return false;
		}
		return true;
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			return a;
		}
	}

}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void) {
	int y1,m1,d1,y2,m2,d2,s,f,i;
	while(scanf("%d%d%d%d%d%d",&y1,&m1,&d1,&y2,&m2,&d2) , y1 > 0 && m1 > 0 && d1 > 0 && y2 > 0 && m2 > 0 && d2 > 0){
		s = 0;f = 0;
		for(i = 1;i < y1;i++){
			if((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){s+=366;}
			else{s+=365;}
		}
		if((y1 % 4 == 0 && y1 % 100 != 0) || y1 % 400 == 0){
			if(m1 == 1){s+=d1;}
			if(m1 == 2){s+=(31+d1);}
			if(m1 == 3){s+=(60+d1);}
			if(m1 == 4){s+=(91+d1);}
			if(m1 == 5){s+=(121+d1);}
			if(m1 == 6){s+=(152+d1);}
			if(m1 == 7){s+=(182+d1);}
			if(m1 == 8){s+=(213+d1);}
			if(m1 == 9){s+=(244+d1);}
			if(m1 == 10){s+=(274+d1);}
			if(m1 == 11){s+=(305+d1);}
			if(m1 == 12){s+=(335+d1);}
		}
		else{
			if(m1 == 1){s+=d1;}
			if(m1 == 2){s+=(31+d1);}
			if(m1 == 3){s+=(59+d1);}
			if(m1 == 4){s+=(90+d1);}
			if(m1 == 5){s+=(120+d1);}
			if(m1 == 6){s+=(151+d1);}
			if(m1 == 7){s+=(181+d1);}
			if(m1 == 8){s+=(212+d1);}
			if(m1 == 9){s+=(243+d1);}
			if(m1 == 10){s+=(273+d1);}
			if(m1 == 11){s+=(304+d1);}
			if(m1 == 12){s+=(334+d1);}
		}
		for(i = 1;i < y2;i++){
			if((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){f+=366;}
			else{f+=365;}
		}
		if((y2 % 4 == 0 && y2 % 100 != 0) || y2 % 400 == 0){
			if(m2 == 1){f+=d2;}
			if(m2 == 2){f+=(31+d2);}
			if(m2 == 3){f+=(60+d2);}
			if(m2 == 4){f+=(91+d2);}
			if(m2 == 5){f+=(121+d2);}
			if(m2 == 6){f+=(152+d2);}
			if(m2 == 7){f+=(182+d2);}
			if(m2 == 8){f+=(213+d2);}
			if(m2 == 9){f+=(244+d2);}
			if(m2 == 10){f+=(274+d2);}
			if(m2 == 11){f+=(305+d2);}
			if(m2 == 12){f+=(335+d2);}
		}
		else{
			if(m2 == 1){f+=d2;}
			if(m2 == 2){f+=(31+d2);}
			if(m2 == 3){f+=(59+d2);}
			if(m2 == 4){f+=(90+d2);}
			if(m2 == 5){f+=(120+d2);}
			if(m2 == 6){f+=(151+d2);}
			if(m2 == 7){f+=(181+d2);}
			if(m2 == 8){f+=(212+d2);}
			if(m2 == 9){f+=(243+d2);}
			if(m2 == 10){f+=(273+d2);}
			if(m2 == 11){f+=(304+d2);}
			if(m2 == 12){f+=(334+d2);}
		}
		printf("%d\n",f-s);
	}
	return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n,k,h[100005],dp[100005];
void solve(){
    cin>>n>>k;
    rep(i,1,n+1) cin>>h[i];
    h[0]=hell;
    rep(i,1,n+1){
        if(i==1) dp[i]=0;
        else{
            dp[i]=hell;
            rep(j,max(1LL,i-k),i){
                dp[i]=min(dp[j]+abs(h[j]-h[i]),dp[i]);
            }
        }
    }
    cout<<dp[n]<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);printf("%d\n",a*b/2);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int i,N;
	cin>>N;
	for(i=1;i<10;i++){
		if(N<=111*i){
			cout<<111*i;
			break;
		}
	}
}


Measured memory_bytes: 256