akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  string s;cin>>s;
  vector<vector<int>> dp(n+5,vector<int>(n+5,0));
  rep1(i,n)dp[1][i]=1;
  rep1(i,n-1){
      char sign=s[i-1];
      if(sign=='>'){
          rep1(j,n){
              dp[i+1][1]+=dp[i][j];
              dp[i+1][j]+=MOD-dp[i][j];
          }
      }
      else{
          rep1(j,n){
              dp[i+1][n+1-i]+=MOD-dp[i][j];
              dp[i+1][j]+=dp[i][j];
          }
      }
      rep1(j,n){
          dp[i+1][j]=dp[i+1][j-1]+dp[i+1][j];
          dp[i+1][j]%=MOD;
      }
  }
  cout<<dp[n][1]<<"\n";
  return 0;
}

Measured memory_bytes: 72960
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		PrintWriter pw=new PrintWriter(System.out);
		char[] cs=sc.next().toCharArray();
		int[] cnt=new int[26];
		for(char c:cs) {
			cnt[(int)(c-'A')]++;
		}
		boolean ans=true;
		for(int v:cnt) {
			ans&=v==0||v==2;
		}
		pw.println(ans?"Yes":"No");
		pw.close();
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
    	return Integer.parseInt(next());
    }
    
    public long nextLong() {
    	return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second
int main(){
    ll n;
    cin>>n;
    vi v(n);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    ll max = 0;
    ll c = 0;
    for(ll i=0;i<(n-1);i++){
        if(v[i+1]<=v[i]){
            c++;
            if(c>max){
                max = c;
            }
        }
        else{
            c = 0;
        }
    }

    if(c>max){
        max = c;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 1024
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
# include <algorithm>
# include <string>
using namespace std;


int main(){
    int n;
    
	while(1){
        cin >>n;
        if(n ==0) break;
        else
        {int sum =0 ;
            double a,avg,x =0;
            double b[n];
                    for(int i =0;i<n;i++){
                        cin >>b[i];
                        sum += b[i];
                    }
                    avg = (double)sum /(double)n;
                    for(int j=0;j<n;j++){
                       x += pow(b[j]-avg,2);
                    }
                    a= (double)x/(double)n;
                     printf("%.7f\n",pow(a,0.5));
        }

    }

	return 0;
}



Measured memory_bytes: 3408
#include<iostream>

using namespace std;

int main(){

	int a,b,c,d,e; 
	cin >> a >> b >> c >> d >> e;
	int answer;


	if(a<0){
		answer=-a*c+e*b+d;
	      }

	if(a>0){
		answer=e*b-e*a;
	}
	cout << answer <<endl;


	return 0;
}


Measured memory_bytes: 3096
n=int(input())
h=[int(x) for x in input().split()]

ans=0
for y in range(max(h))[::-1]:
    rzk=0
    for x in range(n):
        if y+1==h[x]:
            h[x]-=1
            if not rzk:
                ans+=1
                rzk=1
        else:
            rzk=0
            
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(){
  int n, m;
  scanf("%d %d", &n, &m);

  int aluno[n][2];
  int coor[m][2];

  for(int i = 0; i < n; ++i)
    scanf("%d %d", &aluno[i][0], &aluno[i][1]);

  for(int i = 0; i < m; ++i)
    scanf("%d %d", &coor[i][0], &coor[i][1]);

  for(int i = 0; i < n; ++i){
    int menor = 1000000000;
    int k;
    for(int j = 0; j < m; ++j){
      int x = (abs(aluno[i][0] - coor[j][0]) + abs(aluno[i][1] - coor[j][1]));
      if(x < menor){
        menor = x;
        k = j+1;
      }
    }
    printf("%d\n", k);
  }
  return 0;
}


Measured memory_bytes: 128
x = int(input())
for i in range(x):
    if((i+1)%3 ==0):
        print(" ",end="")
        print(i+1, end="")
        continue
    q = i+1
    while(q != 0):
        if(q%10==3):
            print(" ", end="")
            print(i + 1, end="")
            break
        q=q//10
print()


Measured memory_bytes: 6160
#include<stdio.h>

char S[5] = {0};

int main()
{
    scanf("%s",S);
    for(int i = 0; i < 3; i++)
    {
        if(S[i] != S[2 - i])
        {
            printf("No\n");
            return 0;
        }
    }printf("Yes");
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

N=INT()
P=[0]*(N+1)
for i in range(N):
    r,c=MAP()
    if i==0:
        P[i]=r
    P[i+1]=c

dp=[[INF]*(N+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][i]=0

for l in range(2, N+1):
    for i in range(1, N-l+2):
        j=i+l-1
        for k in range(i, j):
            dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+P[i-1]*P[k]*P[j])
print(dp[1][N])



Measured memory_bytes: 5688
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){
    long a, b;
    cin >> a >> b;
    long r, x, tmp;

    x = a * b;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    cout << x/b << endl;

}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

res=0

Hmax = max(H)
Hmax_idx = 0
localmax=H[0]
for idx,h in enumerate(H):
    if h >= localmax:
        localmax = h
        res+=1
    else:
        continue
    

    if h == Hmax:
        Hmax_idx = idx
        break

if Hmax_idx+1 < N:
    for i in range(idx+1,N):
        if H[i] >= Hmax:
            res+=1

print(res)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    string s,t;
    cin >> s;
    cin >> t;

    string test = t + t;
    if (test.find(s) != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int digitlen(int i){
    int t = i;
    int count = 0;
    while(t){
        count++;
        t /= 10;
    }
    return count;
}

int main(){
    int n;
    cin >> n;
    set<int> s;
    while(n--){
        int t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 256
N = int(input())
idx = {int(input()): i for i in range(N)}
res = N - 1
cnt = 1
for x in range(2, N + 1):
    if idx[x - 1] < idx[x]:
        cnt += 1
    else:
        res = min(res, N - cnt)
        cnt = 1
print(min(res, N - cnt))

Measured memory_bytes: 32608
<?php
fscanf(STDIN, "%d", $n);
$inputs = array_map('intval', explode(' ', trim(fgets(STDIN))));
$max = max($inputs);

$decs = [];
for ($i = 0; $max > $i; $i++) {
    $tmp = 0;
    foreach ($inputs as $input) {
        $x = $input - ($i + 1);
        $y = pow($x, 2);
        #echo join(", ", [$input, $i, $n, $x, $y]) . "\n";
        $tmp += $y;
    }
    #echo "=" . $tmp . "\n";
    $decs[] = $tmp;
}
#echo join(",", $decs) . "\n";
echo min($decs);


Measured memory_bytes: 4604
class BFS():
    def __init__(self, H, W, maze):
        self.H = H
        self.W = W
        self.maze = maze
        self.distance = [[0 for i in range(self.W)] for j in range(self.H)]
        self.sx = 0
        self.sy = 0
        self.gx = W-1
        self.gy = H-1


    def bfs(self):
        queue = []
        queue.insert(0, (self.sx, self.sy))

        self.distance[self.sx][self.sy] = 0

        while len(queue):
            x, y = queue.pop()

            if x == self.gx and y == self.gy:
                break

            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

                if (0 <= nx and nx < self.W and 0 <= ny and ny < self.H and self.maze[ny][nx] != '#' and self.distance[ny][nx] == 0):
                    queue.insert(0, (nx, ny))
                    self.distance[ny][nx] = self.distance[y][x] + 1
        return self.distance[self.gy][self.gx]

H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]
bfs = BFS(H,W,maze)
distance = bfs.bfs()
black = 0
for i in range(H):
    black += maze[i].count('#')

if distance == 0:
    print(-1)
else:
    print(H*W - (distance+1)-black)

Measured memory_bytes: 3188
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // Initialize
          	var intN = cin.ReadInt;
          	var aryP = cin.ReadIntArray(intN);
          	var intMin = aryP[0];
          	var intAns = 0;
            // Process
			for (int i = 0; i < intN; i++)
			{
				if(aryP[i] <= intMin)
				{
					intMin = aryP[i];
					intAns++;
				}
			}
            // Output
        	WriteLine( intAns );
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main() {
  int N, a = 0, n;
  cin >> N;
  n = N;
  
  for (int i = 0; i < 9; i++) {
	a += N % 10;
    N /= 10;
  }
  
  if (n % a == 0) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3564
x,y=map(int,input().split())
mod=10**9+7

def comb(n,k):
    if n<k:
        return 0
    if n-k<k:
        k=n-k
    comb=1
    for x in range(n-k+1,n+1):
        comb=(comb*x)%mod
    d=1
    for x in range(1,k+1):
        d =(d*x)%mod
    comb*=pow(d,mod-2,mod)
    return comb%mod

ans=0
if (x+y)%3==0:
    n=int((x+y)/3)
    r=int((2*x-y)/3)
    if n-r>=0 and r>=0:
        ans=comb(n,r)%mod
print(ans)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) {
    cout << 1 << endl;

  } else if (a == b && a != c) {
    cout << 2 << endl;

  } else if (a != b && a == c) {
    cout << 2 << endl;
  } else if (b == c && a != c) {
    cout << 2 << endl;

  } else {
    cout << 3 << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int alice = 0;
  int bob = 0;
  
  rep(i, n) {
    if (i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }
  
  cout << (alice - bob) << endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int n;
	cin>>n;
	int t[10][10]={0};
	loop(i,1,n+1){
		string s=to_string(i);
		int a=s[0]-'0',b=s.back()-'0';
		t[a][b]++;
	}
	int s=0;
	rep(i,10)rep(j,10)s+=t[i][j]*t[j][i];
	cout<<s<<endl;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string S; cin >> S;
    if(S[0] == S[1] && S[1] == S[2]) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=200020,mod=998244353;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
inline int qmo(int x){return x+(x>>31?mod:0);}
int n,at=1,stk[maxn],tp;
ll aa[maxn],bb[maxn],a[maxn],b[maxn],g[maxn];
long double ans;
int main(){
	n=read();
	FOR(i,1,n) aa[i]=read();
	FOR(i,1,n) bb[i]=read();
	FOR(i,1,n) if(aa[i]>aa[at]) at=i;
	FOR(i,1,n){
		int pos=(i-at+1+n)%n;
		if(!pos) pos=n;
		a[pos]=aa[i],b[pos]=bb[i];
	}
	a[n+1]=a[1];b[n+1]=b[1];
	FOR(i,3,n+1) g[i]=2*g[i-1]-g[i-2]-2*b[i-1];
	ROF(i,n+1,1){
		a[i]+=g[i];
		while(tp>=2){	
			ll x_1=stk[tp]-stk[tp-1],y_1=a[stk[tp]]-a[stk[tp-1]];
			ll x_2=i-stk[tp-1],y_2=a[i]-a[stk[tp-1]];
			if(x_1*y_2-x_2*y_1<=0) tp--;
			else break;
		}
		stk[++tp]=i;
	}
	FOR(i,1,tp-1) ans+=1.0L*(a[stk[i+1]]+a[stk[i]])*(stk[i]-stk[i+1]+1)/2-a[stk[i]];
	FOR(i,1,n) ans-=g[i];
	printf("%.10lf\n",(double)ans/n);
}

Measured memory_bytes: 11848
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

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

	while (t--) {
		double x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double a = y2 - y1;
		double b = x2 - x1;
		double c = (x2*x2 - x1*x1 + y2*y2 - y1*y1)/2;
		double d = y3 - y2;
		double e = x3 - x2;
		double f = (x3*x3 - x2*x2 + y3*y3 - y2*y2)/2;

		double px = (c*d - a*f) / (b*d - a*e);
		double py = (c*e - b*f) / (a*e - d*b);

		double r = sqrt((px - x1)*(px - x1) + 
			(py - y1)*(py - y1));

		cout << fixed << setprecision(3);
		cout << px << " " << py << " " << r << endl;
	}

	return 0;
}

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

int sx, sy, tx, ty;

int main(void){
  cin >> sx >> sy >> tx >> ty;
  int p, q;
  p = tx-sx;
  q = ty-sy;
  for(int i = 0; i < q; i++) cout << 'U';
  for(int i = 0; i < p; i++) cout << 'R';
  for(int i = 0; i < q; i++) cout << 'D';
  for(int i = 0; i < p; i++) cout << 'L';
  cout << 'L';
  for(int i = 0; i < q+1; i++) cout << 'U';
  for(int i = 0; i < p+1; i++) cout << 'R';
  cout << 'D';
  cout << 'R';
  for(int i = 0; i < q+1; i++) cout << 'D';
  for(int i = 0; i < p+1; i++) cout << 'L';
  cout << 'U';
  cout << endl;
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int a[101],b[101];
int main()
{
	int n;
	cin>>n;
	int cnt=0;
	bool flag=false;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		if(a[i]==b[i])
			cnt++;
		else
			cnt=0;
		if(cnt==3)
			flag=true;
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3560
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int h, w;
	cin >> h >> w;
	int cnt[26] = {};
	for (int i = 0; i < h * w; i++) {
		char c;
		cin >> c;
		cnt[c - 'a']++;
	}
	bool ok = true;
	for (int i = 0; i < (h / 2) * (w / 2); i++) {
		for (int j = 0; j < 26; j++) {
			if (cnt[j] >= 4) {
				cnt[j] -= 4;
				break;
			}
			if (j == 25) {
				ok = false;
				i = h * w;
			}
		}
	}
	if (h % 2 == 1) {
		for (int i = 0; i < w / 2; i++) {
			for (int j = 0; j < 26; j++) {
				if (cnt[j] >= 2) {
					cnt[j] -= 2;
					break;
				}
				if (j == 25) {
					ok = false;
					i = w;
				}
			}
		}
	}
	if (w % 2 == 1) {
		for (int i = 0; i < h / 2; i++) {
			for (int j = 0; j < 26; j++) {
				if (cnt[j] >= 2) {
					cnt[j] -= 2;
					break;
				}
				if (j == 25) {
					ok = false;
					i = h;
				}
			}
		}
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define SIZE(x) ll(x.size())

typedef long long ll;

using namespace std;
int main() {
  string S, T;
  cin >> S >> T;
  REP(i, SIZE(S)) {
    if (S == T) {
      cout << "Yes";
      return 0;

    } else {
      string tmp = T;
      tmp.erase(SIZE(T) - 1);
      T = T[SIZE(T) - 1] + tmp;
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
char A[110][110];
int n, m;
int dp[110][110];
int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++) scanf("%s", A[i]);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(i + j == 0){
				dp[i][j] = A[i][j] == '#';
				continue;
			}
			int u = 1e9, l = 1e9;
			if(j > 0) l = dp[i][j-1] + (A[i][j] == '#' && A[i][j-1] == '.');
			if(i > 0) u = dp[i-1][j] + (A[i][j] == '#' && A[i-1][j] == '.');
			dp[i][j] = min(l, u);
		}
	}
	printf("%d\n", dp[n-1][m-1]);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

/*void output(int array[],int n, int count){
  int i;
  
   for(i = 0;i<n;i++){
    if(i>0){
      printf(" ");
    }
      printf("%d",array[i]);
    
  }
    printf("\n");
    printf("%d\n",count);

    
  }
*/


  


int selectionSort(int array[], int n){
  int i,j,miji;
  int tmp;
  int count = 0;
  for(i=0;i<n-1;i++){
    miji = i;
    for(j = i;j<n;j++){
      if(array[j] < array[miji]){
	miji = j;
      }
    }
    tmp = array[i];
    array[i] = array[miji];
    array[miji] = tmp;
    if(i != miji){
      count++;
      
    }
        }
  return count;
}


int main(){
  int array[101];
  int i,n;
  int count;
 

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&array[i]);
  }
  count = selectionSort(array,n);
  // output(array ,n,count);

   for(i = 0;i<n;i++){
    if(i>0){
      printf(" ");
    }
      printf("%d",array[i]);
    
  }
    printf("\n");
    printf("%d\n",count);

    return 0;
  }
    
  



Measured memory_bytes: 2144
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  s = InputLine.to_s
  t = InputLine.to_s
  puts ((s == t[0...s.size]) ? 'Yes' : 'No')
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 14388
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

from collections import deque

h,w = nm()

s = []

for y in range(h):
  s.append([_ for _ in input()])



def bfs(sx,sy,visited):
  xx=[1,-1,0,0]
  yy=[0,0,1,-1]
  
  q=deque([(sx,sy)])
  visited[sy][sx] = 0

  while q:
    _ = q.popleft()
    x=_[0]
    y=_[1]

    for i in range(4):
      nx = x + xx[i]
      ny = y + yy[i]
      
      if 0 <= nx < w and 0 <= ny < h:
        if s[ny][nx] == '.' and visited[ny][nx]==-1:
          visited[ny][nx] = visited[y][x]+1
          q.append((nx,ny))
  mx=0
  for y in range(h):
    for x in range(w):
      mx = max(mx,visited[y][x])
  return mx

MX = 0

for sx in range(w):
  for sy in range(h):
    if s[sy][sx] == '.':
      b = bfs(sx,sy,[[-1]*w for _ in range(h)])
      MX = max(MX,b)

print(MX)

Measured memory_bytes: 9436
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

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

    int maxa=0;
    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=0;j<=i;j++) sum+=a[0][j];
        for(int j=i;j<=n-1;j++) sum+=a[1][j];
        maxa=max(sum,maxa);
    }

    cout<<maxa<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main () {
    int W,H,x,y,r;
    std::cin >>W>>H>>x>>y>>r;
    
    if (x >= r && x <= W-r){
        if (y >= r && y <= H-r){
            std::cout << "Yes" << std::endl;
        }
        else{
            std::cout << "No" << std::endl;
        }
    }
    else{
         std::cout << "No" << std::endl;
    }
    
}


Measured memory_bytes: 3100
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int Map[3][3];
  bool flag=false;
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>Map[i][j];
  for(int k=0;k<=Map[0][0];k++){
    int a[3]={};
    int b[3]={};
    a[0]=k;
    b[0]=Map[0][0]-k;
    bool flag2=false;
    for(int i=0;i<3;i++){
      if(i!=0)a[i]=Map[i][0]-b[0];
      if(a[i]<0){flag2=true;break;}
      for(int j=0;j<3;j++){
	if(i==0)b[j]=Map[i][j]-a[i];
	if(b[j]<0){flag2=true;break;}
	if((b[j]+a[i])==Map[i][j]){;
	}else{
	  flag2=true;
	  break;
	}
      }
      if(flag2)break;
    }
    if(flag2==false){
      flag=true;
      break;
    }
  }
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()

using namespace std;

int main()
{
    IOS;
    int n;
    cin>>n;
    int a[n];
    repf(i,0,n) cin>>a[i];
    vector<int> v;
    int cnt=0;
    repf(i,1,n-1)
    {
        v.clear();
        v.pb(a[i-1]);v.pb(a[i]);v.pb(a[i+1]);
        sort(all(v));
        if(v[1]==a[i]) cnt++;
    }
    cout<<cnt<<endl;
}
 

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

int main() {
  int x;
  cin >> x;
  
  if (x % 10 == x % 100 / 10 && x % 100 / 10 == x % 1000 / 100) {
    cout << "Yes" << endl;
  }
  
  else if (x / 1000 == x % 1000 / 100 && x % 1000 / 100 == x % 100 / 10) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
N = int(input())
A = [int(input()) for i in range(N)]

target = {}

for i in A:
    if i in target:
        target[i] += 1
    else:
        target[i] = 1

ans = 0
for i in target:
    if target[i] % 2 == 0:
        continue
    else:
        ans += 1

print(ans)

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

int keta(ll n) {
  int cnt = 0;
  while (n > 0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

int f(ll a, ll b) {
  int na = keta(a);
  int nb = keta(b);
  return max(na,nb);
}

int main() {
  ll n;
  cin >> n;
  int ans = 10000;
  ll i = 0ll;
  while(i*i < n) {
    i++;
    if (n % i == 0) {
      int num = f(i, n/i);
      if (num < ans) ans = num;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
// AOJ 2138: Vending Machine
// 2017.11.10 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

int a[12], c[1025];
int dp[100002];

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, m, i, j, sum, ans;
	int ii, k, s, lim;
#if TM
	clock_t start, end;
	start = clock();
#endif
	while (scanf("%d%d", &n, &m) && (n|m)) {
		for (i = 0; i < n; i++) scanf("%d", a+i);
		for (lim = 1 << n, j = 0; j < lim; j++) {
			for (s = 0, ii = 1, i = 0; i < n; i++, ii <<= 1) if (j & ii) s += a[i];
			c[j] = s;
		}
		sum = c[lim-1];
		if (m % sum <= lim-1 && c[m % sum] == 1) ans = m/sum + 1;
		else {
			memset(dp, 0x33, sizeof(dp)); dp[0] = 0;
		    for (j = 1; j < lim; j++) for (i = 0; (k=i+c[j]) <= m; i++) {
				if (dp[k] > dp[i]+1) dp[k] = dp[i]+1;
			}
			ans = dp[m];
		}
		printf("%d\n", ans);
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 2144
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<string> x;
    map<string, int> y;
    while(n--){
        string tmp;
        cin>>tmp;
        y[tmp]++;
    }
    int vote = 1;
    map<string, int>::iterator it = y.begin();
    for(auto i = y.begin(); i != y.end(); i++){
        if(i->second > vote){
             vote = i->second;
             it = i;
        }
    }
    vector<int> indAll;
    for(auto i = y.begin(); i != y.end(); i++){
        if(i->second == it->second) x.push_back(i->first);
    }
    sort(x.begin(), x.end());
    for(int i=0; i<x.size(); i++){
        cout<<x[i]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 27224
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func pfs(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func generateComb(index []int, s, r int, ch chan []int) {
	if r != 0 {
		if s < 0 {
			return
		}
		generateComb(index, s-1, r, ch)
		index[r-1] = s
		generateComb(index, s-1, r-1, ch)
	} else {
		ch <- index
	}
	return
}

func Combinations(n, k int, ch chan []int) {
	index := make([]int, k)
	generateComb(index, n-1, k, ch)
	close(ch)
}

func a(M, N int, ch chan int) {
	ans := 1
	for i := N; i < M; i++ {
		if M%i == 0 {
			ans = M / i
			break
		}
	}
	ch <- ans
	//	close(ch)
}

func b(M, N int, ch chan int) {
	ans := 1
	m := M/N + 1
	for i := 1; i < m; i++ {
		if M%i == 0 && ans < i {
			ans = i
		}
	}
	ch <- ans
	//	close(ch)
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()

	c := make(chan int)
	go a(M, N, c)
	go b(M, N, c)

	res := <-c
	out(res)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
using namespace std;

int N;
int X[10];
int Y[10];
int C[10];

int main() {
    cin >> N;
    for (int i = 1; i <= N; ++i) cin >> X[i] >> Y[i];

    double ans = 0.0;
    int count = 0;
    iota(&C[1], &C[N + 1], 1);
    do {
        ++count;
        for (int i = 2; i <= N; ++i) {
            int x1 = X[C[i]];
            int x0 = X[C[i - 1]];
            int y1 = Y[C[i]];
            int y0 = Y[C[i - 1]];
            ans += sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
        }
    } while (next_permutation(&C[1], &C[N + 1]));

    cout << setprecision(10) << ans / count << endl;

    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,k;
  cin >> n >> k;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  vll shoki(n, 0);
  vll total(n, 0);
  REP(i, n){
    REP(j, n){
      if(a[i] > a[j]){
        if(i == j)
          continue;
        else if(i < j){
          shoki[i]++;
          total[i]++;
        }
        else
          total[i]++;
      }
    }
  }

  ll s = 0;
  ll t = 0;
  REP(i, n){
    s += shoki[i];
    t += total[i];
  }

  ll ans = (k*s%MOD + k*(k-1)/2%MOD*t)%MOD;
  cout << ans << endl;

  
  
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc110/tasks/abc110_c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char s[200001];
char t[200001];
char map_s[256];
char map_t[256];

void solv() {
  for (int i = 0; s[i] != '\0'; i++) {
    if (map_s[s[i]] != 0 || map_t[t[i]] != 0) {
      if (map_s[s[i]] != t[i] || map_t[t[i]] != s[i]) {
        puts("No");
        return;
      }
    } else {
      map_s[s[i]] = t[i];
      map_t[t[i]] = s[i];
    }
  }
  puts("Yes");
}

int main(int argc, char **argv) {
  int n, h;

  while (scanf("%s", s) != EOF && scanf("%s", t) != EOF) {
    for (int i = 0; i < 256; i++) {
      map_s[i] = map_t[i] = 0;
    }
    if (strlen(s) != strlen(t)) {
      puts("No");
    } else {
      solv();
    }
  }

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vi b(a);
  sort(a.begin(), a.end());
  int cnt = 0;
  rep(i,n){
    if (a[i] != b[i]) cnt++; 
  }
  if (cnt>2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
} 

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

int main() {
  int k; cin >> k;
  string s; cin >> s;
  if(s.size()<=k) cout << s << endl;
  else {
    rep(i,k) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: u64 = sc.read();
    let b: u64 = sc.read();

    for i in 1..(a + 1) {
        let aa = (i * b + a - 1) / a;
        if aa < greedy(a, b, aa * a) {
            println!("{}", aa * a);
            return;
        }
    }
    println!("-1");
}

fn greedy(a: u64, b: u64, mut x: u64) -> u64 {
    let mut ans = 0;
    ans += x / b;
    x %= b;
    ans += x / a;
    x %= a;
    ans + x
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 5032
#T = int(rw_input())
T = 1

def check(n, D):
    a = map(lambda x : ord(x) - ord('0'), str(n))
    for i in a:
        if i in D:
            return False
    return True


def get(n, D):
    while True:
        if check(n, D):
            return n
        n += 1
    return n

for i in range(T):
    n, k = map(int, raw_input().split())
    D = map(int, raw_input().split())
    D = set(D)
    print get(n, D)

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

int main()
{
	int n; cin >> n;
	string t, h;

	int tscore = 0, hscore = 0;
	while(n-- && cin >> t >> h) {
		int cmp = t.compare(h);
		tscore += ((cmp>0) ? 3 : 0) + !cmp;
		hscore += ((cmp<0) ? 3 : 0) + !cmp;
	}
	cout << tscore << ' ' << hscore << endl;

	return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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;}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

struct UnionFind {
	vector<long long> par;
	UnionFind(long long size):par(size+1,-1){}
	bool unite(long long x,long long y){	//集合の連結
		x=root(x);
        y=root(y);
		if (x!=y){
			if(par[y]<par[x]) swap(x,y);
			par[x]+=par[y];
            par[y]=x;
		}
		return x!=y;
	}
	bool same(long long x,long long y){	//同集合内かの判定
		return root(x)==root(y);
	}
	int root(long long x){	//根を求める
		return par[x]<0?x:par[x]=root(par[x]);
	}
	int size(long long x){	//集合の大きさ
		return -par[root(x)];
	}
};

int main()
{
	ll n,cnt=0,tmp=0;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	sort(rall(a));
	rep(i,n){
		cnt++;
		if(cnt==4){
			cout << a[i]*a[i] << endl;
			return 0;
		}
		else if(cnt==2){
			if(tmp==0) tmp=a[i];
			else{
				cout << tmp*a[i] << endl;
				return 0;
			}
		}
		if(a[i]!=a[i+1] && i!=n-1) cnt=0;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n;
  cin>>n;
  vector<int> x(n),y(n);
  r(i,n)cin>>x.at(i);
  y=x;
  sort(x.begin(),x.end());
  int c=x.at(n/2-1);
  r(i,n){
    if(y.at(i)<=c)cout<<x.at(n/2)<<endl;
    else cout<<x.at(n/2-1)<<endl;
  }



  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535;

ll Combination(ll n, ll r) {
    ll molecule = 1;
    ll denominator = 1;
    for (ll i = 0; i < r; i++) {
        molecule *= n - i;
        denominator *= r - i;
    }
    return (molecule / denominator);
}

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

    vector<vector<int>> jobs(m);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        // a > mの場合無意味、例外処理
        if (a > m) continue;
        jobs[a - 1].push_back(b);
    }

    priority_queue<int> pque;
    ll ans = 0;
    rep(i, m) {
        for (auto b : jobs[i]) {
            pque.push(b);
        }
        if (!pque.empty()) {
            ans += pque.top();
            pque.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5504
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			int a = sc.nextInt();
			int b = sc.nextInt();
			ArrayList<Integer> array = new ArrayList<>();
			array.add(a);
			array.add(b);

			ArrayList<Integer> result = new ArrayList<>();
			result.add(1);
			result.add(2);
			result.add(3);

			result.removeAll(array);

			System.out.println(result.get(0));

		}
	}
}


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

int main()
{
        string str, left, right;
        int h, t, size;

        while(1){
                cin >> str;
                if(str=="-"){break;}
                cin >> h;
                for(int i=0; i<h; i++){
                        cin >> t;
                        size = str.length();
                        left = str.substr(0,t);
                        right = str.substr(t,size-t);
                        str = right + left;
                }
                cout << str << endl;
        }
}




Measured memory_bytes: 3116
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n, m = map(int, input().split())

    parent = {x:[] for x in range(1,n+1)}

    na_num = 1

    for _ in range(m):
        u,v,w = map(int, input().split())
        parent[u].append(v)
        parent[v].append(u)

    base = [1]

    ans = 0

    for i in range(2,n+1):
        if len(parent[i]) == 0:
            ans += 1

    while True:
        pop_num = base.pop()
        for i in parent[pop_num]:
            parent[i].remove(pop_num)
            base.append(i)
        parent[pop_num] = []
        if len(base) == 0:
            ans += 1
            while len(parent[na_num]) == 0:
                na_num += 1
                if na_num == n+1:
                    print(ans)
                    exit()
            base.append(na_num)


Measured memory_bytes: 30768
#include<stdio.h>
int main(void)
{
	int n,m,k,x,y;
	scanf("%d",&n);
	x=0;
	y=0;
	k=0;
	m=0;
	while(1){
		if(n==0){
			printf("%d\n",x);
			break;
		}
		m=n;
		while(1){
			if(m%2!=0) break;
			m=m/2;
			k++;
		}
		if(k>=y){
			x=n;
			y=k;
		}
		k=0;
		n--;
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
#define MOD 1000000007ll

using namespace std;
int n;

bool is_ok(vector<ll> &a,map<ll,int> mp){


	vector<ll> v;
	
	v.push_back(a[0]);
	mp[a[0]]--;
	int start=-1;
	rep(i,1,n){
		mp[a[i]]--;
		if (mp[a[i]^a[0]]>0){
		v.push_back(a[i]);
			start=i;
			break;
		}
		mp[a[i]]++;
	}
	if (start==-1){
		return false;
	}
	n-=2;
	while (n){
		int x=v[v.size()-1],y=v[v.size()-2];
		if (mp[x^y]<=0){
			return false;
		}
		v.push_back(x^y);
		mp[x^y]--;
		n--;
	}
	return (v[0]==(v[1]^v[v.size()-1]) && (v[v.size()-1]==(v[v.size()-2]^v[0]) ));
}

int main(int argc, char const *argv[])
{
	cin>>n;
	vector<ll> a(n,0);
	map<ll,int> mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	if (is_ok(a,mp)){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    long Mod = 1000000007;
    long a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    long sum1=0;
    long sum2=0;
    for (int i = 0; i < n; i++)
    {
        sum1 = (sum1 + a[i]) % Mod;
        sum2 = (sum2 + (a[i] * a[i]) % Mod ) % Mod;
    }
    cout << ( ( (sum1 * sum1) % Mod + Mod - sum2) % Mod * 500000004) % Mod << endl;
    
}

Measured memory_bytes: 5104
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
  return *(int*)b -*(int*)a;
}
int maxi(int a,int b){
  if(a>b) return a;
  return b;
}
  
int main(void){
  int n,max=0,i,j;
  scanf("%d",&n);
  int a[n],tmp[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    tmp[i] = a[i];
  }
  qsort(tmp,n,sizeof(int),cmp);
  for(i=0;i<n;i++) max = maxi(max,a[i]);
  for(i=0;i<n;i++){
    if(a[i]==max) printf("%d\n",tmp[1]);
    else printf("%d\n",max);
  }
  return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>
int main(){
	int n,k,i,height,m=0;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++){
		scanf("%d",&height);
		if(height>=k)
			m++;
	} 
	printf("%d",m); 
	return 0;
} 

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>

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

	std::vector<int> a(n);
	for(int i=0; i<n; i++){
		std::cin >> a[i];
	}
	
	std::vector<std::vector<long long>> dp(n+1, std::vector<long long>(n+1));
	// d[i][j]: a[i, j)の区間で双方が最善を尽くした x-y
	for(int len=1; len<=n; len++){
		for(int i=0; i+len<=n; i++){
			int j = i+len;
			// 先手
			if((n-len)%2 == 0){
				dp[i][j] = std::max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
			}
			// 後手
			else{
				dp[i][j] = std::min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
			}
		}
	}

	std::cout << dp[0][n] << std::endl;
	return 0;

}

Measured memory_bytes: 70784
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 100002
using namespace std;
char s[N],t[N];
int q,i,ls,lt,a[N],b[N];
int main()
{
	scanf("%s%s%d",s+1,t+1,&q);
	ls=strlen(s+1);
	lt=strlen(t+1);
	for(i=1;i<=ls;i++) a[i]=(int)(s[i]-'A'+1);
	for(i=1;i<=lt;i++) b[i]=(int)(t[i]-'A'+1);
	for(i=1;i<=ls;i++) a[i]+=a[i-1];
	for(i=1;i<=lt;i++) b[i]+=b[i-1];
	for(i=1;i<=q;i++){
		int l1,r1,l2,r2;
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
		if((a[r1]-a[l1-1])%3==(b[r2]-b[l2-1])%3) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 4136
from collections import defaultdict

n, m = list(map(int, input().split()))
loved_food_list = [list(map(int, input().split())) for _ in range(n)]

food_dict = defaultdict(int)

for loved_foods in loved_food_list:
    for food in loved_foods[1:]:
        food_dict[food] += 1

ans = 0
for food, num in food_dict.items():
    if num == n:
        ans += 1

print(ans)


Measured memory_bytes: 3316