akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N; cin >> N;
ll cnt = 0;
REP(i, N){
  REP(j, N){
    REP(k, N){
      cnt++;
    }
  }
}
cout << cnt;
}

Measured memory_bytes: 3636
//Dubious Document 2

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s,t;cin>>s>>t;
    int c = -1;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<nnn;
        return 0;
    }
    rep(i,0,s.size()-t.size()+1){
        bool flag = true;
        rep(j,i,t.size()+i){
            if(s[j]=='?')continue;
            if(s[j]!=t[j-i]){
                flag=false;
            }
        }
        if(flag)c=i;
    }
    rep(i,0,s.size()){
        if(s[i]!='?')break;
        if(i==s.size()-1){
            rep(i,0,s.size()-t.size()){
                cout<<"a";
            }
            cout<<t<<nnn;
            return 0;
        }
    }
    if(c==-1){
        cout<<"UNRESTORABLE"<<nnn;
    }else{
        rep(i,c,t.size()+c){
            s[i]=t[i-c];
        }
        rep(i,0,s.size()){
            if(s[i]=='?'){
                s[i]='a';
            }
        }
        cout<<s<<nnn;
    }
    return 0;
}

Measured memory_bytes: 3620
# coding: utf-8

N = int(input())
A = [0]*N
xy = []
for i in range(N):
    A[i] = int(input())
    xy_i = []
    for j in range(A[i]):
        xy_i.append([int(k) for k in input().split()])
    xy.append(xy_i)

ans = 0
for i in range(1, 2**N):
    nisin = str(bin(i))[2:].zfill(N)
    flag = True
    for j in range(N):
        if nisin[j] == '1':
            for k in range(A[j]):
                if ((xy[j][k][1] == 1 and nisin[xy[j][k][0]-1] == '1') or (xy[j][k][1] == 0 and nisin[xy[j][k][0]-1] == '0')):
                    flag = True
                else:
                    flag = False
                    break
        
            if (not flag):
                break
    if (flag):
        ans = max(ans, nisin.count('1'))

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main()
{

    int a, b, ans, remainder;
    double real;
    scanf("%d %d", &a, &b);
    ans = a / b;
    remainder = a % b;
    real = (double)a/(double)b;
    printf("%d %d %lf",ans,remainder,real);
}


Measured memory_bytes: 2108
#include <stdio.h>

int adj[100][100];

int main(void) {
	int i, j;
	int n;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		int u, k;

		scanf("%d %d", &u, &k);
		u--;

		for (j = 0; j < k; j++) {
			int v;

			scanf("%d", &v);
			v--;

			adj[u][v] = 1;
		}
	}

	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			printf("%d%c", adj[i][j], " \n"[j == n - 1]);

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  while(true){
    if(n/100==n%10&&n/100==(n/10)%10){
        cout << n << endl;
        return 0;
    }
    n++;
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
  
static const double EPS = 1e-8;
 
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};
 
class Domino {
private:
  int _head;
  int _tail;
public:
  Domino(int head, int tail) {
    _head = head;
    _tail = tail;
  }
 
  int detect_connect_pattern(Domino d) {
    int res = 0;
    if(d.get_head() == _head){
      return (res | (1<<0));
    }
    if(d.get_head() == _tail){
      return (res | (1<<1));
    }
    if(d.get_tail() == _head){
      return (res | (1<<2));
    }
    if(d.get_tail() == _tail){
      return (res | (1<<3));
    }
    return res;
  }
 
  Domino connect(Domino d,int pattern){
    if(pattern == (1<<0)){
      return Domino(d.get_tail(),_tail);
    }
    if(pattern == (1<<1)){
      return Domino(d.get_tail(),_head);
    }
    if(pattern == (1<<2)){
      return Domino(d.get_head(),_tail);
    }
    if(pattern == (1<<3)){
      return Domino(d.get_head(),_head);
    }
    return *this;
  }
 
  int get_head() const{
    return _head;
  }
 
  int get_tail() const{
    return _tail;
  }
};
 
bool dp[1<<22];
 
bool dfs(Domino& current_state,int visited, const vector<Domino>& dominos){
  if(dp[visited]) return false;
  if(visited == (1<<dominos.size()) - 1){
    return true;
  }
 
  int res = false;
  for(int i = 0; i < dominos.size(); i++){
 
    if(visited & (1<<i)) continue;
    int pattern;
    if((pattern = current_state.detect_connect_pattern(dominos[i])) == 0) continue;
    Domino next = current_state.connect(dominos[i],pattern);
    res |= dfs(next,visited | (1<<i),dominos);
    dp[visited | (1<<i)] = true;
  }
  return res;
}
 
int main(){
  int n;
  while(~scanf("%d",&n)){
    vector<Domino> dominos;
    memset(dp,false,sizeof(dp));
 
    int same_head_tail = 0;
    for(int i = 0; i < n; i++){
      char domino[8];
      scanf("%s",domino);
      if(domino[0] - '0' == domino[1] - '0'){
        same_head_tail |= (1 << (domino[1] - '0'));
        continue;
      }
      dominos.push_back(Domino(domino[0] - '0',domino[1] - '0'));
    }
 
    bool same_check = true;
    for(int num = 0; num <= 6; num++){
      if(same_head_tail & (1 << num)){
        bool isok = false;
        for(int i = 0; i < dominos.size(); i++){
          if(dominos[i].get_tail() == num
             || dominos[i].get_head() == num){
            isok = true;
          }
        }
        if(!isok){
          same_check = false;
          break;
        }
      }
    }
 
    bool travel_check = false;
    travel_check = dfs(dominos[0],(1<<0),dominos);
    printf("%s\n",((same_check && travel_check) || (n == 1)) ? "Yes" : "No");
  }
}

Measured memory_bytes: 5272
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long n,d,x,y;
    int ans=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(d*d>=x*x+y*y){
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3632
S = input()

if int(S[0:2]) < 99 and 0 < int(S[2:4]) < 13:
    if int(S[2:4]) < 99 and 0 < int(S[0:2]) < 13:
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif int(S[2:4]) < 99 and 0 < int(S[0:2]) < 13:
    if int(S[0:2]) < 99 and 0 < int(S[2:4]) < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    char S[11];
    if (scanf("%s", S) < 1) return 0;

    S[3] = '8';

    printf("%s\n", S);
    return 0;
}

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

using namespace std;
typedef long long ll;

ll N,M;
vector<vector<ll>> G;
ll dp[100000];

void dfs(ll n){
    if(dp[n] != -1) return;
    ll d = 0;
    for(auto &e : G[n]){
        dfs(e);
        d = max(d, dp[e]+1);
    }
    dp[n] = d;
    return;
}

int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
    }
    for(int i=0;i<N;i++) dp[i] = -1;
    for(int i=0;i<N;i++) dfs(i);
    ll max_l = 0;
    for(int i=0;i<N;i++) max_l = max(max_l, dp[i]);
    cout << max_l << endl;
    return 0;
}

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

struct edge { int to, cost; };

//O(|E|log|V|)
struct dijkstra {
	int n;						//# of vertex
	vector<vector<edge>> g;		//info of edges
	vector<ll> d;				//output of dijkstra
	const ll INF = 1e18;		//enough large val
	typedef pair<int, int> P;	//{cost, vertex}

	dijkstra(int N, vector<vector<edge>> G = {}) :n(N), g(G) { g.resize(N); }

	//input should be 0-indexed
	void add_edge(int from, int to, int cost) {
		g[from].push_back({ to,cost });
	}

	void calc(int s = 0) {
		priority_queue<P, vector<P>, greater<P>> pq;
		d.clear();
		d.resize(n, INF);
		d[s] = 0;
		pq.push({ 0,s });
		while (!pq.empty()) {
			P p = pq.top();
			pq.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (edge e : g[v]) {
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					pq.push({ d[e.to],e.to });
				}
			}
		}
	}
};

int main() {
	ll n, m, r;
	cin >> n >> m >> r;
	dijkstra dij(n);
	vector<ll> v(r);
	for (ll i = 0; i < r; ++i) {
		cin >> v[i];
		--v[i];
	}
	for (ll i = 0; i < m; ++i) {
		ll a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		dij.add_edge(a, b, c);
		dij.add_edge(b, a, c);
	}
	vector<vector<ll>> d(r);
	for (ll i = 0; i < r; ++i) {
		dij.calc(v[i]);
		d[i] = dij.d;
	}
	ll ans = dij.INF;
	vector<ll> permutation(r);
	for (ll i = 0; i < r; ++i)permutation[i] = i;
	do {
		ll preans = 0;
		for (ll i = 1; i < r; ++i) {
			preans += d[permutation[i - 1]][v[permutation[i]]];
		}
		ans = min(ans, preans);
	} while (next_permutation(permutation.begin(), permutation.end()));
	cout << ans << endl;
}


Measured memory_bytes: 4056
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


S = read()[:-1]
T = read()[:-1]
ans = 0
for s, t in zip(S, T):
    ans += s != t

print(ans)


Measured memory_bytes: 69280
N = int(input())
a = list(map(int, input().split()))
A = [0]*9
for i in range(N):
    if a[i] < 400:
        A[0] = 1
    elif a[i] < 800:
        A[1] = 1
    elif a[i] < 1200:
        A[2] = 1
    elif a[i] < 1600:
        A[3] = 1
    elif a[i] < 2000:
        A[4] = 1
    elif a[i] < 2400:
        A[5] = 1
    elif a[i] < 2800:
        A[6] = 1
    elif a[i] < 3200:
        A[7] = 1
    else:
        A[8] += 1
print(max(1,sum(A[:8])),sum(A[:8])+A[8])

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int N;
int H[100001];

int main()
{
    // 整数の入力
    cin >> N;
    // スペース区切りの整数の入力
	for (int i=1; i<=N; i++) {
    	cin >> H[i];
	}

	int maxm=0;
	int mv;

	mv=0;
	for (int i=1; i<N; i++) {
		if (H[i] >= H[i+1] ) {
			mv++;
		} else {
			if (mv>maxm) maxm = mv;
			mv = 0;
		}
	}
	if (mv>maxm) maxm = mv;
    // 出力
    cout << maxm << endl;
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef float f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

char gra[205][205];
int par[205];
int n;
bool valid=1;
void dfs(int at, int pari) {
	par[at]=pari;
	fr(i,1,n) {
		if(gra[at][i]=='1') {
			if(par[i]==-1) {
				dfs(i,pari^1);
			} else if(par[i]!=(par[at]^1))
				valid=0;
		}
	}
}
int dist[205][205];
void solve() {
	memset(par,-1,sizeof(par));
	memset(dist,0x3f,sizeof(dist));
	cin>>n;
	fr(i,1,n)
		fr(j,1,n)
			cin>>gra[i][j];
	fr(i,1,n)
		dist[i][i]=0;
	dfs(1,0);
	if(valid==0) {
		cout<<-1<<endl;
		return;
	}
	fr(i,1,n)
		fr(j,1,n)
			if(gra[i][j]=='1')
				dist[i][j]=1;
	fr(l,1,4)
		fr(k,1,n) {
			fr(i,1,n)
				fr(j,1,n)
					dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
		}
	int ans=0;
	fr(i,1,n)
		fr(j,1,n)
			ans=max(ans,dist[i][j]);
	cout<<ans+1<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	fr(i,1,t) {
//		cout<<"Case "<<i<<": ";
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 640
#include<map>
#include<string>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<set>
#include<vector>
#include<cmath>
#include<queue>
using namespace std;


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	int a[4000];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	int k = 0;
	for (int i = 0; i < n; i++)
	{
		k += a[i] - 1;
	}
	printf("%d", k);


	
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int N, M, C;
    cin >> N >> M >> C;
    
    vector<int> B(M);
    for ( int i = 0; i < M; i++ ) cin >> B.at(i);
    
    vector<vector<int>> A(N, vector<int>(M));
    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < M; j++ ) {
            cin >> A.at(i).at(j);
        }
    }
    
    int correct_answer_num = 0;
    for ( int i = 0; i < N; i++ ) {
        int answer = 0;
        for ( int j = 0; j < M; j++ ) {
            answer += A.at(i).at(j) * B.at(j);
        }
        answer += C;
        if (answer > 0) {
            correct_answer_num++;
        }
    }
    
    cout << correct_answer_num << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define Starseven main
#define ll long long
namespace lyt {
	void read(int &x){
	char ch=getchar();int re=0,op=1;
	while(ch<'0'||ch>'9'){if(ch=='-') op=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){re=(re<<3)+(re<<1)+ch-'0';ch=getchar();}
	x = re * op;
	return ;
	}
	void read(long long &x){
	char ch=getchar();long long re=0,op=1;
	while(ch<'0'||ch>'9'){if(ch=='-') op=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){re=(re<<3ll)+(re<<1ll)+ch-'0';ch=getchar();}
	x = re * op;
	return ;
	}
	void write(int x){
		if(x<0){putchar('-');x=-x;}
		if(x>9) write(x/10);
		putchar(x%10+'0');
		return ;
	}//记得自己加空格和换行 
	void write(long long x){
		if(x<0){putchar('-');x=-x;}
		if(x>9) write(x/10);
		putchar(x%10+'0');
		return ;
	}//记得自己加空格和换行
	int max(int x,int y){return x<y?y:x;}
	int min(int x,int y){return x<y?x:y;}
	int abs(int x){return x<0?-x:x;}
	long long max(long long x,long long y){return x<y?y:x;}
	long long min(long long x,long long y){return x<y?x:y;}
	long long abs(long long x){return x<0?-x:x;}
	double abs(double x){return x<0?-x:x;}
	void swap(int &a,int &b) {a ^= b ^= a ^= b;}
	void swap(long long &a,long long &b) {a ^= b ^= a ^= b;}
	ll Power(ll a, ll b, ll p) {
		ll re = 1;
		while(b) {
			if(b & 1ll) re = (re * a) % p;
			b >>= 1ll;
			a = (a * a) % p; 
		}
	return re;
	}
}using namespace lyt;
const int N = 1e6;
const ll mod = 998244353;
ll tong[N + 20];
int prime[N], num, mu[N + 20];
bool vis[N + 20];
ll T[N + 20];

void Init() {
	mu[1] = 1;
	for (int i = 2; i <= N; i++) {
		if(!vis[i]) {
			prime[++num] = i;
			mu[i] = -1;
		}
		for (int j = 1; j <= num && prime[j] * i <= N; j++) {
			int x = prime[j] * i;
			vis[x] = true;
			if(i % prime[j] == 0) {
				mu[x] = 0;
				break;
			}
			mu[x] = -mu[i];
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = i; j <= N; j += i) {
			T[j] += 1ll * mu[i] * i;
			T[j] %= mod;
		}
	}
}

int Starseven(void) {
	int n, x;
	read(n);
	ll all = 0;
	for (int i = 1; i <= n; i++) {
		read(x);
		all += (ll)x;
		tong[x]++;
	}
	all %= mod;
	Init();	
	ll ans = 0;
	for (int l = 1; l <= N; l++) {
		ll vac = 0;
		for (int i = 1; i <= (N / l); i++)
			vac = (vac + 1ll * i * tong[i * l]) % mod;
		ans = (ans + l * vac % mod * vac % mod * T[l] % mod) % mod;
		ans = (ans + mod) % mod;	
	}
	ans = (ans - all) % mod;
	ans = (ans + mod) % mod;
	ll y = Power(2ll, mod - 2ll, mod);
	ans = (ans * y) % mod;
	write(ans);
	puts("");
	return 0;	
}

Measured memory_bytes: 22352
import java.io.*;
import java.util.*; 
import java.lang.*;

public class Main 
{   
    static long[] A;
    static long[][] dp;
    
    static long fn(int i, int j, int c) {
        if (i > j) { return 0; }
        if (dp[i][j] != -1) { return dp[i][j]; }
        if (c == 0) {
            dp[i][j] = Math.max(A[i] + fn(i+1, j, 1), A[j] + fn(i, j-1, 1));
        }
        else {
            dp[i][j] = Math.min(-A[i] + fn(i+1, j, 0), -A[j] + fn(i, j-1, 0));
        }
        return dp[i][j];
    }
    
    public static void main(String[] args) throws IOException 
    {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        A = new long[N];
        for (int n =0; n < N; n ++) {
            A[n] = scan.nextLong();
        }
        dp = new long[N][N];
        for (int i =0; i < N; i ++) {
            for (int j = 0; j < N; j ++) {
                dp[i][j] = -1;
            }
        }
        System.out.println(fn(0, N-1, 0));
    }
}    


Measured memory_bytes: 129780
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    long long a[N], b[N];

    for (int i = 0; i < N; i++)
    {
        cin >> a[i] >> b[i];
    }

    long long ans = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        if((a[i] + ans) % b[i] != 0 ) ans += b[i] - ((a[i] + ans) % b[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> L(N);
    REP(i,N) cin >> L[i];
    sort(L.begin(),L.end());
    ll ans = 0;
    int cnt = 0;
    REP(i,N) for(int j=i+1;j<N;j++){
        int cand = lower_bound(L.begin(),L.end(), L[i] + L[j]) - L.begin();
        cand -= (j + 1);
        if(cand > 0) ans+=cand;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

h, a = map(int, input().split())

ans = h // a
if h % a > 0:
    ans += 1
    
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll  n, i, j=0,  b=1;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    for(i=n-2; i>=0; i--){
        if(a[i]>=a[i+1]){
            b++;
        }
        else{
            j=max(j, b);
            b=1;
        }
    }
  j=max(j, b);
    cout<<j-1<<endl;
    return 0;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int N,S,sum=0,ans=1e9,k;
int a[100000];
int main(){
 
  scanf("%d %d",&N,&S);
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
    sum+=a[i];
    while(sum-a[k]>=S){
      sum-=a[k];
      k++;
    }
    if(sum>=S)ans=min(ans,i-k+1);
  }
  if(ans==1e9)ans=0;
  printf("%d\n",ans);
  return 0;
}

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

const int inf = 1001001001;

int main() {
  int w, h, n;
  cin >> w >> h >> n;

  vector<int> a(h + 2, 0);

  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;

    a[y] = max(a[y], x);
  }

  int ans = inf;
  for (int i = h; i >= 0; --i) {
    ans = min(ans, i + a[i + 1]);
    a[i] = max(a[i], a[i + 1]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
int n;

void solve() {
  int x,t;
  int ans;
  cin >> n >> x >> t;
  if (n%x == 0)
  ans = (n/x)*t;
  else ans = (n/x + 1)*t;
  cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int l = 1;
    //cin >> t;
    while(l--) {
      solve();
    }

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main()
{
  string S; cin >> S;
  int N = S.size();

  ll ans = 0;
  for (int i = 0; i < (1 << N - 1); ++i) {
    bitset<10> bit(i);

    ll sum = 0, now = S[0]-'0';
    for (int j = 1;  j < N; ++j) {
      if (1&(i>>j-1)) {
        sum += now;
        now = 0;
      }
      now *= 10;
      now += S[j] - '0';
    }
    ans += sum + now;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int a=in.nextInt(),b=in.nextInt();
		int n=in.nextInt();
		boolean jd=true;
		for(int i=0;i<n;i++){
			int s=in.nextInt(),f=in.nextInt();
			if((s<a && f<=a) || (s>=b && f>b))continue;
			else{
				jd=false;
				break;
			}
		}
		if(jd)System.out.println(0);
		else System.out.println(1);
	}

}



Measured memory_bytes: 26572
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FlippingSigns solver = new FlippingSigns();
        solver.solve(1, in, out);
        out.close();
    }

    static class FlippingSigns {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = new long[n];
            long count = 0;
            for (int i = 0; i < n; i++) {
                a[i] = in.nextLong();
                if (a[i] < 0) {
                    count++;
                    a[i] = -a[i];
                }
            }

            long result = 0;
            for (int i = 0; i < n; i++) {
                result += Math.abs(a[i]);
            }
            if (count % 2 == 0) {
                out.println(result);
                return;
            }
            Arrays.sort(a);
            out.println(result - a[0] * 2);

        }

    }
}



Measured memory_bytes: 61740
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(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 tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ll n;
    cin >> n;
    cout << (n-1)*n/2 << endl;
}


Measured memory_bytes: 256
from fractions import Fraction

N, K = map(int, input().split())

y = Fraction(1, N)


count = 0
for i in range(1, N + 1):
    kakuritu = 1
    while 1 <= i and i <= K - 1:
        i *= 2
        kakuritu /= 2
        if (i <= K):
            continue
        elif (i >= K):
            break
    count += kakuritu
print("{:.12f}".format(count * float(y)))


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
 int N;
 cin>>N;
 if(N>=1000){cout<<"ABD"<<endl;}
 else{cout<<"ABC"<<endl;}
return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#define N 1000

int main(void){
  int i,num,j,k;
  int n[N],m[N];
  int h[N];
  int c,ic;

  for(i=0;;i++){
    scanf("%d%d",&n[i],&m[i]);
    if(n[i]==0 && m[i]==0)
      break;
  }
  num=i;
  for(i=0;i<num;i++){
    for(j=0;j<n[i];j++){
      h[j]=1;
    }
    for(j=0,c=0;c<n[i]-1;c++){
      for(k=j,ic=0;ic<m[i];k++){
        k%=n[i];
        if(h[k]==1){
          ic++;
        }
        k%=n[i];
      }
      h[k-1]=0;
      j=k;
    }
    for(j=0;j<n[i];j++){
      if(h[j]==1){
        printf("%d\n",j+1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector <ll>
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ff(i,a,n) for(int i=a;i<n;i++)
#define vvi vector<vi > //v(r, vi (c,"#"))
// clock_t begin = clock(); f(n) ; clock_t end = clock(); cout<<(double)(end-begin)/ CLOCKS_PER_SEC;
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    int h[n], dp[n];
    for(int i=0; i<n; ++i) {
        cin >> h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2; i<n; ++i)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    cout << dp[n-1];
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, D;
  cin >> N >> D;
  D *= 2;
  D++;
  cout << (N + D - 1) / D << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1e9 + 7;
const int N = int(3e5) + 999;
#define int long long int
#define inf 1e18

int dp[405][405];
int ans = 0;
int arr[405];

int sum(int l, int r)
{
    int x = 0;
    l--, r--;
    while (l <= r)
    {
        x += arr[l];
        l++;
    }
    return x;
}

int32_t main()
{
    IOS;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i == j)
                dp[i][j] = 0;
            else
                dp[i][j] = inf;
        }
    }

    for (int len = 2; len <= n; len++)
    {
        for (int start = 1; start + len - 1 <= n; start++)
        {
            int end = start + len - 1;
            int s = sum(start, end);
            for (int i = start; i <= end - 1; i++)
            {
                dp[start][end] = min(dp[start][end], dp[start][i] + s + dp[i + 1][end]);
            }
        }
    }

    cout << dp[1][n];
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int yy(int x)
{
	int i=x;
	if(i%2==0) return 1+yy(i/2);
	else return 1;
}
int main()
{
	int n,ans=0;
	cin>>n;
	int a[n];
	for(int t=0;t<n;t++)
	{
		cin>>a[t];
		ans+=yy(a[t]);
		ans--;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

void Main() {
    string N;
    cin >> N;
    bool good = false;
    if ((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        good = true;
    }
    cout << (good ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

vector<int> ans[100100];

int main(){
	int n; cin >> n;
	int k=-1;
	if(n==1){
		cout << "Yes" << endl;
		cout << 2 << endl;
		cout << 1 << " " << 1 << endl;
		cout << 1 << " " << 1 << endl;
		return 0;
	}
	for(int i=1;i<n*2;i++){
		if(i*(i-1)==2*n)k=i;
	}
	if(k==-1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << k << endl;
	int now=1;
	for(int i=0;i<k-1;i++){
		cout << k-1 << " ";
		int pre=0;
		for(int j=i;j>0;j--){
			ans[i].push_back(ans[pre][i]);
			pre++;
		}
		while(ans[i].size()<k-1){
			ans[i].push_back(now);
			now++;
		}
		for(int j=0;j<k-1;j++){
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	cout << k-1 << " ";
	for(int i=0;i<k-1;i++){
		cout << ans[i][i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 4608
A,B=map(int,input().split())
Pa={1}
Pb={1}
a=2
while(a*a<=A):
    if A%a==0:
        A=A//a
        Pa.add(a)
    else:
        a+=1
if A>1:
    Pa.add(A)
b=2
while(b*b<=B):
    if B%b==0:
        B=B//b
        Pb.add(b)
    else:
        b+=1
if B>1:
    Pb.add(B)
print(len(Pa&Pb))


Measured memory_bytes: 3064
H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag = 0
for i in range(H):
    for j in range(W):
        if S[i+1][j+1]=='#':
            if S[i][j+1]=='.' and S[i+2][j+1]=='.' and S[i+1][j]=='.' and S[i+1][j+2]=='.':
                flag = 1
print('Yes' if flag == 0 else 'No')


Measured memory_bytes: 3316
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))

using namespace std;
//using namespace boost::multiprecision;

long long MOD = 1000000007;


long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

vector<int> domino;
char s[100];
char t[100];

int main(void){
    int N;
    cin >> N;
    cin >> s;
    cin >> t;

    int flag = 0;
    for (int i = 0; i < N; i++){
        if (flag){
            flag = 0;
            continue;
        }
        if (s[i] == t[i]){
            domino.push_back(0);
        }else{
            domino.push_back(1);
            flag = 1;
        }
    }
    long long ans;
    if (*domino.begin()){
        ans = 6;
    }else{
        ans = 3;
    }

    for (auto itr = domino.begin()+1; itr != domino.end(); itr++){
        if (*(itr - 1)){
            if (*itr){
                ans *= 3;
                ans %= MOD;
            }
        }else{
            if (*itr){
                ans *= 2;
                ans %= MOD;
            }else{
                ans *= 2;
                ans %= MOD;
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
/*****************
 *   I<3   C++   *
 *  IWANT ANYAC  *
 * ILOVEPROGRAM! *
 *IT'SINTERESTING*
 * ILOVEPROGRAM! *
 *  INCONTESTS   *
 *   GETSCORE    *
 *    ACCODE     *
 *     LETS      *
 *      GO       *
 *****************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n;
int a,b;
vector<INT> nei[100007];
int bss[2][100007];
set<int> lgl[2];

void bfs(int b,int c)
{
	queue<int> q,bs;
	q.push(b);
	bs.push(0);
	lgl[c].insert(b);
	bss[c][b]=0;
	while(!q.empty())
	{
		int qq=q.front(),bb=bs.front();
		q.pop();bs.pop();
		for(int i=0;i<SZ(nei[qq]);i++)
		{
			int ii=nei[qq][i];
			if(!lgl[c].count(ii))
			{
				lgl[c].insert(ii);
				q.push(ii);
				bs.push(bb+1);
				bss[c][ii]=bb+1;
			}
		}
	}
}

int cnt1=0,cnt2=0;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&a,&b);
		nei[a-1].push_back(b-1);
		nei[b-1].push_back(a-1);
	}
	bfs(0,0);
	bfs(n-1,1);
	for(int i=0;i<n;i++)
		if(bss[0][i]<=bss[1][i])cnt1++;
		else cnt2++;
	if(cnt1>cnt2)OVER("Fennec");
	else OVER("Snuke");
}

Measured memory_bytes: 16000
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    long long sum = 0, k; cin >> k;
    repeat(i, 1, k+1)
        repeat(j, 1, k+1)
            repeat(l, 1, k+1)
                sum += gcd(gcd(i, j), l);
    cout << sum;


    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

void compress(vi& v)
{
	sort(ALL(v));
	v.erase(unique(ALL(v)), v.end());
}

int main()
{
	int n, m;
	cin >> n >> m;
	vector<pii> v;
	vi vx, vy;
	REP(i, n)
	{
		ld x, y; cin >> x >> y;
		vx.push_back(x); vy.push_back(y);
		v.emplace_back(x, y);
	}
	compress(vx);
	compress(vy);
	vector<vi> sum(n+1, vi(n+1));
	REP(i, n)
	{
		int x = v[i].first, y = v[i].second;
		int cx = find(ALL(vx), x) - vx.begin();
		int cy = find(ALL(vy), y) - vy.begin();
		sum[cx+1][cy+1]++;
	}
	FOR(i, 1, n + 1)FOR(j, 1, n + 1)
	{
		sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i-1][j-1];
	}
	
	REP(i, m)
	{
		ld lx, ly, rx, ry;
		cin >> lx >> ly >> rx >> ry;
		rx++; ry++;
		int clx = lower_bound(ALL(vx), lx) - vx.begin();
		int cly = lower_bound(ALL(vy), ly) - vy.begin();
		int crx = lower_bound(ALL(vx), rx) - vx.begin();
		int cry = lower_bound(ALL(vy), ry) - vy.begin();
		cout << sum[crx][cry] - sum[crx][cly] - sum[clx][cry] + sum[clx][cly] << endl;
	}
	return 0;
}

Measured memory_bytes: 100912
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
using namespace std;
signed main(){
    int n;
    cin >> n;
    vec(a,n);
    vec(b,201);
    REP(i,n){
        cin >> a[i];
    }
    FOR(i,-100,101){
        REP(j,n){
            int t = a[j] - i;
            t *= t;
            b[i+100] += t;
        }
    }
    sort(b.begin(),b.end());
    cout << b[0] << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        
        for(int a = 0; a <= N; a++) {
        	for(int b = 0; b <= N - a; b++) {
        		int c = N - a - b;
        		int total = a * 10000 + b * 5000 + c * 1000;
        		if(total == Y) {
        			System.out.println(a + " " + b + " " + c);
        			return;
        		}
        	}
        }
        
        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 22612
l=[]
for i in range(3):
        l.extend(list(map(int,input().split())))

n = int(input())
b = [int(input()) for i in range(n)]
c = []
for ii in range(n):
    for iii in range(9):
        if b[ii] == l[iii]:
            c.append(iii)
            break
flag = 'No'
for i in range(3):
    if 3*i in c and 3*i+1 in c and 3*i+2 in c:
        flag = 'Yes'
        break
    if i in c and 3+i in c and 6+i in c:
        flag = 'Yes'
        break
if 0 in c and 4 in c and 8 in c:
    flag = 'Yes'
elif 2 in c and 4 in c and 6 in c:
    flag = 'Yes'

print(flag)


Measured memory_bytes: 3064
//tyama_C_fast.cpp
//much faster!

//PerlÅà¯é¯Ç½ªâçÈ¢B

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define hi(x) ((x)>>16)
#define lo(x) ((x)&0xffff)

struct comp{
    bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
};

inline void solve(int n, int w, int d){
	vector<unsigned> v;
	v.push_back((w<<16)+d);
	while(n--){
		int p, s, state=0;
		scanf("%d %d", &p, &s);
		p--;
		s%=(hi(v.at(p))+lo(v.at(p)));
		
		unsigned x=hi(v.at(p)), y=lo(v.at(p)), _x=0, _y=0;
		while(s--){
			switch(state){
				case 0:{
					_x++;
					if(_x==x)state=1;
					break;
				}
				case 1:{
					_y++;
					/* impossible
					if(_y==y)state=2;
					break;
				}
				case 2:{
					_x--;
					if(_x==0)state=3;
					break;
				}
				case 3:{
					_y--;
					if(_y==0)state=0;
					*/
					break;
				}
			}
		}
		unsigned x1, x2, y1, y2;
		switch(state){
			case 0: /*case 2:*/{
				x1=_x;x2=x-_x;
				y1=y2=y;
				break;
			}
			case 1: /*case 3:*/{
				x1=x2=x;
				y1=_y;y2=y-_y;
				break;
			}
		}
		
		v.erase(v.begin()+p);
		if(x1*y1>x2*y2){
			v.push_back((x2<<16)+y2);
			v.push_back((x1<<16)+y1);
		}else{
			v.push_back((x1<<16)+y1);
			v.push_back((x2<<16)+y2);
		}
	}
	
	sort(v.begin(), v.end(), comp());
	while(v.size()){
		printf("%d", hi(v.at(0))*lo(v.at(0)));
		v.erase(v.begin());
		if(v.size())printf(" "); //±ÌÓÍPerl¾Æjoinªg¦é¨B
	}
	printf("\n");
}

int main(){
	int n,w,d;
	while(1){
		scanf("%d %d %d",&n,&w,&d);
		if(!n&&!w&&!d)return 0;
		solve(n, w, d);
	}
}

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

void solve () {
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort (a.rbegin(), a.rend());
    for (int i = 0; i < n; i++) {
        int j = 0;
        while (a[j].second == i) j++;
        cout << a[j].first << "\n";
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 4784