akhauriyash/Code-Regression huggingface dataset:
import java.io._
import java.util.StringTokenizer

/**
  * @author Aydar Gizatullin a.k.a. lightning95 on 30.05.17.
  */

object Main {

  def main(args: Array[String]) {
    val rw = new RW("input.txt", "output.txt")
    val n = rw.nextInt
    val m = rw.nextInt
    rw.println(if (n % 3 == 0 || m % 3 == 0 || (n + m) % 3 == 0) "Possible" else "Impossible")
    /* val n = rw nextInt
     var beg = false
     var mid = false
     var end = false
     var last = 0
     var ok = true
     for (_ <- 1 to n) {
       val x = rw.nextInt
       if (last < x) {
         if (!mid && !end)
           beg = true
         else
           ok = false
       }
       if (x == last) {
         if (end)
           ok = false
         else
           mid = true
       }
       if (last > x)
         end = true

       last = x
     }

     rw println (if (ok) "YES" else "NO")*/
    rw.close()
  }

  class RW(val inputFile: String, val outputFile: String) {
    private var br = new BufferedReader(new InputStreamReader(System.in))
    private var out = new PrintWriter(new OutputStreamWriter(System.out))

    private val f = new File(inputFile)
    if (f.exists && f.canRead)
      try {
        br = new BufferedReader(new FileReader(inputFile))
        out = new PrintWriter(new FileWriter(outputFile))
      } catch {
        case e: IOException =>
          e.printStackTrace()
      }

    private var st = null: StringTokenizer
    var eof = false

    def nextLine: String = {
      var s = ""
      try
        s = br.readLine()
      catch {
        case e: IOException =>
          e.printStackTrace()
      }
      s
    }

    def next: String = {
      while (st == null || !st.hasMoreTokens)
        try
          st = new StringTokenizer(br.readLine)
        catch {
          case _: IOException =>
            eof = true
            ""
        }
      st.nextToken
    }

    def nextLong: Long = next.toLong

    def nextInt: Int = next.toInt

    def println(): Unit = out.println()

    def println(o: Any): Unit = out.println(o)

    def print(o: Any): Unit = out.print(o)

    def close(): Unit = {
      try
        br.close()
      catch {
        case e: IOException =>
          e.printStackTrace()
      }

      out.close()
    }
  }

}



Measured memory_bytes: 25532
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep (i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
class alp
{
public:
	int start;
	int end;
	int count;

	alp()
	{
		start = 0;
		end = 0;
		count = 0;
	}
};

/* TLE
int t_start = -1;
int t_end = -1;

bool check(string s, int start, int end)
{
	alp a[26];
	if (end - start < 1)
	{
		return false;
	}
	for (int i = start; i <= end; i++)
	{
		int index = s[i-1] - 97;

		//cout << index << endl;
		if (a[index].count == 0)
		{
			a[index].start = i;
		}

		a[index].count++;
		a[index].end = i;
	}

	int max = 0;
	for (int i = 0; i < 26; i++)
	{
		if (a[i].count > a[max].count)
		{
			max = i;
		}
	}
	//cout << "max="<< max << endl;
	if (a[max].count <= (end - start + 1) / 2)
	{
		if (!check(s, start + 1, end))
		{
			check(s, start, end - 1);
		}
	}
	else
	{
		t_start = start;
		t_end = end;
		return true;
	}
	return false;
}
*/

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

	string s;
	
	cin >> s;

	
	alp a[26];

	for (int i = 1; i <= s.size(); i++)
	{
		int index = s[i-1] - 97;

		//cout << index << endl;
		if (a[index].count == 0)
		{
			a[index].start = i;
		}

		a[index].count++;
		a[index].end = i;
	}

	/*
	int max = 0;
	for (int i = 0; i < 26; i++)
	{
		if (a[i].count > a[max].count)
		{
			max = i;
		}
	}
	//cout << "max="<< max << endl;
	if (a[max].count < s.size() / 2)
	{
		cout << "-1 -1" << endl;
		return 0;
	}
	cout << a[max].start << " " << a[max].end << endl;
	*/

	for (int i = 0; i < 26; i++)
	{
		int span = a[i].end - a[i].start + 1;
		if (a[i].count > span / 2)
		{
			cout << a[i].start << " " << a[i].end << endl;
		}
	}
	/*
	check(s, 1, s.size());

	cout << t_start << " " << t_end << endl;
	*/
	return 0;
}
#endif
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	string s;
	
	cin >> s;

	int i = 0;
	for (i = 0; i < s.size(); i++)
	{
		if (i < s.size() - 1)
		{
			if (s[i+1] == s[i])
			{
				cout << i+1 << " " << i+2 << endl;
				break;
			}
			else if (i < s.size() - 2)
			{
				if (s[i] == s[i+2])
				{
					cout << i+1 << " " << i + 3 << endl;
					break;
				}
			}
		}
	}

	if (i == s.size())
	{
		cout << "-1 -1" << endl;
	}
}

Measured memory_bytes: 512
#include <stdio.h>
int N;
int L;
int a[100001];
int main(){
  int i,j;
  int flag=0;
  scanf("%d %d",&N,&L);
  for(i=1;i<=N;i++)scanf("%d",&a[i]);
  for(i=1;i<N;i++){
    if(a[i]+a[i+1]>=L)flag=1;
  }
  if(flag==0){
    printf("Impossible\n");
    return 0;
  }
  printf("Possible\n");
  i=1;
  while(i<N){
    if(a[i]+a[i+1]>=L)break;
    i++;
  }
  for(j=1;j<i;j++)printf("%d\n",j);
  for(j=N-1;j>i;j--)printf("%d\n",j);
   printf("%d\n",i);
  return 0;
}


Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

def eratosthenes_sieve(n):
    table = [0] * (n + 1)
    prime_list = []
    
    for i in xrange(2, n + 1):
        if table[i] == 0:
            prime_list.append(i)
            for j in xrange(i + i, n + 1, i):
                table[j] = 1
    
    return prime_list

def trial_division_sqrt(n):
    prime_count = collections.Counter()
    
    for i in xrange(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    
    for p, c in prime_count.iteritems():
        prime_count[p] = c % 3
    
    return prime_count

def trial_division_prime(n, prime_list):
    prime_count = collections.Counter()
    
    for i in prime_list:
        if i * i > n:
            break
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1
    
    for p, c in prime_count.iteritems():
        prime_count[p] = c % 3
    
    return prime_count

N = n()

A = []
for i in xrange(N):
    A.append(n())

result = A[0] - 1
th = 2
#print 1
for a in A[1:]:
    if a > th:
        num = (a - 1) / th
        rest = a - th * num
        a = rest
        result += num
        if rest > th:
            th = rest
#        print rest
    elif a == th:
        th = a + 1
#        print a
#    else:
#        print a
#    print 'th', th

#print
print result


Measured memory_bytes: 29592
#include<bits/stdc++.h>
using namespace std;
char s[100005];
map<int , int> m;


int main()
{
	int i,j;
	long long totalsum;
	
	scanf("%s",s);
	
	char dream[]="dream";
	totalsum=0;
	for(i=4;i>=0;i--)
	{
		totalsum *= 67;
		totalsum += dream[i];
		totalsum %= 1000000007;
	}
//	printf("dream %d\n",totalsum);
	m[totalsum] = 1;
	
	char dreamer[]="dreamer";
	totalsum=0;
	for(i=6;i>=0;i--)
	{
		totalsum *= 67;
		totalsum += dreamer[i];
		totalsum %= 1000000007;
	}
//	printf("dreamer %d\n",totalsum);
	m[totalsum] = 1;
	
	char erase[]="erase";
	totalsum=0;
	for(i=4;i>=0;i--)
	{
		totalsum *= 67;
		totalsum += erase[i];
		totalsum %= 1000000007;
	}
//	printf("erase %d\n",totalsum);
	m[totalsum] = 1;
	
	char eraser[]="eraser";
	totalsum=0;
	for(i=5;i>=0;i--)
	{
		totalsum *= 67;
		totalsum += eraser[i];
		totalsum %= 1000000007;
	}
//	printf("eraser %d\n",totalsum);
	m[totalsum] = 1;
	
	totalsum = 0;
	int len = strlen(s);
	for(i=len-1;i>=0;i--)
	{
		totalsum *= 67;
		totalsum += s[i];
		totalsum %= 1000000007;
		
	//	printf("%d\n",totalsum);
		if(m[totalsum] == 1)
		{
			totalsum = 0;
		}
	}
	if(totalsum==0) printf("YES\n");
	else printf("NO\n");
	
	
}

Measured memory_bytes: 7352
#include<stdio.h>
int main(void){
	int n,m,i,j;
	int A[100][100];
	int B[100];
	int x=0;
	
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(i=0;i<m;i++)scanf("%d",&B[i]);
	
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			x+=B[j]*A[i][j];
		}
		printf("%d\n",x);
		x=0;
	}
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int h, w; cin >> h >> w;
        if(h == 0 and w == 0) return 0;
        else{
            int ansH = 0, ansW = 0;
            
            int sqMin = INF;
            int i, j;
            [&]{
                for(int i = 0; j * j + i * i <= w * w + h * h; i++){
                    for(int j = i + 1; j * j + i * i <= w * w + h * h; j++){
                        int men = (i + 1) * (i + 1) + (j + 1) * (j + 1);
                        if(i + 1 == h and j + 1 == w) continue;
                        if(men == h * h + w * w and (i + 1) > h){
                            ansH = i + 1;
                            ansW = j + 1;
                            return ;
                        }
                        else if(men > h * h + w * w and sqMin > men){
                            sqMin = men;
                            ansH = i + 1;
                            ansW = j + 1;
                        }
                    }
                }
            }();
            cout << ansH << " " << ansW << endl;
            
        }
    }
}


Measured memory_bytes: 3104
n, k = map(int, input().split())

l = list(map(int, input().split()))
l = [(i+1)/2 for i in l]

ls = [0, l[0]]
for i in range(1, n):
    ls.append(ls[-1]+l[i])

if n == 1:
    print(l[0])
else:
    lans = [ls[i+k]-ls[i] for i in range(len(ls)-k)]
    print(max(lans))

Measured memory_bytes: 25060
#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>;

//ABC 082 b.cpp
int main() {
    string s,t;
    cin >>s>>t;
    vector<int> sv(s.size()),tv(t.size());
    rep(i,s.size()) sv[i] = s[i] - 'a';
    rep(i,t.size()) tv[i] = t[i] - 'a';

    sort(sv.begin(),sv.end());
    sort(tv.begin(),tv.end(),greater<int>());

    rep(i,s.size()){
        if(tv[i]<sv[i]){
            cout << "No" << endl;
            break;
        }else if(tv[i] > sv[i]){
            cout << "Yes" << endl;
            break;
        }

        if(i == s.size()-1){
            if(t.size() > s.size()){
                cout <<"Yes"<<endl;
            }else cout << "No" << endl;
        }
    }

}

Measured memory_bytes: 3636
open System.IO
open System

let sw = new StreamWriter(Console.OpenStandardOutput())
sw.AutoFlush <- false

let _n = stdin.ReadLine() |> int64
let _a = stdin.ReadLine().Split() 

let memoize fn = 
    let cache = new System.Collections.Generic.Dictionary<_,_>()
    (fun x ->
    match cache.TryGetValue x with
    | true, v -> v
    | false, _ -> 
        let v = fn (x)
        cache.Add(x,v)
        v)

/// nC2
let c2 n = n * (n - 1L) / 2L
let memC2 = memoize c2

let countByA =  _a |> Array.countBy id |>Map.ofArray

// 全部の答えを出して余分な数を引く方針
let ansWhole = 
    countByA
    |> Seq.map (fun x -> memC2 (int64 x.Value))
    |> Seq.sum

let unNeeded aNum = 
    let x = int64 countByA.[aNum]
    // xC2 - (x-1)C2 = x-1
    x-1L

let memUnNeeded = memoize unNeeded
/// それぞれの答え
let ansEach aNum = ansWhole - memUnNeeded aNum |> string

_a
|> Seq.map ansEach
|> Seq.iter stdout.WriteLine

stdout.Flush()

Measured memory_bytes: 64108
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   cout << fixed << setprecision(20);

   long long a,b,c; cin >> a >> b >> c;
   long long d=c-a-b;
   if(0<d and d*d>4*a*b) cout << "Yes" << endl;
   else cout << "No"<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,max=0,min=0,ans1[100],ans2[100],count=0;
  long int a[50];
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(a[max]<a[i])max=i;
    if(a[min]>a[i])min=i;
  }
  if(a[max]==a[min]){
    puts("0");
    return 0;
  }
  else if(abs(a[min])<=abs(a[max])){
    for(i=1;i<n;i++){
      while(a[i-1]>a[i]){
        a[i]+=a[max];
        ans1[count]=max+1;
        ans2[count]=i+1;
        count++;
      }
      if(a[max]<=a[i])
        max=i;
    }
  }
  else {
    for(i=n-2;i>=0;i--){
      while(a[i+1]<a[i]){
        a[i]+=a[min];
        ans1[count]=min+1;
        ans2[count]=i+1;
        count++;
      }
      if(a[min]>=a[i])
        min=i;
    }
  }
  printf("%d\n",count);
  for(i=0;i<count;i++) printf("%d %d\n",ans1[i],ans2[i]);
  return 0;
}

Measured memory_bytes: 128
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<numeric>
#include<deque>
using namespace std;
typedef long long ll;
const int N = 400000 + 5;
const int MOD = (int)1e9 + 7;
ll F[N], Finv[N], inv[N];//F是阶乘，Finv是逆元的阶乘 
void init(){
 inv[1] = 1;
 for(ll i = 2; i < N; i ++){
     inv[i] = (MOD - MOD / i) * 1ll * inv[MOD % i] % MOD;
 }
 F[0] = Finv[0] = 1;
 for(ll i = 1; i < N; i ++){
     F[i] = F[i-1] * 1ll * i % MOD;
     Finv[i] = Finv[i-1] * 1ll * inv[i] % MOD;
 }
}
ll comb(ll n, ll m){//comb(n, m)就是C(n, m) 
 if(m < 0 || m > n) return 0;
 return F[n] * 1ll * Finv[n - m] % MOD * Finv[m] % MOD;
}//更厉害的组合数
int main()
{
	ll n, k;
	init();
	cin >> n >> k;
	ll ans;
	ans = comb(2 * n - 1, n - 1);
	ll mm = n - 1 - k;
	//cout<<ans<<endl;
	for (ll m = 1; m <= mm; m++)
	{
		ans = ans + MOD - (comb(n, n - m) * comb(n - 1, m - 1)) % MOD;
		ans %= MOD;
	}
	cout << ans%MOD << endl;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W, N;
char S[330][330];
int A[620][620];
int acc[620][620];

i64 ret;

void solve()
{
	for (int i = 0; i < N; ++i) {
		acc[i][0] = 0;
		for (int j = 0; j < N; ++j) {
			acc[i][j + 1] = acc[i][j] + A[i][j];
		}
	}

	for (int y = 0; y < N; ++y) {
		for (int x = 0; x < N; ++x) {
			if (A[y][x] == 0) continue;
			for (int x2 = x + 1; x2 < N; ++x2) {
				if (A[y][x2] == 0) continue;

				int d = x2 - x;
				if (y + d < N) {
					ret += acc[y + d][x2] - acc[y + d][x + 1];
					ret += A[y + d][x];
				}
			}
		}
	}
}
int A2[620][620];
void rot()
{
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			A2[i][j] = A[j][N - 1 - i];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			A[i][j] = A2[i][j];//[j][N - 1 - i];
		}
	}
}
int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) scanf("%s", S[i]);

	N = H + W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (S[i][j] == '#') {
				int x = i + j;
				int y = i - j + W - 1;
				A[x][y] = 1;
			}
		}
	}

	ret = 0;
	solve(); rot();
	solve(); rot();
	solve(); rot();
	solve(); rot();

	printf("%lld\n", ret);

	return 0;
}


Measured memory_bytes: 4736
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int M=5000001;
		for(;;)
		{
			int c=in.nextInt();//チケットの数
			int n=in.nextInt(),m=in.nextInt();//バス停の数,道の数
			int s=in.nextInt(),d=in.nextInt();//スタート&ゴール
			if((c|n|m|s|d)==0)
				return;
			int cost[][]=new int[n+1][n+1];
			for(int i=0;i<=n;i++)
				Arrays.fill(cost[i], M);
//			for(int q[]: cost) {
//				Arrays.fill(q, M);
//			}
			for(int i=1;i<=n;i++)
				cost[i][i]=0;
			for(int i=0;i<m;i++)
			{
				int a=in.nextInt();
				int b=in.nextInt();
				int f=in.nextInt();
				cost[a][b]=f;
				cost[b][a]=f;
			}
			int p=0,w=0;
			int v[][] = new int[n+1][c+1];// decision flag
			int leng[][]=new int[n+1][c+1];// minimum distance
			for(int i=0;i<=n;i++)
				for(int k=0;k<=c;k++)
				{
					leng[i][k]=M;
					v[i][k]=0;
				}
			leng[s][c]=0;
			for(;;)
			{
				int min=M;//最小の節点を探す
				for(int l=1;l<=n;l++)
					for(int k=0;k<=c;k++)
					{
						if(v[l][k]==0&&leng[l][k]<min)
						{
							p=l;
							w=k;
							min=leng[l][k];
						}
					}
				if(min==M)
					break;
				v[p][w]=1;//確定フラグ
				for(int l=1;l<=n;l++) //pを経由してlに至る長さがそれまでの最短経路より小さければ更新
				{
					leng[l][w]=Math.min(leng[l][w], leng[p][w]+cost[p][l]);
					if (w>0)
						leng[l][w-1]=Math.min(leng[l][w-1], leng[p][w]+cost[p][l]/2);
				}
			}
			int ans=M;
			for(int i=0;i<=c;i++)
				ans=Math.min(ans, leng[d][i]);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 998244353
#define ll long long
#define vll vector<long long>  

#define all(c) c.begin(), c.end()

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;



int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO

    int n;
    cin>>n;
    int arr[n] ,ans=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(i%2==0 && arr[i]%2==1)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3184
import math

#n, a, b= map(int, input().split())
#a, b  = map(int, input().split())
#h = list(map(int, input().split()))
#s = list(str(input()))
n = int(input())
a = list(map(int, input().split()))

alice = 0
bob   = 0

for i in range(n):
  a.sort(reverse=True)
  alice = alice + a[0]*((i+1)%2)
  bob   = bob   + a[0]*(i%2)
  a[0] = 0
    
print(alice - bob)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    set<int >s;
    int n;
    cin>>n;
    if(n>=400 and n<600)
        cout<<"8";
    if(n>=600 and n<800)
        cout<<"7";
    if(n>=800 and n<1000)
        cout<<"6";
    if(n>=1000 and n<1200)
        cout<<"5";
    if(n>=1200 and n<1400)
        cout<<"4";
    if(n>=1400 and n<1600)
        cout<<"3";
    if(n>=1600 and n<1800)
        cout<<"2";
    if(n>=1800 and n<2000)
        cout<<"1";
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include <sstream>
using namespace std;
int main()
{
    int n,b;
    cin>>n;
    string s;
    cin>>s;
    for(int a = 0;a<s.length();a ++)
    {
        s[a] += n;
        if(s[a]>'Z')
        s[a] =s[a]-26;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,a[200005],u[200005]={},k,t;
  
  cin >> n;
  for (i=1;i<=n;i++) cin >> a[i];
  
  for (i=n;i>n/2;i--) u[i]=a[i];
  
  for (i=n/2;i>0;i--){
    k=i*2;
    t=0;
    while (k<=n){
      t+=u[k];
      k+=i;
    }
    if (t%2!=a[i]) u[i]=1;
  }
  
  vector<int> ans;
  for (i=1;i<=n;i++){
    if (u[i]==1) ans.push_back(i);
  }
  
  cout << ans.size() << endl;
  for (i=0;i<ans.size();i++) cout << ans[i] << ' ';
  cout << endl;
  
  return 0;
}

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

int main() {
  
  int N=0, money=0, oturi=0;
  
  cin >> money;
  
  if(money%1000==0) {
    
    cout << "0" << endl;
    
  } else {
    
    N = money/1000;
    
    oturi = ((N+1)*1000)-money;
  
    cout << oturi << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 3588
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = list(input())
K = int(input())
length = len(N)

dp = [[[0]*2 for _ in range(K+1)] for _ in range(length+1)]
dp[0][0][1] = 1
for i in range(length):
    n = int(N[i])
    for k in range(K+1):
        if k==K:
            dp[i+1][k][0]+=dp[i][k][0]
            if n==0:
                dp[i+1][k][1]+=dp[i][k][1]
            else:
                dp[i+1][k][0]+=dp[i][k][1]
            continue
        for j in range(10):
            if j==0:
                if n==0:
                    dp[i+1][k][0]+=dp[i][k][0]
                    dp[i+1][k][1]+=dp[i][k][1]
                else:
                    dp[i+1][k][0]+=dp[i][k][0]+dp[i][k][1]
            elif j==n:
                dp[i+1][k+1][1]+=dp[i][k][1]
                dp[i+1][k+1][0]+=dp[i][k][0]
            elif j<n:
                dp[i+1][k+1][0]+=dp[i][k][0]+dp[i][k][1]
            else:
                dp[i+1][k+1][0]+=dp[i][k][0]
print(sum(dp[-1][K]))

Measured memory_bytes: 67436
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define endl '\n'

using namespace std;
struct custom_hash 
{
    static unsigned long long splitmix64(unsigned long long x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(unsigned long long x) const 
    {
        static const unsigned long long FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
mt19937 random_generator(chrono::steady_clock::now().time_since_epoch().count());

string s, t; 
void read()
{
	cin >> s >> t; 	
}
  
void solve()
{
	for (int i = 0; i < (int)s.size(); i++)
	if (s[i] != t[i])
	{
		cout << "No" << endl;
		return;
	}
	
	cout << "Yes" << endl; 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	
	read();
	solve();
}


Measured memory_bytes: 3656
#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 T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

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

  int n;
  while (cin >> n) {
    if (n == 1) {
      cout << "Hello World" << endl;
    } else {
      int a, b;
      cin >> a >> b;
      cout << a + b << endl;
    }
  }
  
  return 0;
}


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

using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL);


#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
typedef long long int llint;

int main(){
        fast_io
        llint a, b,c,k;
        cin >> a >> b >> c >> k;
        VI v;
        
        llint sum = 0;
        // cout << sum << " " << k << endl;
        if(a <= k ) {sum += a;k = k - a;}
        else {sum = k; k = 0; }
        // cout << sum << " " << k << endl;
        if(b <= k ) {k = k - b;}
        else { k = 0; }
        // cout << sum << " " << k << endl;
		sum -= k;
        // cout << sum << " " << k << endl;
		cout << sum << endl;
        
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

int func(int kaidan,int now){
	int a=0,b=0,c=0;
	
	if(now==kaidan){
		return 1;
	}else if(now>kaidan){
		return 0;
		}else{
		a+=func(kaidan,now+1);
		b+=func(kaidan,now+2);	
		c+=func(kaidan,now+3);
		}
	
	return a+b+c;
	
}

int main(){
	int n,ans;

	while(cin>>n){
		if(n==0)break;
		ans=func(n,0);
		cout<<ans/10/365+1<<endl;
		
		
		
	}
	
	
	return 0;
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
typedef		vector<int>				 vi;
typedef 	vector<vi>				vii;
typedef		pair<int,int>			pii;
typedef		unsigned long long		ull;
typedef		long long				ll ;
#define MOD 1e9+7
#define rep(i,a,b)		for(int i=a ; i < b ; i++)  
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;



int main()
{
	ios_base::sync_with_stdio(0);
	int a , b , c ;
	cin >> a >> b >> c ;
	cout << (a + b + c ) - max( a , max ( b , c ) ) <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int k,t,x=0,xx=0,y=0,yy=0;
  cin>>k>>t;
  vector<int> a(t);
  for(int i=0; i<t; i++)cin>>a[i];

  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int b:a){
    if(x>=y){
      y+=b;
      yy++;
    }else{
      x+=b;
      xx++;
    }
  }
 
  if(x<y-yy)cout<<y-yy-x<<endl;
  else if(y<x-xx)cout<<x-xx-y<<endl;
  else cout<<0<<endl;
}

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

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

#define P106 1'000'000

int main()
{
    int n; cin >> n;
    int max_a = 0;
    int *a = new int[n]; rep(i,n) { cin >> a[i]; max_a = max(max_a, a[i]); }
//    int count_max_a = (max_a + 1) / 2;
    int *sieve = new int[P106 * 3]; //rep(i,n) sieve[i] = 0;
    int *duplicate = new int[P106 + 9]; //rep(i,n) duplicate[i] = 0;

    rep(j,n){
        int& i = a[j];
        if (duplicate[i])
            sieve[i]++;
        ++duplicate[i];
        for (int j = i * 2; j <= max_a; j += i)
            sieve[j]++;
    }

    int ans = 0;
    rep(j,n){
        int& i = a[j];
        if(!sieve[i]) ++ans;
    }

    cout << ans << endl;

    delete[] duplicate;
    delete[] sieve;
    delete[] a;
    return 0;
}

Measured memory_bytes: 11816
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

string N;

cin >> N;

if(N.find('7') != std::string::npos) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;

}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    swap(X,Y);
    swap(X,Z);
    cout << X << " " << Y << " " << Z << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        bool check = true;
        for (int j = 0; j < N; j++) {
            for (int k = j; k < N; k++) {
                if (S[(j-i+N)%N][k] != S[(k-i+N)%N][j]){
                    check = false;
                    break;
                }
            }
            if (!check)break;
        }
        if (check) ans += N;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int v[n];
  int c[n];
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  for(int i=0;i<n;i++)
  {
    cin>>c[i];
  }
  int ans=0;
  for(int i=0;i<n;i++)
  {
    
    if((v[i]-c[i])>0)
      ans+=v[i]-c[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#coding:utf-8

N = int(input())
a = sorted([int(x) for x in input().split()], reverse=True)

Alice = sum(a[::2])	#最初から最後までを2間隔で取る。
Bob = sum(a[1::2])	#一項から最後までを2間隔で取る。

print(Alice-Bob)

Measured memory_bytes: 2940
# C - Align
from collections import deque
n=int(input())
a=[int(input()) for i in range(n)]
a.sort(reverse=True)
b=deque()
for i in range(n):
    t=0
    if i==n-1:
        t=a.pop(0)
        if abs(t-b[0])>=abs(t-b[-1]):
            b.appendleft(t)
        elif abs(t-b[0])<abs(t-b[-1]):
            b.append(t)
        break
    if i%2==0:
        if i==0:
            t=a.pop(0)
            b.append(t)
            continue
        if b[0]>=b[-1]:
            t=a.pop(0)
            b.append(t)
        elif b[0]<b[-1]:
            t=a.pop(0)
            b.appendleft(t)
    else:
        if i==1:
            t=a.pop(-1)
            b.append(t)
            continue
        if b[0]>=b[-1]:
            t=a.pop(-1)
            b.appendleft(t)
        elif b[0]<b[-1]:
            t=a.pop(-1)
            b.append(t)
ans=0
for i in range(n-1):
    ans+=abs(b[i+1]-b[i])
print(ans)


Measured memory_bytes: 7824
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=300005;

bool state[MAXN][2];
bool used[MAXN];
int x[MAXN],t[MAXN];
int st00[MAXN],tp00;
int st01[MAXN],tp01;

int main()
{
	int N,L,ans=0;
	scanf("%d%d",&N,&L);
	for(int i=1;i<=N;i++)
		scanf("%d",x+i);
	for(int i=1;i<=N;i++)
	{
		scanf("%d",t+i);
		ans+=(t[i]/(2*L));
		t[i]%=2LL*L;
	}
	for(int i=1;i<=N;i++)
	{
		if(t[i]==0)
			state[i][0]=state[i][1]=1;
		else
		{
			state[i][0]=t[i]>(L-x[i])*2;
			state[i][1]=t[i]>x[i]*2;
			if(state[i][0]&&state[i][1])
				ans++;
		}
	}
	for(int i=N-1;i>0;i--)
	{
		if(state[i][0]==0&&state[i][1]==0)
		{
			if(tp01)
				used[st01[tp01--]]=used[i]=true,ans++;
			else
				st00[++tp00]=i;
		}
		if(state[i][0]==1&&state[i][1]==0)
			if(tp00)
				used[st00[tp00--]]=used[i]=true,ans++;
		if(state[i][0]==0&&state[i][1]==1)
			st01[++tp01]=i;
	}
	while(tp00>=2)
		used[st00[tp00]]=used[st00[tp00-1]]=true,tp00-=2,ans++;
	for(int i=1;i<N;i++)
		if(!used[i])
		{
			if(state[i][0]==0&&state[i][1]==0&&state[N][0]==0)
			{
				used[i]=used[N]=true,ans++;
				break;
			}
			if(state[i][0]==1&&state[i][0]==0&&state[N][0]==0&&state[N][1]==0)
			{
				used[i]=used[N]=true,ans++;
				break;
			}
		}
	int S=0;
	for(int i=1;i<=N;i++)
		if((state[i][0]==0||state[i][1]==0)&&!used[i])
			S++;
	int last=0;
	for(int i=1;i<=N;i++)
		if(state[i][0]==0&&!used[i])
			last=i;
	if(last!=N)
		ans+=S+1;
	if(last==N)
		ans+=S;

	printf("%lld\n",1LL*ans*(2LL*L));
	
	return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, a[100005];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) cin >> a[i];
    sort(a, a+n, greater<int>());
    ll s = -1, t = -1;
    rep(i, 0, n-1) {
        if (s > 0 && a[i+1] == a[i]) {
            t = a[i];
            cout << s * t << endl;
            return 0;
        } else if (s < 0 && a[i+1] == a[i]) {
            s = a[i];
            i++;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int ans=0;
  for(int i=0;i<=N;i++){
    int sum=0,c=i;
    while(c!=0){
      sum+=c%10;
      c/=10;
    }
    if(A<=sum && sum<=B){
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    if i!=n-1 and a[i]+1==a[i+1]:
        ans +=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

  int s,w ;
  cin >> s >> w  ;

  if(w>=s){
      cout << "unsafe" << endl ;
  }else{
      cout << "safe" << endl ;
  }



 return 0 ;
}  


Measured memory_bytes: 3592
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n, count = 0, max = 0;
	cin >> n;
	vi h(n);
	vi memo(n, 0);
	
	cin >> h[0];
	for (int i = 1; i < n;i++) {
		cin >> h[i];
		if (h[i] <= h[i - 1])memo[i] = memo[i - 1] + 1;
		if (memo[i] > max)max = memo[i];
	}

	cout << max << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 1272
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	int n;
	int D,X;
	cin>>n;
	cin>>D>>X;
	vector<int> A(n);
	rep(i,n){
		cin>>A[i];
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= D; j = j + A[i]){
			ans++;
		}
	}
	ans += X;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

class Main{
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int peopleCount = sc.nextInt();
    int day = sc.nextInt();
    int restChocolate = sc.nextInt();
    int[] interval = new int[peopleCount];
    int eatedChocolate = 0;
    for (int i=0; i<peopleCount; i++) {
      interval[i] = sc.nextInt();
    }

    for (int i=0; i<peopleCount; i++) {
      eatedChocolate += (day-1)/interval[i] + 1;
    }
    System.out.println(eatedChocolate + restChocolate);
  }
}


Measured memory_bytes: 21460
#%%
N = int(input())
A = list(map(int, input().split()))

# 4の倍数になるものを削除
A_x2 = [a for a in A if a % 4 != 0]
# 4の倍数の要素数を数える
num_x4 = len(A) - len(A_x2)
# 2の倍数になるものを削除
A_x1 = [a for a in A_x2 if a % 2 != 0]

# 奇数と偶数の数を数える
num_odd = len(A_x1)
num_even = len(A_x2) - num_odd

#
if num_even == 0:
    num_mod = 0
else:
    num_mod = 1

if num_odd + num_mod <= num_x4 + 1:
    print('Yes')
else:
    print('No')



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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

ll dp[101][100001];
int main(void){
    int n;
    ll W;
    cin>>n>>W;
    vector<ll> w(n),v(n);
    rep(i,0,n)cin>>w[i]>>v[i];

    rep(i,0,n+1){rep(j,0,100001)dp[i][j]=INF;}
    dp[0][0]=0;

    rep(i,0,n){
        rep(j,0,100001){
            if(j>=v[i]){
                dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
            }
            dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        }
    }
    
    ll ans=0;
    rep(i,0,100001){
        if(dp[n][i]<=W)ans=i;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long

ll read(){
    char c= getchar(); ll f = 1, ret = 0;
    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for(; isdigit(c); c = getchar()) ret = ret*10 + c - '0';
    return ret*f;
}
void write(ll x) {
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) write(x / 10);
    putchar(x%10 + '0');
}
#define nl puts("")
#define bs putchar(' ')
#define FLUSH fflush(stdout)

void putwt(int l, int r, int another = 0) {
    printf("? ");
    for(int j = l; j <= r; j++) {
        write(j), bs;
    }
    if(another) write(another);
    nl; FLUSH;
}
int getcol(){
    static char s[12];
    scanf("%s", s);
    if(s[0] == 'R') return 1;
    if(s[0] == '-') return 0;
    return -1;
}
char itoch(int x) {
    if(x == 1) return 'R';
    else return 'B';
}
int col[223];
int lisr[233], lisb[233], cntr, cntb, xz;
int n;
void addp(int x){
    if(col[x] == 1) {
        if(cntr < xz) {
            lisr[++cntr] = x;
        }
    } else {
        if(cntb < xz) {
            lisb[++cntb] = x;
        }
    }
}
signed main(){
    n = read();
    
    putwt(1, n);
    int qk = getcol(), qk2;
    int l = 1, r = n+2;
    int le, ri;
    while(r - l > 1) {
        int mid = (l+r)>>1;
        putwt(mid, mid+n-1);
        qk2 = getcol();
        if(qk2 != qk)  {
            r = mid;
        } else l = mid;
    }
    le = l+1, ri = l+n-1; xz = (n-1) / 2;
    for(int i = 1; i < le; i++) {
        putwt(le, ri, i);
        col[i] = getcol();
        addp(i);
    }
    for(int i = ri+1; i <= n*2; i++) {
        putwt(le, ri, i);
        col[i] = getcol();
        addp(i);
    }
    for(int i = le; i <= ri; i++) {
        printf("? %d ", i);
        for(int j = 1; j <= cntr; j++) write(lisr[j]), bs;
        for(int j = 1; j <= cntb; j++) write(lisb[j]), bs;
        nl; FLUSH;
        int res = getcol();
        if(!res) return 0;
        col[i] = res;
    }
    printf("! ");
    for(int i = 1; i <= n*2; i++) {
        printf("%c", col[i] == 1 ? 'R' : 'B');
    }
    nl;
    return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[200010];
int cum[200010], cum2[200010], ma[200010], ma2[200010];
int ans = -INF;

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i % 2)cum[i] += a[i];
		else cum2[i] += a[i];
		cum[i] += cum[i - 1];
		cum2[i] += cum2[i - 1];
	}
	ma[2] = max(a[1], a[2]);
	for (int i = 4; i <= n; i += 2) {
		ma[i] = max({ ma[i - 2] + a[i], cum[i - 3] + a[i],cum[i - 1] });
	}
	ma2[n - 1] = max(a[n], a[n - 1]);
	for (int i = n - 3; i >= 1; i -= 2) {
		ma2[i] = max({ ma2[i + 2] + a[i], cum[n] - cum[i + 2] + a[i],cum[n] - cum[i] });
	}
	if (n % 2 == 0) {
		cout << ma[n] << endl;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (i % 2) {
			ans = max(ans, ma[i - 1] + cum[n] - cum[i + 1]);
		}
		else {
			ans = max(ans, cum[i] + ma2[i + 2]);
		}
	}
	ans = max(ans, ma[n - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 11348
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main
{
    static class Pair{
        int first, second;
        boolean flag;
        public Pair(int first, int second){
            this.first = first;
            this.second = second;
            flag = (first == second);
        }
    }

    public static void process(int test_number)throws IOException
    {
        int n = ni(), res = 0;
        Pair arr[] = new Pair[n];

        for(int i = 1; i <= n; i++){
            int x = ni(), y = ni();
            arr[i - 1] = new Pair(x, y);
        }        

        for(int i = 0; i + 2 < n; i++){
            if(arr[i].flag && arr[i + 1].flag && arr[i + 2].flag){
                pn("Yes");
                return ;
            }
        }

        pn("No");
    }
 
    static final long mod = (long)1e9+7l;
    
    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc = new FastReader();
 
        long s = System.currentTimeMillis();
        int t = 1;
        //t = ni();
        for(int i = 1; i <= t; i++)
            process(i);
 
        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }

    static void trace(Object... o){ System.err.println(Arrays.deepToString(o)); };
    static void pn(Object o){ out.println(o); }
    static void p(Object o){ out.print(o); }
    static int ni()throws IOException{ return Integer.parseInt(sc.next()); }
    static long nl()throws IOException{ return Long.parseLong(sc.next()); }
    static double nd()throws IOException{ return Double.parseDouble(sc.next()); }
    static String nln()throws IOException{ return sc.nextLine(); }
    static long gcd(long a, long b)throws IOException{ return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{ return (b==0)?a:gcd(b,a%b); }
    static int bit(long n)throws IOException{ return (n==0)?0:(1+bit(n&(n-1))); }
    
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            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(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 36632
import java.util.Scanner;


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


        int x = sc.nextInt();
        int a = sc.nextInt();

        if (x>=a){
            System.out.println("10");
        }else if (x<a){
            System.out.println("0");
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long lucas[] = new long[90];
            lucas[0] = 2;
            lucas[1] = 1;

            for (int i = 2; i <= n; i++) {
                lucas[i] = lucas[i - 2] + lucas[i - 1];
            }

            out.print(lucas[n]);
        }

    }
}



Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> t;
    while(t--) {
        cin >> x >> y;
        a = x * y - 1;
        b = sqrtl(a);
        ans = 2 * (b - 1);
        if(b * (b + 1) <= a)
            ans++;
        if(abs(x - y) < 1)
            ans++;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(string s){
  int i;
  int n=0;
  int ln=s.length();
  for(i=0;i<ln;i++){
    if('2'<=s[i]&&s[i]<='9'){
      if(0){
      }else if(s[i+1]=='m'){
	n+=(s[i]-'0')*1000;
      }else if(s[i+1]=='c'){
	n+=(s[i]-'0')*100;
      }else if(s[i+1]=='x'){
	n+=(s[i]-'0')*10;
      }else if(s[i+1]=='i'){
	n+=s[i]-'0';
      }
      i++;
    }else{
      if(0){
      }else if(s[i]=='m'){
	n+=1000;
      }else if(s[i]=='c'){
	n+=100;
      }else if(s[i]=='x'){
	n+=10;
      }else if(s[i]=='i'){
	n+=1;
      }
    }
  }
  return n;
}
string g(int n){
  string s;
  s="";
  if(0){
  }else if(n/1000==0){
  }else if(n/1000==1){
    s+='m';
  }else{
    s+=(char)('0'+n/1000);
    s+='m';
  }
  if(0){
  }else if(n%1000/100==0){
  }else if(n%1000/100==1){
    s+='c';
  }else{
    s+=(char)('0'+n%1000/100);
    s+='c';
  }
  if(0){
  }else if(n%100/10==0){
  }else if(n%100/10==1){
    s+='x';
  }else{
    s+=(char)('0'+n%100/10);
    s+='x';
  }
  if(0){
  }else if(n%10==0){
  }else if(n%10==1){
    s+='i';
  }else{
    s+=(char)('0'+n%10);
    s+='i';
  }
  return s;
}
int main(){
  int i;
  int n;
  string t,u;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>t>>u;
    cout<<g(f(t)+f(u))<<endl;
  }
  return 0;
}

Measured memory_bytes: 0