akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lli unsigned long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

void solve(){
    int n; cin>>n;
    cout<< int(n/2) + n%2;
    return;
}
void solve1(){
    int n; cin>>n;
    vector<int> a(n),b(n+1,0);
    NA(i,0,n) cin>>a[i];
    NA(i,0,n){
        ++b[a[i]];
        if(b[a[i]]==2) {cout<<a[i]; return;}
    }
    cout<<'_';
    return;
}
vector<int> mergeSorted(vector<int>& a, vector<int>& b){
    vector<int> res;
    int i=0, j=0;
    while(i<a.size() || j<b.size()){
        if(i<a.size() && j<b.size()) {
            if(a[i]<b[j]) res.pb(a[i]), ++i;
            else res.pb(b[j]), ++j;
        } else if(i<a.size()){
            res.pb(a[i]), ++i;
        } else {
            res.pb(b[j]), ++j;
        }
    }
    return res;
}
void solve2(){
    int n,tp; cin>>n;
    vector<int> a,b;
    NA(i,0,n) cin>>tp, (tp<0) ? b.pb(tp) : a.pb(tp); 
    NA(i,0,a.size()) a[i] *= a[i];
    NA(i,0,b.size()) b[i] *= b[i];
    reverse(b.begin(), b.end());
    vector<int> res = mergeSorted(a,b);
    NA(i,0,res.size()) cout<<res[i]<<' ';
    return;
}
void solve3(){
    int n,m,sum; cin>>n>>m>>sum;
    vector<int> a(n), b(m);
    unordered_set<int> st;
    NA(i,0,n) cin>>a[i], st.insert(a[i]);
    NA(i,0,m) {
        cin>>b[i];
        if(st.find(sum-b[i])!=st.end()) {cout<<1; return;}
    }
    cout<<0;
    return;
}
int main(){
    fastIO;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <ctime>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 1LL << 62
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

const int MAX_M = 100001;

ll f[MAX_M];

void calc() {
    f[0] = 1;
    rep(i, 1, MAX_M) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    calc();
    int N;
    ll X;
    cin >> N >> X;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    reverse(all(A));
    
    vector<ll> dp(MAX_M);
    vector<ll> tmp(MAX_M);
    dp[X] = 1;
    rep(i, N) {
        tmp.assign(MAX_M, 0);
        ll inv = inv_mod(N - i, mod);
        rep(j, MAX_M) {
            tmp[j % A[i]] += dp[j] * inv % mod;
            tmp[j % A[i]] %= mod;
            tmp[j] += (dp[j] * inv % mod) * (N - i - 1) % mod;
            tmp[j] %= mod;
        }
        dp = tmp;
    }
    
    ll ans = 0;
    rep(i, MAX_M) {
        ans += dp[i] * i;
        ans %= mod;
    }
    ans *= f[N];
    ans %= mod;
    output(ans);
    
    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <stdio.h>

#define MAXN 100000
typedef long long ll;

using namespace std;

int maxa;
int B[MAXN];

int main()
{
  int N;
  ll H;
  int maxa = 0;
  ll cnt = 0;
  int bpos = 0;

  cin >> N;
  scanf("%lld", &H);

  for ( int i = 0; i < N; ++i ) {
    int tmpa;
    scanf("%d", &tmpa);
    scanf("%d", &B[i]);
    if ( maxa < tmpa) maxa = tmpa;
  }

  sort(B,B+N, greater<int>());

  while ( bpos < N && maxa < B[bpos] && H > 0) {
    H -= B[bpos];
    ++cnt;
    ++bpos;
  }

  if ( H > 0 ) {
  cnt += (H/maxa);
  if ( H%maxa != 0 ) ++cnt;
}

  cout << cnt << "\n";

  /*
  for ( int i = 0; i < N; ++i ) cout << B[i] << " "; cout << "\n";
  cout << maxa << "\n";
  cout << H << "\n";
  */
}


Measured memory_bytes: 888
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
void ng() {
    output("UNRESTORABLE");
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s, t;
    cin >> s >> t;
    if(t.size() > s.size()) ng();
    
    for(int i = (int)(s.size() - t.size()); i >= 0; i--){
        string u = s.substr(i, t.size());
//        cout << i << ":" << u << endl;
        bool ok = true;
        rep(j, u.size()){
            if(u[j] != '?' && t[j] != u[j]) ok = false;
        }
        if(ok){
            rep(j, u.size()){
                s[j + i] = t[j];
            }
            rep(j, s.size()){
                if(s[j] == '?') s[j] = 'a';
            }
            output(s);
            return 0;
        }
        
    }
    ng();
    
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-5 0583: Common Divisors
// 2017.8.30 bal4u@uu

#include <stdio.h>

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

int main()
{
	int n, a, b, g;

	scanf("%d", &n);
	scanf("%d%d", &a, &b); g = gcd(a, b);
	n -= 2;
	while (n-- > 0) scanf("%d", &a), g = gcd(g, a);
	b = 1 + (g & 1);
	for (a = 1; a <= g; a += b) {
		if (g % a == 0) printf("%d\n", a);
	}
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
using namespace std;

struct block {
    int w, s, v;
};
// 比較関数
bool comp(block a, block b) { return a.w + a.s < b.w + b.s; }

int N;
block B[1009];
long long dp[1009][20009];

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        int w, s, v;
        cin >> w >> s >> v;
        B[i] = block{w, s, v};
    }

    sort(B, B + N, comp);

    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= 20000; j++) {
            dp[i + 1][j] = dp[i][j];
            if(j >= 1) dp[i + 1][j] = max(dp[i + 1][j], dp[i + 1][j - 1]);
            if(j >= B[i].w && j - B[i].w <= B[i].s)
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - B[i].w] + B[i].v);
        }
    }

    cout << dp[N][20000] << endl;

    return 0;
}

Measured memory_bytes: 157824
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  string S;
  cin>>S;
  
  string K=S.substr(N),T;
  REP(i,N) T+=K.at(N-1-i);
  S.erase(N);
  
  map<pair<string,string>,ll> M;
  for(ll bit=0; bit<(1<<N); ++bit){
    string L,P;
    for(ll i=0; i<N; ++i){
      if(bit&(1<<i)) L+=S.at(i);
      else P+=S.at(i);
    }
    M[make_pair(L,P)]++;
  }
  
  for(ll bit=0; bit<(1<<N); ++bit){
    string L,P;
    for(ll i=0; i<N; ++i){
      if(bit&(1<<i)) L+=T.at(i);
      else P+=T.at(i);
    }
    ans+=M[make_pair(L,P)];
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 49408
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		char[] N = sc.next().toCharArray();
		int ans = 0;
		int acum = 0;
		for (int i = 0; i < N.length; i++) {
			acum += N[i] -'0';
			ans = Math.max(ans, acum);
			ans = Math.max(ans, acum - 1 + (N.length - i - 1) * 9);
		}
		System.out.println(ans);
	}
}


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

int main() {
	
	int n, count;
	cin >>n;
	
	count =0;
	
	vector<int> vec(n);
	
	for(int i=0; i<n; i++){
		
		cin >>vec.at(i);
		
	}
	
	for(int i=1; i<n-1; i++){
		
		if(min(vec.at(i),min(vec.at(i-1),vec.at(i+1)))!=vec.at(i)&&max(vec.at(i),max(vec.at(i-1),vec.at(i+1)))!=vec.at(i)){
			
			count++;
			
		}
		
	}
	
	cout <<count <<endl;

}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    ll n = S.size();
    vector<ll> countW(n, 0);
    countW[0] = S[0] == 'W' ? 1 : 0;
    REP(i, n - 1)
    {
        countW[i + 1] = countW[i];
        if (S[i + 1] == 'W')
        {
            countW[i + 1]++;
        }
    }
    ll ans = 0;
    REP(i, n)
    {
        if (S[i] == 'B')
        {
            ans += countW[n - 1] - countW[i];
        }
    }

    cout << ans << endl;
}


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

#define PB push_back
#define MP make_pair
#define fi first
#define se second

typedef long long LL;

const double EPS=1e-9;
const double PI=acos(-1.0);
const int MAXN=100005;
const LL MOD=1000000007;
const int dx[8]={-1, 0, 1, -1, 1, -1, 0, 1}, dy[8]={-1, -1, -1, 0, 0, 1, 1, 1};

void base(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

bool stat[100001];

int main(){
	base();
	int n, l, r, ans=0;
	cin>>n;

	while(n--){
		cin>>l>>r;
		for(int i=l; i<=r; i++){
			if(!stat[i]){
				stat[i]=1;
				ans++;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
bool PRIME(ll&x){
  for(ll i=2;i*i<=x;i++)if(x%i==0)return 0;
  return 1;
}
signed main(){
  ll N,i,ans=1,mod=1000000007;cin>>N;
  FOR(i,2,N+1)if(PRIME(i)){
    ll R=i,COUNT=0;
    while(R<=N){
      COUNT+=N/R;
      R*=i;
    }
    ans*=COUNT+1;ans%=mod;
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
	string s, t; cin >> s >> t;
	int ans = 0;
	rep(i, 3) {
		ans += (s[i] == t[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]
d = {}
for x in a:
	d[x] = d.get(x, 0) + 1
ok = True
for i in range(1 + n % 2, n, 2):
	if i not in d or d[i] != 2:
		ok = False
		break
if ok: print(pow(2, n//2, 10**9+7))
else: print(0)


Measured memory_bytes: 14436
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int a, b, c; cin >> a >> b >> c;
    int ans = 0;
    rep(i,100) {
        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
            break;
        }
        else {
            ++ans;
            int a_tmp = a; int b_tmp = b; int c_tmp = c;
            a = (b_tmp + c_tmp) / 2;
            b = (a_tmp + c_tmp) / 2;
            c = (a_tmp + b_tmp) / 2;
        }
    }
    if (ans < 100) {
        out(ans);
    }
    else {
        out(-1);
    }
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    vector<int> a(n, 0), b(n, 0);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];

    int c = 0, flag = 0;

    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[i]) c++;
        else c = 0;

        if (c == 3)
        {
            flag = 1;
            break;
        }
    }

    if (flag == 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
  int n, c = 0;
  cin >> n;
  int p[n];
  for (int k = 0; k < n; k++)
    cin >> p[k];
  
  for (int i = 2; i < n; i++) {
    if (p[i - 2] < p[i - 1] && p[i - 1] <= p[i]
        || p[i] < p[i - 1] && p[i - 1] <= p[i - 2])
      c++;
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read()
{
    int x=0;bool f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return f?x:-x;
}
int h,w,n,m;
int main()
{
    h=read(),w=read(),n=read();
    m=max(h,w);
    printf("%d\n",(n+m-1)/m);
    return 0;
}


Measured memory_bytes: 128
from sys import stdin

X = [ 0 for i in range(100) ]
d = [ 0 for i in range(100) ]
f = [ 0 for i in range(100) ]
G = [[ 0 for i in range(100) ] for i in range(100)]

t = 0

def DFS(i) :
	global t
	t += 1
	d[i] = t
	for j in range(n) :
		if G[i][j] != 0 and d[j] == 0 : DFS(j)
	t += 1
	f[i] = t


n = int(input())
for i in range(n) :
	X[i] = stdin.readline().strip().split()


for i in range(n) :
	for j in range(int(X[i][1])) :
		G[int(X[i][0])-1][int(X[i][j+2])-1] = 1

for i in range(n) :
	if d[i] == 0 : DFS(i)

for i in range(n) : print(i+1,d[i],f[i])

Measured memory_bytes: 6808
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M, X, A[111];
    scanf("%d%d%d", &N, &M, &X);
    int v1=0,v2=0;
    for(int i=0; i<M; ++i)
    {
        int t; cin >> t;
        if(t<X) ++v1;
        else ++v2;
    }
    cout << min(v1,v2) <<endl;
    
}

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

import sys
from operator import itemgetter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = MAP()
edges = []
for i in range(M):
    a, b = MAP()
    edges.append((a, b))
# 右端でソート
edges.sort(key=itemgetter(1))

nxt = cnt = 0
for a, b in edges:
    # 左端が切る位置より先にあったらもう1回切る
    if a > nxt:
        # 次に切る位置
        nxt = b - 0.5
        cnt += 1
print(cnt)


Measured memory_bytes: 18264
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
    int n;
    cin>>n;
    bool ok=true;
    vector<string> v(n);
    set<string> s;
    for(auto &it:v){
		cin>>it;
		s.insert(it);
	}
	if((int)s.size()!=n)cout<<"No"<<endl;
	else{
	  for(int i=0;i+1<n;i++){
		   if(v[i][(int)v[i].size()-1]!=v[i+1][0]){
			     ok=false;
			     break;
			  } 
		 }
	cout<<(ok?"Yes":"No")<<endl;	
	}
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    set<int> tim;
    map<int,set<int>> ins;
    map<int,set<int>> del;
    REP(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        tim.insert(a-c);
        tim.insert(b-c);
        ins[a-c].insert(c);
        del[b-c].insert(c);
    }
    set<int> lis;
    vi vec(m);
    cin>>vec;
    auto itr=tim.begin();
    REP(i,m){
        while(itr!=tim.end()&&*itr<=vec[i]){
            if(del.count(*itr)){
                for(auto itr2:del[*itr]){
                    lis.erase(itr2);
                }
            }
            if(ins.count(*itr)){
                for(auto itr2:ins[*itr]){
                    lis.insert(itr2);
                }
            }
            itr++;
        }
        if(!lis.size()){
            cout<<-1<<endl;
        }else{
            cout<<*lis.begin()<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 86400
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
 int N;
 cin >> N;
 
 int cnt = 0;
 int P[N];
 for(int i=0; i<N; i++){
  int p[3];
  cin >> p[0] >> p[1] >> p[2];

  sort(p, p+3);

  P[i] = ((p[0]-1)*1000+(p[1]-1))*1000+(p[2]-1);
 }

 int d = 0;
 for(int I=0; I<N; I++){
  for(int i=I+1; i<N; i++){
   if(P[i]==P[I]){
    cnt++;
    P[i] = d++;
   }
  }
 }

 cout << cnt << endl;

 return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;


int main() {
	//22日目 
	ll n = 0, F = 0;
	vector<ll> a;
	ll sum = 0;
	cin >> n;
	rep(i, n) {
		cin >> F;
		a.push_back(F);
		sum += F;
	}

	ll umaru = 0, d = 0;
	d = 9223372036854775807;
	rep(i, n) {
		umaru += a[i];
		if(i+1<n)
		d = min(d,abs(sum-2*umaru));
	}
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 2420
# coding: utf-8
s1 = gets.chomp#探したい文字列
n = gets.chomp.to_i#指輪の個数
c = 0#何個探したい文字列があるか数える変数
for i in 0..n-1
  s2 = gets.chomp#指輪に書かれている１０文字の文字列
  if (s2*2).index(s1)
    c += 1;
  end
end

puts c



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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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 ll MRINF = 5000000000000000;

int main() {

  ll N, M, K; cin >> N >> M >> K;
  vector<ll> A(N), B(M), sumA(N), sumB(M);
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i];
    int ans = 0;
    ll c[M + 1]{};
    for (int i = 0; i < M; i++) {
        c[i + 1] = c[i] + B[i];
    }
    ll t = 0;
    for (int i = 0; i <= N; i++) {
        if (i != 0) {
            t += A[i - 1];
        }
        if (t > K) break;
        int l = -1;
        int r = M + 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (t + c[m] <= K) {
                l = m;
            } else {
                r = m;
            }
        }
        ans = max(ans, i + l);
    }
    cout << ans << "\n";
    return 0;
  


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 11104
import sys
input = sys.stdin.buffer.readline

from collections import defaultdict
dd = defaultdict(lambda:0)

n, x, y = map(int, input().split())
len_ = [[-1]*(n+1) for _ in range(n+1)]
k = 0
for i in range(1,n+1):
    for j in range(1, n+1):
        if i < j:
            len_[i][j] = min(min(j-i, abs(j-x)+abs(i-y)+1), min(j-i, abs(j-y)+abs(i-x)+1))
            dd[len_[i][j]] += 1

for i in range(1, n):
    print(dd[i])

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

void
solver(long long n, long long a, long long b)
{
    long long d = b-a;
    long long r;

    if (d%2==0) {
        printf("%lld\n", d/2);
    }
    else {
        if (n-b>a-1) {
            d = a-1;
        }
        else {
            d = n-b;
        }
        d += (b-a+1)/2;
        printf("%lld\n", d);
    }
    return;
}

int
main(int argc, char *argv[])
{
    long long N, A,  B;

    scanf("%lld %lld %lld", &N, &A, &B);
    solver(N, A, B);
    return 0;
}

Measured memory_bytes: 128
use std::io;

fn main() {
    loop {
        let mut buf = String::new();
        let n = io::stdin().read_line(&mut buf)
            .expect("failed read line");
        if n == 0 { break }
        let mut iter = buf.trim().split(" ");
        let a: u32 = iter.next()
            .expect("need at least 1 number")
            .parse().expect("type a number");
        let b: u32 = iter.next()
            .expect("need at least 2 number")
            .parse().expect("type a number");
        println!("{} {}", gcd(a, b), lcm(a, b));
    }
}

fn gcd(n: u32, m: u32) -> u32 {
    if n > m { return gcd(m, n) }
    if n == 0 { return m }
    return gcd(m % n, n);
}

fn lcm(n: u32, m: u32) -> u32 {
    return n / gcd(n, m) * m;
}



Measured memory_bytes: 5028
S = input()
T = input()

naga = len(S)
count = 0
for i in range(naga):
    ss = S[i]
    tt = T[i]
    if S.find(ss) != -1 :
        count = count + 1
    S = S.replace(ss,"!")
    S = S.replace(tt,ss)
    S = S.replace("!",tt)

    if count > 28:
        break


if S == T:
    print("Yes")
else:
    print("No")


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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int K = sc.nextInt();

		int ans = 0;

		if(K%2==0) {

			ans = (K/2)*(K/2);

		}else {

			ans = (K/2)*((K/2)+1);

		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 23124
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
const lld MAX=1020;
const lld MOD=1000000007;
vector<lld> req;
lld n,a[MAX],chk[MAX],k1,k2,max_a1=-MOD,max_a2=-MOD,max_a,idx_a1=-1,idx_a2=-1,idx,cnt;
int main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i+=2) {
        max_a1=max(max_a1,a[i]);
        if(max_a1==a[i]) idx_a1=i;
        k1+=max(a[i],0ll);
    }
    for(int i=2;i<=n;i+=2) {
        max_a2=max(max_a2,a[i]);
        if(max_a2==a[i]) idx_a2=i;
        k2+=max(a[i],0ll);
    }
    if(max_a1<0&&max_a2<0){
        max_a=max(max_a1,max_a2);
        if(max_a1<max_a2) idx=idx_a2;
        else idx=idx_a1;
        printf("%lld\n%lld\n",max_a,n-1);
        for(int i=0;i<idx-1;i++) printf("1\n");
        for(int i=0;i<n-idx;i++) printf("%d\n",n-idx-i+1);
    }
    else{
        if(max_a1<0) max_a=k2,idx=2;
        else if(max_a2<0) max_a=k1,idx=1;
        else max_a=max(k1,k2),idx=(max_a==k2)+1;
        printf("%lld\n",max_a);
        for(int i=idx;i<=n;i+=2) chk[i]=(a[i]>=0);
        for(int i=n;i>=1;i--){
            int j=i;
            for(;chk[j]==0&&j>=1;j--);
            if(i-j==0) continue;
            else if(j==0){
                for(int k=0;k<i-j;k++) req.push_back(1);
            }
            else{
                for(int k=1;k<i-j;k+=2){
                    req.push_back(j+2);
                }
                req.push_back(j+1);
            }
            i=j;
        }
        printf("%lld\n",req.size());
        for(int i=0;i<req.size();i++) printf("%lld\n",req[i]);
    }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/function.hpp>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sort_all(T v) { return std::sort(v.begin(),v.end()); }
template<typename T>
auto sum_all(T v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

typedef llint dtype;

int main(void)
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A*N,B) << endl;

    return 0;
}

Measured memory_bytes: 256
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()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

const mod = 1000000007

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

	N := getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	n := make(map[int]int)
	n[-1] = 3
	ans := 1
	for i := 0; i < N; i++ {
		x := a[i]
		// out(n[x-1] - n[x])
		ans *= n[x-1] - n[x]
		ans %= mod
		n[x]++
	}
	out(ans)

}


Measured memory_bytes: 7168
n=int(input())
a=list(map(int, input().split()))

s=1
if 0 in a:
    print(0)
    exit()
else:
    for i in range(n):
        s=s*a[i]
        if s>10**18:
            print(-1)
            exit()
        else:
            continue

print(s)


Measured memory_bytes: 21608
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<int> A(N);

    int pre = -1, cons = 0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    A.push_back(INF);

    int ans = 0;
    for(int i=0; i<=N; i++) {
        if(pre < 0) {
            cons++;
        }
        else if(pre == A[i]) cons++;
        else {
            ans += cons / 2;
            cons = 1;
        }
        pre = A[i];
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    char X;
    cin >> X;
    cout << (char) (X + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			int num = scan.nextInt();
			
			int[] primeList = new int[num+1];
			int cnt = 0;
			
			// 2以上の自然数をすべて1（素数）にする
			for(int i = 2; i <= num; i++) {
				primeList[i] = 1;
			}
			
			for(int i = 2; i <= num; i++) {
				if(primeList[i] == 0);
				else {
					cnt++;
					for(int j = i + i; j <= num; j += i) {
						primeList[j] = 0;
					}
				}
			}
			
			System.out.println(cnt);
			
		}
	}
}

Measured memory_bytes: 54336
#include <bits/stdc++.h>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll> > matrix;
// const ll S = 3e5 + 20;
// const ll N = 1e6 + 1;
// const ll PRIME = 1e9 + 7;
// const ll MAX = 1e6;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    int x = 0;
    fr(i, n)
    {
        cin >> a[i];
        x ^= a[i];
    }
    int ans[n];
    fr(i, n)
    {
        ans[i] = x ^ a[i];
    }
    fr(i, n)
    {
        cout << ans[i]<<" ";
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  if(n&1)cout<<0<<endl;
  else{
    res+=n/10;
    n/=10;
    while(n){
      res+=n/5;
      n/=5;
    }
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n,k;
cin >> n >> k;
vi p(n);
rep(i,n) cin >> p[i];
sort(all(p));
int sum = 0;
rep(i,k) {
    sum += p[i];
}
cout << sum << endl;
return 0;
}

Measured memory_bytes: 3644
N=int(input())
A=list(map(int,input().split()))

T={}
for a in A:
    if a in T:
        T[a]+=1
    else:
        T[a]=1

K=0
for b in T:
    if T[b]<b:
        K+=T[b]
    elif b<T[b]:
        K+=T[b]-b
print(K)


Measured memory_bytes: 98752
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
vector<int> col;
int n;
char G[205][205];
bool dfs(int x, int p) {
	if (col[x] != -1) {
		if (col[x] != p) return true;
		return false;
	}
	col[x] = p;
	for (int y = 0; y < n; ++y) {
		if (G[x][y] == '1') {
			if (dfs(y, 1 - p)) return true;
		}
	}
	return false;
}
int main() {
	scanf("%d", &n);
	col = vector<int>(n, -1);
	for (int i = 0; i < n; ++i) scanf("%s", G[i]);
	if (dfs(0, 0)) printf("-1\n");
	else {
		vector<vector<int>> D(n, vector<int>(n, 1e9));
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				if (G[i][j] == '1') D[i][j] = 1;
				else if (i == j) D[i][j] = 0;
		for (int k = 0; k < n; ++k)
			for (int i = 0; i < n; ++i)
				for (int j = 0; j < n; ++j)
					D[i][j] = min(D[i][k] + D[k][j], D[i][j]);
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			ans = max(ans, *max_element(D[i].begin(), D[i].end()));
		}
		printf("%d\n", ans + 1);
	}
}


Measured memory_bytes: 3968
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int com(const void *a, const void *b){
	return *(int *)a-*(int *)b;
}

int main()
{
	int n, k=0, l=0, i, j, d[100000];
	
	scanf("%d", &n);
	
	lop(i, n){ scanf("%d", &d[i]); }
	
	qsort(d, n, sizeof(int), com);
	
	int m=n/2;
	
	printf("%d", d[m]-d[m-1]);
	
return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
char x[10001];
bool op=0;
int main(){
	cin>>x;
	int lena=strlen(x);
	for(int i=0;i<lena;i++){
		if(x[i]=='C')op=1;
		if(op==1&&x[i]=='F'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	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 N;
	string S;
	cin >> N >> S;
	int Xa = 0;
	int MaxX = Xa;
	rep(i, N){
		if(S.at(i) == 'I'){
			Xa++;
			MaxX = max(MaxX, Xa);
		} else {
			Xa--;
		}
	}
	cout << MaxX << endl;
}

Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <stack>
    #include <string>
    #include <cstring>
    #include <cmath>
    #include <vector>
    #include <set>
    #define maxn 1000605
    typedef long long LL;
    using namespace std;
    int num[55];
    int left[55];
    int right[55];
    vector<int>temp;
    int main(){
        int n,k,ans,lnum,rnum,maxans;
        while(cin>>n>>k){
            for(int i=1;i<=n;i++)
                cin>>num[i];
       /*     left[1]=num[1];
            for(int i=2;i<=n;i++)
                left[i]=left[i-1]+num[i];
            right[n]=num[n];
            for(int i=n-1;i>=1;i--)
                right[i]=right[i+1]+num[i];*/
            maxans=-1;
            for(int i=1;i<=k&&i<=n;i++){
                for(int j=0;j<=i;j++){ //=
                    temp.clear();
                    ans=0;
                    lnum=j;
                    rnum=i-j;
                    for(int l=1;l<=lnum;l++){
                        if(num[l]<0)
                            temp.push_back(num[l]);
                        ans+=num[l];
                    }
                    for(int r=1;r<=rnum;r++){
                        if(num[n-r+1]<0)
                            temp.push_back(num[n-r+1]);
                        ans+=num[n-r+1];
                    }
                    /*for(int q=0;q<k-i&&q<temp.size();q++){
                        cout<<temp[q]<<"***";
                    }
                    cout<<endl;*/
                    sort(temp.begin(),temp.end());
                    /*for(int q=0;q<k-i&&q<temp.size();q++){
                        cout<<temp[q]<<"***";
                    }
                    cout<<endl;*/
                    //cout<<lnum<<"---"<<rnum<<"----";
                    for(int q=0;q<k-i&&q<temp.size();q++){
                            ans-=temp[q];
                            //cout<<temp[q]<<" ";
                    }
                    //cout<<"--ans:"<<ans<<endl;
                    if(ans>maxans) //=
                        maxans=ans;
                }

            }
            cout<<maxans<<endl;
        }
        return 0;
    }


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

int main() {

  while( true ) {

    long long int n, w;
    cin >> n >> w;
    if ( n == 0 ) break;

    long long int v[11] = {};
    long long int w_max = 0;
    long long int h_max = 0;

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

      long long int in;
      cin >> in;

      long long int k = 0;
      while( in >= w ) {
	in -= w;
	k++;
      }
      v[k]++;
      w_max = max( w_max, k );
      h_max = max( h_max, v[k] );

    }

    double ans = 0.01;

    if ( w_max == 0 ) {

      ans += 1.00;

    }else {

      for ( long long int i = 0; i <= w_max; i++ ) {
	ans += 1.00 * ( w_max - i ) / w_max * v[i] / h_max;
      }

    }

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

  }

  return 0;

}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

string S;

signed main()
{
    ll cand1 = 0, cand2 = 0;
    cin >> S;
    REP(i, S.length()) {
        if(i % 2 == 0) {
            if(S[i] == '0') { cand1++; }
            if(S[i] == '1') { cand2++; }
        }
        else {
            if(S[i] == '1') { cand1++; }
            if(S[i] == '0') { cand2++; }
        }
    }
    printf("%lld\n", min(cand1, cand2));
    return 0;
}


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

int main(){
  int n,m;
  int a;
  cin>>n>>m;
  vector<int>k(n);
  vector<int>cnt(m,0);
  for(int i=0;i<n;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      cin>>a;
      a--;
      cnt[a]++;
    }
  }
  int ans=0;
  for(int i=0;i<m;i++){
    if(cnt[i]==n)
      ans++;
  }
  cout<<ans<<endl;
  

}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  int x = n;
  bool flag = (n%2 == 0);
  for (int i = 1; i <= m; ++i) {
    if (flag && x-i <= n/2) {
      --x;
      flag = false;
    }
    cout << i << " " << x-- << endl;
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld long double
typedef pair<ll,ll>pairs;
int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	ll t,n,i,j,k,l,c=0,f;
	cin>>n;
	i=1;
	vector<ll>a(n+1);//b(n+1),d(n+1);
	map<ll,ll>m;
	while(i<=n)
	{
	    cin>>a[i];
	    if(m.find(a[i]+i)==m.end())
	        m.insert({i+a[i],1});
	    else
	        m[i+a[i]]++;
	    i++;
	}
	for(i=1;i<=n;i++)
	{
	    k=i-a[i];
	    if(m.find(k)!=m.end())
	        c+=m[k];
	}
	cout<<c<<"\n";
	return 0;
}


Measured memory_bytes: 17228
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String S = scan.next();

		Map<String, Integer> map = new HashMap<String, Integer>();

		for (int i = 0; i < 4; i++) {
			if (map.containsKey(String.valueOf(S.charAt(i)))) {
				int count = map.get(String.valueOf(S.charAt(i)));
				map.put(String.valueOf(S.charAt(i)), count + 1);

			} else {
				map.put(String.valueOf(S.charAt(i)), 1);
			}
		}

		int count = map.size();

		if (count != 2) {
			System.out.println("No");
			return;
		}

		for (String key : map.keySet()) {
			if (map.get(key) != 2) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
	}

	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 21588
N = int(input())
result = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(N):
    S = input()
    result[S] += 1
print('AC x ' + str(result['AC']))
print('WA x ' + str(result['WA']))
print('TLE x ' + str(result['TLE']))
print('RE x ' + str(result['RE']))

Measured memory_bytes: 74828