akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll get_bin_digit(ll n,ll x){
  return (n&((ll)1<<x))==0?0:1;
}

ll N;
v_ll A;
int main(){
  cin >> N;
  A.assign(N+10,0);
  for (ll i=1;i<=N;i++){
    cin >> A[i];
  }
  ll x=0;
  for (ll i=1;i<=N;i++){
    x=x^A[i];
  }
  ll key=1;
  for (ll d=59;d>=0;d--)
  {
    bool flg=false;
    if (get_bin_digit(x,d)==1){continue;}

    for (ll i=key;i<=N;i++)
    {

      if (get_bin_digit(A[i],d)==1){
        ll t=A[i];A[i]=A[key];A[key]=t;
        break;
      }
      if (i==N)flg=true;
    }
    if (flg) continue;
    for (ll i=1;i<=N;i++)
    {
      if (i==key)continue;
      if (get_bin_digit(A[i],d)==1){A[i]=A[i]^A[key];}
    }
    key++;
  }
  ll y=0;
  for (ll i=1;i<=N;i++){
    y=y^A[i];
  }
  ll ans=0;
  for (ll d=59;d>=0;d--)
  {
    if (get_bin_digit(x,d)==1) ans+=((ll)1<<d);
    else if (get_bin_digit(y,d)==1) ans+=((ll)1<<d)*2;

  }
  cout << ans << endl;
}




Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
  int n, i, ans=0, j;
  scanf("%d", &n);
  int a[n], x;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  x=a[0];
  for(j=1;j<n;j++){
    if(a[j]>=x){
      ans+=1;
      x=a[j];
    }else{}
  }
  printf("%d", ans+1);
  return 0;
}


Measured memory_bytes: 128
i=int(input())
n,m=map(int,input().split())
s=[]
if n%i==0:
  print('OK')
elif m%i==0:
  print('OK')
else:
  for j in range(n,m+1):
    if j%i==0:
      s.append(j)
  if len(s)>0:
    print('OK')
  else:
    print('NG')
        

  
    


Measured memory_bytes: 9184
#include <stdio.h>
#include <stdlib.h>
#define MAX_N 100
#define MAX_L 100

int N, L;
char S[MAX_N][MAX_L+1];

int compare(const void *a, const void *b){
    int i;
    char *c = (char*)a, *d = (char*)b;
    for (i=0; i<L; i++){
        if (c[i]<d[i]) return -1;
        if (c[i]>d[i]) return 1;
    }
    return -1;
}

int main(){
    int i;
    scanf("%d%d", &N, &L);
    for (i=0; i<N; i++)
        scanf("%s", S[i]);
    
    qsort(S, N, sizeof(char)*(MAX_L+1), compare);
    for (i=0; i<N; i++)
        printf("%s", S[i]);
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 252
#include<bits/stdc++.h>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
int main()
{
    ll a,b,c,d,i,j;
    char s[1000];
    in>>a>>b>>c;
    if(a%b==0)
    {
        out<<(a/b)*c<<nl;
    }
    else
    {
        out<<((a/b)+1)*c<<nl;
    }


}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main(){
  while(1){
    int N;
    cin >> N ;
    if(N==0){
      break;
    }
    int str[11][6]={0};
    for(int i=N-1;i>=0;i--){
      for(int j=0;j<5;j++){
        cin >> str[i][j];
      }
    }
    int score=0;
    for(int i=0;i<10;i++){
//    for(int q=0;q<N;q++){
//     for(int w=0;w<5;w++){
//       cout << str[q][w];
//     }
//     cout << endl;
//    }
//    cout << endl;
      for(int j=0;j<N;j++){
        int a=str[j][0];
        int ch=0;
        for(int k=0;k<=5;k++){
          if(a==str[j][k]&&a!=0){
            ch++;
          }else{
            if(ch>=3){
              for(int l=k-1;l>=k-ch;l--){
                score+=str[j][l];
                str[j][l]=0;
              }
              break;
            }else{
              a=str[j][k];
              ch=1;
            }
          }
        }
      }
      for(int j=0;j<N;j++){
        for(int k=0;k<N;k++){
          for(int l=0;l<5;l++){
            if(str[k][l]==0){
              str[k][l]=str[k+1][l];
              str[k+1][l]=0;
            }
          }
        }
      }
    }
//    for(int q=0;q<N;q++){
//     for(int w=0;w<5;w++){
//       cout << str[q][w];
//     }
//     cout << endl;
//    }
    cout << score << endl;
  }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int s,t,d,maki=(1<<n);
    int dis[n][n];
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++){
    		if(i==j)dis[i][j]=0;
    		else dis[i][j]=mod;
    	}
    }
    for(int i=0;i<m;i++){
    	cin>>s>>t>>d;
    	dis[s][t]=d;
    }
    int dp[maki][n];
    for(int i=0;i<maki;i++){
    	for(int j=0;j<n;j++){
    		dp[i][j]=mod;
    	}
    }
    dp[maki-1][0]=0;
    for(int bit=maki-2;bit>=0;bit--){
    	for(int i=0;i<n;i++){
    		for(int j=0;j<n;j++){
    			if(!((1<<j)&bit)){
    				dp[bit][i]=min(dp[bit][i],dp[bit|(1<<j)][j]+dis[i][j]);
    			}
    		}
    	}
    }
    if(dp[0][0]==mod)cout << -1<<endl;
    else cout << dp[0][0] <<endl;
    return 0;
}



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

vector<vector<int>> g;

void dfs(int cur, int par, vector<int>& d){
    for(int nex : g[cur]){
        if(nex == par) continue;
        d[nex] = d[cur] + 1;
        dfs(nex, cur, d);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    g.resize(n);

    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<long long> c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    vector<int> d1(n, 0);
    dfs(0, -1, d1);

    int node = 0;
    for(int i = 0; i < n; i++){
        if(d1[node] < d1[i]) node = i;
    }

    vector<int> d2(n, 0);
    dfs(node, -1, d2);

    int node2 = 0;
    for(int i = 0; i < n; i++){
        if(d2[node2] < d2[i]) node2 = i;
    }
    int max_val = d2[node2];

    vector<int> d3(n, 0);
    dfs(node2, -1, d3);

    vector<int> d(n), ord(n);
    for(int i = 0; i < n; i++){
        d[i] = min({d2[i], d3[i], max_val - d2[i], max_val - d3[i]});
        ord[i] = i;
    }
    sort(ord.begin(), ord.end(), [&](const int i1, const int i2){return d[i1] < d[i2];});

    vector<int> used(n, false);
    long long ans = 0;
    vector<int> memo(n, 0);
    for(int ii = 0; ii < n; ii++){
        int i = ord[ii];
        memo[i] = c[ii];
        for(int j : g[i]){
            if(used[j]) continue;
            ans += c[ii];
        }
        used[i] = true;
    }

    cout << ans << endl;
    for(int i = 0; i < n; i++){
        cout << memo[i] << " \n"[i+1 == n];
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



signed main() {
	ll a, b, sum;
	

	cin >> a >> b;
	sum = a;

	for (ll i = 1; ; i++) {
		if (sum%b == 0) {

			break;
		}
		sum += a;
	}

	cout << sum << endl;




	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long ans = 0;
        for(int i=1;i<=n;i++) {
            long s = n/i;
            ans+=(s+1)*i*s/2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35860
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <tuple>
#include <ctime>
#include <list>
#include <map>
#include <set>

#define REP(i,n) for(int i=0;i<(n);i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define SIZE(x) (int)(x).size()

#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

int main() {
    char t[] = "CODEFESTIVAL2016";
    char s[100];
    while (~scanf("%s", s)) {
        int ans = 0;
        REP(i, 16) if (s[i] != t[i]) {
            ++ans;
        }
        cout << ans <<endl;

    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp2[300000][60]={};
int main() {
	ll h;
	cin>>h;
	ll n=1;
	ll r=0;
	while(h>0){
		h/=2;
		r+=n;
		n*=2;
	}
	cout<<r;
	return 0;
}


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

int main(){
 std::string A,B;
 cin >> A >> B;
 int a = std::stoi(A);
 int b = std::stoi(B);
 if(a == 1 && b == 1){
   cout << "Draw" << endl;
   }else if(a == 1){
     cout << "Alice" << endl;
   }else if(b == 1){
     cout << "Bob" << endl;
   }else if(a == b){
     cout << "Draw" << endl;
   }else if(a > b){
     cout << "Alice" << endl;
   }else{
     cout << "Bob" << endl;
   }

 return 0;
}



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

constexpr char NL = '\n';
constexpr int MOD = 1e9 + 7;

struct safe_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void solve()
{
    int a, b, c; cin >> a >> b >> c;
    vector<int> v(11);
    ++v[a]; ++v[b]; ++v[c];
    cout << (v[5] == 2 && v[7] == 1 ? "YES" : "NO") << NL; 
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3608
function Main(input) {
  input = input.trim().split("\n").map(function(x) { return x.split(" ")});
  var N = parseInt(input[0][0], 10);
  var K = input[0][1];
  var K1, K2;
  if (K.length > 9){
    K1 = parseInt(K.substr(0, K.length - 9), 10);
    K2 = parseInt(K.substr(-9), 10);

  } else {
    K1 = 0
    K2 = parseInt(K, 10);
  }
  var vec_A = input[1].map(e => (parseInt(e, 10)));
  var mapRecord = Array.from({length: N}, () => 0);
  var tmpTown = 1;
  var loopStart, loopEnd ,loopStartTown, ans;
  for (var i = 0; i <= N; i++){
    mapRecord[tmpTown - 1] ++;
    if (mapRecord[tmpTown - 1] > 1){
      loopEnd = i;
      loopStartTown = tmpTown;
      break;
    }
    tmpTown = vec_A[tmpTown - 1];
  }
  tmpTown = 1;
  for (var i = 0; i <= N; i++){
    if (tmpTown === loopStartTown){
      loopStart = i;
      break;
    }
    tmpTown = vec_A[tmpTown - 1];
  }
  if (K2 > loopStart || K1 > 0){
    K2 = (K2 - loopStart) % (loopEnd - loopStart) + (K1 % (loopEnd - loopStart)) * (1e+9 % (loopEnd - loopStart));
	K2 %= (loopEnd - loopStart);
    tmpTown = loopStartTown;
  } else {
    tmpTown = 1;
  }
  for (var i = 0; i <= N; i++){
    if (i === K2){
      ans = tmpTown;
      break;
    }
    tmpTown = vec_A[tmpTown - 1];
  } 
  console.log(ans);
}   

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 44800
def main():
    H, W = map( int, input().split())
    if H == 1 or W == 1:
        print(1)
        return
    if H%2 == 0 or W%2 == 0:
        print(H*W//2)
    else:
        print(H*W//2+1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

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

    while (scanf("%d", &n), n != 0){
       for (i = n; 0 < i; i--){
           j = i;
           while (j % 5 == 0){
              j /= 5;
              count++;
           }
       }
       printf("%d\n", count);
       count = 0;
    }

    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define INF (1<<31)-1
void input(int&,int&,int&,vector<int>&);
int sumr(int,int,int);
int suml(int,int,int);
bool check(int,int,vector<int>);
int main(){
    int N,M,p;
    vector<int> line;
    input(N,M,p,line);
    int ans=INF;
    for(int i=0;i<M;++i){
        int a,b;
        a=line[i];
        b=line[(i+1)%M];
        if(check(i,p,line)){
            ans=min(ans,min(suml(p,b,N),sumr(p,a,N)));
        }else{
            a=sumr(p,a,N);
            b=suml(p,b,N);
            ans=min(ans,min(a*2+b,a+b*2));
        }
    }
    cout<<ans*100<<endl;
    return 0;
}

void input(int &N,int &M,int &p,vector<int> &line){
    cin>>N>>M>>p;
    for(int i=0;i<M;++i){
        int n;
        cin>>n;
        line.push_back(n);
    }
    sort(line.begin(),line.end());
}

bool check(int i,int p,vector<int> line){
    int a,b;
    a=line[i];
    b=line.size()==i+1?INF:line[i+1];
    if((a<p&&p<b)||(i+1==line.size()&&p<line[0])){
        return true;
    }else{
        return false;
    }
}

int suml(int from,int to,int N){
    if(to<from)return from-to;
    else return from+N-to;
}

int sumr(int from,int to,int N){
    if(to>from)return to-from;
    else return N-from+to;
}

Measured memory_bytes: 3204
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int T, P, R, tid, pid, t;
  string m;
  while (cin >> T >> P >> R, T) {
    vector< vector<int> > V(T, vector<int>(3, 0));
    vector< vector<int> > Problem(T, vector<int>(P, 0));
    for (int i = 0; i < T; ++i) V[i][2] = i+1;
    for (int i = 0; i < R; ++i) {
      cin >> tid >> pid >> t >> m;
      --tid;
      --pid;
      if (Problem[tid][pid] != 1) {
	if (m == "CORRECT") {
	  V[tid][1] += -Problem[tid][pid]*1200 + t;
	  Problem[tid][pid] = 1;
	  --V[tid][0];
	} else {
	  --Problem[tid][pid];
	}
      }
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < T; ++i) {
      cout << V[i][2] << " " << -V[i][0] << " " << V[i][1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <climits>
#include <utility>
#include <map>
#include <set>
#include <complex>
#include <numeric>

#include <time.h>
#include <float.h>

#define loop(i, start, end) for(i = (start); i <= (end); i++)
#define loopIterators(it, vec) for(it = (vec).begin(); it != (vec).end(); it++)
#define loopIteratorsRev(it, vec) for(it = (vec).rbegin(); it != (vec).rend(); it++)
#define loopRev(i, start, end) for(i = (start); i >= (end); i--)
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCases(t) cin >> t; while(t--)
#define PN(n) cout << (n)
#define PN1(n) cout << (n) << " "
#define PN2(a, b) cout << (a) << " " << (b) << " "
#define PNN1(n) cout << (n) << endl
#define PNN2(a, b) cout << (a) << " " << (b) << endl
#define PNN3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define PrintArray(ar, n) for(i = 0; i < n; i++) cout << ar[i] << " "; cout << endl
#define PrintObject(ar, it) loopIterators(it, ar) cout << *it << " "; cout << endl
#define PrintMap(map, it) loopIterators(it, map) PNN2(it->first, it->second)
#define sz(a) sizeof(a)
#define IN1(n) cin >> n
#define IN2(a, b) cin >> a >> b
#define IN3(a, b, c) cin >> a >> b >> c
#define ALL(s) s.begin(), s.end()
#define SWAP(a, b, c) c = a; a = b; b = c
#define STRSP(s) scanf("%[^\n]%*c", s)
#define ENTER PNN1("");
#define MOD7 1000000007
#define MOD9 10000009
#define MAX 1000000000
#define llPair std::pair<lli, lli>
#define iiPair std::pair<int, int>
#define ONLINE_JUDGE

typedef long long int lli;
typedef long int li;
typedef unsigned long long int ulli;
typedef long double ld;

using namespace std;

int main(void){
	FLASH

	#ifndef ONLINE_JUDGE
		freopen("input-stream.txt", "r", stdin);
		freopen("output-stream.txt", "w", stdout);
	#endif

	ld n;
	IN1(n);

	n /= 3.0;

	std::cout << std::setprecision(6) << std::fixed;
	PNN1(n * n * n);

	#ifndef ONLINE_JUDGE
		fclose(stdin);
		fclose(stdout);
	#endif

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    vector<ll> dp(n + 1, 0);
    rep(i, n) dp[i + 1] = (dp[i] + a[i]) % k;
    map<ll, vector<ll>> idx;
    rep(i, n) idx[dp[i + 1]].push_back(i + 1);
    ll ans = 0;
    rep(i, n) {
        ll cnt1 = sz(idx[dp[i]]) - (upper_bound(all(idx[dp[i]]), i) - idx[dp[i]].begin());
        ll cnt2 = sz(idx[dp[i]]) - (lower_bound(all(idx[dp[i]]), i + k) - idx[dp[i]].begin());
        ans += cnt1 - cnt2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 25216
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main() {
  string s1,s2;cin>>s1>>s2;
  int** dp=new int*[s2.length()+1];
  for(int i=0;i<=s2.length();i++){dp[i]=new int[s1.length()+1];memset(dp[i],0,(s1.length()+1)*sizeof(int));}
  for(int i=1;i<=s2.length();i++) {
  	for(int j=1;j<=s1.length();j++) {
      dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
      if(s2[i-1]==s1[j-1]) {
      	dp[i][j]=dp[i-1][j-1]+1;
      }
    }
  }
  string revOut="";
  int len=dp[s2.length()][s1.length()];
  int row=s2.length(),col=s1.length();
  while(row>0 && col>0) {
    if(dp[row][col]==dp[row-1][col]) {
      row--;
    } else if(dp[row][col]==dp[row][col-1]) {
      col--;
    } else if(dp[row][col]==dp[row-1][col-1]+1) {
      revOut+=s2[row-1];
      row--;col--;
      //len--;
    }
  }
  /*
  for(int i=1;i<=s2.length();i++) {
  	for(int j=1;j<=s1.length();j++) {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */
  for(int i=revOut.length()-1;i>=0;i--) {cout<<revOut[i];}cout<<endl;
  //cout<<dp[s2.length()][s1.length()]<<endl;
  return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <set>
#include <algorithm>
using namespace std;
int main(void){
    long long int n, k;
    cin >> n >> k;
    vector<long long int> h(n);
    for(long long int i=0; i<n; i++){
        cin >> h.at(i);
    }
    sort(h.begin(), h.end());
    long long int ans = 0;
    for(long long int i=0; i<n-k; i++){
        ans += h.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
N, P = map(int, input().split())

def primeCount(N):
    R = int(N**(0.5)) + 1  # 素数の範囲
    primes = {}  # 素数のリスト
    n = N
    for num in range(2, R):
        primes[num] = 0
        while n % num == 0:
            n //= num
            primes[num] += 1
    if n > 1 :
        primes[n] = 1
    return { key : val for key, val in primes.items() if val > 0}  # フィルターをかける

primeP = primeCount(P)
ans = 1
for p, cnt in primeP.items():
    ans *= max(1, p**(cnt // N))

print(ans)


Measured memory_bytes: 99040
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> l_l;
//typedef pair<int, int> i_i;
//map<int, int> m[512];
//struct edge{int to, cost;};
//vector<edge> G[MAX_V];
//typedef pair<int, int> P;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
/////////////////////////////////////////

int N, M, L, Q;
#define MAX_V 512
#define INF (1e9 + 1) // * 100000000LL)

int V;
ll d[MAX_V][MAX_V];

void warshal_floyd(void){
    for (int k = 0; k < V; k++)
        for (int i = 0; i < V; i++)
            for (int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    return;
}


int main() {
    cin >> N >> M >> L;
    V = N;
    vector<ll> A(M), B(M), C(M);
    
    rep(i, N)rep(j, N)d[i][j] = INF;
    
    rep(i, M){
        cin >> A[i] >> B[i] >> C[i];
        d[A[i] - 1][B[i] - 1] = C[i];
        d[B[i] - 1][A[i] - 1] = C[i];
    }
    
    cin >> Q;
    vector<int> S(Q), T(Q);
    for (int i = 0; i < Q; i++){
        cin >> S[i] >> T[i];
        S[i]--; T[i]--;
    }
    
    // �S�_�ԍŏ�����(Warshall-Floyd)
    warshal_floyd();
    
    rep(i, N)rep(j, N){
        if (d[i][j] <= L){
            d[i][j] = 1;
        } else {
            d[i][j] = INF;
        }
    }
    warshal_floyd();
    for (int i = 0; i < Q; i++){
        if (d[S[i]][T[i]] < INF){
            cout << d[S[i]][T[i]] - 1 << endl;
        } else {
            cout << - 1 << endl;
        }
    }
    return 0;
}


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

int main() {
  vector<vector<int>> C(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> C.at(i).at(j);
    }
  }
  
  vector<int> A(3), B(3);
  A.at(0) = 0;
  for (int i = 0; i < 3; i++) {
    B.at(i) = C.at(0).at(i);
  }
  A.at(1) = C.at(1).at(0) - B.at(0);
  A.at(2) = C.at(2).at(0) - B.at(0);
  
  string ans = "Yes";
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (C.at(i).at(j) != A.at(i) + B.at(j)) {
        ans = "No";
        break;
      }
    }
  }
  
  cout << ans << endl;
}




Measured memory_bytes: 256
from itertools import product
from bisect import bisect_left, bisect_right

n = int(input())
s = []
for i in range(3, 10):
    for v in product('753', repeat=i):
        if len(set(v)) >= 3:
            s.append(int(''.join(v)))

s.sort()

idx = bisect_right(s, n)
print(len(s[:idx]))

Measured memory_bytes: 45424
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
const int M=110;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,m,a[N],st[N],top=0;
int main() {
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        a[i]=gi();
        if(a[i]&1) st[++top]=i;
    }
    if(top>2) return puts("Impossible"),0;
    if(top) swap(a[1],a[st[1]]);
    if(top==2) swap(a[m],a[st[2]]);
    if(m==1) {
        if(a[1]==1) puts("1\n1\n1");
        else printf("%d\n2\n%d 1\n",a[1],a[1]-1);
        return 0;
    }
    for(int i=1;i<=m;i++) printf("%d ",a[i]);
    puts("");
    printf("%d\n",m-(a[1]==1));
    if(a[1]!=1) printf("%d ",a[1]-1);
    for(int i=2;i<m;i++) printf("%d ",a[i]);
    printf("%d\n",a[m]+1);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

const ll MOD=1'000'000'007;

ll mpow(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return x*mpow(x,n-1)%MOD;
    return mpow(x*x%MOD,n/2);
}

ll mfrac(ll n){
    if(n==0) return 1;
    else return n*mfrac(n-1)%MOD;
}

ll mperm(ll n,ll r){
    ll res=1;
    for(ll i=0;i<r;i++) res=res*(n-i)%MOD;
    return res%MOD;
}

ll mcomb(ll n,ll r){
    if(r>n-r) r=n-r;
    ll res=mperm(n,r);
    return res*mpow(mfrac(r),MOD-2)%MOD;
}

ll N,K;

int main(){
    cin>>N>>K;

    for(ll i=1;i<=K;i++){
        if(i>N-K+1){
            cout<<0<<endl;
            continue;
        }

        ll ans=mcomb(N-K+1,i)*mcomb(K-1,i-1)%MOD;

        //cout<<i<<':'<<ans<<' '<<mcomb(N-K+1,i)<<' '<<mcomb(K-1,i-1)<<endl;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char [] cs = s.toCharArray();
        int n = s.length();

        // Key insight: as long as #0's > 0 and #1's > 1, there will always be a 0 and 1 touching somewhere. Reason: any streak of say 0's must have in at least one of the ends a 1

        int numZeros = 0;
        int numOnes = 0;

        for (char c : cs) {
            if (c == '0') {
                numZeros++;
            } else {
                numOnes++;
            }
        }

        System.out.println(2 * Math.min(numZeros, numOnes));
    }
}

Measured memory_bytes: 28332
#include <bits/stdc++.h>
/* Karen {{{
  ___  ____
 |_  ||_  _|
   | |_/ /    ,--.   _ .--.  .---.  _ .--.
   |  __'.   `'_\ : [ `/'`\]/ /__\\[ `.-. |
  _| |  \ \_ // | |, | |    | \__., | | | |
 |____||____|\'-;__/[___]    '.__.'[___||__]
}}} */
/* cpp template {{{*/
using namespace std;

#define endl '\n'

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()

typedef double D;
typedef long long ll;
typedef long double lb;
typedef complex<D> P;
typedef vector<P> VP;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);}
inline int in() {int x; std::cin >> x; return x;}

template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  REP(i, v.size()) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << endl;
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
/* }}} */
/* 定数 {{{*/
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const D EPS  = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
/* }}} */

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

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);

  if (a[2] == a[1] + a[0]) cout << "Yes" << endl;
  else cout << "No" << endl;

}



Measured memory_bytes: 764
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [ss] <- getInts
  ; let (mm,s) = ss `divMod` 60
  ; let (h,m)  = mm `divMod` 60
  ; putStrLn (intercalate ":" (map show [h,m,s]))
  }

getInts :: IO [Int]
getInts = do
  { line <- getLine
  ;  let ints = map readInt (words line)
  ;  return ints
  }

getInts' :: IO [Int]
getInts' = do
  { line <- getLine
  ;  return (map readInt (words line))
  }

getInts'' :: IO [Int]
getInts'' =  map readInt . words <$> getLine


readInt :: String -> Int
readInt = read

Measured memory_bytes: 3532
#include<iostream>

using namespace std;

int N;
int A[3];

int main(){
	A[0] = 0;
	A[1] = 0;
	A[2] = 0;

	cin >> N;

	int a;
	for(int i = 0; i < N; i++){
		cin >> a;
		if(a % 4 == 0){
			A[0]++;
		}else if(a % 2 == 0){
			A[1]++;
		}else{
			A[2]++;
		}
	}

	if(A[1]){
	 if(A[2] <= A[0]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		if(A[2] <= A[0] + 1){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut n: isize = iterator.next().unwrap().parse().unwrap();

    if n == 0 {
        return "0".to_string();
    }

    let mut ans = String::new();
    while n != 0 {
        if (n % 2).abs() == 1 {
            ans = format!("{}{}", 1, ans);
            n -= 1;
        } else {
            ans = format!("{}{}", 0, ans);
        }
        n /= -2;
    }
    ans
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int32 n = s.size();
  int32 k;
  cin >> k;
  vector<vector<vector<int64>>> dp(n+1,vector<vector<int64>>(2,vector<int64>(k+1,0)));
  dp[0][0][0] = 1;
  REP(i,n){
    REP(j,k+1){
      if(s[i] == '0'){
        dp[i+1][0][j] += dp[i][0][j];
      }else{
        dp[i+1][1][j] += dp[i][0][j];
        if(j+1<=k){
          dp[i+1][0][j+1] += dp[i][0][j];
          dp[i+1][1][j+1] += dp[i][0][j] * (s[i] - '1');
        }        
      }
      dp[i+1][1][j] += dp[i][1][j];
      if(j+1<=k)
        dp[i+1][1][j+1] += dp[i][1][j] * 9;
    }
  }
  ANS(dp[n][0][k] + dp[n][1][k]);
  return 0;
}

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


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

bool solve() {
    int n;
    cin >> n;
    if (n == 0) return false;

    vector<pair<ll, ll>> xy(n + 1);
    REP(i, n) {
        cin >> xy[i].first >> xy[i].second;
    }
    xy[n] = xy[0];

    ll lx = INF, rx = -INF, dy = INF, uy = -INF;

    vector<pair<ll, ll>> rect(4);
    REP(i, 4) cin >> rect[i].first >> rect[i].second;

    REP(i, 4) {
        chmin(lx, rect[i].first);
        chmax(rx, rect[i].first);
        chmin(dy, rect[i].second);
        chmax(uy, rect[i].second);
    }


    ll ans = 0;

    REP(i, n) {
        ll sx, sy, tx, ty;
        tie(sx, sy) = xy[i];
        tie(tx, ty) = xy[i + 1];

        if (sx == tx) continue;

        ll cx = max(0ll, min(max(sx, tx), rx) - max(min(sx, tx), lx));
        ll cy = 0;
        if (sy >= dy) {
//            cy = max(sy - dy, 0ll);
            cy = min(uy, sy) - dy;
        }

        ll add = abs(tx - sx) * ty;
        add -= cx * cy;
        if (sx < tx) {
            add *= -1;
        }
        ans += add;
    }


    cout << ans << endl;

    return true;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    while (solve());


    return 0;
}



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

namespace ABC126A
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NK = CIN.IntArray();
            string S = CIN.String();

            for (int i = 0; i < NK[0]; i++)
            {
                if (i == NK[1]-1)
                {
                    Console.Write((char)(S[i] - ('A' - 'a')));
                    continue;
                }
                Console.Write(S[i]);
            }

            Console.WriteLine();
        }
    }

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

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

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

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

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

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

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    map<int, int> mp;
    int n;
    cin >> n;
    rep(i, n) {
        int t;
        cin >> t;
        mp[t]++;
    }
    ll ans = 0;
    for(auto m : mp) {
        if (m.first > m.second) {
            ans += m.second;
        }
        else if (m.first < m.second) {
            ans += m.second - m.first;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int z[1000]; 
int main()
{
	int n;
	cin>>n;
	int e[n+1],h[n+1];
	
	int cnt=0;
	int a,b,c;
	for(int i=1;i<=n;i++)
	{
		cin>>e[i]>>h[i];
		if(e[i]==h[i])
		{
			z[i]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(z[i]==1)
		{
			if(z[i+1] && z[i+2])
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			else
			{
				continue;
			}
		}
	}
	cout<<"No"<<endl;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<stack>
using namespace std;

int main(){
    stack<int> S;
    int a,b;
    string s;
    
    while(cin >> s){
        if(s[0]=='+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }else if(s[0]=='-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        }else if(s[0]=='*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }
    
    cout << S.top() << endl;
    
    return 0;
}

Measured memory_bytes: 3152
#include <cstdio>
#include <algorithm>
using namespace std;

int a[100005] = {0};
int main()
{	
	int n,max,r,t;
	
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&t);
		a[t]++;
		a[t + 1]++;
		a[t + 2]++;		
	}
	r = *max_element(a,a+100005);
	printf("%d\n",r);
	
	return 0;
}

Measured memory_bytes: 2024
#include <iostream>
#include <string>
#include <vector>


using namespace std;


int main() {
    // 入力
    int N;
    string S;
    cin >> N >> S;


    int count = 0;
    for (int i = 0; i < N; ++i) {
        string str = S.substr(i, 1);
        if (str == "R") {
            count ++;
        };
    }

    if (count > (N / 2)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    };
}



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

using namespace std;
//131073
typedef pair<int, int> pii;
typedef long long ll;
multiset<int>s;
multiset<int>::iterator it;

const int maxn = 1234;
struct pp{
    ll a, b, c;
}p[maxn], q[maxn];

bool cmp(const pp& x, const pp& y){
    return x.a + x.b + x.c > y.a + y.b + y.c;
}
int main(){
    ios_base::sync_with_stdio(0);
//    freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    ll x, y, z;
    for (int i = 0; i < n; ++i) {
        cin >> x>>y>>z;
        p[i].a = x;
        p[i].b = y;
        p[i].c = z;
    }
    ll res = 0;
    for (int k = 0; k < 8; ++k) {
        int t1 = (k & 1) ? 1 : -1;
        int t2 = (k & 2) ? 1 : -1;
        int t3 = (k & 4) ? 1 : -1;
        for (int i = 0; i < n; ++i) {
            q[i].a = p[i].a * t1;
            q[i].b = p[i].b * t2;
            q[i].c = p[i].c * t3;
        }
        sort(q, q+n, cmp);
        ll ans = 0;
        for (int j = 0; j < m; ++j) {
            ans += q[j].a + q[j].b + q[j].c;
        }
        res = max(res, abs(ans));
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int a, b, c;
    cin >> a >> b >> c;
    int maxt = max(max(a, b), c);
    int mint = min(min(a, b), c);
    cout << maxt - mint << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int K;
    string S;
    while (cin >> K >> S) {
        if (S.size() <= K) cout << S << endl;
        else cout << S.substr(0, K) + "..." << endl;
    }
}

















Measured memory_bytes: 3632
def main(m, a, b):
    ans = [0,0,0]
    for x in p:
        for y in p:
            if x * y > m:
                break
            if 1 >= x / y >= a / b and x * y > ans[0]:
                ans = [x * y, x, y]
    print(ans[1], ans[2])

def primes(n):
    """ 
    Input n>=6, Returns a list of primes, 2 <= p < n 
    6以上の数であれば p (素数) <= n のlistを返す 
    :param int n:
    :rytpe list:
    """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

if __name__ == "__main__":
    p = primes(10000)
    while 1:
        m, a, b = map(int, input().split())
        if m == a == b == 0:
            break
        else:
            main(m,a,b)


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

using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  int a[n], b[n], c[m], d[m];
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }

  for(int i = 0; i < n; i++) {
    int mn = INT_MAX;
    int near;
    for(int j = 0; j < m; j++) {
      int dx = a[i] - c[j];
      int dy = b[i] - d[j];
      if(dx < 0) {
	dx *= -1;
      }
      if(dy < 0) {
	dy *= -1;
      }
      if(dx + dy < mn) {
	mn = dx + dy;
	near = j;
      }
    }
    cout << near + 1 << endl;
  }
}

Measured memory_bytes: 256
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = ii2nn(N)
    Ai = [(i, a) for i, a in enumerate(A)]
    Ai.sort(key=lambda v: v[1])
    i1 = Ai[-1][0]
    M = max(A)
    M2 = Ai[-2][1]
    for i, a in enumerate(A):
        if i == i1:
            print(M2)
        else:
            print(M)

main()


Measured memory_bytes: 81712
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;

void solve() {
	cin >> N;
	int res = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		if(a != i + 1) res++;
	}
	if(res <= 2) cout << "YES\n";
	else cout << "NO\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 512