akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF 1000000100;

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    cin>>n>>m;
    cout<<n*m nn;
    return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>
int x[100005],w=1,n,m,a,i;
long s=0;
main(){
scanf("%d %d",&n,&m);
for(i=1;i<n;i++){
scanf("%d",&x[i]);
}
for(i=0;i<m;i++){
scanf("%d",&a);
if(a>0){
for(n=0;n<a;n++){
s+=x[w+n];
}
}else{
for(n=a;n<0;n++){
s+=x[w+n];
}
}
w+=a;
}
printf("%ld\n",s%100000);
return 0;
}

Measured memory_bytes: 984
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,f=0;
	cin>>n;
	while(n>0){
		if(n%10==7){
			f=1;
			break;
		}
		n=n/10;
	}
	if(f) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int BinarySearch(int *arr,int low,int high,int find)
{
    int mid = 0;

    while(low <= high)
    {
        mid = (low+high)/2;
        if(find < arr[mid])
            high = mid-1;
        else if(find > arr[mid])
            low = mid+1;
        else
            return 1;
    }
    return 0;
}

int main(int argc, char *argv[])
{
    int q = 0;
    cin>>q;
    int *T = new int[q];
    for(int j=0;j<q;j++)
        cin>>T[j];

    int n = 0;
    cin>>n;
    int *S = new int[n];
    for(int i=0;i<n;i++)
        cin>>S[i];

    int num = 0;
    for(int i = 0;i<n;i++)
    {
        if(BinarySearch(T,0,q,S[i]))
            num ++;
    }
    cout << num << endl;
    return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN
    
    ll n,m;cin>>n>>m;
    vector<pair<ll,ll>> v(0);
    REP(i,n){
        ll a,b;cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    VSORT(v);
    ll ans=0;
    for(auto p:v){
        ll a = p.first;
        ll b = p.second;
        if(m<=b) {
            ans += a*m;
            break;
        } 
        else {
            ans+=a*b;
            m-=b;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    vector<ll>v;
    map<ll,ll>mp;
    for(ll i=0;i<n;i++)
        {
            cin>>a[i];
            if(find(v.begin(),v.end(),a[i])==v.end())
                v.push_back(a[i]);
                mp[a[i]]++;
        }
        sort(v.begin(),v.end());
        //reverse(v.begin(),v.end());
        ll cnt=0;
        ll rc=0;
        if(v.size()==1)
            {cout<<"0\n";
        return 0;}
    for(ll i=0;i<v.size()-2;i++)
    {
        for(ll j=i+1;j<v.size()-1;j++)
        {
            for(ll k=j+1;k<v.size();k++)
            {
                if(v[i]+v[j]>v[k])
                    {
                        rc+=(mp[v[i]]*mp[v[j]]*mp[v[k]]);
                    }
                else
                    break;
            }
        }
    }
    cout<<rc<<"\n";
}

Measured memory_bytes: 3596
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	string s, t;
	cin >> s >> t;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}



Measured memory_bytes: 256
N = int(input())
S = list(input())
ans = "No"
first = ""
latter = ""
if N % 2== 0:
    for i in range(0,N//2):
        first += S[i]
    for j in range(N//2,N):
        latter += S[j]
    if first == latter:
        ans = "Yes"
        
print(ans)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
   void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
vec<vec<int>> G;

void dfs(int pos, vec<int> &dist) {
   if (dist[pos] == -1) return;
   for (int to : G[pos]) {
      if (dist[to] == -1) {
         dist[to] = dist[pos] + 1;
         dfs(to, dist);
      }
   }
}

int main() {
   cin >> N;
   G = vec<vec<int>>(N);
   rep (i, N-1) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }
   vec<int> dist1(N, -1), dist2(N, -1);
   dist1[0] = 0;
   dfs(0, dist1);
   dist2[N-1] = 0;
   dfs(N-1, dist2);

   int b = 0, w = 0;
   rep (i, N) {
      if (dist1[i] <= dist2[i]) {
         b++;
      } else {
         w++;
      }
   }

   if (b > w) {
      puts("Fennec");
   } else {
      puts("Snuke");
   }

   return 0;
}

Measured memory_bytes: 11136
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long x, y;
  cin >> x >> y;
  cout << (abs(x - y) > 1 ? "Alice" : "Brown") << endl;
  return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int coin = 0;
  if(a>b){
    coin+=a;
    a--;
    coin+=a;
  }
  else if(a<b){
    coin+=b;
    b--;
    coin+=b;
  }
  else if(a==b){
    coin+=a+b;
  }
  cout<<coin<<endl;
  return 0;
}


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

int main() {
  int N , M , C;
  cin >> N >> M >> C;
  vector<int> A(M);
  vector<int> B(M);
  int p=0;
  int ans=0;
  for(int i=0 ; i<M ; i++){
    cin >> B.at(i);
  }
  for(int j=0 ; j<N ; j++){
    for(int l=0 ; l<M ; l++){ 
    cin >> A.at(l);
    }
    for(int k=0 ; k<M ; k++){
      p += A.at(k)*B.at(k);
    }
    if(p+C > 0){
      ans++;
    }
    p=0;
  }
  cout << ans << endl;
}


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


void solve(std::string S, std::string T){
    ll ans=0;
    rep(i,3)(S[i]==T[i])?ans++:0;
    cout<<ans<<endl;
    
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 256
s = list(input())
for _ in range(int(input())):
    li = input().split()
    li[1] = int(li[1])
    li[2] = int(li[2]) + 1
    if li[0] == "print":
        print("".join(s[li[1]:li[2]]))
    elif li[0] == "reverse":
        s[li[1]:li[2]] = s[li[1]:li[2]][::-1]
    else:
        s[li[1]:li[2]] = li[3]



Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());
  
  rep(i,n-1){
    if (a[i]==a[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  string N;
  cin >> N;
  for(auto &c : N) {
    if(c == '9') cout << 1;
    else if(c == '1') cout << 9;
    else cout << c;
  }
  cout << endl;
}

Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    // writeln(a);
    auto s = new long[](n + 1);
    s[1] = a[0];
    foreach (i; 0 .. n)
    {
        s[i + 1] = s[i] + a[i];
    }
    // writeln(s);
    long ans;
    long mod = (10 ^^ 9) + 7;
    long aj;
    foreach (i; 0 .. n)
    {
        // writeln(a[i], "  ", s[n] - s[i + 1]);
        a[i] %= mod;
        aj = s[n] - s[i + 1];
        aj %= mod;
        ans += a[i] * aj;
        ans %= mod;

    }
    writeln(ans % mod);

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 14232
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)
 
using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
 
pair<map<int,ll>, int> dfs(const vector<vecint>& g, const vecint& clr,
    vecll& ans, int i, int p = -1) {
  ll sz = 1;
  map<int,ll> ret;
  for (auto&& to : g[i]) {
    if(to == p) continue;
    auto [cret, csz] = dfs(g, clr, ans, to, i);
    ll icsz = csz - cret[clr[i]];
    if (cret.size() > ret.size()) swap(cret, ret);
    for (auto&& [c, num] : cret) {
      ret[c] += num;
    }
    ans[clr[i]] -= icsz * (icsz + 1) / 2;
    sz += csz;
  }
  ret[clr[i]] = sz;
  return make_pair(move(ret), sz);
}
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vecint clr(n);
  REP(i,n)cin>>clr[i];
  vector<vecint> g(n);
  REP(i,n-1) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vecll ans(n+1, n*(n+1)/2);
  auto [cret, _] = dfs(g, clr, ans, 0);
  FOR(i,1,n+1) {
    ll icsz = n - cret[i];
    ans[i] -= icsz * (icsz+1) / 2;
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 82152
A = [[int(i) for i in input().split()] for _ in range(3)]
N = int(input())
for i in range(N) :
    b = int(input())
    for j in range(3) :
        if b in A[j] :
            x = A[j].index(b)
            A[j][x] = 0
        
#print(A)

for i in range(3) :
    if all(A[i][n] == 0 for n in range(3)) or all(A[m][i] == 0 for m in range(3)):
        print('Yes')
        exit()
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0 :
    print('Yes')
    exit()
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0 :
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 9248
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char T; int l, a, b, x[1000], d[1000], M, N, y[1000], z[1000];
int main() {
	while (true) {
		M = 0;
		memset(y, 0, sizeof(y));
		cin >> b >> l; if (!l) { break; }
		for (int i = 1; i <= b; i++) {
			cin >> T >> x[i];
			if (T == 'L') { d[i] = 0; M = max(M, x[i]); }
			else { d[i] = 1; M = max(M, l - x[i]); }
		}
		N = 0;
		for (int i = 1; i <= M + 1; i++) {
			memset(z, 0, sizeof(z));
			for (int j = b; j >= 1; j--) {
				if (y[j] == 0) {
					if (d[j] == 0) {
						x[j]--;
					}
					else {
						x[j]++;
					}
					if (x[j]<0 || x[j]>l) {
						y[j] = 1;
					}
					else {
						z[x[j]]++;
					}
					if (M+1 == i) {
						if (N) {
							if (x[j] < 0) { N = j; }
						}
						else {
							N = j;
						}
					}
				}
			}
			for (int j = b; j >= 1; j--) {
				if (z[x[j]] >= 2) {
					if (d[j]) { d[j] = 0; }
					else { d[j] = 1; }
				}
			}
		}
		cout << M << ' ' << N << endl;
	}
}

Measured memory_bytes: 1176
# n = int(input())
# s = input()
n,m = map(int,input().split())
da = list(map(int,input().split()))
# a = [int(input()) for i in range(n)]
# da = [list(map(int,input().split())) for i in range(m)]

a = 0
for i in da: a += i
co = 0
b = (a-1)//(4*m)
for i in range(n):
    if b < da[i]: co += 1
# print(co)
if co >= m:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a;
  int n,k,cnt,sum;
  bitset<32> m;
  cin >> n >> k;

  for(ii=0;ii<pow(2,n);ii++){
    m = ii;
    cnt = 0;
    sum = 0;
    for(jj=0;jj<n;jj++){
      if(m.test(jj)){
        cnt++;
        sum += pow(2,jj);
      }
    }

    if(cnt == k){
      cout << sum << ":";
      for(jj=0;jj<n;jj++){
        if(m.test(jj)){
          cout << " " << jj;
        }
      }
      cout << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3260
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  long long v = 1, w = 1;
  for (int i = 0; i < n; ++i)
  {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    long long v1, w1, v2, w2;
    v1 = (v + a - 1) / a * a;
    w1 = v1 / a * b;
    w2 = (w + b - 1) / b * b;
    v2 = w2 / b * a;
    if (v1 >= v && w1 >= w)
    {
      if (v2 >= v && w2 >= w)
      {
        if (v1 + w1 < v2 + w2)
        {
          v = v1, w = w1;
        }
        else
        {
          v = v2, w = w2;
        }
      }
      else
      {
        v = v1, w = w1;
      }
    }
    else if (v2 >= v && w2 >= w)
    {
      v = v2, w = w2;
    }
  }
  printf("%lld\n", v + w);
  return 0;
}

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

using namespace std;

const int N = 100010;

vector<int> graph[N];

vector<int> bfs(int from, int n) {
  vector<int> dist(n, -1);
  dist[from] = 0;
  queue<int> q;
  q.push(from);
  while (!q.empty()) {
    int u = q.front(); q.pop();
    for (int v : graph[u]) {
      if (dist[v] == -1) {
        dist[v] = 1 + dist[u];
        q.push(v);
      }
    }
  }
  return dist;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  vector<int> black = bfs(0, n);
  vector<int> white = bfs(n - 1, n);
  int fen = 0, snu = 0;
  for (int i = 0; i < n; ++i) {
    if (black[i] <= white[i]) {
      ++fen;
    } else {
      ++snu;
    }
  }
  return !printf("%s\n", fen > snu ? "Fennec" : "Snuke");
}

Measured memory_bytes: 6656
#include<iostream>
#include<cstdio>
#include<ctype.h>
#include<cstdlib>
using namespace std;
inline int read(){
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
    return f?-x:x;
}
inline void Yeah(){puts("Yes");exit(0);}
int main(){ 
    int n=read(),m=read(),k=read();
    for(int i=1;i<=n;++i){int kk=(k-i*m),a=n-i-i;if(!kk||a&&(kk>>31&1)==(a>>31&1)&&kk%a==0 && kk/a<=m)Yeah();}
    puts("No");
    return 0;
}

Measured memory_bytes: 256
"use strict";
 
const Main = (input) => {
  let xs = input.trim().split(' ');
  let A = parseInt(xs[0],10) + parseInt(xs[1],10);
  let B = parseInt(xs[0],10) + parseInt(xs[2],10);
  let C = parseInt(xs[1],10) + parseInt(xs[2],10);
  
  const compare = (a, b) => {
  return a - b;
  }
 
  let ans = [A,B,C];
  ans.sort(compare);
  console.log(ans[0]);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 21064
x = int(input())
count = 0

if 6 < x <= 11:
	print(2)
elif x <= 6:
	print(1)
else:
	initcount = x // 11
	if initcount:
		count += initcount*2
		x -= initcount * 11
		mod = x % 11
		if 6 < mod <= 11:
			count += 2
		elif 0 < mod <= 6:
			count += 1
		else:
			pass
		print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

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

	if((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}else 
		cout << "Odd" << endl;
	return 0;

}


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

struct st {
	int from, to, c;
};
vector<st>E;
int d[1000];
int main() {
	int v, e; scanf("%d%d", &v, &e);
	rep(i, e) {
		int s, t; scanf("%d%d", &s, &t);
		E.push_back({ s,t,-1 });
	}
	rep(i, v)rep(j, e) {
		st s = E[j];
		if (d[s.from] != INF&&d[s.to] > d[s.from] + s.c) {
			d[s.to] = d[s.from] + s.c;
			if (i == v - 1) {
				puts("1"); return 0;
			}
		}
	}
	puts("0");
}

Measured memory_bytes: 3204
import itertools

n,m,r=map(int,input().split())
r=list(map(int,input().split()))

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

##############################

d = [[float("inf") for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
warshall_floyd(d)

ans=float("inf")
list_r=list(itertools.permutations(r))
# print(r)
# print(list_r)
for i in range(len(list_r)):
    tmp=0
    for j in range(len(r)-1):
        tmp+=d[list_r[i][j]-1][list_r[i][j+1]-1]
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 65880
s = input()
n = len(s)
ans = 0
for bit in range( 1 << (n-1)):
  f = s[0]
  for i in range(n-1):
    if bit & (1 << i):
      f += "+"
    f += s[i+1]
  ans += sum(map(int, f.split("+")))
print(ans)   

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    sort(all(A));
    
    if(N%2==0) rep(i,N/2) if(A[2*i] != 2*i+1 || A[2*i+1] != 2*i+1){
        cout << 0 << endl;
        return 0;
    }
    
    if(N%2==1){
        if(N==1 && A[0] == 0){
            cout << 1 << endl;
            return 0;
        }
        else if(N > 1 && A[0] == 0){
            rep(i,N/2) if(A[2*i+1] != 2*i+2 || A[2*i+2] != 2*i+2){
                cout << 0 << endl;
                return 0;
            }
        }else{
            cout << 0 << endl;
            return 0;
        }
        
    }
    
    ll ans = 1;
    ll mod = 1000000007;
    
    if(N%2==0){
        rep(i,N/2){
            ans = ans * 2;
            ans = ans % mod;
        }
    }else{
        rep(i,(N-1)/2){
            ans = ans * 2;
            ans = ans % mod;
        }
    }
        
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 640
using System;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = int.Parse(Console.ReadLine());
        }

        //出力用のテキスト
        string ans = "second";

        //判定
        for (int i = 0; i < N; i++) {
            if (a[i] % 2 == 1) {
                ans = "first";
                break;
            } 
        }

        //出力
        Console.WriteLine(ans);
    }
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


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

	int N, M, X;
	vector<int> A;

	cin >> N >> M >> X;
	for(int i=1; i<=M; i++){
		int a;
		cin >> a;
		A.push_back(a);
	}

	int c1 = 0, c2 = 0;
	for(int i=0; i<M; i++){
		if(A[i] < X){
			c1++;
		}
		if(A[i] > X){
			c2++;
		}
	}
	int c = min(c1, c2);
	printf("%d\n",c);
	return 0;
}

Measured memory_bytes: 3720
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	lint n;cin>>n;int out=0;
	for(lint i=2;i*i<=n;i++){
		int t=0;
		while(n%i==0){
			n/=i;t++;
		}
		int x=1;
		while(t>=x){
			out++;t-=x;x++;
		}
	}
	if(n>1L) out++;
	cout<<out<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}

ll digit(ll N){
  ll res;
  res = floor(log10(N)) + 1;
  return res;
}



int main(){
  ll N;
  cin >> N;
  
  
  ll M = floor(pow(N, 0.50));
  //cout << M << endl;
  
  ll res = 1;
  
  if(digit(N) == 1){
    res = 1;
  }else{
    res = digit(N);
    rep(i, M){
      if(N%(i+1) == 0 && res > digit(N/(i+1))){
        //cout << i+1 << endl;
        res = digit(N/(i+1));
      }
    }
  }
  
  cout << res;
         
}

Measured memory_bytes: 384
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
double p[3000];
double dp[3000][3000];

void init()
{
}

void solve()
{
    dp[1][0] = 1. - p[1];
    dp[1][1] = p[1];

    FOR(i, 2, N+1){
        FOR(j, 0, N+1){
            dp[i][j] = dp[i-1][j]*(1.-p[i]) + dp[i-1][j-1]*p[i];
        }
    }
    double ans = 0.;
    int n = N/2+1;
    FOR(i, n, N+1){
        ans += dp[N][i];
    }
    cout << fixed;
    cout << setprecision(10) << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 1, N+1) cin >> p[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 70528
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		LinkedList<Character> list = new LinkedList<Character>();
		for(char c : S.toCharArray()){
			list.add(c);
		}
		int Q = sc.nextInt();
		boolean r = false;
		for(int q = 0 ; q < Q ; ++q){
			int T = sc.nextInt();
			if(T == 1){
				r = !r;
			}else{
				int f = sc.nextInt();
				char c = sc.next().charAt(0);
				if(f == 1){
					if(r){
						list.addLast(c);
					}else{
						list.addFirst(c);
					}
				}else{
					if(r){
						list.addFirst(c);
					}else{
						list.addLast(c);
					}					
				}
			}
		}
		if(r){
			Collections.reverse(list);
		}
		StringBuilder ret = new StringBuilder();
		for(char c : list){
			ret.append(c);
		}
		System.out.println(ret);
	}
}


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

using namespace std;
#define ll long long
#define ld long double
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int k, a, b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++) {
        if(i % k == 0 && i >= k) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}


//座圧(破壊的)
int cocomp(ll*a,int n){
	//0～cnt-1に圧縮
	ll*b=(ll*)malloc(sizeof(ll)*n);
	memcpy(b,a,sizeof(ll)*n);
	sortup(b,n);
	int cnt=1;
	rep(r,1,n)if(b[r]!=b[cnt-1])b[cnt++]=b[r];
	rep(i,0,n){
		int l=0,r=cnt;
		while(r-l>1){int m=(l+r)/2;if(b[m]>a[i])r=m;else l=m;}
		a[i]=l;
	}
	free(b);
	return cnt;
}

ll a[200010];
ll cum[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		int x,y;
		scanf("%d%d",&x,&y);
		a[2*i]=x;
		a[2*i+1]=y+1;
	}
	cocomp(a,2*n);
	rep(i,0,n){
		cum[a[2*i]]++;
		cum[a[2*i+1]]--;
	}
	ll ans=cum[0];
	rep(i,0,2*n+5){
		cum[i+1]+=cum[i];
		ans=max(ans,cum[i+1]);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 6244
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar('0'+aa%10);
	return;
}
int n,A,B,C,D;
char s[200005];
int main()
{
	n=read(),A=read(),B=read(),C=read(),D=read();
	scanf("%s",s+1);
	for(int i=B+1;i<=D;++i) if(s[i]=='#'&&s[i-1]=='#') {puts("No");return 0;}
	for(int i=A+1;i<=C;++i) if(s[i]=='#'&&s[i-1]=='#') {puts("No");return 0;}
	if(C<D) {puts("Yes");return 0;}
	for(int i=B-1;i<=D-1;++i) if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') {puts("Yes");return 0;}
	puts("No");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 100050;

int N, M;
bool flag[MAX_N];
int num[MAX_N];

int x[MAX_N], y[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N >> M;

    for (int i = 1; i <= M; i++) {
        std::cin >> x[i] >> y[i];
    }

    for (int i = 1; i <= N; i++) {
        num[i] = 1;
        flag[i] = false;
    }

    flag[1] = true;

    for (int i = 1; i <= M; i++) {
        num[y[i]]++;
        num[x[i]]--;
        if (flag[x[i]]) {
            flag[y[i]] = true;
        }
        if (num[x[i]] == 0) {
            flag[x[i]] = false;
        }
    }

    int ret = 0;
    for (int i = 1; i <= N; i++) {
        if (flag[i]) {
            ret++;
        }
    }
    std::cout << ret << std::endl;
    
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
#define INF 200000

int main() {
    int N; cin >> N;
    vector<char> c(N);
    rep(i, N) cin >> c[i];
    vector<int> sr(N+1), sw(N+1);
    rep(i, N) {
        sr[i+1] = sr[i];
        sw[i+1] = sw[i];
        if (c[i] == 'R') sr[i+1]++;
        else sw[i+1]++;
    }
    int ans = INF;
    rep(i, N+1) {
        int mx = max(sw[i], sr[N] - sr[i]);
        chmin(ans, mx);
    }
    cout << ans << endl;
}


Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int n;
int main(){
  cin >> n;
  int a = (int)ceil(n/1.08);
  int x = a*1.08;
  if(n == x){
    cout << a;
  }else{
    cout<<":(";
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int answer = 0;
		for(int x = 0; x <= k; x++){
			for(int y = 0; y <= k; y++){
				int z = s - x - y;
				if((0 <= z) && (z <= k)){
					answer += 1;
				}
			}
		}
		
		System.out.println(answer);
	}
}

Measured memory_bytes: 23124
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N = int(input())
    H = list(map(int,input().split()))
    cnt = 0
    ans = 0
    H[0]
    for i in range(1,N):
        if H[i-1] >= H[i]:
            cnt += 1
            ans = max(cnt,ans)
        else:
            cnt =0
    print(ans)
if __name__ == "__main__":
    main()


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

int main() {
  int A;
  int B;
  cin >> A >> B;
  if ((A + B) % 2 == 0){
    cout << (A + B) / 2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}



Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <typeinfo>
#include <map>
#define INF 100000000
#define rep(i,a) for(int i=0;i<(a);i++)

using namespace std;
typedef long long ll;

int main(){
    double f;
    while(cin>>f){
        double data[10];
        data[0]=f;
        for(int i=1;i<10;i++){
            if((i+1)%2==0)data[i]=data[i-1]*2;
            else data[i]=data[i-1]/3;
        }
        double ans=0;
        rep(i,10)ans+=data[i];
        printf("%12.10lf\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1236
n = int(input())

A = []
max1 = 0
max2 = 0
max1w = False
for _ in range(n):
    a = int(input())
    A.append(a)
    if a > max1:
        max2 = max1
        max1 = a
        max1w = False
    elif a == max1:
        max1w = True
    elif a > max2:
        max2 = a

for a in A:
    if a == max1 and max1w:
        print(max1)
    elif a == max1:
        print(max2)
    else:
        print(max1)


Measured memory_bytes: 12532
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 3) ans += 100000;
  else if (x == 2) ans += 200000;
  else if (x == 1) ans += 300000;
  if (y == 3) ans += 100000;
  else if (y == 2) ans += 200000;
  else if (y == 1) ans += 300000;
  if (x == 1 && y == 1) ans += 400000;
  cout << ans << endl;
 
  
 


  
  return 0;
}

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

using namespace std;

#define N 10

int main(){
  int tc; //test case
  cin >> tc;

  while(tc-->0){
    //maximun 1024 pattern. try all

    int n[10];
    for(int i=0; i<N; i++){ scanf("%d", &n[i]); }

    int b, c; //tube
    bool ans = false;
    for(int i=0; i<(1<<N); i++){
      int bit=i; b=c=0;
      for(int j=0; j<N; j++){
	if(bit%2==0){ // to B
	  if(b < n[j]) b=n[j];
	  else break;
	} else { // to C
	  if(c < n[j]) c=n[j];
	  else break;
	}
	if(j==N-1){
	  ans=true;
	  goto OUT;
	}
	bit /= 2;
      }
    }

  OUT:
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
long long gcd(long long m, long long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
int main()
{
  int n,i;
  long long m,t,res;
  long long a[N_MAX];
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> a[i];
    a[i]/=2;
  }
  t=a[0];
  for(i=1;i<n;i++)
    t=t*a[i]/gcd(t,a[i]);
  for(i=0;i<n;i++)
    if((t/a[i])%2==0){
      cout << "0" << endl;
      return 0;
    }
  res=(m/t+1)/2;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int N = sc.nextInt();
        int M = sc.nextInt();

        int pow = 1;
        for (int i = 0; i < M; i++) {
            pow *= 2;
        }
        System.out.println((1900 * M + 100 * (N - M)) * pow);
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <map>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif
#define PI 3.1415926535897932384626433832795
#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;
#define vv(t) vector<t>

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}



int main(){
    int N;
    cin >> N;
    vv(int) A(N+1);
    for(int i=2; i<=N; i++){
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }
    REP2(i, N){
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4052
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)998244353;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();

        Map<Integer, Integer> map = new HashMap<>();

        for (int i=0; i<n; i++) {
            int tmp = sc.nextInt();
            if (map.containsKey(tmp)) {
                map.put(tmp, map.get(tmp)+1);
            } else {
                map.put(tmp, 1);
            }
        }

//        System.out.println(map);

        Set<Integer> set = map.keySet();
        List<Integer> list2 = new ArrayList<>();
        List<Integer> list4 = new ArrayList<>();

        for (int t: set) {
            if (map.get(t) >= 2) list2.add(t);
            if (map.get(t) >= 4) list4.add(t);

        }

//        Collections.reverse(list2);
//        Collections.reverse(list4);

        Collections.sort(list2, Collections.reverseOrder());
        Collections.sort(list4, Collections.reverseOrder());
//        System.out.println(list2);
//        System.out.println(list4);


        System.out.println(Math.max((list2.size() < 2) ? 0 : (long)list2.get(0) * (long)list2.get(1), (list4.size() < 1) ? 0 : (long)list4.get(0) * (long)list4.get(0)));

    }

}



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

int main(){
  string A,B,C;
  cin >> A >> B >> C;
  
  int Act=0,Bct=0,Cct=0;
  int k=0;
  
  while(true){
    if(k==0){
      if(Act==A.size()){
        cout << "A" << endl;
        return 0;
      }
      if(A[Act]=='a'){
        k=0;
        Act++;
      }else if(A[Act]=='b'){
        k=1;
        Act++;
      }else{
        k=2;
        Act++;
      }
    }else if(k==1){
      if(Bct==B.size()){
        cout << "B" << endl;
        return 0;
      }
      if(B[Bct]=='a'){
        k=0;
        Bct++;
      }else if(B[Bct]=='b'){
        k=1;
        Bct++;
      }else{
        k=2;
        Bct++;
      }
    }else{
      if(Cct==C.size()){
        cout << "C" << endl;
        return 0;
      }
      if(C[Cct]=='a'){
        k=0;
        Cct++;
      }else if(C[Cct]=='b'){
        k=1;
        Cct++;
      }else{
        k=2;
        Cct++;
      }
    }
  }
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

n = int(input())
A = []
#リストAにappend()を使って格納していく
for _ in range(n):
    A.append(int(input()))


sort_A = sorted(A, reverse=True)
max_1 = sort_A[0]
max_2 = sort_A[1]

if max_1 == max_2:
    for _ in range(n):
        print(max_1)
else:
    for i in range(n):
        if A[i] == max_1:
            print(max_2)
        else:
            print(max_1)

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

const int MOD = 998244353;
int jc[500003] , inv[500003];

int poww(long long a , int b){
	int times = 1;
	while(b){
		if(b & 1) times = times * a % MOD;
		a = a * a % MOD; b >>= 1;
	}
	return times;
}

int binom(int a , int b){return a < b ? 0 : 1ll * jc[a] * inv[b] % MOD * inv[a - b] % MOD;}

int main(){
	long long N , A , B , K; cin >> N >> A >> B >> K;
	jc[0] = 1; for(int i = 1 ; i <= N ; ++i) jc[i] = 1ll * jc[i - 1] * i % MOD;
	inv[N] = poww(jc[N] , MOD - 2); for(int i = N - 1 ; ~i ; --i) inv[i] = inv[i + 1] * (i + 1ll) % MOD;
	int sum = 0;
	for(long long i = 0 ; i <= N && i * A <= K ; ++i){
		if((K - i * A) % B) continue;
		long long t = (K - i * A) / B;
		sum = (sum + 1ll * binom(N , i) * binom(N , t)) % MOD;
	}
	cout << sum; return 0;
}

Measured memory_bytes: 2560
import math
import sys
#####sorting a dictionary by the values#####
def dict_sort(ans):
    ans=sorted(ans.items(),reverse=True,key=lambda kv:(kv[1]))
#####Primes till Nth#####
def seive_primes(n):
    flag=[0]*(n+10)
    flag[1]=flag[0]=1
    i=2
    while i*i<=n+1:
        if flag[i]==0:
            j=i*i
            while j<=n+1:
                flag[j]=1
                j+=i
        i+=1
    return flag
##### naive method for testing prime or not#####
def is_prime(n):
    if n==1:
        return 0
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
#####greatest common divisor of two numbers#####
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
#####least common multiplyer of two numbers#####
def lcm(a,b):
    return (a*b)//gcd(a,b)
#####function that return all the letters#####
def alphbates():
    return "abcdefghijklmnopqrstuvwxyz"
#####taking an array/list as input#####
def inp():
    ls=list(map(int,input().split()))
    return ls
#####taking multiple inputs#####
def mult_inp():
    return map(int,input().split())
#####Main function starts from here#####
n,k=mult_inp()
ls=inp()
ls.sort()
print(sum(ls[:k]))

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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
 int a,b ,c;
 cin >> a >> b >> c;
 bool ans = false;
 if(a == b && a != c) ans = true;
 if(a == c && b != c) ans = true;
 if(c == b && a != c) ans = true;

 if(ans) cout <<"Yes" << endl;
 else cout << "No" << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

vector<int>A[100000];

int main()
{
	int a,b,N, M;
	int i,x;
	
	cin >> N >> M;

	for (i = 0; i < M; i++)
	{
		cin >> a>> b;
		A[a].push_back(b);
		A[b].push_back(a);
	}

	queue<int> que;
	vector<int>Lgth(N+1, -1);
	vector<int>Torch(N + 1);

	Lgth[1] = 0;
	que.push(1);
	while (que.empty()==0)
	{
		x = que.front();
		que.pop();
		

		for (int j : A[x])
		{
			if (Lgth[j] != -1) continue;
			Torch[j]=x;
			Lgth[j] = Lgth[x] + 1;
			que.push(j);
		}
	}
	cout << "Yes" << endl;
	for (i = 2; i <= N; i++)cout << Torch[i] << endl;
	return 0;
}


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

int main(){
  // 入力
  int N, l, r;
  cin >> N;
  
  int counter = 0;
  
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    counter += r - l + 1;
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 256
//2016/11/3
//stable sort


#include <stdio.h>
#include <string.h>
#include <ctype.h>

typedef struct{
				char suit;
				int  num;
}card;

int n;

void bubble_sort(card*, int);
void selection_sort(card*, int);


int main(void)
{
	int i;
	card c[36], bubble[36], selection[36];

	scanf("%d", &n);

	for(i = 0; i < n; i++)
	{
		scanf(" %c%d", &c[i].suit, &c[i].num);
	}

	for(i = 0; i < n; i++)
	{
		bubble[i] = c[i];
		selection[i] = c[i];

	}

	bubble_sort(bubble,n);

	for(i = 0; i < n; i++)
	{
		if (i == n-1)
		{
			printf("%c%d\n", bubble[i].suit, bubble[i].num);
		}else
		{
			printf("%c%d ", bubble[i].suit, bubble[i].num);
		}
	}

	printf("Stable\n");

	selection_sort(selection, n);

	for(i = 0; i < n; i++)
	{
		if (i == n-1)
		{
			printf("%c%d\n", selection[i].suit, selection[i].num);
		}else
		{
			printf("%c%d ", selection[i].suit, selection[i].num);
		}
	}

	for(i = 0; i < n; i++)
	{
		if (selection[i].suit != bubble[i].suit && selection[i].num == bubble[i].num)
		{
			printf("Not stable\n");
			return 0;
		}
	}

	printf("Stable\n");

	return 0;
}



void bubble_sort(card *a,int n)
{
	int i;
	int tempnum, flag = 1;
	char tempsuit;

	while(flag)
	{
		flag = 0;

		for(i = n-1; i > 0; i--)
		{
			if (a[i].num < a[i-1].num)
			{
				tempnum = a[i].num;
				tempsuit = a[i].suit;

				a[i].num = a[i-1].num;
				a[i].suit = a[i-1].suit;

				a[i-1].num = tempnum;
				a[i-1].suit = tempsuit;

				flag = 1;
			}
		}
	}
}


void selection_sort(card *a, int n)
{
	int i,j;
	int min, tempnum;
	char tempsuit;

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

		for(j = i; j < n; j++)
		{
			if (a[min].num > a[j].num)
			{
				min = j;
			}
		}

		if (i != min)
		{
			tempnum = a[i].num;
			tempsuit = a[i].suit;

			a[i].num = a[min].num;
			a[i].suit = a[min].suit;

			a[min].num = tempnum;
			a[min].suit = tempsuit;
		}

	}
}

Measured memory_bytes: 608