akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int a[20], n;
bool solve(int, int);
string putout(bool);
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	int q, x;
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> x;
		cout << putout(solve(0,x)) << endl;
	}
	return 0;
}
bool solve(int i, int m) {
	if (m == 0)return true;
	if (i >= n)return false;
	return solve(i + 1, m) || solve(i + 1, m - a[i]);
}
string putout(bool a) {
	if (a)return "yes";
	else return "no";
}

Measured memory_bytes: 1192
let input = require('fs').readFileSync('/dev/stdin', 'utf8')
// let input = require('fs').readFileSync('./sample_b.txt', 'utf8')
.split(/\n/)
// .map(item => parseInt(item))
.slice(1,-1)

const sample = input.map(item=>item.split(" "))


let sum = 0
for( item of sample){
    if( item[0] === item[1] ){
        sum++
    }else{
        sum = 0
    }
    if(sum === 3){
        console.log("Yes")
        return
    }
}
console.log("No")

Measured memory_bytes: 29668
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n,a,b,i;
  cin >> n >> a >> b;
  int ans=0;
  for(i=1;i<=n;i++){
    if(digit(i)>=a && digit(i)<=b){
      ans+=i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  ll x;
  cin >> x;
  ll ans = 0;
  if (x >= 500)
  {
    ans = 1000 * (x / 500);
    x -= 500 * (x / 500);
  }
  if (x >= 5)
  {
    ans += 5 * (x / 5);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3616
#最大二部マッチング
def dfs(v, edges, n, visited, matched):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], edges, n, visited, matched):
            matched[u] = v
            return True
    return False
def examC():
    N = I()
    ab = [LI() for _ in range(N)]
    cd = [LI() for _ in range(N)]
    xn = N; yn = N
    matched = [-1] * yn
    E = [set() for _ in range(xn)]
    for i in range(xn):
        for j in range(yn):
            if ab[i][0]<cd[j][0] and ab[i][1]<cd[j][1]:
                E[i].add(j)
    ans = 0
    for s in range(xn):
        ans += dfs(s, E, yn, set(), matched)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 3668
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	
	private static BufferedReader br;
	private static StringTokenizer tokenizer;
	public static String next() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            String line = br.readLine();
            if (line == null)
                throw new IOException();
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    } 
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    } 
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    } 
    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    
	public static void main(String[] args) throws IOException {		
		
		br = new BufferedReader(new InputStreamReader(System.in));
		int n = nextInt();
		int k = nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) {
			h[i] = nextInt();
		}
		Arrays.sort(h);
		if(k>=n) {
			System.out.println("0");
			return;
		}
		long sum = 0;
		for(int i=0;i<n-k;i++) {
			sum += h[i];
		}
		System.out.println(sum);
	}
}






















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

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(A < C){
        if(B > C) cout << "Yes";
        else cout << "No";
    }
    else if(A > C){
        if(C > B) cout << "Yes";
        else cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	ll k; cin >> k;
	ll ans[51];
	if (k == 0) {
		REP(i, 50) {
			ans[i] = i;
		}
	}
	else if (k <= 50) {
		for (int i = k-2; i >=0; --i) {
			ans[i] = 50 - (k-i-1);
		}
		ans[k - 1] = 50;
		for (int i = k; i < 50; ++i) {
			ans[i] = i - k;
		}
	}
	else {
		ll key = k / 50;
		k %= 50;
		for (int i = k - 2; i >= 0; --i) {
			ans[i] = 50 - (k-i-1);
		}
		ans[k - 1] = 50;
		for (int i = k; i < 50; ++i) {
			ans[i] = i - k;
		}
		REP(i, 50) {
			ans[i] += key;
		}
	}
	cout << 50 << endl;
	REP(i, 50) {
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}

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



int main(void){
    int n, m;
    cin >> n;
    vector<int> t(n);
    for(int i=0; i<n; i++) cin >> t[i];
    
    cin >> m;
    vector<int> p(m), x(m);
    for(int i=0; i<m; i++) cin >> p[i] >> x[i];
    
    int sum = accumulate(t.begin(), t.end(), 0);
    for(int i=0; i<m; i++) {
        int prob = p[i]-1;
        cout << sum - (t[prob] - x[i]) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "stdio.h"
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;


class Puzzle
{
public:

	int N, M;
	vector<int> ms;

	void input()
	{

		int buf;
		cin >> N >> M;
		for (int mi = 0; mi < N; mi++) {
			cin >> buf;
			ms.push_back(buf);
		}

	}


	void play()
	{
		int ans = N - 1 - M;
		printf("%d\n", ans);
	}


};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}




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

int main(int argc, char const *argv[]) {
    int N, X, D=0, count=1;
    cin >> N >> X;

    vector<int> L(N);
    for (int i=0; i<N; i++) {
        cin >> L.at(i);
        D += L.at(i);
        if (D <= X) {
            count++;
        } else {
            break;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include <iomanip>
#include <bits/stdc++.h>
#include <fstream>
#include <map>
using namespace std;
typedef long long ll;
//#define INF 1000000000000 //10^12:極めて大きい値,∞
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int N,K,sum=0,temp;
    vector<int> p;
    cin >> N >> K;
    REP(i,N){
        cin >> temp;
        p.emplace_back(temp);
    }
    sort(p.begin(),p.end());
    REP(i,K) sum += p[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3540
n = int(input())
bt, bx, by = 0, 0, 0
flag = True
for i in range(n):
    nt, nx, ny = map(int, input().split())
    dist = abs(nx - bx) + abs(ny - by)
    diff_t = nt - bt
    if diff_t < dist or (diff_t - dist) % 2:
        flag = False
    bt, bx, by = nt, nx, ny
print('Yes' if flag else 'No')

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
	ll a,b,c,x,y;cin >> a >> b >> c >> x >> y;
	ll ans = 0;
	if(a + b >= 2 * c){
		int mi = min(x,y);
		ans += 2 * mi * c;
		x -= mi;
		y -= mi;
	}
	if(a >= 2 * c){
		int mi = max(0LL,x);
		ans += 2 * mi * c;
		x -= mi;
		y -= mi;
	}
	if(b >= 2 * c){
		int mi = max(0LL,y);
		ans += 2 * mi * c;
		x -= mi;
		y -= mi;
	}
	ans += max(0LL,x) * a;
	ans += max(0LL,y) * b;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NM[0], M = NM[1];
        string S = ReadLine();
        string T = ReadLine();

        long g = gcd(N, M);
        long l = lcm(N, M);
        long a = N / g;
        long b = M / g;

        bool frag = true;
        int num = 0;
        for (int i = 0; i < g; i++)
        {
            if (S[(int)a * i] != T[(int)b * i])
                frag = false;
        }
        if (frag)
        {
            WriteLine(l);
        }
        else
        {
            WriteLine(-1);
        }
    }
    static long gcd(long a,long b)
    {
        return a == 0 ? b : gcd(b % a, a);
    }
    static long lcm(long a,long b)
    {
        return a * b / gcd(a, b);
    }
}


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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(ll D, const vector<ll> &c, const vector<vector<ll>> &s, const vector<ll> &t) {
  vector<ll> last(26, -1);
  ll score = 0;
  REP(d, D) {
    ll i = t[d];
    score += s[d][i];
    last[i] = d;
    REP(j, 26) {
      score -= c[j] * (d - last[j]);
    }
  }
  return score;
}

ll area(ll D, ll d, const vector<ll> &t, ll target) {
  ll l = -1;
  for (int i = d - 1; i >= 0; i--) {
    if (t[i] == target) {
      l = i;
      break;
    }
  }
  ll r = D;
  FOR(i, d + 1, D) {
    if (t[i] == target) {
      r = i;
      break;
    }
  }
  ll x = r - d;
  ll y = d - l;
  return x * y;
}

ll calc_diff(ll D, ll pre, ll next, const vector<ll> &c, const vector<vector<ll>> &s, ll d, const vector<ll> &t) {
  ll diff = s[d][next] - s[d][pre];
  diff += c[next] * area(D, d, t, next);
  diff -= c[pre] * area(D, d, t, pre);
  return diff;
}

void solve(ll D, vector<ll> c, vector<vector<ll>> s) {
  vector<ll> t(D, 0);
  REP(d, D) {
    ll m = 0;
    ll cur = 0;
    FOR(i, 1, c.size()) {
      t[d] = i;
      ll diff = calc_diff(d + 1, 0, i, c, s, d, t);
      if (diff > m) {
        m = diff;
        cur = i;
      }
    }
    t[d] = cur;
  }

  auto start = std::chrono::system_clock::now();
  std::mt19937 mt{0};
  std::uniform_int_distribution<int> dist2(0, D - 1);
  std::uniform_int_distribution<int> dist3(0, 25);
  ll count = 0;
  while (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start).count() <
         1970) {
    count++;
    if (count % 2 == 0) {
      ll d = dist2(mt);
      ll d2 = dist2(mt);
      ll pre = t[d];
      ll next = t[d2];
      t[d] = next;
      ll diff = calc_diff(D, pre, next, c, s, d, t);
      t[d2] = pre;
      diff += calc_diff(D, next, pre, c, s, d2, t);
      if (diff > 0) {
        // cout << "swap" << endl;
      } else {
        swap(t[d], t[d2]);
      }
    } else {
      ll d = dist2(mt);
      ll pre = t[d];
      ll next = dist3(mt);
      t[d] = next;
      ll diff = calc_diff(D, pre, next, c, s, d, t);
      if (diff > 0) {
        // cout << "change" << endl;
      } else {
        t[d] = pre;
      }
    }
  }

  REP(d, D) {
    cout << t[d] + 1 << "\n";
  }
}

int main() {
  ll D;
  scanf("%lld", &D);
  vector<ll> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  vector<vector<ll>> s(D, vector<ll>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  solve(D, move(c), move(s));
  return 0;
}


Measured memory_bytes: 3796
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination

int main(){
    int n,a,b;
    cin >> n>> a >> b;
    cout<<min(n*a,b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

int n, a[maxn], g[maxn];

int gcd(int x, int y) {
	if (x % y == 0)
		return y;
	else
		return gcd(y, x%y);
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		g[i] = i == 0 ? a[i] : gcd(g[i-1], a[i]);
	}

	if (n == 2) {
		cout << max(a[0], a[1]) << endl;
		return 0;
	}

	int cur = a[n-1], ans = max(g[n-1], g[n-2]);
	for (int i = n-2; i > 0; --i) {
		int tmp = gcd(cur, g[i-1]);
		ans = max(ans, tmp);

		cur = gcd(a[i], cur);
	}

	ans = max(ans, cur);

	cout << ans << endl;

	return 0;
}

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

int main() {
	int  a[100], n;
	cin >> n; 
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
    for (int i = n-1; i >= 0; i--) {
    	cout << a[i];
        if (i != 0) {
            cout  <<" ";
        } else {  
        	cout << endl;  
        } 
    } 
    
	return 0;
}	


Measured memory_bytes: 3092
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;
long long n,h;
int a[1000+10],b[1000+10];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		h+=b[i]-a[i]+1;
	}
	cout<<h<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(raw_input())
A = [raw_input() for _ in xrange(N)]
counts = map(lambda x: x.count("#"), A)

if sum(counts) == 0:
	print -1
	exit(0)

for i in xrange(N):
	has_hash = False
	for j in xrange(N):
		if A[j][i] == "#":
			has_hash = True
	if not has_hash:
		counts[i] -= 1
ans = N+N-max(counts)

for j in xrange(N):
	complete = True
	for i in xrange(N):
		if A[i][j] != "#":
			complete = False
	if complete:
		ans -= 1

print ans

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

const int MOD = 1e9 + 7;

int n, k;
int a[155];

int dp[155][100055];

inline void add(int &a, int b) {
	a += b;
	
	if (a >= MOD) {
		a -= MOD;
	}
}
inline void sub(int &a, int b) {
	a -= b;
	
	if (a < 0) {
		a += MOD;
	}
}
int main() {
	cin >> n >> k;
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	dp[0][0] = 1;
	
	for (int i = 0; i < n; i++) {
		int ac = 0;
		
		for (int j = 0; j <= k; j++) {
			add(ac, dp[i][j]);
			add(dp[i + 1][j], ac);
			
			if (j - a[i] >= 0) {
				sub(ac, dp[i][j - a[i]]);
			}
		}
	}
	
	cout << dp[n][k];
}


Measured memory_bytes: 40832
#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>;

int main() {
	int n,k,t;
	cin >> n >> k >> t;
	int ans = n / k;
	if (n % k) ans++;
	cout << ans * t << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
	int a, b;
	int sen, hyaku, juu;
	int oturi;
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			break;
		}
		sen = hyaku = juu = 0;
		oturi = b - a;
		sen = oturi / 1000;
		oturi %= 1000;
		hyaku = oturi / 500;
		oturi %= 500;
		juu = oturi / 100;
		cout << juu << ' ' << hyaku << ' ' << sen << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
	ll n,arr[3],narr[3],i=0,j,k,temp[3];
	cin>>n;
	narr[0]=-1,temp[0]=-1;
	narr[1]=-1;temp[1]=-1;
	narr[2]=-1;temp[2]=-1;
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		cin>>narr[j];
		if(i==0)
		{
			for(j=0;j<3;j++)
			arr[j]=narr[j];
		}
		else
		{
			for(j=0;j<3;j++)
			{
				for(k=0;k<3;k++)
				{
					if(j!=k)
					{
						//cout<<arr[j]<<" "<<arr[k]+narr[j]<<endl;
						temp[j]=max(temp[j],arr[k]+narr[j]);
					}
				}
				//cout<<arr[j]<<" ";
			}
			for(j=0;j<3;j++)
			{arr[j]=temp[j];temp[j]=-1;}
			//cout<<endl;
		}
	}
	cout<<max(arr[0],max(arr[1],arr[2]));
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import math

N, D = list(map(int, input().split()))
xy_list = []

count = 0
for _ in range(N):
    x, y = list(map(int, input().split()))
    if math.sqrt(x ** 2 + y ** 2) <= D:
        count += 1
print(count)


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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

const int N = 100005;
vector <int> v[N];
int p[N];
bool vis[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	queue <int> q;
	q.push(1);
	vis[1] = true;
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		for (auto y : v[x]) {
			if (!vis[y]) {
				vis[y] = true;
				q.push(y);
				p[y] = x;
			}
		}
	}
	cout << "Yes\n";
	for (int i = 2; i <= n; i++) {
		cout << p[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 10612
#include <stdio.h>

int main(){
    int count[128] = {0};
    char ch;
    
    while (scanf("%c", &ch) != EOF)
    {
      count[ch]++;
    } 
    
    for (char c = 'a'; c <= 'z'; c++)
    {
        printf("%c : %d\n", c,count[c] + count[c - 32]);
    }

    return 0;
}



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

for h in range(1, 3501):
    for n in range(1, 3501):
        try:
            w = (N * h * n) / (4 * (h * n) - (N * n) - (N * h))
        except:
            continue
        if w.is_integer() and w > 0:
            if 4 * (h * n * w) == N * ((n * w) + (h * w) + (h * n)):
                ans = [h, n, int(w)]
                exit(print(' '.join(map(str, ans))))

Measured memory_bytes: 67456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n); rep(i, n) cin >> A[i];
  vector<int> cnt(3);
  rep(i, n) {
    if(A[i] % 4 == 0) cnt[0]++;
    else if(A[i] % 2 == 0) cnt[1]++;
    else cnt[2]++;
  }
  if(cnt[0] >= n/2) cout << "Yes" << endk;
  else if(cnt[2] - cnt[0] <= 0) cout << "Yes" << endk;
  else cout << "No" << endk;
  return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
    double x1, y1, x2, y2;
    double ans;
    cin >> x1 >> y1 >> x2 >> y2;

    ans = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));

    printf("%f", ans);
}


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

char s[105];

void in()
{
    scanf("%s",s);
}

void work()
{
    int c=1;
    for(int i=0;i<strlen(s);++i)
    {
        if(s[i]=='C'&&c==1)
        {
            c=0;
        }
        if(s[i]=='F'&&c==0)
        {
           cout<<"Yes"<<endl;
            exit(0);
        }
    }
   cout<<"No"<<endl;
}

int main()
{
    in();
    work();
    return 0;
 } 


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

int main(){
  int res = 0;
  int tmp = 0;
  string str;
  cin >> str;
  for(auto c : str){
    if(c == 'A' || c == 'T' || c == 'G' || c == 'C'){
      tmp++;      
    }
    else{
      res = max(res, tmp);
      tmp = 0;
    }
  }
  res = max(res, tmp);
  cout << res << endl;
  
  return 0;
}


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

using namespace std;

//#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

//const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct SegmentTree {
  vector< set<int> > dataO, dataP;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz<<=1;
    resz(dataO, 2*sz-1);
    resz(dataP, 2*sz-1);
  }
  void update(int a, int b, int c, int k, int l, int r) {
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      dataO[k].insert(c);
      return;
    }
    update(a, b, c, 2*k+1, l, (l+r)/2);
    update(a, b, c, 2*k+2, (l+r)/2, r);
    dataP[k].insert(c);
  }
  void update(int a, int b, int c) {
    update(a, b, c, 0, 0, sz);
  }
  bool query(int a, int b, int c, int d, int k, int l, int r) {
    if(r <= a || b <= l) return true;
    bool vO = dataO[k].lower_bound(c) == dataO[k].upper_bound(d);
    if(!vO) return false;
    bool vP = dataP[k].lower_bound(c) == dataP[k].upper_bound(d);
    if(a <= l && r <= b) return vP;
    bool vl = query(a, b, c, d, 2*k+1, l, (l+r)/2);
    bool vr = query(a, b, c, d, 2*k+2, (l+r)/2, r);
    return vl&&vr;
  }
  bool query(int a, int b, int c, int d) {
    return query(a, b, c, d, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vint px(N), py(N), qx(N), qy(N);
  vint cx, cy;
  rep(i, N) {
    cin >> px[i] >> py[i] >> qx[i] >> qy[i];
    cx.push_back(px[i]); cy.push_back(py[i]);
    cx.push_back(qx[i]); cy.push_back(qy[i]);
  }
  sort(all(cx));
  cx.erase(unique(all(cx)), end(cx));
  sort(all(cy));
  cy.erase(unique(all(cy)), end(cy));

  rep(i, N) {
    px[i] = lower_bound(all(cx), px[i])-begin(cx);
    py[i] = lower_bound(all(cy), py[i])-begin(cy);
    qx[i] = lower_bound(all(cx), qx[i])-begin(cx);
    qy[i] = lower_bound(all(cy), qy[i])-begin(cy);
    if(px[i] > qx[i]) swap(px[i], qx[i]);
    if(py[i] > qy[i]) swap(py[i], qy[i]);
  }

  SegmentTree segX(cx.size()), segY(cy.size());

  rep(i, N) {
    if(segX.query(px[i], qx[i]+1, py[i], qy[i]) &&
       segY.query(py[i], qy[i]+1, px[i], qx[i])) {
      cout << 1 << endl;
      if(px[i] == qx[i]) segY.update(py[i], qy[i]+1, px[i]);
      else segX.update(px[i], qx[i]+1, py[i]);
    } else {
      cout << 0 << endl;
    }
  }
  return 0;
}

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

int main()
{
    string s, p, ans="No";
    cin >> s >> p;
    
//    s = "vanceknowledgetoad";
//    p = "advanced";
//    s = "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjj";
//    p = "ja";
    
    for(int i=0;i<s.size(); i++)
    {
        for(int j=0;p[j]==s[(i+j)%s.size()];j++)
        {
            if(j == p.size() - 1)
            {
                ans = "Yes";
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  long long ans;
  ans=0;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin >> h.at(i);
  sort(h.begin(),h.end());
  for(int i=0;i<n-k;i++) ans+=h.at(i);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    cout << s;
    if(s[s.length()-1]=='s') {
        cout << "es" << endl;
    } else {
        cout << "s" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e6+5;
const int M = (int)2e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

ll dp[M];
ll rec(int s) {
  if(s<3) {
    return (s==0);
  }
  else if(s==3) {
    return 1;
  }
  else if(dp[s]!=(-1)) {
    return dp[s];
  }
  dp[s] = 0;
  REP(i,3,s) {
    dp[s] += rec(s-i);
  }
  dp[s] %= mod;
  return dp[s];
}
void solve() {
  mms(dp,-1);
  int s;
  cin >> s;
  cout << rec(s);
}

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

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        //cout<<"\n";
    }
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> h(n+1);
    set<int> trash;
    for (int i=1; i<=n; ++i)
        cin >> h.at(i);

    for (int i=0; i<m; ++i) {
        int a,b;
        cin >> a >> b;
        if (h.at(a) > h.at(b)) {
            trash.insert(b);
        }
        else if (h.at(a) == h.at(b)) {
            trash.insert(a);
            trash.insert(b);
        }
        else
            trash.insert(a);

    }
    cout << n - (int)trash.size();
}


Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int x;
  cin>>x;
  int a=x,cnt=1;
  while (true) {
    if(x%360==0){
      break;
    }
    x+=a;
    cnt++;
  }
  out(cnt);
}

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


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);

	int n;
	cin >> n;
	string s;
	cin >> s;
	FOR(i, 0, SZ(s))
	{
		char x = s[i];
		x -= 'A';
		x += n;
		x %= 26;
		x += 'A';
		cout << x;
	}
	cout << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


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

int main() 
{
    int h, w;
    cin >> h >> w;
    // Fill two matrices at one time
    // Matrix v1=x*y and v2=y*x
    vector<vector<char>> v(h);
    vector<vector<char>> v2(w);
    for (int i=0; i<h; i++)
        for (int j=0; j<w; j++)
        {
            char e; cin >> e;
            v[i].push_back(e);
            v2[j].push_back(e);
        }
    bool y = true;
    for (int i=1; i<h-1; i++)
        for (int j=1; j<w-1; j++)
        {
            if (v[i][j] == '#' &&
            v[i][j+1] == '.' && v[i][j-1] == '.' &&
            v[i-1][j] == '.' && v[i+1][j] == '.')
                y = false;
        }

    for (int i=1; i<h-1; i++)
    {
        if (v[0][i] == '#' && v[0][i-1] == '.' &&
        v[0][i+1] == '.' && v[1][i] =='.')
            y = false;
        if (v[h-1][i] == '#' && v[h-1][i-1] == '.' &&
        v[h-1][i+1] == '.' && v[h-2][i] =='.')
            y = false;
    }
    for (int i=1; i<w-1; i++)
    {
        if (v2[0][i] == '#' && v2[0][i-1] == '.' &&
        v2[0][i+1] == '.' && v2[1][i] =='.')
            y = false;
        if (v2[w-1][i] == '#' && v2[w-1][i-1] == '.' &&
        v2[w-1][i+1] == '.' && v2[w-2][i] =='.')
            y = false;
    }
    if (v[0][0] == '#' && v[0][1] == '.' && v[1][0] == '.')
        y = false;
    if (v[h-1][0] == '#' && v[h-1][1] == '.' && v[h-2][0] == '.')
        y = false;
    if (v2[w-1][0] == '#' && v2[w-1][1] == '.' && v2[w-2][0] == '.')
        y = false;
    if (v[h-1][w-1] == '#' && v[h-1][w-2] == '.' && v[h-2][w-1] == '.')
        y = false;
    cout << (y?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int h[22];
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);int finalhe=0;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(h[i]>=finalhe) ans++;
		finalhe=max(finalhe,h[i]);
		
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> L(2*N);
  cinf(2*N,L);
  sort(L.begin(),L.end());
  int ans=0;
  for(int i=0;i<2*N;i+=2){
    ans +=L[i];
  }
  cout << ans << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}


const int MAXN=100001;
int N,M,K;

using Graph = vector<vector<int> >;

map<int,int> label;
int numberling[MAXN] = {0};
int Node[MAXN] = {0};
int ans[MAXN] = {0};

void bps(Graph &Friend, Graph &Enemy, int  current_person, int counter) {
  numberling[current_person] = counter;
  label[counter]++;
  for(int tm : Friend[current_person]) {
    Node[current_person]++;
    if(numberling[tm]==0){
      bps(Friend,Enemy,tm,counter);
    }
  }
  return;
}

int main(){
  cin >> N >> M >> K;
  Graph Friend(N+1);
  Graph Enemy(N+1);
  rep(i,M){
    int a,b;cin >> a >> b;
    Friend[a].push_back(b);
    Friend[b].push_back(a);
  }
  int c[MAXN];
  int d[MAXN];
  rep(i,K) {
    cin >> c[i] >> d[i];
  }
  int counter = 0;
  Rep(i,N) {
    if(!numberling[i]){
      counter++;
      bps(Friend, Enemy, i, counter);
    }
  }

  Rep(i,N) {
    ans[i] = label[numberling[i]];
  }
  
  rep(i,K) {
    if(numberling[c[i]] == numberling[d[i]]) {
      ans[c[i]]--;
      ans[d[i]]--;
    }
  }

  rep(i,N){
    cout << ans[i+1] - 1 - Node[i+1] << " ";
  }
  cout << endl;
  return 0;

}

Measured memory_bytes: 16100
n,k = gets.chomp.split(" ").map(&:to_i)
R,S,P = gets.chomp.split(" ").map(&:to_i)
t = gets.chomp.split("")
flag = []

(0...k).each do |number|
  flag.push(true)
end

(k...n).each do |idx|
  if t[idx] == t[idx - k] && flag[idx - k] 
    flag.push(false)
  else
    flag.push(true)
  end
end

sum = 0

t.each_with_index do |string, idx|
  if flag[idx]
    case string
    when "r"
      sum += P
    when "s"
      sum += R
    when "p"
      sum += S
    end
  end
end

puts sum

Measured memory_bytes: 9724
#include<iostream>
using namespace std;
int main () {
  int N;
  cin >> N;
  int h[100];
  for (int i = 0; i < N; i ++) cin >> h[i];
  int ma = h[0];
  int ans = 1;
  for (int i = 1; i < N; i ++) {
    if (h[i] >= ma) {
      ma = h[i];
      ans ++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

const i64 INF = 1e14;
i64 n, m;
using P = pair<i64, i64>;
vector<vector<P>> g;

int main() {
  cin >> n >> m;
  init_n(g, n + 1);
  for (i64 i = 0; i < m; ++i) {
    i64 a, b, c;
    cin >> a >> b >> c;
    g[a].emplace_back(b, -c);
  }

  vector<i64> dist(n + 1, INF);
  dist[1] = 0;
  bool upd = false;
  for (i64 i = 0; i < n + 10; ++i) {
    upd = false;
    for (i64 u = 1; u <= n; ++u) {
      if (dist[u] < INF) {
        for (auto p : g[u]) {
          i64 v, c;
          tie(v, c) = p;
          if (dist[u] + c < dist[v]) {
            fprintf(stderr,
                "%4lld->%4lld: %lld(%lld)\n", u, v, dist[u] + c, dist[v]);
            dist[v] = dist[u] + c;
            if (v == n) upd = true;
          }
        }
      }
    }
  }
  if (upd) cout << "inf\n";
  else cout << -dist[n] << '\n';
  return 0;
}


Measured memory_bytes: 384
import sys
import math
import itertools


# \n


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, WW = map(int, input().split())

    dp = [[0] * (WW+1) for _ in range(N)]

    for i in range(N):
        w, v = map(int, input().split())
        for j in range(WW+1):
            if w<=j:
                dp[i][j] =max(dp[i-1][j],dp[i-1][j-w]+v)
            else:
                dp[i][j] =dp[i-1][j]

    print(max(dp[N-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 151836
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int prime[1001000];//i番目の素数
bool is_prime[1001010];//is_prime[i]がtrueならiは素数
					   //n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; ++i) {
		is_prime[i] = true;
	}
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) {
			prime[p] = i;
			p++;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

int main() {
	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}
void chmax(ll &a,ll b){	if(a<b) a = b ;}
void chmin(ll &a,ll b){ if(a>b) a = b ;}

int main(){
    ll d,s,t ;
    cin >> d >> s >> t ;
    yorn(d<=s*t) ;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2<<11;
int dp[15][MAXN];
int ha[15][15];
int a[15];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int t;
        scanf("%d",&t);
        while(t--){
            int x;  scanf("%d",&x);
            ha[i][x]=1;
        }
    }
    for(int i=1;i<=m;i++)   scanf("%d",&a[i]);
    for(int i=0;i<=(1<<10)-1;i++)   dp[0][i]=1;
    for(int i=1;i<=m;i++){
        for(int j=0;j<=(1<<n)-1;j++){
            int cnt=1,ans=0,k=j;
            while(k){
                if(k&1){
                    if(ha[i][cnt])  ans++;  ///若第cnt开关打开时，并且能够控制第i盏灯，则ans++
                }
                k>>=1;   cnt++;
            }
            if(ans%2 == a[i] && dp[i-1][j])   dp[i][j]=1;///当前开关数量与灯亮的条件一致时，并且上一盏灯能够亮时
        }
    }
    int sum=0;
    for(int i=0;i<=(1<<10)-1;i++)
        if(dp[m][i])    sum++;  ///统计当所有灯亮起来时，开关的组合情况。
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;

public class AtCoder_150_C
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int num = int.Parse(Console.ReadLine());
        int[] p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int[] q = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        int pIndex = 0;
        int qIndex = 0;

        bool[] pChecked = new bool[num + 1];
        bool[] qChecked = new bool[num + 1];

        for (int i = 0; i < num; i++)
        {
            pChecked[p[i]] = true;
            int pCurrentIndex = 0;
            for (int j = 1; j < p[i]; j++)
            {
                if (pChecked[j] == false) pCurrentIndex++;
            }
            int pGap = 1;
            for (int j = 1; j < num - i; j++)
            {
                pGap *= j;
            }
            pIndex += pGap * pCurrentIndex;

            qChecked[q[i]] = true;
            int qCurrentIndex = 0;
            for (int j = 1; j < q[i]; j++)
            {
                if (qChecked[j] == false) qCurrentIndex++;
            }
            int qGap = 1;
            for (int j = 1; j < num - i; j++)
            {
                qGap *= j;
            }
            qIndex += qGap * qCurrentIndex;
        }

        Console.WriteLine(Math.Abs(pIndex - qIndex));
    }
}


Measured memory_bytes: 13396
/**
 *      ABC 87 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-01 05:07:23
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C, X; cin >> A >> B >> C >> X;

    int count = 0;
    for (int i = 0; i <= A; ++i) {
        for (int j = 0; j <= B; ++j) {
            for (int k = 0; k <= C; ++k) {
                if (500 * i + 100 * j + 50 * k == X){
                    ++count;
                }                
            }            
        }        
    }

    cout << count << endl;

    return 0;
}

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

int main()
{
  long long int n;
  std::cin >> n;

  auto v = std::vector<long long int>{};
  long long int a;
  while (std::cin >> a)
  {
    v.push_back(a);
  }

  auto sum = std::accumulate(v.begin(), v.end(), static_cast<long long int>(0));
  auto max = *std::max_element(v.begin(), v.end());
  auto min = *std::min_element(v.begin(), v.end());
  printf("%d %d %lld\n", min, max, sum);

  return 0;
}



Measured memory_bytes: 3388
import itertools
n, k=map(int, input().split())
a=list(map(int, input().split()))
a.insert(0, 0)

ary=[0]
for i in range(1,n+1):
    ary.append((a[i]+1)/2)

cumsum=itertools.accumulate(ary)
ary2=list(cumsum)
ans=0

for i in range(n-k+1):
    tmp=ary2[i+k]-ary2[i]

    if tmp > ans:
        ans=tmp

print(ans)

Measured memory_bytes: 25152