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

int Q;

int max_kakezan(int n){
    int dec = 1;
    int front,back;
    int max = -1000;
    while(n/dec != 0) {
        front = n/dec;
        back = n%dec;
        if (max < front * back){
            max = front * back;
        }
        dec *= 10;
    }
    return max;
}

int  how_many_kakezan(int n){
    int times = 0;
    while (n/10 != 0) {    //もしnが1桁ならば、終了,それ以外は続行
        n = max_kakezan(n);
        times++;
    }
    return times;
}

int main(){
    cin >> Q;
    for (int q = 0; q < Q; q++){
        int n;
        cin >> n;
        cout << how_many_kakezan(n) << endl;
    }
}



Measured memory_bytes: 3108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e6+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
char s[maxn];
int f[maxn][2],ans;

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    scanf("%s",s+1);
    int n=strlen(s+1);
    _rep(i,1,n)
        s[i]-='0';
    memset(f,0x3f,sizeof(f));
    f[0][0]=0,f[0][1]=1;
    _rep(i,1,n+1)
    {
        f[i][0]=min(f[i-1][0]+s[i],f[i-1][1]+10-s[i]);
        f[i][1]=min(f[i-1][0]+s[i]+1,f[i-1][1]+9-s[i]);
    }
    cout<<f[n+1][0]<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int a,b;
    char op;
    cin >> a >> op >>b;
    while(op!='?'){
        int c;
        if(op=='+')c=a+b;
        if(op=='-')c=a-b;
        if(op=='*')c=a*b;
        if(op=='/')c=a/b;
        cout << c << endl;
        cin >> a >> op >> b;
    }
    return 0;
}


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String string[] = {"Yes", "No"};
		int ans = 1;
		while(n > 0){
			int tmp = n / 10;
			int digitnum = n - tmp * 10;
			if(digitnum == 7)ans = 0;
			n /= 10;
		}
		sc.close();
		System.out.println(string[ans]);
	}
}


Measured memory_bytes: 35860
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const int MAX= 1e6+100;


int main(){
	fastio;
	ll tc,n,m,a,b,c,d;
	cin>>n;
	string ss;
	set<string> s;
	f(i,0,n) cin>>ss, s.insert(ss);
	cout<<s.size()<<endl;
	
	return 0;
}

Measured memory_bytes: 19196
#include <iostream>
#include <cmath>
#include <cctype>
#include<cstdio>
//#include <string>
using namespace std;
int main(){
   
    
    int alpha[26];
    for(int i=0;i<26;i++){
        alpha[i]=0;
    }
    char c;
    while(cin>>c){
        if(isalpha(c)){
            
            if(isupper(c)){
            alpha[c-'A']++;
            }else alpha[c-'a']++;
            
        }
    }
    
    for(int i=0;i<26;i++){
        
        cout<<char('a'+i)<<" : "<<alpha[i]<<endl;
    }
    
    
    
    
    return 0;
}



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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int x;
    cin >> x;
    cout << (x < 1200 ? "ABC" : "ARC") << endl;
}


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

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

using namespace std;




void one_case() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    --k;
    vector<int> p(n);
    for (auto& el : p) {
        cin >> el;
        --el;
    }
    auto cur = p[0];
    int slow = p[cur];
    int fast = p[slow];
    while (slow != fast) {
        slow = p[slow];
        fast = p[p[fast]];
    }
    int pd = 0;
    while (cur != slow) {
        ++pd;
        cur = p[cur];
        slow = p[slow];
    }
    int cycle = 1;
    while (p[slow] != cur) {
        ++cycle;
        slow = p[slow];
    }

    int res = 0;
    if (pd >= k) {
        cur = p[0];
        while (k--) {
            cur = p[cur];
        }
        res = cur;
    } else {
        k -= pd;
        k = k % cycle;
        while (k--) {
            cur = p[cur];
        }
        res = cur;
    }





    cout << res + 1 << "\n";

}



int main() {
//    std::ios::sync_with_stdio(false);
//    std::cin.tie(nullptr);

    int t = 1;
//    cin >> t;
    while (t--) {
        one_case();
    }

    return 0;
}


Measured memory_bytes: 4052
e = [0, 0] + [1] * 55555
for i in range(2, int(55555 ** 0.5) + 1):
    if e[i] == 1:
        for j in range(i * i, 55555 // i, i): e[j] = 0
p = []
for i in range(55555):
    if e[i] == 1: p.append(i)

n = int(input())
ans = []
for x in p:
    if x % 5 == 1: ans.append(x)
    if (len(ans) == n): break
print(' '.join(str(x) for x in ans))


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

const int MAX_H = 1000;
int H, W;
string A[MAX_H];

bool check(pii p) {
    int i = p.first, j = p.second;
    if (i < 0 || j < 0 || i >= H || j >= W)return false;
    if (A[i][j] == '#')return false;
    A[i][j] = '#';
    return true;
}

signed main() {
    cin >> H >> W;
    rep(i, H) {
        cin >> A[i];
    }
    int bc = 0;
    vector<pii> X, Y;
    rep(i, H) {
        rep(j, W) {
            if (A[i][j] == '#') {
                bc++;
                X.push_back(pii(i - 1, j));
                X.push_back(pii(i + 1, j));
                X.push_back(pii(i, j - 1));
                X.push_back(pii(i, j + 1));
            }
        }
    }
    int ans = 0;
    while (bc < H * W) {
        for (pii p:X) {
            if (check(p)) {
                bc++;
                int i = p.first, j = p.second;
                Y.push_back(pii(i - 1, j));
                Y.push_back(pii(i + 1, j));
                Y.push_back(pii(i, j - 1));
                Y.push_back(pii(i, j + 1));
            }
        }
        swap(X, Y);
        Y.clear();
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 90076
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.time.chrono.MinguoChronology;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException { 
      int i = 0;
      while (true) {
        int x = in.nextInt();
        if (x == 0) {
          break;
        }
        out.println("Case "+(++i)+": "+x);
      }
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

Measured memory_bytes: 30156
#include<iostream>
#include<vector>

using namespace std;

int main(void){

    int n, m, c, count = 0, sum = 0;

    cin >> n >> m >> c;

    vector<int> b(m), a(m);

    for(int i = 0;i < m;i++){
        cin >> b[i];
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            cin >> a[j];
        }

        for(int j = 0;j < m;j++){
            sum += a[j] * b[j];
        }
        sum += c;

        if(sum > 0) count++;
        sum = 0;
    }

    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
n = int(input())
ta = list(map(int, input().split()))
t = ta[0]
a = ta[1]
h = list(map(int, input().split()))
mind = 10**6
ans = 0
for i in range(n):
    d = t - h[i] * 0.006
    if abs(d - a) < mind:
        mind = abs(d - a)
        ans = i + 1
print(ans)

Measured memory_bytes: 3064
N, K = map(int,input().split())

ans = 0

if N >= K:
    ans += (N - K + 1) / N
    L = K-1
    #print(N-K+1)
else:
    L = N
#print(ans)

rate = 0
for i in range(1,L+1,1):
    #print(i)
    score = i
    c = 0
    
    while score < K:
        score = score * 2
        c += 1
    r = 2** c
    #print(c)
    rate += 1/r
    
    #print(ans)
ans += (1/N) * rate

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(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);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

//next_permutation
void nexp(ll*a,int cnt){
	int l=cnt-1,r=cnt-1;
	ll t;
	while(--l>=0&&a[l]>a[l+1]);
	if(l>=0){
		while(a[l]>a[r])r--;
		t=a[l];a[l]=a[r];a[r]=t;
	}
	for(l++,r=cnt-1;l<r;l++,r--)t=a[l],a[l]=a[r],a[r]=t;
}

ll a[100]={0,1,2,3,4,5,6,7};
double x[10],y[10];

int main(){
	int n;
	scanf("%d",&n);
	int cnt=1;
	rep(i,0,n)cnt*=i+1;
	
	rep(i,0,n)scanf("%lf%lf",x+i,y+i);
	
	double ans=0;
	rep(_,0,cnt){
		rep(i,0,n-1)ans+=hypot(x[a[i]]-x[a[i+1]],y[a[i]]-y[a[i+1]]);
		nexp(a,n);
	}
	
	printf("%.9f",ans/cnt);
}

Measured memory_bytes: 128
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T, class S> inline T pow_L(T a, S b){
  T res = 1;
  res = 1;
  for(;;){
    if(b&1){
      res *= a;
    }
    b >>= 1;
    if(b==0){
      break;
    }
    a *= a;
  }
  return res;
}
inline double pow_L(double a, double b){
  return pow(a,b);
}
int main(){
  long long X;
  long long A;
  long long B;
  long long v;
  rd(X);
  for(A=0;;A++){
    for(B=A-1;;B--){
      v =(pow_L(A,5))-(pow_L(B,5));
      if(v==X){
        wt_L(A);
        wt_L(' ');
        wt_L(B);
        wt_L('\n');
        return 0;
      }
      if(v > X){
        break;
      }
    }
  }
  return 0;
}
// cLay varsion 20200419-1

// --- original code ---
// {
//   ll X, A, B, v;
//   rd(X);
//   for(A=0;;A++){
//     for(B=A-1;;B--){
//       v = A**5 - B**5;
//       if(v==X) wt(A, B), return 0;
//       if(v > X) break;
//     }
//   }
// }


Measured memory_bytes: 3600
while 1:
	N, T, L, B = map(int,raw_input().split(" "))
	if N == T == L == B == 0: break
	dp = [[0 for _ in range(N+1)] for _ in range(T+1)]
	Lose = set([int(raw_input()) for _ in range(L)])
	Back = set([int(raw_input()) for _ in range(B)])
	dp[0][0] = 1
	for i in range(T):
		for j in range(N):
			rank = i-1 if j in Lose else i
			for d in range(1,7):
				next = j + d
				if next > N :
					next = N - (next - N)
				if next in Back:
					dp[i+1][0] += dp[rank][j] / 6.
				else :
					dp[i+1][next] += dp[rank][j] / 6.
	
	print "%6f" % sum([dp[i][N] for i in range(1,T+1)])

Measured memory_bytes: 4508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,c;
	cin>>n>>c;
	vector<tuple<int,int,int>>times;
	for(int i=0;i<n;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		times.push_back({a,b,c});
	}
	sort(times.begin(),times.end());

	vector<tuple<int,int,int>>recorders;
	recorders.push_back(times[0]);
	get<0>(recorders[0])-=0.5;
	for(int i=1;i<n;i++)
	{
		bool flag=false;
		for(int j=0;j<recorders.size();j++)
		{
			
			if(get<2>(recorders[j])==get<2>(times[i])){
				get<1>(recorders[j])=get<1>(times[i]);
				flag=true;
				break;
			}
			else if(get<0>(times[i])>=0.5+get<1>(recorders[j])){
				get<1>(recorders[j])=get<1>(times[i]);
				get<2>(recorders[j])=get<2>(times[i]);
				flag=true;
				break;
			}
		}
		if(flag==false)
			recorders.push_back({get<0>(times[i])-0.5,get<1>(times[i]),get<2>(times[i])});

	}
	cout<<recorders.size()<<"\n";
//	for(int i=0;i<times.size();i++)
//		cout<<get<0>(times[i])<<" "<<get<1>(times[i])<<" "<<get<2>(times[i])<<"\n";
}

Measured memory_bytes: 4964
import java.util.*;

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

    int n = sc.nextInt();
    int[] a = new int[n];
    int[] ans = new int[n];

    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    for(int i = 0; i < n; i++){
      ans[a[i] - 1] = i + 1;
    }

    for(int i = 0; i < n; i++){
      System.out.print(ans[i] + " ");
    }
  }
}


Measured memory_bytes: 64984
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

bool power_of_two(int n){
    return ((n&(n-1))==0);

}

void solve(){

    int r,c, ans = 0;
    cin >> r >> c;
    int m;
    cin >> m;
    
    vector<int> adj[r+1];
    vector<int> row(r+1,0);
    vector<int> col(c+1,0);
    
    for(int i = 0; i<m;i++){
        int x, y;
        cin >> x >> y;
        adj[x].pb(y);
        row[x]++;
        col[y]++;
    }
    
    set<pii> col_cnt;
    
    for(int j = 1; j<=c; j++){
        col_cnt.insert({col[j], j});
    }
    
    for(int i = 1;i<=r;i++){
        
        for(auto j:adj[i]){
            if(col_cnt.find({col[j], j})!=col_cnt.end())
                col_cnt.erase(col_cnt.find({col[j], j}));
                
            col[j]--;
            col_cnt.insert({col[j],j});
        }
        
        auto it = col_cnt.end();
        if(it!=col_cnt.begin())
            it--;
            
        ans = max(ans, row[i]+(*it).ff);
        
        for(auto j:adj[i]){
            col_cnt.erase(col_cnt.find({col[j], j}));
            col[j]++;
            col_cnt.insert({col[j],j});
        }
    }
    cout << ans << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
   // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 
    

Measured memory_bytes: 43028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,arr[200005],has,f[200005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	sort(arr+1,arr+n+1,greater<int>());
	f[0]=1,f[1]=1;
	for(int i=2;i<=n;i++) f[i]=2;
	int p=2,now=1;
	while(p<=n)
	{
		if(f[now]==0) now++;
		has+=arr[now];
		f[now]--;
		p++;
	}
	cout<<has<<endl;
}

Measured memory_bytes: 6700
import java.lang.Math;
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	double r,s,shu;
	Scanner scan=new Scanner(System.in);
	r=scan.nextDouble();
	s=r*r*Math.PI;
	shu=2*r*Math.PI;
	System.out.printf("%f %f\n",s,shu);
    }
}

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

const int MAXN = 3e6 + 5;
const int MOD = 998244353;

int N, M;
int fact[MAXN], inv[MAXN];

void load() {
	scanf("%d%d", &N, &M);
}

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)
		return x - MOD;
	if (x < 0)
		return x + MOD;
	return x;
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

int pot(int x, int y) {
	int res = 1;
	for (; y; y /= 2) {
		if (y % 2)
			res = mul(res, x);
		x = mul(x, x);
	}
	return res;
}

int choose(int n, int k) {
	if (k < 0 || n < k)
		return 0;
	return mul(fact[n], mul(inv[k], inv[n - k]));
}

int stars_bars(int sum, int n) {
	return choose(sum + n - 1, n - 1);
}

int calc_odd(int k) {
	if ((k + M) % 2)
		return 0;
	return mul(choose(N, k), stars_bars((3 * M - k) / 2, N));
}

int solve() {
	fact[0] = inv[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fact[i] = mul(fact[i - 1], i);
		inv[i] = pot(fact[i], MOD - 2);
	}
	
	int sol = 0;
	for (int i = 0; i <= M && i <= N; i++)
		sol = add(sol, calc_odd(i));
	
	for (int i = 2 * M + 1; i <= 3 * M; i++)
		sol = add(sol, -mul(N, stars_bars(3 * M - i, N - 1)));
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  
  REP(i, w + 2)
    cout << "#";
  cout << endl;
  
  REP(i, h) {
    cout << "#";
    REP(j, w) {
      char c;
      cin >> c;
      cout << c;
    }
    cout << "#" << endl;
  }
  
  REP(i, w + 2)
    cout << "#";
  cout << endl;
  
  return 0;
}

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

int main() {
  int n, d, x, a;
  cin >> n >> d >> x;
  for(int i = 0; i < n; i++) {
    cin >> a;
    x += (d - 1) / a + 1;
  }
  cout << x << endl;
}

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

int main() {
    int m1,d1, m2,d2; 
    cin>>m1>>d1>>m2>>d2;
    if(m1 != m2) cout<<'1'<<"\n";
    else cout<<'0'<<"\n";
}

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

using namespace std;

int main(){
	int h,w;
	while(cin>>h>>w){
		if(h!=0 || w!=0){
			for(int i=1;i<=h;i++){
				if(i % 2 == 0){
					cout<<'.';
						for(int j=2; j<= w; j++){
							if(j % 2==0){
								cout<<'#';
							}
							else{
							cout<<'.';
							}
						}
					}
				else{
					cout<<'#';
				for(int j=2; j<= w; j++){
					if(j % 2==0){
						cout<<'.';
					}
					else{
						cout<<'#';
					}
				}
				}
				cout<<endl;
			}
		cout<<endl;
		}
		else{
			break;
		}
	}
}


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

int main() {
  char C;
  cin >> C;
  
  if (C == 'a' || C == 'e' || C == 'i' || C == 'o' || C == 'u'){
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
  
      
      
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long long N,K;
  cin>>N>>K;
  long long asum=0;
  long long bsum=0;
  long long csum=0;
  for (long long j=K;j<=N+1; j++){csum+=(j*(N-j+1)+1);
  }
  cout<<csum%1000000007<<endl;
}

Measured memory_bytes: 3624
using System;

public class Test
{
	public static void Main()
	{
		string[] str = Console.ReadLine().Split(' ');
		long a = long.Parse(str[0]);
		long b = long.Parse(str[1]);
		long n = long.Parse(str[2]);
		long ans = b/n - a/n;
		if(a%n==0) ans++;
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
int main() {
	ll n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	printf("%lld\n", n / (a + b) * a + min(n % (a + b), a));
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	cout << ((a1 + a2 + a3 >= 22) ? "bust" : "win") << endl;
	return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
X = 0
Y = 0
T = 0
flag = True
for i in range(N):
    t,x,y = [int(i) for i in input().split()]
    dt = t-T
    dx = abs(x-X)
    dy = abs(y-Y)
    if dx + dy <= dt and (dt - dx - dy) % 2 == 0:
        flag = True
    else:
        flag = False

    if flag == False:
        break

if flag == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#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;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#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));
//priority_queue<int,vector<int>, greater<int> > q2;

struct edge {
	int to, cost;
};
vector<vector<edge> >G;
VI dist;

void dfs1(int now, int par) {
	for (edge& e : G[now]) {
		if (e.to == par)continue;
		dfs1(e.to, now);
		dist[now] = max(dist[now], dist[e.to] + e.cost);
	}
}

int dfs2(int now, int dpar, int par) {
	vector<pii> dchi;
	dchi.emplace_back(pii(0, -1));

	for (edge &e : G[now]) {
		if (e.to == par)dchi.emplace_back(pii(dpar + e.cost, e.to));
		else dchi.emplace_back(pii(e.cost + dist[e.to], e.to));
	}
	rSORT(dchi);
	int ret = dchi[0].first + dchi[1].first;

	for (edge &e : G[now]) {
		if (e.to == par)continue;
		ret = max(ret, dfs2(e.to, dchi[dchi[0].second == e.to].first, now));
	}


	return ret;
}


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


	int N; cin >> N;
	G.resize(N);
	dist.resize(N);
	REP(i, N - 1) {
		int a, b, c; cin >> a >> b >> c;
		G[b].push_back((edge{ a,c }));
		G[a].push_back((edge{ b,c }));
	}

	dfs1(0, -1);
	
	cout << dfs2(0, 0, -1) << endl;

	return 0;
}




Measured memory_bytes: 32500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
	class Program
	{
		static void Main(string[] args)
		{
			int x = int.Parse(Console.ReadLine());

			if (x == 3 || x == 5 || x == 7)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
n = int(input())
p = [int(input()) for i in range(n)]
x,r,num,ans = [0 for i in range(n)],0,1,0
for i in range(n): x[p[i]-1] = i
while r!=n-1:
	r += 1
	if x[r-1]<x[r]: num = num+1
	else: ans,num = max(ans,num),1
ans = max(ans,num)
print(n-ans)

Measured memory_bytes: 18888
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		for(int i=1; i<=k; i++) {
			if(i%2==1) {
				if(a%2==1) {
					a=a-1;
					a=a/2;
					b=b+a;
				}else {
					b=b+(a/2);
					a=a/2;
				}
			}else {
				if(b%2==1) {
					b=b-1;
					b=b/2;
					a=b+a;
				}else {
					a=a+(b/2);
					b=b/2;
				}
			}
		}
		System.out.println(a+ " "+b );
	}
}

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

using namespace std;

typedef long long ll;

struct Node {
    int at;
    ll cost; 
    int prev;
    Node(int at, ll cost, int prev) : at(at), cost(cost), prev(prev) {}
    bool operator>(const Node &s) const {
        if (cost != s.cost) return cost > s.cost;
        if (prev != s.prev) return prev > s.prev; //最短経路を辞書順最小にする(省略可)
        return at > s.at;
    }
};

struct Edge {
  int to;
  ll cost;  
  Edge(int to, ll cost) : to(to), cost(cost) {}  
};

typedef vector<vector<Edge> > AdjList; //隣接リスト

const ll INF = 1000000000000000000LL;
const int NONE = -1;

AdjList graph;
vector<ll> minc; //最短経路のコスト
vector<int> Prev; //最短経路をたどる際の前の頂点

//trueなら負の閉路を検出
bool bellman_ford(int n, int s) { //nは頂点数、sは始点
    minc = vector<ll>(n, INF);
    Prev = vector<int>(n, NONE);
    minc[s] = 0; //始点までの距離は0
    for (int i = 1; i < n; i++) {
        for (int from = 0; from < n; from++) {
            for (int j = 0; j < (int)graph[from].size(); j++) {
            	Edge e = graph[from][j];
                if (minc[from] != INF && minc[e.to] > minc[from] + e.cost) {
                    minc[e.to] = minc[from] + e.cost;
                    Prev[e.to] = from;
                }
            }
        }
    }
    
    //負の閉路を検出
    for (int from = 0; from < n; from++) {
        for (int j = 0; j < (int)graph[from].size(); j++) {
        	Edge e = graph[from][j];
            if (minc[from] != INF && minc[e.to] > minc[from] + e.cost) {
            	minc[e.to] = minc[from] + e.cost;
                if (e.to == n - 1) return true;
            }
        }
    }
    return false;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	graph.resize(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--;
		b--;
		graph[a].emplace_back(b, -c);
	}

	if (bellman_ford(n, 0)) {
		cout << "inf" << endl;
	} else {
		cout << -minc[n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)

Measured memory_bytes: 9112
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i, n)
	{
		cin >> p[i];
	}
	int num = 0;
	rep(i, n)
	{
		if (p[i] != i + 1)
		{
			num++;
		}
	}
	if (num == 0 || num == 2)
		cout << "YES" << endl;
	else
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
k = int(input())
c = 0
d = 0
a = []
s += "A"
for i in range(len(s)-1):
    if (s[i] == s[i+1]):
        c += 1
    else:
        a.append(c+1)
        d += 1
        c = 0
c = 0
if s[0] != s[len(s)-2]:
    for i in range(d):
        c += int(a[i]/2)
    print(int(c*k))
elif d == 1:
    print(int(a[0]*k/2))
else:
    for i in range(1,d-1):
        c += int(a[i]/2)
    c=c*k
    c += (k-1)*int((a[0]+a[d-1])/2) + int(a[0]/2) + int(a[d-1]/2)
    print(int(c))


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

int bitcount(int bits) {
  int ret = 0;
  while (bits > 0) {
    if (bits & 1) ret++;
    bits = bits >> 1;
  }
  return ret;
}

signed main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  int ans = 0;
  if (K == 1) {
    rep(i, S.length()) {
      if (i == 0) continue;
      if (S[i] == S[i - 1]) {
        S[i] = 1;
        ans += 1;
      }
    }
  } else {
    string S2 = S + S;
    string S3 = S + S + S;
    int buf2 = 0;
    int buf3 = 0;
    rep(i, S2.length()) {
      if (i == 0) continue;
      if (S2[i] == S2[i - 1]) {
        S2[i] = 1;
        buf2 += 1;
      }
    }
    rep(i, S3.length()) {
      if (i == 0) continue;
      if (S3[i] == S3[i - 1]) {
        S3[i] = 1;
        buf3 += 1;
      }
    }
    ans = buf2 + (buf3 - buf2) * (K - 2);
  }
  if (S.length() == 1) ans = K / 2;
  int same = 0;
  rep(i, S.length() - 1) {
        if (S[i] != S[i + 1]) same = 1;
  }
  if (same == 0) ans = S.length() * K / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
/******************************************************************************

                         بسم الله الرحمن الرحيم
                     Author: Mst: Mhamuda Khatun
                               RUCSE27

*******************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007
#define MAX 1000000000000
#define N 305

int main()
{
    fastio;
    string s;
    cin>>s;

    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes";
    else
        cout<<"No";

    cout<<"\n";
    return 0;   //:D
}




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

int main()
{
    string S;
    cin >> S;

    int m = S.size() / 2;
    int s = m;
    int e = m;
    int res = 0;

    while (true)
    {
        if (m == 0 || (s <= 0 && e >= S.size() - 1))
            break;

        if (s > 0)
        {
            if (S.at(s) != S.at(s - 1))
            {
                S.erase(s - 1, 2);
                res += 2;
                m = S.size() / 2;
                s = m;
                e = m;
                continue;
            }
        }
        if (e < S.size() - 1)
        {
            if (S.at(e) != S.at(e + 1))
            {
                S.erase(e, 2);
                res += 2;
                m = S.size() / 2;
                s = m;
                e = m;
                continue;
            }
        }
        s--;
        e++;
    }
    cout << res << endl;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
cnt = [0]*((10**5)+2) #-1 ~ 10**5+1

for ai in a:
    cnt[ai + 1] += 1
    cnt[ai-1 + 1] += 1
    cnt[ai+1 + 1] += 1

print(max(cnt))

Measured memory_bytes: 13964
import java.util.*;

import static java.lang.System.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long[] fac = null;
    static long[] finv = null;
    static long[] inv = null;
    static final long prime = 998244353;

    public static void main(String[] args) {
        int N = ni();
        long A = nl();
        long B = nl();
        long K = nl();


        prepareCombinationMod(N + 1, N + 1, prime);

        int aNum = 0;
        int bNum;
        long comb = 0;
        while (aNum <= N) {
            long tmpK = K - aNum * A;
            if (tmpK % B == 0 && tmpK / B <= N) {
                bNum = (int) (tmpK / B);
                comb += combinationMod(N, aNum, prime) * combinationMod(N, bNum, prime);
                comb %= prime;
            }
            aNum++;
        }

        out.println(comb);
    }

    public static void prepareCombinationMod(int n, int k, long prime) {
        // 事前計算
        fac = new long[n + 1];
        finv = new long[n + 1];
        inv = new long[n + 1];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            fac[i] = fac[i - 1] * i % prime;
            inv[i] = prime - inv[(int) (prime % Long.valueOf(i))] * (prime / i) % prime;
            finv[i] = finv[i - 1] * inv[i] % prime;
        }
    }

    public static long combinationMod(int n, int k, long prime) {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;

        return fac[n] * (finv[k] * finv[n - k] % prime) % prime;
    }

    static int ni() {
        return sc.nextInt();
    }

    static long nl() {
        return sc.nextLong();
    }

    static String ns() {
        return sc.next();
    }

    static int[] niarr(int N) {
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        return a;
    }

    static long[] nlarr(int N) {
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }
        return a;
    }
}

Measured memory_bytes: 31700
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define INF 0x3f3f3f3f 
#define MEM(x,y) memset(x,y,sizeof(x))
#define int long long
#define rep(i , a , b) for(int i = a ; i <= b ; i ++)
#define P pair<int,int>
#define  sc(a) scanf("%lld",&a)
#define pf(a) printf("%lld ",a)
using namespace std;
string q;
int d[2005][2005];
int ans[2005];
signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	rep(i, 1, a)
		rep(j, 1, a)
		d[i][j] = d[j][i] = abs(i - j);
	rep(i, 1, a)
	{
		rep(j, 1, a)
		{
			d[i][j] = min(d[i][j], d[i][b] + d[c][j] + 1);
			d[i][j] = min(d[i][j], d[i][c] + d[b][j] + 1);
		}
	}
	rep(i,1,a)
		rep(j, 1, a)
	{
		ans[d[i][j]]++;
	}
	rep(i, 1, a-1)
		cout << ans[i]/2 << endl;
}


Measured memory_bytes: 31616
#include <iostream>
#include <utility>
#include <algorithm>
#include <queue>
#include <vector>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pll pair<long long, long long>
#define ff first
#define ss second

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m; cin >> n >> m;
    piii inp[m]; for(auto &i : inp) {cin >> i.ff.ff >> i.ff.ss >> i.ss; --i.ff.ff;}
    sort(inp, inp + m);

    priority_queue<pll, vector<pll>, greater<pll>> Q;
    Q.push({0, 1});
    for(auto &i : inp)
    {
        while(!Q.empty() && Q.top().ss <= i.ff.ff) Q.pop();
        if(Q.empty()) {cout << -1; return 0;}
        Q.push({Q.top().ff + i.ss, i.ff.ss});
    }

    while(!Q.empty() && Q.top().ss < n) Q.pop();
    if(Q.empty()) {cout << -1; return 0;}
    cout << Q.top().ff;
    return 0;
}


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

/* 繰り返し自乗法. */
int modPow(long long a, long long n, long long p) {
	if (n == 0) return 1; // 0乗にも対応する場合.
	if (n == 1) return a % p;
	if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
	long long t = modPow(a, n / 2, p);
	return (t * t) % p;
}

int main() {
    int N;
    cin >> N;
    int a[N+1];
    rep (i, N) {
        cin >> a[i+1];
    }

    int cnt=0;
    rep (i, N) {
        if (((i+1)%2) == 0) continue;
        if ((a[i+1]%2) == 0) continue;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	ll m;
	cin >> n >> m;
	vector< map<ll, ll>> mp(n + 1);
	vector<P> py(m);
	ll p, y;
	rep(i, m) {
		cin >> p >> y;
		mp[p][y] = 1;

		py[i] = make_pair(p, y);
	}
	for (ll i = 1; i < n + 1; i++) {
		ll cnt = 1;
		for (auto itr = mp[i].begin(); itr != mp[i].end(); ++itr) {
			itr->second = cnt++;
		}
	}
	rep(i, m) {
		rep(j, 6 - GetDigit(py[i].first)) {
			cout << 0;
		}
		cout << py[i].first;
		rep(j, 6 - GetDigit(mp[py[i].first][py[i].second])) {
			cout << 0;
		}
		cout << mp[py[i].first][py[i].second] << endl;
	}
}

Measured memory_bytes: 14208
#include <iostream>

using namespace std;

int main() {
  int n;
  int a[10004];

  while ( cin >> n ) {
    // n == 0 と同じ
    if (!n) { break; }

    double ave_num = 0;

    for (int i = 0; i < n; i++) {
      cin >> a[i];
      ave_num += a[i];
    }

    ave_num /= n;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] <= ave_num) {
        cnt++;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 100000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
int h,w, n, m;
char maze[60][60];
int dis[60][60];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	string res;
	if (b - a <= k && c - a <= k && d - a <= k && e - a <= k && c - b <= k && d - b <= k && 
		e - b <= k && d - c <= k && e - c <= k && e - d <= k) {
		res = "Yay!";
	}
	else {
		res = ":(";
	}
	cout << res << endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: i64 = input();
    println!("{}", (0..n).sum::<i64>());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll count=0,ans;
    for(int i=a[1];i>0;i--){
        if(a[1]%i==0 || a[0]%i==0){
        for(int j=0;j<n;j++){
            if(a[j]%i==0)count++;
        }
        }
        if(count>n-2){
            ans=i;
            break;
        }else count=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ms(x, t) memset(x, t, sizeof(x))
typedef long long int ll;
typedef unsigned long long int ull;
const int limit = 3e3 + 1;
const int inf = 1e7;

int main()
{
    string s, t;
    cin >> s >> t;
    int sl = s.length();
    int tl = t.length();
    int m[sl + 1][tl + 1];
    stack<char> st;
    ms(m, 0);
    for (int i = 1; i <= sl; i++)
    {
        for (int j = 1; j <= tl; j++)
        {
            if (s[i - 1] == t[j - 1])
            {
                m[i][j] = 1 + m[i - 1][j - 1];
            }
            else
            {
                m[i][j] = max(m[i][j - 1], m[i - 1][j]);
            }
        }
    }
    int i = sl;
    int j = tl;
    for (; i != 0 && j != 0;)
    {
        if (s[i-1] == t[j-1])
        {
            st.push(s[i - 1]);
            i--;
            j--;
        }
        else if (m[i][j] == m[i - 1][j])
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    while (!st.empty())
    {
        cout << st.top();
        st.pop();
    }
    cout << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  string s;
  cin >> s;
  string t = "";
  rep(i,s.size()){
    if(s[i] == '0')t += '0';
    else if(s[i] == '1')t += '1';
    else if(!t.empty())t.erase(t.end()-1);
  }
  cout << t  << endl;






  

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(int argc, char const *argv[]) {
    int n,d,x;
    scanf("%d\n%d %d",&n,&d,&x);
    int i,a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int sum=0;
    for(i=0;i<n;i++){//i人目
        int eaten=0;
        for(int j=0;j*a[i]+1<=d;j++){//何回食べられるか
            eaten++;
        }
        sum+=eaten;//全員が食べた数
    }
    printf("%d",sum+x);
    return 0;
}


Measured memory_bytes: 128