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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
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); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair
vector<vector<bool> > dp(10001, vector<bool>(5001));

int main() {
  int n, m;
  cin >> n >> m;
  vi use = {0, 2,5,5,4,5,6,3,7,6};
  vi a(m);
  rep (i, m) {
    cin >> a[i];
  }
  sort(all(a));
  dp[0][0] = 1;
  rep (i, n) {
    rep (j, 5001) {
      if (!dp[i][j]) continue;
      rep (k, m) {
        int add = use[a[k]];
        if (i + add > n) continue;
        dp[i + add][j + 1] = true;
      }
    }
  }
  int keta;
  for (keta = 5000; keta >= 0; keta--) {
    if (dp[n][keta]) break;
  }
  string ans;
  while (n > 0) {
    rrep (i, m) {
      int add = use[a[i]];
      if (n < add) continue;
      if (dp[n - add][keta - 1]) {
        ans.push_back(a[i] + '0');
        keta--;
        n -= add;
        break;
      }
    }
  }
  cout << ans << endl;
}
  
  


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

int main(){
	int n;
	cin >> n;
	
	string ret = " ";
	for(int i = 0 ; i < 2*n ; i ++){
		ret += " ";
	}
	cout << "?";
	for(int i = 1 ; i <= n ; i ++){
		cout << " " << i;
	}
	cout << endl;
	fflush(stdout);
	
	string in;
	cin >> in;
	string left = in;
	int l = 2, r = n+1;
	while(l<r){
		int m = (l+r)/2;
		cout << "?";
		for(int i = 1 ; i <= n ; i ++){
			cout << " " << m+i-1;
		}
		cout << endl;
		fflush(stdout);
		cin >> in;
		if(in == left)l = m+1;
		else r = m;
	}
	vector<int> A,B;
	A.push_back(l-1);
	B.push_back(l+n-1);
	ret[l-1] = 'A';
	ret[l+n-1] = 'B';
	for(int i = 1 ; i <= 2*n ; i ++){
		if(l-1 <= i && i <= l+n-1)continue;
		cout << "?";
		for(int j = 0 ; j <= n-2 ; j ++){
			cout << " " << l+j;
		}
		cout << " " << i;
		cout << endl;
		fflush(stdout);
		cin >> in;
		if(in == left){
			ret[i] = 'A';
			A.push_back(i);
		}
		else{
			ret[i] = 'B';
			B.push_back(i);
		}
	}
	for(int i = l ; i <= l+n-2 ; i ++){
		cout << "?";
		for(int j = 0 ; j < (n-1)/2 ; j ++){
			cout << " " << A[j];
		}
		for(int j = 0 ; j < (n-1)/2 ; j ++){
			cout << " " << B[j];
		}
		cout << " " << i;
		cout << endl;
		fflush(stdout);
		cin >> in;
		if(in == left){
			ret[i] = 'A';
			A.push_back(i);
		}
		else{
			ret[i] = 'B';
			B.push_back(i);
		}
	}
	for(int i = 1 ; i <= 2*n ; i ++){
		if(left[0] == 'R'){
			if(ret[i] == 'A')ret[i] = 'R';
			else ret[i] = 'B';
		}
		else {
			if(ret[i] == 'A')ret[i] = 'B';
			else ret[i] = 'R';
		}
	}
	cout << "!" << ret << endl;
	fflush(stdout);
}



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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i,n) for(ll i=0; i<(n); i++)
#define forn for(ll i=0; i<(n); i++)
#define fori(i,k,n) for(ll i=k; i<(n); i++) 
#define all(x) (x).begin(),(x).end()
#define en '\n'
#define FILL(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

void solve(){
	ll n;
	cin >> n;
	vll a(n), pre(n,0), dp(n+1, 0);
	forn{
		cin >> a[i];
		pre[i] = (i>1 ? pre[i-2] : 0) + a[i];
	}
	for(ll i=2; i<=n; i++){
		if(i&1L){//odd
			dp[i]=max(dp[i-2]+a[i-1], dp[i-1]);
		} else{
			dp[i]=max(pre[i-2], dp[i-2]+a[i-1]);
		}
	}
	cout << dp[n] << en;
}

int main(){
    ios::sync_with_stdio(0);
	cin.tie(0);
    cout.tie(0);
 
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
    int t = 1;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 7948
#include <bits/stdc++.h>
using namespace std;
void main_sub(void);
int main(int argc, char* argv[]) {
    main_sub();
    return 0;
}
// int を int64_t にする
// g++ に -DUSE_STRICT_INT をつけるか、
// 下のコメントアウトを外すと無効化
// #define USE_STRICT_INT
using i64 = int64_t;
#ifndef USE_STRICT_INT
#define int i64
#endif
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF = (1 << 30);
constexpr i64 INFL = (1LL << 62);
constexpr i64 MOD = 1000000007;

int dp[105][4][2];

void main_sub(void) {
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;
    dp[0][0][0] = 1;  // 空集合が1つって意味？
    rep(i, n) {
        rep(j, 4) {
            rep(k, 2) {
                int nd = s[i] - '0';
                rep(d, 10) {
                    int ni = i + 1;
                    int nj = j;
                    int nk = k;
                    if (d != 0) nj++;
                    if (nj > K) continue;
                    if (k == 0) {
                        if (d > nd) continue;
                        if (d < nd) nk = 1;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[n][K][0] + dp[n][K][1] << endl;
    return;
}

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

int main() {
  int n, m, x_max, y_min, x, y;
  cin >> n >> m >> x_max >> y_min;
  int i;
  for (i = 0; i < n; i++) {
    cin >> x;
    if (x > x_max) {
      x_max = x;
    }
  }
  for (i = 0; i < m; i++) {
    cin >> y;
    if (y < y_min) {
      y_min = y;
    }
  }
  if (x_max < y_min) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(a == 0 || b == 0){
        print("Zero");
    }else if(a > 0){
        print("Positive");
    }else{
        if(b > 0){
            print("Zero");
        }else{
            if((b-a+1) % 2 == 0){
                print("Positive");
            }else{
                print("Negative");
            }
        }
    }

    

}

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

int n;
const int nmax = 100;

vector<pair<int, int> > red, blue;
bool flg[nmax];

int main()
{
    cin >> n;
    red.resize(n);
    blue.resize(n);
    for (int i=0; i<n; i++)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        red[i] = make_pair(tmp1, tmp2);
    }
    for (int i=0; i<n; i++)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        blue[i] = make_pair(tmp1, tmp2);
    }

    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());

    int count = 0;
    for (auto bp : blue)
    {
        int maxtmp = -1;
        int argmax = -1;
        for (int i=0; i<n; i++)
        {
            if (red[i].first > bp.first) break;
            if (red[i].second < bp.second && !flg[i])
            {
                if (red[i].second > maxtmp)
                {
                    argmax = i;
                    maxtmp = red[i].second;

                }
            }
        }
        if (argmax >= 0)
        {
            flg[argmax] = true;
            count++;
        }
    }

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

Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
long long mod;

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

ll t[400008];
void build(vector<ll>& a, int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

ll maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}



void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

int main() { 
int n;
ll ans=0;

cin>>n;
unordered_map<ll,ll> h;
int t;
for(int i=0;i<n;i++)
{
  cin>>t;
  h[t]++;
  ans+=t;
}

int q;
cin>>q;

int a,b;
ll temp;
for(int i=0;i<q;i++)
{
  cin>>a>>b;
  h[b]+=h[a];
  ans-=h[a]*a;
  ans+=h[a]*b;
  h[a]=0;
  cout<<ans<<"\n";
}


return 0;
}


Measured memory_bytes: 7056
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int n600 = 600;
		List<Integer> list = new ArrayList<Integer>();
		while(scan.hasNext()){
			int d = scan.nextInt();
			int ans = 0;
			for(int x = d; x < n600; x += d){
				ans += d * (x*x);
			}
			list.add(ans);
		}

		for(int n : list){
			System.out.printf("%d\n", n);
		}
	}
}

Measured memory_bytes: 26116
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 

ll fact[800005],rfact[800005];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}

 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];

char s[500005];

int main(){
    cin >> a >> b >> c;
    double aa,bb,cc;
    aa = a;
    bb = b;
    cc = c;
    if(cc / aa >= (aa * bb / 2)){
        double ans = atan((2.0f * bb / aa) - (2.0f * cc) / (aa * aa * aa));
        //ps(2 * bb / aa - (2 * cc) / (aa * aa * aa));
        ans = ans * 360.0f / (2.0f * Pi);
        ps(ans);
    }else{
        double ans = atan(2.0f * cc / (aa * bb * bb));
        ans *= (360.0f / (2.0f * Pi));
        //ps(ans);
        ans = 90.0f - ans;
        ps(ans);
    }


    return 0;
}











Measured memory_bytes: 15360
n,k,q=map(int,input().split())
a=list(map(int,input().split()))
ans=10**10
for x in a:
  b=[[]]
  can=0
  for i in a:
    if i<x:
      if len(b[-1]):b.append([])
    else:b[-1].append(i)
  if len(b[-1])==0:del b[-1]
  for i in range(len(b)):b[i].sort()
  c=[]
  for i in b:
    i.sort()
    if len(i)>=k:c+=i[:len(i)-k+1]
  if len(c)<q:continue
  c.sort()
  ans=min(ans,c[q-1]-c[0])
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int a[110];
	rep(i,n) cin >> a[i];

	int cnt = 0;

	rep (i,n){
		if ((i%2 == 1) && (a[i]%2 == 1)) {
			//cout << i << ", " << a[i] <<endl;
			cnt++;
		}
	}
	cout << cnt << endl;


}

Measured memory_bytes: 3628
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 n = Console.ReadLine().ToInt();
		var p = Input();
		var a = new long[n];
		for(int i = 0; i < n; i++)
		{
			a[i] = p[i].ToLong();
		}
		
		Array.Sort(a);
		long wa = 0;
		long sum = 0;
		for(int i = 0; i < n; i++)
		{
			if(sum * 2 < a[i])
			{
				wa = 0;
			}
			sum += a[i];
			wa++;
		}
		Console.WriteLine(wa);

	}


	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: 25692
//  Author : Amit Kumar 

#include <iostream>
#include <algorithm> 
#include <string> 
#include <sstream>
#include <fstream>
#include <iomanip> 
#include <chrono> 
#include <numeric> 
#include <utility>
#include <functional>

#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <deque>
#include <list>


#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdio>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
//  using namespace placeholders;
using namespace __gnu_pbds;
template<typename TypeInfo>
using new_set = tree< 
/* ob.order_of_key(element) -> number of element strictly less than element
 * *ob.find_by_order(n) ->  nth element in increasing order
 */
         TypeInfo ,
         null_type ,
         less<TypeInfo> ,
         rb_tree_tag ,
         tree_order_statistics_node_update 
 > ;

void show_me() { cerr << endl; }
 
template <typename HEAD, typename... TAIL>
void show_me(HEAD H, TAIL... T) {
  cerr << " " << (H);
  show_me(T...);
}
 
#ifdef HELL_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "]:", show_me(__VA_ARGS__)
#else
#define show(...) 0
#endif
 
template<typename A, typename B>
ostream& operator<<(ostream&out, const pair<A, B>&p){
    out << p.first << ' ' << p.second ;
    return out;
}

template<typename A, typename B>
istream& operator>>(istream&in, pair<A, B>&p){
    in >> p.first >> p.second ;
    return in;
}

template<typename A> 
istream& operator>>(istream&in, vector<A>&vec){
    for(auto&itr:vec){
        in >> itr;
    }
    return in;
}

template<typename A>
ostream& operator<<(ostream&out,const vector<A>&vec){
    for(auto&itr:vec){
        out << itr <<' '; // VVV 
    }
    return out;
}

const int MAXM = (int)1e5+100;
const int MAXN = (int)1e5+100;
const int MOD  = (int)1e9+7;




signed main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    ios::sync_with_stdio(false); // FLUSH THE STREAM IF USING puts / printf / scanf/
    cin.tie(nullptr);            //
    cout.tie(nullptr);           //
#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 
    int64_t n; cin >> n; 
    vector<int64_t>v(n); cin >> v; 
    vector<int64_t>xr;
    int64_t total=0;
    for(int i=0;i<n;++i){
        xr.emplace_back(v[i]^v[i+1]);
        ++i;
    }
    for(auto&itr:xr){
        total^=itr;
    }
    for(int i=0;i<n;i+=2){
        int x = (total^xr[i/2]);
        cout << (v[i+1]^x) << ' ';
        cout << (v[i]^x) << ' ';
    }
    cout << '\n'; 
#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


Measured memory_bytes: 5776
#include <bits/stdc++.h>
#define INF 1e9+7
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int lo;
string a,b,c;
lo x,y;
lo n;
map<lo,lo> mep;
int main(){
    cin >> n;
    bool ans = true;
    for(lo i = 0;i < n;i++){
        lo a;
        cin >> a;
        if(!mep[a]) mep[a]++;
        else ans = false;
    }
    if(ans) cout << "YES";
    else cout << "NO";
    
}

Measured memory_bytes: 12800
#include<stdio.h>

#define N 100
#define INF 10000000

#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
int G[N+1][N+1];
int color[N+1];
int d[N+1];
int Q[N+1];
int a=0,b=0;

void enqueue(int s){
  Q[b] = s;
  b++;
}

int dequeue(){
  a++;
  return Q[a-1];
}

int empty(){
  if(a==b) return 1;
  else return 0;
}

void bfs(int s){
  int i,u;

  for(i=1;i<=n;i++){    
    color[i] = WHITE;
    d[i] = -1;
  }
  color[s] = GRAY;
  d[s] = 0;
  //Q = empty;
  enqueue(s);

  while(empty()!=1){
    u = dequeue();
    for(i=1;i<=n;i++){
      if(color[i]==WHITE && G[u][i]==1){
	enqueue(i);
	color[i] = GRAY;
	d[i] = d[u] + 1;
      }
    }
    color[u] = BLACK;
  }
}

int main(){

  int i,j,k;
  int flag;

  scanf("%d",&n);

  int Adj[n+1][n+2];

  for(i=1;i<=n;i++){
    scanf("%d",&Adj[i][0]);
    scanf("%d",&Adj[i][1]);
    for(j=0;j<Adj[i][1];j++){
      scanf("%d",&Adj[i][j+2]);
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      G[i][j]=0;
      for(k=0;k<Adj[i][1];k++){
	if(j==Adj[i][k+2]){
	  G[i][j]=1;
	  break;
	}
      }
    }
  }

  bfs(1);

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

  return 0;
}



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

int main(){
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> ans(N);
	for(auto &i:A)cin >> i;
	
	long long sum=0;
	for(int i=0;i<N;i++)sum+=A[i];
	
	ans[0]=sum;
	for(int i=1;i<N;i+=2)ans[0]-=2*A[i];
	
	for(int i=1;i<N;i++)ans[i]=A[i-1]*2-ans[i-1];
	
	for(int i=0;i<N-1;i++)cout << ans[i] << " ";
	cout << ans[N-1] << endl;
	return 0;
}

Measured memory_bytes: 2944
a=input()
list=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a=int(a)-1
print(list[a])


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	static int n;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");
		char[] c = str[0].toCharArray();
		System.out.println((char) (c[0] + 1));
	}
}

Measured memory_bytes: 19924
from itertools import combinations

n = int(input())
r = range(n)
a = [(set(), set()) for _ in r]
for i in r:
  for _ in range(int(input())):
    x, y = map(int, input().split())
    a[i][y].add(x - 1)

fail = lambda x: not all(a[i][0].isdisjoint(x) and a[i][1] < x for i in x)

while n and all(map(fail, map(set, combinations(r, n)))):
  n -= 1
print(n)


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

bool isKaibun(string s){
  int n = s.size();
  bool res = true;
  rep(i,n/2){
    if(s[i] != s[n-1-i]) res = false;
  }

  return res;
}

int main(){
  string s; cin >> s;
  int n = s.size();

  string s2 = s.substr(0, (n-1)/2);
  string s3 = s.substr((n+3)/2-1, n-((n+3)/2-1));

  YesNo(isKaibun(s) && isKaibun(s2) && isKaibun(s3));
}

Measured memory_bytes: 256
import fractions
from functools import reduce

N = int(input())
a =  list(map(int, input().split()))

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a) - 1
print(f(m, a))

Measured memory_bytes: 5716
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::min;

#[fastout]
fn main() {
    input! {
    h: usize,
    w: usize,
    k: usize,
    s: [Chars; h]
    }
    let mut ans = std::usize::MAX;
    for i in 0..1usize << h - 1 {
        let mut ws = vec![0; h];
        let mut tmp = i.count_ones() as usize;
        let mut is_enable = true;
        for j in 0..w {
            let mut wc = vec![0;h];
            let mut t = 0;
            for tk in 0..h {
                if s[tk][j] == '1' {t += 1}
                if i & 1 << tk > 0 || tk == h - 1 {
                    wc[tk] =  t;
                    t = 0;
                }
            }
            if wc.iter().any(|&x| x > k) {
                is_enable = false;
                break;
            }
            if (0..h).map(|x| wc[x] + ws[x]).any(|y| y > k) {
                tmp += 1;
                ws = vec![0; h];
            }
            for tk in 0..h {
                ws[tk] += wc[tk];
            }
        }
        if is_enable {
            ans = min(ans, tmp);
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;

    int ans=1;
    for(int i=m/n; i>0; i--) {
      if(m%i==0) {
        ans=i;
        break;
      } 
    }
    cout << ans << endl;
    return 0;
}

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

namespace ABC126B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = CIN.String();
            int Y = int.Parse(S.Substring(0, 2));
            int M = int.Parse(S.Substring(2, 2));

            if (Y == 0 && M == 0)
            {
                Console.WriteLine("NA");
                return;
            }
            
            if (Y > 12 || Y == 0)
            {
                if (M > 12 || M == 0)
                {
                    Console.WriteLine("NA");
                    return;
                }
                Console.WriteLine("YYMM");
                return;
            }
  

            if (M > 12 || M == 0)
            {
                Console.WriteLine("MMYY");
                return;
            }
            
            Console.WriteLine("AMBIGUOUS");
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int first=n/500;
    int ans=0;
    ans+=(first)*1000;
    int left=n-(first)*500;
    int second=left/5;
    ans+=(second)*5;
    cout<<ans;
}

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

int main(int argc, char const *argv[])
{
	int n, i; cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}

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

int main() {
  int n;
  std::cin >> n;
  int h[n];
  for (int i = 0; i < n; i++) {
    std::cin >> h[i];
  }

  for (int i = 1; i < n; i++) {
    if (h[i - 1] <= h[i] - 1) {
      h[i]--;
    } else if (h[i - 1] <= h[i]) {
      continue;
    } else {
      std::cout << "No" << "\n";
      return 0;
    }
  }
  std::cout << "Yes" << "\n";
  return 0;
}

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

int main() {
  
  int N;
  int f = 0;
  int d = 1;
  cin >> N;
  int M = N;
  while(M > 0) {
    d *=10;
    f += (M%d)/(d/10);
    M -= M%d;
  }
  if ( N % f == 0 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


yes, no = "POSSIBLE", "IMPOSSIBLE"
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
if N == 1:
    print(yes if A[0] == K else no)
elif K > max(A):
    print(no)
else:
    GCD = gcd(A[0], A[1])
    for i in range(2, N):
        GCD = gcd(GCD, A[i])
    print(yes if K % GCD == 0 else no)


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

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}


signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,k;
    cin>>n>>k;
    int cnt=1;
    n-=k;
    cnt+=(n+k-2)/(k-1);
    cout<<cnt;

}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, M;
vector<ll> A;
vector<pair<int, int>> BC;

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

    rep(i, N) {
        ll a;
        cin >> a;
        A.push_back(a);
    }

    sort(ALLOF(A));

    rep(i, M) {
        int B, C;
        cin >> B >> C;
        BC.push_back(make_pair(B, C));
    }

    sort(ALLOF(BC), [](const pair<int, int>& lh, const pair<int, int>& rh){ return lh.second > rh.second; });

    int t = 0;
    rep(i, M) {
        int dst = distance(A.begin() + t, lower_bound(A.begin() + t, A.end(), BC[i].second));
        int len = min(BC[i].first, dst);
        if (len < 0) break;
        REP(k, t, t + len) {
            A[k] = BC[i].second;
        }
        t += len;
    }

    // rep(i, M) {
    //     int B, C;
    //     cin >> B >> C;
    //     int dst = distance(A.begin(), lower_bound(ALLOF(A), C));
    //     int len = min(B, dst);

    //     if (len > 0) {
    //         REP(k, 0, len) {
    //             A[k] = C;
    //         }

    //         sort(A.begin(), A.begin() + dst);
    //     }
    // }

    ll sum = 0;
    rep(i, N) {
        sum += A[i];
    }

    cout << sum << endl;

    return 0;
}

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

int main(){
    int H,W;cin >> W >> H;
    vector<int> Hvec,Wvec;
    for(int a = 0;a < W;a++){
        int b;cin >> b;
        Wvec.push_back(b);
    }
    for(int b = 0; b < H;b++){
        int c;cin >> c;
        Hvec.push_back(c);
    }

    for(int a = 0;a < H;a++){
        sort(Wvec.begin(),Wvec.end(),greater<int>());
        for(int b = 0;b < W;b++){
            if(Hvec.at(a)&&Wvec.at(b)){
                Hvec.at(a)--;
                Wvec.at(b)--;
            }
        }
    }
    bool result = true;
    for(int a = 0;a < H;a++){
        if(Hvec.at(a)!= 0)result= false;
    }
    for(int b = 0;b < W;b++){
        if(Wvec.at(b)!=0)result = false;
    }
    if(result){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}
//2t+2



Measured memory_bytes: 3164
"""O(N^0.5) solution"""

N = int(input())
N -= 1

ans = 0
n = int(N**.5)
for x in range(1, n+1):
  # (x,x)
  ans += 1
  # (x,y)
  ans += N//x - x
  # (y,x)
  ans += N//x - x

print(ans)

Measured memory_bytes: 9360
# -*- coding: utf-8 -*-

N = int(input())

aN = []
i = 1
# かけ合わせる数の左右逆はやる意味ない
while i <= N//i:
    if N % i == 0:
        aN.append([i, N//i])
    i += 1

# 末尾に格納されたペアの右側の数値
print(len(str(aN[-1][1])))

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

void solve(long long H, long long W, vector<string> C){
	for(int i=0;i<H;i++){
		cout<<C[i]<<endl;
		cout<<C[i]<<endl;
	}	
}

int main(){	
	long long W;
	long long H;
	scanf("%lld",&H);
	vector<string> C(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> C[i];
	}
	solve(H, W, C);
	return 0;
}



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

using namespace std;

#define ll long long

int main(){
	ll n, t; 
	cin >> n >> t;
	ll ans = n*t;
	ll last;
	cin >> last;
	for(int i = 1; i < n; ++i){
		int cur;
		cin >> cur;
		if(cur<(last+t)){
			ans += (cur-(last+t));
		}
		last = cur;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 3608
using System;

namespace AtCoder.ABC116
{
    public class A
    {
        public static void Solve()
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            
            
            Console.WriteLine((a * b) / 2);
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC116.A.Solve();
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    char b;
    cin >> b;

    if(b == 'A') {
        out("T");
    }
    if(b == 'C') {
        out("G");
    }
    if(b == 'G') {
        out("C");
    }
    if(b == 'T') {
        out("A");
    }
    
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <int, ll> P;
const ll INF = 1ll << 60;

void bellman_ford(
        vector<vector<P>> &edge,
        vector<ll> &dist,
        vector<bool> &loop,
        int s) {
    int n = edge.size();
    dist.resize(n, INF);
    dist[s] = 0;
    for (int i = 1; i < n; i++) {
        for (int from = 0; from < n; from++) {
            if (dist[from] == INF) continue;
            for (P e : edge[from]) {
                int to = e.first;
                dist[to] = min(dist[to], dist[from] + e.second);
            }
        }
    }

    loop.resize(n, false);
    for (int i = 0; i < n; i++) {
        for (int from = 0; from < n; from++) {
            if (dist[from] == INF) continue;
            for (P &e : edge[from]) {
                int to = e.first;
                if (dist[to] > dist[from] + e.second) {
                    dist[to] = dist[from] + e.second;
                    loop[from] = true;
                    loop[to] = true;
                }
            }
        }
    }
}


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B&lang=jp
void AOJ_GRL_1_B() {
    int V, E, r;
    cin >> V >> E >> r;
    vector<vector<P>> edge(V);
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        edge[s].push_back({t, d});
    }
    vector<ll> dist;
    vector<bool> loop;
    bellman_ford(edge, dist, loop, 0);
    for (int i = 0; i < V; i++) {
        if (loop[i]) {
            cout << "NEGATIVE CYCLE" << "\n";
            return;
        }
    }
    for (ll d : dist) {
        if (d == INF) cout << "INF\n";
        else cout << d << "\n";
    }
}


// verified
//  https://atcoder.jp/contests/abc061/tasks/abc061_d
void AtCoder_2017_05_13_D() {
    int n, m;
    cin >> n >> m;
    vector<vector<P>> edge(n);
    for (int i = 0; i < m; i++) {
        int a, b; ll c;
        cin >> a >> b >> c;
        edge[--a].push_back({--b, -c});
    }
    vector<ll> dist;
    vector<bool> loop;
    bellman_ford(edge, dist, loop, 0);
    if (loop[n - 1]) cout << "inf" << endl;
    else cout << -dist[n - 1] << endl;
}

int main() {
    // AOJ_GRL_1_B();
    AtCoder_2017_05_13_D();
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#include <cmath>

using namespace std;

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

    for(int h = 1; h <= 3500; h++) {
        for(int w = 1; w <= 3500; w++) {
            long long int n1 = N * h * w;
            long long int n2 = (4 * h * w - N * w - N * h);
            if(n2 <= 0) continue;
            if(n1 % n2 != 0) continue;
            cout << (n1 / n2) << " "<< h << " " << w << endl;
            return 0;
        }
    }

}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>
#include <boost/multiprecision/cpp_int.hpp>

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


int main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    auto ans = (a < b && c < b && a < c) || (a > b && c > b && c < a);
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
enum day{
	SUN=1,MON,TUE,WED,THU,FRI,SAT
};
int main(){
	string s,t[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	int ans=7; 
	cin>>s;
	for(int i=0;i<7;i++){
		if(s==t[i]){
			ans-=i;break;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <algorithm>

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

using namespace std;

const int inf = 2e6;

typedef pair<int, int> P;

struct E{
	E(int t, int c, int r): t(t), c(c), r(r){}

	int t, c, r;
};

int n, m, h, k;
vector<E> g[2500];
int s, t, p;
int f[256][257];
int d[2500];

int index(int i, int j){
	return i * (h + 1) + j;
}

int main(){
	while(scanf("%d%d%d%d", &n, &m, &h, &k), n){
		rep(i, m){
			int a, b, c, d, e;
			scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
			--a;
			--b;
			--e;
			rep(i, h - d + 1){
				g[index(a, i)].push_back(E(index(b, i + d), c, e));
				g[index(b, i)].push_back(E(index(a, i + d), c, e));
			}
		}
		scanf("%d%d%d", &s, &t, &p);
		--s;
		--t;
		fill_n(f[0], 1 << k, inf);
		f[0][0] = 0;
		rep(i, p){
			int l, d;
			scanf("%d%d", &l, &d);
			int a = 0;
			rep(j, l){
				int k;
				scanf("%d", &k);
				a |= 1 << (k - 1);
			}
			rep(j, 1 << k){
				f[i + 1][j] = min(f[i][j & ~a] + d, f[i][j]);
			}
		}

		int ans = inf;
		rep(i, 1 << k){
			if(f[p][i] == inf){
				continue;
			}

			fill_n(d, index(n, 0), inf);

			priority_queue<P, vector<P>, greater<P> > q;
			d[index(s, 0)] = 0;
			q.push(P(0, index(s, 0)));
			while(!q.empty()){
				P v = q.top();
				q.pop();
				if(v.first > d[v.second]){
					continue;
				}
				rep(j, g[v.second].size()){
					E e = g[v.second][j];
					if(i & (1 << e.r)){
						e.c = 0;
					}
					if(d[e.t] > v.first + e.c){
						d[e.t] = v.first + e.c;
						q.push(P(d[e.t], e.t));
					}
				}
			}

			int a = *min_element(d + index(t, 0), d + index(t + 1, 0));
			if(a != inf){
				ans = min(f[p][i] + a, ans);
			}
		}
		printf("%d\n", ans != inf ? ans : -1);

		rep(i, index(n, 0)){
			g[i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 2172
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	int H, W;
	cin >> H >> W;
	VS S(H);
	REP(i, H) {
		cin >> S[i];
		REP(j, W) if (S[i][j] == '.') S[i][j] = '0';
	}

	REP(i, H) {
		REP(j, W) {
			if (S[i][j] == '0') continue;
			if (S[i][j] == '#') {
				if (i != 0) if (j != 0) if(S[i - 1][j - 1] != '#') S[i - 1][j - 1] = '0' + (S[i - 1][j - 1] - '0') + 1;
				if (i != 0) if (S[i - 1][j] != '#') S[i - 1][j] = '0' + (S[i - 1][j] - '0') + 1;
				if (i != 0) if (j != W-1) if (S[i - 1][j + 1] != '#') S[i - 1][j + 1] = '0' + (S[i - 1][j + 1] - '0') + 1;

				if (j != 0) if (S[i][j - 1] != '#') S[i][j - 1] = '0' + (S[i][j - 1] - '0') + 1;
				if (j != W - 1) if (S[i][j + 1] != '#') S[i][j + 1] = '0' + (S[i][j + 1] - '0') + 1;

				if (i != H - 1) if (j != 0) if (S[i + 1][j - 1] != '#') S[i + 1][j - 1] = '0' + (S[i + 1][j - 1] - '0') + 1;
				if (i != H - 1) if (S[i + 1][j] != '#') S[i + 1][j] = '0' + (S[i + 1][j] - '0') + 1;
				if (i != H - 1) if (j != W - 1) if (S[i + 1][j + 1] != '#') S[i + 1][j + 1] = '0' + (S[i + 1][j + 1] - '0') + 1;

			}
		}
	}
	REP(i, H) cout << S[i] << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
if sum(a) % ((1 + n) * n // 2):
    print("NO")
else:
    m = sum(a) // ((1 + n) * n // 2)
    d = [0] * n
    for i in range(n):
        d[i] = a[(i + 1) % n] - a[i] - m
    for i in d:
        if i % n or i > 0:
            print("NO")
            exit()
    if -sum(d) == n * m:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 14996
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    string s; cin>>s;
    int n=s.size();
    if(s[0]=='0') { cout<< -1 <<"\n"; return; }
    if(s[n-1]=='1') { cout<< -1 <<"\n"; return; }
    rep(i,n-1) if(s[i]!=s[n-2-i]) { cout<< -1 <<"\n"; return; }

    ll last=n;
    repr(i,n-2,0){
        cout<< last <<" "<< i+1 <<"\n";
        if(s[i]=='1') last=i+1; 
    }
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main() {
    int n,i;
    cin >> n >>i;
    cout << n-i+1 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
signed main(){
	int n; cin >> n;
	vector<int> a(n);
	REP(i, n){cin >> a[i];}

	deque<int> que;
	if(n%2 == 0){

		FOR(i, 1, n+1){
			if(i%2 != 0){
				que.push_back(i);
			}else{
				que.push_front(i);
			}
		}

	}else{

		FOR(i, 1, n+1){
			if(i%2 != 0){
				que.push_front(i);
			}else{
				que.push_back(i);
			}
		}

	}


	REP(i, n){cout << a[que[i]-1] << ' ';}
	cout << endl;
}

Measured memory_bytes: 3840
N=int(input())
A=list(map(int,input().split()))
a=1
m=A[0]
for i in range(1,N):
  if A[i]==1:
    a+=1
    break
  if m>=A[i]:
    m=A[i]
    a+=1
  else:
    continue
print(a)
    

Measured memory_bytes: 78672
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

string a,b;
int main(){
  cin >> a >> b;
  a += b;
  stringstream ss;
  ss << a;
  int c;
  ss >> c;
  if((int)(sqrt(c)) * (int)(sqrt(c)) == c){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const* argv[]){
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);

    if (a == b && b == c) {
        printf("1\n");
    }else if ((a == b && b != c) ||
              (a != b && b == c) ||
              (a == c && b != c)) {
        printf("2\n");
    }else{
        printf("3\n");
    }

    return 0;
}

Measured memory_bytes: 128
// E - Sequence Sum
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rp(i,s,e) for(ll i=(ll)(s);i<(ll)(e);++i)

int main(){
	ll N, X, M; cin>>N>>X>>M;

	ll mn = min(N, M);
	set<ll> S;
	vector<ll> A;
	ll a = X;
	ll ans = 0;

	rp(_i, 0, mn){
		if(S.find(a) != S.end()) break;
		S.insert(a);
		A.push_back(a);
		ans += a;
		a = a*a % M;
		a = (a + M) % M;
		if(a == 0){
			cout<< ans <<endl;
			return 0;
		}
	}

	if((ll)A.size() >= mn){
		cout<< ans <<endl;
		return 0;
	}

	ll st_len = 0;
	while(st_len < (ll)A.size() && a != A[st_len]) st_len += 1;
	ll st = 0; rp(i, 0, st_len) st += A[i];
	ll cyc_sum = 0; rp(i, st_len, A.size()) cyc_sum += A[i];
	ll cyc_len = A.size() - st_len;
	ll cyc_num = (N - st_len) / cyc_len;
	ll ed_len = (N - st_len) % cyc_len;
	ll ed = 0; rp(i, st_len, st_len + ed_len) ed += A[i];
	cout<< st + cyc_sum * cyc_num + ed <<endl;
}


Measured memory_bytes: 5940
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	bool ans = true;
	rep(i, n - 1) {
		if (a[i] == a[i + 1])
			ans = false;
	}
	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int cut_count(vi L, int mid){
    int n = L.size();
    long res = 0;
    REP(i, 0, n){
        res += (long)((long double)(L[i]-0.1)/mid);
    }
    return res;
}

int main() {
    int N, K; 
    cin>>N>>K;
    vi L(N);
    REP(i, 0, N){
        cin >> L[i];
    }
    int left = 0, right = 1000000001;
    while(right - left > 1){
        int mid = (left + right) / 2;
        if(cut_count(L, mid) > K){
            left = mid;
        }else{
            right = mid;
        }
    }
    cout << right << endl;
}

Measured memory_bytes: 4836