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

#define mid(s,e)        (s+(e-s)/2)
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)	        getline(cin, s)
#define ll              long long
#define ull             unsigned long long
#define dd              double
#define mx 1000005


int main()
{
    //freopen("A.txt","r",stdin);
    //freopen("A.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    ll a;
    cin>>a;
    ll m=a;
    int k=0;
    while(a>0)
    {
        ll r=a%10;
        k+=r;
        a/=10;
    }
    if(m%k==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer :: n,i,r1,r2,b1,b2,c1,c2
integer,allocatable :: a(:),a_l(:),a_r(:),ans(:)

read*, n
allocate(a(n),a_l(n),a_r(n),ans(n))
read*, a(1:n)

a_l(1) = a(1)
a_r(1) = a(n)

do i = 2, n
  b1 = a(i)
  c1 = a_l(i-1)
  b2 = a(n+1-i)
  c2 = a_r(i-1)
  do
    r1 = mod(c1,b1)
    if ( r1 == 0 ) exit
    c1 = b1
    b1 = r1
  end do
  do
    r2 = mod(c2,b2)
    if ( r2 == 0 ) exit
    c2 = b2
    b2 = r2
  end do
  a_l(i) = b1
  a_r(i) = b2
end do

ans(1) = a_r(n-1)
ans(n) = a_l(n-1)

do i = 2, n-1
  c1 = a_l(i-1)
  b1 = a_r(n-i)
  do
    r1 = mod(c1,b1)
    if ( r1 == 0 ) exit
    c1 = b1
    b1 = r1
  end do
  ans(i) = b1
end do

print'(i0)', maxval(ans)

END PROGRAM ATCODER

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

using namespace std;

#define ll              long long int
#define endl            '\n'

static const int maxn = 5000 + 5;

ll A[maxn], B[maxn], C[maxn];

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



      int n;
      cin >> n;
      for (int i = 1; i <= n; i++) cin >> A[i];
      for (int i = 1; i <= n; i++) cin >> B[i];
      for (int i = 1; i < n; i++) cin >> C[i];
      ll sum = 0;
      for (int i = 1; i <= n; i++)
      {
            sum += B[A[i]];
            if (i > 1 && A[i-1] + 1 == A[i]) sum += C[A[i-1]];
            //cerr << i << " " << sum << endl;
      }
      cout << sum << endl;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n; cin >> n;
    vl cnt(n+1, 1);
    for(ll i=2; i<n+1; i++){
        if(cnt[i] > 1) continue;
        for(ll j=i; j<n+1; j+=i){
            int t = j, c = 0;
            while(t % i == 0) c++, t/= i;
            cnt[j] *= c+1;
        }
    }
    ll ans = 0;
    REP(i,1,n+1) ans += i * cnt[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81400
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int n;
vector<LL> x,y;

int check(LL dx,LL dy)
{
  LL cnt = 0;
  REP(i,n) REP(j,n) if(x[i] - x[j] == dx && y[i] - y[j] == dy) ++cnt;
  return cnt;
}

int main(void)
{
  cin >> n;
  x.resize(n);
  y.resize(n);
  REP(i,n) cin >> x[i] >> y[i];
  int answer = n;
  REP(i,n) REP(j,i) {
    answer = min(answer, n - check(x[i] - x[j], y[i] - y[j]));
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import math
n = int(input())
l1 = []
l = []
ans = 0
for i in range(n):
    x,y = map(int,input().split())
    l.append(i)
    l1.append((x,y))
per = permutations(l)
for elm in per:
    for i in range(1,len(elm)):
        x=(((l1[elm[i]][0]-l1[elm[i-1]][0])**2)+((l1[elm[i]][1]-l1[elm[i-1]][1])**2))
        ans+=math.sqrt(x)
ans = ans/(math.factorial(n))
print(ans)

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

namespace contest5
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                //空白で分割する
                var line_origin = Console.ReadLine();

                if (string.IsNullOrEmpty(line_origin))
                {
                    break;
                }
                var line = line_origin.Split();
                //配列の要素、すべてに処理を行う
                var num_array = Array.ConvertAll(line, len => long.Parse(len));

                Array.Sort(num_array);

                //最大公約数
                long max = 0;
                long small = num_array[0];
                long big = num_array[1];
                while (true)
                {
                    long ans = big % small;
                    if (ans == 0)
                    {
                        max = small;
                        break;
                    }
                    else
                    {
                        big = small;
                        small = ans;
                    }

                }
                long min = (num_array[0] * num_array[1]) / max;

                Console.WriteLine("{0} {1}", max.ToString(), min.ToString());
            }
        }
    }
}

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

using namespace std;

string s, t;

set<int> pos[200];

int main() {
	cin >> s >> t;
	for (int i = 0; i < (int)s.size(); i++)
		pos[(int)s[i]].insert(i);

	int at = 0;
	long long ans = 0;
	for (int c : t) {
		if (pos[c].empty()) goto bad;
		auto it = pos[c].lower_bound(at);
		if (it == pos[c].end()) {
			it = pos[c].begin();
			ans += s.size() - at;
			at = 0;
		}
		ans += *it + 1 - at;
		at = *it + 1;
	}
	cout << ans << '\n';
	return 0;

bad:
	cout << "-1\n";
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

struct edge{
  int from, to, cost;
  edge();
  edge(int from, int to, int cost) : from(from), to(to), cost(cost) {}
  friend bool operator<(const edge &e1, const edge &e2){ return e1.cost < e2.cost; }
};
class UnionFind{
  vector<int> parent;
  vector<int> _weight;
  vector<int> rank;
public:
  
  UnionFind(int N) : parent(vector<int>(N)),
                     _weight(vector<int>(N, 1)),
                     rank(vector<int>(N, 0)){
    for(int i = 0; i < N; i++) parent[i] = i;
  }
  
  int find(int x){
    if(x == parent[x]) return x;
    else return parent[x] = find(parent[x]);
  }

  int weight(int x){
    return _weight[find(x)];
  }

  bool same(int x, int y){
    return find(x) == find(y);
  }

  void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]){
      _weight[y] += _weight[x];
      parent[x] = y;
    }else{
      _weight[x] += _weight[y];
      parent[y] = x;
      if(rank[x] == rank[y]) rank[y]++;
    }
  }
};


int main(){
  int n, m;
  while(cin >> n >> m && n + m){
    vector<edge> es;
    
    REP(i, m){
      int f, t, c;
      cin >> f >> t >> c;
      es.push_back(edge(--f, --t, c));
    }
    sort(ALL(es));

    int best = INF;
    REP(l, m){
      UnionFind uf(n);
      REP2(r, l, m){
        uf.unite(es[r].from, es[r].to);
        if(uf.weight(es[r].from) == n){
          best = min(best, es[r].cost - es[l].cost);
          break;
        }
      }
    }
    cout << (best == INF ? -1 : best) << endl;
  }
  return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>



using ll = long long;
const int M = 1000005;

int a[12][12];

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0;i < n;i++) 
		cin >> p[i];
	vector<int> q(n);
	for (int i = 0;i < n;i++)
		cin >> q[i];
	vector<int> cnt(n);
	for (int i = 0;i < n;i++)
		cnt[i] = i + 1;
	map<vector<int>, int> mp;
	do {
		mp[cnt] = mp.size();
	} while (next_permutation(cnt.begin(), cnt.end()));

	cout << abs(mp[p]-mp[q]);

	

}
	

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var o = Input().ToInt();
		var n = o[0];
		var t = o[1];
		var costs = new List<int>();
		for(int i = 0; i < n; i++)
		{
			var p = Input().ToInt();
			if(p[1] <= t)
			{
				costs.Add(p[0]);
			}
		}
		if(costs.Count == 0)
		{
			Console.WriteLine("TLE");
			return;
		}
		costs.Sort();
		Console.WriteLine(costs[0]);
		
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(register int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int dx[]={0,1,-1,0},dy[]={1,0,0,-1};
//const int MOD=;
//const int N=2e5+10;

inline int read(){
	int ww=1,xx=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') ww=-ww;ch=getchar();}
	while(isdigit(ch)){xx=(xx<<1)+(xx<<3)+(ch^48);ch=getchar();}
	return ww*xx;
}

int a,b;

signed main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	cout<<max(max(a*b,a+b),a-b);
	return 0;
}


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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){

    int x;

    cin>>x;

    if(x == 0){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }

    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;

int main(){
	int n;
	cin >> n;
	vector<tuple<string, int, int>> rest(n);
	rep(i, n){
		string city;
		int score;
		cin >> city >> score;
		rest[i] = make_tuple(city, -score, i+1);
	}

	sort(rest.begin(), rest.end());
	for(auto i : rest){
		cout << get<2>(i) << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	int a[1001];
	int y = 0;
	int x = 0;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]%2==0){
			x++;
			if (a[i]%3==0 || a[i]%5==0){
				y++;
			}	
		}
	}	
	if(x == y)
		cout << "APPROVED";	
	else
		cout << "DENIED";
	
	return 0;
}

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

/*座標0を軸としてアリの順番が何匹ずれたかだけを記憶し、順番は考慮せずにアリが存在する位置を計算。
アリが座標0を通るたびにアリの順番をずらす。
位置をソートしたのち、アリがずれた分だけ配列をずらして出力。*/
int main(void){
    int N, L, T, x, w, gap;
    cin >> N >> L >> T;
    vector<int> X;
    rep(i,N){
        cin >> x >> w;
        x += ((w+1) % 3 - 1) * T;
        gap += x / L;
        if(x < 0 && x % L != 0)gap--;
        X.emplace_back(((x % L) + L) % L);
    }
    sort(X.begin(), X.end()); 
    rep(i,N)cout << X[(((gap + i) % N) + N) % N] << endl;
    return 0;
}

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

int main(){
    ll x, n; cin >> x >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    bool jud = true;
    ll cnt = 0;
    while(1){
        jud = true;
        rep(i,n){
            if(x - cnt == a[i]) jud = false;
        }
        if(jud){
            cout << x - cnt << endl;
            return 0;
        }
        jud = true;
        rep(i,n){
            if(x + cnt == a[i]) jud = false;
        }
        if(jud){
            cout << x + cnt << endl;
            return 0;
        }
        cnt++;

    }

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,a[100010];
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> a[i];
	int dp[55][2];
	for(int i = 0;i < 55;i++) dp[i][0] = dp[i][1] = -INF;
	dp[43][0] = 0;
	for(int i = 42;i >= 0;i--){
		int cnt1 = 0;
		for(int j = 0;j < n;j++) cnt1 += ((a[j] >> i) & 1);
		if((k >> i) & 1){
			if(dp[i + 1][0] != -INF){
				chmax(dp[i][1],dp[i + 1][0] + cnt1 * (1ll << i));
				chmax(dp[i][0],dp[i + 1][0] + (n - cnt1) * (1ll << i));
			}
			if(dp[i + 1][1] != -INF){
				chmax(dp[i][1],dp[i + 1][1] + cnt1 * (1ll << i));
				chmax(dp[i][1],dp[i + 1][1] + (n - cnt1) * (1ll << i));
			}
		}else{
			if(dp[i + 1][0] != -INF){
				chmax(dp[i][0],dp[i + 1][0] + cnt1 * (1ll << i));
			}
			if(dp[i + 1][1] != -INF){
				chmax(dp[i][1],dp[i + 1][1] + cnt1 * (1ll << i));
				chmax(dp[i][1],dp[i + 1][1] + (n - cnt1) * (1ll << i));
			}
		}
	}
	cout << max(dp[0][0],dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

vi ans;
vector<vi> g;

void dfs(int u, int x, int p = -1) {
    ans[u] += x;
    for (int v : g[u]) {
        if (v != p) {
            dfs(v, ans[u], u);
        }
    }
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    while(cin >> n >> m){
        ans = vi(n);
        g = vector<vi>(n);
        REP(i, n - 1) {
            int u, v;
            cin >> u >> v; u--; v--;
            g[u].push_back(v);
            g[v].push_back(u);
        }
        REP(i, m) {
            int u, x;
            cin >> u >> x; u--;
            ans[u] += x;
        }
        dfs(0, 0);
        REP(i, n) cout << ans[i] << " \n"[i + 1 == n];
    }
    return 0;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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 () {
  int n;
  cin >> n;
  vv(ll) a(n,v(ll)(n));
  rep(i,n)rep(j,n) cin >> a[i][j];

  vv(ll) dp(n+1,v(ll)(1<<n));
  dp[0][0] = 1;
  rep(i,n) {
    rep(s,1<<n) {
      if (dp[i][s]) {
        rep(j,n) {
          if (bit(s,j) == 0 && a[i][j] == 1) {
            dp[i+1][s^(1<<j)] = (dp[i+1][s^(1<<j)] + dp[i][s])%mod;
          }
        }
      }
    }
  }

  ll ans = dp[n][(1<<n)-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 377216
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int translate(string s) {
    int res = 0;
    int num = 1;
    REP(i, s.size()) {
        if (s[i] == 'm') {
            res += num * 1000;
        }
        if (s[i] == 'c') {
            res += num * 100;
        }
        if (s[i] == 'x') {
            res += num * 10;
        }
        if (s[i] == 'i') {
            res += num * 1;
        }
        num = 1;
        if ('0' <= s[i] && s[i] <= '9') {
            num = s[i] - '0';
        }
    }
    return res;
}

string translate(int n) {
    string res = "";
    string keta = "mcxi";
    for (int i = 0; i < 4; i++) {
        int c = n / pow(10, 3 - i);
        c %= 10;
        if (c > 1) {
            res.push_back(c + '0');
            res.push_back(keta[i]);
        } else if (c == 1) {
            res.push_back(keta[i]);
        }
    }
    return res;
}

void solve(string s1, string s2) {
    //cerr << translate(s1) << " " << translate(s2) << endl;
    cout << translate(translate(s1) + translate(s2)) << endl;
    return;
}

signed main(void) {
    int n, p, m, w, h;
    string s, s1, s2;
    int a, b, c, d;
    while (cin >> n) {
        REP(i, n) cin >> s1 >> s2, solve(s1, s2);
        return 0;
    }
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    vector<int> node(4);
    for(int i = 0; i < 3; i++)
    {
        int a, b; cin>>a>>b;
        a--, b--;
        node[a]++;
        node[b]++;
    }
    int c2=0, c1=0;
    for(int i = 0; i < 4; i++)
    {
        if(node[i]==2)c2++;
        else if(node[i]==1)c1++;
    }
    if(c2==2&&c1==2)puts("YES");
    else puts("NO");

    return 0;
}

Measured memory_bytes: 256
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, k, q;
    readf("%s %s %s", &n, &k, &q);
    readln;
    
    auto cnt = new int[] (n);
    
    foreach (_; 0 .. q) {
        int x;
        readf("%s", &x);
        readln;
        
        cnt[x-1] += 1;
    }
    
    foreach (e; cnt) {
        auto ans = k - (q - e);
        writeln(ans > 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 3964
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int[] C = new int[N];
        int[] S = new int[N];
        int[] F = new int[N];
        for (int i = 0; i < N-1; i++) {
            C[i] = ni();
            S[i] = ni();
            F[i] = ni();
        }
        for (int i = 0; i < N; i++) {
            int time = 0;
            for (int j = i; j < N; j++) {
                // System.out.println(time);
                if(j == N-1) out.println(time);
                else{
                    time = Math.max(time, S[j]);
                    time = time%F[j]==0 ? time : F[j] * (time/F[j] + 1);
                    time = time + C[j];
                }               
            }
        }
 
    }

 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

using namespace std;

int main(void) {
  string S, T;
  int ans = 0;

  cin >> S >> T;

  for (size_t i = 0; i < S.length(); i++) {
    if (S[i] != T[i]) { 
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3816
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}
unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}
int tow(int n) {//2のn乗を求めるらしい
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
	//dominoに借りたやつです
}
/*
  for A以上B未満でI探索 for (int I = A; i <= B; i++)

  string s = to_string(i);　iをstringでsに変換

  char　小文字のほうが32大--------------------大文字と小文字の境=93

  大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[n])

  pow(a,b) → aのb乗を求める

  s1.erase(n) 文字列s1の、n文字目以降削除
  */
int a=0, b=0, c = 0;
string s = "";

int main(void) {
	//vector,set,map,stack,queue,deque,priority_queue

	int n, m;
	cin >> n >> m;
	vint a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
	}
	vint cnt(n, false);
	rep(i, m) {
		if (a[i] == 1)cnt[b[i]]++;
		if (b[i] == n)cnt[a[i]]++;
	}
	rep(i, n) {
		if (cnt[i] >= 2) {
			cout << "POSSIBLE" << rt;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << rt;

	please AC;
}

Measured memory_bytes: 2560
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#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<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n;
ll ans;
ll a[55];
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	while(a[n]>=n){
		ll sol=a[n]/n;
		ans+=sol;
		a[n]%=n;
		for(int i=1;i<=n-1;i++)
		a[i]+=sol;
		sort(a+1,a+n+1);
	}
	cout<<ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ns()
flag = 0
for i in n:
    if i == "9":
        flag = 1
if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int progression(int N){
    return (1+N)*N/2;
}

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

    int diff = b - a;

    cout << progression(diff) - b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int arr[5],k;
    for(int i=0; i < 5; ++i) cin >> arr[i];
    cin>>k;
    sort(arr,arr+5);

    for(int i = 0; i < 4; ++i){
        for(int j = i+1; j < 5; ++j){
            if(abs(arr[i]-arr[j])>k){
                cout << ":(";
                return 0;
            }
        }
    }
    cout << "Yay!";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n= sc.nextInt();
		int[] sarray=new int[13];
		int[] harray=new int[13];
		int[] carray=new int[13];
		int[] darray=new int[13];

		for(int i=0; i<n; i++) {
			char ch = sc.next().charAt(0);
			int num = sc.nextInt();
			if(ch=='S') {
				sarray[num-1]=num;
			}else if(ch=='H') {
				harray[num-1]=num;
			}else if(ch=='C') {
				carray[num-1]=num;
			}else if(ch=='D') {
				darray[num-1]=num;
			}
		}
		for(int i=0; i<13; i++) {
			if(sarray[i]==0) {
				System.out.println("S " + (i+1));
			}
		}
		for(int i=0; i<13; i++) {
			if(harray[i]==0) {
				System.out.println("H " + (i+1));
			}
		}
		for(int i=0; i<13; i++) {
			if(carray[i]==0) {
				System.out.println("C " + (i+1));
			}
		}
		for(int i=0; i<13; i++) {
			if(darray[i]==0) {
				System.out.println("D " + (i+1));
			}
		}
	}
}


Measured memory_bytes: 26236
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
	
	ll num;
	cin >> num;
	//vector<ll> pw(12);
	//pw[0] = 1;
	//for(int i = 1; i < 11;++i){
	//	pw[i] = pw[i-1]*26;
	//}
	string ans = "";
	while(num > 0){
		int k = (--num%26);
		ans += (char)(k + 'a');
		num /= 26;
	}
	reverse(begin(ans), end(ans));
	cout<<ans;

}


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

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

    long long ans = 0;
  vector<long long> vec(N);
  for(int i = 0; i < N;i++) {
      cin >> vec.at(i);

    while(vec.at(i) % 2 == 0) {
        vec.at(i) /= 2;
        ans++;
     }
      
  }

  cout << ans << endl;


}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> day(M);
  for (int i = 0; i < M; i++) {
    cin >> day.at(i);
  }
  int a = 0;
  for (int i = 0; i < M; i++) {
    a += day.at(i);
  }
  int ans;
  ans = N - a;
  if (ans < 0) {
    cout << -1 << endl;
  }
  else {
    cout << N - a << endl;
  }
}

Measured memory_bytes: 3672
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 1000000000
typedef long long int lli;
typedef pair<int,int> P;

int main(){
	int a,b;
	cin >> a >> b;
	vector<int> anna;
	vector<int> bruno;
	for(int i=0; i<a; ++i){
		int tmp;
		cin >> tmp;
		anna.push_back(tmp);
	}
	for(int i=0; i<b; ++i){
		int tmp;
		cin >> tmp;
		bruno.push_back(tmp);
	}
	int ans=0;
	for(int i=0; i<b; ++i){
		int cnt=0;
		for(int j=0; j<a; ++j){
			if(bruno[i+cnt]==anna[j]){
				++cnt;
			}
		}
		ans=max(ans,cnt);
	}
	cout << ans << "\n";
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int N;

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

  cin >> N;
  if (N!=3 && N<5) cout << "No\n";
  else {
    if ((N&1)==0) {
      int x = 0;
      while(((N>>x)&1)==0) ++x;
      int p1 = 1 << x;
      int p2 = N - p1;
      ++p1;
      if (p2==0) {
        cout << "No\n";
        return 0;
      } else {
        cout << "Yes\n";
      }
      cout << p1 << " " << N << "\n";
      cout << p2 << " " << N*2 << "\n";
    } else {
      cout << "Yes\n";
    }
    int M = (N-1)/2;
    rep(i,M*2) cout << 1 << " " << (i+2) << "\n";
    rep(i,M) cout << (i*2+2) << " " << (i*2+3+N) << "\n";
    rep(i,M) cout << (i*2+3) << " " << (i*2+2+N) << "\n";
    cout << M*2+1+N << " " << N+1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 2304
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define min(a,b) ((a)<(b)?(a):(b))
#define reg register
#define file(x) freopen(x".in","r",stdin);freopen(x".out","w",stdout);
#define endfile fclose(stdin);fclose(stdout);
namespace IO{
    char buf[1<<15],*S,*T;
    inline char gc(){
        if (S==T){
            T=(S=buf)+fread(buf,1,1<<15,stdin);
            if (S==T)return EOF;
        }
		return *S++;
    }
    inline int read(){
        reg int x;reg bool f;reg char c;
        for(f=0;(c=gc())<'0'||c>'9';f=c=='-');
        for(x=c^'0';(c=gc())>='0'&&c<='9';x=(x<<3)+(x<<1)+(c^'0'));
        return f?-x:x;
    }
    const int _outlim=1<<20;
    char outbuf[_outlim+5];int cnt;
    inline void pc(char c){
        outbuf[cnt++]=c;
        if (cnt==_outlim)
            fwrite(outbuf,1,cnt,stdout),cnt=0;
    }
    inline void ps(char *c){
    	reg int lim=strlen(c);
    	for(reg int i=0;i<=lim;i++)pc(c[i]);
	}
    inline void ps(const char *c){
    	reg int lim=strlen(c);
    	for(reg int i=0;i<=lim;i++)pc(c[i]);
	}
    inline void write(int x){
        if(x>9)write(x/10);pc(x%10^'0');
    }
    inline void end(){
        if(cnt)fwrite(outbuf,1,cnt,stdout);endfile;
    }
}
const int MN=1005;
const int inf=0x3f3f3f3f;
int n,a[MN],f[MN],g[2][MN*5];
int to[MN],nxt[MN],h[MN],cnt;
inline void ins(int s,int t){to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;}
bool dfs(int st){
	if(!h[st]){f[st]=0;return true;}
	for(reg int i=h[st];i;i=nxt[i])if(!dfs(to[i]))return false;
	reg int pos=1;memset(g[1],0x3f,sizeof(g[1]));g[1][0]=0;
	for(reg int i=h[st];i;i=nxt[i]){
		pos^=1;memset(g[pos],0x3f,sizeof(g[pos]));
		for(reg int j=0;j<=a[st];j++){
			if(j>=f[to[i]])g[pos][j]=min(g[pos][j],g[pos^1][j-f[to[i]]]+a[to[i]]);
			if(j>=a[to[i]])g[pos][j]=min(g[pos][j],g[pos^1][j-a[to[i]]]+f[to[i]]);
		}
	}
	reg int res=inf;
	for(reg int i=0;i<=a[st];i++)res=min(res,g[pos][i]);
	if(res==inf)return false;f[st]=res;return true;
}
int main(){
	//file("division");
	n=IO::read();
	for(reg int i=2;i<=n;i++)ins(IO::read(),i);
	for(reg int i=1;i<=n;i++)a[i]=IO::read(); 
	//IO::ps(dfs(1)?"POSSIBLE":"IMPOSSIBLE");IO::pc('\n');IO::end();
	puts(dfs(1)?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
r,c=map(int,input().split())
x=[]
for i in range(r):
    x.append(list(map(int,input().split())))
    x[i].append(sum(x[i]))
    print(" ".join(list(map(str,x[i]))))
y=[]

for j in range(c+1):
    ysum=0
    for i in range(r):
        ysum+=x[i][j]
    y.append(ysum)
print(" ".join(list(map(str,y))))


Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n;cin>>n;
    string s;
    map<string, int> mp;
    rep(i,n){cin>>s;mp[s]++;}
    int mx = -1;
    for(auto i = mp.begin();i!=mp.end();i++){
        mx = max(i->second, mx);
    }
    for(auto i = mp.begin();i!=mp.end();i++){
        if(mx == i->second)co(i->first);
    }

}

Measured memory_bytes: 25344
N=list(input())
mae=int(N[0])*10+int(N[1])
ato=int(N[2])*10+int(N[3])
if 0<mae<13:
    if 0<ato<13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0<ato<13:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<int> nei[100000];
bool used[100000];
int dist[100000];
int par[100000];

struct edge {
  int d, u, v;
  edge(int i, int j, int k) {
    d = i; u = j; v = k;
  }
};

bool compare(edge& e1, edge& e2) {
  return e1.d > e2.d;
}

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int u, v;
    cin >> u >> v; u--; v--;
    nei[u].push_back(v);
    nei[v].push_back(u);
  }
  rep(i, n) used[i] = true;

  priority_queue<edge, vector<edge>, decltype(&compare)> que(compare);
  que.push(edge(0, 0, -1));
  while (!que.empty()) {
    int u = que.top().u, v = que.top().v, d = que.top().d;
    que.pop();
    if (used[u]) {
      dist[u] = d; par[u] = v; used[u] = false;
      rep(i, nei[u].size()) {
        if (used[nei[u][i]]) {
          que.push(edge(d+1, nei[u][i], u));
        }
      }
    }
  }

  cout << "Yes" << endl;
  rep(i, n-1) cout << par[i+1] + 1 << endl;
  
  return 0;
}


Measured memory_bytes: 12180
a = int(input())
b = int(input())
c = int(input())
X = int(input())
count = 0
for i in range(a+1):
    x = 500 * i
    for j in range(b+1):
        y = 100 * j
        for k in range(c+1):
            z = 50 * k
            if x+y+z == X :
                count += 1
print(count)

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

int main(){
    int a,b,c,i,n;
    cin >> a >> b >> c;
    n = 0;
    for (i = a; i <= b ; i++){
        if (c % i == 0) {
            n += 1;
        }   
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3100
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll X, Y; cin >> X >> Y;
        rep(i,X+1){
            if (2 * i + 4 * (X - i) == Y){
                    puts("Yes");
                    return 0;
            }
        }
        puts("No");


return 0;
}




Measured memory_bytes: 3664
#include <iostream>

using namespace std;

const int N = 1e5+10;

int a[N];
bool q;

int main()
{
    q = false;

    int n;
    cin >> n;

    for (int i = 1; i <= n; i ++ ) cin >> a[i];

    int cnt = 0;
    int index = 1;
    for (int i = 0; i < n; i ++ )
    {
        index = a[index];
        cnt ++ ;
        if(index == 2)
        {
            q = true;
            break;
        }
    }

    if(q) cout << cnt << endl;
    else cout << "-1" << endl;
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  s = s.substr(0, s.size()-2);
  while(1) {
    string s1 = s.substr(0, s.size()/2);
    string s2 = s.substr(s.size()/2);
    if(s1 == s2) {
      cout << s.size() << "\n";
      break;
    }
    s = s.substr(0, s.size()-2);
  }
  return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;

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

  for (int i = 2; i <= n; i++) {
    list[i] = list[i-1] + list[i-2];
  }

  cout << list[n] << eol;
  
  return 0;
}

Measured memory_bytes: 3196