akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define N ((ll)301*1000)
#define MOD ((ll)1e9+7)

ll r,c,n,x[2][N],y[2][N];
vector <pair<ll,ll> > v[4];
bool mark[N];

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>r>>c>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[0][i]>>y[0][i]>>x[1][i]>>y[1][i];
		if(((x[0][i]!=0 && x[0][i]!=r) && (y[0][i]!=0 && y[0][i]!=c)) || ((x[1][i]!=0 && x[1][i]!=r) && (y[1][i]!=0 && y[1][i]!=c)))
		{
			n--;i--;
			continue;
		}
		for(int t=0;t<2;t++)
		{
			if(x[t][i]==0)v[0].push_back({y[t][i],i});
			else if(y[t][i]==c)v[1].push_back({x[t][i],i});
			else if(x[t][i]==r)v[2].push_back({-y[t][i],i});
			else v[3].push_back({-x[t][i],i});
		}
	}
	for(int i=0;i<4;i++)sort(v[i].begin(),v[i].end());
	stack <ll> s;
	for(int i=0;i<4;i++)
		for(auto u:v[i])
		{
			if(mark[u.second] && s.top()!=u.second)return cout<<"NO\n",0;
			if(!mark[u.second])s.push(u.second),mark[u.second]=1;
			else s.pop();
		}
	cout<<"YES\n";
	return 0;
}

Measured memory_bytes: 11752
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int a,b;
		String op=null;
		Scanner scan = new Scanner(System.in);
		
		while(true){
			a=scan.nextInt();
			op=scan.next();
			b=scan.nextInt();	
			if(op.equals("?"))
				break;
			
			switch(op){
				case "+":
					System.out.println(a+b);
					break;
				case "-":
					System.out.println(a-b);
					break;
				case "*":
					System.out.println(a*b);
					break;
				case "/":
					System.out.println(a/b);
					break;
			}
		}
	}
}


Measured memory_bytes: 26404
#include<stdio.h>
#define M 500000
#define SEN 2000000000

void merge(int *,int,int ,int,int);

void mergesort(int *, int,int,int);

int data = 0;
int main(){
  int suzi;

  int S[M],i;
  
  scanf("%d",&suzi);
  for(i = 0;i < suzi;i++){scanf("%d",&S[i]);
  }
  mergesort(S,suzi,0,suzi);

  for(i = 0;i < suzi;i++){
    
    printf("%d",S[i]);
    if(i != suzi-1){
      printf(" ");
    }
    
  }
  printf("\n");
  
  printf("%d\n",data);
  return 0;
}


void merge(int S[],int n,int left,int mid,int right){
  int L[M],R[M];
  
  
  int n1 = mid - left;
  int n2 = right - mid;
  
  for(int i = 0;i < n1;i++){
    L[i] = S[left + i];
    
  }
  for(int i = 0;i < n2;i++){
    R[i] = S[mid + i];
  }
  L[n1] = R[n2] = SEN;
  int i = 0,j = 0;
  for(int k = left;k<right;k++){
    data++;
    
    if(L[i] < R[j]){
      S[k] = L[i++];
      
    }else{
      
      S[k] = R[j++];
    }
  }
}


void mergesort(int S[],int n,int left,int right){
  if(left+1<right){int mid = (left + right)/2;
    mergesort(S,n,left,mid);
    mergesort(S,n,mid,right);
    merge(S,n,left,mid,right);
  }
}




Measured memory_bytes: 5616
from decimal import Decimal
N, K = map(int, input().split())


def Cal(N, K):
    if N < K:
        pro = Decimal(0)
        for n in range(1, N+1):
            for j in range(0, K):
                n = n * 2
                if n >= K:
                    break
            pro += (Decimal(1) / Decimal(N * 2**(j+1)))
        return pro
    else:
        pro = Decimal(N-K+1) / Decimal(N)
        for n in range(1, K):
            for j in range(0, K):
                n = n * 2
                if n >= K:
                    break
            pro += (Decimal(1) / Decimal(N * 2**(j+1)))
        return pro


ans = Cal(N, K)
print(ans)

Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

const ll INF = 3000000000005;

void rundp(int i, int j, vector<vector<ll>> &dp, int n, const vector<ll> &v) {
    if(dp[i][j] != -INF)
        return;
    if(i + j == n) {
        dp[i][j] = 0;
        return;
    }

    rundp(i + 1, j, dp, n, v);
    rundp(i, j + 1, dp, n, v);

    dp[i][j] = max(v[i + 1] - dp[i + 1][j], v[n - j] - dp[i][j + 1]);
}

int main() {
    ios::sync_with_stdio(false);

    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);

    int n;
    cin >> n;
    vector<ll> v(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        cin >> v[i];

    vector<vector<ll>> dp(n + 2, vector<ll> (n + 2, -INF));
    rundp(0, 0, dp, n, v);

    cout << dp[0][0];

    return 0;
}


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

using namespace std;

int dp1[1000001];
int dp2[1000001];

int const INF = 1<<29;

int main() {
    fill(dp1, dp1+1000001, INF);
    fill(dp2, dp1+1000001, INF);
    
    dp1[0] = dp2[0] = 0;
    
    for(int i=1;;i++) {
      int n = i*(i+1)*(i+2)/6;
      if(n>1000000) break;
      for(int j=n; j<=1000000; j++) {
	dp1[j] = min(dp1[j], dp1[j-n]+1);
	if(n%2) {
	  dp2[j] = min(dp2[j], dp2[j-n]+1);
	}
      }
    }
    
  int N;
  while(cin >> N && N) {
    cout << dp1[N] << ' ' << dp2[N] << endl;
  }
  return 0;
}

Measured memory_bytes: 8972
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	long long a,b,c;
	long long x[3];
	cin>>a>>b>>c;
	x[0] = a;
	x[1] = b;
	x[2] = c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		cout<<0<<endl;
	}
	else{
		sort(x,x+3);
		cout<<x[0]*x[1]<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#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(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    int x = 0;
    rep(i,n)
    {
        if (s[i] == 'I')
        {
            x ++;
            ans = max(ans, x);
        }
        else
        {
            x--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
x = []
y = []
for _ in range(n):
    line = list(map(int, input().split()))
    x.append(line[0])
    y.append(line[1])
if n >= 2:
    slope = []
    for i in range(n):
        for j in range(n):
            if i != j:
                X = x[j] - x[i]
                Y = y[j] - y[i]
                slope.append([X, Y])
    cnt = []
    for i in slope:
        cnt.append(slope.count(i))
    print(n - max(cnt))
else:
    print(1)

Measured memory_bytes: 42428
#include<stdio.h>
int main(void){
    int i,n,temp,d,mx,mn;
    scanf("%d",&n);
    mx=-1;
    mn=1000000000;
    for(i=0;i<n;i++){
        scanf("%d",&temp);
        if(temp>mx){
            mx=temp;
        }
        if(mn>temp){
            mn=temp;
        }
    }
    printf("%d\n",mx-mn);
    return 0;
}




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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;






int main() {
	
	int n;
	cin >> n;

	VLL v(n);
	REP(i, n) {
		cin >> v[i];
	}
	sort(ALL(v));

	ll ans = 0;
	REP(i, n)ans ^= v[i];

	if (ans == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1000000000000000001LL;

ll add(ll a,ll b){
  if(a+b>INF)return INF;
  else return a+b;
}
int main(){
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll ab=A-B;
  if(K%2==0)cout<<ab<<endl;
  else cout<<-ab<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

X,Y,A,B,C=list(map(int, input().split()))
p = np.array(list(map(int, input().split())))
q = np.array(list(map(int, input().split())))
r = np.array(list(map(int, input().split())))
p_sort = np.sort(p)[-X:]
q_sort = np.sort(q)[-Y:]
pq_xy=np.concatenate([p_sort, q_sort], 0)
pqr=np.concatenate([r, pq_xy], 0)
pqr_sort = np.sort(pqr)[-X-Y:]
print(np.sum(pqr_sort))

Measured memory_bytes: 24856
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i,a,b) for(register int i=(a);i<=(b);i++)
#define down(i,a,b) for(register int i=(a);i>=(b);i--)
#define mem(x,y) memset(x,(y),sizeof x)
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d",&a)
#define scl(a) scanf("%I64d",&a)
#define scs(a) scanf("%s",a)
#define pr(a,b) printf("%d%c",a,b)
#define prl(a,b) printf("%I64d%c",a,b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(),v.end()

typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int> V;

char a[110],b[110],c[110];
int main() {
	int n,ans=0;
	sc(n);
	scs(a),scs(b),scs(c);
	up(i,0,n-1){
		set<char>s;
		s.clear();
		s.insert(a[i]);
		s.insert(b[i]);
		s.insert(c[i]);
		
		ans+=s.size()-1;
	}
	pr(ans,'\n');
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (l, r) = readLine()!!.split(' ').map(String::toInt)
    if (r - l >= 2018) {
        println(0)
    } else {
        var min = 2019
        for (i in l..r) {
            for (j in l until i) {
                val po = (i % 2019) * (j % 2019) % 2019
                min = Math.min(min, po)
            }
        }
        println(min)
    }
}


Measured memory_bytes: 38208
let pick_up_max l =
	match l with
		| [] -> failwith "Empty list"
		| e :: es ->
			let rec loop max acc = function
				| [] -> (max, acc)
				| x :: xs ->
					if x > max then loop x (max :: acc) xs
					else            loop max (x :: acc) xs
			in loop e [] es

let rec play cards alice bob =
	if cards = [] then
		alice - bob
	else
		let (max, rest) = pick_up_max cards in
		let alice' = alice + max in
		if rest = [] then
			alice' - bob
		else
			let (max, rest) = pick_up_max rest in
			let bob' = bob + max in
			play rest alice' bob'

let () =
	let _ = read_int () in
	let cards =
		read_line ()
		|> Str.split (Str.regexp " ")
		|> List.map int_of_string
	in print_endline (string_of_int (play cards 0 0))


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    int n;cin>>n;
    int m=52-n;
    map<pair<char,int>,int>M;
    for(int i=0;i<n;i++){
        char c;int x;cin>>c>>x;
        M[mp(c,x)]++;
    }
    for(int i=1;i<=13;i++){
        if(M[mp('S',i)]==0){
            cout<<"S "<<i<<endl;
        }
    }
    for(int i=1;i<=13;i++){
        if(M[mp('H',i)]==0){
            cout<<"H "<<i<<endl;
        }
    }

for(int i=1;i<=13;i++){
        if(M[mp('C',i)]==0){
            cout<<"C "<<i<<endl;
        }
    }

for(int i=1;i<=13;i++){
        if(M[mp('D',i)]==0){
            cout<<"D "<<i<<endl;
        }
    }

    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































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


int main() {
	float x;
	cin >> x;
	if(floor(ceil(x / 1.08) * 1.08)  == x){
		cout << ceil(x / 1.08) << endl;
	} else {
		cout << ":(" << endl;
	}	
 }


Measured memory_bytes: 3740
from sys import stdin
def an(n ,a):
    if n == 1:
        return a
    if n % 2 == 0:
        return an(n - 1, a) * 2
    else:
        return an(n - 1, a) / 3
    
for line in stdin:
    a = float(line)
    print (sum([an(n,a) for n in range(1,11)]))

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

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

const long long MOD = 1000000007;

int main(){
  string s,t;
  int ls,lt;
  cin >> s >> t;
  ls = s.size();
  lt = t.size();
  
  int ans = 1000,c=0;
  
  rep(i,ls-lt+1){
    c=0;
    rep(j,lt){
      if(t.at(j) != s.at(i+j)) c++;
    }
    ans = min(ans,c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>

int main(void){
	std::string input, buf;
	std::stringstream ss;
	int a[3];
	int i, ab, c;
	int Rectangle=0, Diamond=0;
	while(std::cin >> input){
		i=0;
		ss << input;
		while(getline(ss, buf,',')){
			a[i++] = std::atoi(buf.c_str());
		}
		ab = a[0]*a[0] + a[1]*a[1];
		c = a[2]*a[2];
		if(ab==c) Rectangle++;
		if(a[0]==a[1] && ab!=c) Diamond++;

		ss.str("");
		ss.clear(std::stringstream::goodbit);
	}
	std::cout << Rectangle << std::endl << Diamond << std::endl;
	return 0;
}



Measured memory_bytes: 3160
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
M = 10**9 + 7
def get_diffsum(X, M):
  left_sum = sum(X)
  left_count = len(X)
  ans = 0
  for x in X:
    left_sum -= x
    left_count -= 1
    ans += left_sum - left_count * x
    ans %= M
  return ans

print(get_diffsum(X, M) * get_diffsum(Y, M) % M)


Measured memory_bytes: 96764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define chmin(x,y) x = min(x, y)
#define chmax(x,y) x = max(x, y)
#define V vector
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    if (x - (__int128_t)k*d >= 0) {
        printf("%ld\n", x-k*d);
        return 0;
    }

    k -= x / d;
    ll ans;
    if (k%2 == 0) ans = x - x/d * d;
    else ans = d - (x - x/d * d);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3688
s1 = input()
s2 = input()
N,M = len(s1),len(s2)

dp = [ [0]*(M+1) for _ in range(N+1)]
for i in range(N+1):
  dp[i][0] = i

for j in range(M+1):
  dp[0][j] = j

for i in range(1, N+1):
  for j in range(1, M+1):
    if s1[i-1] == s2[j-1]:
      # dp[i][j] = min(dp[i-1][j-1],dp[i-1][j],dp[i][j-1])
      dp[i][j] = dp[i-1][j-1]
    else:
      dp[i][j] = min(dp[i-1][j-1],dp[i-1][j],dp[i][j-1])+1

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


Measured memory_bytes: 41952
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		string s=Console.ReadLine();
		string t=Console.ReadLine();
		var hs=new Dictionary<char,int>();
		var ht=new Dictionary<char,int>();
		string ans="Yes";
		for(int i=0;i<s.Length;i++){
			if(!hs.ContainsKey(s[i])){hs.Add(s[i],1);}
			else{hs[s[i]]++;}
			if(!ht.ContainsKey(t[i])){ht.Add(t[i],1);}
			else{ht[t[i]]++;}
			if(hs[s[i]]!=ht[t[i]]){ans="No";}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 14816
import java.util.*;


public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int ans =1000 - n % 1000;
    if(ans == 1000){
      ans = 0;
    }

    
    
    System.out.println(ans);
    
    scanner.close();
    return;
  }
  
}


Measured memory_bytes: 35684
<?php

fscanf(STDIN, "%d", $n);
$result = 0;

for ($i = 1; $i <= $n; $i++) {
    if ((($i % 3) === 0) or (($i % 5) === 0)) {
        continue;
    }

    $result += $i;
}

echo "{$result}\n";

Measured memory_bytes: 16168
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> adj[],bool vis[],int src,int dp[])
{
    vis[src]=true;
    for(auto x:adj[src])
    {
        if(!vis[x])
        {
            dfs(adj,vis,x,dp);
        }
        dp[src]=max(dp[src],1+dp[x]);
    }
}
int main()
{
    int v,e;
    cin>>v>>e;
    vector<int>adj[v+1];
    int i,j,k;
    int dp[v+1];
    memset(dp,0,sizeof(dp));
    for(i=0;i<e;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    bool vis[v+1];
    memset(vis,false,sizeof(vis));
    for(i=1;i<=v;i++)
    {
        if(!vis[i])
        dfs(adj,vis,i,dp);
    }
    int ans=0;
    for(i=1;i<=v;i++)
    ans=max(ans,dp[i]);
    cout<<ans<<endl;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  int N = S.size();
  bool flag = true;
  for(int i = 0 ; i < N ; i++) { 
        if(S.at(i)!=T.at(i)){
        flag = false;
    } 
  }
  if(flag){
        cout << "Yes" << endl;
  }
  else{
        cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main(){
	
	char a[11];
	char b[11];
	char c[11];
	
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	
	int len1 = strlen(a);
	int len2 = strlen(b);
	int len3 = strlen(c);
	
	if(a[len1-1] == b[0]  &&  b[len2-1] == c[0]){
		printf("YES");
	}
	else{
		printf("NO");
	}
	
	return 0;
}


Measured memory_bytes: 1728
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb push_back
#define fi first
#define se second
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef pair<int,int> pi;
const int N=1005,M=2e5+5;
vector<pi>to[N];
int ans[M];
int dfn[N],low[N],st[N],col[N],tim,top,cnt,n,m;
void tarjan(int u){
	dfn[u]=low[u]=++tim,st[++top]=u;
	for(auto v:to[u])if(!dfn[v.fi])tarjan(v.fi),cmin(low[u],low[v.fi]);
	else if(!col[v.fi])cmin(low[u],dfn[v.fi]);
	if(dfn[u]==low[u])
		for(++cnt;st[top+1]!=u;--top)col[st[top]]=u;
}
int q[M<<3],fr[N],vis[N];
inline int trs(R int &x,R int y){return x==y?0:(x=!x?y:1023,1);}
void bfs(int rt){
	int h=1,t=0,u;
	fp(i,1,n)vis[i]=fr[i]=0;
	for(auto v:to[rt])fr[v.fi]=v.fi,q[++t]=v.fi,vis[v.fi]=1;
	while(h<=t){
		u=q[h++],vis[u]=0;
		for(auto v:to[u])if(v.fi!=rt&&trs(fr[v.fi],fr[u])&&!vis[v.fi])q[++t]=v.fi,vis[v.fi]=1;
	}
	for(auto v:to[rt])ans[v.se]=(fr[v.fi]==1023)^(col[rt]==col[v.fi]);
}
int main(){
//	freopen("testdata.in","r",stdin); 
	scanf("%d%d",&n,&m);
	for(R int i=1,u,v;i<=m;++i)scanf("%d%d",&u,&v),to[u].pb(pi(v,i));
	fp(i,1,n)if(!dfn[i])tarjan(i);
	fp(i,1,n)bfs(i);
	fp(i,1,m)puts(ans[i]?"diff":"same");
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

int main(){
    int n;
    int i, j;
    int temp;
    int operation_flag;
    
    cin >> n;
    
    vector <int> b;
    stack <int> ans;
    
    for(i=0; i<n; i++){
        cin >> temp;
        b.push_back(temp);
    }
    
    for(i=n; i>0; i--){
        operation_flag = 0;
        for(j=i; j>0; j--){
            if(b[j-1] == j){
                ans.push(j);
                b.erase(b.begin()+j-1);
                operation_flag = 1;
                break;
            }
        }
        if(operation_flag == 0){
            break;
        }
    }
    
    if(operation_flag == 1){
        for(i=0; i<n; i++){
            cout<< ans.top() << endl;
            ans.pop();
        }
    } else {
        cout << "-1";
    }
    
    return 0;
}

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


int main(){
    std::string b;
    std::cin >> b;
    int len = 0;
    int max = 0;
    if ((int)b.size() >= 1 && (int)b.size() <= 10){
        for (int i = 0;i < (int)b.size(); i++){
            switch (b[i]) {
                case 'A':
                    len++;
                    break;
                case 'C':
                    len++;
                    break;
                case 'G':
                    len++;
                    break;
                case 'T':
                    len++;
                    break;
                default:
                    len = 0;
                    break;
            }
            if (max <= len){
                max = len;
            }
        }
    }
    std::cout << max;
    return 0;
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion

vector<string> res;
int n;
void dfs(int cnt, string s, char mx)
{
	if (cnt == n)
	{
		res.push_back(s);
		return;
	}
	for (char c = 'a'; c <= mx; ++c)
	{
		if(c==mx)dfs(cnt + 1, s + c, mx + 1);
		else dfs(cnt + 1, s + c, mx);
	}
}

int main()
{
	cin >> n;
	dfs(0, "", 'a');
	for (string x : res)cout << x << endl;
}

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

using namespace std;

int main() {
    int x[6];
    for(int i = 1; i < 6; ++i) {
        cin >> x[i];
        if(x[i] == 0) {
            cout << i << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  vector<int> point(5);
  int k;
  bool ans = true;

  for (int i=0; i<5; i++) cin >> point[i];
  cin >> k;

  for (int i=0; i<5; i++) {
    for (int j=i+1; j<5; j++) {
      if (abs(point[j] - point[i]) > k)
        ans = false;      
    }
  }

  cout << (ans? "Yay!" : ":(") << endl;
}


Measured memory_bytes: 504
import java.util.Scanner;

 class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    //"1~100までの整数を入力してください
  int N = scanner.nextInt();
    if(N % 2 ==0) {
      System.out.println((double)1/2);
    }else{
      System.out.println((double)(N+1)/2/N);
    }
  }
  }

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> A, B;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    long long dp[N][T + 1][2];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= T; j++) {
            dp[i][j][0] = 0;
            dp[i][j][1] = 0;
        }
    }
    for (int j = 0; j <= T; j++) {
        dp[0][j][0] = (j >= A[0] ? B[0] : 0);
        dp[0][j][1] = B[0];
    }
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= T; j++) {
            if (j - A[i] < 0) {
                dp[i][j][0] = dp[i - 1][j][0];
                dp[i][j][1] = max(
                    dp[i - 1][j][1],
                    dp[i - 1][j][0] + B[i]
                );
            } else {
                dp[i][j][0] = max(
                    dp[i - 1][j][0],
                    dp[i - 1][j - A[i]][0] + B[i]
                );
                dp[i][j][1] = max(
                    dp[i - 1][j][1],
                    max(
                        dp[i - 1][j - A[i]][1] + B[i],
                        dp[i - 1][j][0] + B[i]
                    )
                );
            }
        }
    }
    long long ans = 0;
    for (int j = 0; j < T; j++) {
        ans = max(ans, max(dp[N - 1][j][0], dp[N - 1][j][1]));
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
  int N, L;
  cin >> N >> L;
  int sum = L*N + (N-1)*N/2;
  int ans;
  if(1-L<=N && 1-L>=1) ans=sum;
  else if(1-L>N) ans=sum-L-N+1;
  else ans=sum-L;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int rick[256];

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	
	
	
	ins(morty);
	int l = 0;
	int r = morty.size()-1;
	int tmp = 0;
	while(l<r){
		if(morty[l] == morty[r]){
			l++;
			r--;
		}
		else if(morty[l] == 'x'){
			tmp++;
			l++;
		}
		else if(morty[r] == 'x'){
			tmp++;
			r--;
		}
		else {
			out(-1);
			tmp = -1;
			break;
		}
	}
	if(tmp>=0)out(tmp);
	
		















	return 0;
}


Measured memory_bytes: 512
import sys
n = input()
d = [int(i) for i in raw_input().split()]
m = input()
t = [int(i) for i in raw_input().split()]

dd = {}
tt = {}

for ddd in d:
    dd.setdefault(ddd,0)
    dd[ddd] += 1

for ttt in t:
    tt.setdefault(ttt,0)
    tt[ttt] += 1




for search in tt.keys():
    if search in dd:
        if tt[search] > dd[search]:
            
            print 'NO'
            sys.exit()

    else:
        print 'NO'
        sys.exit()

print 'YES'

Measured memory_bytes: 52080
#include <stdio.h>

int main(void){

	int W,H,x,y,r;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end());
#define fill(a,x) memset(a,x,sizeof(a))
#define zero(a) fill(a,0)
#define minus(a) fill(a,-1)
#define dbg(x) cout << #x"=" << x << endl

const int INF=INT_MAX/3;
const int LIMIT=100;

int dx[]={0,-1,0,1};
int dy[]={1,0,-1,0};

ll n,k;
ll ans;

int main(){
  cin>>n>>k;
  ans=1;
  rep(i,n){
    ans=min(2*ans,ans+k);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
*A,=map(int,input().split())
A = sorted(A)

if N == 1:
  print(1)
  exit()

flag = [0]*(10**6+5)
for i in range(N):
  flag[A[i]] = 1

for i in range(N):
  if flag[A[i]] == 0:
    continue
  if i>0 and A[i]==A[i-1]:
    flag[A[i]] = 0
    continue
  for num in range(A[i]*2,A[-1]+1,A[i]):
    flag[num] = 0
  
print(sum(flag))

Measured memory_bytes: 32204
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
using namespace std;
const ld pi=3.14159265358979323;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}
ll MAX(ll a,ll b){return a>b?a:b;}
ll MAX(ll a,ll b,ll c){return max(max(a,b),c);}
ll MIN(ll x,ll  y){return x+y-max(x,y);}
ll MIN(ll x,ll y,ll z){return min(min(x,y),z);}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}







int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt" , "r" , stdin) ;
    freopen("out.txt" , "w" , stdout) ;
    //freopen("error.txt" , "w" , stderr) ;
#endif

ll r;
cin>>r;
cout<<fixed<<setprecision(8)<<2*pi*r;

    return 0;
}

Measured memory_bytes: 3792
N = int(input())
L = input().split()
Lng=0
sumL=0
for i in range(N):
    if Lng<int(L[i]):
        sumL=sumL+Lng
        Lng=int(L[i])
    else:
        sumL=sumL+int(L[i])
    # print("Lng="+str(Lng))
    # print("sumL="+str(sumL))
if Lng<sumL:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B,C,sum1,sum2;
	cin>>A>>B>>C;
	sum1=A-B;
	sum2=C-sum1;
	if(sum2<0)
	sum2=0;
	
	cout<<sum2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <stack>
#include <vector>
#include <utility>
#include <list>
#include <algorithm>
using namespace std;

#define N 100000

class Hash
{
  private:
    list<string> *a;

    unsigned long long getChar(char ch)
    {
        switch (ch)
        {
        case 'A':
            return 1;
        case 'C':
            return 2;
        case 'G':
            return 3;
        case 'T':
            return 4;
        default:
            return 0;
        }
    }

    unsigned long long getKey(string str)
    {
        unsigned long long x = 0;
        for (unsigned int i = 0; i < str.length(); i++)
        {
            x += getChar(str[i]);
            x *= 5;
        }
        return x % N;
    }

  public:
    Hash()
    {
        a = new list<string>[N];
    }

    void insert(string str)
    {
        a[getKey(str)].push_back(str);
    }

    bool find(string str)
    {
        unsigned long long key = getKey(str);
        list<string>::iterator itr = a[key].begin();
        for (; itr != a[key].end(); itr++)
            if (str == *itr)
                return true;
        return false;
    }
};

int main()
{
    Hash H;
    int n;
    cin >> n;
    string str;
    for (int i = 0; i < n; i++)
    {
        //cout << i << "\n";
        cin >> str;
        if (str[0] == 'i')
        {
            cin >> str;
            H.insert(str);
        }
        else if (str[0] == 'f')
        {
            cin >> str;
            if (H.find(str))
                cout << "yes\n";
            else
                cout << "no\n";
        }
    }
}


Measured memory_bytes: 54076
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
using namespace std;

int main() {
	int n, sum=0; cin >> n;
	int tmp = n;
	for (;;) {
		sum += n%10;
		n /= 10;
		if (n < 1)break;
	}
	if (tmp%sum) { cout << "No" << endl; }
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
def abs(x):
    if x >0:
        return x
    else:
        return -x

N = int(input())
t_a = input()
T_A = t_a.split()
T = int(T_A[0])
A = int(T_A[1])
h = input()
H = h.split()
for i in range (0,N):
    H[i] = int(H[i])

p = 0
    
for j in range (1,N):
    if abs(A - (T - 0.006*H[j])) < abs(A - (T - 0.006*H[p])):
        p = j
        
print(p+1)

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

unordered_map<uint32_t, uint32_t> memo;
constexpr uint32_t M = 1e9 + 7;
string K;
uint32_t D;

uint32_t calcMask(uint32_t pos, uint32_t rem, bool checkK)
{
	return pos + (rem << 16) + (checkK ? 1 << 30 : 0);
}

uint32_t calc(uint32_t pos, uint32_t rem, bool checkK)
{
	if (pos == K.size())
	{
		if (rem == 0)
			return 1;
		return 0;
	}
	uint32_t h = calcMask(pos, rem, checkK);
	
	if (memo.count(h))
		return memo[h];

	uint32_t KA = K[pos] - '0';
	uint32_t res = 0;

	for (uint32_t i = 0; i < 10; ++i)
	{
		if (checkK && i == KA)
		{
			res = res + calc(pos + 1, (rem + i)%D, true);
			if (res >= M)
				res -= M;
			break;
		}
		res = res + calc(pos + 1, (rem + i) % D, false);
		if (res >= M)
			res -= M;
	}
	memo[h] = res;
	return res;
}

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	
	cin >> K >> D;
	uint32_t r = calc(0, 0, true);
	cout << (r > 0? r-1 : M-1) << endl;
	return 0;
}


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

int main() {
  int a, b, c;
  int s;
  cin >> a >> b >> c;
  
  s = a * b;
  
  if (s < c) {
    cout << s << endl;
  } else {
    cout << c << endl;
  } 
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll a,b,k;
  cin >> a>>b>>k;
  
  rep(i,k){
    if(i%2==0){
      if(a%2==1) a--;
    b+=a/2;
    a/=2;
    }
    if(i%2==1){
      if(b%2==1) b--;
    a+=b/2;
    b/=2;
    }
  }
   
  cout << a << " " << b << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less   
using namespace __gnu_pbds;  
using namespace std;  
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> set1;
ll find(ll a,ll p[])
{
   //cout<<"find "<<a<<endl;
   if(a==p[a])
   return a;
   else return p[a]=find(p[a],p);

}
void join(ll a,ll b,ll p[],ll sz[])
{
   a=find(a,p);
   b=find(b,p);
   if(a!=b)
   {
      if(sz[a]<sz[b])
      swap(a,b);
      sz[a]+=sz[b];
      p[b]=a;
   }
}
ll power(ll a,ll b,ll mod)
{
   ll res=1;
   while(b>0)
   {
      if(b&1)
      res=(res*a)%mod;
      b=b/2;
      a=(a*a)%mod;
   }
   return res;
}
ll inverse(ll x, ll p)
{
   return power(x,p-2,p);
}
ll hash1(ll x,ll y)
{
   return x+y+x*y;
}
//ll f[200000]={0};
ll mod=1000000007;
/*void ini()
{
   f[0]=1;
   for(ll i=1;i<=200000;i++)
   f[i]=(i*f[i-1])%mod;
}*/



/*ll ncr(ll n,ll r)
{
   ll res=1;
   ll k=f[n];
   ll v=inverse(f[n-r],mod);
   ll u=inverse(f[r],mod);
   ll x=(u*v)%mod;
   k=(k*x)%mod;
   return k;
}*/
/*struct edge
{
   ll from;
   ll to;
};*/
void dfs(ll v,ll vis[],ll dp[][2],vector<ll> adj[])
{
   ll k=adj[v].size();
   dp[v][1]=1;
   dp[v][0]=1;
   for(ll i=0;i<k;i++)
   {
      ll u=adj[v].at(i);
      if(vis[u]==0)
      {
         vis[u]=1;
         dfs(u,vis,dp,adj);
         dp[v][0]=(dp[v][0]*(dp[u][1]+dp[u][0]))%mod;
         dp[v][1]=((dp[v][1])*(dp[u][0]))%mod;
         
      }
      
      
   }
}


int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
   vector<ll> adj[n+1];
   for(ll i=0;i<n-1;i++)
   {
      ll u,v;
      cin>>u>>v;
      adj[u].pb(v);
      adj[v].pb(u);
   }
   ll dp[n+1][2];
   for(ll i=0;i<=n;i++)
   dp[i][0]=dp[i][1]=0;
   ll vis[n+1]={0};
   vis[1]=1;
   dfs(1,vis,dp,adj);
   ll ans=(dp[1][1]+dp[1][0])%mod;
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 14976
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
       int n, r;

       scanf("%d %d", &n, &r);

       if( n >= 10 ) 
              printf("%d\n", r);
       else 
              printf( "%d\n", r + 100 * ( 10 - n ));
       return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    Scd(n);

    static char s[100003][21] = {{}};
    char t[21] = {};
    Rep(i,n){
        Scs(s[i]);
    }
    Scs(t);

    int len = strlen(t);
    int less = 1, great = n+1;
    Rep(i,n){
        Rep(j,len+1){
            if( !t[j] && !s[i][j] ){
                break;
            }
            if( !t[j] ){
                great--;
                break;
            }
            if( !s[i][j] ){
                less++;
                break;
            }
            if( s[i][j] == '?' ){
                if( t[j] == 'z' || t[j] == 'a' ){
                    continue;
                }
                break;
            }else if( s[i][j] > t[j] ){
                great--;
                break;
            }else if( s[i][j] < t[j] ){
                less++;
                break;
            }else{
                continue;
            }
        }
    }

    Repe(i,great+1,less)
        printf ( i == great ? "%d\n" : "%d " , i);


    return 0;
}



Measured memory_bytes: 512
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys
import itertools

import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W, H, N = map(int, readline().split())
Xt = W
Xd = 0
Yt = H
Yd = 0
for _ in range(N):
    x, y, a = map(int, readline().split())
    if a == 1:
        Xd = max(x, Xd)
    elif a == 2:
        Xt = min(x, Xt)
    elif a == 3:
        Yd = max(y, Yd)
    else:
        Yt = min(y, Yt)

print(0 if Xd > Xt or Yd > Yt else (Xt - Xd) * (Yt - Yd))


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

const int N = 3005;
const int MOD = 1e9 + 7;
int dp[N][N], cnt[2];
char s[N], t[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, m; cin >> n >> m >> (s + 1);
    strcpy(t + 1, s + 1); dp[0][0] = 1;
    for (int i = 1; i <= m; i++) {
        int l, r; cin >> l >> r;
        sort(s + l, s + r + 1);
        sort(t + l, t + r + 1, greater <char> ());
    }
    for (int i = 1; i <= n; i++) {
        cnt[0] += s[i] == '0';
        cnt[1] += t[i] == '0';
        for (int j = cnt[1]; j <= cnt[0]; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j) dp[i][j] += dp[i - 1][j - 1];
            if (dp[i][j] >= MOD) dp[i][j] -= MOD;
        }
    }
    int res = 0;
    for (int j = cnt[1]; j <= cnt[0]; j++) {
        res += dp[n][j];
        if (res >= MOD) res -= MOD;
    }
    cout << res << '\n';
}

Measured memory_bytes: 15796
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    int K;
    cin >> N;
    cin >> K;
    int ans = 0;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        ans += min(abs(tmp -K), tmp) * 2;
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L long long
using namespace std;
L a[100005];
int main()
{
	int n,k,Q,x;
	cin >> n >> k >> Q;
	for (int i = 0; i < Q; i++)
	{
		cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] + k - Q>0)cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

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

    int ok = 0, ng = min(a[0], a.back()) + 1;
    while(ng-ok > 1) {
        int mid = (ok+ng)/2;
        vector<int> c(n, 0);
        c[0] = 2*mid;
        for(int i=1;i<n;++i) {
            c[i] = 2 * (a[i-1] - c[i-1]/2);
        }
        if(c[0]/2 + c[n-1]/2 > a[n-1]) {
            ng = mid;
        } else {
            ok = mid;
        }
    }

    b[0] = ok * 2;
    for(int i=1;i<n;++i) {
        b[i] = 2 * (a[i-1] - b[i-1]/2);
    }

    for(int i=0;i<n-1;++i) {
        cout << b[i] << " ";
    }
    cout << b[n-1] << endl;
}


Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b==c || b+c==a || a+c==b)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int MAX_V = 310;

int V;
vector<vector<int>> G(MAX_V);
vector<vector<int>> rG(MAX_V);
vector<int> vs;
vector<bool> used(MAX_V);
vector<int> cmp(MAX_V);

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void dfs(int v){
    used[v] = true;
    
    for(int i=0; i<G[v].size(); i++){
        if(!used[G[v][i]]) dfs(G[v][i]);
    }

    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;

    for(int i=0; i<rG[v].size(); i++){
        if(!used[rG[v][i]]) rdfs(rG[v][i], k);
    }
}

int scc(){
    for(int i=0; i<MAX_V; i++) used[i] = false;
    vs.clear();
    
    for(int v=0; v<V; v++){
        if(!used[v]) dfs(v);
    }

    for(int i=0; i<MAX_V; i++) used[i] = false;
    int k = 0;

    for(int i=vs.size()-1; i>=0; i--){
        if(!used[vs[i]]) rdfs(vs[i], k++);
    }

    return k;
}

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

    int m; cin>>V>>m;
    int n = V;
    for(int i=0; i<m; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        add_edge(a, b);
    }

    scc();

    for(int i=0; i<n; i++){
        vector<int> ans;
        for(int j=0; j<n; j++){
            if(cmp[i] == cmp[j]) ans.emplace_back(j);
        }

        for(int j=0; j<ans.size(); j++){
            cout << ans[j] + 1 << " \n"[j + 1 == ans.size()];
        }
    }

    return 0;
}


Measured memory_bytes: 4252
def solve(i,m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = solve(i+1,m) or solve(i+1,m-S[i])
    return res
    
n = int(input())
S = list(map(int, input().split()))
int(input())
T = list(map(int, input().split()))

for i in T:
    if   i > sum(S):
        print("no")
    else:
        print("yes" if solve(0,i) else "no")


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

int main()
{
    int N;
    cin >> N;
    long long A[N];
    for(int i = 0; i < N; i++)
        cin >> A[i];
    
    long long ans = 0;
    int prev = 0;
    for(int i = 0; i < N; i++)
    {
        if (A[i] == 0)
        {
            prev = 0;
            continue;
        }
        ans += (A[i] + prev) / 2;
        prev = ((A[i] + prev) % 2 == 0)? 0 : 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 100 > (a / 10000) + ((a / 1000) % 10) * 10) a += 100;
	if (b % 100 < (b / 10000) + ((b / 1000) % 10) * 10) b -= 100;
	cout << b / 100 - a / 100 + 1 << endl;
	return 0;
}

Measured memory_bytes: 256