akhauriyash/Code-Regression huggingface dataset:
import javax.print.DocFlavor;
import java.util.ArrayList;
import java.util.Scanner;

class graphDP{

    int v;
    ArrayList<ArrayList<Integer>> adj = new ArrayList<>();

    graphDP(int x){

        v = x;
        for(int i=0;i<=v;i++){

            ArrayList<Integer> z = new ArrayList<>();
            adj.add(z);
        }

    }

    void add(int x , int y){
        adj.get(x).add(y);
    }

    void dfs(int x , int[] dp , boolean[] visited){


        visited[x] = true;
        for(int ver=0; ver<adj.get(x).size();ver++){
            int t= adj.get(x).get(ver);
            if(!visited[t]){

                dfs(t,dp,visited);

            }

            dp[x] = Math.max(dp[x],1+dp[t]);
        }




    }


}


public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        graphDP g = new graphDP(n);
        boolean[] visited = new boolean[n+1];

        for (int i = 0; i < m; i++) {

            int start = in.nextInt();
            int end = in.nextInt();
            g.add(start,end);
        }

        int[] dp = new int[n+1];

        for(int i=1;i<=n;i++){

            if(!visited[i]){

                g.dfs(i,dp,visited);

            }

        }

//        for(int i=0;i<dp.length;i++) {
//
//            System.out.println(dp[i] + " ");
//        }
//            System.out.println();

        int max = dp[0];
        for(int i=1;i<dp.length;i++){

            if(max<dp[i]) max = dp[i];
        }


        System.out.println(max);

    }
}


Measured memory_bytes: 107124
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

N,K = map(int,input().split())
W,D = np.array([input().split() for _ in range(N)], dtype=np.int64).T

def f(x):
    # 座標xまでに生える花の個数を数える。x inclusive
    return np.maximum(0,np.minimum((x - W)//D+1,10**10)).sum()

left = 0 # K本未満
right = (1<<63)-1 # K本以上
while right > left + 1:
    mid = (left + right)//2
    if f(mid) >= K:
        right = mid
    else:
        left = mid

answer = right
print(answer)


Measured memory_bytes: 57860
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = 1e18;

const ll MAX = 100000;

class Edge {
public:
  ll t, w;
  Edge(){}
  Edge(ll t, ll w): t(t), w(w) {}
};

V<Edge> G[MAX];
ll n;
vll d(MAX);
V<bool> visited(MAX);
ll cnt;

void bfs(ll s) {
  REP(i, n) d[i] = HIGHINF;
  queue<ll> q; q.push(s);
  d[s] = 0;
  while(!q.empty()) {
    ll u = q.front(); q.pop();
    REP(i, G[u].size()) {
      Edge e = G[u][i];
      if (d[e.t] == HIGHINF) {
        d[e.t] = d[u] + e.w;
        q.push(e.t);
      }
    }
  }
}

void solve() {
  // 適当な始点から（今は0）最も遠い節点tgtを求める
  bfs(0);
  ll maxv = 0;
  ll tgt = 0;
  REP(i, n) {
    if (d[i] == HIGHINF) continue;
    if (maxv < d[i]) {
      maxv = d[i], tgt = i;
    }
  }
  // tgtから最も遠い節点の距離を求める
  bfs(tgt);
  maxv = 0;
  REP(i, n) {
    if (d[i] == HIGHINF) continue;
    chmax(maxv, d[i]);
  }
  cout << maxv << endl;
}

int main() {
  ll s, t, w; cin >> n;
  REP(i, n-1) {
    cin >> s >> t >> w;
    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }
  solve();
  return 0;
}



Measured memory_bytes: 11780
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int cnt[100010];
int cnt1[100010];
int cnt2[100010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int X[100010];
    rep(i, N) cin >> X[i];
    rep(i, N) cnt[X[i]]++;
    rep(i, N) cnt1[X[i] % M]++;
    int ans = 0;
    rep(i, M) {
        int tmp = 0;
        if(i != (M - i) % M) tmp = min(cnt1[i], cnt1[(M - i) % M]);
        else tmp = cnt1[i] / 2;
        ans += tmp;
        cnt2[i] += tmp;
        cnt2[(M - i) % M] += tmp;
        cnt1[i] -= tmp;
        cnt1[(M - i) % M] -= tmp;
    }
    // rep(i, M) cout << cnt2[i] << " ";
    // cout << endl;
    for(int i = 0; i <= M; i++) {
        for(int j = i; j <= 100000; j += M) {
            if(cnt2[i] > 0 && cnt[j] % 2 == 1) {
                cnt2[i]--;
                cnt[j]--;
            }
        }
    }
    for(int i = 0; i <= M; i++) {
        for(int j = i; j <= 100000; j += M) {
            if(cnt2[i] > 0) {
                int tmp = min(cnt2[i], cnt[j]);
                cnt2[i] -= tmp;
                cnt[j] -= tmp;
            }
        }
    }
    // rep(i, M) cout << cnt2[i] << " ";
    // cout << endl;
    rep(i, 100010) ans += cnt[i] / 2;
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 6740
n = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    if P[i+1]>P[i] and P[i+1]<P[i+2]:
        cnt += 1
    elif P[i+1]<P[i] and P[i+1]>P[i+2]:
        cnt += 1
print(cnt)    

Measured memory_bytes: 3060
// ConsoleApplication10.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<cmath>
using namespace std;


int main()
{ 
	int N, M,x,y,j,ans;
	cin >> N;
	cin >> M;
	x = 100 * (N - M) + 1900 * M;
	y=pow(2, M);
	cout << x * y << endl;


    return 0;
}



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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL powm(LL x, LL y, LL m){
  if(y == 0) return 1;
  return powm(x*x%m, y/2, m) * (y%2==1?x:1) % m;
}
LL inv(LL x, LL m){
  return powm(x, m-2, m);
}

int N1, N2, M;
PLL dp[300000];
PLL dp2[300000];

const LL M1 = 1000000007;
const LL M2 = 1000000009;
LL R1, R2;
PLL thash(int u, int p, VVI& G){
  int sz = SZ(G[u]);
  PLL res(sz, sz);

  for(int v: G[u]){
    if(v == p) continue;
    PLL x = thash(v, u, G);
	(res.FF *= (R1 + x.FF)) %= M1;
	(res.SS *= (R2 + x.SS)) %= M2;
  }
 
  return res;
}


int getsz(int u, vector<bool>& used, VVI& G){
  used[u] = true;
  int res = 1;
  for(int to: G[u])
	if(!used[to])
	  res += getsz(to, used, G);
  return res;
}

void dfs1(int u, int p, VVI& G){
  int sz = SZ(G[u]);
  dp[u] = MP(sz, sz);

  for(int v: G[u]){
    if(v == p) continue;
    dfs1(v, u, G);
	(dp[u].FF *= (R1 + dp[v].FF)) %= M1;
	(dp[u].SS *= (R2 + dp[v].SS)) %= M2;
  }
}

int dfs2(int u, int p, VVI& G, PLL acc, PLL& target){
  if(p != -1){
	dp2[u].FF = dp[u].FF * (R1 + acc.FF) % M1;
	dp2[u].SS = dp[u].SS * (R2 + acc.SS) % M2;
  }
  else
	dp2[u] = dp[u];

  if(dp2[u] == target)
	return 1;
  
  for(int to: G[u]){
	if(to == p) continue;
	PLL tmp = dp2[u];
	(tmp.FF *= inv((R1 + dp[to].FF) % M1, M1)) %= M1;
	(tmp.SS *= inv((R2 + dp[to].SS) % M2, M2)) %= M2;
	if(dfs2(to, u, G, tmp, target))
	  return 1;
  }
  return 0;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  random_device rd;
  R1 = rd();
  R2 = rd();

  cin >> N1 >> M;
  VVI G(N1);
  REP(i,M){
	int u, v; cin >> u >> v;
	--u, --v;
	G[u].PB(v);
	G[v].PB(u);
  }

  cin >> N2;
  VVI T(N2);
  REP(i,N2-1){
	int u, v;
	cin >> u >> v;
	--u, --v;
	T[u].PB(v);
	T[v].PB(u);
  }

  int ans = 0;
  PLL th = thash(0, -1, T);
  vector<bool> used(N1);
  REP(i,N1){
	if(used[i]) continue;
	int sz = getsz(i, used, G);
	if(sz != N2) continue;
	dfs1(i, -1, G);
	ans += dfs2(i, -1, G, MP(1,1), th);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 31964
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  map<int,int>d;
  //map<int,int>::iterator itr;
  int l=1;
  int b=0;
  for(int i=0;i<n;i++)
  {
   // int a,b=0;
    //cin>>a;
    ++d[a[i]];
  }
  for(int i=0;i<n;i++) 
  {
    if(d[a[i]]>=2)
        {
            l=0;
            break;
        }
  }
  if(l==0)
    cout<<"NO";
  else
        cout<<"YES";
  return 0;
}


Measured memory_bytes: 10368
#include<stdio.h>
#include<limits.h>


int main(){

    int  i;
    int  n;
    unsigned long long int a=1 ,b [1000000];

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%lld",&b[i]);
        
    }

    for(i=0;i<n;i++){
        if(b[i]==0){
            printf("0");
            return 0;
        }
    }

    for(i=0;i<n;i++){

        if(b[i]<=1000000000000000000/a){
            a*=b[i];
        }else{
            printf("-1");
            return 0;
        }
    }
    printf("%lld",a);
    
    

    return 0;
}

Measured memory_bytes: 2516
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			@SuppressWarnings("unused")
			int h = scanner.nextInt(), w = scanner.nextInt(), m = scanner.nextInt();
			Map<Data, Boolean> bombMap = new HashMap<>();
			Map<Integer, Integer> xCountMap = new HashMap<>(), yCountMap = new HashMap<>();
			IntStream.range(0, m).forEach(i -> {
				int x = scanner.nextInt() - 1, y = scanner.nextInt() - 1;
				bombMap.put(new Data(x, y), true);
				xCountMap.put(x, xCountMap.getOrDefault(x, 0) + 1);
				yCountMap.put(y, yCountMap.getOrDefault(y, 0) + 1);
			});
			int xCountMax = xCountMap.values().stream().mapToInt(Integer::intValue).max().getAsInt();
			int yCountMax = yCountMap.values().stream().mapToInt(Integer::intValue).max().getAsInt();
			List<Entry<Integer, Integer>> xCountEntries = xCountMap.entrySet().stream()
					.filter(entry -> xCountMax == entry.getValue()).collect(Collectors.toList());
			List<Entry<Integer, Integer>> yCountEntries = yCountMap.entrySet().stream()
					.filter(entry -> yCountMax == entry.getValue()).collect(Collectors.toList());
			for (Entry<Integer, Integer> xCountEntry : xCountEntries) {
				for (Entry<Integer, Integer> yCountEntry : yCountEntries) {
					if (null == bombMap.get(new Data(xCountEntry.getKey(), yCountEntry.getKey()))) {
						System.out.println(xCountMax + yCountMax);
						return;
					}
				}
			}
			System.out.println(xCountMax + yCountMax - 1);
		}
	}

	private static class Data {
		int x;
		int y;

		Data(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int hashCode() {
			return Objects.hash(x, y);
		}

		@Override
		public boolean equals(Object o) {
			if (o instanceof Data) {
				Data data = (Data) o;
				return (x == data.x) && (y == data.y);
			}
			return false;
		}
	}
}


Measured memory_bytes: 128868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define T() long long t;cin>>t;for(long long i=1;i<=t;i++)
#define INF (int)MAX_INT
#define INFS (int)MIN_INT
#define mod 1000000007
#define FOR(a, b, n) for(int a = b; a < n; a++)
#define REP(a,c, b) for(int a = c; a < b; a++)
#define FORD(a, b, c) for(int a = b; a >= c; a--)
#define REPD(a, c,b) for(int a = b-1; a >= c; a--)
#ifdef HOHOHO
#define DEBUG(x) cerr << #x << " : " << x << '\n'
#define DEBUGV(x) cerr << #x << " : { "; REP(_it, x.size()) cerr << x[_it] << ' '; cerr << "}" << '\n'
#define DEBUGA(x, y) cerr << #x << " : { "; REP(_it, y) cerr << x[_it] << ' '; cerr << "}" << '\n'
#define PRINTF(...) fprintf(stderr,__VA_ARGS__)
#define CHECKPOINT cerr << "OK LINE #" << __LINE__ << '\n'
#else
#define DEBUG(x) {}
#define DEBUGV(x) {}
#define DEBUGA(x, y) {}
#define PRINTF(...) {}
#define CHECKPOINT {}
#endif
#define RESET(a, b) memset(a, b, sizeof a)
#define EPS 1e-9
#define m_p make_pair
#define pb push_back
#define fi first
#define se second
#define RALL(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define ALL(x, y) x, x+y
#define SZ(x) ((int)x.size())
#define  pi(a)  pair<a, a> 
#define  vi(a)  vector<a> 
#define  vii(a) vector<pi(a)>
#define  vs vector<string>
template<class T> T sqr(T x){ return x*x; }
template<class T> T binPow(T p, int q, int MOD) {
    if(q == 1) return p % MOD;
    if(q & 1) return p*(binPow(p, q-1, MOD) % MOD) % MOD;
    else return sqr(binPow(p, q/2, MOD) % MOD) % MOD;
}
 
ll nxt() {
    ll temporaryVariable;
    cin >> temporaryVariable;
    return temporaryVariable;
}
const double PI = acos(-1.0);
#define MAXN 100001
const int G = 2e5 + 5;
 
 
 
int main(){
  ios::sync_with_stdio(false);

  int n;cin>>n;
  vii(int) v;
  
  REP(i,0,n){
      int x,y;cin>>x>>y;
      v.pb(m_p(x,y));
  }
  
bool flag=false,ok=true;

  
  for(int i=0;i<=(n-3);i++){
      
      ok=true; 
      int cnt=0;
      for(int j=i;j<i+3;j++)
      {
          
        if(v[j].first==v[j].second && ok==true){
           cnt++;  
         }
         
        else {
         ok=false;
        }
     }
     if(cnt>=3)flag=true;
  }
 
  if(flag)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
 
    #ifdef HOHOHO   
    fprintf(stderr, "%.3lf\n", clock() / (double) CLOCKS_PER_SEC );
#endif
}
 



Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		/*
		 * Ring StrS = random point;
		 *
		 * ????¨????????????? StrP
		 *
		 * 1???????????????????????°
		 *
		 * 1 <= P.length <= S.length <= 100
		 *
		 *	>> YES or NO ?
		 */

		// input info
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// variable declear
		String strS,strP ;

		// break condition
		//while((strS=br.readLine())!=null || (strP=br.readLine())!=null ){
		strS = br.readLine();
		strP = br.readLine();

		// Check Works
		strS += strS;

		//output info
		if(strS.contains(strP))
			System.out.println("Yes");
		else
		System.out.println("No");
		}
	}

Measured memory_bytes: 24384
#include<bits/stdc++.h>
#define maxn 100005
#define Mod 1000000007
#define Val(x) (((long long)x) % Mod)
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	map<int,int> cnt;
	for(int i=1,val;i<=n;i++) {
		cin >> val;
		cnt[val]++;
	} 
	int ans = 1;
	for(int i=1;i<=(n+1)/2;i++) {
		int num = ((n&1) && i == (n+1)/2 ? 1 : 2);
		if(cnt[abs((n-i)-(i-1))] != num)
			ans = 0;
		else
			ans = Val(ans * num);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

string s;
ll l,r;

int z[430252*2];
void zalgo(string s){
  REP(i,s.size())z[i] = 0;
  // z algorithm
  // http://snuke.hatenablog.com/entry/2014/12/03/214243
  z[0] = s.size();
  {
    int i=1,j=0;
    while(i<s.size()){
      while(i+j<s.size() && s[j]==s[i+j]){
        j++;
      }
      z[i]=j;
      if(j==0){
        i++;
        continue;
      }
      int k=1;
      while(i+k<s.size() && k+z[k]<j){
        z[i+k] = z[k];
        k++;
      }
      i+=k;
      j-=k;
    }
  }
}

ll fibmemo[1252];
ll fib(int x){
  if(x==0)return 0;
  if(x==1)return 1;
  if(fibmemo[x]>0)return fibmemo[x];
  return fibmemo[x] = fib(x-1)+fib(x-2);
}

ll cnt[26];
ll ans[26];

void calc(string &X, string &Y, ll end){
  ll x = X.size();
  ll y = Y.size();
  if(end <= x+y){
    // greedy
    REP(i,end){
      if(i<x)cnt[X[i]-'a']++;
      else cnt[Y[i-x]-'a']++;
    }
    return;
  }
  ll xcnt = 1; int xi=1;
  ll ycnt = 0; int yi=0;
  while(x*xcnt <= end && y*ycnt <= end && x*xcnt+y*ycnt > 0 && x*xcnt+y*ycnt <= end){
    xcnt = fib(++xi);
    ycnt = fib(++yi);
  }
  xcnt = fib(--xi);
  ycnt = fib(--yi);
  REP(i,x)cnt[X[i]-'a']+=xcnt;
  REP(i,y)cnt[Y[i]-'a']+=ycnt;
  ll len = x*xcnt+y*ycnt;
  if(len==end)return;
  calc(X,Y,end-len);
}

string f(string s){
  zalgo(s);
  int n = s.size();
  int k = 0;
  REP(i,(n-1)/2){
    if(z[n-1-i]>=i+1)k=i+1;
  }
  string t = s.substr(0,n-k);
  return t+t;
}

int main(){
  cin>>s;
  int n = s.size();
  cin>>l>>r;
  s = f(s);
  int x1 = s.size();
  // first step
  s = f(s);
  int x2 = s.size();
  // second
  string t = f(s);
  int x3 = t.size();

  if(x3-x2 == x2-x1){
    int width = x3-x2;
    {
      ll x = r;
      ll tms = x/width;
      ll y = x-tms*width;
      REP(i,width)ans[s[i]-'a'] += tms;
      REP(i,y)ans[s[i]-'a']++;
    }
    {
      ll x = l-1;
      ll tms = x/width;
      ll y = x-tms*width;
      REP(i,width)ans[s[i]-'a'] -= tms;
      REP(i,y)ans[s[i]-'a']--;
    }
    REP(i,26)printf("%llu%c",ans[i],i==25?'\n':' ');
    return 0;
  }

  string X = s.substr(0,s.size()/2);
  string Y = t.substr(X.size(),t.size()/2-X.size());
  calc(X,Y,r);
  REP(i,26)ans[i]=cnt[i];
  REP(i,26)cnt[i]=0;
  calc(X,Y,l-1);
  REP(i,26)ans[i]-=cnt[i];
  REP(i,26)printf("%llu%c",ans[i],i==25?'\n':' ');
  return 0;
}


Measured memory_bytes: 4640
import java.util.*;
interface Main{
	static void main(String[]$){
		Scanner s=new Scanner(System.in);
		final int D=1000000007,N=s.nextInt(),M=s.next().length();
		s.close();
		long[]p=new long[N+1],a=new long[N+1];
		p[M]=1;
		for(int i=N;i>=1;i--){
			a[0]=(p[0]+p[1])%D;
			for(int j=1;j<i;j++)a[j]=(p[j-1]*2+p[j+1])%D;
			System.arraycopy(a,0,p,0,i);
		}
		System.out.println(a[0]);
	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<cstdint>
#include<algorithm>

int64_t calc(int64_t a1, int64_t a2, int64_t b1, int64_t b2, int lv, int64_t L) {
  if(lv == 0) return 0;
  int64_t Lb = L/3;
  int64_t bi_a1 = a1/Lb;
  int64_t bi_a2 = a2/Lb;
  int64_t bi_b1 = b1/Lb;
  int64_t bi_b2 = b2/Lb;
  if(bi_a1 == bi_b1 && bi_a2 == bi_b2) {
    return calc(a1%Lb, a2%Lb, b1%Lb, b2%Lb, lv-1, Lb); // same block
  }
  if(bi_a2 == bi_b2) { std::swap(a1, a2); std::swap(b1, b2); }
  // bi_a2 != bi_b2
  while(Lb > 0) {
    bi_a1 = a1/Lb;
    bi_b1 = b1/Lb;
    if(bi_a1 != bi_b1) return std::abs(a1-b1) + std::abs(a2-b2);
    if(bi_a1 == 1 && std::abs(a2/Lb - b2/Lb) > 1) {
      //a1 %= Lb;
      //b1 %= Lb;
      //return std::abs(a2 - b2) + std::min(a1+b1+2, Lb*2-a1-b1);
      int64_t r1 = a1 - (Lb-1) + b1 - (Lb-1);
      int64_t r2 = Lb*2 - a1 + Lb*2 - b1;
      return std::abs(a2-b2) + std::min(r1, r2); 
    }
    a1 %= Lb;
    b1 %= Lb;
    Lb /= 3;
  }
  return std::abs(a2 - b2);
}

int main() {
  int64_t L = 1;
  for(int i = 0; i < 30; ++i) L *= 3;
  int Q; std::cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int64_t a, b, c, d; std::cin >> a >> b >> c >> d;
    std::cout << calc(a-1, b-1, c-1, d-1, 30, L) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
//終局から考える。
//S[i] = '1'なるiについて、A[i]が{A[j], i+1≦j≦N-1, S[j] = '0'}と独立ならx≠0.
//全て従属とする。iが大きい方から考えると、最終的にx=0(従属)にできる。
//独立性の判定:
//・各数を2進数ベクトルと考えて {A[j], i+1≦j≦N-1, S[j] = '0'}について掃き出し法をおこない、
//  表現できるベクトル集合が同一のより単純な表現に直す
//・その表現では'1'の立つ最上位ビットの場所がdistinctだから、A[i]を作れるかを貪欲に判定できる
//計算量はO(TN^3). 厳しい？ -> 定数倍が軽いので大丈夫そう. 0ベクトルを取り除かないバージョン.
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
 
void sweep(vector<int> &vs) {
	int n = vs.size();
	int row = 0;
	
	for (int i = 59; i >= 0; i--) {
		int pipot = -1;
		for (int j = row; j < n; j++) {
			if ((vs[j] >> i) & 1) {
				pipot = j;
				break;
			}
		}
		if (pipot == -1) continue;
		swap(vs[row], vs[pipot]);
		
		for (int j = row + 1; j < n; j++) {
			if ((vs[j] >> i) & 1) {
				vs[j] ^= vs[row];
			}
		}
		row++;
	}
}
 
int solve(vector<int> a, string s) {
	int n = a.size();
	
	vector<int> vs;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '0') {
			vs.push_back(a[i]);
		}
		else {
			sweep(vs);
			int val = a[i];
			for (int j = 0; j < vs.size(); j++) {
				if ((val ^ vs[j]) < val) {
					val ^= vs[j];
				}
			}
			if (val != 0) return 1;
		}
	}
	return 0;
}
 
signed main() {
	int T;
	cin >> T;
	while (T--) {
		int i, n; cin >> n;
		vector<int> a(n);
		rep(i, n) cin >> a[i];
		string s; cin >> s;
		cout << solve(a, s) << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
L, R = map(int, input().split())
if R - L >= 2019:
    print(0)
    exit()
L_mod = L % 2019
R_mod = R % 2019
if L_mod > R_mod:
    R_mod += 2019
can = float('INF')
for i in range(L_mod, R_mod):
    for j in range(i + 1, R_mod + 1):
        if can > i * j % 2019:
            can = i * j % 2019
print(can)


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        sum += x;
    }
    if (sum > n) {
        cout << "-1" << endl;
    } else {
        cout << n - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
from fractions import gcd
a, b, c, d = map(int, input().split())


def calc(n, div_1, div_2):
    cnt = n // div_1
    cnt += n // div_2
    lcm = div_1 * div_2 // gcd(div_1, div_2)
    cnt -= int(n // lcm)
    return n - cnt


print(calc(b, c, d) - calc(a-1, c, d))


Measured memory_bytes: 5076
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int a;
	string s;
	cin>>a;
	cin>>s;
	if(a>=3200)
	{
		cout<<s<<endl;
	}
	else
	{
		cout<<"red"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,m){
        int a;
        cin>>a;
    }
    cout<<n-1-m<<endl;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 100005
#define inf 1000000000000000008LL
ll arr[102], dp[2][mx], weight[102], value[102];
int n;
int main()
{
    int cap;
    scanf("%d%d",&n, &cap);
    for(int i=1; i<=n; i++)
        scanf("%lld%lld",&weight[i], &value[i]);
    memset(dp, 0, sizeof dp);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=cap; j++){
            if(j - weight[i] >=0)
                dp[i%2][j] = max(dp[(i+1)%2][j], value[i] + dp[(i+1)%2][ j-weight[i] ]);
            else
                dp[i%2][j] = dp[(i+1)%2][j];
        }
    }
    printf("%lld\n", dp[n%2][cap]);
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    string s,g;
    
    cin >> s;
    cin >> g;
    
    if ((s[0]==g[2])&&(s[1]==g[1])&&(s[2]==g[0])){
    
    cout << "YES" << endl;
    
    }else{
    
    cout << "NO" << endl;
    
    }

return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline void read(rel &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  x=f?x:-x;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int mulu=55555;
int pr[mulu|10],p[mulu|10]={1,1},pnum;

void pre(){
int i,j;
for (i=2;i<=mulu;++i) if (!p[i]){
  pr[++pnum]=i;
  for (j=i<<1;j<=mulu;j+=i) p[j]=1;
  }
}

int main(){
int i,j,cnt=0,ans[59];pre();
for (i=1;i<=pnum&&cnt<=55;++i){
  if (pr[i]%5==1) ans[++cnt]=pr[i];
  }
int n=read();
for (i=1;i<=n;++i) write(ans[i]),p32;
}

Measured memory_bytes: 512
n = int(input())
S = []
for _ in range(n):
    S.append(int(input()))

min_not_ten = 1000
for i in range(n):
    if S[i] <= min_not_ten and S[i] % 10 != 0:
        min_not_ten = S[i]
if min_not_ten == 1000:
    min_not_ten = 0

if sum(S) % 10 != 0:
    ans = sum(S)
elif min_not_ten == 0:
    ans = 0
else:
    ans = sum(S) - min_not_ten

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<double> x(n);
    vector<double> y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }
    vector<int> num(n);
    rep(i, n) num[i] = i;
    double sum = 0;
    double div_num = 0;
    do {
        rep(i, n-1) {
            int idx1 = num[i];
            int idx2 = num[i+1];
            double dx = x[idx2] - x[idx1];
            double dy = y[idx2] - y[idx1];
            dx = dx * dx;
            dy = dy * dy;
            //printf("%lf\n", sqrt(dx + dy));
            sum += sqrt(dx + dy);

        }
        ++div_num;
    } while(next_permutation(num.begin(), num.end()));
    //cout << div_num << endl;
    printf("%7lf\n", sum / div_num);
    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
using namespace std;
#include<string>
#include<cstdlib>

class stack
{
    int S[101], top, MAX;
public:
    stack();
	void initialize(){ top = 0; MAX = 100; }
	void push(int x){ top++; S[top] = x; }
	int pop(){ top--; return S[top + 1]; }
};

stack::stack(){}

int main()
{
    stack s = stack();
    string t;
	int a, b;
    s.initialize();

    while(cin >> t){
        if(t[0] >= '0'){
            s.push(atoi(t.c_str()));
        }else{
            b = s.pop(); a = s.pop();
            if(t[0] == '+') s.push(a + b);
            if(t[0] == '*') s.push(a * b);
            if(t[0] == '-') s.push(a - b);
        }
    };
    cout << s.pop() << endl;

    return 0;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    int e_sum = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
            e_sum += a[i][j];
        }
    }
    e_sum /= 2;

    // WF をまわして更新が起こらなければよさそう
    vector<vector<int>> dp = a;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            bool flag = false;
            for(int k=0; k<n; k++){
                if(k == i || k == j) continue; // 自明になってしまう
                if(dp[i][j] > dp[i][k] + dp[k][j]){
                    cout << -1 << endl;
                    return 0;
                }
                else if(dp[i][j] == dp[i][k] + dp[k][j]){
                    flag = true; // 辺 ij はいらなそう
                }
            }
            if(flag){
                // ある k について dp[i][j] = dp[i][k] + dp[k][j] だったので、辺 ij は辺 ik と辺 kj の和とすればよく、不要
                e_sum -= dp[i][j];
            }
        }
    }
    cout << e_sum << endl;

    return 0;
}

#if 0
4 
0 1 100 11
1 0 101 10
100 101 0 111
11 10 111 0
// 想定解 111
#endif

Measured memory_bytes: 5004
def solve():
    N, *a_l = map(int, open(0).read().split())
    a_l = [0] + a_l

    for i in range(N//2, 0, -1):
        a_l[i] = sum(a_l[i::i]) % 2

    b_l = [i for i, x in enumerate(a_l) if x]

    print(len(b_l))
    if len(b_l) != 0:
        print(' '.join(map(str, b_l)))


if __name__ == '__main__':
    solve()

Measured memory_bytes: 18424
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
    
/*
    Author: Koushik Sahu
    Created: 19 Sep 2020 17:21:15
*/

string s;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>s;
    if(s[s.length()-1]=='s'){
        s = s + "es";
    }else{
        s = s + "s";
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 3652
//35
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int d[101][101];
  for(int n,m,s,g1,g2;cin>>n>>m>>s>>g1>>g2,n|m|s|g1|g2;){
    for(int y=1;y<=n;y++){
      for(int x=1;x<=n;x++){
	d[y][x]=(y==x)?0:1<<28;
      }
    }
    for(int i=0;i<m;i++){
      int b1,b2,c;
      cin>>b1>>b2>>c;
      d[b1][b2]=c;
    }
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	for(int k=1;k<=n;k++){
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
	}
      }
    }
    int ans=1<<30;
    for(int i=1;i<=n;i++){
      ans=min(ans,d[s][i]+d[i][g1]+d[i][g2]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

struct UnionFind {
  vector<ll> d;
  UnionFind(ll n = 0) : d(n, -1) {
  }
  ll find(ll x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
  ll size(ll x) {
    return -d[find(x)];
  }
};

ll deg[100005];
vll to[100005];

signed main() {
  ll n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    deg[a]++;
    deg[b]++;
    uf.unite(a, b);
  }

  rep(i, k) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].pb(b);
    to[b].pb(a);
  }

  rep(i, n) {
    ll ans = uf.size(i) - 1 - deg[i];
    for (ll u : to[i]) {
      if (uf.same(i, u)) {
        ans--;
      }
    }
    if (i == 0) {
      cout << ans;
    } else {
      cout << " " << ans;
    }
  }
  ENDL;

  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string S;
int p,ch[1<<8];

ll getNum(){
  ll res=0;
  while(isdigit(S[p])) res=res*10+S[p++]-'0';
  return res;
}

ll get(ll &a,ll b,char c){
  if(c=='+')a+=b;
  if(c=='-')a-=b;
  if(c=='*')a*=b;
  return a;
}

ll calc(int c){
  ll res,t;
  if(S[p]=='(') p++,res=calc(-1),p++;
  else res=getNum();
  while(p<S.size()&&S[p]!=')'&&ch[S[p]]>c)t=S[p++],get(res,calc(ch[t]),t);
  return res;
}

int main(){
  cin>>S; 
  ll res=calc(-1);
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++) {
	ch['+']=i,ch['-']=j,ch['*']=k;
	p=0;
	res=max(res,calc(-1));
      }
  
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
	int r, c;
	int t[103][103] = {0};
	
	cin >> r >> c;
	
	for(int i = 1; i <= r;i++){
		for(int j = 1; j <= c;j++){
			cin >> t[i][j];
			t[r+1][j] += t[i][j];
			t[i][c+1] += t[i][j];
			t[r+1][c+1] += t[i][j];
		}
	}
	
	for(int i = 1; i <= r+1;i++){
		for(int j = 1; j <= c+1;j++){
			cout << t[i][j];
			if(j != c+1) cout << " ";
		}
		cout << endl;
	}
	
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a[0];
  int g = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    g = __gcd(g, a[i]);
  }
  unordered_set<int> us;
  us.emplace(1);
  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (a[i] != 1) {
      if (us.find(a[i]) != us.end()) {
        flag = false;
        break;
      }
      us.emplace(a[i]);
      int sr = (int)sqrt(a[i]);
      for (int j = 2; j <= sr; j++) {
        if (a[i] % j == 0) {
          if (us.find(j) != us.end()) {
            flag = false;
            break;
          }
          us.emplace(j);
          int k = a[i] / j;
          if (j != k) {
            if (us.find(k) != us.end()) {
              flag = false;
              break;
            }
            us.emplace(k);
          }
        }
      }
      if (!flag) {
        break;
      }
    }
  }
  if (flag) {
    cout << "pairwise coprime" << '\n';
  } else if (g == 1) {
    cout << "setwise coprime" << '\n';
  } else {
    cout << "not coprime" << '\n';
  }
  return 0;
}

Measured memory_bytes: 7160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
map<int,int> v;
int main()
{
    int n,x;
    int sum=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(!v[x])
        {
            v[x]++;
            sum++;
        }
        else
        {
            v[x]--;
            sum--;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 4864
/*
      author : nishi5451
      created: 11.08.2020 01:08:56
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    int n,a;
    cin >> n >> a;
    cout << n*n-a << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i,N){
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  int ans = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      if(L.at(i)==L.at(j)) continue;
      for(int k=j+1; k<N; k++){
        if(L.at(j)==L.at(k)) continue;
        if(L.at(k)<L.at(i)+L.at(j)) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3620
from copy import deepcopy

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    a=list(map(int,input().split()))
    s.append(a)

def score_calculator(l):
    score=0
    las=[0]*26
    for i in range(d):
        for j in range(26):
            las[j]+=1
        las[l[i]]=0
        for j in range(26):
            score-=las[j]*c[j]
        score+=s[i][l[i]]
    return score

for i in range(1,26):
    highest_sum_score=-1000000000000
    last=[0]*26
    temp_ans_lst=[]
    for j in range(d):
        daily_highest_score=-10000000000000
        for k in range(26):
            temp_score=s[j][k]
            temp_last=deepcopy(last)
            for p in range(26):
                temp_last[p]+=1
            temp_last[k]=0
            for p in range(26):
                down=temp_last[p]
                for q in range(i):
                    qdown=down+i+1
                    down+=qdown
                temp_score-=down*c[p]
            if temp_score>daily_highest_score:
                daily_highest_score=temp_score
                daily_choice=k
        for k in range(26):
            last[k]+=1
        last[daily_choice]=0
        temp_ans_lst.append(daily_choice)
    if score_calculator(temp_ans_lst)>highest_sum_score:
        ans_lst=deepcopy(temp_ans_lst)
        
for i in ans_lst:
    print(i+1)

Measured memory_bytes: 85288
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
#include <iomanip>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n;
	cin >> n;
	cout << n * n << endl;
}


Measured memory_bytes: 15872
import java.util.*;

public class Main {
	public static void main(String[] argv) {
		Graph g = new Graph();
		g.loadAdjMatrix();
		int[] dist = g.Dijkstra(0);
		for(int i = 0; i < g.getTotalVertex(); i ++) {
			System.out.println(i + " " + dist[i]);
		}
	}
}

class Graph {
	private int totalVertex;
	//adjMatrix[u][v] = 1 if there is an edge from u to v, otherwise 0
	private int[][] adjMatrix;
	//adjWeight[u][v] -- the weight of the edge from u to v if there is one
	private int[][] adjWeight;
	//if a node is settled (e.g., processed in the Dijkstra's algorithm)
	private Boolean[] ifSettled;
	public Graph() { totalVertex = 0; }
	public int getTotalVertex() { return totalVertex; }
	//load graph from standard input
	public void loadAdjMatrix() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjMatrix = new int[totalVertex][totalVertex];
		adjWeight = new int[totalVertex][totalVertex];
		ifSettled = new Boolean[totalVertex];
		int i, j;
		for(i = 0; i < totalVertex; i ++) {
			ifSettled[i] = false;
			for(j = 0; j < totalVertex; j ++) {
				adjMatrix[i][j] = adjWeight[i][j] = 0;
			}
		}
		int u, v;
		for(i = 0; i < totalVertex; i ++) {
			u = in.nextInt();
			int degree = in.nextInt();
			for(j = 0; j < degree; j ++) {
				v = in.nextInt(); 
				adjMatrix[u][v] = 1;
				adjWeight[u][v] = in.nextInt();
			}	
		}
		in.close();
	}
	//return weight of the edge from u to v if there is one
	public int getWeight(int u, int v) {
		return adjWeight[u][v];
	}
	//return neighbors of u as a LinkedList
	public LinkedList<Integer> getNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if(adjMatrix[u][v] == 1) tmp.add(v);
		}
		return tmp;
	}
	//return unsettled neighbors of u as a LinkedList
	public LinkedList<Integer> getUnsettledNeighbors(int u) {
		LinkedList<Integer> tmp = new LinkedList<Integer>();
		for(int v = 0; v < totalVertex; v ++) {
			if((adjMatrix[u][v] == 1) && (ifSettled[v] == false)) tmp.add(v);
		}
		return tmp;
	}
	//return the unsettled node that has the smallest dist
	public int getUnsettledNearest(int[] dist) {
		int md = Integer.MAX_VALUE;
		int mv = -1;
		int v;
		for(v = 0; v < totalVertex; v ++) {
			if((ifSettled[v] == false) && (dist[v] < md)) {
				md = dist[v];
				mv = v;
			}
		}
		return mv;
	}
	//implement the following
	public int[] Dijkstra(int s) {
		int[] dist = new int[totalVertex];
		int[] previous = new int[totalVertex];
		
		for(int i = 1; i < totalVertex; i++) {
			dist[i] = Integer.MAX_VALUE;
			previous[i] = -1;
		}
		dist[s] = 0;
	
		LinkedList<Integer> settled = new LinkedList<Integer>();
		
		while(!settled.containsAll(getNeighbors(s))) {
			int u = getUnsettledNearest(dist);
			if(dist[u] == Integer.MAX_VALUE) {
				break;
			}
			for(int j = 0; j < totalVertex; j++) {
				int v = getUnsettledNearest(dist);
				ifSettled[v] = true;
				for (int x = 0; x < totalVertex; x++) {
					if (ifSettled[x] == false && adjMatrix[v][x] == 1) {
						dist[x] = Math.min(dist[v] + getWeight(v, x), dist[x]);
					}
				}
				settled.add(v);
			}
		}
		
		
		return dist;

	}

}



Measured memory_bytes: 40072