akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};



int main(){
    CIN(N);
    //CIN(A);
    //CIN(B);
    //CIN(C);
    //SCIN(str);
    if(N < 1200){
        COUT("ABC");
    }else if(N < 2800){
        COUT("ARC");
    }else{
        COUT("AGC");
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<bool> a(100001,true);
  vector<int> b(100001);
  a[0]=a[1]=false;
  for(int i=4;i<=100000;i+=2) a[i]=false;
  for(int i=3;i<=100000;i+=2){
    if(a[i]){
      for(int j=i*2;j<=100000;j+=i) a[j]=false;
    }
  }
  b[0]=b[1]=b[2]=0;
  for(int i=3;i<=100000;i++){
    b[i]=b[i-1];
    if(a[i]&&a[(i+1)/2]) b[i]++;
  }
  int q,l,r;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>l>>r;
    cout<<b[r]-b[l-1]<<endl;
  }
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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(void){
    int K,T; cin >> K >> T;
    VI a(T); int mx=0;
    REP(i,T){
        cin >> a[i];
        chmax(mx, a[i]);
    }
    int diff = max(0,mx-(K+1)/2);
    int ans = diff*2 + K%2 - 1;
    if(diff == 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000000
#define M 10000

int A[N],B[N];

int main(){
    int n,i;
    int C[M];
    int k=M;
    scanf("%d",&n);
    for(i=0;i<k;i++)C[i]=0;
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }
    for(i=1;i<=k;i++){
        C[i]=C[i]+C[i-1];
    }
    for(i=0;i<n;i++){
        B[C[A[i]]]=A[i];
        C[A[i]]--;
    }
    for(i=1;i<=n;i++){
        if(i!=n)printf("%d ",B[i]);
        else printf("%d",B[i]);
    }
    printf("\n");
    return 0;
}



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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  int L = A + B;
  int R = C + D;
  
  if (L < R)
    cout << "Right" << endl;
  else if (L == R)
    cout << "Balanced" << endl;
  else if (L > R)
    cout << "Left" << endl;
}

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

const long long mod = 1000000007;
const int maxn = 100005;

int n, m;
int x[maxn], y[maxn];
long long ans, len, t1, t2;

signed main () {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &x[i]);
	for (int i = 1; i <= m; ++i)
		scanf("%d", &y[i]);
	for (long long i = 2; i <= m; ++i) {
		len = y[i] - y[i - 1];
		(t2 += (len * (((i - 1) * (((long long) m) - i + 1)) % mod)) % mod) %= mod;
	}
	for (long long i = 2; i <= n; ++i) {
		len = x[i] - x[i - 1];
		(t1 += (len * (((i - 1) * (((long long) n) - i + 1)) % mod)) % mod) %= mod;
	}
	ans = (t1 * t2) % mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n; cin >> n;
  if (n%10 == 3) cout << "bon" << endl;
  else if (n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int len = s.size();
    if(s.at(len-1) != 's') cout << s << "s" << endl;
    else cout << s << "es" << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) {
            x -= mod;
        }
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ll nck(ll n, ll k){
    vector<mint> ret(k+1, 1);
    rep(i, k){
        ret[i+1] = ret[i].x * (n-i);
        ret[i+1] /= (i+1);
    }
    return ret[k].x;
}

int main() {
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll ans = nck(r2+c2+2, c2+1);
    ans = (ans - nck(r2+c1+1, c1) + mod) % mod;
    ans = (ans - nck(r1+c2+1, c2+1) + mod) % mod;
    ans = (ans + nck(r1+c1, c1)) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin>>x>>y;
		if(x==0 && y==0) break;
		if(y>x){
			int t = x;
			x = y;
			y = t;
		}
		int step=0;
		while(y!=0){
			x = x%y;
			int t = x;
			x = y;
			y = t;
			step++;
		}
		cout<<x<<" "<<step<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import sys
input=sys.stdin.readline

s = input().strip()
t = input().strip()

for i in range(len(s)-len(t),-1,-1):
    for j in range(len(t)):
        if s[i+j] == "?" or s[i+j] == t[j]:
            if j == len(t)-1:
                s = "" + s[:i] + t + s[i+len(t):]
                print(s.replace("?","a"))
                exit()
        else:
            break
print("UNRESTORABLE")


Measured memory_bytes: 3060
#pragma GCC optimize("O3") 

#include <bits/stdc++.h>
using namespace std;

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << "--" << x << "--" << endl;
#define deb2(x,y)	        cout << #x << "-" << x << "-" << " ~~ " <<  #y << "-" << y << "-" << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    ll n;
    cin >> n;
    
    ll sum = 0, ar[n + 1] = {0};
    
   /* ll i = 1;
    ll a = (n / (i + 1)) + 1, b = n / i;

    f(k, a, b + 1)
        ar[k] += 1;
    deb(sum)
    i += 1;
    
    while(a != 1 && b != 1)
    {
        a = (n / (i + 1)) + 1, b = n / i;
        deb2(a, b)
        deb(i)
        f(k, a, b + 1)
            sum += (k * i) % mod;
        deb(sum)
        i += 1;
    }
    
    cout << sum % mod << endl;*/
    
    
    
    for(int i = 1; i <= n; i++)
    {
        for(int k = i; k <= n; k += i)
        {
            ar[k] += 1;
        }
    }
    // deba(ar)
    f(i, 1, n + 1)
        sum += (i * ar[i]);
        
        
    cout << sum << endl;
    
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}

Measured memory_bytes: 81776
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int P,Q,R;
    cin>>P>>Q>>R;
    int A=P+Q;
    int B=P+R;
    int C=Q+R;
    cout<<min(min(A,B),C)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    vector<bool> dp(k+1,false);
    for(int i=0;i<=k;i++){
	for(int j=0;j<n;j++){
	    if( a[j]<=i ) dp[i] = dp[i] | ( !dp[i-a[j]] );
	}
    }
    if(dp[k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;

    return 0;
}


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

#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define rep(n) for(int i = 0;i<n;i++)
#define rrep(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
/* Long Long Int */
#define int long long int
const int N = (int)1e5+5;

int n, k;
vector<int> h(N+100), dp(N+100);
//RECURSION
int soln(int current){
    // trace(current);/
    if(current >= n)return M;
    if(current == n-1)return 0;
    int &ans = dp[current];
    if(ans != -1)return ans;

    ans = M;
    for (int i = 1; i <= k; ++i)
    {
        ans = min(ans, soln(current+i) + abs(h[current]-h[current+i]));
    }

    return ans;

}
 
void solve(){
    // int n, k;
    cin>>n>>k;

    // memset(dp, -1, sizeof(dp)); Memset not on vectors
    fill(all(dp), M);
    for (int i = 0; i < n; ++i)
    {
        cin>>h[i];
    }
    // cout<<soln(0);

//ITERATION
    dp[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 1; j <= k && i-j>=0 ; ++j)
        {
            dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]) );
        }
    }

    cout<<dp[n-1]<<endl;
    return;

}

signed main()
{
    FAST
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;

return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long llmax(long long a, long long b){return a>b?a:b;}
int assort(const void *a, const void *b){return *(int*)a-*(int*)b;}
int main(void){
    int n;
    long long tmp=0,ans=0;
    scanf("%d",&n);
    int a[n];
    for (int i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    qsort (a,n,sizeof(int),assort);
    if  (n%2==0){
        for(int i=0; i<n/2; i++){
            ans-=a[i];
            ans+=a[n/2+i];
        }
        for (int i=1; i<n/2; i++){
            ans-=a[i-1];
            ans+=a[n/2+i];
        }
    } else {
        for (int i=0; i<=n/2; i++){
            ans-=a[i];
        }
        for (int i=0; i<=n/2-2; i++){
            ans-=a[i];
        }
        for (int i=n/2+1; i<n; i++){
            ans+=a[i]*2;
        }
        for (int i=0; i<n/2; i++){
            tmp-=a[i]*2;
        }
        for (int i=n/2; i<n; i++){
            tmp+=a[i];
        }
        for (int i=n/2+2; i<n; i++){
            tmp+=a[i];
        }
    }
    printf("%lld\n",llmax(ans,tmp));
	return 0 ;
}

Measured memory_bytes: 892
import sys
input = sys.stdin.readline

N =int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

sumA1 = A1[0]
sumA2 = sum(A2)
total = sumA1 + sumA2
ans = total
for i in range(1,N):
    sumA1 += A1[i]
    sumA2 -= A2[i-1]
    total = sumA1+sumA2
    ans = max(ans,total)
print(ans)
    


Measured memory_bytes: 9080
#include <stdio.h>

int main(){
	char a, b;
	scanf("%c %c", &a, &b);
	if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
		printf("%c\n", 'H');
	}
	else{
		printf("%c\n", 'D');
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,i=0;
    cin>>n;
    char a[150],b[150];
    cin>>a>>b;
    while(i!=n)
        printf("%c%c",a[i],b[i]),i++;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
p=[int(i) for i in input().split()]
q=[(i+1)/2 for i in p]
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=S[i]+q[i]
ans=0
for i in range(N-K+1):
    ans=max(ans,S[i+K]-S[i])
print(ans)

Measured memory_bytes: 82440
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int n;
	int g,k;
	cin>>n;
	if(n%2) k=n/2+1;
	else k=n/2;
	g=n/2;
	cout<<k*g<<endl;
	return 0;
}

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

int main() {
  long int a,b,c,d,e;
  string s,t;
  cin>>a>>b;
  
  c=min({a,b});
  d=max({a,b});
  e=0;
  for(long int i=1;i<1000000;i++){
  	if((c*i)%d==0){
    	e=i;
      	break;
    }
    
  }
    
  cout<<c*e<<endl;
  
  return 0;
}
  

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

namespace _001_FindingMissingCards
{
    /*
     * S -> 0
     * H -> 1
     * C -> 2
     * D -> 3
     */

    class Program
    {
        static void Main()
        {
            string line = Console.ReadLine();
            int num = Convert.ToInt32(line);
            int [,] cards = new int[4, 13];
            for (int i = 0; i < num; i++)
            {
                string sample1 = Console.ReadLine();
                string[] sn = sample1.Split(' ');
                string suit = sn[0];
                int a = Convert.ToInt32(sn[1]);
                if (suit == "S")
                {
                    cards[0, a - 1] = 1;
                }
                else if (suit == "H")
                {
                    cards[1, a - 1] = 1;
                }
                else if (suit == "C")
                {
                    cards[2, a - 1] = 1;
                }
                else if (suit == "D")
                {
                    cards[3, a - 1] = 1;
                }
            }
            for(int i = 0; i< 4; i++)
                for (int j = 0; j < 13; j++)
                {
                    if (cards[i, j] == 0)
                    {
                        if (i == 0)
                        {
                            Console.WriteLine("S {0}", j + 1);
                        }
                        else if (i == 1)
                        {
                            Console.WriteLine("H {0}", j + 1);
                        }
                        else if (i == 2)
                        {
                            Console.WriteLine("C {0}", j + 1);
                        }
                        else if (i == 3)
                        {
                            Console.WriteLine("D {0}", j + 1);
                        }
                    }
                }
        }
    }
}

Measured memory_bytes: 9224
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    int k;
    cin >> k;
    string s = "ACL";
    rep(i,k) cout << s;

    return 0;
}


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

vector<vector<int>> friends;
vector<vector<int>> brock;
vector<int> check;

int bfs(int root,int now){
    int ans=0; int l=0;
    while(l<friends[root].size()){
        int next=friends[root][l];
        if(!check[root]){
            check[root]=now;
            ans++;
        }
        if(!check[next]) ans+=bfs(next,now);
        l++;
    }
    return ans;
}


int main(){
    int n,m,k; cin >> n >> m >> k;
    friends.resize(n);
    brock.resize(n);
    check=vector<int>(n,0);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
    }
    rep(i,k){
        int c,d; cin >> c >> d;
        c--; d--;
        brock[c].push_back(d);
        brock[d].push_back(c);
    }
    
    vector<int> ans(n+1,0);

    int nownow=1;

    rep(i,n){
        if(!check[i]){
            ans[nownow]=bfs(i,nownow);
            nownow++;
        }
    }

    vector<int> br(n,0);

    rep(i,n){
        rep(j,brock[i].size()){
            if(check[brock[i][j]]==check[i]) br[i]++;
        }
    }

    rep(i,n){
        int co=ans[check[i]]-friends[i].size()-br[i]-1;
        printf("%d ",max(0,co));
    }
return 0;
}


Measured memory_bytes: 13440
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
typedef long long ll;
string s[305];
int ans[305][305];
signed main(){
    int h,w,k;cin>>h>>w>>k;
    rep(i,h)cin>>s[i];
    int now=0;

    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#'){
                now++;
                ans[i][j]=now;
            }
        }
    }

    rep(i,h){
        rep(j,w-1){
            if(ans[i][j]&&!ans[i][j+1])ans[i][j+1]=ans[i][j];
        }
    }

    rep(i,h){
        for(int j=w-1;j>0;j--){
            if(ans[i][j]&&!ans[i][j-1])ans[i][j-1]=ans[i][j];
        }
    }
    rep(i,h-1){
        rep(j,w){
            if(ans[i][j]&&!ans[i+1][j])ans[i+1][j]=ans[i][j];
        }
    }
    for(int i=h-1;i>0;i--){
        rep(j,w){
            if(ans[i][j]&&!ans[i-1][j])ans[i-1][j]=ans[i][j];
        }
    }

    rep(i,h){
        rep(j,w){
            if(j)cout<<' ';cout<<ans[i][j];
        }cout<<endl;
    }
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
#define N 90
#define mod 1000000007

int n;
long long f[N];
vector<pair<long long,long long> > q[N];

long long read(){
	long long x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
 
int main(){
	f[0]=f[1]=1;
	for (int i=2;i<N;i++) f[i]=f[i-2]+f[i-1];
	q[1].push_back(make_pair(1,2));
	q[1].push_back(make_pair(1,3));
	for (int i=2;i<N-2;i++)
		for (int j=0;j<(int)q[i-1].size();j++){
			long long x=q[i-1][j].second,y=q[i-1][j].first;
			for (y+=x;y<=f[i+2];y+=x) q[i].push_back(make_pair(x,y));
		}
	for (int t=read();t;t--){
		long long x=read(),y=read(),ans=1,cnt=0;
		if (x>y) swap(x,y);
		while (f[ans+1]<=x&&f[ans+2]<=y) ans++;
		if (ans==1){
			printf ("1 %lld\n",1ll*x*y%mod);
			continue;
		}
		for (int i=0;i<(int)q[ans-1].size();i++){
			long long tx=q[ans-1][i].first,ty=q[ans-1][i].second;
			if (x>=ty&&y>=tx+ty) cnt=(cnt+(y-tx)/ty)%mod;
			if (y>=ty&&x>=tx+ty) cnt=(cnt+(x-tx)/ty)%mod;
		}
		printf("%lld %lld\n",ans,cnt);
	}
	return 0;
}

Measured memory_bytes: 4096
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
Asort = sorted(A)[:: -1]
L = [0] * N  # 左からi番目までのgcdをメモった配列
R = [0] * N  # 右からi番目までのgcdをメモった配列
L[0] = A[0]
R[0] = A[N - 1]
for i in range(1, N):
	L[i] = gcd(L[i - 1], A[i])
	R[i] = gcd(R[i - 1], A[N - 1 - i])
ans = max(L[N - 2], R[N - 2])
for j in range(1, N - 1):
	ans = max(ans, gcd(L[j - 1], R[N - j - 2]))
print(ans)

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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
const long mod = 1000000007;

int main(){
    long long int N;
    int K;
    cin >> N >> K;
    long long int NN = N;
    long long int count = (N / 11) * 5;
    N %= 11;
    N *= 7;
    for(long long int i = 1;i <= N-16;i++){
        if(i % 7 != 0 && i % 7 != 6 && (9*i+6) % 11 == K){
            count++;
        }
    }
    if(NN > 100 && K == 10){
        cout << count - 1 << endl;
        ED
    }
    cout << count << endl;
}

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

const ll MOD = 1000000000000000000;

int main() {
	//入力
	int x;
	cin >> x;

	//処理
	int ans = 0;
	if (x == 0)
		ans = 1;

	//出力
	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
using ll = long long;
typedef vector<int> vi;
//macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int mod = 1e9+7;
void solution(){
	int n;
	cin >> n;
	// int ans = 0;
	if(n >= 30){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// cout << ans << endl;
	return;
}

// void solution(){ //read a whole line from the input, possibly containing spaces
// 	string s;
// 	getline(cin,s);
// }
int main(){
	
    fio; // fast input output
    int t;
    t = 1;
    // cin >> t;
    while(t--){
    	// cout << "Case #" << t  << ": ";
        solution();
    }
    return 0;
};

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

string S;

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

	vector<string> table{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

	cin >> S;
	int index = 0;
	FOR(n,table.size()) {
		if (table[n]==S) {
			index=n;
		}
	}

	cout << 7-index << endl;




	return 0;
}




Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
set<ll> st;

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

  cin >> n;
  rep(i, n) cin >> a, st.insert(a);
  Cout(Size(st));
  return 0;
}


Measured memory_bytes: 7852
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

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

  if(a<=9 && b<=9){
    cout << a*b << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_H 2010
#define MAX_W 2010

ll H, W;
vector<string> S;

ll dp_l[MAX_H][MAX_W];  // [i][j] の位置から左をみたときの # までの数（自分は含まない）
ll dp_r[MAX_H][MAX_W];
ll dp_u[MAX_H][MAX_W];
ll dp_d[MAX_H][MAX_W];

signed main()
{
    cin >> H >> W;
    S.resize(H);
    REP(i, H) { cin >> S[i]; }

    for(int i = 0; i < H; ++i) {
        ll cur = 0;
        for(int j = 0; j < W; ++j) {
            dp_l[i][j] = cur;
            if(S[i][j] == '#') { cur = 0; }
            else { cur++; }
        }
        cur = 0;
        for(int j = W-1; j >= 0; --j) {
            dp_r[i][j] = cur;
            if(S[i][j] == '#') { cur = 0; }
            else { cur++; }
        }
    }
    for(int i = 0; i < W; ++i) {
        ll cur = 0;
        for(int j = 0; j < H; ++j) {
            dp_u[j][i] = cur;
            if(S[j][i] == '#') { cur = 0; }
            else { cur++; }
        }
        cur = 0;
        for(int j = H-1; j >= 0; --j) {
            dp_d[j][i] = cur;
            if(S[j][i] == '#') { cur = 0; }
            else { cur++; }
        }
    }

    ll ans = 0;
    REP(i, H) {
        REP(j, W) {
            if(S[i][j] == '#') { continue; }
            ll cand = dp_l[i][j] + dp_r[i][j] + dp_u[i][j] + dp_d[i][j] + 1;
            ans = max(ans, cand);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 130432
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stdio.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

char buf[100]; 

void lemon()
{
	rep(i,0,11) scanf("%c",buf+i);
	rep(i,0,3) printf("%c",buf[i]);
	printf(" ");
	rep(i,4,11) printf("%c",buf[i]);
	printf("\n");
}

int main()
{
	ios::sync_with_stdio(true);
	lemon();
	return 0;
}



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

int main() {
  
  int N;
  cin >> N;
  
  if(N%1110 < 10){
    cout << "Yes" << endl;
  }
  else if(N%1000%111 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sc(int a,int b,int c,int d){
    return a+b+c+d;
}
int main(void){
    int infA,mathA,sciA,engA;
    int infB,mathB,sciB,engB;
    cin>>infA>>mathA>>sciA>>engA;
    cin>>infB>>mathB>>sciB>>engB;
    int S=sc(infA,mathA,sciA,engA);
    int T=sc(infB,mathB,sciB,engB);
    if(S>T){
        cout<<S<<endl;
    }else if(S<T){
        cout<<T<<endl;
    }else if(S==T){
        cout<<S<<endl; /*cout<<T<<endl;*/
    }
    return 0;
}


Measured memory_bytes: 3076
poll_number = gets.chomp.split.map(&:to_i)

polls = []

1.upto(poll_number[0]) do
  polls << gets.chomp.split[0]
end

poll_hash = Hash.new{0}

polls.each do |poll|
  poll_hash[poll] += 1
end

max_value = poll_hash.max{ |x, y| x[1] <=> y[1] }[1]

ans =[]

poll_hash.each do |k,v|
  ans << k if v == max_value
end

puts ans.sort


Measured memory_bytes: 46180
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        int N,M;
        cin >> N >> M;
        if(N == 0) break;
        vector<vector<int>> G(N);
        for(int i=0; i<M; i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        vector<int> dist(N,-1);
        queue<int> que;
        que.push(0);
        dist[0] = 0;
        bool can = true;
        while(que.size()){
            int v = que.front();
            que.pop();
            for(int nv: G[v]){
                if(dist[nv] == -1){
                    if(dist[v] == 0) dist[nv] = 1;
                    else dist[nv] = 0;
                    que.push(nv);
                }else{
                    if(dist[v] == dist[nv]){
                        can = false;
                    }
                }
            }
        }
        vector<int> sum(2,0);
        for(int i=0; i<N; i++){
            sum[dist[i]]++;
            // cout << dist[i] << enld;
        }
        set<int> se;
        for(int i=0; i<2; i++){
            if(sum[i]%2 == 0){
                sum[i] /= 2;
                if(sum[i]){
                    se.insert(sum[i]);
                }
            }
        }
        if(se.size() and can){
            cout << se.size() << enld;
            for(int s: se){
                cout << s << enld;
            }
        }else{
            cout << 0 << enld;
        }
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  ll a,b,c,n,k;
  cin>>n>>k;
  ll ans=0;
  rep(i,1,n+1)
    {
      ll x=i%k;
      ll rem=k-x;
      if((rem+rem)%k!=0) continue;
      ll tmp=1+(n-rem)/k;
      if(n<rem) continue;
      ans+=tmp*tmp;
    }
  cout<<ans<<endl;
  return 0 ;
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n, q;
	cin >> n >> q;
	pair<int, P> w[n];
	REP(i, n){
		int s, t, x;
		cin >> s >> t >> x;
		w[i] = {x, {s-x, t-x}};
	}
	sort(w, w+n);
	int d[q];
	REP(i, q) cin >> d[i];
	int ans[q];
	REP(i, q) ans[i] = -1;
	set<int> s;
	REP(i, q) s.insert(i);
	REP(i, n){
		int first = lower_bound(d, d+q, w[i].second.first) - lower_bound(d, d+q, -1);
		int last = lower_bound(d, d+q, w[i].second.second) - lower_bound(d, d+q, -1) - 1;
		for(auto it = s.lower_bound(first); it != s.upper_bound(last); it++){
			ans[*it] = w[i].first;
		}
		s.erase(s.lower_bound(first), s.upper_bound(last));
	}
	REP(i, q) cout << ans[i] << endl;
	return 0;
} 


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }

ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }


int main(){
    ll n;
    cin >> n;
    cout << 180*(n-2) << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
   ll int x,flag;
   cin>>x;
   
   for(int j=x;j<=x+100;j++)
   {
       flag=1;
for(int i=2;i<j;i++)
{
if(j%i==0)
{
flag=0;
break;
}

}
if(flag==0)
continue;
else
{
    cout<<j;
    break;
}
   }

return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	if(N%2)for(int i=0;i<M;i++)cout << i+1 << " " << N-i << endl;
	else{
		for(int i=0;i<(M+1)/2;i++)cout << i+1 << " " << (M+1)/2*2-i << endl;
		int r=(M+1)/2*2;
		for(int i=0;i<M/2;i++)cout << r+i+1 << " " << r+M/2*2+1-i << endl;
	}
	return 0;
}

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

bool primenumver(int a){
	for (int b = 2;; b += 2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b+ 1) >a)return true;
		if (b == 2)b--;
	}
}
int main() 
{
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		if (a % 2 == 0) {
			for (int b = a-1;; b -= 2) {
				if (primenumver(b) && primenumver(b - 2)) { cout << b - 2 << " " << b<<endl; break; }
			}
		}
		else {
			for (int b = a;; b -= 2) {
				if (primenumver(b) && primenumver(b - 2)) { cout << b - 2 << " " << b<<endl; break; }
			}
		}
	}
}

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

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


def solve(items):
    from itertools import permutations
    total_weight = 0
    for i in items:
        total_weight += i.w
    best_ans = []
    best_gp = float('inf')
    # ???????????????????????????????????????????????°?????????????????§????????????
    for perm in permutations(items):
        ans = []
        squashed = False
        cw = 0
        gp = 0
        n = len(items)
        for p in perm:
            if p.s < cw:
                squashed = True
                break
            cw += p.w
            ans.append(p.name)
            gp += n * p.w
            n -= 1
        # ????????°???????????£?????´????????????????¨???????????????????????????????????????£?????????????????§????????????
        if not squashed:
            gp /= total_weight
            if gp < best_gp:
                best_gp = gp
                best_ans = ans[:]
    # ????????????????????????????????£??????????????§?????????????±?????????????????????????????????????????????????
    best_ans.reverse()
    return best_ans


def solve2(items):
    items.sort(key=lambda x:x.w, reverse=True) # ??????????????????????????????
    total_weight = 0            #  ??¢?????????????????????
    for i in items:
        total_weight += i.w
    ans = []
    # ?????£???????????¢??????????????????????????????????????????????????§???????????¢??????????????????????????????????????????????????????????????????????????¢?????????????????????????????§??°????????????
    while items:
        cap = [x.s - total_weight + x.w for x in items] #  ????????\??????????????¢?????????????????????????????¨????????°??????????????????????????????????????????????????????0??\?????????OK
        for i in range(len(items)):
            if cap[i] >= 0:     #  ??°???????????????????????????????????????????????????????????????????????????
                ans.append(items[i].name)
                i = items.pop(i)
                total_weight -= i.w #  ???????????¢?????????????????????????????????
                break
    return ans


item = namedtuple('item', ['name', 'w', 's'])
def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        items = []
        for _ in range(n):
            name, w, s = input().split()
            items.append(item(name, int(w), int(s)))
        result = solve2(items)
        print('\n'.join(result))


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

Measured memory_bytes: 8104
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;


ll ans, mx, mn, flag, sum, cnt;



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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
      long long int i,j,a,b,k,r;
      cin>>a>>b>>k;
      r = b-a;
      if(r<2*k)
      {
        for(i=a;i<=b;i++)
        {
           cout<<i<<endl;
        }
      }
      else
      {
          for(i=a,j=1;j<=k;j++,i++)
          {
              cout<<i<<endl;
          }
          for(i=b+1-k;i<=b;i++)
          {
              cout<<i<<endl;
          }

      }

      return 0;
      }


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

makeAverage (x:[]) = x
makeAverage (x:y:xs) = makeAverage (((x + y) / 2) : xs)

main = do
  n <- getInt
  vs <- getIntList
  let us = sort vs
  print $ makeAverage us

Measured memory_bytes: 508
package main

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

var (
	N     int
	A     []int
	count map[int]int = make(map[int]int)
)

func readVariables() {
	N = nextInt()
	for i := 0; i < N; i++ {
		count[nextInt()]++
	}
	A = make([]int, 0, 100000)
}

func main() {
	readVariables()
	for k, v := range count {
		if v > 1 {
			A = append(A, -k)
		}
	}
	sort.Ints(A)
	// fmt.Println(A)
	if len(A) < 2 {
		fmt.Println(0)
	} else if count[-A[0]] >= 4 {
		fmt.Println(A[0] * A[0])
	} else {
		fmt.Println(A[0] * A[1])
	}
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 7936
#include <stdio.h>

int main() {

  int n,k[10001],i,j,sum,check;
  int a[10001] = {0};

  while(1) {
    j = 0;
    sum = 0;
    check = 0;

    scanf("%d",&n);
    //    printf("n = %d\n",n);

    if(n == 0) break;

    for(i=0;i<10001;i++) a[i] = 0;

    for(i=0;i<n;i++) {

      scanf("%d",&k[i]);
      //  printf("k[%d] = %d\n",i,k[i]);
      if(k[i] == 0) {
	i--;
	n--;
      }
      if(k[i] >=2) check = 1;
      
    }

    // printf("end scanf\n");
    
    
    if(check == 1) {
      // printf("while strt\n");
      while(1) {
	for(i=0;i<n;i++) {
	  //  printf("for check\n");
	  sum++;
      k[i]--;
      a[i]++;
      if(a[i] == 2) {
	j = 1;
	break;
      }
	} 
	if(j==1) break;
	
      }
    }
    
    
    if(j == 1) printf("%d\n",sum);
    else printf("NA\n");

  }

  return 0;

}
  

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

int main() {
	int N; cin >> N;
	int arr[N];
	for (auto&& e : arr) {
    	cin >> e;
    }
	int sump = 0; int sumq = 0;
	int* p = arr; int* q = arr+N-1;
	// cout << *p << ' ' << *q << endl;
	for (int i = 0; i < N; ++i) {
    	if (sump > sumq) {
        	sumq += *q;
        	q--;
        } else {
        	sump += *p;
        	p++;
        }
    }
	cout << abs(sump - sumq) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[10], ans;
int main()
{
	for(int i = 1; i <= 7; ++i) cin >> a[i]; 
	ll ans1 = a[2] + 2 * ((a[1] / 2) + (a[4] / 2) + (a[5] / 2));
	if(a[1] && a[4] && a[5])
	{
		--a[1], --a[4], --a[5];
		ll ans2 = a[2] + 2 * ((a[1] / 2) + (a[4] / 2) + (a[5] / 2)) + 3;
		cout << max(ans1, ans2) << endl;
	}
	else cout << ans1 << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {
    
    int n,k,s;
    cin>>n>>k>>s;

    if(s==1000000000) {
        rep(i,n) {
            if(k>i) {
                cout<<s;
            }
            else {
                cout<<3;
            }
            if(i<n-1) {
                cout<<' ';
            }
        }       
    }
    else {
        rep(i,n) {
            if(k>i) {
                cout<<s;
            }
            else {
                cout<<1000000000;
            }
            if(i<n-1) {
                cout<<' ';
            }
        }
    }

 return 0;
}

Measured memory_bytes: 1280