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

int main(){
    int N;
    cin >> N;
    long x[N], y[N], h[N];
    int able_h = 0;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0){
            able_h = i ;
        }
    }

    for(long i = 0; i <= 100; i++){
        for(long j = 0; j <= 100; j++){
            long H = abs(x[able_h] - i) + abs(y[able_h] - j) + h[able_h];
        
            bool is_ok = true;
            for(int k = 0; k < N; k++){
                if(max(H - abs(x[k] - i) - abs(y[k] - j), 0l) != h[k]){
                    is_ok = false;
                    break;
                }
            }
            if(is_ok){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//????????????????????????????????????
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
struct P {
    ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//??£??\???????????¨???
    ll to, cost;
};
struct S {//???????????±?????\???????????°
    int from, to, cost;
};
struct H {
    int x, y;
};
ll gcm(ll i, ll j) {//?????§??¬?´???°
    if (i > j) swap(i, j);
    if (i == 0) return j;
    return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
    return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad?????§?¨???????2??????????????¢
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int sum=0,l,r,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l>>r;
		sum+=(r-l+1);
	}
	cout<<sum<<endl;
    getchar(); getchar();
}


Measured memory_bytes: 256
#include<iostream>
#define mod 998244353
using namespace std;
int k, n, m, i, j, sol;
int d[2005][2005], c[2005][2005], s[2005][2005], pt[2005], ff[4005], e[4005];
int modul(int x){
    if(x >= mod){
        return x - mod;
    }
    return x;
}
int main(){
    cin>> k >> n;
    c[0][0] = 1;
    pt[0] = 1;
    for(i = 1; i <= k; i++){
        pt[i] = modul(pt[i - 1] * 2);
    }
    for(i = 1; i <= k; i++){
        for(j = i; j <= k; j++){
            ff[i + j]++;
        }
    }
    for(i = 2; i <= k + k; i++){
        for(j = 1; j <= k; j++){
            if(j >= i || j + k < i){
                e[i]++;
            }
        }
    }
    for(i = 1; i <= k; i++){
        c[i][0] = 1;
        for(j = 1; j <= i; j++){
            c[i][j] = modul(c[i - 1][j] + c[i - 1][j - 1]);
        }
    }
    s[0][0] = 1;
    for(i = 1; i <= k; i++){
        s[i][0] = 1;
        for(j = 1; j <= n; j++){
            s[i][j] = modul(s[i - 1][j] + s[i][j - 1]);
        }
    }
    for(i = 2; i <= k + k; i++){
        m = ff[i];
        if(i % 2 == 0){
            m--;
        }
        sol = 0;
        for(j = 0; j <= min(n, m); j++){
            sol += c[m][j] * 1LL * pt[j] % mod * s[j + e[i] ][n - j] % mod;
            sol = modul(sol);
            if(i % 2 == 0 && j < n){
                sol += c[m][j] * 1LL * pt[j] % mod * s[j + e[i] ][n - j - 1] % mod;
                sol = modul(sol);
            }
        }
        cout<< sol <<"\n";
    }
}


Measured memory_bytes: 33024
a=[]#入力画面の二文字を別々の文字に格納
a=input().split(" ")
A=int(a[0])
B=int(a[1])-1

Y=input()#1行に沢山の数値(または文字)が並んでいる場合にリストに格納していく
X=[]
X=list(Y) #数値YをリストXに格納
if X[B]=='A':
    X[B]='a'
elif X[B]=='B':
    X[B]='b'
elif X[B]=='C':
    X[B]='c'

P=''.join(X)
print(P)


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

const double eps = 1e-10;
const int MOD = 1000000007;
const ll INF = 1ll << 50;

void printv(vector<auto> const& s) {
  REP(i, s.size()) {
    cout << s[i] << " ";
  }
  cout << endl;
}

void warshall_floyd(vector<vector<ll>> &g) {
  int n = g.size();
  REP(i, n) {
    REP(j, n) {
      REP(k, n) {
        g[j][k] = min(g[j][k], g[j][i] + g[i][k]);
      }
    }
  }
}

ll res = INF;
vector<bool> used;
void dfs(vector<vector<ll>> &g, vector<int> &r, int c, int las, ll dist) {
  if(c == r.size()) {
    res = min(res, dist);
    return;
  }
  REP(i, r.size()) {
    if(!used[i]) {
      used[i] = true;
      if(las == -1) dfs(g, r, c+1, i, 0);
      else dfs(g, r, c+1, i, dist+g[r[las]][r[i]]);
      used[i] = false;
    }
  }
}

int main () {
  cin.tie(0);
  cout << setprecision(10);
  int n, m, r; cin >> n >> m >> r;
  vector<int> v(r);
  used.resize(r);
  REP(i, r) {
    cin >> v[i];
    v[i]--;
  }
  vector<vector<ll>> g(n);
  REP(i, n) {
    g[i].resize(n);
    REP(j, n) {
      g[i][j] = INF;
    }
  }
  int a, b, c;
  REP(i, m) {
    cin >> a >> b >> c;
    g[a-1][b-1] = c;
    g[b-1][a-1] = c;
  }

  warshall_floyd(g);
  vector<int> tmp;
  dfs(g, v, 0, -1, 0);
  cout << res << endl;
}


Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;
use  std::collections::BTreeMap;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let s: Vec<char> = read::<String>().chars().collect();
    for _ in 0..(s.len()) {
        print!("x");
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll n;
    cin>>n;
    ll i,j;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    string print[3];
    print[0]="pairwise coprime";
    print[1]="setwise coprime";
    print[2]="not coprime";

    mll m;
    ll g=0;
    for(i=0;i<n;i++)
    {
        g=gcd(g,a[i]);
        // cout<<a[i]<<" ";
        for(j=2;j*j<=a[i];j++)
        {
            if(a[i]%j==0)
            {
                m[j]++;
                // cout<<j<<" ";
                while(a[i]%j==0)
                {
                    a[i]/=j;
                }
            }
        }
        if(a[i]>1)
        {
            // cout<<a[i]<<" ";
            m[a[i]]++;
        }
        // cout<<"\n";
    }
    // if(g>1)
    // {
    //     cout<<print[2]<<"\n";
    //     return;
    // }
    ll f=0;
    for(auto it:m)
    {
        // cout<<it.first<<" "<<it.second<<"\n";
        if(it.second>1)
        {
           f=1;
        //    break; 
        }
    }
    if(!f)
    {
        cout<<print[0];
        return;
    }
    if(g==1)
    {
        cout<<print[1];
        return;
    }
    cout<<print[2];

    
}



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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 16256
a, b, c = (int(x) for x in input().split())
if any([a%2==1, b%2==1, c%2==1]) == True:
  print(0)
else:
  if len(set({a, b, c})) == 1:
    print(-1)
  else:
    res = 0
    while all([a%2==0, b%2==0, c%2==0]):
      a, b, c = (b + c)//2, (c + a)//2, (a + b)//2
      res += 1
    print(res)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))

cnt=0

def half(n):
    return n*(1/2)

for i in range(min(a)//2):
    
    tmp=list(filter(lambda x:x%2==0,a))
    if len(tmp)==len(a):
        a=list(map(half,a))
        cnt+=1
    else:
        break
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, k;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n);
    for(auto &i : a) cin >> i;
    while(k--){
        vector <int> b(n + 1);
        for(int i = 0 ; i < n ; i++){
            b[max(0, i - a[i])]++;
            b[min(n, i + a[i] + 1)]--;
        }
        for(int i = 1 ; i < n ; i++){
            b[i] += b[i - 1];
        }
        for(int i = 0 ; i < n ; i++){
            a[i] = b[i];
        }
        bool ok = 1;
        for(auto &i : a){
            if(i != n) ok = 0;
        }
        if(ok) break;
    }
    for(auto &i : a) cout << i << " ";
    cout << endl;
}


Measured memory_bytes: 4908
h, n = [int(_) for _ in input().split()]
l = []
for i in range(n):
    a, b = [int(_) for _ in input().split()]
    l.append((a, b))

dp = [[0 for _ in range(h)] for _ in range(n)]
for i in range(n):
    a, b = l[i]
    for j in range(h):
        if j - a >= 0:
            if i == 0:
                dp[i][j] = dp[i][j-a] + b
            else:
                dp[i][j] = min(dp[i][j-a] + b, dp[i-1][j])
        else:
            if i == 0:
                dp[i][j] = b
            else:
                dp[i][j] = min(b, dp[i-1][j])

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

Measured memory_bytes: 126684
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int a,b;
    cin >> a >> b;
    cout << a * b << " " << 2 * (a + b) << endl;

    return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;
 
void solve(){
	int n,x=0,y=0;
	cin>>n;
	int a[n];
	map<int,int>m1,m2;
	int mx1=-1e8,mx2=-1e8;
	int xx=0,yy=0;
	rep(i,n){
		cin>>a[i];
		if(i & 1){
			x++;
			m1[a[i]]++;
			if(mx1<m1[a[i]]){
				mx1=m1[a[i]];
				xx=a[i];
			}
		}
		else{
			y++;
			m2[a[i]]++;
			if(mx2<m2[a[i]]){
				mx2=m2[a[i]];
				yy=a[i];
			}
		}
	}
	if(xx==yy){
			vi v,vv;
			for(auto it:m2){
				v.pb(it.S);
			}
			sort(all(v));
			for(auto it:m1){
				vv.pb(it.S);
			}
			sort(all(vv));
			cout<<n-mx1-max((sz(v)-2<0?0:v[sz(v)-2]),(sz(vv)-2<0?0:vv[sz(vv)-2]));
	}
	else{
		cout<<x-mx1+y-mx2;
	}
 
}
 
 
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 5888
def main():

    x = int(input())
    x_amari = x%100

    x_100 = x//100
    #print('x_100')
    #print(x_100)

    x_1 = x_amari//1
    x_2 = x_amari//2
    x_3 = x_amari//3
    x_4 = x_amari//4
    x_5 = x_amari//5
    #print('x_5')
    #print(x_5)

    if x_100 >= (x_5+1) or x%105 == 0:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int z[5000+10];
int len;
string s;
void Run(int St){
	string s1;
	int le;
	rb(i,St,len-1) s1+=s[i];
	le=s1.length();
	s1='$'+s1;
	int l_bound=1,r_bound=0;
	rb(i,2,le){
		if(r_bound>=i){
			z[i]=min(z[i-l_bound+1],r_bound-i+1);
			if(z[i]==r_bound-i+1){
				l_bound=i;
				int it=r_bound+1;
				rb(j,z[i]+1,le){
					if(s1[j]!=s1[it]) break;
					z[i]++;
					it++;
				}
				r_bound=z[i]+i-1;
			}
		}
		else{
			l_bound=i;
			int it=i;
			rb(j,1,le){
				if(s1[j]!=s1[it]) break;
				it++;
				z[i]++;
			}
			r_bound=i+z[i]-1;
		}
	}
	St++;
	rl(i,len,St) z[i]=z[i-St+1];
	rep(i,len) z[i]=z[i+1]; 
}
int main(){
	cin>>len>>s;
	int res=0;
	rep(i,len){
		rep(j,len) z[j]=0;
		Run(i);
//		rep(j,len) cout<<z[j]<<" ";cout<<endl;
		rep(j,len){
			res=max(res,min(j-i,z[j]));
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()

int main(){
    ll D;cin>>D;
    vector<int> c(26);rep(i,26)cin>>c[i];
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,D)rep(j,26) cin>>s[i][j];
    rep(i,D) cout<<i%26+1<<endl;
}



Measured memory_bytes: 3684
#include<bits/stdc++.h>
const int maxn = 200200;
const int mod = 998244353;
typedef long long ll;
inline ll pow(ll a,int b,ll ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1) ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline void reduce(int & x){ x += x >> 31 & mod; }
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
int n;
ll x[maxn], y[maxn];
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	int flg1 = 1, flg2 = 1;
	for(int i = 1;i <= n;++i) {
		std::cin >> x[i] >> y[i];
		flg1 &= x[i] + y[i] & 1;
		flg2 &= x[i] + y[i] + 1 & 1;
	}
	if(!flg1 && !flg2) {
		std::cout << - 1 << '\n';
		return 0;
	}
	std::vector<ll> v;
	if(flg2) v.push_back(1);
	for(int i = 30;i >= 0;--i) v.push_back(1ll << i);
	std::cout << v.size() << '\n';
	for(int i : v) std::cout << i << ' ';
	std::cout << '\n';
	for(int i = 1;i <= n;++i) {
		for(ll j : v) {
			if(std::abs(x[i]) > std::abs(y[i])) {
				if(x[i] > 0) x[i] -= j, std::cout.put('R');
				else x[i] += j, std::cout.put('L');
			} else {
				if(y[i] > 0) y[i] -= j, std::cout.put('U');
				else y[i] += j, std::cout.put('D');
			}
		}
		std::cout << '\n';
	}
}


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

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x:vect)
        cout<<x<<" ";
    cout<<"\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
//LCM
int lcm(int a, int b) {  return a * (b / gcd(a, b)); }

//For sort by second
bool cmp(const pair<int,int> &a)
{ return a.first<a.second; }

//Tree
/* const int MAXN = 1e5 + 5;
vector<ll> adj[MAXN];*/

//ModPower
ll modpower(ll a,ll b,ll c)
{
    ll res=1;
    while(b)
    {
        if(b&1LL)
            res=(res*a)%c;
        a=(a*a)%c;
        b>>=1;
    }
    return res;
}

int main()
{
    FASTIO;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll a,b,c,d;
     cin>>a>>b>>c>>d;

     ll num1=a*c;
     ll num2=a*d;
     ll num3=b*c;
     ll num4=b*d;

     cout<<max(max(num1,num2),max(num3,num4))<<"\n";


    
    return 0;
}

Measured memory_bytes: 3648
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#pragma endregion

void solve() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for (int i=0; i<h; i++) {
        cin >> s.at(i);
    }
    vector<vector<int>> ans(h, vector<int>(w, -1));
    vector<bool> straw(h);
    for (int i=0; i<h; i++) straw.at(i) = count(s.at(i).begin(), s.at(i).end(), '#');
    int cur = 1;
    for (int i=0; i<h; i++) {
        if (!straw.at(i)) continue;
        bool f = false;
        for (int j=0; j<w; j++) {
            if (s.at(i).at(j) == '#') {
                if (f) cur++;
                else f = true;
            }
            ans.at(i).at(j) = cur;
        }
        cur++;
    }
    vector<int> a(h);
    for (int i=0; i<h; i++) a.at(i) = i;
    for (int i=1; i<h; i++) if (!straw.at(i)) a.at(i) = a.at(i-1);
    for (int i=h-2; i>=0; i--) if (!straw.at(i)) a.at(i) = a.at(i+1);
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            cout << ans.at(a.at(i)).at(j);
            if (j == w-1) cout << endl;
            else cout << " ";
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<list>
#include<queue>
#define MAX 8
using namespace std;
struct domino{
  int a,b;
  domino():a(0),b(0){}
  domino(int t):a(t/10),b(t%10){}
  void swap(){std::swap(a,b);}
};
bool dfs(list<domino> now, domino ds[], bool vis[], int n, int num){
  if( num == n ){
    /*
for(list<domino>::iterator itl = now.begin();
	itl != now.end(); ++itl){
      cout << '[' << itl->a << ',' << itl->b << "] ";
    }
    cout << endl;
    */
    return true;
  }
  /*
  for(list<domino>::iterator itl = now.begin();
      itl != now.end(); ++itl){
    cout << '[' << itl->a << ',' << itl->b << "] ";
  }
  cout << endl;
  */
  for(int i = 0; i < n; ++i){
    if( !vis[i] ){
      domino t = ds[i];
      
      /*if( t.b == now.front().a ){
	now.push_front( t );
	vis[i] = true;
	if( dfs( now, ds, vis, n, num+1) ) return true;
	vis[i] = false;
	now.pop_front();
      }else if( t.a == now.front().a ){
	t.swap();
	now.push_front( t );
	vis[i] = true;
	if( dfs( now, ds, vis, n, num+1 ) ) return true;
	vis[i] = false;
	now.pop_front();
	}else
      */if( t.b == now.back().b ){
	t.swap();
	now.push_back( t );
	vis[i] = true;
	if( dfs( now, ds, vis, n, num+1 ) ) return true;
	vis[i] = false;
	now.pop_back();
      }else if( t.a == now.back().b ){
	now.push_back( t );
	vis[i] = true;
	if( dfs( now, ds, vis, n, num+1 ) ) return true;
	vis[i] = false;
	now.pop_back();
      }
      //return false;
    }
  }
  return false;
}

bool isConnected(bool adj[][MAX], bool vis[], bool exist[]){
  int st;
  bool ret=true;
  for(int i = 0; i < MAX; ++i){if(exist[i])st=i;vis[i]=false;}
  queue<int> q;q.push(st);
  while(!q.empty()){
    int now=q.front();q.pop();
    //cout << now << endl;
    for(int i = 0; i < MAX; ++i){
      //cout << "NOW : " << now << " to " << i << " : " << adj[now][i] << endl;
      if(adj[now][i]&&!vis[i]){vis[i]=true;q.push(i);}
    }
  }
  for(int i = 0; i < MAX; ++i){
    if(exist[i]){
      //cout << i << " : " << vis[i] << endl;
      if(!vis[i])ret=false;
    }
  }
  //cout << endl;
  return ret;
}

int main()
{
  while(true){
    int n;
    bool ans=false;
    cin >> n;
    if(cin.eof())break;
    int dim[MAX]={0,};
    bool exist[MAX]={false,};
    bool vis[MAX];
    bool adj[MAX][MAX] = {{false,}};
    for(int i = 0; i < n; ++i){
      int t;cin>>t;
      exist[t/10]=exist[t%10]=true;
      adj[t/10][t%10]=adj[t%10][t/10]=true;
      dim[t/10]++;dim[t%10]++;
    }
    int even=0;
    int odd=0;
    for(int i = 0; i < 7; ++i){
      if( exist[i] ){
	//cout << i << " : " << dim[i] << endl;
	if(dim[i]%2==0)++even;
	else odd++;
      }
    }
    if( isConnected(adj,vis,exist) && (odd == 0 || odd == 2) ) ans = true;

    if( ans )puts("Yes");
    else puts("No");
  }
  return 0;
}

Measured memory_bytes: 0
/*
#include "stdafx.h"
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<complex>

*/
#include<bits/stdc++.h>

#define X real()
#define Y imag()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define FastF freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
#define Fast cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0)
using ll = long long;
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vi::iterator vii;
typedef vector<ll> vl;
typedef vl::iterator vli;
typedef long double C;
typedef complex<C> P;
const int INF = 1e9 + 5;
const ll INFF = 1e18 + 5;
const int M = 1e9 + 7;
const double pi = acos(-1);

int main()
{
	//FastF;
	Fast;
	int h, w;
	cin >> h >> w;
	vector<vi> dp(h + 1, vi(w + 1, 0));
	dp[1][0] = 1;
	for (int i = 1; i <= h; ++i) {
		string row;
		cin >> row;
		for (int j = 1; j <= w; ++j) {
			if (row[j - 1] == '#') continue;
			dp[i][j] = (dp[i - 1][j] % M + dp[i][j - 1] % M) % M;
		}
	}
	cout << dp[h][w] << '\n';
	return 0;
}

Measured memory_bytes: 4224
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int K = s.nextInt();
        String str = s.next();

        if (str.length() <= K) System.out.print(str);
        else System.out.print(str.substring(0, K) + "...");
    }
}

Measured memory_bytes: 38628
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<x<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
ll mod=1e9+7;
using namespace std;
int main(){
    boost;
    int n;
    cin>>n;
    cout<<(ll)n*n*3;
 
    
 
 
 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    while (1) {
		int N; cin >> N;
		if (N==0) break;
		vector<int> A(N);
		rep(i,N) cin >> A[i];

		sort(all(A));
		int ans = 1e9;
		rep(i,N-1) chmin(ans,A[i+1]-A[i]);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3228
//AC済 バチャ用再提出
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n + 1); rank.resize(n + 1); diff_weight.resize(n + 1);
        for (int i = 1; i <= n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    //cout.precision(10);
    UnionFind<int> field;
    int n, m;
    cin >> n >> m;
    field.init(n);
    for(int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        if(field.issame(l, r)){
            if(field.diff(l, r) != d){
                cout << "No" << endl;
                return 0;
            }
            continue;
        }
        field.merge(l, r, d);
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))

int main() {
  long x,t;
  cin>>x>>t;
  cout << max(x-t,0L);
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		var d = ria();
		Console.WriteLine(d.Sum() % 24);
	}

	public Sol(){
		
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e6 + 10; 

int fact[N];

ll power(ll x, ll y){
   ll ans=1;
   if(y==1) return x%MOD;
   x=x % MOD,y=y % (MOD-1);
   while(y){
      if(y & 1) ans = (ans*x) %MOD;
      x *= x;
      x = x % MOD;
      y >>= 1;
   }
   return ans;
}
 
ll inv(ll x){
   return power(x,MOD-2);
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int x,y;
   cin >> x >> y;
   fact[0] = 1;
   f(i,1,N){
      fact[i] = fact[i-1]*i;
      fact[i] = fact[i]%MOD;
   }
   if(2*x-y<0 or 2*y-x<0){
      cout << "0\n";
      return 0;
   }
   int a = 2*x-y;
   int b = 2*y-x;
   int ans = 0;
   if(a%3==0 and b%3==0){
      a = a/3;
      b = b/3;
      ans = fact[a+b];
      ans = ans*inv(fact[b]);
      ans = ans%MOD;
      ans = ans*inv(fact[a]);
      ans = ans%MOD;
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef long double ld;
//----head----
int data[200005];
ll pre[200005];
ll _abs(ll a)
{
	return a>0?a:-a;
}
int main()
{
	int n;
	scanf("%d",&n);
	rep(i,1,n+1)scanf("%d",&data[i]);
	rep(i,1,n+1)pre[i]=pre[i-1]+data[i];
	ll mi=8e18;
	rep(i,1,n)
	{
		ll l=pre[i],r=pre[n]-pre[i],ans=_abs(l-r);
		if(ans<mi)mi=ans;
	}
	printf("%lld\n",mi);
	return 0;
}


Measured memory_bytes: 2560
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

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

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for ni in range(n):
     print(" ".join([str(s) for s in C[ni]]))

Measured memory_bytes: 8992
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int H, A;

    std::cin >> H >> A;
    
    if (H % A ==- 0)
        return H / A;
    else
        return H / A + 1;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if (b % a == 0)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#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 ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
int n, k, c;
int dp[L], dp1[L];
string s;
ll solve(int i)
{
	if(i>=n)return 0;
	if(dp[i] != -1)return dp[i];
	if(s[i] == 'o')dp[i] = max(1+solve(i+c+1), solve(i+1));
	else dp[i] = solve(i+1);
	return dp[i];
}
ll solve1(int i)
{
	if(i<0)return 0;
	if(dp1[i] != -1)return dp1[i];
	if(s[i] == 'o')dp1[i] = max(1+solve1(i-c-1), solve1(i-1));
	else dp1[i] = solve1(i-1);
	return dp1[i];
}
void fff()
{
	init(dp,-1);
	init(dp1,-1);
	cin >> n >> k >> c;
	cin >> s;
	solve(0);
	solve1(n-1);
	int cur = 0;
	FOR(i,0,n)
	{
		if(s[i] == 'o')
		{
			cur = 0;
			if(i)cur = dp1[i-1];
			if(i!=n-1)cur += dp[i+1];
			if(cur < k)cout<<i+1<<ln;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 15892
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9;
#define LINF = 1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << = << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

void input(vector<int> x, auto n){
   rep(i,n)cin >> x[i];
}

int main(){

    int n;
    cin >> n;

    for(int i = 1; i <= n; i++){
        int x = i;
        bool f = 1;
        if(x%3 == 0)cout << " " << i;
        else do{
            if(x%10 == 3){
                cout << " " << i;
                f = 0;
            }
            x /= 10;
        }while(x && f);
    }
    cout << endl;

}


Measured memory_bytes: 3092
#include<stdio.h>
#define MAX 5000
void cal(void);
int A;
int v[MAX][MAX];
 
main(){
  int a,b,k,i,j,p,q;
  
  scanf("%d",&A);
  for(i = 0;i < A;i++){
    scanf("%d%d",&q,&p);
    for(j = 0;j < p;j++){
    scanf("%d",&b);
    v[q-1][b-1] = 1;
    }
    }
  cal();
  return 0;
}
 
void cal(void){
  int i;
  int j;
for(i = 0;i < A;i++){
    for(j = 0;j <A-1; j++){
      printf("%d ",v[i][j]);
    }
    printf("%d\n",v[i][j]);
  }
}

Measured memory_bytes: 1008
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000
#define INF_LL 9223372036854775806

typedef long long ll;

int G;

ll length[10000];

class edge{
public:
    int fromid;
    int toid;
    int m;
    int len;
    
    edge(int from){
        len = 0;
        fromid = from;
        INPUT(toid);
        INPUT(m);
    }
    
    bool operator < (const edge &e) const {
        return len < e.len;
    }
};

//??§?????????????????????????????????????????§??????????????\?????????
priority_queue<edge> PQ;
vector<vector<edge> > eList;

void dijkstra(int i, ll len){
    if(length[i] != INF_LL) return;
    
    //1.??????????????¢????¢????
    PQ.pop();
    length[i] = len;
    
    //2.?¨??????????????£????????´?
    REP1(k,eList[i].size()){
        if(length[i] != INF_LL){
            eList[i][k].len = -length[i] - eList[i][k].m;
            PQ.push(eList[i][k]);
        }
    }
    
    //3.?¬?????¨??????????????¢?????????????
    while (PQ.size() != 0 && length[PQ.top().toid] != INF_LL) {
        PQ.pop();
    }
    
    //4.?????£????????????
    if (PQ.size() != 0) {
        dijkstra(PQ.top().toid, -PQ.top().len);
    }
}

int main(){
    INPUT(G);
    REP1(i,G){
        vector<edge> list;
        eList.push_back(list);
        length[i] = INF_LL;
        INT(from);
        INT(k);
        REP1(j,k){
            edge e(from);
            eList[i].push_back(e);
        }
    }
    PQ.push(eList[0][0]);
    
    dijkstra(0,0);
    
    REP1(i,G){
        printf("%d %lld\n",i,length[i]);
    }
    
    return 0;
}

Measured memory_bytes: 19920
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim];

int main(){
    lld n = sc();
    lld times = (n + 999) / 1000;
    prL(times * 1000 - n);
    return 0;
}


Measured memory_bytes: 3824
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define ll long long
ll ans;
int K,A,B;
int main()
{
	scanf("%d%d%d",&K,&A,&B);
	if(A>=K)return printf("%d\n",K+1),0;
	if(A>=B)return printf("%d\n",K+1),0;
	int t=K-A+1;
	ans=(ll)(t>>1)*(B-A)+(t&1)+A;
	printf("%lld\n",max(K+1ll,ans));
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, k, i, h;
	int count = 0;

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

	for (i = 0; i < n; i++) {
		scanf("%d", &h);
		if (h >= k) {
			count++;//入力された身長がKcm以上ならカウントする
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())
#define bit(i) (1LL<<i)
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

void dfs(const vector<vector<int>> &tree, const vector<LLI> &c, int cur, int par, int &i, vector<LLI> &ret){
  ret[cur] = c[i];

  for(auto next : tree[cur]){
    if(next == par) continue;
    dfs(tree, c, next, cur, ++i, ret);
  }
}

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

  int N;
  while(cin >> N){
    vector<vector<int>> tree(N);

    REP(i,N-1){
      int a,b; cin >> a >> b;
      --a, --b;
      tree[a].push_back(b);
      tree[b].push_back(a);
    }

    vector<LLI> c(N); cin >> c;
    sort(RALL(c));
    
    LLI ans = 0;

    vector<LLI> a(N);

    {
      int i = 0;
      dfs(tree, c, 0, -1, i, a);
    }
    
    REP(i,N){
      for(auto j : tree[i]){
	if(i>j){
	  ans += min(a[i], a[j]);
	}
      }
    }

    cout << ans << endl;
    join(cout, ALL(a));
  }
  
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
using namespace std;
int main()
{
    int n,m,l;
    scanf("%d%d%d",&n,&m,&l);
    int A[n][m],B[m][l];
    long long int c[n][l];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<l;j++)
        c[i][j]=0;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            scanf("%d",&A[i][j]);
        }
    }
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<l;j++)
        {
            scanf("%d",&B[i][j]);
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            for(int k=0;k<l;k++)
            {
                c[i][k]+=A[i][j]*B[j][k];
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<l-1;j++)
        {
            printf("%lld ",c[i][j]);
        }
       printf("%lld\n",c[i][l-1]);
    }

    }



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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;


int numLen(int K) 
{ 
    if (K % 2 == 0 || K % 5 == 0) 
        return -1; 
  
    int number = 0; 
  
    int len = 1; 
  
    for (len = 1; len <= K; len++) { 
        number = (number * 10 + 7) % K;
        if (number == 0) 
            return len; 
    } 
  
    return -1; 
} 

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    int k;
    cin>>k;
    cout<<numLen(k)<<endl;
}

Measured memory_bytes: 3628
n = int(input())
s = input() #sys.stdin.readlineは最後が改行

rcount = 0
rmargin = 0
lcount = 0
lmargin = 0
for i in range(n):
    if s[i] == ')':
        if rmargin ==0: rcount +=1
        else: rmargin -= 1
    else: rmargin +=1

    if s[-1-i] == '(':
        if lmargin ==0: lcount +=1
        else: lmargin -= 1
    else: lmargin +=1

ans = '('*rcount + s + ')'*lcount
print(ans)


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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    vector<int> dp(n+1, 50000);
    dp[0] = 0;
    dp[1] = 1;

    vector<int> c(m);
    REP(i, m) {
        cin >> c[i];
    }

    REP(i, n+1) {
        REP(j, m) {
            if (i >= c[j])
                dp[i] = min(dp[i], dp[i-c[j]]);
        }

        dp[i] += 1;
    }
    
    cout << dp[n]-1 << endl;
}


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

int getDiff(char ch1, char ch2)
{
	if(ch1 == 'R')
	{
		if(ch2 == 'G')
		{
			return 2;
		}
		return 1;
	}
	else if(ch1 == 'G')
	{
		if(ch2 == 'R')
				return 2;
		return 0;
	}
	else
	{
		if(ch2 == 'R')
				return 1;
		return 0;
	}

}

int main()
{	
	int n; cin >> n;
	string s; cin >> s;
	vector<vector<int>> v(3);
	int index = 0;
	for(auto& ch : s)
	{
		if(ch == 'R')
		{
			v[0].push_back(index);
		}
		else if(ch == 'G')
		{
			v[1].push_back(index);
		}
		else
		{
			v[2].push_back(index);
		}
		++index;
	}

	long long int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		for(int j = i+1; j < n-1; j++)
		{
			if(s[i] != s[j])
			{
				
				int num = getDiff(s[i], s[j]);
				
				auto it = upper_bound(v[num].begin(), v[num].end(), j);
				if(it != v[num].end())
				{
					
					int counts = (v[num].end() - it);
					
					auto it2 = find(it, v[num].end(), j + j - i);
					if(it2 != v[num].end())
							counts--;
					ans += counts;
					
				}
			}
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 3636