akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};



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

	int n;
	cin >> n;
	vl a(n);
	vl b(n);
	rep(i,n){
		cin >> a[i];
		b[i] = a[i]-(i+1);
	}
	sort(all(b));
	ll ch = 0;
	if(n%2==0){ch = (b[n/2] + b[n/2-1])/2;}
	else ch = b[(n-1)/2];
	ll ans = 0;
	rep(i,n){
		ans+= abs(b[i] - ch);
	}
	cout << ans << endl;
	

	return 0;
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

vector<vector<int>> v;
vector<int> dx{1, 1, 1, 0, -1, -1, -1, 0};
vector<int> dy{-1, 0, 1, 1, 1, 0, -1, -1};

pair<int, vector<vector<int>>> put(int x, int y, int side){
    if(v[x][y] != 0)
        return make_pair(0, v);
    auto w = v;
    w[x][y] = side;
    int cnt = 0;
    for(int d = 0; d < 8; ++d){
        int px = x, py = y;
        bool fl = true;
        while(1){
            int nx = px + dx[d];
            int ny = py + dy[d];
            px = nx, py = ny;
            if(px < 0 || py < 0 || px >= 8 || py >= 8 || w[px][py] == 0){
                fl = false;
                break;
            }
            if(w[px][py] == side)
                break;
        }
        if(fl){
            while(px != x || py != y){
                if(w[px][py] != side)
                    ++cnt;
                w[px][py] = side;
                px -= dx[d];
                py -= dy[d];
            }
        }
    }
    return make_pair(cnt, w);
}

vector<vector<int>> sim(int side){
    vector<vector<int>> w(8, vector<int>(8, 0));
    for(int i = 0; i < 8; ++i)
        for(int j = 0; j < 8; ++j)
            w[i][j] = put(i, j, side).first;
    return w;
}

bool solve(){
    v.assign(8, vector<int>(8, 0));
    for(int i = 0; i < 8; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < 8; ++j){
            if(s[j] == 'o')
                v[i][j] = 1;
            if(s[j] == 'x')
                v[i][j] = 2;
            if(s[j] == '.')
                v[i][j] = 0;
        }
    }

    auto c1 = [](auto x, auto y){
        if(x.first != y.first)
            return x > y;
        return x.second < y.second;
    };
    auto c2 = [](auto x, auto y){
        if(x.first != y.first)
            return x > y;
        return x.second > y.second;
    };

    for(int i = 0; i < 100; ++i){
        auto res = sim(i % 2 + 1);
        vector<pair<int,pair<int,int>>> g;
        for(int j = 0; j < 8; ++j)
            for(int k = 0; k < 8; ++k)
                g.emplace_back(res[j][k], make_pair(j, k));
        if(i % 2 == 0)
            sort(g.begin(), g.end(), c1);
        else
            sort(g.begin(), g.end(), c2);
        if(g[0].first == 0)
            continue;
        v = put(g[0].second.first, g[0].second.second, i % 2 + 1).second;
    }
    string st = ".ox";
    for(int i = 0; i < 8; ++i){
        for(int j = 0; j < 8; ++j)
            cout << st[v[i][j]];
        cout << endl;
    }
    return true;
}

signed main(){
    solve();
    // while(solve());
}



Measured memory_bytes: 3248
N, Y = map(int,input().split())

a,b,c = 10000, 5000, 1000

for x in range(N,-1,-1):
    if a*x > Y:
        continue
    for y in range(N-x,-1,-1):
        z = N-x-y
        if a*x+b*y+c*z == Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
// ABC064_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second

int main() {
    // input
    ll N;
    cin >> N;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    sort(vec.begin(), vec.end());
    
    // calculation
    cout << vec.back() - vec.front() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a >= b && a >= c) {
            sum = b + c;
        } else if (b >= a && b >= c) {
            sum = a + c;
        } else {
            sum = a + b;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define vvi vector<vector<int> >
#define vb vector<bool>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define all(v) v.begin(),v.end()
#define input(a,b,n) for(i=b;i<n;i++){cin>>a[i];}
#define print(a) for(i=0;i<a.size();i++){cout<<a[i]<<" ";}cout<<endl;
#define trace1(a); cout<<"a="<<a<<endl;
#define trace2(a,b); cout<<"a="<<a<<" b="<<b<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int inf=0x3f3f3f3f3f3f3f3f;
int power(int a, int b){
    int res = 1;
    while(b!=0){
        if(b&1){
            res *= a; 
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
int32_t main()
{
	fast;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
    	int a,b,c,k;
      cin>>a>>b>>c>>k;
      int ans=0;
     	if(a>=k) ans=k;
      else if(a+b>=k)ans=a;
      else
      {
        ans=a+(k-a-b)*-1;
      }
      cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3652
from itertools import product


def solve():
    N = int(input())
    x, y, h = [0] * N, [0] * N, [0] * N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())

    xt, yt, ht = -1, -1, -1
    for i in range(N):
        if h[i] != 0:
            xt, yt, ht = x[i], y[i], h[i]
            break
    
    for cx, cy in product(range(101), repeat=2):
        ans_h = ht + abs(cx - xt) + abs(cy - yt)
        flg = True
        for i in range(len(x)):
            if h[i] != max(ans_h - abs(x[i] - cx) - abs(y[i] - cy), 0):
                flg = False
                break
        if flg:
            print(cx, cy, ans_h)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
ll S;
int main()
{
	cin>>S;
	ll x = 1e9;
	ll a = x, d = (S+x-1)/x;
	ll b = 1, c = a*d-S;
	cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,cnt=0;
string s;
int main()
{
	cin>>s;
	n=s.size();
	for(int i=0;i<n;++i) cnt+=s[i]-'0';
	if(cnt%9==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

string s;

int main() {
	cin >> s;
	cout << count(ALL(s), '1') << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
if n==1:
    print(4)
    print(2)
elif n==2:
    print(14)
    print(2)
    print(3)

else:
    ans=1
    for i in range(2,2+n):
        ans*=i


    print(ans-n-1)
    for i in range(n+1,1,-1):
        print(i)
    

Measured memory_bytes: 7808
#include<stdio.h>
int main(){
int a,i,j,N,ans=0;
scanf("%d",&N);

for(i=0;i<N;i++){
scanf("%d",&a);
for(j=0;a%2==0;j++){
    a=a/2;
}
ans=ans+j;
}
printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
struct mouse{
	int x;
	int y;
	int cnt;
};
int used[1000][1000]={0};
char map[1000][1000];
int maps[1000][1000]={0};
int main(){
	int h,w,n,p=1,i,j,fx,fy,k;
	int mx[4]={-1,0,1,0};
	int my[4]={0,-1,0,1};
	char num[11]="0123456789";
	queue<mouse> m;
	mouse v,u;
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>map[i][j];
			if(map[i][j]=='S'){
				v.x=j;
				v.y=i;
			}
			for(k=0;k<10;k++){
				if(num[k]==map[i][j]){
					maps[i][j]=k;
				}
			}
		}
	}
	v.cnt=0;
	m.push(v);
	while(1){
		v=m.front();
		m.pop();
		if(used[v.y][v.x]==1){
			continue;
		}
		
		else{
			used[v.y][v.x]=1;
		}
		if(maps[v.y][v.x]==p){
			if(p==n){
				break;
			}
			memset(used,0,sizeof(used));
			while(!m.empty()){
				m.pop();
			}
			p++;
			m.push(v);
			continue;
		}
		for(i=0;i<4;i++){
			if((v.x+mx[i])>=0&&(v.x+mx[i])<w&&(v.y+my[i])>=0&&(v.y+my[i])<h){
				u=v;
				u.x=v.x+mx[i];
				u.y=v.y+my[i];
				if(map[u.y][u.x]!='X'){
					u.cnt++;
					m.push(u);
				}
			}
		}
	}
	printf("%d\n",v.cnt);
	return 0;
}

Measured memory_bytes: 8168
#include <stdio.h>
int main (){
	int a,b,k,j;
	scanf ("%d",&k);
	scanf ("%d %d", &a,&b);
	for (int i=a ; i<=b ; i++)
	{
		if (i%k==0){
		j++;}
		else {
		continue;}
	}
j>0 ? printf("OK") : printf ("NG");
return 0;
}


Measured memory_bytes: 1732
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[][] comb = new long[101][101];
        for (int i = 0; i <= 100; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    comb[i][j] = 1;
                } else {
                    comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
                }
            }
        }
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        System.out.println(comb[n][2] + comb[m][2]);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long ll;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll MOD = 1e9+7;
string s;
vector< vector<ll> > dp(100100, vector<ll>(15, 0));

int main() {
    cin >> s;
    int slen = s.length();

    dp[0][0] = 1;
    for(int i = 0; i < slen; ++i) {
        int cc;
        if(s.at(i) == '?') cc = -1;
        else cc = s.at(i) - '0';

        for(int j = 0; j < 10; ++j) {
            if(cc != -1 && cc != j) continue;
            for(int k = 0; k < 13; ++k) {
                dp[i+1][(k*10+j)%13] += dp[i][k];
            }
        }
        for(int j = 0; j < 13; ++j) dp[i+1][j] %= MOD;
    }

    cout << dp[slen][5] << endl;
}

Measured memory_bytes: 17280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  vector<pair<ll, ll> > ab(n);
  rep(i, 0, n)
    cin >> ab[i].first >> ab[i].second;
  sort(all(ab));
  
  ll sum = 0;
  rep(i, 0, n) {
    sum += ab[i].second;
    if(sum >= k) {
      cout << ab[i].first << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 1792
m=1000000007
x=[[0,765144583,346175634,347662323,5655049,184117322,927321758,444014759,542573865,237315285,417297686,471090892,183023413,660103155,727008098,869418286],[539588932,729548371,700407153,404391958,962779130,184117322,927321758,444014759,542573865,237315285,417297686,471090892,183023413,660103155,727008098,869418286]]
for _ in range(int(input())):
	n=int(input())
	print(sum([pow(n,j,m)*x[n&1][j]%m for j in range(16)])%m)

Measured memory_bytes: 65716
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<string>
#include<math.h>
using namespace std;

int main()
{
	int a, b;
	int x, y;
	cin >> x >> y;
	a = max(x, y);
	b = min(x, y);
	while (b)
	{
		int k = b;
		b = a%b;
		a = k;
	}
	cout << a << endl;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int tst_count;

void inserSort(int A[], int n, int g){
    if (g > n) return;
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            tst_count++;
        }
        A[j + g] = v;
    }
}

void shell(int A[],int n){
    tst_count = 0;
    int m = 7;
    int G[7] = {1,4,13,40,121,364,1093};
    
    while (G[m-1] > n) {
        m--;
    }

    for (int i = m-1; i >= 0; i--) {
        inserSort(A,n,G[i]);
    }
    
    cout << m << endl << G[m-1];
    for (int i = m-2; i >= 0; i--) {
        cout << " " << G[i];
    }
    cout << endl << tst_count << endl;
}

int main(){
    int n;
    int A[1000001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    shell(A,n);
    
    for (int i = 0; i < n; i++) {
        printf("%d\n",A[i]);
    }
    
    return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> is(3);
  int k;
  cin>>is.at(0)>>is.at(1)>>is.at(2)>>k;
  int max_i=0;
  for(int i=0;i<3;i++){max_i=max(is.at(i),max_i);}
  cout<<is.at(0)+is.at(1)+is.at(2)-max_i+max_i*pow(2, k)<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const int N = 500;
class st{
public:
  int n,hit;    
  int rc[N],cc[N];//rowÆcolÅµÁÄ¢ézÌB
  int n1,n2;//Îßn1 i==j,n2 i+j == n-1
  map<int,pair<int,int> > M;
  st(){}
  st(int tn,int thit):n(tn),hit(thit),n1(tn),n2(tn){
    M.clear();
    rep(i,n){
      rc[i] = n;
      cc[i] = n;
    }
  }
  void set(){
    rep(i,n){
      rep(j,n){
	int tmp;cin>>tmp;M[tmp] = make_pair(i,j);
      }
    }
  }
  bool isend(int val){//hitsÈãÌf[^ªµÁ½©ð»è·éB
    if (M.count(val) == 0)return false;
    int y = M[val].first,x = M[val].second;
    rc[y]--;
    cc[x]--;
    if (y == x)n1--;
    if (y+x == n-1)n2--;


    if (rc[y] == 0)hit--;
    if (n != 1){//n !=1 ÌÈOÌ
      if (cc[x] == 0)hit--;//esÉÂ¢Ä²×é
      if (n1 == 0)hit--,n1--;//Îßð²×é
      if (n2 == 0)hit--,n2--;//Îßð²×é
    }
    
    return hit <= 0;
  }
  void debug(){
    cout <<"debug----------------------------" << endl;
    cout <<"hit " << hit << endl;
    cout <<"n1 " << n1 << endl;
    cout <<"n2 " << n2 << endl;
    rep(i,n)cout <<" " << cc[i];cout << endl;
    rep(i,n){
      cout << rc[i] << endl;
    }
    cout << endl;
  }

};


main(){
  int n,u,v,m;
  while(cin>>n>>u>>v>>m && n){
    st usagi(n,u),neko(n,v);
    usagi.set();
    neko.set();
    vector<int> in(m);
    rep(i,m){cin>>in[i];}
    rep(i,m){
      bool ur = usagi.isend(in[i]),nr = neko.isend(in[i]);
      //usagi.debug();
      //neko.debug();
      if (ur && nr){
	cout <<"DRAW"<<endl;
	goto end;
      }else if (ur){
	cout <<"USAGI" << endl;
	goto end;
      }else if (nr){
	cout <<"NEKO"<<endl;
	goto end;
      }
    }
    //cout <<"hogehoge" << endl;
    cout <<"DRAW"<<endl;
  end:;
  }
}

Measured memory_bytes: 0
X,N=map(int,input().split())
P=list(map(int,input().split()))
setP=set(P)
ANS=[]
for i in range(102):
  if i not in setP:
    ANS+=[i]
d=100
for i in ANS:
  if abs(X-i)<d:
    ans=i
    d=abs(X-i)
print(ans)    

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

using std::ios_base;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::fixed;

using std::vector;
using std::string;
using std::stack;
using std::queue;
using std::deque;
using std::map;
using std::set;
using std::unordered_map;
using std::unordered_set;

using std::tuple;
using std::make_tuple;
using std::pair;
using std::make_pair;

using std::sort;
using std::reverse;
using std::nth_element;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int MAXN = 100000;
const int INF = 1e9;
const int MOD = 1e9+7;
const int64_t L_INF = 4e18;

int n, d, x;
int a[MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    cin >> n >> d >> x;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int64_t ans = 0;
    for (int i = 0; i < n; i++) {
        ans += (d + a[i] - 1) / a[i];
    }
    ans += x;
    cout << ans << '\n';

    #ifdef LOCAL
        cerr << "\n== " << 1.0 * clock() / CLOCKS_PER_SEC << " sec.\n";
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

vector<int> enum_div(int n) {
    vector<int> result;
    for (int i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if (i*i != n) {
                result.push_back(n/i);
            }
        }
    }
    return result;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    auto a = enum_div(m);
    sort(a.rbegin(), a.rend());
    int ans;
    rep(i, a.size()) {
        if (m / a[i] >= n) {
            ans = a[i];
            break;
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(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 q = sc.nextInt();

            int buf;
			for(int i=0;i<q;i++) {
				int b = sc.nextInt();
				int e = sc.nextInt();
				int t = sc.nextInt();
				for(int k=0;k<(e-b);k++) {
					buf = A[b+k];
					A[b+k] = A[t+k];
					A[t+k] = buf;
				}
			}
			System.out.print(A[0]);
			for(int i=1;i<A.length;i++) {
				System.out.print(" " + A[i]);
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 36244
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;

const int inf = 1e9;
const int N = 200005;
int pr[2][N][25], su[2][N][25], p[N], id[N], n, lg[N];

void pre_st () {
	for (int i = 1; i <= n; ++ i)
		for (int jo = 0; jo < 2; ++ jo)
			pr[jo][i][0] = su[jo][i][0] = inf;
	for (int i = 1; i <= n; ++ i)
		pr[i&1][i][0] = su[i&1][i][0] = p[i];
	
	for (int j = 1; (1<<j)<=n; ++ j)
		for (int i = 1; i <= n; ++ i)
			for (int jo = 0; jo < 2; ++ jo) {
				if (i-(1<<j)>=0) pr[jo][i][j] = min (pr[jo][i][j-1], pr[jo][i-(1<<(j-1))][j-1]);
				if (i+(1<<j)<=n+1) su[jo][i][j] = min (su[jo][i][j-1], su[jo][i+(1<<(j-1))][j-1]);
			}
	
	for (int i = 2; i <= n; i <<= 1) ++lg[i];
	for (int i = 1; i <= n; ++ i) lg[i] += lg[i-1];
}

int rmq (int l, int r, bool jo) {
	//cout << min (pr[jo][r][lg[r-l+1]], su[jo][l][lg[r-l+1]]) << endl;
	return id[min (pr[jo][r][lg[r-l+1]], su[jo][l][lg[r-l+1]])];
}

struct nd {int l, r, u, v;};
bool operator < (nd a, nd b) {return p[a.u]>p[b.u];}
priority_queue <nd> q;

int main () {
	int l, r, u, v, u1, v1, u2, v2, u3, v3;
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		scanf ("%d", &p[i]); id[p[i]] = i;
	}
	
	pre_st ();
	
	u = rmq (1, n, 1); v = rmq (u+1, n, 0);
	//cout << u << " " << v << endl; 
	q.push((nd){1, n, u, v});
	//return 0;
	
	while (!q.empty()) {
		nd x = q.top(); l = x.l; r = x.r; u = x.u; v = x.v;
		printf ("%d %d ", p[u], p[v]); q.pop();
		
		if (l!=u) {
			u1 = rmq (l, u-1, l&1); v1 = rmq (u1+1, u-1, l&1^1);
			q.push((nd){l, u-1, u1, v1});
		}
		
		if (u+1!=v) {
			u2 = rmq (u+1, v-1, u&1^1); v2 = rmq (u2+1, v-1, u&1);
			q.push((nd){u+1, v-1, u2, v2});
		}
		
		if (r!=v) {
			u3 = rmq (v+1, r, v&1^1); v3 = rmq (u3+1, r, v&1);
			q.push((nd){v+1, r, u3, v3});
		}
	}
	
	puts ("");
	return 0;
}


Measured memory_bytes: 82676
"""
0-1ナップザック
wi...i個目の重さ
vi...i個目の価値

2次元

dp[i][j]...i個目までの宝で重さjの時の価値の最大
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi)  (wi <= j)
dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])                          (wi >  j)


1次元

dp[j]...重さjの時の価値の最大
dp[j] = max(dp[j], dp[j - wi] + vi)  (wi <= j <= w)

wi <= j <= wについて更新(j < wiについては変化が無いため更新不要)
前から更新すると更新した結果を使って更新してしまうため後ろから更新
"""

INF = 10 ** 20

def main():
  case = 0

  while True:
    w = int(input())
    if not w:
      break
  
    case += 1
  
    n = int(input())
  
    dp = [0 for _ in range(w + 1)]
    
    for i in range(1, n + 1):
      vi, wi = map(int, input().split(","))
      for j in range(w, wi - 1, -1):
        dp[j] = max(dp[j], dp[j - wi] + vi)
  
    print("Case " + str(case) + ":")
    print(dp[w])
    print(dp.index(dp[w]))
main()



Measured memory_bytes: 5644
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(), (a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> jodan(n);
    vector<int> gedan(n);
    rep(i,n) cin >> jodan[i];
    rep(i,n) cin >> gedan[i];

    int ans = 0;

    rep(i, n)
    {
        int tmp = 0;
        for (int j = 0; j <= i; j++)
        {
            tmp += jodan[j];
        }
        for (int k = i; k <= n - 1; k++)
        {
            tmp += gedan[k];
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, A; cin >> X >> A;
  if(X < A){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

	int n;
	cin>>n;
	ll f[n+1]={};
	
	for(int i=2;i<n+1;i++){
		for(int j=i;j<n+1;j+=i){
			f[j]++;
		}
	}

	ll ans=0;
	for(ll i=1;i<=n;i++)ans=ans+i*(f[i]+1);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 81740
#include<iostream>
using namespace std;
string s[8]={"AAA","AA","A","B","C","D","E","NA"};
double a[8]={35.5 , 37.5 , 40.0 , 43.0, 50.0, 55.0, 70.0,9999999.9999999};
double b[8]={71.0 , 77.0 , 83.0 , 89.0,105.0,116.0,148.0,9999999.9999999};
double q,w;
int main(){
  while(cin>>q>>w){
    for(int i=0;i<8;i++){
      if(q<a[i]&&w<b[i]){
	cout<<s[i]<<endl;
	break;
}}}}

Measured memory_bytes: 3208
n, m = map(int, input().split())
X = []
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    X.append((b,a))
X.sort()

pre_b = -1
ans = 0
for i in range(m):
    b, a = X[i]
    if a >= pre_b:
        ans += 1
        pre_b = b
print(ans)


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> A,B;

int main()
{
	scanf("%d",&N);
	A.assign(N,0);
	B.assign(N,0);
	FOR(i,0,N){
		scanf("%d",&A [i]);
	}
	FOR(i,0,N){
		scanf("%d",&B [i]);
	}

	vector<int> accA(N + 1),accB(N + 1);
	FOR(i,0,N){
		accA [i + 1] = accA [i] + A [i];
		accB [i + 1] = accB [i] + B [i];
	}

	int ans = 0;
	FOR(i,1,N + 1){
		chmax(ans,accA [i] + accB [N] - accB [i - 1]);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
b = ["", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"]
buf = [0,0]
n.times do
    s = gets.chomp
    s.each_char do |c|
        if c == "0"
            print b[buf[0]][(buf[1] - 1) % b[buf[0]].size] if buf[0] != 0
            buf = [0,0]
            next
        end
        buf[0] = c.to_i
        buf[1] += 1
    end
    puts
end

Measured memory_bytes: 6116
#include <iostream>

using namespace std;

int main(){
  char S[10], T[10];
  int sum = 0;
  
  cin >> S >> T;
  
  if (S[0] == T[0]) sum += 1;
  if(S[1] == T[1]) sum += 1;
  if(S[2] == T[2]) sum += 1;
    
  cout << sum << endl;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll h,n,tong=0;
int main()
{
    cin >> h >> n;
    for(ll i = 1;i <= n;i ++)
    {
        ll u;
        cin>>u;
        tong+=u;
    }
    tong >= h ? cout << "Yes" : cout << "No" ;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 2345;
int a[MAXN];

int solve(int N, int cur, int K, int Q) {
    vector<int> ans, tmp;
    for (int l = 1; l <= N + 1; l++) {
        if (l == N + 1 || a[l] < cur) {
           sort(tmp.begin(), tmp.end());
           for (int i = 0; i < (int)tmp.size() - K + 1; i++)
               ans.push_back(tmp[i]);
           tmp.clear();
        } else tmp.push_back(a[l]);
    }
    sort(ans.begin(), ans.end());
    if ((int)ans.size() < Q) return (int)2e9;
    return ans[Q - 1] - cur;
}

int main() {
    int N, K, Q;
    // freopen("in.txt", "r", stdin);
    while (~scanf("%d %d %d", &N, &K, &Q)) {
          for (int i = 1; i <= N; i++) {
              scanf("%d", &a[i]);
          }
          int ans = (int)2e9;
          for (int i = 1; i <= N; i++) {
              ans = min(ans, solve(N, a[i], K, Q));
          }
          printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
import Data.List.Split
import Data.List

main = do
    a <- getContents
    let aa = splitOn " " $ head $ splitOn "\n" a
    let bb = read $ head aa :: Int
    let cc = read $ last aa :: Int
    --print bb
    --print cc
    let ans = if bb - cc <= 0 then 0 else bb - cc
    putStr $ show ans



Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L= sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();
		int count = 0;
		for (int i=L;i<=R;i++) {
			if (i%d==0) {
				count ++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    string ans = "";
    if(n == 0) ans += "0";
    while(n != 0){
        if(n % 2){
            ans += "1";
            n--;
        }
        else ans += "0";
        n /= -2;
    }
    reverse(ans.begin(), ans.end());
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    N = int(input())
    S = list(map(int, input().split()))
    S.extend([-1, float('inf')])
    S.sort()
    # print(S)
    Q = int(input())
    T = list(map(int, input().split()))
    T.sort()
    ans = 0
    for ti in T:
        # S[x]
        ok = 0
        ng = len(S)
        while ng - ok > 1:
            mid = (ng+ok)//2
            if S[mid]<=ti: ok=mid
            else:          ng=mid
        if S[ok]==ti:
            ans += 1

    print(ans)



Measured memory_bytes: 16716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t=1;
   // cin>>t;
   while(t--){
	   string s;
      cin>>s;
      int ans=0;
      for(int i=0;i<s.length();i++){
         int len=0;
          if(s[i]=='R') len=1;
          while(s[i]=='R' && (i<s.length()-1 && s[i]==s[i+1])){
             len++;
             i++;
          }
          ans=max(ans,len);
      }
      cout<<ans;
}
   return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  int q;
  while(cin>>q,q){
    using D = deque<int>;
    auto mv=
      [&](D &a,D &b,D &ax,D &ay,D &bx,D &by){
	if(!bx.empty()&&bx.back()==b.back()) bx.pop_back();
	if(!by.empty()&&by.back()==b.back()) by.pop_back();	  
	
	a.emplace_back(b.back());
	b.pop_back();
	
	if(ax.empty()||ax.back()>a.back()) ax.emplace_back(a.back());
	if(ay.empty()||ay.back()<a.back()) ay.emplace_back(a.back());
      };

    D a,b;
    D ax,ay,bx,by;
    
    while(q--){
      int t,x=-1;
      cin>>t;
      if(t==0||t==4||t==5||t==8||t==9) cin>>x;     

      if(t==0){	
	while(!bx.empty()&&bx.front()>x) bx.pop_front();
	while(!by.empty()&&by.front()<x) by.pop_front();
	b.emplace_front(x);
	bx.emplace_front(x);
	by.emplace_front(x);
      }
      
      if(t==1){
	if(!ax.empty()&&ax.back()==a.back()) ax.pop_back();
	if(!ay.empty()&&ay.back()==a.back()) ay.pop_back();
	cout<<a.back()<<endl;
	a.pop_back();
      }

      if(t==2) cout<<ax.back()<<endl;
      if(t==3) cout<<bx.back()<<endl;

      if(t==4) cout<<ax[ax.size()-x]<<endl;
      if(t==5) cout<<bx[bx.size()-x]<<endl;
            
      if(t==6) cout<<ay.back()<<endl;
      if(t==7) cout<<by.back()<<endl;
      
      if(t==8) cout<<ay[ay.size()-x]<<endl;
      if(t==9) cout<<by[by.size()-x]<<endl;
      
      while(a.size()<b.size())   mv(a,b,ax,ay,bx,by);
      while(a.size()>b.size()+1) mv(b,a,bx,by,ax,ay);

    }
    cout<<"end"<<endl;
  }
  return 0;
}



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

int main(){
	int n, m, x, res = 0;
  	cin >> n >> m >> x;
  	char a[n][m];
  	for(int i = 0; i < n; ++i)
      for(int j = 0; j < m; ++j)
        cin >> a[i][j];
  	for(int mask = 0; mask < (1<<(n + m)); ++mask){
      int count = 0;
    	for(int i = 0; i < n; ++i){
          for(int j = 0; j < m; ++j){
         	if(a[i][j] != '#')
               continue;
            else if((mask&((1<<i) | (1<<(n + j)))) != 0)
               continue;
           	count++;
				
          }
        }
        if(count == x)
               res++;
    }
    cout << res << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(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 inf 2,147,483,647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int n,m;cin>>n>>m;
    ll ans=1;
    if(abs(n-m)<=1){
        if(n==m){
            rep(i,n){
                ans*=(i+1);
                ans%=MOD;
            }
            rep(i,m){
                ans*=(i+1);
                ans%=MOD;
            }
            ans*=2;
            ans%=MOD;
            cout<<ans<<endl;
        }else{
            rep(i,n){
                ans*=(i+1);
                ans%=MOD;
            }
            rep(i,m){
                ans*=(i+1);
                ans%=MOD;
            }
            cout<<ans<<endl;
        }
    }else{
        cout<<0<<endl;
    }
    return 0;
}


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

int main() {
#ifdef LOCAL_DEFINE
  // freopen("data.in", "rt", stdin);
  // freopen("data.out", "w", stdout);
  auto _start = chrono::high_resolution_clock::now();
#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	int V = *max_element(v.begin(), v.end()) * n;
	const int inf = 2e9;
	vector<long long> dp(V + 1, inf);
	dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = V; j >= v[i]; j--) {
			dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}
	int ans = 0;
	for(int i = 0; i <= V; i++) {
		if(dp[i] <= W) {
			ans = i;
		}
	}
	cout << ans << '\n';

#ifdef LOCAL_DEFINE
  auto _end = chrono::high_resolution_clock::now();
  cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

Measured memory_bytes: 1024
n, y = map(int, input().split())

all1000s = y // 1000
x = all1000s - n

for a in range(0, x+1, 4):
    nines = (x - a) // 9
    fours = a // 4
    ones = n - nines - fours
    if (x - a) % 9 == 0 and all(x >= 0 for x in (nines, fours, ones)):
        print("{} {} {}".format(nines, fours, ones))
        break
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A;

    map<int, int> mp;

    for(int i=0; i<M; i++) {
        int a, b;
        cin >> a >> b;
        if(a == 1 && b != N) mp[b]++;
        if(b == N && a != 1) mp[a]++;
    }
    string ans = "IMPOSSIBLE";
    for (auto p : mp) {
        if (p.second >= 2) ans = "POSSIBLE";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12876
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int D = 0, result = 0, N = 0, k = 0, t = 0;
    cin >> D >> N;

    result = pow(100, D); // 1

    while (k != N)
    {
        t += 1;
        if (t % 100 != 0)
            k += 1;
    }

    cout << t * result << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "string"
using namespace std;

int main()
{
	int A, B, C, D,x,y,z;
	cin >> A >> B >> C >> D;
	if (A <= C)
	{
		x = C;
	}
	else
	{
		x = A;
	}
	if (B < D)
	{
		y = B;
	}
	else
	{
		y = D;
	}
	z = y - x;
	if (z <=0)
	{
		cout << 0<<endl;
	}
	else
	{
		cout << z<<endl;
	}

	
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


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


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

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c=c-b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a=a-d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    
    


    return 0;
}



Measured memory_bytes: 3640
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
tempx = max(x)
tempy = min(y)
judge = False
for i in range(X+1,Y+1):
    if tempx < i <= tempy:
        judge = True
if judge:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
template<class E>
using Graph = vector<vector<E>>;

vector<bool> used;
Graph<int> gv;
vector<P> ge;

int dfs(int u, int d, int K) {
  int res = (d > K / 2);
  for (auto&& v : gv[u]) {
    if (used[v]) continue;
    used[v] = true;
    res += dfs(v, d + 1, K);
  }
  return res;
}


int main() {
  int N, K; cin >> N >> K;
  gv.resize(N);
  for (int i = 0; i < N - 1; ++i) {
    int A, B; cin >> A >> B;
    --A; --B;
    gv[A].push_back(B);
    gv[B].push_back(A);
    ge.push_back({A, B});
  }
  int ans = N;
  for (int i = 0; i < N; ++i) {
    used.assign(N, false);
    if (K % 2) {
      used[ge[i].first] = used[ge[i].second] = true;
      ans = min(ans, dfs(ge[i].first, 0, K - 1) + dfs(ge[i].second, 0, K - 1));
    } else {
      used[i] = true;
      ans = min(ans, dfs(i, 0, K));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int k=0,u=0,p=0,c=0;
	int ans[4];
	string str;
	cin>>str;
	for(int i=0;i<str.size();i++){
		if(str[i]=='K')k++;
		else if(str[i]=='U')u++;
		else if(str[i]=='P')p++;
		else if(str[i]=='C')c++;
	}
	cout<<min(min(k,u),min(p,c))<<endl;
}

Measured memory_bytes: 1188
from calendar import isleap
f = lambda x: map(str, x) if x else ["NA"]
ans = []
while True:
    a, b = map(int, raw_input().split())
    if b == 0:
        break
    ans += f(filter(isleap, xrange(a, b+1))) + [""]
print "\n".join(ans).strip()

Measured memory_bytes: 5060
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=13;
int n,m,lim,c[MN],a[MN][MN];
int tot[MN],res,Ans=2e9;
void dfs(int st){
	if(st==n+1){
		reg int flg=1;
		for(reg int i=1;flg&&i<=m;i++)
			if(tot[i]<lim)flg=0;
		if(flg)Ans=min(Ans,res);
		return;
	}
	for(reg int i=1;i<=m;i++)tot[i]+=a[st][i];
	res+=c[st];dfs(st+1);
	for(reg int i=1;i<=m;i++)tot[i]-=a[st][i];
	res-=c[st];dfs(st+1);
}
int main(){
	scanf("%d%d%d",&n,&m,&lim);
	for(reg int i=1;i<=n;i++){
		scanf("%d",c+i);
		for(reg int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	}
	dfs(1);
	if(Ans==2e9)puts("-1");
	else printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 3828
n,m,l=map(int,input().split())
g=[[999999999999 if i!=j else 0 for j in range(n)] for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    a,b=a-1,b-1
    if c>l:
        continue
    g[a][b]=c
    g[b][a]=c

for k in range(n):
    for i in range(n):
        for j in range(n):
            if g[i][j]>g[i][k]+g[k][j]:
                g[i][j] = g[i][k]+g[k][j]

for i in range(n):
    for j in range(n):
        if g[i][j]<=l:
            g[i][j]=1

for k in range(n):
    for i in range(n):
        for j in range(n):
            if g[i][j]>g[i][k]+g[k][j]:
                g[i][j] = g[i][k]+g[k][j]

for i in range(int(input())):
    s,t=map(int,input().split())
    s-=1
    t-=1
    print(g[s][t]-1 if g[s][t]-1<99999999999 else -1)



Measured memory_bytes: 58456
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok=false;
  if(s.at(0)=='7'){
    ok=true;
  }
  if(s.at(1)=='7'){
    ok=true;
  }
  if(s.at(2)=='7'){
    ok=true;
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int N, A[110];
int x, y;

int main() {
	rd(N);
	repi(i, 0, N) rd(A[i]);
	sort(A, A + N);
	reverse(A, A + N);
	repi(i, 0, N) {
		if (i % 2 == 0) x += A[i];
		else y += A[i];
	}

	wrln(x - y);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <vector>
#include <cstring>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <map>
#include <stack>
#include <cmath>
#define LL long long 
using namespace std; 
 
long long c[100005];

vector <int > v[100005];
int n,m,N;
int anss[100005];

void dfs(int pre,int x)
{
//	cout<<x<<" "<<v[x].size()<<endl;
	anss[x]=c[N--];
	for(int i=0;i<v[x].size();i++)
	{
		if(pre==v[x][i])
			continue;
		dfs(x,v[x][i]);
	}
}

struct Node
{
	int a,b;
}node[100005];

bool cmp(Node x,Node y)
{
	if(x.a==y.a)
		return x.b<y.b;
	return x.a<y.a;
}

int main()
{

	LL ans=0,maxn=0;
	scanf("%d",&n);
	m=n-1;
	int a,b;
	for(int i=1;i<=m;i++)
		scanf("%d%d",&node[i].a,&node[i].b);
	sort(node+1,node+n,cmp);
	for(int i=1;i<=m;i++)	
	{
		v[node[i].a].push_back(node[i].b);
		v[node[i].b].push_back(node[i].a);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&c[i]);
		maxn=max(c[i],maxn);
		ans+=c[i];
	}
	sort(c+1,c+n+1);
	N=n;
//	for(int i=1;i<=n;i++)
//		cout<<c[i]<<" ";
//	cout<<endl;
	ans-=maxn;
	cout<<ans<<endl;
	dfs(1,1);
	for(int i=1;i<=n;i++)
		cout<<anss[i]<<" ";
}

Measured memory_bytes: 4096
#include<iostream>

int main(){
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  if ((x - r) < 0 || (x + r) > w || (y - r) < 0 || (y + r) > h){
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  } 
  
  return 0;
}

Measured memory_bytes: 3088
arr = input().split()
arr = list(map(str,arr))
a = arr[0]
b = arr[1]
if a == 'H' and b == 'H':
    print('H')
elif a == 'D' and b == 'H':
    print('D')
elif a == 'D' and b == 'D':
    print('H')
elif a == 'H' and b == 'D':
    print('D')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n;
  cin >> n;
  int score[100001] = {};
  int ans = 0;
  LOOP(i,n){
    int a;
    cin >> a;
    score[a]++;
    ans += a;
  }
  int q;
  cin >> q;

  LOOP(i,q){
    int b,c;
    cin >> b >> c;
    score[c] += score[b];
    ans -= score[b] * b;
    ans += score[b] * c;
    score[b] = 0;
    cout << ans << endl;
  }
}


Measured memory_bytes: 4368
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    for(int i=0; i<n; i++) {
        cin >> x[i];
        y[i] = x[i];
    }

    sort(y, y+n);

    int l = y[n/2-1], r = y[n/2];

    if(l==r) {
        for(int i=0; i<n; i++) cout << l << endl;
        return 0;
    }

    for(int i=0; i<n; i++) {
        if(x[i]<=l) cout << r << endl;
        else if(x[i]>=r) cout << l << endl;
    }

    return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,c,x,a,b;
bool res=true,flg;
int main(){
  for(cin>>n;i<n;i++){
    cin>>a;
    while(a%2==0)a/=2,c++;
  }
  cout<<c;
}

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a + b) < (c + d)) {
    cout << "Right" << endl;
  } else if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  } else {
    cout << "Balanced" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
using namespace std;
typedef long long int lli;
int main(void)
{
    int s, w;
    cin >> s >> w;
    if (s <= w)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
int main(){
    int n,x,i,s;
    while(1){
        char str[200] = {};
        scanf("%s",str);
        if(!strcmp(str,"-")) break;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            char str1[200] = {},str2[200] = {};
            scanf("%d",&x);
            strncpy(str1,str,x);
            str1[x] = '\0';
            strncpy(str2,str+x,strlen(str));
            str2[strlen(str)] = '\0';
            sprintf(str,"%s%s",str2,str1);
        }
        printf("%s\n",str);
        
    }
}


Measured memory_bytes: 2120