akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<PII, int> PPI;
typedef pair<int, PII> PIP;

const int INF = 3e18;
const int MOD = 1000000007;
int n, a[100010];
int na, nb, nc;

int soujou[100010];
int soujou_r[100010];

bool check[100010];
int d, i;

int cb(int n, int k)
{
  return soujou[n] * soujou_r[k] % MOD * soujou_r[n - k] % MOD;
}

int gyakugen(int k){
  int ans = 1;
  int m = MOD - 2;
  while(m){
    if(m & 1){
      ans *= k;
      ans %= MOD;
    }
    k *= k;
    k %= MOD;
    m >>= 1;
  }
  return ans;
}

signed main()
{
  cin >> n;
  
  for(i = 0; i < n + 1; i++){
    cin >> a[i];
    if(check[a[i]]){
      d = a[i];
    }
    check[a[i]] = true;
  }

  for(i = 0; i < n + 1; i++){
    if(a[i] == d){
      na = i;
      break;
    }
  }
  for(i = i + 1; i < n + 1; i++){
    if(a[i] == d){
      nb = i - na - 1;
      break;
    }
  }
  nc = n - i;

  soujou[0] = soujou_r[0]= 1;
  for(i = 1; i <= n + 1; i++){
    soujou[i] = soujou[i - 1] * i % MOD;
    soujou_r[i] = soujou_r[i - 1] * gyakugen(i) % MOD;
  }

  
  for(i = 1; i <= n + 1; i++){
    int ans = MOD + cb(n + 1, i);
    if(na + nc >= i - 1){
      ans -= cb(na + nc, i - 1);
    }
    ans %= MOD;
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3712
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],

    }
    let mut map = vec![0; 9];
    for i in 0..n {
        if a[i] >= 3200 {
            map[8] += 1;
            continue;
        }
        map[(a[i] / 400)] += 1;
    }
    let mut max = 0;
    let mut min = 0;
    for k in 0..8 {
        if map[k] > 0 {
            max += 1;
            min += 1;
        }
    }
    if map[8] > 0 {
        max += map[8];
        if min == 0 {
            min = 1;
        }
    }
    println!("{} {}", min, max);
}


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

int main(){
	int a,b,c;cin>>a>>b>>c;
	int A=a+b;
	int B=a-b;
	int C=a*b;
	int ans=max(A,B);
	ans=max(ans,C);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
def calc_orthogonal_vect(x1: int, y1: int, x2: int, y2: int)->tuple:
    if x1 == x2:
        return x2 - (y2 - y1), y2

    return x2 - (y2 - y1), y2 + (x2 - x1)


def ruined_square(x1: int, y1: int, x2: int, y2: int)->tuple:
    x3, y3 = calc_orthogonal_vect(x1, y1, x2, y2)
    x4, y4 = calc_orthogonal_vect(x2, y2, x3, y3)

    return x3, y3, x4, y4


if __name__ == "__main__":
    x1, y1, x2, y2 = map(int, input().split())
    x3, y3, x4, y4 = ruined_square(x1, y1, x2, y2)
    print(x3, y3, x4, y4)


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

int main() {
  int a;
  a = 0;
  long N, ans;
  cin >> N;
  vector<long> res;
  res.push_back(1);
  for(long i = 1; i*i <= N; ++i) {
    if(N % i != 0) continue;
    res.push_back(i);
    ++a;
    if(N/i == i) continue; // 上の行で追加済み。
    res.push_back(N/i);
    ++a;
  }
  sort(res.begin(), res.end());
  ans = 0;
  if (a % 2 == 0) {
    a = a / 2;
    ans = res[a] + res[a + 1] - 2;
  } else {
    a = a / 2;
    ans = 2 * res[a+1] - 2;
  }
  cout << ans <<endl;
  return 0;
}

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


int main(){
	int k,s; 
	cin>>k>>s;  int count=0; 
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(s-(i+j)<=k && s-(i+j)>=0) count++; 
		}
	}

	cout<<count<<endl;
	return 0; 
}

Measured memory_bytes: 256
N,K= map(int,input().split())
import math
import itertools

f = 1

if len(list(itertools.combinations(range(1,N),2))) < K:
    f = 0

if f == 0:
    print(-1)

if f!=0:
    ans_list = []
    kumi = list(itertools.combinations(range(2,N+1), 2))
    kumilen = len(kumi)
    # ans_list.append(kumi)
    for i in range(2,N+1):
        ans_list.append((1,i))
    for i in range(0,kumilen-K):
        ans_list.append(kumi[i])
    
    print(len(ans_list))
    for i in range(len(ans_list)):
        print(ans_list[i][0],ans_list[i][1])

Measured memory_bytes: 4084
n = int(input())
py = []
start = 0
for i in range(n):
    x,y,h = map(int, input().split())
    if start < h:
        start = h
    py.append((x,y,h))

height = lambda x,y,cx,cy,hh:max(hh -abs(x-cx) -abs(y-cy), 0)
while True:
    for i in range(101):
        for j in range(101):
            for a,b,h in py:
                if height(a,b,i,j,start) != h:
                    # no
                    break
            else:
                # ok
                print(i,j,start)
                exit()
    start += 1


Measured memory_bytes: 49520
def move(Tiles_map, x, y, Loop_ch):
    if [x,y] in Loop_ch:
        print("LOOP")
        return
    else:
        Loop_ch.append([x,y])

    if Tile_map[x][y] == ".":
        print(str(y) + " " + str(x))
        return
    elif Tile_map[x][y] == ">":
        move(Tiles_map, x, y+1, Loop_ch)
    elif Tile_map[x][y] == "<":
        move(Tiles_map, x, y-1, Loop_ch)
    elif Tile_map[x][y] == "v":
        move(Tiles_map, x+1, y, Loop_ch)
    elif Tile_map[x][y] == "^":
        move(Tiles_map, x-1, y, Loop_ch)

        
        
while True:
    Tile_map = []
    Loop_ch = []
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        Tiles = input()
        Tiles = list(str(Tiles))
        Tile_map.append(Tiles)
    ans = move(Tile_map,0,0,Loop_ch)




Measured memory_bytes: 6112
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();
	static Node[] V;
	static ArrayDeque<Integer> que = new ArrayDeque<>();

	public static void main(String[] args) {
		int n = sc.nextInt();	
		
		V = new Node[n];
		for(int i=0; i<n; i++) {
			sc.nextInt();
			int k = sc.nextInt();
			int[] adj = new int[k];
			for(int j=0; j<k; j++) {
				adj[j] = sc.nextInt() - 1;
			}
			V[i] = new Node(adj);
		}
	
		V[0].d = 0;
		V[0].breadthFirstSearch();
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<n; i++) {
			ans.append(i+1);
			ans.append(" ");
			ans.append(V[i].d);
			ans.append("\n");
		}
		System.out.print(ans);
	}

	static class Node {	
		int d = -1;
		int[] adj;
		
		Node(int[] adj) {
			this.adj = adj;
		}
		
		public void breadthFirstSearch() {
			
			for(int i=0; i<adj.length; i++) {
				if(V[adj[i]].d == -1) {
					que.add(adj[i]);
					V[adj[i]].d = d + 1;	
				}
			}
			
			if(!que.isEmpty()) {
				V[que.poll()].breadthFirstSearch();
			}
		}
	}

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

Measured memory_bytes: 24356
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#include <tuple>
#define ll long long int
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define rel(i,x,y) for(ll i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;
int main(){
	int n;
	cin >> n;
	vector<tuple<ll,ll,ll>> p;
	rep(i,0,n){
		ll a,b,c;
		cin >> a >> b >> c;
		p.push_back(make_tuple(a,b,c));
	}
	ll H;
	rep(j,0,101){
		rep(k,0,101){
			bool ok = true;
			rep(i,0,n){
				if(get<2>(p[i])>0){
					H = get<2>(p[i]) + abs(j-get<1>(p[i])) + abs(k-get<0>(p[i]));
					break;
				}
			}
			rep(i,0,n){
				if(get<2>(p[i]) != max((ll)0,H-abs(j-get<1>(p[i]))-abs(k-get<0>(p[i])))){
					ok = false;
					break;
				}
			}
			if(ok){
				cout << k << " " << j << " " << H << endl;
					return 0;
			}
		}
	}
}


Measured memory_bytes: 256
import Data.Bool
main=putStrLn.f.reverse=<<getLine
f('r':'e':'m':'a':'e':'r':'d':s)=f s
f('m':'a':'e':'r':'d':s)=f s
f('r':'e':'s':'a':'r':'e':s)=f s
f('e':'s':'a':'r':'e':s)=f s
f s=bool"NO""YES"$null s

Measured memory_bytes: 10768
N,K = map(int,input().split())
V = list(map(int,input().split()))

ans = 0
sz = min(N,K)
for a in range(1+sz):
	for b in range(1+sz-a):
		#print('{} {}'.format(V[:a],V[N-b:]))
		taken = V[:a]+V[N-b:]
		taken.sort()
		for c in range(1+min(K-a-b,a+b)):
			score = sum(taken[c:])
			#print('   ({}) {}'.format(score,taken[c:]))
			ans = max(ans,score)
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (3200 <= a) {
        cout << s << endl;

    } else {
        cout << "red\n";
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
mike=int(input())
boid=[int(i) for i in input().split()]

boid2=defaultdict(int)
for i in range(len(boid)):
    boid2[i+1]=boid[i]
    
#print(boid2)
ans = sorted(boid2.items(), key=lambda x: x[1])

for i in range(len(boid2)):
    print(ans[i][0],end=" ")
    

Measured memory_bytes: 26580
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 100000
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  ll m=0, a=0, r=0, c=0, h=0;
  ll ans = 0;
  string s;
  ll w[5];
  int x[10] = {0,0,0,0,0,0,1,1,1,2};
  int y[10] = {1,1,1,2,2,3,2,2,3,3};
  int z[10] = {2,3,4,3,4,4,3,4,4,4};
  REP(i, n){
    cin >> s;
    if(s[0]=='M') m++;
    if(s[0]=='A') a++;
    if(s[0]=='R') r++;
    if(s[0]=='C') c++;
    if(s[0]=='H') h++;
  }
  w[0]=m; w[1]=a; w[2]=r; w[3]=c; w[4]=h;
  REP(i, 10){
    ans += w[x[i]]*w[y[i]]*w[z[i]];
  }
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main(){
    int k;
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2] >> k;
    sort(v.begin(), v.end());
    while(k--){
         v[2] *= 2;
    }
    cout << accumulate(v.begin(), v.end(), 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){

    int a,b,c;
    cin >> a >> b >> c;
    string ans = "No";
    if(a==b&&a!=c) ans = "Yes";
    if(a==c&&a!=b) ans = "Yes";
    if(c==b&&a!=c) ans = "Yes";

    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int friends[100005]={};
  int i;
  int n;
  int a,b;
  int max=0;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>a>>b;
    friends[a]++;
    friends[b+1]--;
    //    cout<<"i"<<i<<endl;
  }
  for(i=1;i<100005;i++)
    friends[i]+=friends[i-1];
  for(i=0;i<100005;i++)
    if(friends[i]>=i-1)
      max=i-1;

  cout<<max<<endl;
}

Measured memory_bytes: 1560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    char c[h][w];
    rep(i,h)rep(j,w)cin >> c[i][j];
    int ans=mod;
    rep(i,bit(h-1)){
        bool can=true;
        int temp=0;
        int box[h]={};
        rep(j,w){
            if(!can)break;
            bool cut=false;
            int tbox[h]={};
            rep(p,h){
                if(c[p][j]=='1')tbox[p]++;
            }
            int now=h-1;
            for(int p=h-2;p>=0;p--){
                if(bit(p) & i){
                    now=p;
                }
                else{
                    tbox[now]+=tbox[p];
                    tbox[p]=0;
                }
            }
            rep(p,h){
                if(tbox[p]>k)can=false;
                else if(tbox[p]+box[p]>k)cut=true;
            }
            if(cut){
                temp++;
                rep(p,h){
                    box[p]=tbox[p];
                }
            }
            else{
                rep(p,h){
                    box[p]+=tbox[p];
                }
            }
        }
        if(!can)continue;
        else{
            rep(j,h-1){
                if(i & bit(j))temp++;
            }
            chmin(ans,temp);
        }
    }
    cout << ans;
    


}

/*



 */



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int H, W, K; cin >> H >> W >> K;
	char c[10][10];

	REP(i,H) REP(j,W) cin >> c[i][j];

	// int ans = 0;
	// REP(i,1<<H){
	// 	REP(j,1<<W){
	// 		int cnt = 0;
	// 		REP(y,H){
	// 			int b_y = (i>>y)&1;
	// 			REP(x,W){
	// 				int b_x = (j>>x)&1;
	// 				if(!b_y and !b_x and c[y][x] == '#') cnt++;
	// 			}
	// 			if(cnt == K) ans++;
	// 		}
	// 	}
	// }
	//

	int ans = 0;
	REP(i,1<<H){
		REP(j, 1<<W){
			bitset<8> y(i);
			bitset<8> x(j);

			int cnt = 0;
			REP(a,H){
				REP(b,W){
					if(y[a] and x[b] and c[a][b] == '#') cnt++;
				}
			}
			if(cnt == K) ans++;
		}
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
constexpr int INF = 1e9;

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    string S;
    cin >> S;

    string ans;
    bool ok = false;
    vector<string> c = {"SS", "SW", "WS", "WW"};
    for (auto x:c) {
        ans = x;
        FOR (index, 1, n) {
            if (ans[index] == 'S') {
                if (S[index] == 'o') {
                    ans += (ans[index-1] == 'S' ? "S" : "W");
                } else {
                    ans += (ans[index-1] == 'S' ? "W" : "S");
                }
            } else {
                if (S[index] == 'x') {
                    ans += (ans[index-1] == 'S' ? "S" : "W");
                } else {
                    ans += (ans[index-1] == 'S' ? "W" : "S");
                }
            }
        }
        //cout << ans << endl;
        if (ans[0] == 'S') {
            if (S[0] == 'o') {
                if (ans[n-1] != ans[1]) continue;
            } else {
                if (ans[n-1] == ans[1]) continue;
            }
        } else {
            if (S[0] == 'x') {
                if (ans[n-1] != ans[1]) continue;
            } else {
                if (ans[n-1] == ans[1]) continue;
            }
        }
        if (ans[0] == ans[n]) {
            REP(i,n) cout << ans[i];
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 712
// スタック
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>

// スタック関連の定義
const int Max_Stack = 1000;
int stack_count = 0;
int ary_stack[Max_Stack];

void create_stack(void);
int push(int element);
int pop(void);

int main(void)
{
    char str[10];
    int i = 0, ch, operand_1, operand_2;
    int result;

    // スタックを作成
    create_stack();

    while( ( ch = getchar() ) != '\n' )
    {

        if( '0' <= ch && ch <= '9' )
        {
            str[i++] = ch;
        }
        else if( ch == '+' || ch == '-' || ch == '*' )
        {
            operand_1 = pop();
            operand_2 = pop();

            if( ch == '+' )
            {
                result = operand_2 + operand_1;
            }
            else if( ch == '-' )
            {
                result = operand_2 - operand_1;
            }
            if( ch == '*' )
            {
                result = operand_2 * operand_1;
            }

            // 演算結果をpushしておく
            push(result);
        }
        else if( str[0] != '\0' )
        {
            str[i] = '\0';

            // 数値をプッシュする
            push(atoi(&str[0]));

            // 初期化をする
            i = 0;
            str[0] = '\0';
        }
    }

    printf("%d\n", result);

    return 0;

}

// スタックを作成する関数
void create_stack(void)
{
    int i;

    for(i = 0; i < Max_Stack; i++)
    {
        // スタックの初期化
        ary_stack[i] = 0;
    }

    return;
}

// スタックへプッシュする関数
int push(int element)
{

    if( stack_count >= Max_Stack - 1 )
    {
        // サイズオーバー
        return -1;
    }

    // スタックに追加する
    ary_stack[++stack_count] = element;

    return 0;
}

// スタックからポップする関数
int pop(void)
{
    int ret = 0;

    if( stack_count <= 0 )
    {
        // スタックが空の時
        ret = INT_MIN;
    }
    else
    {
        ret = ary_stack[stack_count--];
    }

    return ret;
}



Measured memory_bytes: 2692
import java.util.*;

public class Main{
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)){
			char[] S = sc.next().toCharArray();
			Arrays.sort(S);
			for(int i = 1; i < S.length; i++){
				if(S[i-1] == S[i]){
					System.out.println("no");
					return;
				}
			}
			System.out.println("yes");
		}
	}
}


Measured memory_bytes: 25044
n = gets.chomp.to_i
s = gets.chomp.split("")
a = []
b = s
ans = 0
(n-1).times do 
    hash = Hash.new(0)
    arr = [*"a".."z"]
    arr.each do |i|
    hash[i] += 0
    end
    a << b.shift
    aa = a.uniq
    bb = b.uniq
    aa.each do |i|
        hash[i] += 1
    end
    bb.each do |i|
        hash[i] += 1
    end
    count = 0
    hash.each do |i|
        if i[1] == 2
            count += 1
        end
    end
    ans = [ans,count].max
end
puts ans

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

main()
{
    ll x;
    cin>>x;
    for(ll i=-120;i<=120;i++){
        for(ll j=-120;j<120;j++)
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout<<i<<" "<<j;
                return 0;
            }
    }
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int X = Integer.parseInt(sc.next());
        sc.close();

        boolean f = false;
        outside : for (int i=0; i<=100000/105; i++) {
            if (X<i*105)
                break;
        for (int j=0; j<=100000/104; j++) {
            if (X<i*105+j*104)
                break;
        for (int k=0; k<=100000/103; k++) {
            if (X<i*105+j*104+k*103)
                break;
        for (int l=0; l<=100000/102; l++) {
            if (X<i*105+j*104+k*103+l*102)
                break;
        for (int m=0; m<=100000/101; m++) {
            if (X<i*105+j*104+k*103+l*102+m*101)
                break;
        for (int n=0; n<=100000/100; n++) {
            int Y = i*105+j*104+k*103+l*102+m*101+n*100;
            if (X==Y) {
                f=true;
                break outside;
            } else if (X<Y) {
                break;
            }
        }}}}}}
        if (f) {
            System.out.println("1");
        } else {
            System.out.println("0");
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(void) {
	string s;
	cin >> s;
	int n = 0, S = 0, e = 0, w = 0;
	rep(i, s.length()) {
		if (s[i] == 'N')n = 1;
		else if (s[i] == 'E')e = 1;
		else if (s[i] == 'S')S = 1;
		else w = 1;
	}
	if (n == S && e == w)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=a-(a>n); i!=n-(a>n); i+=1-2*(a>n))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_bac
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000007

int main(){
	flash; QuickSilver;
	int n; cin>>n;
  vl a(n); get(a);
  ll m=1e10, cnt=0; 
  rep(i,0,n) {
    m=min(m,a[i]);
    if(m==a[i]) cnt++;
  }
  cout<<cnt<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int a[1000000]={0};
int main(){
  int n,i,j,x;

  while(scanf("%d",&n) != EOF){
    x=0;
    for(i=2 ; i<=n/2 ; i++){
      for(j=2 ; j*i<=n ; j++){
	a[i*j]=1;
      }
    }

    for(i=2 ; i<=n ; i++){
      if(a[i] == 0){
	x++;
      }
    }

    printf("%d\n",x);
  }

  return (0);
}

Measured memory_bytes: 4500
a=input().split()
x=int(a[0])
n=int(a[1])

if n==0:
  print(x)
else:
  b=input().split()
  il=[]
  for y in b:
    il.append(int(y))

  if not x in il:
    print(x)
  else:
    for i in range(1,100):
      if not x-i in il:
        print(x-i)
        break
      elif not x+i in il:
        print(x+i)
        break

Measured memory_bytes: 9148
n = int(input())
d = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d)]

count = 0
flag = 0
for i in range(n):
  if d1[i]==d2[i]:
    count += 1
  else:
    count = 0
  if count==3:
    flag = 1
    print('Yes')
    break

if flag==0:
  print('No')

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


using namespace std;



int n ;
const int N = 1e5 + 10 ;
int h[N] ;
int mem[N] ;


int jump(int i){
    if(i == n - 1) return 0 ;

    if(i >= n)
        return 1e9 ;

    if(mem[i] != -1) return mem[i] ;

    return mem[i] = min( jump(i + 1) + abs(h[i] - h[i + 1])  , jump(i + 2) + abs(h[i] - h[i + 2])) ;

}


int main(){
    scanf("%d" , &n) ;
    memset(mem , -1 , sizeof mem) ;

    /*
    for(int i = 0 ; i < n ; i++)
        printf("%d " , mem[i]) ;
    */

    for(int i = 0 ; i < n ; i++)
        cin>> h[i] ;

    printf("%d\n" , jump(0)) ;
}





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

int main(){
  string S,T;
  cin>>S>>T;
  int c=0;
  int out=0;
  int n=S.size();
  for(int i=0;i<n;i++){
    out=0;
    for(int j=0;j<n;j++){
      if(S[(j+i)%n]!=T[j])out++;
    }
    if(out==0)c++;
  }
  if(c)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
x = [int(input()) for i in range(5)]
y = []
for i in range(5):
    tmp = x[i]%10
    if(tmp!=0):
        y.append(tmp)
if (y==[]):
    y = [0]
md = min(y)
print(sum(x[i]//10 for i in range(5))*10 + (len(y)-1)*10+md)

Measured memory_bytes: 3060
n,m,l = map(int,input().split())

A =[]
B = []
ans =[]

for _ in range(n):
    A.append([int(n) for n in input().split()])

for _ in range(m):
    B.append([int(n) for n in input().split()])

for x in range(n):
    L = []
    for y in range(l):
        a = 0
        for z in range(m):
            a += A[x][z]*B[z][y]
        L.append(str(a))

    ans.append(L)

for a in ans:
    print(" ".join(a))


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

#define mp(x,y) make_pair(x,y) 
#define M 1000000007
#define endl "\n"
#define pb(x) push_back(x)
#define llip(t) long long t ; cin >> t ;
#define llip2(a,b) long long a,b ; cin >> a >> b ;
#define dip(a) double a ; cin >> a ;
#define dip2(a,b) double a,b ; cin >> a >> b ; 
#define pll pair<long long,long long>  
typedef long long ll;
 
ll N , W ;

vector<pll> stones ;

ll dp[105][100005] ;

ll knapsack(ll curr,ll pos){
    if(curr == W || pos == N) return 0 ;
    if(dp[pos][curr] != -1) return dp[pos][curr] ;
    if(curr + stones[pos].first <= W){
        dp[pos][curr] = max(stones[pos].second+knapsack(curr+stones[pos].first,pos+1),knapsack(curr,pos+1)) ;
    }
    else{
        dp[pos][curr] = knapsack(curr,pos+1) ;
    }
    return dp[pos][curr] ;
}

int main(){ 
    ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> N >> W ;
    for(int i = 0 ; i < 105 ; i++){
        for(int j = 0 ; j < 100005 ; j++){
            dp[i][j] = -1 ;
        }
    }
    for(ll i = 0 ; i < N ; i++){
        llip2(w,v) ;
        stones.pb(mp(w,v)) ;
    }
    ll ans = knapsack(0,0) ;
    cout << ans << endl  ;
}

 

Measured memory_bytes: 82304
#include<bits//stdc++.h>
#define mod 1000000007
using namespace std;

int main()
{
   int n,m;
   cin>>m>>n;
   vector<char>tmp;
   vector<vector<char> >dp; 
   char x;
   for(int i=0;i<m;i++)
   {
    for(int i=0;i<n;i++)
    {
        cin>>x;
        tmp.push_back(x);
    }
    dp.push_back(tmp);
    tmp.clear();
   }
  vector<long int>tm(n,0);
  vector<vector<long int> >ans(m,tm);
  ans[0][0]=1;
  
  for(int i=1;i<m;i++)
  if(dp[i][0]=='.')
  ans[i][0]=ans[i-1][0];
  else
  break;
  
   for(int i=1;i<n;i++)
  if(dp[0][i]=='.')
  ans[0][i]=ans[0][i-1];
  else
  break;
  
  for(int i=1;i<m;i++)
    for(int j=1;j<n;j++)
    {
     if(dp[i][j]=='#')
      continue;
     ans[i][j]=ans[i-1][j]+ans[i][j-1]; 
     ans[i][j]%=mod;
   }
  
  cout<<ans[m-1][n-1]<<endl;
}

Measured memory_bytes: 9088
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 160000;
const int K = 20000;
int phicalc (int n) {
	int result = n;
	for (int i=2; i*i<=n; ++i)
		if (n % i == 0) {
			while (n % i == 0)
				n /= i;
			result -= result / i;
		}
	if (n > 1)
		result -= result / n;
	return result;
}
int gcd (int a, int b, int & x, int & y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int x1, y1;
	int d = gcd (b%a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
int binpow(int x, int y, int mod){
    if (y == 0) return 1 % mod;
    if (y % 2) return x * binpow(x, y - 1, mod) % mod;
    int z = binpow(x, y / 2, mod);
    return z * z % mod;
}
int mul(int x, int y, int mod){
    if (x < 0) x += mod;
    if (y < 0) y += mod;
    if (y == 0) return 0;
    if (y % 2){
        return (x + mul(x, y - 1, mod)) % mod;
    }
    int z = mul(x, y / 2, mod);
    return (z + z) % mod;
}
int solve(int a, int m){
    a %= m;
    if (a % m == 0) return m;
    int g = __gcd(a, m);
    int phi = phicalc(m);
    int c = __gcd(phi, m);
    if (g != 1){
        int nm = m / g;
        while(__gcd(nm, g) != 1){
            int t = __gcd(nm, g);
            nm /= t;
            g *= t;
        }
        int nphi = phicalc(nm);
        int invg = binpow(g, nphi - 1, nm);
        int na = binpow(binpow(a, g, nm), invg, nm);
        int z = solve(na, nm);
        int yp = mul(invg, z, nm * nphi);
        int y = mul(invg, z, nm);
        int x = mul(g, mul(invg, z, nm * nphi), m * phi);
        return x + m * phi;
    }
  //  cout << m << " " << phi << " " << c << endl;
    if (c == 1){
        int x = 0;
        int y = 0;
        int z = gcd(phi, -m, x, y);
        if (x * phi - y * m == -1){
            x = -x;
            y = -y;
        }
        int res = phi * x;
        //cout << x << " -- " << y << endl;
        if (res < 0) res += m * phi;
        return res;
    }
    int z = solve(a, c);
    int d = binpow(a, z, m);
    int v1 = (d - z) / c;
    int zz = z;
    int x = 0;
    int y = 0;
    z = gcd(phi / c, -m / c, x, y);
    if (x * phi / c - m * y / c == -1){
        x = -x;
        y = -y;
    }
    y = mul(m, mul(y, v1, phi * m), phi * m);
    x = mul(phi, mul(x, v1, phi * m), phi * m);
    int res1 = x + zz;
    int res2 = y + d;
    if (res1 <= 0) res1 += m * phi;
    if (res2 <= 0) res2 += m * phi;
    return res1;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int q;
    cin >> q;
    while(q--){
        int a, m;
        cin >> a >> m;
        int res = solve(a, m);
        cout << res << endl;
       // cout << res % m << " " << binpow(a, res, m) << endl;
    }
}


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

int main(){

    double D,px,py,vx,vy,L;
    while(cin>>D,D!=0){
        cin>>px>>py>>vx>>vy;
        if(abs(atan2(py,px)-atan2(vy,vx))<1e-6||abs(abs(atan2(py,px)-atan2(vy,vx))-atan2(0,-1))<1e-6){
            if(px*vx<0||py*vy<0){
                L=hypot(px,py);
            }else{
                L=2-hypot(px,py);
            }
            if(D-L>1e-3){
                cout.precision(8);
                cout<<fixed<<L<<endl;
            }else{
                cout<<"impossible"<<endl;
            }
        }else{
            cout<<"impossible"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3464
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[n];
    ll b[n];
    ll sum = 0;
    F0R(i,n){
      cin >> a[i];
      b[i] = a[i] - (i+1);
      sum +=b[i];
    }
    if(n == 1) {cout << 0 << endl; return 0;}
    sort(b,b+n);
    ll sgT[n];
    sgT[0] = b[0];
    FOR(i,1,n) sgT[i] = sgT[i-1] + b[i];
    ll ans = INF;
    ll curAns;
    F0R(i,n-1){
      ll sumCons = sgT[i] - (sum - sgT[i]);
      ll multier = n - 2*(i+1);
      if(multier == 0) {
        curAns = abs(sumCons);
        if(curAns < ans ) ans = curAns;
        continue;
      }
      if(sumCons >= b[i]*multier*(-1) && sumCons <= b[i+1]*(-1)*multier)
        {ans = 0; break;}
      if(abs(sumCons + multier*b[i]) < ans) ans = abs(sumCons + multier*b[i]);
      if(abs(sumCons + multier*b[i+1]) < ans) ans = abs(sumCons + multier*b[i+1]);
    }
    cout << ans << endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main(){
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='7'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

int g(int x, int y, int z)
{
	return x*x + y*y + z*z + x*y + y*z + z*x;
}

int main()
{
	int N;
	cin >> N;
	for (int x = 1; x <= 100; ++x)
	{
		if (x*x + x > N) break;
		for (int y = 1; y <= 100; ++y)
		{
			if (x*x + x + y*y + y > N) break;
			for (int z = 1; z <= 100; ++z)
			{
				if (g(x,y,z) <= N) ans[g(x,y,z)]++;
			}
		}
	}
	for (int i = 1; i <= N; ++i)
	{
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,i;
	cin >> a;
	string s;
	b=a;
	cin >> s;
	for(i=1;i<s.length();i++)
	{
		if(s[i]==s[i-1])
		{
			b--;
		}
	}
	cout << b;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<math.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#define INF 0x3f3f3f3f
#include<map>
#include<string>
#include<queue>
#include<vector>
#include<set>
#define mod 1000000007
double pi=acos(-1.0);
typedef long long ll;
using namespace std;
int n;
ll a[400000];
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+3*n);
	ll sum=0;
	for(int i=1;i<=n;i++)
		sum+=a[3*n-(2*i-1)];
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5],ans;
int main()
{
	for(int i=1;i<=3;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+3+1);
	ans+=(a[2]-a[1])/2;
	a[1]=a[2]-(a[1]%2+a[2]%2)%2;
	ans+=(a[3]-a[2]);
	a[1]=(a[3]-a[2]+a[1]);
	a[2]=a[3];
	ans+=(a[1]+a[2]+a[3])%3;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;


#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ffr(i,a) for (int i = (a)-1; i >= 0; i--)
#define endl "\n"
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int maxn = 2e5 + 5 ;
const int mod = 1000000007;
const ll INF = 1e18;
const int MX = 2000000001; //check the limits, dummy

pair < int , string > s[200] ;
int main() {
	ios_base::sync_with_stdio(0) ,cin.tie(0);
  ll t, qr, n, ar, hb, k, l, m, r,  x = 0, y = 0, ans = 0, temp = 0, res = 0 ;
  cin >> n >> k ;
  ffd(i, k, n )  ans += ( i * (n - i + 1)) % mod + 1;
  cout << ans % mod + 1 ;
}

Measured memory_bytes: 3600
/*
Author : N_o_o_B
Created : April 19 2020 17:39:15 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

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

    int n;
    cin >> n;
    vi cnt(n);
    fori(i,n-1){
        int x;
        cin >> x;
        x--;
        cnt[x]++;
    }
    fori(i,n){
        cout << cnt[i] << endl;
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 4052
#include<cstdio>
using namespace std;
typedef long long ll;
ll a,b,c,d;
ll gcd(ll a,ll b)
{
	if(b) return gcd(b,a%b);
	return a;
}
inline ll lcm(ll a,ll b)
{
	return a/gcd(a,b)*b;
}
inline ll fsum(ll t,ll a,ll b)
{
	return t-t/a-t/b+t/lcm(a,b);
}
int main()
{
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	printf("%lld",fsum(b,c,d)-fsum(a-1,c,d));
}

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

using namespace std;
typedef long long int ll;

int N,M;
set<int> g[55];
vector<int> low(55,-1);
vector<int> pre(55,-1);
int cnt;
void f(int n, int p, int from){

  if(pre[n]<0)pre[n]=p;
  else return;

  low[n]=p;
  for( auto&& i:g[n]){
    if(i==from)continue;
    f(i,p+1, n);
    if(pre[n]<low[i])cnt++;
    else low[n]=min(low[n],low[i]);

  }
}
int main() {
  cin>>N>>M;
  for(int i = 0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  f(0,0, -1);
  cout<<cnt<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;
int main(){
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> dp(H + 1, vector<int>(W, 0));
	dp[0][0] = 1;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < (1 << (W - 1)); j++){
			bool ok = true;
			for (int k = 0; k < W - 2; k++){
				if ((j >> k & 1) && (j >> (k + 1) & 1)){
					ok = false;
				}
			}
			if (ok){
				vector<int> p(W);
				for (int k = 0; k < W; k++){
					p[k] = k;
				}
				for (int k = 0; k < W - 1; k++){
					if (j >> k & 1){
						swap(p[k], p[k + 1]);
					}
				}
				for (int k = 0; k < W; k++){
					dp[i + 1][p[k]] += dp[i][k];
					dp[i + 1][p[k]] %= MOD;
				}
			}
		}
	}
	cout << dp[H][K - 1] << endl;
}

Measured memory_bytes: 3576
import java.util.*;

    public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int curtain = a - b*2;
            if( curtain < 0){
                System.out.println("0");
            }else{
                System.out.println(curtain);
            }
        }
    }

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x; cin >> x;

  if(x==0) x = 1;
  else if(x==1) x = 0;

  cout << x << endl;
  
  return 0;
}


Measured memory_bytes: 3616
n, w = map(int, (input().split()))
lst = [list(map(int, input().split())) for i in range(n)]

dp = [0] * (w + 1)

for i in range(n):
    for j in range(w, lst[i][0] - 1, -1):
        dp[j] = max(dp[j - lst[i][0]] + lst[i][1], dp[j])

print(dp[w])


Measured memory_bytes: 41708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();

		int[] B = new int[M];

		for(int i = 0 ; i < M ; i++){
			B[i] = sc.nextInt();
		}

		int[] A = new int[N*M];
		for(int i = 0 ; i < N*M ; i++){
			A[i] = sc.nextInt();
		}

		sc.close();

		int[] calc = new int[M];

		int tmp = 0;
		int ans = 0;
		int p = 0;
		for(int i = 0 ; i < M*N ; i=i+M){
			for(int k = 0 ; k < M ; k++){
				tmp = tmp + B[k]*A[i+k];
			}
			if(tmp+C > 0){
				ans = ans + 1;
			}
			tmp = 0;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x),b(y),c(z);
    for (int i = 0; i < x; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < y; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < z; ++i) {
        cin >> c[i];
    }
    vector<ll> ab;
    for (int i = 0; i < x; ++i) {
        for (int j = 0; j < y; ++j) {
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end(),greater<ll>());
    ab.resize(k);
    vector<ll> ans;
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < z; ++j) {
            ans.push_back(ab[i]+c[j]);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    for (int i = 0; i < k; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 43368
N = int(input())

def doround(n) :
    if n % 1000 > 0 :
        return (n // 1000) * 1000 + 1000
    else :
        return n
    
base = 100000
for i in range(N) :
    base *= 1.05
    base = doround(base)
    
print(int(base))
    


Measured memory_bytes: 5616
#include <stdio.h>

int main() {
	int n, p, cnt = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &p);
		if (p != i)
			cnt++;
	}
	if ((cnt == 0) || (cnt == 2))
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 128
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

/**
 *
 * @author nai
 */
public class Main {

    public static void main(String[] args) throws Exception{
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int sum = 0;
        
        for(int i = 1 ; i <= N ; i++){
            int n = i;
            int digSum = 0;
            //合計が条件を満たすことを確認
            while(n > 0){
                digSum += n % 10;
                n /= 10;
            }
            if(A <= digSum && digSum <= B){
                sum += i;
            }
        }
        System.out.println(sum);
    }
  }
    



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a==b && b==c)
  {
    cout << 1;
  }
  else if(a==b || b==c || c==a)
  {
    cout << 2;
  }
  else
  {
    cout << 3;
  }
}

Measured memory_bytes: 256
#include <cstdio>

const int MAXN=100011;
const long long LONF=4567891012345678910LL;


int N;
int A[MAXN];
int O[MAXN];

long long F[MAXN][3];

int rO(){
	static char ch[2];
	scanf("%s", ch);
	return ch[0]=='+';
}

void relax(long long &f, long long v){
	if(f<v)	f=v;
}

int Calc(int t, int o, int a){
	if(t)	o=!o;
	return ((o<<1)-1)*a;
}

int main(){
	
	scanf("%d", &N);
	
	scanf("%d", &A[1]);
	for(int i=2;i<=N;++i){
		O[i]=rO();
		scanf("%d", &A[i]);
	}
	
	for(int i=1;i<=N;++i)
		for(int j=0;j<=2;++j)
			F[i][j]=-LONF;
	
	F[1][0]=(long long)(A[1]);
	for(int i=2;i<=N;++i){
		for(int j=0;j<3;++j){
			for(int k=0;k<=j;++k){
				relax(F[i][k], F[i-1][j]+Calc(k&1, O[i], A[i]));
			}
			if(!O[i]){
				for(int k=0;k<=j && k<2;++k){
					relax(F[i][k+1], F[i-1][j]+Calc(k&1, O[i], A[i]));
				}
			}
		}
	}
	
	long long Ans=-LONF;
	for(int j=0;j<3;++j)
		relax(Ans, F[N][j]);
	printf("%lld\n", Ans);
	
	return 0;
}

Measured memory_bytes: 3328
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n, k = map(int, input().split())

    ans = 0
    for a in range(1, n+1):
        if 2 * a % k == 0:
            d = a // k
            u = (n+a) // k
            ans += (u-d) ** 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] = { 0, 0, 1, -1, 1, -1, 1, -1 };


const int N = 3010;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const int T = 238;
const ld e = 74e-9;

lli bp(lli a, lli b = -2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}

int x;
int pat;
int main()
{
	fastio;
	cin >> x;
	pat += 1000 * (x / 500);
	x = x % 500;
	pat += 5 * (x / 5);
	cout << pat << endl;
	return 0;
}


/*
  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/


Measured memory_bytes: 256