akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define int long long
#define EB emplace_back
#define MOD 1000000007
#define F first
#define S second
#define N 100005
#define endl "\n"
 
 
using namespace std; 



    

int32_t main()
{

   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int tt=1;

    //cin>>tt;
    
    while(tt--)
    {
      string str; cin>>str;
      int n = str.size();
      for(int i=0;i<n;i++) cout<<"x";
    }
        return 0;
}







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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


int N;
vector<vector<int>> g;
vector<int> sente, gote;

void dfs_sente(int s){
	for (int v : g[s]){
		if (sente[v]==INF){
			sente[v] = sente[s] + 1;
			dfs_sente(v);
		}
	}
}

void dfs_gote(int s){
	for (int v : g[s]){
		if (gote[v] == INF){
			gote[v] = gote[s] + 1;
			dfs_gote(v);
		}
	}
}


signed main(){
	cin >> N;

	g.assign(N, vector<int>());
	for (int i = 0; i < N - 1; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	sente.assign(N, INF);
	gote.assign(N, INF);
	sente[0] = 0; gote[N - 1] = 0;
	dfs_sente(0);
	dfs_gote(N - 1);

	int count_sente = 0, count_gote=0;
	for (int i = 0; i < N; i++){
		if (sente[i] <= gote[i]) count_sente++;
		else count_gote++;
	}

	if (count_sente > count_gote) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	
	return 0;
}

Measured memory_bytes: 12032
// Problem : R - Walk
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_r
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define maxm 1e18
#define minm -1e18
#define pr pair<ll,ll>
#define mod 1000000007

vector< vector<ll> > mul(vector< vector<ll> > a,vector< vector<ll> > b)
{
	ll n=a.size(),i,j,k;
	vector< vector<ll> > res(n,vector<ll>(n));
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			for(k=0;k<n;k++)
				res[i][k]=(res[i][k]+(a[i][j]*b[j][k])%mod)%mod;
	return res;
}

vector< vector<ll> > power(vector<vector<ll> > a,ll k)
{
	if(k==1)
		return a;
	ll n=a.size();
	vector< vector<ll> > res(n, vector<ll> (n));
	res=power(a,k/2);
	res=mul(res,res);
	if(k%2)
		res=mul(res,a);
	return res;
}
 
void solve()
{
	ll n,k,i,j,ans=0;
	cin>>n>>k;
	vector< vector<ll> > a(n,vector<ll>(n));
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			cin>>a[i][j];
	vector< vector<ll> > res(n,vector<ll>(n));
	res=power(a,k);
	for(i=0;i<n;i++)
		for(j=0;j<n;j++)
			ans=(ans+res[i][j])%mod;
	cout<<ans<<endl;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
// 前計算 [0-i)の接頭辞と接尾辞が何文字まであっているか
vector<ll> makeTable(vector<ll> s) {
    ll n = s.size();
    vector<ll> ret(n+1);
    ret[0] = -1;
    ll j = -1;
    rep(i,n){
        while ( j>=0 and s[i]!=s[j] ) j = ret[j];
        ret[i+1] = ++j;
    }
    return ret;
}
// str の中に word と一致する場所を返す
vector<ll> kmp(vector<ll>& str, vector<ll>& word) {
    vector<ll> table = makeTable(word), ret;
    ll m=0, i=0, n=str.size();
    while ( m+i < n) {
        if (word[i] == str[m+i]) {
            if (++i == (ll)(word.size())) {
                ret.emplace_back(m);
                m = m+i-table[i];
                i = table[i];
            }
        }
        else{
            m = m+i-table[i];
            if (i > 0) i = table[i];
        }
    }
    return ret;
}

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    vector<ll> B(N);
    rep(i,N) cin>>A[i];
    rep(i,N) cin>>B[i];
    vector<ll> X(N,0);
    vector<ll> Y(N,0);
    rep(i,N) X[i]=A[(i+1)%N]^A[i];
    rep(i,N) Y[i]=B[(i+1)%N]^B[i];
    auto X2=X;
    for(auto x: X) X2.emplace_back(x);
    auto ve=kmp(X2,Y);
    for(auto x: ve){
        if(x>=N) continue;
        cout<< x << " ";
        cout<< (A[x]^B[0]) <<"\n";
    }

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 15332
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string();
lli ans=1;
vl adj[100001];
lli p=1000000007;
lli fac[1000001];
lli power(lli x, lli y, lli p) 
{ 
    lli res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
lli modInverse(lli n,lli p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
lli npr(lli n, lli r,lli p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  	if(n-r<0)return 0;
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
/*    lli fac[n+1]; 
    fac[0] = 1; 
    for (lli i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  */
    return (fac[n]* modInverse(fac[n-r], p) % p) % p; 
} 
lli k;  
void dfs(lli v,lli par){
	lli m=adj[v].size();
	if(v==1)
		ans*=npr(k-1,m,p);
	else
		ans*=npr(k-2,m-1,p);
	ans%=p;
	for(lli u:adj[v]){
		if(u==par)continue;
		dfs(u,v);
	}
}
int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n;
    cin>>n>>k;
    fac[0] = 1; 
    for (lli i=1 ; i<=100001; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    for(lli i=0;i<n-1;i++){
    	lli a,b;
    	cin>>a>>b;
    	adj[a].pb(b);
    	adj[b].pb(a);
    }

    dfs(1,0);
    cout<<(k*ans)%p;



	return 0;

}

Measured memory_bytes: 11648
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
const int mod=1e9+7;
int main (){ 
   int a , b , c, x , y ;
   cin >> a >> b >> c >> x >> y;
 
	
	
	int mn = 1001001001;
 
	int m;
 
	for (int i = 0; i <= max(2*x,2*y); i = i + 2) {
 
		m = i * c + max(x - i/2, 0) * a + max(y - i/2, 0) * b;
		if (mn > m) {
			mn = m;
		}
 
	}
	cout << mn << endl;
 
}

 


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        //Number of Atcoder crackers
        int n = sc.nextInt();

        //Number of mans
        int k = sc.nextInt();

        int answer = n % k;

        if(answer == 0){
        	System.out.println( answer );
        } else {
        	System.out.println( 1 );
        }
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define MOD 1000000007
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<double> p(N);
    REP(i, N) cin >> p[i];

    vector<vector<double>> dp(N+1, vector<double>(N+1));
    dp[0][0] = 1;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            dp[i+1][j] += dp[i][j] * (1-p[i]);
            dp[i+1][j+1] += dp[i][j] * p[i];
        }
    }
    double ans = 0;
    for(int i=N/2+1; i<=N; i++)
        ans += dp[N][i];
    cout << fixed << setprecision(32) << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
//EDPC S
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

string k;
int d;
ll dp[10001][2][101];

ll rec(int digit, bool tight, int sum){
    if(dp[digit][tight][sum] != -1){
        return dp[digit][tight][sum];
    }
	if(digit == k.size()){
		return sum == 0;
	}
	int x = k[digit] - '0';
	int lim = (tight ? x : 9);
	ll res = 0;
	for(int i = 0; i <= lim; i++){
		res += rec(digit + 1, tight && i == lim, (sum + i) % d);
		res %= MOD;
	}
	return dp[digit][tight][sum] = res;
}

signed main(){
	cin >> k;
    cin >> d;
    memset(dp, -1, sizeof(dp));
	cout << (rec(0, 1, 0) - 1 + MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main(){
    int a[3], res;
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    res=(a[1]-a[0])+(a[2]-a[1]);
    cout << res << endl;
    return 0;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s[2];
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if (s[0] <= a[i]) {
            s[1] = s[0];
            s[0] = a[i];
        } else if (s[1] < a[i]) s[1] = a[i];
    }
    for(int i=0; i<n; i++) {
        if (a[i] == s[0]) printf("%d\n", s[1]);
        else printf("%d\n", s[0]);
    }
    return 0;
}



Measured memory_bytes: 2432
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

/*
 貪欲
 ?決定問題 必ず解に含まれる(含むように変換できる)ものから決めていく みんプロ本選B
 ?最適化問題 任意の解から評価を落とさず解に含められるようなものから決めていく 区間スケジューリングとか
 ?
 */

/*
 DP
 ?DPはある程度決め打ちをするべき(解を帰納的に構成できないか？)
 */

void dfs(ll i, ll j, vector<vector<int>>& c) {
	c[i][j]=0;
	for(ll dx=-1; dx<=1; dx++) {
		for(ll dy=-1; dy<=1; dy++) {
			if(i+dx>=0&&i+dx<(ll)c.size()&&j+dy>=0&&j+dy<=(ll)c[0].size()&&c[i+dx][j+dy]==1) dfs(i+dx,j+dy,c);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
	ll w,h;
	cin>>w>>h;
		if(w==0&&h==0) break;
	vector<vector<int>> c(h,vector<int>(w));
	REP(i,h) REP(j,w) cin>>c[i][j];
	ll ret=0;
	REP(i,h) REP(j,w) {
		if(c[i][j]==1) {
			ret++;
			dfs(i,j,c);
		}
	}
	cout<<ret<<endl;
	}
}

Measured memory_bytes: 3412
#include<iostream>

int main() {
  int R;
  std::cin >> R;
  if (R < 1200) {
    std::cout << "ABC" << std::endl;
  } else if (R < 2800) {
    std::cout << "ARC" << std::endl;
  } else {
    std::cout << "AGC" << std::endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a),i##_end_ = (b);i<=i##_end_;i++)
#define ROF(i,a,b) for(int i = (a),i##_end_ = (b);i>=i##_end_;i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 5005
#define M 1500005
#define INF 1000000007
#define MOD 1000000007
#define MOD2 1000000009
#define eps 1e-14
#define DEBUG_
#ifdef DEBUG_
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
#else
#define DEBUG(...)
#endif // DEBUG
using namespace std;

int a[N];
bool val[2][N];
int n,k;
bool ok(int p)
{
    MST(val[0],0);
    val[0][0] = 1;
    int f = 0;
    FOR(i,1,n)
    {
        if(i == p)continue;
        f = 1-f;
        FOR(j,0,N-1)val[f][j] = val[1-f][j];
        FOR(j,0,N-1)
        {
            if(val[1-f][j]&&j+a[i]<N)
                val[f][j+a[i]] = 1;
        }
    }
    FOR(i,0,N-1)
    {

        if(val[f][i]&&i>=k-a[p]&&i<k)
        {
            //if(p == 5)cout<<i<<endl;
            return 0;
        }
    }
    return 1;
}
int main()
{

    while(scanf("%d%d",&n,&k)!=EOF)
    {
        FOR(i,1,n)scanf("%d",&a[i]);
        sort(a+1,a+n+1);
        if(a[1]>=k)
        {
            printf("0\n");
            continue;
        }
        int l = 0,r = n+1;
        while(l<r-1)
        {
            int mid = (l+r)>>1;
            if(ok(mid))l =mid;
            else r = mid;
        }
        printf("%d\n",l);
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long w, h, x, y;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); //cout.tie(0);
	cin >> w >> h >> x >> y;
	long long tmp = w * h;
	double ans = ((double)tmp) / 2;
	cout << setprecision(10) << ans << " ";
	if (x * 2 == w && y * 2 == h) {
		cout << "1\n";
	}
	else {
		cout << "0\n";
	}
	//system("pause");
	return 0;
}

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

void solve(long long a, long long b, long long h){
    cout << (a + b) * h / 2 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long h;
    scanf("%lld",&h);
    solve(a, b, h);
    return 0;
}


Measured memory_bytes: 256
# ABC162_C
from math import gcd
k=int(input())
t=[]
for i in range(1,k+1):
    for j in range(1,k+1):
        t.append(gcd(i,j))
ans=[]
for tt in t:
    for i in range(1,k+1):
        ans.append(gcd(tt,i))
print(sum(ans))



Measured memory_bytes: 209016
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ar array

int N;
vector<char>V;
string S;

void init()
{
    for(int i = 0; i < 26; i++)
        V.pb(((char)(i+65)));
}

void solve()
{
    init();
    //print();
    cin>>N;
    cin>>S;

    string res = "";

    for(int i = 0; i < S.length(); i++)
    {
        char ch = S[i];
        int asc = (int)ch;
        int index = asc - 65;

        res += V[(index + N)%26];
    }

    cout<<res<<endl;
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
  ll a;
  cin>>a;
  int count=0;
  for(ll i=0;i<1000;i++){
    if(count>0){
      break;
    }
    for(ll j=0;j<1000;j++){
     ll b=(i*i*i*i*i)-(j*j*j*j*j);
      ll c=(i*i*i*i*i)+(j*j*j*j*j);
      ll d=-(i*i*i*i*i)+(j*j*j*j*j);
      if(b==a){
        cout<<i<<" "<<j<<endl;
        count++;
        break;
      }
      else if(c==a){
        cout<<i<<" "<<j*(-1)<<endl;
        count++;
         break;
      } 
      if(d==a){
        cout<<i*(-1)<<" "<<j*(-1)<<endl;
        count++;
        break;
      }
    }
  }
}

Measured memory_bytes: 3580
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        int cnt = 0;
        for(int i = 0; i<n-2; i++) {
            if(a[i]<a[i+1] && a[i+1]<=a[i+2]) cnt++;
            if(a[i+2]<a[i+1] && a[i+1]<=a[i]) cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
from collections import deque


def solve():
    N, Q = map(int, input().split())
    graph = [[] for _ in range(N + 1)]
    for i in range(N-1):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)
    val = [0 for _ in range(N + 1)]
    for i in range(Q):
        p, x = map(int, input().split())
        val[p] += x

    que = deque([1])
    parent = [0 for _ in range(N+1)]
    while que:
        i = que.popleft()
        for j in graph[i]:
            if j == parent[i]:
                continue
            parent[j] = i
            que.append(j)
            val[j] += val[i]

    print(*val[1:])


if __name__ == '__main__':
    solve()

Measured memory_bytes: 56124
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);

    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;

    return 0;
}


Measured memory_bytes: 632
import java.util.Scanner;

public class Main{
	static int n, k;
	static int[] w;
	static boolean ok(int p) {
		int tw=0, tc=1;
		for(int i=0; i<n; i++) {
			if(tw+w[i]<=p) {
				tw+=w[i];
			}
			else if(w[i]<=p){
				tc++;
				tw=w[i];
			}
			else {
				return false;
			}
		}
		return (tc<=k)? true:false;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			n=sc.nextInt();
			k=sc.nextInt();
			w=new int[n+1];
			for(int i=0; i<n; i++) {
				w[i]=sc.nextInt();
			}
			int l=0, h=1000000000;
			while(l+1<h) {//積みきれない最大値がある範囲[l, h)
				int m=(l+h)/2;
				if(ok(m)) {//積みきれる場合
					h=m;
				}
				else {
					l=m;
				}
			}
			System.out.println(h);

		}
	}
}


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

const int stack_size = 200;
class Stack{
  public:
    Stack(){}
    void init(){
      top = 0;
    }
    int isEmpty(){
      return top == 0;
    }
    int isFull(){
      return top >= stack_size;
    }
    void push(int x){
      if(isFull()){
        cout << "error";
      }else{
        top++;
        stack[top] = x;
      }
    }
    int pop(){
      if(isEmpty()){
        cout << "error Empty";
      }else{
        top--;
        return stack[top + 1];
      }
    }
  private:
    int top;
    int stack[stack_size];
};


int main(){
  Stack stack;
  char x[100];
  int y;
  while(scanf("%s ", x) != EOF){
    if(x[0] == '+'){
      stack.push(stack.pop() + stack.pop());
    }else if(x[0] == '-'){
      int z, w;
      z = stack.pop();
      w = stack.pop();
      stack.push(-z + w);
    }else if(x[0] == '*'){
      stack.push(stack.pop() * stack.pop());
    }else{
      y = atoi(x);
      stack.push(y);
    }
  }
  cout << stack.pop() << endl;
}



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

int main(){
    int n ;cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        if(a[i] > i){
            cout << -1 << endl;
            return 0;
        }
    }
    rep(i,n-1){
        if(a[i+1] > a[i]+1) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    rep(i,n-1){
        if(a[i] != a[i+1]-1) ans += a[i];
    }
    ans += a[n-1];
    cout << ans << endl;
}

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

int n[10001][723]={};
int main(){

int N,M;
while(1){
cin>>N>>M;if(N==0&&M==0)break;
int r;
cin>>r;

for(int i=0;i<=M;i++)
for(int j=0;j<722;j++)
n[i][j]=0;

for(int i=0;i<r;i++)
{int t,x,m,w;
cin>>t>>x>>m>>w;
t-=540;
if(w==1)n[m][t]+=1;
else{n[m][t]-=1;}
}
for(int i=0;i<=M;i++)
for(int j=0;j<721;j++)
n[i][j+1]+=n[i][j];


int q,t1,t2,y;
cin>>q;


for(int i=0;i<q;i++){
cin>>t1>>t2>>y;
t1-=540;t2-=540;
int c=0;
for(int j=t1;j<t2;j++)
{
	if(n[y][j]!=0){c++;}//cout<<j+540<<" "<<c<<n[y][j]<<endl;}
}
cout<<c<<endl;
}
}
return 0;
}

Measured memory_bytes: 28512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int answer = 0;

		answer = C - (A - B);

		if (answer < 0) {
			System.out.println(0);
		} else {
			System.out.println(answer);
		}
	}
}


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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<int,int>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int dp[100009][3];
vector<vector<int> > acts;
int n;

int solve (int i, int prev){
    if(i == n) return 0;

    int &ret = dp[i][prev];
    if(ret != -1) return ret;

    int mx = 0;
    loop(j, 3) if(j != prev){
        mx = max(mx, acts[j][i] + solve(i+1, j));
    }

    return ret = mx;
}

int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    clr(dp, -1);

    cin>>n;
    acts = vector<vector<int> > (3, vector<int> (n));

    loop(i, n){
        cin>>acts[0][i]>>acts[1][i]>>acts[2][i];
    }

    int ans=0;
    loop(i, 3){
        ans = max(ans, solve(1, i) + acts[i][0]);
    }

    cout<<ans;
}



Measured memory_bytes: 10364
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, m: u64
    }

    let y = (n - m) * 100 + m * 1900;
    println!("{}", y * 2u64.pow(m as u32));
}


Measured memory_bytes: 4352
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
if n>=m:
    print(0)
else:
    s=[]
    for i in range(m-1):
        a=x[i+1]-x[i]
        s.append(a)
    s.sort()
    ans=0
    for i in range(m-n):
        ans+=s[i]
    print(ans)

Measured memory_bytes: 90428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll OO = 1e18;
class Edmond{
  public:
    bool directed;
    int n;
    ll add;
    Edmond(int _n):directed{1}, n{_n}, add{0}{}
    Edmond(int _n, bool _directed):n{_n}, directed{_directed}, add{0}{
      par.resize(n);
      vis.resize(n);
      adj.resize(n);
      vis.resize(n);
    }
    void add_edge(int u, int v, ll c){
      add_directed(u, v, c);
      if(!directed)
        add_directed(v, u, c);
    }
    ll max_flow(int s, int t){
      if(adj.size() <= s)return 0;
      ll res = 0;
      ll aug = 0;
      while(aug = augment(s, t)){
        tt++;
        res += aug;
      }
      return res;
    }
    struct Edge{
      ll oc;
      int u, v;
      ll c;
      Edge(int _u, int _v, ll _c):u{_u}, v{_v}, c{_c}{oc = c;}
    };
    vector<vector<int>> adj;
    vector<Edge> e;
  private:
    int tt = 1;
    vector<int> vis;
    vector<int> par;
    ll fix_path(int s, int u, ll flow){
      if(u == s)
        return flow;
      ll res = fix_path(s, e[par[u]].u, min(flow, e[par[u]].c));
      e[par[u]].c     -= res;
      e[par[u] ^ 1].c += res;
      return res;
    }
    ll augment(int s, int t){
      queue<int> q;
      q.push(s);
      vis[s] = tt;
      while(q.size()){
        int u = q.front();q.pop();
        if(u == t)break;
        for(auto el : adj[u]){
          Edge& ee = e[el];
          if(vis[ee.v] != tt && ee.c != 0){
            vis[ee.v] = tt;
            par[ee.v] = el;
            q.push(ee.v);
          }
        }
      }
      if(vis[t] != tt)
        return 0;
      return
        fix_path(s, t, OO);
    }
    void add_directed(int u, int v, ll c){
//      cout << u << ' ' << v << ' ' << c << endl;
      e.push_back(Edge(u, v, c));
      adj[u].push_back(e.size() - 1);
      e.push_back(Edge(v, u, 0));
      adj[v].push_back(e.size() - 1);
    }
};
int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int a[n + 1];
  ll x = 0;
  int s = 0, t = n + 1;
  Edmond mf(n + 2, true);
  ll res = 0;
  for(int i = 1;i <= n;i++){
    cin >> a[i];
    if(a[i] > 0)
      res += a[i], mf.add_edge(s, i, a[i]);
    else if(a[i] < 0)
      mf.add_edge(i, t, -a[i]);
  }
  for(int i = 1;i <= n;i++)
    for(int j = 2 * i;j <= n;j += i)
      mf.add_edge(j, i, OO);
  cout << res - mf.max_flow(s, t);
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N, 0);
    for(auto& a: A){
        cin >> a;
    }
    int one = 0;
    for (int i = 0; i < N; ++i){
        if( A[i] == 1 ){
            one = i;
        }
    }
    int ans = (N - 1 + K - 1 - 1) / (K - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main ()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   bool t=true;
   while(t=true)
   {
     c=c-b;
    if(c<=0)
    {
    cout<<"Yes";
    break;
    }
     a= a-d;
    if(a<=0)
    {
    cout<<"No";
    break;
    }

    }
}

Measured memory_bytes: 3544
// Problem : E - Double Factorial
// Contest : AtCoder - AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vint vector<int>
#define sint set<int>
#define mint map<int,int>
#define pint pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void solve(){
	int n;
	rd(n);
	if(n&1){
		pp(0);
		return ;
	}
	int ans=0,t=10,ans2=0,t2=5;
	while(n/t2)ans2+=n/(2*t2),t2*=5;
	pp(ans2);
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 3584
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


from collections import defaultdict
n,m = map(int, input().split())
ns = defaultdict(int)
for _ in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    ns[u] += 1
    ns[v] += 1
if all(val%2==0 for val in ns.values()):
    ans = "YES"
else:
    ans = "NO"
print(ans)

Measured memory_bytes: 79636
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

sys.setrecursionlimit(1000000)
dire, dire8 = [[1, 0], [0, 1], [-1, 0], [0, -1]], [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets, ALPHABETS = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD, INF = 1000000007, float("inf")

def main():
    N = I()
    A = IR(N)

    cur = 1
    count = 0
    for _ in range(N):
        if cur == 2:
            print(count)
            break
        cur = A[cur-1]
        count += 1
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 82536
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
        
a,b,k = map(int,input().split())
cnt=1

ans=gcd(a,b)
n=ans
if not(k==1):
    for i in range(n):
        c=n-i-1
        if(a%c==0 and b%c==0):
            ans=n-i-1
            cnt+=1
        if(cnt==k):
            break
      
print(ans)

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

int main(){
    int H, W, X, Y;
    while(1){
        cin>>H>>W;
        if(W==0&&H==0){
            break;
        }
        X=H-2;
        Y=W-2;
        for(int i=1; i<=W; i++){
            cout<<'#';
        }
        cout<<'\n';
        for(int a=1; a<=X; a++){
            cout<<'#';
            for(int b=1; b<=Y; b++){
                cout<<'.';
            }
            cout<<'#';
            cout<<'\n';
        }
        for(int c=1; c<=W; c++){
            cout<<'#';
        }
        cout<<'\n'<<'\n';
    }
    return 0;
}


Measured memory_bytes: 2988
#include <stdio.h>

int main( int argc, char *argv[] )
{
	int input[3] = { 0 };
	int i = 0;
	
	int five = 0;
	int seven = 0;

	scanf( "%d %d %d", &input[0], &input[1], &input[2] );

	for(i = 0; i < 3; i = i + 1 ){
		if(5 == input[i]){
			five++;
		}else if(7 == input[i]){
			seven++;
		}
	}
	
	if(2 == five && 1 == seven){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	ll arr[n + 1];
	for (int i = 1; i <= n; ++i)
		cin >> arr[i];
	int brr[n + 1];
	for (int i = 2; i <= n; ++i)
		if (arr[i] > arr[i - 1])
			brr[i] = 1;
		else if (arr[i] < arr[i - 1])
			brr[i] = 0;
		else
			brr[i] = 2;
	ll m = 1000;
	ll s = 0;

	for (int i = 2; i <= n; ++i) {
		/*if (i == n) {
			m += s * arr[i];
			s = 0;
		}
		else*/ if (brr[i] == 1) {
			ll here = m / arr[i - 1];
			s += here;
			m -= here * arr[i - 1];
			m += s * arr[i];
			s = 0;
		}
		else if (brr[i] == 0) {
			int pos = i;
			while (pos < n and brr[pos + 1] == 0 or brr[pos + 1] == 2)
				++pos;
			//int next = pos;
			/*while (next < n and brr[pos + 1] == 1 or brr[pos + 1] == 2)
				++next;
			for (int j = pos + 1; j <= next; ++j) {
				ll here = m / arr[i - 1];
				s += here;
				m -= here * arr[i - 1];
				m += s * arr[i];
				s = 0;
			}*/
			//cout << i << " " << pos << endl;
			i = pos;

		}
	}
	cout << m << endl;
}

Measured memory_bytes: 3540
x1,y1,x2,y2 = map(int,input().split())
import numpy as np

x1 = np.array([x1,y1])
x2 = np.array([x2,y2])
rot = np.array([[0,-1],[1,0]])
x3 = np.dot(rot,(x2-x1))+x2
x4 = np.dot(rot,(x3-x2))+x3
print(x3[0],x3[1],x4[0],x4[1])

Measured memory_bytes: 12500
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var map = mutableMapOf<String, Int>()
    for(i in 0 until n){
        val str = readLine()!!
        if(map.keys.contains(str)) {
            map[str] = map[str]?.plus(1) ?: 1
        } else {
            map[str] = 1
        }
    }

    val max = map.values.max()!!

    for((k, v) in map.toSortedMap()){
        if(v == max) {
            println(k)
        }
    }
}

Measured memory_bytes: 94332
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int R = sc.nextInt();
    if(N >=10){
      System.out.println(R);
    }else{
      R = R + (10- N)*100;
      System.out.println(R);
    }
  }
}



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

int main(){
  int A,B,count=0;
  cin >> A >> B;
  
  for(int i=A;i<=B;i++){
    if(i/10000==i%10&&(i/1000)%10==(i%100)/10) count++;
  }
  cout << count << endl;
}



Measured memory_bytes: 256
def combs_mod(n,k,mod):
  #nC0からnCkまで
  inv = [1]*(k+1)
  for i in range(1,k+1):
    inv[i] = pow(i,mod-2,mod)
  ans = [1]*(k+1)
  for i in range(1,k+1):
    ans[i] = ans[i-1]*(n+1-i)*inv[i]%mod
  return ans
def solve():
  mod = 998244353
  N, K = map(int, input().split())
  ans = 0
  if K<N:
    return ans
  com = combs_mod(K,K,mod)
  com2 = combs_mod(K-1,K-1,mod)
  for r in range(K+1):
    b = K-r
    dif = r-b
    if dif<0 or r<N:
      continue
    elif dif==0:
      ans += com2[r]
      if N>=2:
        ans -= com2[N-2]
    elif dif<N:
      ans += com[r] - com[N-1-dif]
    else:
      ans += com[r]
    ans %= mod
  return ans
print(solve())

Measured memory_bytes: 182276
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k, ans;

	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	vector<vector<int>> dp(2, vector<int>(n));
	for (i = 0; i < 2; i++) {
		for (j = 0; j < n; j++) cin >> a[i][j];
	}
	dp = a;
	for (i = 0; i < 2; i++) {
		for (j = 0; j < n; j++) {
			if (i == 1) dp[i][j] = max(dp[i][j], dp[i - 1][j] + a[i][j]);
			if (j >= 1) dp[i][j] = max(dp[i][j], dp[i][j - 1] + a[i][j]);
		}
	}
	cout << dp[1][n - 1] << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define PQ priority_queue
#define pb push_back
#define fu(i,a,j) for(int i=a;i<j;i++)
#define fd(i,a,j) for(int i=a;i>=j;i--)
#define SYNC ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define MOD 1000000007 
#define MOD2 1000000021
#define MAXN 2000000
#define INF 1e9
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;

//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll m_pow(ll a, ll b, ll M = MOD) { ll res = 1; for (; b; b >>= 1, a = (a * a) % M)if (b & 1)res = (res * a) % M; return res; }
ll gcd(ll a, ll b) { if (a < b) swap(a, b); for (; b; a %= b, swap(a, b)); return a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };
db dis(pii a, pii b) { return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); }
int dr[] = { 0, 1, 0, -1, 1,1,-1,-1 };
int dc[] = { 1, 0, -1, 0, 1,-1,1,-1 };

int n, m, k, t;

string ansok[2] = { "NO","YES" };
char a[1001][1001];
bool vis[1001][1001];

int main()
{
	SYNC;
	cin >> n >> m;
	int ans = 0;
	int sr, sc;
	int Dr, Dc;
	cin >> sr >> sc;
	cin >> Dr >> Dc;
	sr--; sc--;
	Dr--, Dc--;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	//양옆 2칸씩까지 워프가능
	PQ<pair<int,pii>> q;
	q.push({ 0,{ sr,sc } });
	ans = INF;
	while (!q.empty()) {
		int cnt = -q.top().x;
		int r = q.top().y.x, c = q.top().y.y;
		q.pop();
		if (vis[r][c]) continue;
		vis[r][c] = 1;
		if (r == Dr && c == Dc) {
			ans = cnt;
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nr = r + dr[i], nc = c + dc[i];
			if (nr < 0 || nr >= n || nc < 0 || nc >= m) continue;
			if (vis[nr][nc] || a[nr][nc]=='#') continue;
			q.push({ -cnt,{ nr,nc } });
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				if ((i == 0 && j == 0) || (i == 0 && j == 1) || (i == 0 && j == -1) 
					|| (i == 1 && j == 0) || (i == -1 && j == 0)) continue;
				int nr = r + i, nc = c + j;
				if (nr < 0 || nr >= n || nc < 0 || nc >= m) continue;
				if (vis[nr][nc] || a[nr][nc] == '#') continue;
				q.push({ -cnt - 1,{ nr,nc } });
			}
		}
	}
	if (ans == INF)
		ans = -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 5892
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K,X;
    cin>>K>>X;
    int c[100000];
        for(int i=0;i<2*K-1;i++){
        c[i]=X-K+i+1;
        cout<<c[i]<<" "; 
        }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int v[10001];

int main() {
    int num_elems, max_price;
    cin >> num_elems >> max_price;
    do {
        int best = -1;
        bool best_initialized = false;
        int x;
        for (int i = 0; i < num_elems; i++) {
            cin >> x;
            v[i] = x;
        }

        sort(v, v + num_elems);

        int j = num_elems - 1;
        for (int i = 0; i < num_elems; i++) {
            while(j > i && v[i] + v[j] > max_price) {
                j--;
            }

            if(j > i && (!best_initialized || v[i] + v[j] > best)) {
                best = v[i] + v[j];
                best_initialized = true;
            }
        }

        if (best_initialized) {
            cout << best << '\n';
        }
        else {
            cout << "NONE\n";
        }

        cin >> num_elems >> max_price;
    }while(num_elems != 0);

    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    n=n-n/k*k;
    puta(min(n,k-n));
    return 0;
}

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

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

  int n, a;
  cin >> n >> a;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  for (int i = 0; i < n; i++) x[i] -= a;
  unordered_map<int, long long> dp;
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    auto ndp = dp;
    for (auto &kv : dp) {
      auto k = kv.first + x[i];
      auto v = kv.second;
      ndp[k] = (ndp.find(k) != ndp.end()) ? ndp[k] + v : v;
    }
    dp = ndp;
  }
  cout << dp[0] - 1 << '\n';
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long gcd(long a,long b){
  if(a%b == 0)return b;
  else return gcd(b,a%b);
}

int main(){
  int n;
  long x;
  int i;
  cin >> n >> x;
  long xx[n];
  long dist[n];
  for(i=0;i<n;i++){
    cin >> xx[i];
    dist[i] = abs(xx[i]-x);
  }
  sort(dist,dist+n);
  long ans = dist[0];
  for(i=1;i<n;i++){
    ans = gcd(dist[i],ans);
  }
  cout << ans;
}


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

int main() {
  char s[5];
  scanf("%s",s);
  bool b[3]={0};
  for ( int i=0; i<3; i++ ) {
    b[s[i]-'a']=1;
  }
  if ( b[0] && b[1] && b[2] ) {
    puts("Yes");
  }
  else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int num,i=0,hit=0,out=0,total=0,score=0;
	char data[10];
	
	while(1){
		
		scanf("%d",&num);
		
		scanf("%s",data);
		
		if(data[1]=='I'){
			hit=hit+1;
			if(hit==4){
				score++;
				hit=3;
			}
		}
		else if(data[1]=='O'){
			score=score+hit+1;
			hit=0;
		}
		else if(data[1]=='U'){
			out++;
			if(out==3){
				out=0;
				hit=0;
				printf("%d\n",score);
				score=0;
				total++;
			}
		}
		
		if(total==num){
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
N,K = map(int,input().split())

d = [0]*K
A = [[0] * K for i in range(N)]
n = 0

for i in range(K):
    d[i] = int(input())
    a = list(map(int, input().split()))
    for j in range(len(a)):
        A[a[j]-1][i] = 1
    
for i in range(N):
    if sum(A[i]) == 0:
        n += 1

print(n)


Measured memory_bytes: 9196
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

use std::cell::RefCell;
pub struct GraphL {
    g: Vec<Vec<usize>>,
    res: RefCell<Vec<usize>>,
}
impl GraphL {
    pub fn bfs(&self, s: usize) {
        use std::collections::VecDeque;
        let mut queue = VecDeque::new();
        queue.push_back(s);
        // self.res.borrow_mut().push(s);
        while let Some(&u) = queue.front() {
            for v in self.g[u].iter() {
                if self.res.borrow_mut()[*v] != std::usize::MAX {
                    continue;
                }
                self.res.borrow_mut()[*v] = u;
                queue.push_back(*v);
            }
            queue.pop_front();
        }
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        edges: [(usize1,usize1);m]
    }
    let mut g = vec![Vec::new();n];
    for (l,r) in edges {
        g[l].push(r);
        g[r].push(l);
    }
    let graph = GraphL {
        g: g,
        res: RefCell::new(vec![std::usize::MAX;n])
    };
    graph.bfs(0);
    let res = graph.res.borrow();
    // println!("{:?}", res);
    println!("Yes");
    for i in res.iter().skip(1) {
        println!("{}", i+1);
    }
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 16080