akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long LL;
const int N=1e5+100;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int p[N],vis[N],st[N],len[N],tot[N];
int head[N],nxt[N];
bool rt[N];
int f[N],g[N];
inline int dfs(int k) {
	int s=0;
	for (int i=head[k];i;i=nxt[i])
		if (!rt[i]) {
			if (s) puts("0"),exit(0);
			s=dfs(i)+1;
		}
	return s;
}
int main()
{
	const int mod=1e9+7;
	int n=gi(),i,k,t,s,cnt=0,top,ans=1,p2=0;
	bool is;
	for (i=1;i<=n;i++) p[i]=gi(),nxt[i]=head[p[i]],head[p[i]]=i;
	for (i=1;i<=n;i++)
		if (!vis[i]) {
			++cnt;
			for (k=i;!vis[k];k=p[k])
				vis[k]=cnt;
			if (vis[k]!=cnt) continue;
			for (t=k,top=0;st[1]!=t;t=p[t]) rt[st[++top]=t]=true;
			reverse(st+1,st+1+top);
			is=false;
			for (k=1;k<=top;k++)
				is|=len[k]=dfs(st[k]);
			if (is) {
				for (k=1;k<=top;k++)
					if (len[k]) {
						for (t=k%top+1,s=1;!len[t];t=t%top+1,s++);
						if (s<len[k]) return puts("0"),0;
						if (s!=len[k]) p2++;
					}
			} else tot[top]++,p2+=top>1&&(top&1);
		}
	const int inv4=1LL*(mod+1)*(mod+1)/4%mod;
	for (i=1;i<=n;i++) {
		for (k=f[0]=f[1]=g[0]=g[1]=1;k<=tot[i];k++) {
			f[k+1]=(1LL*f[k-1]*k%mod*inv4%mod*i+f[k])%mod;
			g[k+1]=(1LL*g[k-1]*k%mod*i+g[k])%mod;
		}
		ans=1LL*ans*(i==1||i%2==0?g[tot[i]]:f[tot[i]])%mod;
	}
	while (p2--) (ans<<=1)%=mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



ll niz[100];
int n;
ll dp[100];


int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    ff(i,1,n)cin >> niz[i];
    dp[1] = 1000;
    ff(i,2,n+1){
        dp[i] = dp[i - 1];
        ff(j,1,i - 1){
            ff(k,j+1,i-1){
                ll sta = dp[j] / niz[j];
                sta = sta * niz[k];
                sta += dp[j]%niz[j];
                dp[i] = max(dp[i], sta);
            }
        }
    }
    cout << dp[n + 1] << "\n";
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
ll n, m, x, mn = 1e18, c[15], arr[15][15];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m >> x;
    for(int i = 0;i < n;++i)
    {
        cin >> c[i];
        for(int j = 0;j < m;++j)
            cin >> arr[i][j];
    }
    for(int i = 1;i < (1LL << n);++i)
    {
        ll tmp[m], cost = 0;
        memset(tmp, 0, sizeof tmp);
        for(int j = 0;j < n;++j)
        {
            if(i & (1LL << j))
            {
                cost += c[j];
                for(int k = 0;k < m;++k)
                    tmp[k] += arr[j][k];
            }
        }
        bool valid = 1;
        for(int j = 0;j < m;++j)
            if(tmp[j] < x)
                valid = 0;
        if(valid)   mn = min(mn, cost);
    }
    cout << (mn == 1e18 ? -1 : mn);
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;


int H,W;
int N;
int a[10001];
int ans[10001][10001];

int main(){
    cin >> H >> W;
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];

    int i=0,j=0;
    bool flag = true;
    for(int color=1;color<=N;color++){

        while(a[color-1]){
            ans[i][j] = color;
            if(flag) j++;
            else j--;

            if(j >= W){
                flag = false;
                j = W-1;
                i++;
            }
            else if(j < 0){
                flag = true;
                j = 0;
                i++;
            }

            a[color-1]--;
        }
    }

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}
   


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,l;
  string s[100];
  cin>>n>>l;
  rep(i,n){
    cin>>s[i];
  }
  sort(s,s+n);
  rep(i,n){
    cout<<s[i];
  }
  cout<<endl;
  return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 1e9+7;


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

	ll t = 1;
	// cin>>t;

	while(t--){
		ll n;
		cin>>n;

		if(n >= 30) cout<<"Yes\n";
		else cout<<"No\n";

	}

	return 0;

}


Measured memory_bytes: 3592
#pragma region template 1.0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    vi a(N);
    REP(i, N)
    {
        cin >> a[i];
    }

    vi c(4);
    REP(i, N)
    {
        ++c[a[i]];
    }
    vector<vector<vector<double>>> p(N + 1, vector<vector<double>>(N + 1, vector<double>(N + 1)));
    vector<vector<vector<double>>> e(N + 1, vector<vector<double>>(N + 1, vector<double>(N + 1)));
    p[c[3]][c[3] + c[2]][N] = 1;
    for (ll i = c[3]; i >= 0; --i)
    {
        for (ll j = c[3] + c[2]; j >= i; --j)
        {
            for (ll k = N; k >= j; --k)
            {
                if (i == c[3] and j == c[3] + c[2] and k == N)
                {
                    continue;
                }
                if (i < j)
                {
                    double q3 = p[i + 1][j][k] * (i + 1) / k;
                    p[i][j][k] += q3;
                    e[i][j][k] += q3 * (e[i + 1][j][k] + 1. * N / k);
                }
                if (j < k)
                {
                    double q2 = p[i][j + 1][k] * (j + 1 - i) / k;
                    p[i][j][k] += q2;
                    e[i][j][k] += q2 * (e[i][j + 1][k] + 1. * N / k);
                }
                if (k < N)
                {
                    double q1 = p[i][j][k + 1] * (k + 1 - j) / (k + 1);
                    p[i][j][k] += q1;
                    e[i][j][k] += q1 * (e[i][j][k + 1] + 1. * N / (k + 1));
                }
                e[i][j][k] /= p[i][j][k];
            }
        }
    }
    double ans = e[0][0][0];
#pragma region precision 1.0
    cout << fixed << setprecision(15) << ans << endl;
#pragma endregion precision
}
#pragma endregion template

Measured memory_bytes: 432768
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;
public class Main implements Runnable{

	int N;
	String[] s;
	HashSet<String> hash;

	public String dfs(int n,int m,String a){
		if(n == m){
			if(hash.contains(a))return null;
			return a;
		}

		for(int i = 0;i < 26;i++){
			String t = (a +(char)('a'+i));
			String res = dfs(n+1,m,t);
			if(res != null){
				return res;
			}
		}
		return null;
	}

    public void solve() {
    	N = nextInt();
    	s = new String[N];
    	hash = new HashSet<String>();
    	for(int i = 0;i < N;i++)s[i] = next();
    	for(int i = 0;i < N;i++){
    		for(int j = 0;j < s[i].length();j++){
	    		for(int k = 1;k <= 4;k++){
	    			hash.add(s[i].substring(j,Math.min(s[i].length(),j+k)));
	    		}
    		}
    	}

    	for(int i = 1;i <= 4;i++){
    		String ans = dfs(0,i,"");
    		if(ans != null){
    			out.println(ans);
    			break;
    		}
    	}
    }

    public static void main(String[] args) {
        new Thread(null,new Main(),"",64 * 1024 * 1024).start();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    @Override
    public void run() {
        out.flush();
        new Main().solve();
        out.close();

    }
}

Measured memory_bytes: 102244
#include <cstdio>
#include <queue>
#include <string>

int main() {
  size_t n;
  int q;
  scanf("%zu%d", &n, &q);
  std::queue<std::pair<std::string, int>> ps;
  for (size_t i = 0; i < n; i++) {
    char s[11];
    int t;
    scanf("%s%d", s, &t);
    ps.push(std::make_pair(s, t));
  }
  int elapsed = 0;
  while (ps.size()) {
    auto p = ps.front();
    ps.pop();
    auto& t = p.second;
    if (t <= q) {
      elapsed += t;
      printf("%s %d\n", p.first.c_str(), elapsed);
    } else {
      elapsed += q;
      t -= q;
      ps.push(p);
    }
  }
  return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
  vector<int>P=p;
  sort(rng(p));
  int c=0;
  for(int i=0;i<N;i++){
    if(p[i]!=P[i])c++;
  }
  if(c<=2)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
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];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		long[] ruiseki = new long[n + 1];
		ruiseki[0] = 0;
		Map<Long, Long> map = new HashMap<>();
		map.put(0l, 1l);
		for (int i = 1; i <= n; i++) {
			ruiseki[i] = ruiseki[i - 1] + a[i - 1];
			map.put(ruiseki[i], map.containsKey(ruiseki[i]) ? map.get(ruiseki[i]) + 1 : 1);
		}
		long ans = 0;
		for (long val : map.values()) {
			if (val > 1) {
				ans += val * (val - 1) / 2;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 79872
#include <bits/stdc++.h>
using namespace std;
#define dg(x) cerr << #x << " = " << x <<endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define fore(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX=100005;
int n;
const int INF=1e9;
int mem[MAX];
int dp(int x){
    int &ans=mem[x];
    if(x==0)return 0;
    if(x<0)return INF;
    if(ans!=-1)return ans;
    ans=dp(x-1)+1;
    for(int i=1;i<=6;i++){
        ans=min(ans,dp(x-pow(6,i))+1);
    }
    for(int i=1;i<=6;i++){
        ans=min(ans,dp(x-pow(9,i))+1);
    }
    return ans;
}
int main(){
#ifdef LOCAL
    //freopen("h.txt", "r", stdin);
    // freopen("main.out", "w", stdout);
#else
    ios::sync_with_stdio(0), cin.tie(0);
    #define endl '\n'
#endif
    cin>>n;
    memset(mem,-1,sizeof(mem));
    cout<<dp(n)<<endl;
    return 0;
}

Measured memory_bytes: 5376
n = int(input())
s, p = [], []
for _ in range(n):
    s_, p_ = input().split()
    s.append(s_)
    p.append(100 - int(p_))

max_len = max([len(e) for e in s])
s = [e.ljust(max_len, '0') for e in s]
p = [str(e).rjust(3, '0') for e in p]
m = [str(e).rjust(3, '0') for e in range(1, n+1)]

merged = [s[i]+p[i]+m[i] for i in range(n)]

merged.sort()

for i in range(n):
    print(int(merged[i][-3:]))


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int A, V; cin >> A >> V;
	int B, W; cin >> B >> W;
	int T; cin >> T;

	YES(V > W and 1.0*abs(A - B) / (V-W) <= T);

	return 0;
}


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

int main() {
  string a;
  string b;
  cin>>a>>b;
  if(a.at(2)==b.at(0) && a.at(0)==b.at(2) && a.at(1)==b.at(1)) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}


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

int main () {
	stack<int> a;
	string data;
	int ans, b, c;
	stringstream ss;
	while(cin >> data) {
		if (data == "*") {
			b = a.top();
			a.pop();
			c = a.top();
			a.pop();
			ans = c * b;
		}
		else if (data == "+") {
			b = a.top();
			a.pop();
			c = a.top();
			a.pop();
			ans = c + b;
		}
		else if (data == "-") {
			b = a.top();
			a.pop();
			c = a.top();
			a.pop();
			ans = c - b;
		}
		else {
			ss << data;
			ss >> ans;
			ss.str("");
			ss.clear(stringstream::goodbit);
		}
		a.push(ans);		
	}
	cout << a.top() << endl;
	return 0;
}

Measured memory_bytes: 3208
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  A = list(map(int, input().split()))
  A = A

#  pre = A[0]
#  right = -1
#  left = 0
#  max_ = 0
#  for i in range(1, N):
#    if pre+1 == A[i]:
#      right = i
#    else:
#      max_ = max(max_, right-left)
#      left = i
#  max_ = max(max_, N-left)

  max_ = 0
  for i in range(N):
    if max_ + 1 == A[i]:
      max_ = A[i]

  print(N-max_ if max_ else -1)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 103272
#include <stdio.h>
#include <string.h>

typedef struct{
	int a, b, c, d, e, f;
}Dice;

int main(void)
{
	Dice dice;
	
	int i, temp, q, n, m;
	
	scanf("%d %d %d %d %d %d", &dice.a, &dice.b, &dice.c, &dice.d, &dice.e, &dice.f);
	scanf("%d", &q);
	
	for(i=0;i<q;i++){
		scanf("%d %d", &n, &m);
		if((dice.a==n&&dice.b==m)||(dice.b==n&&dice.f==m)||(dice.f==n&&dice.e==m)||(dice.e==n&&dice.a==m))
			printf("%d\n", dice.c);
		else if((dice.d==n&&dice.b==m)||(dice.b==n&&dice.c==m)||(dice.c==n&&dice.e==m)||(dice.e==n&&dice.d==m))
			printf("%d\n", dice.a);
		else if((dice.a==n&&dice.d==m)||(dice.d==n&&dice.f==m)||(dice.f==n&&dice.c==m)||(dice.c==n&&dice.a==m))
			printf("%d\n", dice.b);
		else if((dice.a==n&&dice.e==m)||(dice.e==n&&dice.f==m)||(dice.f==n&&dice.b==m)||(dice.b==n&&dice.a==m))
			printf("%d\n", dice.d);
		else if((dice.a==n&&dice.c==m)||(dice.c==n&&dice.f==m)||(dice.f==n&&dice.d==m)||(dice.d==n&&dice.a==m))
			printf("%d\n", dice.e);
		else if((dice.b==n&&dice.d==m)||(dice.d==n&&dice.e==m)||(dice.e==n&&dice.c==m)||(dice.c==n&&dice.b==m))
			printf("%d\n", dice.f);
	}
	
	return 0;
}



Measured memory_bytes: 2048
n,a,b,c=map(int,input().split())
l=[]
for i in range(n):
  l.append(int(input()))
  
import itertools as it
pattern=list(it.product(range(4),repeat=n))

keep=10**100
for i in range(0,len(pattern)):
  kep1=0
  kep2=0
  kep3=0
  mp=0
  liis=pattern[i]
  for j in range(0,n):
    if liis[j]==1:
      if kep1==0:
        kep1=l[j]
      else:
        kep1+=l[j]
        mp+=10
    elif liis[j]==2:
      if kep2==0:
        kep2=l[j]
      else:
        kep2+=l[j]
        mp+=10
    elif liis[j]==3:
      if kep3==0:
        kep3=l[j]
      else:
        kep3+=l[j]
        mp+=10
  if kep1==0 or kep2==0 or kep3==0:
    continue
  mp+=abs(kep1-a)+abs(kep2-b)+abs(kep3-c)
  if mp<keep:
    keep=mp
print(keep)
        

Measured memory_bytes: 10996
nb_s, nb_c = map(int, input().split())

if nb_s*2 > nb_c:
    print(nb_c // 2)
else:
    nb_used_c = 2*nb_s

    nb_rest_c = int(nb_c) - nb_used_c

    print(int(nb_s) + (nb_rest_c // 4))

Measured memory_bytes: 2940
import numpy as np

s = input()
K = int(input())
L = len(s)

candidate = []

for l in range(1, K + 1):
    for j in range(0, L - l + 1):
        candidate.append(s[j:j+l])

candidate = list(set(candidate))
print(np.sort(candidate)[K-1])

Measured memory_bytes: 14296
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main(){
	string s;
	string ans[] = {"Yes", "No"};
	int flag = 0, n = 0;
	cin>>s;
	n = s.length();
	
	for(int i = 0; i < n/2; i++){
		if (s[i] != s[n-i-1]){
			flag = 1;
		}
	}
	for(int i = 0; i < (n-1)/2/2; i++){
		if (s[i] != s[(n-1)/2 - i - 1]){
			flag = 1;
		}
	}
	for(int i = n; i < n - (n-1)/4; i--){
		if (s[i] != s[(n+3)/2 + (n-i)]){
			flag = 1;
		}
	}
	
	cout<<ans[flag]<<endl;
}


Measured memory_bytes: 256
//58
#include<iostream>

using namespace std;


int main(){
  bool ns=false;
  for(int p,s;cin>>p>>s,p;){
    int t[101][11];
    bool q[101][11]={{}};
    int nq=0;
    for(int i=0;i<p+1;i++){
      for(int j=0;j<s+1;j++){
	cin>>t[i][j];
	if(!cin){
	  t[i][j]=nq++;
	  q[i][j]=true;
	  cin.clear();
	  cin.ignore();
	}
      }
    }
    int r=nq;
    int a[1000];
    for(int i=0;i<nq;i++){
      for(int j=0;j<p;j++){
	int cq=0,x;
	int sm=0;
	for(int k=0;k<s;k++){
	  if(q[j][k]){
	    cq++;
	    x=k;
	  }else{
	    sm+=t[j][k];
	  }
	}
	if(cq==1){
	  int an=t[j][s]-sm;
	  a[t[j][x]]=an;
	  t[j][x]=an;
	  q[j][x]=false;
	  r--;
	}
      }
      for(int j=0;j<s;j++){
	int cq=0,x;
	int sm=0;
	for(int k=0;k<p;k++){
	  if(q[k][j]){
	    cq++;
	    x=k;
	  }else{
	    sm+=t[k][j];
	  }
	}
	if(cq==1){
	  int an=t[p][j]-sm;
	  a[t[x][j]]=an;
	  t[x][j]=an;
	  q[x][j]=false;
	  r--;
	}
      }
    }
    if(ns){
      cout<<endl;
    }
    ns=true;
    if(r){
      cout<<"NO"<<endl;
    }else{
      for(int i=0;i<nq;i++){
	cout<<a[i]<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1172
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int M = sc.nextInt();
  int X = sc.nextInt();
  int countp = 0;
  int countq = 0;
  for(int i = 0;i < M;i++){
    int a = sc.nextInt();
    if(X < a){
      countp++;
    }
    else if(X > a){
      countq++;
    }
  }
  System.out.println(countp >= countq ? countq:countp);
}}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(true){
        string str;
        cin >> str;
        if(str == "-") break;
        int m;
        cin >> m;
        for(int i=0; i<m; i++){
            int h;
            cin >> h;
            str = str.substr(h) + str.substr(0, h);
        }
        cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>

int main(){
    int a,b,c;
    int s = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i = a;i <= b;i++){
        if(c % i == 0){
            s++;
        }
        else continue;
    }
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 2748
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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 main(void) {
    char c[2][3];
    for (int i = 0; i < 2; i++)for (int j = 0; j < 3; j++)cin >> c[i][j];
    if (c[0][2] == c[1][0] && c[1][2] == c[0][0] && c[1][1] == c[0][1])cout << "YES";
    else cout << "NO";
    return 0;
}

Measured memory_bytes: 3608
# coding: utf-8
# Your code here!
N=int(input())

cand=["a"]

num=98
for i in range(N-1):
    #print(i)
    temp=[]
    for item in cand:
        ma=0
        for c in item:
            ma=max(ma,ord(c))
        for i in range(ma-95):
            temp.append(item+chr(i+97))
    num+=1
    cand=temp[:]

for item in cand:
    print(item)


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

int N, M, Q;
int Dp[510][510];

int main(){
	int i, j, x, y;
	scanf("%d %d %d", &N, &M, &Q);
	for(i = 0; i < M; i++){
		scanf("%d %d", &x, &y);
		Dp[x][y]++;
	}
	for(i = 1; i <= N; i++){
		for(j = 0; j + i <= N + 1; j++) Dp[j][j + i] += Dp[j][j + i - 1] + Dp[j + 1][j + i] - Dp[j + 1][j + i - 1];
	}
	for(i = 0; i < Q; i++){
		scanf("%d %d", &x, &y);
		printf("%d\n", Dp[x][y]);
	}
	return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int aa[3];
  aa[0]= a+b;
  aa[1]=a-b;
  aa[2]=a*b;
  sort(aa,aa+3);
  cout<<aa[2];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long M=1e9+7,n,k,ans=1,l,r,b=1,a[1<<18],x,y,i;
main(){
  cin>>n>>k;
  r=n-1;
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  if(k%2)ans=a[r],r--,k--,b=(ans<0?-1:1);
  while(k){
    x=a[l]*a[l+1],y=a[r]*a[r-1];
    if(x*b>y*b)ans*=x%M,ans%=M,l+=2;
    else ans*=y%M,ans%=M,r-=2;
    k-=2;
  }
  cout<<(ans+M)%M<<endl;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(N + 1);
    rep(i, 0, M) {
        int L, R;
        cin >> L >> R;
        a[L-1]++;
        a[R]--;
    }
    psum(a);
    int ans = 0;
    rep(i, 0, N) {
        if (a[i] == M) {
            ans++;
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



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

int main(){
	int n,a,b,k,c[100];
	scanf("%d%d%d%d",&n,&a,&b,&k);
	for(int i=0;i<n;i++) scanf("%d",&c[i]);
	sort(c,c+n);
	int d=a, res=k/d;
	for(int i=n-1;i>=0;i--){
		d+=b;k+=c[i];
		if(res>k/d)break;
		res=k/d;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 1204
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func firstDigit(x int) int {
	str := strconv.Itoa(x)
	i, _ := strconv.Atoi(str[len(str)-1 : len(str)])
	return i
}

func minFirstDigit(ints []int) int {
	res := 0
	t := 10
	for _, n := range ints {
		x := firstDigit(n)
		if x == 0 {
			continue
		}
		if x < t {
			t = x
			res = n
		}
	}
	if res == 0 {
		return ints[0]
	}
	return res
}

func roundUp(i int) int {
	fd := firstDigit(i)
	if fd == 0 {
		return i
	}
	return i + (10 - fd)
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	var ints []int
	for i := 0; i < 5; i++ {
		line := readLine(sc)
		n, _ := strconv.Atoi(line)
		ints = append(ints, n)
	}

	flg := false
	min := minFirstDigit(ints)
	res := 0
	for _, n := range ints {
		if n == min && !flg {
			flg = true
			continue
		}
		res += roundUp(n)
	}
	res += min

	fmt.Println(res)
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='1') s[i]='9';
        else if(s[i]=='9') s[i]='1';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
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 c = sc.nextInt();
		// 出力
		System.out.println((a+b-1)/b*c);
	}
}

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

int  main()
{
	int n; cin >> n;
	if (n < 1200)
		cout << "ABC";
	else if (n < 2800)
		cout << "ARC";
	else
		cout << "AGC";
	return (0);
}

Measured memory_bytes: 256
n = int(input())
dic = {}
for i in range(n):
	s = input()
	if s in dic:
		dic[s] += 1
	else:
		dic[s] = 1
dic2 = sorted(dic.items(), key=lambda x:x[1],reverse=True)
x = dic2[0][1]
b = []

for i in dic2:
	if i[1] == x:
		b.append(i[0])
b.sort()
for i in b:
	print (i)


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

int main(){
    int N, a[101];
    cin >> N;
    for(int i=1; i<=N; i++) cin >> a[i];
    int k=1, cnt = 0;
    while(k <= N){
        if(a[k] == a[k+1]){
            ++cnt;
            k += 2;
        }
        else{
            ++k;
        }
    }
    cout << cnt << '\n';
    return 0;
}

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

using namespace std;


void solve() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    for (auto& x: a) {
        cin >> x;
    }
    for (auto& x: b) {
        cin >> x;
    }
    vector<int> f(n);
    iota(f.begin(), f.end(), -1); f[0] += n;
    vector<int> g(n);
    iota(g.begin(), g.end(), 1); g[n-1] = 0;
    auto nei = [&](int i){
        return b[f[i]] + b[g[i]];
    };
    auto ok = [&](int i){
        return nei(i) < b[i];
    };
    vector<int> stk; stk.reserve(n);
    for (int i = 0; i < n; i++) {
        if (ok(i)) stk.emplace_back(i);
    }
    long long res = 0;
    while (!stk.empty()) {
        int i = stk.back(); stk.pop_back();
        if (!ok(i)) continue;
        if (b[i] < a[i]) {
            cout << -1; return;
        }
        int diff = b[i] - a[i];
        int k = diff / nei(i);
        res += k; b[i] -= k * nei(i);
        if (ok(f[i])) stk.emplace_back(f[i]);
        if (ok(g[i])) stk.emplace_back(g[i]);
    }
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            cout << -1; return;
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 3840
a = map(int,input().split())
a = list(a)
for l in range(2):
    a[l] = int(a[l])
c = 0
b =[]
for i in range(1,a[0]+1):
    j = 0
    while True:
        infer = a[1]/i
        refer = (2)**j
        if refer >= infer:
            c = (1/refer)/a[0]
            b.append(c)
            break
        else:
            j += 1
print(sum(b))

Measured memory_bytes: 6296
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n;
  const int tank[] = {5, 7, 5, 7, 7};
  while (cin >> n && n) {
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
      string ww;
      cin >> ww;
      w[i] = ww.length();
    }
    int ans = -1;

    for (int i = 0; i < n; i++) {  //??????????????°?????????????????????
      int tmp = 0;
      int cnt = 0;
      for (int j = i; j < n; j++) {
        tmp += w[j];
        //cerr << tmp << " ";
        if (tmp < tank[cnt]) {
          //?¶???????????????§?????????????¬???????????????????
        } else if (tmp == tank[cnt]) {
          //????????????????????§?¬???????????????????
          tmp = 0;
          cnt++;
          if (cnt == 5) {
            // 57577????????£???
            ans = i + 1;
            goto FIN;
          }

        } else {
          //??¢???????????§??±???
          break;
        }
      }
      //cerr << endl;
    }

  FIN:
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

/*================================================
	Disjoint Set
================================================*/
class DisjointSet {
private:
	vector<int> rank, p;

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			p[y] = x;
		}
		else {
			p[x] = y;
			if (rank[x] == rank[y]) rank[y]++;
		}
	}
	int findSet(int x) {
		if (x != p[x]) p[x] = findSet(p[x]);
		return p[x];
	}

public:
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, size) makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
};

/* weight, source, destination */
priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > Edges;

int krustal(int V)
{
	int totalCost = 0;
	pair<int, pair<int, int> > edge;
	DisjointSet dset = DisjointSet(V + 1);

	rep(i, V) dset.makeSet(i);
	while(!Edges.empty()) {
		edge = Edges.top(); Edges.pop();
		if (!dset.same(edge.second.first, edge.second.second)) {
			totalCost += edge.first;
			dset.unite(edge.second.first, edge.second.second);
		}
	}

	return totalCost;
}

int main()
{
	int V, E, s, t, w;
	int root = 0, root_cost = 0, ans = 0;

	cin >> V >> E;
	rep(i, E) {
		(void)scanf("%d %d %d", &s, &t, &w);
		Edges.push(make_pair(w, make_pair(s, t)));
	}
	
	cout << krustal(V) << endl;

	return 0;
}


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

int main()
{
int i;
int a;
long long n;
long long m;
long long d;
long double X;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> n;
	cin >> m;
	cin >> d;

	if( d > 0 )
		X = ( m - 1 ) * 2 * ( n - d );
	else
		X = ( m - 1 ) * n;

	X /= n * n;

	cout << fixed << setprecision( 10 ) << X << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i=a;i<=b;i++)

void solve()
{
    string s;
    cin >> s;

    if(s[0]==s[1] && s[1]==s[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return;
}

int main() 
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    fastio

    ll t = 1;
    //cin >> t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<string>
#include<utility>
#include<iomanip>
#include<bitset>
#include<math.h>
using namespace std;
 
 
int main(){
 
	int n;
	cin >> n;
	long long ans = 0;
	if(n == 100000){
		ans = 90909;
	}else if(n>=10000){
		ans += 909;
		ans += n-10000+1;
	}else if(n>=1000){
		ans = 909;
	}
	else if(n>=100){
		ans += 9;
		ans += n-100+1;
	}else if(n >= 10){
		ans = 9;
	}else{
		ans = n;
	}
	
	cout << ans << endl;
	

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 22;
const int M = (1 << 21);
const int mod = 1000000007;
int dp[N][M], n, st;
bool fx[N][N];
int cnt[M];

int get(int num) {
    int ones = 0;
    while(num) {
        if(num & 1) ones ++;
        num >>= 1;
    }
    return ones;
}

int main() {
    cin >> n;
    st = (1 << n);
    dp[0][0] = 1;
    for(int i = 1; i < st; i ++) {
        cnt[i] = get(i);
    }
    for(int i = 1; i <= n; i ++) {
        for(int j = 0; j < n; j ++) {
            int x;
            cin >> x;
            if(x) {
                fx[i][j] = true;
            }
        }
    }
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j < st; j ++) {
            if(cnt[j] != i) continue;
            for(int k = 0; k < n; k ++) {
                if (((j >> k) & 1) == 1 && fx[i][k] == true) {
                    dp[i][j] += dp[i-1][j ^ (1 << k)];
                    dp[i][j] %= mod;
                } 
            }
        }
    }
    //&& fx[i][k] == true
    cout << dp[n][st-1] << endl;
    return 0;
}


Measured memory_bytes: 172288
N = int(input())
A = list(map(int,input().split()))
sum_A = sum(A)
ans = 10**15
x = 0
for i in range(N-1):
    x += A[i]
    dif = abs(sum_A - 2*x)
    if dif < ans:
        ans = dif
print(ans)

Measured memory_bytes: 24812
#include <stdio.h>

int main()
{
  int k, a, b, i;
  scanf("%d\n%d %d", &k, &a, &b);
  for(i = a; i <= b; i++) {
    if(i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");
  return 0;
}


Measured memory_bytes: 1660
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toLong).sorted()
    val greatestCommonDiv = gcd(a, b)

    val primes = greatestCommonDiv.getDisjointDividers()

    println(1 + primes.size)
}

tailrec fun gcd(a: Long, b: Long): Long {
    return when (a) {
        0L -> b
        else -> gcd(b % a, a)
    }
}

fun Long.getDisjointDividers(): Set<Long> {
    var divider = 2L
    var n = this
    val dividers = mutableSetOf<Long>()


    while (divider * divider <= this) {
        if (n % divider != 0L) {
            divider += 1L
            continue
        }
        while (n % divider == 0L) n /= divider
        dividers += divider
        divider += 1L
    }

    if (n > 1L) dividers += n

    return dividers
}

Measured memory_bytes: 37780
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
	string S;
	int res;
	
	cin >> S;
 
	if(S == "RRR"){
		res = 3;
	}else if((S == "SRR") || (S == "RRS")){
		res = 2;
	}else if((S == "SSR") || (S == "SRS") || (S == "RSS") || (S == "RSR")){
		res = 1;
	}else if(S == "SSS"){
		res = 0;
	}
 
	cout << res;
 
	return 0;
}

Measured memory_bytes: 3576
using System;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int AC = 0;
		int WA = 0;
		int TLE = 0;
		int RE = 0;
		for (int i =0; i < N; i++)
        {
			string a = Console.ReadLine();
			if (a == "AC") { AC++; }
			if (a == "WA") { WA++; }
			if (a == "TLE") { TLE++; }
			if (a == "RE") { RE++; }
		}
		Console.WriteLine("AC x " + AC);
		Console.WriteLine("WA x " + WA);
		Console.WriteLine("TLE x " + TLE);
		Console.WriteLine("RE x " + RE);
	}
}

Measured memory_bytes: 30632
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr
ans=0
n=int(input())
L=factorization(n)
if n>1:
    for l in L:
        tmp=l
        for i in range(1,l+1):
            tmp-=i
            if tmp>=0:
                ans+=1
            if tmp<=0:
                break
print(ans)

Measured memory_bytes: 9488
#include <bits/stdc++.h>
#define int long long
#define PI acos(-1)

using namespace std;

constexpr double EPS = 1e-8;
constexpr int MAXN = 3e5 + 5;
constexpr int INF = 0x3f3f3f3f;

array<int, MAXN> a;

int n, k;

inline bool check(int mid) {
    int cnt(0);
    for (int i = 1; i <= n; i++) {
        if (a[i] % mid == 0) cnt += a[i] / mid - 1;
        else cnt += a[i] / mid;
    }
    return cnt <= k; //
}

signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int l = 1, r = 2e9, ans = 0;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) {
            ans = mid, r = mid - 1;
        } else l = mid + 1;
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
  int N;
  int Ans=0;
  cin >> N;
  vector<int>Vec(N);
  for(int i=0; i<N; i++){
   cin >> Vec.at(i);
   }
  
  for(int i=0; i<N; i++){
   if((i+1)*Vec.at(i)%2==1){
     Ans++;
   }
  }
  cout << Ans ;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  ll cnt = abs(X) / D;
  if (K < cnt) {
    cnt = K;
  }
  if (0 < X) {
    X -= cnt * D;
  } else {
    X += cnt * D;
  }
  K -= cnt;
  K %= 2;
  if (K == 1) {
    if (0 < X) {
      X = min(abs(X - D), abs(X + D));
    } else {
      X = min(abs(X + D), abs(X - D));
    }
  }
  cout << abs(X) << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<algorithm>
#define lowbit(x) ((x)&-(x))
typedef long long ll;
const int N=3e5+5,M=3e6+5;
const ll inf=1ll<<40;
ll a[N],s[N],f[N],g[N],b[N];int n,m,rk[N];
template<class T>T abs(T x){return x<0?-x:x;}
template<class T>bool chkmax(T&a,T b){return a<b?a=b,true:false;}
template<class T>T min(T a,T b){return a<b?a:b;}
template<class T>T div2(T x){return (x-(x&1))/2;}
inline void init(){
	std::reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++)s[i]=s[i-1]+((i&1)?-a[i]:a[i]);
}
struct node{
	node*c[2];
	int size;
	ll v1,v2,key,x1,x2;
	node();
	void pushup();
}Tnull,*null=&Tnull,pl[M],*rt[N];int pp;
node::node(){
	c[0]=c[1]=null;
	v1=v2=x1=x2=key=size=0;
}
void node::pushup(){
	size=c[0]->size+c[1]->size+1;
	x1=v1,x2=v2;
	if(c[0]!=null)chkmax(x1,c[0]->x1),chkmax(x2,c[0]->x2); 
	if(c[1]!=null)chkmax(x1,c[1]->x1),chkmax(x2,c[1]->x2);
}
void rot(node*&x,bool f){
	node*y=x->c[f];
	x->c[f]=y->c[f^1],y->c[f^1]=x;
	x->pushup(),x=y,x->pushup(); 
}
void insert(node*&x,node*y){
	if(x==null){
		x=y,x->c[0]=x->c[1]=null,x->pushup();
		return;
	}
	bool f=x->key<y->key;
	insert(x->c[f],y);
	if(x->c[f]->size>(x->size+1)*0.75)rot(x,f);else x->pushup();
}
ll ask(node*x,ll cut){
	if(x==null)return -inf;
	ll res=-inf;
	if(x->key<=cut){
		chkmax(res,x->v1-cut);
		if(x->c[0]!=null)chkmax(res,x->c[0]->x1-cut);
		chkmax(res,ask(x->c[1],cut));
	}else{
		chkmax(res,x->v2+cut);
		if(x->c[1]!=null)chkmax(res,x->c[1]->x2+cut);
		chkmax(res,ask(x->c[0],cut));
	}
	return res;
}
inline void calc(ll*f){
	int i,x;
	for(m=0,i=1;i<=n;i++)b[++m]=s[i];
	std::sort(b+1,b+m+1),m=std::unique(b+1,b+m+1)-b-1;
	for(i=1;i<=n;i++)rk[i]=m-(std::lower_bound(b+1,b+m+1,s[i])-b)+1;
	pp=0;
	for(i=1;i<=m;i++)rt[i]=null;
	for(i=1;i<=n;i+=2){
		f[i]=abs(s[i]);
		for(x=rk[i]-1;x;x-=lowbit(x))chkmax(f[i],ask(rt[x],s[i]));
		if(i<n){
			for(x=rk[i+1];x<=m;x+=lowbit(x)){
				node*z=pl+(pp++);
				z->key=div2(2*s[i+1]+s[i]-f[i]);
				z->v1=2*s[i+1],z->v2=f[i]-s[i];
				insert(rt[x],z);
			}
		}
	}
}
int main(){
	int i;
	scanf("%d",&n);
	ll dif=0,sum=0;
	for(i=1;i<=n;i++)scanf("%lld",a+i),dif+=(i&1)?a[i]:-a[i],sum+=a[i];
	dif=abs(dif);
	if(n&1){
		std::reverse(a+1,a+n+1);
		init(),calc(f),init(),calc(g),init();
		std::reverse(g+1,g+n+1);
		for(i=2;i<n;i+=2)chkmax(dif,a[i]+min(s[i-1]+g[i+1],f[i-1]+s[n]-s[i]));
	}
	ll sigma=(sum-dif)>>1,sugim=sigma+dif;
	printf("%lld %lld\n",sugim,sigma);
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];
			var K = inputArray[1];

			var pointArray = retreiveLongArray();
			var R = pointArray[2];//コンピューターがrの時得られる点数
			var S = pointArray[0];//上記と同じ考え
			var P = pointArray[1];
			var janken = retreiveStringArray()[0];

			var rList = new HashSet<long>();
			var sList = new HashSet<long>();
			var pList = new HashSet<long>();

			//r,s,pそれぞれが何番目に出てくるかを記録する
			for (int i = 0; i < N; i++) {
				var ch = janken[i];

				if (ch == 'r') {
					rList.Add(i);
				}
				if (ch == 's') {
					sList.Add(i);
				}
				if (ch == 'p') {
					pList.Add(i);
				}
			}
			//K回目　同じ手出せないときの制約を考えないときのポイント
			var unrestrictPoint = R * rList.Count() + S * sList.Count() + P * pList.Count();

			var rLoss = calLossPoint(K, R,rList);
			var sLoss = calLossPoint(K, S, sList);
			var pLoss = calLossPoint(K, P, pList);



			//答えの出力
			var ans = unrestrictPoint- rLoss- sLoss- pLoss;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// 同じ手を出せないことによって生じる損失点数
		/// </summary>
		/// <param name="K"></param>
		/// <param name="point"></param>
		/// <param name="jankenList"></param>
		/// <returns></returns>
		private static long calLossPoint(long K, long point, HashSet<long> jankenList) {

			var changeList = new HashSet<long>();//K番先に同じ手がある場合、書き換える。書き換えた番号を覚えておくリスト
			var count = 0;
			foreach (var r in jankenList) {

				if (changeList.Contains(r)) {
					continue;
				}

				if (jankenList.Contains(r + K)) {
					count++;
					changeList.Add(r + K);
				}
			}
			return point * count;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

using namespace std;

int A[100005], B[100005];

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int N;
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> A[i];
		B[A[i]] = i;
	}
	for (int i = 1; i <= N; ++i) cout << B[i] << ' ';
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;

long long h,w,c[1500][1500];

long long solve(int y,int x){
    if(c[y][x]!=0)return c[y][x];
    if(c[y+1][x+1]==-1||c[y][x+1]==-1||c[y+1][x]==-1){
        c[y][x]=1;
        return c[y][x];
    }
    else{
        c[y][x]=min(solve(y+1,x+1),solve(y,x+1));
        c[y][x]=min(c[y][x],solve(y+1,x));
        c[y][x]++;
        return c[y][x];
    }
}

int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
            c[i][j]*=-1;
        }
    }
    for(int i=0;i<=h;i++){
        c[i][w]=-1;
    }
    for(int i=0;i<=w;i++){
        c[h][i]=-1;
    }
    long long ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,solve(i,j));
        }
    }
    cout<<ans*ans<<endl;
    return 0;
}

Measured memory_bytes: 19432
//ABC 176 A
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    if(a % b == 0){
        a = a /b;
    }else{
        a = a /b +1;
    }
    a = a * c;
    cout << a <<endl;
}

Measured memory_bytes: 3588