akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

typedef pair<int, int> P;
const int N = 705;
int e[N][N];
vector<int> G[N];
int color[N], totc[2];
vector<P> ps;
bool dp[N][N];

void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v, int c) {
	color[v] = c;
	totc[c]++;
	bool ans(true);
    for (int u : G[v]) {
        if (color[u] == -1) {
			ans &= dfs(u, c ^ 1);
        }
		else if (color[u] == c) {
			return false;
		}
    }
    return ans;
}

int coloring(int mv) {
    memset(color, -1, sizeof(color));
    REPU(v, 1, mv) if (!G[v].empty()) {
        if (color[v] < 0) {
			totc[0] = totc[1] = 0;
            if (!dfs(v, 0)) return false;
			ps.push_back(P(totc[0], totc[1]));
        }
    }
    return true;
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	REPU(_, 0, m) {
		int a, b; cin >> a >> b;
		e[a][b] = e[b][a] = 1;
	}
	REPU(i, 1, n + 1) REPU(j, i + 1, n + 1) {
		if (e[i][j] != 1) {
			add_edge(i, j);
		}
	}
	
	if (!coloring(n + 1)) {
		puts("-1"); return 0;
	}

	int rem = n;
	REPU(i, 0, ps.size()) {
		rem -= ps[i].first + ps[i].second;
	}

	MEM(dp, 0);
	REPU(i, 0, rem + 1) dp[i][rem - i] = 1;

	int tot = rem;
	REPU(k, 0, ps.size()) {
		REPU(i, 0, tot + 1) if (dp[i][tot - i]) {
			dp[i + ps[k].first][tot - i + ps[k].second] = 1;
			dp[i + ps[k].second][tot - i + ps[k].first] = 1;
		}
		tot += ps[k].first + ps[k].second;
	}

	int ans = INT_MAX;
	REPU(i, 0, n + 1) if (dp[i][n - i]) {
		amin(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define precise fixed<<setprecision(50)
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll it = 0; it < n; it++)    cin>>a[it];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

ll n, dp[MX][2];	vvll g;
ll calc(ll i, ll pi, bool allowed){
	if(dp[i][allowed] != -1)	return dp[i][allowed];
	ll w = 1, b = allowed;
	for(auto x : g[i]){
		if(x == pi)	continue;
		w = mop(w, *, calc(x, i, 1));
		if(allowed)	b = mop(b, *, calc(x, i, 0));
	}
	return dp[i][allowed] = mop(w, +, b);
}
int main(){
	init();	fill(dp, -1);
	cin>>n;	g.resize(n+1);
	ll x, y;
	for(ll i = 1; i < n; i++){
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	cout<<calc(1, 0, 1);
}

Measured memory_bytes: 18448
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    vll a(n), s(n+1), t(n+1); 
    s[0] = 0;
    t[0] = 0;
    rep(i, n) {
        cin >> a[i];
        s[i+1] = s[i] + a[i];
        t[i+1] = t[i] ^ a[i];
    }
    
    // 左端 i を固定
    // OK : S_m - S_{i-1} = T_m ^ T_{i-1}
    
    /*
    rep(i, n+1){
        cout << s[i] << " " << t[i] << endl;
    }
    //*/
    
    ll ans = n;
    int i = 0;
    ll tmp = 0;
    
    while(i < n){
        int l = i + tmp - 1; int r = n;

        while(l+1 != r){
            int m = (l+r)/2;
            if(s[m+1] - s[i] == ll(t[m+1] ^ t[i])){
                l = m;
            }else{
                r = m;
            }
        }
        
        tmp = l - i;
        ans += tmp;
        i++;
    }
    
    cout << ans << endl;
    return;
}

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

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

#define ll long long
#define vec vector<ll>
#define rev(a); reverse(a.begin(), a.end());
#define sorta(a); sort(a.begin(), a.end());
#define sortd(a); sort(a.begin(), a.end(), greater<int>());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)
#define printarray(a) FOR(Q,0,(int)(a).size()) cout<<(a)[Q]<<" "; cout<<'\n';
#define pb push_back
#define mp make_pair

ll MOD = 1000000007;
ll INF = 1LL << 60;

/*****************************************************************************/


void solve() {
	
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;cin>>s;
	int n=s.length();
	bool good=false;
	FOR(i,0,n) {
		if (s[i]=='7') good=true;
	}
	if (good) {
		cout<<"Yes";
	} else {
		cout<<"No";
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
//const int MOD=(ll)1e10+7;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n>>m;
  int ans=0;
  for(int i=n;i<=m;i++){
    string t=to_string(i);
    string tt="";
    for(int i=(int)t.size()-1;i>=0;i--)tt+=t[i];
    if(t==tt)ans++;
  }
  print(ans);
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
    return 0;
}






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

int main()
{
	int X, Y;
	cin >> X >> Y;

	string ans = "No";
	for( int t = 0; t <= X; t++ ) {
		int k = X - t;
		if( t * 2 + k * 4 == Y ) ans = "Yes";
	}

	cout << ans << endl;
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0183

"""
import sys
from sys import stdin
input = stdin.readline


def solve(board):
    colors = ['b', 'w']
    for c in colors:
        for y in range(3):
            if board[y].count(c) == 3:
                return c
        for x in range(3):
            if board[0][x] == c and board[1][x] == c and board[2][x] == c:
                return c
        if board[0][0] == c and board[1][1] == c and board[2][2] == c:
            return c
        if board[0][2] == c and board[1][1] == c and board[2][0] == c:
            return c
    return 'NA'


def main(args):
    while True:
        temp = input().strip()
        if temp[0] == '0':
            break
        board = []
        board.append(list(temp))
        board.append(list(input().strip()))
        board.append(list(input().strip()))
        result = solve(board)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

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

int myTop = 0;
int myData[110] = { 0 };
void push(int x)
{
	myData[++myTop] = x;
}
void pop()
{
	--myTop;
}
int top()
{
	return myData[myTop];
}

int main()
{
	char chIn[1000] = { '\0' };
	int nTemp = 0;
	int na = 0, nb = 0;

	while (scanf("%s", chIn) != EOF)
	{
		if (chIn[0] - '0' <= 9 && chIn[0] - '0' >= 0)
		{
			nTemp = atoi(chIn);
			push(nTemp);
		}
		else
		{
			nb = top();
			pop();
			na = top();
			pop();
			switch (chIn[0])
			{
			case '-':
				push(na - nb);
				break;
			case '+':
				push(na + nb);
				break;
			case '*':
				push(na * nb);
				break;
			}
		}
	}
	printf("%d\n", top());
	return 0;
}


Measured memory_bytes: 2080
class DisjointSet
	def initialize(n)
		@parent = Array.new(n){-1}
	end
	def find(a)
		return a if @parent[a]<0
		@parent[a] = find(@parent[a])
	end
	def union(a, b)
		x = find(a)
		y = find(b)
		return x if x == y
		if size(x) < size(y)
			t = x
			x = y
			y = t
		end
		@parent[x] += @parent[y]
		@parent[y] = x
		x
	end
	def size(a)
		-@parent[find(a)]
	end
end

N,M=gets.split.map(&:to_i)
ds=DisjointSet.new(N)
M.times{
	a,b=gets.split.map(&:to_i)
	ds.union(a-1,b-1)
}
r=0
(1 .. N-1).each{|i|
	if ds.find(i)!=ds.find(0)
		ds.union(i,0)
		r+=1
	end
}
puts r


Measured memory_bytes: 15060
#include <iostream>

int main()
{
	int n, q;
	
	std::cin >> n;
	int *S = new int[n];
	for (int i=0; i<n; i++) std::cin >> S[i];
	
	std::cin >> q;
	int *T = new int[q];
	for (int i=0; i<q; i++) std::cin >> T[i];
	
	int count = 0;
	for (int i=0; i<q; i++) {
		int lower = 0;
		int upper = n-1;
		while (lower < upper) {
			if (lower + 1 == upper) {
				if (S[lower] == T[i] || S[upper] == T[i]) count++; 
				break;
			}	
			int mid = (lower + upper) / 2;
			if (S[mid] == T[i]) {
				count++; break;
			}
			else if (S[mid] < T[i]) lower = mid;
			else upper = mid;
		}
	}
	
	std::cout << count << std::endl;
	
	delete[] S;
	delete[] T;
	
	return 0;
}




Measured memory_bytes: 3280
#include<stdio.h>
#include<string.h>
int main()
{
  int i,j,count=0;
  char w[10],t[1000];
  scanf("%s",w);
  int len=strlen(w);
  for(i=0;i<len;i++){
    if(w[i]<='Z' && t[i]>='A')w[i]+=32;
  }
  while(scanf("%s",t)){
    if(strcmp(t,"END_OF_TEXT")==0)break;
    int len=strlen(t);
    for(j=0;j<len;j++){
      if(t[j]<='Z' && t[j]>='A')t[j]+=32;
      
    }
    if(strcmp(w,t)==0)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<int> arr;

    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        arr.insert(p);
    }

    if (n == arr.size())
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct UnionFind{
	vi data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
	int Size(int i){
		return -data[Find(i)];
	}
};

struct Edge{
	int src,dst,weight;
	Edge(){}
	Edge(int s,int d,int w):src(s),dst(d),weight(w){}
};
typedef vector<vector<Edge>> Graph;
bool operator<(const Edge& a,const Edge& b){return a.weight<b.weight;}
bool operator>(const Edge& a,const Edge& b){return a.weight>b.weight;}

int Kruskal(int n,vector<Edge> es,vi& forest)
{
	UnionFind uf(n);
	int res=0;
	rep(i,es.size()){
		Edge e=es[i];
		if(uf.Unite(e.src,e.dst)){
			res+=e.weight;
			forest.push_back(i);
		}
	}
	return res;
}

int main()
{
	for(int n,m;cin>>n>>m && n|m;){
		vector<Edge> edges;
		rep(i,m){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			edges.emplace_back(u,v,w);
		}
		sort(all(edges));
		
		vi cands;
		const int sum=Kruskal(n,edges,cands);
		
		int cnt=0,bsum=0;
		for(int ci:cands){
			Edge candidate=edges[ci];
			vector<Edge> backup=edges;
			edges[ci].weight=INF;
			sort(all(edges));
			
			int weight=0;
			UnionFind uf(n);
			for(Edge e:edges)
				if(uf.Unite(e.src,e.dst))
					weight+=e.weight;
			if(weight>sum){
				cnt++;
				bsum+=candidate.weight;
			}
			
			swap(edges,backup);
		}
		cout<<cnt<<' '<<bsum<<endl;
	}
}

Measured memory_bytes: 2444
#include <algorithm>
#include <cstdlib>
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<cstdio>
using namespace std;
int N;
int main(int argc, char const *argv[])
{
cin>>N;
vector<int> a(N);
for(size_t i=0;i<a.size();i++){
    cin>>a[i];
}
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
int alice=0;
int bob=0;
for(size_t i=0;i<a.size();i++){
    if(i%2==0){
        alice+=a[i];
    }else{
        bob+=a[i];
    }
}
cout<<alice-bob<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

ll N,numbers[100000]; 

ll fn(ll result,ll sum,ll i,bool nextflug){
	if(i==N)
		return result;
	else
		sum+=numbers[i];
	
	if(sum!=0&&(sum>0)==nextflug){
		return fn(result,sum,i+1,!nextflug);
  }else{
		if(nextflug)
			return fn(result+abs(sum)+1,1,i+1,!nextflug);
		else
			return fn(result+abs(sum)+1,-1,i+1,!nextflug);
	}  
}

int main(void){
  cin>>N;
  REP(i,N) cin>>numbers[i];
  
  if(numbers[0]==0)
    print(min(fn(1,1,1,false),fn(1,-1,1,true)));
  else
    print(min(fn(0,0,0,true),fn(0,0,0,false)));
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	string s;
	cin >> s;
	int k;
	cin >> k;

	ll dp_t[4] = { 0 };
	ll dp_f[4] = { 0 };

	dp_t[1] = 1;
	dp_f[1] = s[0] - '1';

	REP(i, 1, s.length()) {
		RREP(j, 1, k) dp_f[j + 1] += dp_f[j] * 9;
		dp_f[1] += 9;

		if (s[i] != '0') {
			REP(j, 1, k + 1) dp_f[j] += dp_t[j];
			REP(j, 1, k) dp_f[j + 1] += dp_t[j] * (s[i] - '1');

			RREP(j, 1, k) dp_t[j] = dp_t[j - 1];
		}
	}

	cout << dp_f[k] + dp_t[k] << "\n";

	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<long long> a(n+1);
    vector<long long> b(n);
    for (int i = 0;i <= n;i++){
        cin >> a.at(i);
    }
    for (int i = 0;i < n;i++){
        cin >> b.at(i);
    }
    long long ans = 0,k;
    for (int i = 0;i < n;i++){
        k = min(a.at(i),b.at(i));
        ans += k;
        a.at(i) -= k;
        b.at(i) -= k;
        k = min(b.at(i),a.at(i+1));
        ans += k;
        a.at(i+1) -= k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string S; cin>>S;
  for(int i=0;i<S.size();i++){
    if((i+1)%2!=0){
      cout<<S[i];
    }
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 512
#!/usr/bin/env python3
"""
Simple Version
Python TLE https://atcoder.jp/contests/dp/submissions/14906600
PyPy TLE https://atcoder.jp/contests/dp/submissions/14906630
"""
from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)


def solve(N, M, edges):
    longest = [-1] * (N + 1)
    for i in range(N + 1):
        if not edges[i]:
            longest[i] = 0

    def get_longest(start):
        ret = longest[start]
        if ret != -1:
            return ret

        next_edges = edges.get(start)
        if not next_edges:
            ret = 0
        else:
            ret = max(get_longest(v) for v in edges[start]) + 1
        longest[start] = ret
        return ret

    return max(get_longest(v) for v in edges)


def main():
    N, M = map(int, input().split())
    edges = defaultdict(set)
    for i in range(M):
        v1, v2 = map(int, input().split())
        edges[v1].add(v2)

    print(solve(N, M, edges))


main()


Measured memory_bytes: 213724
#include <stdio.h>
#include <stdlib.h>
 
 
int main()
{
    int n,i,x;
    scanf("%d %d",&n,&x);
    long long ans=0,sum,a,b;
    scanf("%lld",&a); //第一个 盒子中的糖果个数
    if(a>x)   // x 是最后每个盒子要剩余的个数，  如果第一个盒子的糖果个数a大于x
    {
       ans+=a-x;  //  ans 是多出的个数
       a=x; 
    }
 
    for( i=1; i<n; i++) //剩下的 n-1 个盒子
    {
        scanf("%lld",&b);  
        sum=a+b;
        if(sum>x)
        {
            ans+=sum-x;
            a=b-sum+x;   
        }
        else a=b;       
    }                   
    printf("%lld",ans); // 
    return 0;
}


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

const int MAXN=1e5+10;
ll a[MAXN], dp[MAXN][2], b[MAXN];
int n;

ll solve(void){
    ll sum=0, ans=0;
    ans=a[0];
    bool flag;
    if(ans>0) flag=true;
    else flag=false;
    for(int i=1; i<n; i++){
    ans+=a[i];
    if(flag){
        if(ans>=0){
            sum+=ans+1;
            ans=-1;
        }
        flag=false;
    }else{
        if(ans<=0){
            sum+=abs(ans)+1;
            ans=1;
        }
        flag=true;
    }
  }
  return sum;
}

int main(void){
    ll ans=0, sum1=0, sum2=0;
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
    }
    int cnt=a[0];
    sum1=a[0]>0?0:abs(a[0])+1;
    if(a[0]<=0) a[0]=1;
    sum1+=solve();
    sum2=cnt<0?0:cnt+1;
    if(cnt<0) a[0]=cnt;
    else a[0]=-1;
    sum2+=solve();
    ans=min(sum1, sum2);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

const int N_MAX = 10050;
vector<int> c;
vector<vector<int>> a(N_MAX);
vector<int> v_sc(N_MAX);
vector<bool> visited(N_MAX);
void bfs(int v){
    queue<int> q;
    q.push(v);
    int it = 0;
    visited[0] = true;
    while(!q.empty()){
        int nq = q.front(); q.pop();
        for(int next: a[nq]){
            if (visited[next]) continue;
            visited[next] = true;
            q.push(next);
        }
        //cout << nq <<":" <<it << endl;
        v_sc[nq] = c[it++];
    }

}

int main()
{
    int n;
    cin >> n;
    rep(i, n-1){
        int tmp1, tmp2; cin >> tmp1 >> tmp2;
        tmp1--; tmp2--;
        a[tmp1].push_back(tmp2);
        a[tmp2].push_back(tmp1);
    }
    rep(i, n) { 
        int tmp;  cin >> tmp; c.push_back(tmp);
    }
    sort(c.begin(), c.end(), greater<int>());
    bfs(0);
    
    int c_sum = 0;
    rep1(i, n-1){
        c_sum += c[i];
    }

    cout << c_sum << endl;
    rep(i, n){
        cout << v_sc[i] << " "; 
    }
    cout << endl;
}



Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var k int
	var s string
	con.Scan(&k, &s)
	n := len(s)
	a := 0
	p25 := make([]int, k+1)
	p26 := make([]int, k+1)
	p25[0] = 1
	p26[0] = 1
	for i := 1; i <= k; i++ {
		p25[i] = p25[i-1] * 25
		p25[i] %= mod
		p26[i] = p26[i-1] * 26
		p26[i] %= mod
	}
	c := combmod(n+k-1, n-1)
	for i := 0; i <= k; i++ {
		x := c
		x *= p26[i]
		x %= mod
		x *= p25[k-i]
		x %= mod
		a += x
		a %= mod
		if i < k {
			c *= powmod(n+k-i-1, mod-2)
			c %= mod
			c *= k - i
			c %= mod
		}
	}
	fmt.Println(a)
	return nil
}

const mod = 1e9 + 7

func powmod(a, m int) int {
	b := 1
	for m > 0 {
		if m&1 != 0 {
			b = b * a % mod
		}
		a = a * a % mod
		m >>= 1
	}
	return b
}

func combmod(n, r int) int {
	c := 1
	for i := 0; i < r; i++ {
		c *= n - i
		c %= mod
		c *= powmod(i+1, mod-2)
		c %= mod
	}
	return c
}


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


int main() {
	int i, j, k;
//	long long int l = 0;
	int m, g = 0, n, q, b, c, d, e;
	int f = 0;
	int buka[1100000] = {0};

	scanf("%d", &n);

	for (i = 1;i < n;i++) {
		scanf("%d", &m);
		buka[m] = buka[m] + 1;
	}

	for (i = 1;i < n+1;i++) {
		printf("%d\n", buka[i]);
	}

	

	return 0;
}

Measured memory_bytes: 6028
n=int(input())
T=0
H=0
for i in range(n):
    card_t,card_h=input().split()
    if card_t==card_h:
        T+=1
        H+=1
    else:
        if card_h>card_t:
            H+=3
        else:
            T+=3
print(T,H)


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

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> city(N);
	for(int i = 0; i < 2*M; i++){
		int road;
		cin >> road;
		city.at(road-1)++;
	}
	for(int i = 0; i < N; i++)
		cout << city.at(i) << endl;

	return 0;
}

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


void solve(std::vector<std::string> s){
    for(ll i=0; i< 3; i++){
        cout<< (char)(s[i].at(0)-'a'+'A');
    }
    cout << endl;
}

int main(){
    std::vector<std::string> s(3);
    for(int i = 0 ; i < 3 ; i++){
        std::cin >> s[i];
    }
    solve(std::move(s));
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#include<sstream>
#include<time.h>

#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define MEM(a) memset(a, 0, sizeof(a))
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
#define endl "\n"
#define eps 1e-8
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+10;
void FAST(){ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}
const ll mod =  998244353;

int n, m, k;
ll a, b, c;

void solve()
{
    scanf("%lld%lld.%lld", &a, &b, &c);
    b = b*100+c;
    a = a*b;
    a /= 100;
    printf("%lld\n", a);
}

int main()
{
//    FAST();
//    init();
//    int _;scanf("%d", &_); while(_--)
//    while(scanf("%d", &n)&&n)
//    while(scanf("%d%d%d", &n, &m, &k)&&(n+m+k))
    solve();
    return 0;
}


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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if((((W-x)>=r) && (x>=r)) && (((H-y)>=r) && (y>=r)))
    {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3108
#include <algorithm>
#include <array>
#include <climits> // INT, LONG, LLONG, UINT, ULONG, ULLONG
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

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

    vector<bool> m;
    for (int i = 1; i <= N; i++) {
        int p;
        cin >> p;
        m.push_back(i == p ? true : false);
    }

    int count = 0;

    for (int i = 0; i < N; i++) {
        if (m[i]) {
            count++;
            if (i + 1 < N && m[i + 1])
                i++;
        }        
    }

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


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

int main () {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    int other = 0, sum = 0, max = 0;
    for (int i = 0; i < N; i++) {
        cin >> m.at(i);
        sum += m.at(i);
        max++;
    }
    other  = X - sum;
    sort(m.begin(), m.end());
    while (other >= m.at(0)) {
        max++;
        other -= m.at(0);
    }
    cout << max << endl;
}

Measured memory_bytes: 256
n,k,q=map(int,input().split())
x=[0]*n
answer=[]
for i in range(q):
  a=int(input())
  x[a-1]+=1
y=sum(x)
for j in range(n):
  if y-x[j]<k:
    answer.append("Yes")
  else:
    answer.append("No")
for s in answer:
  print(s)

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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pl;

ld const PI = 4*atan((ld)1);

int const N = 1e5 + 7;

int ar[107];
bool win[N] = {};
int main()
{
	fastio;

	int n, k;
	cin >> n >> k;

	win[0] = true;
	for (int i = 0; i < n; ++i)
	{
		cin >> ar[i];
		win[ar[i]] = true;
	}

	for (int i = 1; i <= k; ++i)
	{
		for (int j = 0; j < n && ar[j] <= i; ++j)
		{
			win[i] |= !win[i - ar[j]];
		}
	}

	cout << (win[k] ? "First\n" : "Second\n");
	return 0;
}


Measured memory_bytes: 3668
#-*- coding:utf-8 -*-
"""
xy平面上に正方形があり、4つの頂点の座標は反時計回りに順番に(x1,y1),(x2,y2),(x3,y3),(x4,y4)です。
なお、x軸は右向きに、y軸は上向きに取ることにします。
高橋君は、これら4つの座標のうち(x3,y3),(x4,y4)を忘れてしまいました。
x1,x2,y1,y2が与えられるので、x3,y3,x4,y4を復元してください。なお、これらの条件から、
x3,y3,x4,y4は一意に存在し、整数となることが証明できます。
"""
import numpy as np


def get_vector(x1, y1, x2, y2):
    a = np.array([x1, y1])
    b = np.array([x2, y2])
    vector = b - a

    return vector


def get_rotation_matrix(rad):
    """
    指定したradの回転行列を返す
    """
    rot = np.array([[np.cos(rad), -np.sin(rad)],
                  [np.sin(rad), np.cos(rad)]])
    return rot


def main(str):
    coodinate = str.split()

    # 標準入力された座標を整数値として読み込み
    x1 = int(coodinate[0])
    y1 = int(coodinate[1])
    x2 = int(coodinate[2])
    y2 = int(coodinate[3])

    # ABvector(仮)を求める
    vector1 = get_vector(x1, y1, x2, y2)
    # 回転行列を求める
    rotate_matrix = get_rotation_matrix(np.pi/2)
    # BCvector(仮)を求める
    vector2 = np.dot(rotate_matrix, vector1)

    x3 = int(round(vector2[0] + x2))
    y3 = int(round(vector2[1] + y2))
    x4 = int(round(vector2[0] + x1))
    y4 = int(round(vector2[1] + y1))

    print(x3, y3, x4, y4)


if __name__ == "__main__":
    main(input())

Measured memory_bytes: 14236
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, K;
int X, Y; char C;

int cnt[4005][4005];
int sum[4005][4005];

int main(){
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    cin >> X >> Y >> C;
    if (C == 'W') Y += K;
    X %= 2 * K; Y %= 2 * K;
    X++; Y++;

    cnt[X][Y]++;
    cnt[X + 2 * K][Y]++;
    cnt[X][Y + 2 * K]++;
    cnt[X + 2 * K][Y + 2 * K]++;
  }

  for (int i = 1; i <= 4 * K; i++){
    for (int j = 1; j <= 4 * K; j++){
      sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
      sum[i][j] += cnt[i][j];
    }
  }

  int ans = 0;
  for (int i = 1; i <= 2 * K; i++){
    for (int j = 1; j <= 2 * K; j++){
      int now = sum[i+K][j+K] - sum[i][j+K] - sum[i+K][j] + sum[i][j];
      now += sum[i+2*K][j+2*K] - sum[i+K][j+2*K] - sum[i+2*K][j+K] + sum[i+K][j+K];
      ans = max(ans, now);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 128652
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>

using namespace std;
const int mod = 1e9 + 7;

int main() {
	int n, k; cin >> n >> k;
	vector<int> dp(k + 2, 0);
	dp[0] = 1;

	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		vector<int> seg(k + 2, 0);	
		for (int used = k; used >= 0; used--) {
			int L = used + 1;		//+1 since adding nothing doesn't yield a new way
			int R = min(k, used + a);
			if (L > R) { continue; }
			seg[L] += dp[used]; seg[L] %= mod;
			seg[R + 1] -= dp[used]; seg[R + 1] %= mod;
		}
		for (int i = 1; i <= k; i++) {
			seg[i] += seg[i - 1]; seg[i] %= mod;
			dp[i] += seg[i]; dp[i] %= mod;
		}
	}

	cout << (dp[k]+mod)%mod << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }

    ll ans = sum;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] < 0) {
            a[i] *= -1;
            a[i+1] *= -1;
            sum += 2 * a[i];
            sum += 2 * a[i+1];
        }
        ans = max(sum, ans);
    }

    for (int i = n; i >= 1; i--) {
        if (a[i] < 0) {
            a[i] *= -1;
            a[i-1] *= -1;
            sum += 2 * a[i];
            sum += 2 * a[i-1];
        }
        ans = max(sum, ans);
    }
    
    printf("%lld\n", ans);

}

Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
#define P pow(4,j++)
main(){
  int i,j,n,c; char m[7],o,d[314159];
  for(i=0,scanf("%d %s",&n,m);i<n;i++,scanf("%s",m)){
    for(j=c=o=0;o!='\n';scanf("%c",&o))
      if(o=='A')c+=1*P;
      else if(o=='C')c+=2*P;
      else if(o=='G')c+=3*P;
      else if(o=='T')c+=4*P;
    m[0]=='i'?d[c]=1:(d[c]?printf("yes\n"):printf("no\n"));
  }
  return 0;
}

Measured memory_bytes: 496
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var (
	s  string
	t  string
	dp [3100][3100]float64
)

func main() {
	sc.Split(bufio.ScanWords)

	ss := strings.Split(nextLine(), "")
	tt := strings.Split(nextLine(), "")

	// DPループ
	for i := 0; i < len(ss); i++ {
		for j := 0; j < len(tt); j++ {
			if ss[i] == tt[j] {
				chmax(&dp[i+1][j+1], dp[i][j]+1)
			}
			chmax(&dp[i+1][j+1], dp[i+1][j])
			chmax(&dp[i+1][j+1], dp[i][j+1])

		}
	}

	var res string

	for i, j := len(ss), len(tt); i > 0 && j > 0; {
		// (i-1, j) -> (i, j)と更新されていた場合
		if dp[i][j] == dp[i-1][j] {
			i-- // dpの遷移を遡る
		} else if dp[i][j] == dp[i][j-1] {
			// (i, j-1) -> (i, j)と更新されていた場合
			j-- // dpの遷移を遡る
		} else {
			// (i-1, j-1) -> (i, j)と更新されていた場合
			res = ss[i-1] + res
			i--
			j--
		}

	}

	fmt.Println(res)

}

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


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


Measured memory_bytes: 21844
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not(cards[i][j]):
            print(n2s[i], j+1)

Measured memory_bytes: 7676
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;

    char mins = *min_element(s.begin(), s.end());
    char maxs = *max_element(s.begin(), s.end());

    char mint = *max_element(t.begin(), t.end());
    char maxt = *max_element(t.begin(), t.end());

    if((mins < maxt) ||
        (s.size() < t.size() && maxs == mint)){
        cout << "Yes" << endl;
        return 0;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int n,m;
    cin >> n >> m;
    int s[m];char c[m];
    rep(i,0,m){cin >> s[i] >> c[i];}
    ll ans = -1;
    rep(i,0,1000){
        string num = to_string(i);
        if(num.length()!=n){continue;}
        bool ok = true;
        rep(j,0,m){
            if(num[s[j]-1] != c[j]){ok = false;}
        }
        if(ok) {ans = i ; break;}
    }
    if(ans>=0){cout << ans;}else{cout << -1;}
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from collections import Counter

def main():
    N, M = LI()
    XY = []
    for _ in range(M):
        XY.append(LI_())
    balls = [1] * N
    exp = set([0])
    for x, y in XY:
        balls[x] -= 1
        balls[y] += 1
        if x in exp:
            exp.add(y)
            if balls[x] == 0:
                exp.remove(x)
    ans = len(exp)
    return ans

print(main())

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

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")

#define fi first
#define se second

using namespace std;

using ll=long long;
using ld=long double;

int main()
{
    int n,w;
    scanf("%d%d",&n,&w);
    vector<pair<int,int>> x(n);
    for(auto &i:x)
        scanf("%d%d",&i.se,&i.fi);
    const ll inf=-1;
    vector<ll> dp(w+1,inf);
    dp[0]=0;
    for(auto &i:x)
        for(int j=w;j>=i.se;--j)
            if(dp[j-i.se]>=0)
                dp[j]=max(dp[j],dp[j-i.se]+i.fi);
    ll res=0;
    for(auto &i:dp)
        res=max(i,res);
    printf("%lld\n",res);
}



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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  Solver(LL n) : n(n){};

  void solve() {
    for(int i=1; i<1000; ++i){
      if((n*i)%360==0){
        cout << i << endl;
        return;
      }
    }
  }
};
class Solver2 {
 public:
  int n, m;
  Solver2(LL n, LL m) : n(n), m(m){};

  void solve() {
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;

  vector<int64_t> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());

  int ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (l[i] != l[j] && l[j] != l[k] && l[i] + l[j] > l[k]) {
          ++ans;
        }
      }
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<sstream>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	rep(i, n) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int answer = v[v.size() / 2] - v[v.size() / 2 - 1];
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,k;
	int ans=0;
	cin >>n>>k;
	Vi a(n);
	Vi b(n, 0);
	cin >> a;
	rep(i,k){
		rep(I, n) { b[I] = 0; }
		rep(j, n) {
			
			b[max(0, j - a[j])]++;
			if(j+a[j]<= n-2){
				b[j + a[j]+1]--;
			}
		}
	//	clog << b << endl;
		rep(I, n) {
			if (I == 0) continue;
			b[I] += b[I - 1];
		}
	//	clog << b << endl;
		if (a == b) break;
		a = b;
	}
	rep(i, n) { cout << a[i]; 
	if(i!=n-1){
		cout << " ";
	}
	
	}
	cout << endl;
}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 1000001;
const int MOD =1000000007;
const int INV2 = (MOD+1)/2;



     signed main(){
 int n;
 cin>>n;
 pair<int,int> p[n];int ax[n];
 for(int i=0;i<n;i++){
   cin>>ax[i];
   p[i]=make_pair(ax[i],i);
 }
 sort(p,p+n);
 int a,b;
 vector<int> hen[n];
 for(int i=0;i<n-1;i++){
   cin>>a>>b;a--;b--;
   hen[a].push_back(b);
   hen[b].push_back(a);
 }
 bool used[n]={};
 for(int i=0;i<n;i++){
   if(used[p[i].second])continue;
   for(auto&& j: hen[p[i].second])if(ax[j]>p[i].first)used[j]=true;
 }
 
 for(int i=0;i<n;i++)if(used[i])cout<<i+1<<' ';


}


        


Measured memory_bytes: 512
import math
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    f = list(map(int, input().split()))
    a.sort(reverse=True)
    f.sort()
    hi = a[0] * f[-1]
    lo = 0
    def caneat(m):
        t = 0
        for i, j in zip(a, f):
            if i * j > m:
                t += math.ceil((i*j - m)/j)
            if t > k:
                return False
        return True
    while hi != lo:
        m = (hi + lo) // 2
        if caneat(m):
            hi = m
        else:
            lo = m + 1
    return hi
print(main())



Measured memory_bytes: 119500
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int k, x;
  cin >> k >> x;
  if(500*k>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3536
#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(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
const int INF = 1e9;
typedef long long ll;
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> p(m);
    REP(i, m) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.rbegin(), p.rend());
    int ans = 0;
    int delete_bridge_first = INF;
    REP(i, m) {
        if(p[i].second <= delete_bridge_first) {
            delete_bridge_first = p[i].first;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	sort(a.rbegin(), a.rend());
	int s = 0;
	for (auto t : a) s += t;
	{
		int nd = ((s + 4 * m - 1) / (4 * m));
		if (a[m - 1] >= nd) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define prique priority_queue<P,vector<P>,greater<P>>
#define ggr getchar(); getchar();return 0;
using namespace std;
typedef pair<string, ll>P;
P a[114];
string s[114];ll ss[114];
signed main() {
	ll n,ans;
	cin>>n;
	rep(i,n)cin>>a[i].first>>a[i].second;
	rep(i,n)a[i].second*=-1;
	rep(i,n){
		s[i]=a[i].first;
		ss[i]=a[i].second;
	}
	sort(a,a+n);
	rep(i,n){
		rep(j,n){
			if(a[i].first==s[j]&&a[i].second==ss[j])ans=j+1;
		}
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 256
s = input().split()
 
if int(s[0]) < int(s[1]):
  s1 = int(s[0])
  s2 = int(s[1])
else:
  s1 = int(s[1])
  s2 = int(s[0])
  
result = 0
if (s2-s1) >= 2:
  result = s2*2 - 1
else:
  result = s2 + s1
 
print(result)


Measured memory_bytes: 3060