akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 262144
#define REP(i,n) for(long long i = 0;i < n;++i)
long long dp[2][20000];
vector<int> gogo[2];
int main(){
	string s;
	cin >> s;
	int two_t[2] = {};
	cin >> two_t[0] >> two_t[1];
	reverse(s.begin(), s.end());
	while (s.empty() == false && s[s.size()-1] == 'F') {
		two_t[0]--;
		s.pop_back();
	}
	reverse(s.begin(), s.end());
	s.push_back('T');
	s.push_back('T');
	int now = 0;
	int itr = 0;
	REP(i, s.length()) {
		if (s[i] == 'F') {
			now++;
		}
		else {
			gogo[itr].push_back(now);
			now = 0;
			itr = (itr + 1) % 2;
		}
	}
	REP(i, 2) {
		REP(j, 2) {
			REP(q, 20000) {
				dp[j][q] = 0;
			}
		}
		dp[0][10000] = 1;
		REP(j, gogo[i].size()) {
			for (int q = 0; q < 20000; ++q) {
				if (dp[j % 2][q] == 1) {
					dp[j % 2][q] = 0;
					if (q - gogo[i][j] >= 0) {
						dp[(j + 1) % 2][q - gogo[i][j]] = 1;
					}
					if (q + gogo[i][j] < 20000) {
						dp[(j + 1) % 2][q + gogo[i][j]] = 1;
					}
				}
			}
		}
		if (dp[gogo[i].size()%2][10000 + two_t[i]] == 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

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

int gcd(int x,int y) {
	if (x < y) swap(y,x);
	while (x%y != 0) {
		int r = y;
		y = x%y;
		x=r;
	}
	return y;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++) {
		cin >> a[i];
	}
	for(int i=0;i<n-1;i++){
		a[i+1] = gcd(a[i],a[i+1]);
	}
	cout << a[n-1] << endl;

}


Measured memory_bytes: 640
import java.util.*;

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

		System.out.println("" + a.charAt(0) + b.charAt(1) + c.charAt(2));
	}
}


Measured memory_bytes: 20052
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;

int main(){
	int n;
	scanf("%d",&n);
	int a[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0,1,2,3,4,5,6,7,8};
	int b[] = {0,1,2,3,4,5};
	rep(q,n){
		int from,to;
		bool f = false;
		scanf("%d%d",&from,&to);
		if(from < 6 && to < 6){
			if(from > to){
				int x = from;
				while(1){
					if(b[x] == to){
						printf(" %d\n",to);
						break;
					}
					if(f)printf(" ");
					printf("%d",b[x]);
					x--;
					f = true;
				}
			}
			else{
				int x = from;
				while(1){
					if(b[x] == to){
						printf(" %d\n",to);
						break;
					}
					if(f)printf(" ");
					printf("%d",b[x]);
					x++;
					f = true;
				}
			}
		}
		else{
			int x = from;
			while(1){
				if(a[x] == to){
					printf(" %d\n",to);
					break;
				}
				if(f)printf(" ");
				printf("%d",a[x]);
				x++;
				f = true;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (100005)
#define INF (1LL << 60)
const int MOD = (int)1e9 + 7;


signed main(){
    int N, K;
    cin >> N >> K;

    int k=0;
    for(int i=1; i<=N-2; i++) k+=i;
    if(k<K){
        cout << -1 << endl;
        return 0;
    }
    cout << N-1+(k-K) << endl;
    for(int i=2; i<=N; i++){
        cout << 1 <<" "<< i << endl;
    }

    int d = k - K, cnt=0;
    if(d==0) return 0;
    for(int i=2; i<=N; i++){
        for(int j=i+1; j<=N; j++){
            cout << i <<" "<< j << endl;
            cnt++;
            if(cnt==d){
                return 0;
            }
        }

    }

}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    d:isize,
    e:isize,
    }
    if (a-c).abs()<=(b-d)*e{println!("YES")}
    else {println!("NO")}
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=200006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
      ll i,j,k,n;
      cin>>n;
      ll ans=0;
      rep(i,1,n)
      {
        rep(j,1,n)
        {
          rep(k,1,n)
          {
            ans+=__gcd(__gcd(i,j),k);
          }
        }
      }
      cout<<ans;
    }
    return 0;
   }

Measured memory_bytes: 14172
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
   
using namespace std;
    
void call(int n)
{        
    for(int i = 1; i <= n; i++)
    {
        if ( i % 3 == 0 )
       {
            cout << " " << i;
       }
        else if( i % 10 == 3 )
        {
            cout << " " << i;
        }
        else
        {   
            int x = i;
                
            while(x)
            {
                x = x / 10;
            
                if(x % 10 ==3)
                {
                    cout<<" "<<i;
                    break;
                }
            } 
        }
    }
    
  cout << endl;
}
int main()
{
    int n;
    cin>>n;
    
    call(n);
    return 0;
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	static int count=0;

	public static void main(String[] args) throws Exception {
		BufferedReader breader = getReader();
//		int[] g = getIntAry(breader);
//		int[] num = { 20, 5, 12, 1, 23, 15, 19, 24, 4, 22, 11, 3, 2, 18, 21, 13, 7, 25, 9, 14, 8, 10, 6, 16, 17 };
		int[] num = getAryMl(breader);
		int len = (int)(Math.log(num.length)/Math.log(2));
		if ( len == 0 ) len = 1;
		int[] g = new int[len];
		if ( num.length == 1) {
			g[0] = 1;
		} else {
			g[0] = (int)(num.length/2);
		}
		for(int i = 1 ; i < len ; i++) {
			g[i] = (int)(g[i-1]/2);
		}
		for(int i = 0 ; i < g.length ; i++) {
			insertionSort( num, num.length, g[i]);
		}
		System.out.println(len);
		putAry(g);
		System.out.println(count);
		for( int i = 0 ; i < num.length ; i++) {
			System.out.println(num[i]);
		}
	}
	public static void insertionSort(int[] A, int n, int g) {
		for( int i= g ; i < n ; i++) {
			int v = A[i];
			int j = i - g;
			while( j >= 0 && A[j] > v) {
				A[j+g] = A[j];
				j = j-g;
				count++;
//				putAry(A,n);
			}
			A[j+g] = v;
//			putAry(A,n);
		}
//		System.out.println( "---" + count + " g=" + g);

	}
	public static BufferedReader getReader() {
		return( new BufferedReader(new InputStreamReader(System.in)));
	}
	public static int getInt(BufferedReader br)throws Exception {
		String line = br.readLine();
		return Integer.valueOf(line);
	}
	public static String[] getAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		return nstr;
	}
	public static int[] getIntAry(BufferedReader br)throws Exception {
		String line = br.readLine();
		String[] nstr = line.split(" ");
		int[] n = new int[nstr.length];
		for( int i=0 ; i < nstr.length ; i++ ) {
			n[i] = Integer.valueOf(nstr[i]);
		}
		return n;
	}
	public static int cardComp(String left, String right) {
		char l = left.charAt(1);
		char r = right.charAt(1);
		return(l-r);
	}
	public static int[] getAryMl(BufferedReader br)throws Exception {
		int n = getInt(br);
		int[] ary = new int[n];
		for( int i=0 ; i < n ; i++ ) {
			ary[i] = getInt(br);
		}
		return ary;
	}
	public static void putAry(int[] ary, int num) {
		for( int i = 0; i < num ; i++ ) {
			System.out.print(ary[i]);
			if ( i < num-1) {
				System.out.print(" ");
			}
		}
		System.out.println("");
	}
	public static void putAry(int[] ary) {
		putAry(ary, ary.length ) ;
	}
	public static boolean isPrime(int n) {
		int r = (int)Math.sqrt((double)n)+1;
		for( int j = 2 ; j < r ; j += 1) {
			if ( n%j == 0 ) {
				return false;
			}
		}
		return true;
	}

	

}

Measured memory_bytes: 100664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public final class Main {

	public static void main(String[] args) {
		final FastScanner fs = new FastScanner();
		final long n = fs.nextInt();

		long a =1;
		long b =1;
		long answer = 0;

		while(a<n) {
			b=1;
			while(a*b<n) {
				answer ++;
				b++;
			}
			a++;
		}

		System.out.println(answer);
	}

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}



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

int cmpMonsterHP(const void *n1, const void *n2)
{
    if (*(long *)n1 < *(long *)n2)
    {
        return 1;
    }
    else if (*(long *)n1 > *(long *)n2)
    {
        return -1;
    }
    else
    {
        return 0;
    }
}

int main(void)
{

    // 入力値の取得
    int i_monsterCount;
    int i_skillCount;
    scanf("%d%d", &i_monsterCount, &i_skillCount);
    long la_monsterHP[i_monsterCount];
    for (int index = 0; index < i_monsterCount; index++)
    {
        scanf("%ld", &la_monsterHP[index]);
    }

    // 敵体力でソートする
    qsort(la_monsterHP, i_monsterCount, sizeof(long), cmpMonsterHP);

    // 攻撃回数の計算
    long l_totalDemandDamage = 0;
    for (int index = i_skillCount; index < i_monsterCount; index++)
    {
        l_totalDemandDamage += la_monsterHP[index];
    }

    // 結果の出力
    printf("%ld", l_totalDemandDamage);

    return 0;

}

Measured memory_bytes: 3324
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                //ios_base::sync_with_stdio(false);
                //cin.tie(NULL);
                lli t,n,i,j,k,b,a,q,m,l;
                cin>>n>>m>>k;
                vector<vector<lli>> c(n,vector<lli>(m+1));
                rep(i,n){
                    rep(j,m+1)cin>>c[i][j];
                }
                lli fcost=INT_MAX;
                rep(i,pow(2ll,n)){
                    vector<lli> lev(m,0);
                    lli cost=0;
                    rep(j,n){
                        if((i&(1ll<<j))){
                            cost+=c[j][0];
                            repp(l,1,m+1){
                                lev[l-1]+=c[j][l];
                            }
                        }
                    }
                    lli f=0;
                    rep(j,m){
                        if(lev[j]<k){
                            f=1;
                            break;
                        }
                    }
                    if(f==0){
                        fcost=min(fcost,cost);
                    }
                }
                if(fcost==INT_MAX){
                    cout<<-1<<endl;
                    return 0;
                }
                cout<<fcost<<endl;
            }


Measured memory_bytes: 4112
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=4005;
char c[N];
int sum1[N],sum2[N],sum3[N];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",c+1);
	for(int i=1;i<=n;i++){
		sum1[i]=sum1[i-1];
		sum2[i]=sum2[i-1];
		sum3[i]=sum3[i-1];
		if(c[i]=='R'){
			sum1[i]++;
		}
		if(c[i]=='G'){
			sum2[i]++;
		}
		if(c[i]=='B'){
			sum3[i]++;
		}
	}
	ll ans=0;
	for(int i=2;i<n;i++){
		if(c[i]=='R'){
			ans+=sum2[i]*(sum3[n]-sum3[i]);
			ans+=sum3[i]*(sum2[n]-sum2[i]);
		}
		if(c[i]=='G'){
			ans+=sum1[i]*(sum3[n]-sum3[i]);
			ans+=sum3[i]*(sum1[n]-sum1[i]);
		}
		if(c[i]=='B'){
			ans+=sum1[i]*(sum2[n]-sum2[i]);
			ans+=sum2[i]*(sum1[n]-sum1[i]);
		}
		for(int j=i-1;j>=1&&i+i-j<=n;j--){
			if(c[j]!=c[i]&&c[i+i-j]!=c[i]&&c[j]!=c[i+i-j]){
				ans--;
			}
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 3852
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<bitset>
#include<map>
using namespace std;

struct P{
  int x,y;
};

vector<P> list;
int input(){
  int N;
  cin>>N;
  list.clear();
  if(N==0)return false;
  for(int i=0;i<N;i++){
    int a,b;
    cin>>a>>b;
    list.push_back(P{a,b});
  }
  return true;
}

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

bool solve(){
  int M;
  cin>>M;
  P r=P{10,10};
  vector<int> use;
  use.resize(list.size());
  for(int i=0;i<use.size();i++){
    use[i]=0;
  }
  for(int i=0;i<M;i++){
    char c;
    int d;
    cin>>c>>d;
    int v;
    switch(c){
      case 'N':
        v=0;
        break;
      case 'E':
        v=1;
        break;
      case 'S':
        v=2;
        break;
      case 'W':
        v=3;
        break;
    }
    int xx = r.x + vx[v]*d;
    int yy = r.y + vy[v]*d;
    for(int j=0;j<list.size();j++){
      if((yy==r.y&&((r.x<=list[j].x&&list[j].x<=xx&&list[j].y==yy)||(xx<=list[j].x&&list[j].x<=r.x&&list[j].y==yy)))
          ||(xx==r.x&&((r.y<=list[j].y&&list[j].y<=yy&& list[j].x==xx)||(yy<=list[j].y&&list[j].y<=r.y&&list[j].x==xx)))){
        use[j]=true;
      }
    }
    r.x = xx;
    r.y = yy;
  }
  for(int i=0;i<use.size();i++){
    if(!use[i])return false;
  }
  return true;
}


int main(){
  while(input()){
    if(solve()){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI 3.141592653589793


int main() {
	
	for (int i = 0; i < 5; i++) {
		int x = 0;
		cin >> x;
		if (x == 0) {
			cout << (i + 1);
			return 0;
		}
	}
	
}

Measured memory_bytes: 3588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
    static void Main()
    {
        string line = Console.ReadLine().Trim();

        string[] lineRecord = Console.ReadLine().Trim().Split(' ');

        var answer = string.Empty;
        for (int i = 0; i < int.Parse(line); i++)
        {
            if (string.IsNullOrEmpty(answer))
            {
                answer = lineRecord[0].Substring(0, 1) + lineRecord[1].Substring(0, 1);
            }
            else
            {
                answer += lineRecord[0].Substring(i, 1) + lineRecord[1].Substring(i, 1);
            }
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

char str[8][8];

void solve()
{
    int H, W, K;
    scanf("%d%d%d", &H, &W, &K);
    int i, j;
    for (i = 0; i < H; i++) {
        scanf("%s", str[i]);
    }

    int ans = 0;
    int p, q;
    for (i = 0; i < (1 << H); i++) {
        for (j = 0; j < (1 << W); j++) {
            int cnt = 0;
            for (p = 0; p < H; p++) {
                if (!(i & (1 << p))) continue;

                for (q = 0; q < W; q++) {
                    if (!(j & (1 << q))) continue;

                    if (str[p][q] == '#') cnt++;
                }
            }
            if (cnt == K)
                ans++;
        }
    }
    printf("%d\n", ans);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>

int main(){
    std::string str, ans;
    std::cin >> str;

    if("Sunny" == str){
        ans = "Cloudy";
    }else if("Cloudy" == str){
        ans = "Rainy";
    }else if("Rainy" == str){
        ans = "Sunny";
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<string.h>
#include<cmath>
using namespace std;
int ans[100010];
int main() {
	int n,pos;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> pos;
		ans[pos-1] = i + 1;
	}
	for (int i = 0; i < n - 1; i++) {
		cout << ans[i] << " ";
	}
	cout << ans[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3856
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

const INF: usize = 1001001001;

#[fastout]
fn main() {
   input! {
      n: usize,
      a: [usize; n],
      uv: [(Usize1, Usize1); n-1]
   }
   let mut to = vec![Vec::new(); n];
   for (u, v) in uv.iter().copied() {
      to[u].push(v);
      to[v].push(u);
   }
   let mut dp = vec![INF; n+1];
   let mut ans = vec![INF; n];
   let mut diff = Vec::<(usize, usize)>::new();
   dfs(0, 0, &mut dp, &mut ans, &mut diff, &to, &a);
   for ans in ans {
      println!("{}", ans);
   }
}

fn dfs(
   v: usize,
   p: usize,
   dp: &mut Vec<usize>,
   ans: &mut Vec<usize>,
   diff: &mut Vec<(usize, usize)>,
   to: &Vec<Vec<usize>>,
   a: &Vec<usize>,
) {
   let pos = dp.lower_bound(&a[v]);
   let res = dp[pos];
   dp[pos] = a[v];
   ans[v] = dp.lower_bound(&INF);
   for u in to[v].iter() {
      if *u == p {
         continue;
      }
      dfs(*u, v, dp, ans, diff, to, a);
   }
   dp[pos] = res;
}

use std::cmp::Ordering;
/// Equivalent to std::lowerbound and std::upperbound in c++
pub trait BinarySearch<T> {
   fn lower_bound(&self, x: &T) -> usize;
   fn upper_bound(&self, x: &T) -> usize;
}
impl<T: Ord> BinarySearch<T> for [T] {
   fn lower_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            Ordering::Less => {
               low = mid + 1;
            }
            Ordering::Equal | Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
   fn upper_bound(&self, x: &T) -> usize {
      let mut low = 0;
      let mut high = self.len();
      while low != high {
         let mid = (low + high) / 2;
         match self[mid].cmp(x) {
            Ordering::Less | Ordering::Equal => {
               low = mid + 1;
            }
            Ordering::Greater => {
               high = mid;
            }
         }
      }
      low
   }
}


Measured memory_bytes: 41036
if __name__ == '__main__':
    n = int(input())
    a_list = []
    max_num = 0
    second_max = 0
    max_count = 0
    for i in range(n):
        a = int(input())
        a_list.append(a)
        if a > max_num:
            max_num = a
            max_count = 1
        elif a > second_max:
            second_max = a

    for i in range(n):
        if a_list[i] != max_num:
            print(max_num)
        else:
            print(second_max)

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const double ESP=1e-10;

int l[10],v1,v2;

int main(){
	do{
		if (scanf("%d,",&l[0])==EOF) break;
		int sum=l[0];
		FOR(i,1,10){
			scanf("%d,",&l[i]);
			sum+=l[i];
		}
		scanf("%d,%d",&v1,&v2);
		double p=(double)sum*v1/(v1+v2);
		double p2=0;
		REP(i,10){
			if (p<=p2+l[i]+ESP){
				printf("%d\n",i+1);
				break;
			}
			p2+=l[i];
		}
	}while(1);
	return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
int n,a[100010];
priority_queue<int>pq;
int gcd(int x,int y){
	if(y==0)return x;
	return gcd(y,x%y);
}
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		pq.push(-a[i]);
	}
	int nw;
	while(!pq.empty()){
		int a,b;
		a=-pq.top();
		pq.pop();
		if(pq.empty()){
			cout<<a<<endl;
			return 0;
		}
		b=-pq.top();
		pq.pop();
		nw=gcd(b,a);
		pq.push(-nw);
	}
	cout<<nw<<endl;
    return 0; 
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9+7;
const ll inf = (LLONG_MAX>>2);
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<ll> a(n),b(n+1),c(n);
  for(ll i = 0; i < n; ++i) cin >> a[i];
  for(ll i = 1; i <= n; ++i) cin >> b[i];
  for(ll i = 1; i < n; ++i) cin >> c[i];
  ll ans = 0;
  for(ll i = 0; i < n; ++i){
    ans += b[a[i]];
    if(i < n-1 and a[i]+1 == a[i+1]) ans += c[a[i]];
  }
  cout << ans;
  return 0;
}

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

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

void solve() {
     double d,s,t;
     cin >> d >> s >> t;

     if(d/s > t)cout << "No";
     else cout << "Yes";
}

int main() {
    
    ios_base::sync_with_stdio(false);cin.tie(NULL); 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt","w",stderr);
    #endif

    solve();
    
        

     cerr<<"\ntime taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
}

Measured memory_bytes: 3792
fn main() {
    let mut sc = Scanner::new();
    let a = sc.usize_read();
    let b = sc.usize_read();
    let x = b - a;
    let t = (1 + x) * x / 2;
    println!("{}", t - b);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;


bool is_even(int x){
  if(x%2==0){
    return true;
  }
  else{return false;}
}


int main() {
 int n;
  cin>>n;
  vector<char> s(n);
  rep(i,n) cin>>s[i];
  bool is_ok=true;//題意
  
  if(!is_even(n)){
    is_ok=false;
  }
  
  rep(i,n/2){
  		if( s[i]!=s[n/2+i]){
          is_ok=false;
          break;
        }
             
  }
  		if(is_ok){
   		 cout<<"Yes"<<endl;
  		}
  		else{
  		  cout<<"No"<<endl;
  		}
  
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 200010, M = 2 * N;
const double eps = 1e-6;

int n, m;
int h[N], e[M], ne[M], idx;
vector<int> st;

void add(int a, int b)
{
    e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

int main()
{
    memset(h, -1, sizeof h);

    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        add(a, b), add(b, a);
    }

    for(int i = h[n]; ~i; i = ne[i])
    {
        int j = e[i];
        st.push_back(j);
    }

    for(int t = 0; t < st.size(); t++)
        for(int i = h[st[t]]; ~i; i = ne[i])
        {
            int j = e[i];
            if(j == 1)
            {
                puts("POSSIBLE");
                return 0;
            }
        }

    puts("IMPOSSIBLE");
    return 0;
}


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

int main() {
  long long n,a[1000000],max=-1,count=0,flag=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n-1;i++){
    if(a[i]>=a[i+1]){
      count++;
    }
    else{
      count=0;
    }
    if(max<count){
      max=count;
    }
  }
  if(max==-1)
    max=0;
  cout<<max<<'\n';
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

std::string S, T, U;
int A, B;

int main()
{
  std::cin >> S >> T;
  std::cin >> A >> B;
  std::cin >> U;

  printf( "%d %d\n", A-(S==U?1:0), B-(T==U?1:0) );

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
signed main() {
	int a, b;
	cin >> a >> b;
	if (a + b == 15)cout << '+' << endl;
	else if (a*b == 15)cout << '*' << endl;
	else cout << 'x' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1) {
        int h, w;
        cin >> w >> h;
        if(w == 0 && h == 0) {
            break;
        }
        int n = h * w + 2;
        vector<vector<int>> g(n);
        g[0].emplace_back(1);
        g[1].emplace_back(0);
        g[n - 2].emplace_back(n - 1);
        g[n - 1].emplace_back(n - 2);
        for(int i = 1; i <= h; i++) {
            for(int j = 1; j <= w - 1; j++) {
                int tmp;
                cin >> tmp;
                if(tmp == 0) {
                    g[w * (i - 1) + j].emplace_back(1 + w * (i - 1) + j);
                    g[1 + w * (i - 1) + j].emplace_back(w * (i - 1) + j);
                }
            }
            if(i == h) {
                break;
            }
            for(int j = 1; j <= w; j++) {
                int tmp;
                cin >> tmp;
                if(tmp == 0) {
                    g[w * (i - 1) + j].emplace_back(w * i + j);
                    g[w * i + j].emplace_back(w * (i - 1) + j);
                }
            }
        }
        vector<int> d(n, INF);
        d[0] = 0;
        queue<int> que;
        que.push(0);
        while(que.size()) {
            int v = que.front();
            que.pop();
            if(d[v] == INF) {
                continue;
            }
            for(auto u : g[v]) {
                if(d[u] == INF) {
                    d[u] = d[v] + 1;
                    que.push(u);
                }
            }
        }
        cout << (d[n - 1] == INF ? 0 : d[n - 1] - 1) << endl;
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vl a(n), b(n);
  ll asum = 0;
  ll bsum = 0;
  rep(i, n) {
    cin >> a[i];
    asum += a[i];
  }
  rep(i, n) {
    cin >> b[i];
    bsum += b[i];
  }

  ll t = bsum-asum;

  cerr << t << endl;
  rep(i, n) {
    t -= max(0LL, b[i]-a[i]+1)/2;
  }

  if (t < 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define pb push_back

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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main(){ _
	int n; cin >> n;
	int a = n%10;
	if(a == 2 or a == 4 or a == 5 or a == 7 or a == 9) cout << "hon" << endl;
	else if (a == 0 or a == 1 or a ==6 or a == 8) cout << "pon" << endl;
	else cout << "bon" << endl;
	
	exit(0);
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N;
	cin >> N;
	string s[N], X;
	int t[N], ans = 0;
	bool yay = false;
	for (int i = 0; i < N; ++i) cin >> s[i] >> t[i];
	cin >> X;
	for (int i = 0; i < N; ++i) {
		if (yay) ans += t[i];
		if (s[i] == X) yay = true;
	}
	cout << ans;
	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    int N,C;
    cin >> N >> C;

    vector<int>s(N);
    vector<int>t(N);
    vector<int>c(N);
    vector<int>w(pow(10,5)+1);
    rep(i,N)
    {
        cin >> s[i] >> t[i] >> c[i];
        w[s[i]]++;
        w[t[i]+1]--;
    }
    int ans = 0;
    int tmp_ans = 0;
    rep(i,w.size())
    {
        tmp_ans += w[i];
        ans = max(ans,tmp_ans);
    }
    cout << min(C,ans) << endl;
}


Measured memory_bytes: 1792
N,K=map(int,input().split())
p=list(map(int,input().split()))

p_=[]
for i in range(len(p)):
  p_.append((1+p[i])/2)
 
import itertools
c=list(itertools.accumulate(p_))

ans=0
if N!=K:
  
  for i in range(0,N-K):
    s=c[i+K]-c[i]
    ans=max(ans,s)
else:
  ans=c[K-1]
print(ans)  

Measured memory_bytes: 24708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;



signed main(){
    ll n,k,ans=0;
    cin>>n>>k;
    k--;
    vector<ll> v(n);

    ll r=((1ll<<(n+2))-4),l=0;

    while(n>0){
        ll mid=(l+r)/2;

        if(n==1){
            if(k==l){
            }else if(k==r){
                ans+=-1+(1ll<<(n+1));
            }else if(k==mid){
                ans+=(1ll<<n);
            }else if(k<mid){
                ans++;
            }else{
                ans+=3;
            } 
            break; 
        }

        if(k==l){
            //cout << "TEST1" << endl;
            break;
        }else if(k==r){
            ans+=-1+(1ll<<(n+1));
            //cout << "TEST2" << endl;
            break;
        }else if(k==mid){
            ans+=(1ll<<n);
            //cout << "TEST3" << endl;
            break;
        }else if(k<mid){
            l++;
            r=mid-1;
            //cout << "TEST4" << endl;
        }else{
            ans+=(1ll<<(n));
            l=mid+1;
            r--;
        }
        n--;   
        
    }

    
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };
 
bool collision_detection( double x1, double y1, double x2, double y2, double x3, double y3, double xp, double yp ) {
    x2 -= x1;
    x3 -= x1;
    xp -= x1;
    y2 -= y1;
    y3 -= y1;
    yp -= y1;
    double t_size = fabs( ( x2 * y3 - y2 * x3 ) / 2 );
    t_size -= fabs( ( x2 * yp -  y2 * xp ) / 2 );
    t_size -= fabs( ( x3 * yp -  y3 * xp ) / 2 );
    x2 -= xp;
    x3 -= xp;
    y2 -= yp;
    y3 -= yp;
    yp = xp = 0;
    t_size -= fabs( ( x2 * y3 - y2 * x3 ) / 2 );
    return fabs( t_size ) < 1e-10;
}
 
int main() {
    double x[ 4 ], y[ 4 ];
    while ( ~scanf( "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[ 0 ], &y[ 0 ], &x[ 1 ], &y[ 1 ], &x[ 2 ], &y[ 2 ], &x[ 3 ], &y[ 3 ] ) ) {
        bool print_yes = true;
        for ( int i = 0; i < 4; i++ ) {
            if ( collision_detection( x[ ( i + 1 ) % 4 ], y[ ( i + 1 ) % 4 ], x[ ( i + 2 ) % 4 ], y[ ( i + 2 ) % 4 ], x[ ( i + 3 ) % 4 ], y[ ( i + 3 ) % 4 ], x[ i ], y[ i ] ) ) {
                print_yes = false;
                break;
            }
        }
        printf( "%s\n", print_yes ? "YES" : "NO" );
    }
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;

// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}
int main(void) {


	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll ans = 0;
	if (k > 0) {
		ans += std::min(a,k);
		k -= a;
	}
	if (k > 0) {
		k -= b;
	}
	if (k > 0) {
		ans -= std::min(c, k);
		k -= c;
	}


	auto output = ans;
	cout << output;

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
multiset<int> a,b;
int mod=1e9+7;
int main(){
	int N;
	cin>>N;
	rep(i,N){
		int x;
		cin>>x;
		a.insert(x);
		b.insert(abs(i-(N-1-i)));
	}
	if(a!=b){
		puts("0");
	}else{
		int ans=1;
		rep(i,N/2) ans=ans*2%mod;
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, A):
    for i in range(H):
        for j in range(W):
            if A[i][j] == 'S':
                s = (i, j)
    from collections import deque

    q = deque([s])
    d = [[None] * W for _ in range(H)]
    d[s[0]][s[1]] = 0

    ans = INF
    while q:
        x, y = q.popleft()
        t = min(abs(x), abs(x-H+1), abs(y), abs(y-W+1))
        ans = min(ans, t)
        for vx, vy in [(x-1, y), (x, y-1), (x, y+1), (x+1, y)]:
            if not (0 <= vx < H and 0 <= vy < W):
                continue
            if A[vx][vy] == '#':
                continue
            if d[vx][vy] is not None:
                continue

            c = d[x][y]
            if c + 1 <= K:
                q.append((vx, vy))
                d[vx][vy] = c + 1

    return 1 + -(-ans // K)


def main():
    H, W, K = read_int_n()
    A = [read_str() for _ in range(H)]
    print(slv(H, W, K, A))


if __name__ == '__main__':
    main()


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

#define ll long long int
ll mod=1e9+7;
#define loop() for(ll i=0;i<n;i++) 


int main()
{ 
      std::ios_base::sync_with_stdio(false);
     // int t;cin>>t;
     /* while(t--)
      {
           
           
      }*/
      
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++)
     cin>>a[i];
     int sum=0;
     for(int i=0;i<n-1;i++)
     {
           for(int j=i+1;j<n;j++)
           sum+=(a[i]*a[j]);
     }
     cout<<sum<<'\n';
     
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int No = 0, Ne = 0;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        if(A%2==0) Ne++;
        else No++;
    }
    if(No % 2 == 0 || (No % 2 == 1 && Ne == 0))
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::VecDeque;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

//return true if consistent
fn search(graph: &mut Vec<Vec<(usize, i64)>>, people: &mut Vec<i64>, i: usize) -> bool{
    let mut queue: VecDeque<(usize)> = VecDeque::new();
    queue.push_back(i);
    let dummy = std::i64::MAX;
    while let Some(cur_v) = queue.pop_front(){
        while let Some((next_v, d)) = graph[cur_v].pop(){
            if people[next_v] == dummy{
                people[next_v] = people[cur_v] + d;
                queue.push_back(next_v);
            }else if people[next_v] != people[cur_v] + d{
                return false;
            }
        }
    }
    true
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, m) = (line[0], line[1]);
    let dummy = std::i64::MAX;
    let mut graph: Vec<Vec<(usize, i64)>> = vec![vec![];n];
    let mut people: Vec<i64> = vec![dummy; n];
    for _ in 0..m{
        let line = read_as_vec::<usize>();
        //let (l, r, d) = (cmp::min(line[0], line[1]), cmp::max(line[0], line[1]), line[2]);
        let (l, r, d) = (line[0]-1, line[1]-1, line[2] as i64);
        graph[l].push((r, d));
        graph[r].push((l, -d));
    }

    for i in 0..n{
        if graph[i].len() == 0{
            continue;
        }
        //init people[i] position to 0
        people[i] = 0;
        let is_consisent: bool = search(&mut graph, &mut people, i);

        if !is_consisent{
            println!("No");
            return;
        }

    }

    println!("Yes");

}


Measured memory_bytes: 18684
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner scanner = new Scanner(System.in);
		
		String inputS = scanner.nextLine();

		scanner.close();
		
		char correct = inputS.charAt(0);
		if(correct == '0') {
			correct = '1';
		} else {
			correct = '0';
		}
		
		int turnCount = 0;
		for(int i = 1; i < inputS.length(); i++) {
			if(correct - inputS.charAt(i) != 0) {
				turnCount++;
			}

			if(correct == '0') {
				correct = '1';
			} else {
				correct = '0';
			}
		}
		
		System.out.println(turnCount);
	}
}

Measured memory_bytes: 27956
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) obj.begin(),obj.end()
#define pb(obj) push_back(obj)
#define REP(i,N) for(ll i=0;i<N;i++)
typedef long long ll;
ll const MOD=1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin>>N;
    int count=0;
    vector<int>a(N+1);
    for(int i=1;i<=N;i++){
        cin>>a[i];
    }
    vector<int>amari(N+1);
    vector<int>res(N+1);
    for(int i=N;i>=1;i--){
        if(amari[i]!=a[i]){
            res[i]=1;
            count++;
            for(int j=1;j<=sqrt(i);j++){
                if (i%j==0){amari[j]=not amari[j];amari[i/j]=not amari[i/j];if(j==sqrt(i))amari[j]=not amari[j];}
            }
        }
    }
    cout<<count<<endl;
    for(int i=1;i<=N;i++){
        if(res[i]==1)cout<<i<<" ";
    }
    if(count!=0)cout<<endl;

}

Measured memory_bytes: 3200
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N, L;
    std::vector<string> S;
    std::string tmp;
    std::cin >> N >> L;
    for (int i = 0; i < N; i++) {
        std::cin >> tmp;
        S.push_back(tmp);
    }
    std::sort(S.begin(), S.end());
    std::string ans = "";
    for (int i = 0; i < N; i++) {
        ans += S.at(i);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3632