akhauriyash/Code-Regression huggingface dataset:
n = int(input())
graph = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
  graph[i] = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    ans += min(graph[i][j], graph[j][i])
print(ans)


Measured memory_bytes: 6008
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
    int n, m;
    cin>>n>>m;

    string a(m, char(n+'0'));
    string b(n, char(m+'0'));

    if(n>m) cout<<b<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<ios>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;


int main(void) {
	int n, k; cin >> n >> k;

	if (n%k == 0) { cout << "0" << endl; }
	else { cout <<"1"<< endl; }

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
		int a = Integer.parseInt(s);
		System.out.print(a/3600+":");
		int b = a % 3600;
		System.out.print(b/60+":");
		System.out.println(b%60);
		
	}

}

Measured memory_bytes: 17052
list0=[]
date0=input().rstrip().split(" ")
date1=input().rstrip().split(" ")
date2=input().rstrip().split(" ")
list0.append(date0)
list0.append(date1)
list0.append(date2)
num=int(input())
for k in range(num):
  memo=input()
  for i in range(3):
    j=0
    for j in range(3):
      if list0[i][j]==memo:
        list0[i][j]="0"
if list0[0]==['0','0','0'] or list0[1]==['0','0','0'] or list0[2]==['0','0','0']:
  print("Yes")
elif list0[0][1]=="0" and list0[1][1]=="0" and list0[2][1]=="0":
  print("Yes")
elif list0[0][2]=="0" and list0[1][2]=="0" and list0[2][2]=="0":
  print("Yes")
elif list0[0][0]=="0" and list0[1][0]=="0" and list0[2][0]=="0":
  print("Yes")
elif list0[0][0]=="0" and list0[1][1]=="0" and list0[2][2]=="0":
  print("Yes")
elif list0[0][2]=="0" and list0[1][1]=="0" and list0[2][0]=="0":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    string s;
    cin >> s;
    int C_count = 0,up_count = 0;

    bool flag = 0;

    if(s[0]!='A'||s[1]=='C'||s[s.size()-1]=='C'){
        flag = 1;
    }
    
    FOR(i,2,s.size()-1){
        if(s[i]=='C'){
            C_count++;
        }

       
    }

    FOR(i,1,s.size()){
        if(s[i]<='Z'){
            up_count++;
        }
    }

    if(C_count != 1){
        flag = 1;
    }

    if(C_count==1&&up_count!=1){
        flag = 1;
    }

    if(flag == 1){
        cout << "WA" << endl;
    }else{
        cout << "AC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    int n, k; cin>>n>>k;

    string s; cin >> s;

    vector<int> hs, up;


    if(s[0] == '0'){
        hs.push_back(0);
    }

    int tempup = 0;
    int temphs = 0;
    
    for(int i=0; i<n; i++){
        
        if(s[i] == '1'){
            temphs++;
        }
        else{
            tempup++;
        }

        if(i != 0){
            if(s[i-1] == '1' && s[i] == '0'){
                hs.push_back(temphs);
                temphs = 0;
            }
            else if(s[i-1] == '0' && s[i] == '1'){
                up.push_back(tempup);
                tempup = 0;
            }
        }

        if(i == n-1){
            if(s[i] == '1'){
                hs.push_back(temphs);
            }
            else{
                up.push_back(tempup);
                hs.push_back(0);
            }
            break;
        }
    }

    int tempmax = 0;
    if(up.size() <= k){
        cout << s.size();
    }
    else if(up.size() == 0){
        cout << hs[0];
    }
    else{
        for(int i=0; i<hs.size()-k; i++){
            int temp = 0;
            for(int j=i; j<i+k; j++){
                temp += up[j] + hs[j];
            }
            temp += hs[i+k];
            if(tempmax < temp){
                tempmax = temp;
            }
        }
        cout << tempmax;
    }

    // cout << endl << "hs" << endl;
    // for(int i=0; i<hs.size(); i++){
    //     cout << hs[i] << endl;
    // }
    // cout << endl << "up" << endl;
    // for(int i=0; i<up.size(); i++){
    //     cout << up[i] << endl;
    // }

    return 0;
}

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

int main(){
	int X; cin >> X;
	int ans = 1;
	for(int i = 2; i < X; i++)
	{
		for(int j = i*i; j <= X; j*=i)
		{	
			ans = max(ans, j);
		}
		
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  ll N; cin >> N;
  ll a,b;
  if (N%2){
    a = (N-1)/2;
    a *= N;
  }
  else{
    a = N/2;
    a *= (N-1);
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
struct data{
	int x,y;
}t[200001];
int n,m,f[200001],x,y,cnt;
set<int> v[200001];
int fa(int a){
	if(f[a]!=a)f[a]=fa(f[a]);
	return f[a];
}
void ins(int a,int b){
	set<int>::iterator id1=v[a].find(b),id2=v[b].find(a);
	if(id1==v[a].end()){
		v[a].insert(b);
		v[b].insert(a);
	}else{
		cnt++;
		v[a].erase(b);
		v[b].erase(a);
		t[cnt].x=a;
		t[cnt].y=b;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n*2-2;i++){
		scanf("%d%d",&x,&y);
		ins(x,y);
	}
	for(int i=1;i<=n;i++)f[i]=i;
	while(cnt){
		x=fa(t[cnt].x);
		y=fa(t[cnt].y);
		cnt--;
		if(v[x].size()>v[y].size())swap(x,y);
		f[x]=y;
		for(int i:v[x]){
			v[i].erase(x);
			ins(i,y);
		}
		v[x].clear();
		m++;
	}
	if(m==n-1)printf("YES\n");
	else printf("NO\n");
}

Measured memory_bytes: 29184
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007

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

    int n;
    cin >> n;
    rep1(i,9){
        rep1(j,9){
            int k = i*j;
            if(n==k){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
	return 0;
  
}

Measured memory_bytes: 3616
def inpl(): return list(map(int, input().split()))

N = int(input())
P = inpl()
T = inpl()

cost = 10**9
for a in range(-(-N//T[0]) + 1):
    costa = P[0]*a
    teaa = T[0]*a
    rema = N - teaa
    for b in range(max(1, -(-rema//T[1]) + 1)):
        costb = P[1] * b
        teab = T[1]*b
        remb = max(rema - teab, 0)
        for c in range(max(1, -(-remb//T[2]) + 1)):
            costc = P[2] * c
            teac = T[2] * c
            remc = max(remb - teac, 0)
            
            d = max(-(-remc//T[3]), 0)
            costd = P[3] * d
            tead = T[3] * d

            cost = min(cost, costa + costb + costc + costd)
print(cost)


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

using namespace std;
using namespace __gnu_pbds;

//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 

 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;  
typedef unsigned long long ull;         
typedef vector < pii > vpii;                                   	
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;
 
typedef tree < int, null_type, less < int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
 
const int inf = 1e9, maxn = 2e5 + 48, mod = 998244353, N = 1e6 + 12;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = acos(-1);
const ll INF = 1e18;


vi g[N], gg[N];
int n, a[maxn], res[N], ans;

inline void precalc () {
	for (int i = 1; i < N; ++i)
		for (int j = i; j < N; j += i) 
			g[j].pb(i); 
}

inline void add (int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	if (x < 0)
		x += mod;
}

int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res = res * 1ll * a % mod;
		a = a * 1ll * a % mod;
		n >>= 1;
	}

	return res;
}

main () {
	precalc();

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		for (auto j : g[a[i]])
			gg[j].pb(a[i]);
	}

	for (int i = N - 1; i > 0; --i) {
		for (int j = sz(gg[i]) - 2; j >= 0; --j) {
		    add(res[i], gg[i][j] * 1ll * gg[i][j + 1] % mod);
			add(gg[i][j], gg[i][j + 1]);
		}

		for (int j = i + i; j < N; j += i)
			add(res[i], -res[j]);
		if (res[i])
			add(ans, res[i] * 1ll * binpow(i, mod - 2) % mod);
	}

	printf("%d\n", ans);
	return 0;
}	

	     


Measured memory_bytes: 182316
#include <algorithm>
#include <iostream>
#include <map>
#include <cstdio>
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
using namespace std;

int main() {
	int N;
	int a[100001];
	int ans = 0;
	
	scanf("%d",&N);
	
	FOR(i,0,N) {scanf("%d", &a[i]);}
	
	map<int, int> mp;
	FOR(i,0,N) {mp[a[i]]++;}
	
	for (auto p: mp) {
		int x = p.first;
		int nx = p.second;
		if (nx < x) {
			ans = ans + nx;
		}else if (nx > x){
			ans = ans + nx - x;
		}
	}
	
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 5120
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

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

Measured memory_bytes: 256
function main()
  
  (N,X) = map(x -> parse(Int,x), split(readline()))
  
  m = zeros(N)
  
  for i in 1:N
    
    m[i] = parse(Int,readline())
    
  end
  
  ans = N
  
  sort!(m)
  
  for i in 1:N
    
    X -= m[i]
    
  end
  
  while X > 0
    
    X -= m[1]
    
    ans += 1
    
  end
  
  if X < 0
    
    ans -= 1
    
  end
  
  println(ans)
  
end

main()

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

const int inf = -1000;
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a /gcd(a, b) *b;
}
int main() {



   int n,x;
   cin>>n>>x;

   int arr[n];

   for(int i=0;i<n;++i)
       cin>>arr[i];

   int dp[n+5];
   dp[0] = 0;
   int ct = 1;
   for(int i=1;i<=n;++i){
    dp[i] = dp[i-1]+arr[i-1];
     if(dp[i]>x)
        break;
     else
        ct++;
   }
      cout<<ct;
    return 0;

      }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n;
  cin >> n;
  int ans = 0;
  int cnt = 0;
  int d1,d2;
  REP(i,n) {
    cin >> d1 >> d2;
    if (d1 == d2) {
      cnt++;
      if (cnt >= 3) {
        ans = 1;
      }
    } else {
      cnt = 0;
    }
  }
  Yes(ans);

  return 0;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000003  
//1000000007
#define P pair<ll, ll>


ll q;

ll powmod(ll a, ll b) {
	a %= MOD;
	ll res = 1;
	while (b > 0) {
		if (b % 2 == 1)res = res * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return res;
}

ll f[5100000];
void cominit() {
	f[0] = 1;
	REP(i, 5100000)f[i + 1] = f[i] * (i + 1) % MOD;
}

ll com(ll n, ll r) {

	return f[n] * powmod(f[r] * f[n - r], MOD - 2) % MOD;
}

ll perm(ll n, ll r) {
	return f[n] * powmod(f[n - r], MOD - 2) % MOD;
}

int main() {
	cominit();
	cin >> q;
	REP(i, q) {
		ll x, d, n;
		cin >> x >> d >> n;
		if (d == 0) {
			cout << powmod(x, n) << endl;
			continue;
		}
		ll now = x * powmod(d, MOD - 2) % MOD;
		if (now / MOD != (now + n - 1) / MOD) {
			cout << 0 << endl;
			continue;
		}
		cout << f[now + n - 1] * powmod(f[now - 1], MOD - 2) % MOD * powmod(d, n) % MOD << endl;
	}
}

Measured memory_bytes: 40704
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	static int mod = (int) 1e9 + 7;

	static ArrayList<Integer>[] g;
	static boolean leaf[];

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		if (n == 1) {
			System.out.println(2);
			return;
		}
		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; i++) {
			int x = scn.nextInt() - 1;
			int y = scn.nextInt() - 1;
			g[x].add(y);
			g[y].add(x);
		}
		int color[] = new int[n];
		for (int i = 0; i < n; i++) {
			color[i] = -1;
		}
		long dp[][] = new long[2][n];
		for (long v[] : dp) {
			Arrays.fill(v, -1);
		}
		
		long ans=0;
		ans=dfs(0, -1, 0, dp, color);
		ans=(ans+dfs(0, -1, 1, dp, color))%mod;
		System.out.println(ans);
	}

	private static long dfs(int sr, int pa, int col, long[][] dp, int[] color) {
		color[sr] = col;
	
		if (dp[col][sr] != -1) {
			return dp[col][sr];
		}
		long res = 1;
		for (int nei : g[sr]) {
			if (nei != pa) {
				if (color[sr] == 0) {
					res = (res* dfs(nei, sr, 1, dp, color))%mod;
				} else {
					res = (res*(dfs(nei, sr, 1, dp, color)+dfs(nei, sr, 0, dp, color))%mod)%mod;
				}
			}
		}
		dp[col][sr] = res%mod;
		return res;
	}

}

Measured memory_bytes: 117748
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    string s[110];
    for(int i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n);
    for(int i=0;i<n;i++)
        cout<<s[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

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

int main(){

    string s;
    cin >> s;
    if(s=="SUN")
        cout << 7 << endl;
    if(s=="MON")
        cout << 6 << endl;
    if(s=="TUE")
        cout << 5 << endl;
    if(s=="WED")
        cout << 4 << endl;
    if(s=="THU")
        cout << 3 << endl;
    if(s=="FRI")
        cout << 2 << endl;
    if(s=="SAT")
        cout << 1 << endl;
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<char> C(4);
  vector<int> N(4);
  for(int i = 0; i < 4; i++){
    cin >> C.at(i);
    N.at(i) = C.at(i) - '0';
  }
  
  for(int tmp = 0; tmp < (1<<3); tmp++){
    bitset<3> a(tmp);
    int sum = N.at(0);
    for(int i = 0; i < 3; i++){
      if(a.test(i)) sum += N.at(i+1);
      else sum -= N.at(i+1);
    }
    if(sum == 7){
      cout << N.at(0);
      for(int i = 0; i < 3; i++){
        if(a.test(i)) cout << '+';
        else cout << '-';
        cout << N.at(i+1);
      }
      break;
    }
  }
  cout << "=7" << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	N := ReadInt()
	factors := Factorization(N)
	ans := 0
	for i := 0; i < len(factors); i++ {
		cnt := factors[i][1]
		j := 0
		for cnt >= j+1 {
			j++
			cnt -= j
		}
		ans += j
	}
	fmt.Println(ans)
}

func Factorization(n int) [][]int {
	res := [][]int{}
	for i := 2; i*i <= n; i++ {
		if n%i != 0 {
			continue
		}
		cnt := 0
		for n%i == 0 {
			n /= i
			cnt++
		}
		res = append(res, []int{i, cnt})
	}
	if n != 1 {
		res = append(res, []int{n, 1})
	}
	return res
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

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

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

    int N, E, T;
    while (cin >> N >> E >> T) {
        --T;
        vector<int> start;
        REP(i, N) {
            int w; cin >> w;
            if (w == 1) start.push_back(i);
        }

        // rules[goal][rule][seed]
        vector<vector<vector<int>>> rules(N);
        REP(i, E) {
            int g, c; cin >> g >> c; --g;
            vector<int> seeds(c);
            REP(j, c) {
                cin >> seeds[j];
                --seeds[j];
            }
            rules[g].push_back(move(seeds));
        }

        static const int inf = 1e8;
        vector<int> width(N, inf);
        for (int g : start) width[g] = 1;
        bool updated;
        do {
            updated = false;
            REP(g, N) {
                for (auto& rule : rules[g]) {
                    vector<int> ws(rule.size());
                    REP(i, rule.size())
                        ws[i] = width[rule[i]];
                    sort(ws.begin(), ws.end(), greater<int>());
                    int v = 0;
                    REP(i, ws.size())
                        v = max(v, ws[i]+i);
                    if (v < width[g]) {
                        width[g] = v;
                        updated = true;
                    }
                }
            }
        } while (updated);

        cout << (width[T] < inf ? width[T] : -1) << '\n';
    }
}

Measured memory_bytes: 3208
#include<stdio.h>
double dp[2][12];
int main(){
	while(1){
	int n;
	scanf("%d",&n);
	if(n==0)return 0;
	int i,j;
	double ans=0.0f;
	for(j=0;j<12;j++)dp[0][j]=0.0f;
	dp[0][1]=1.0f;
	for(i=0;i<n-1;i++){
		for(j=0;j<12;j++)dp[(i+1)%2][j]=0.0f;
		dp[(i+1)%2][1]+=dp[i%2][0];
		for(j=1;j<11;j++){
			double p=1.0f/(1<<j);
			dp[(i+1)%2][j+1]+=dp[i%2][j]*p;
			dp[(i+1)%2][0]+=dp[i%2][j]*(1-p);
			ans+=dp[i%2][j];
		}
	}
	for(j=1;j<12;j++)ans+=dp[(n+1)%2][j];
	printf("%lf\n",ans);
	}
}

Measured memory_bytes: 1060
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
struct comp{
    bool operator()(int a, int b){
        return a>b;
    }
};

///________CODE_STARTS_HERE________\\\

long long n,cnt,s;

int main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    cnt+=2*(n/11);
    n%=11;
    if(n>=6) cnt++,n-=6;
    if(n) cnt++;
    cout << cnt;
}


Measured memory_bytes: 256
num = int(input())

s = set()
for _ in range(num):
    c, k = [int(x) for x in input().split()]
    
    if c == 0:
        s.add(k)
        print(len(s))
    elif c ==1:
        if k in s:
            print(1)
        else:
            print(0)
    else:
        pass
    


Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  ll s=0;
  for(ll i=0;i<N-1;i++) {
    if(S[i]!=S[i+1]) {
s++;
    }
  }

  
  if(s==0) {
cout<<N-1<<endl;
    return 0;
  }
  else if(s==1) {
cout<<N-1<<endl;
    return 0;
  }
  
  
  if(s%2==0) {
if(s<=2*K) {
cout<<N-1<<endl;
  return 0;
}
    else {
cout<<N-1-(s-2*K)<<endl;
    }
  }
  
  else {
if(s+1<=2*K) {
cout<<N-1<<endl;
}
    else {
cout<<N-1-(s-2*K)<<endl;
    }
  }
}
  
  
  
  
  
  
  


Measured memory_bytes: 3752
<?php
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (empty($l)) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a[0];
    $key->B = $a[1];
    $key->C = $a[2];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
  }
}
$a=array();
$a[5]=0;
$a[7]=0;
$a[$key->A]=$a[$key->A]+1;
$a[$key->B]=$a[$key->B]+1;
$a[$key->C]=$a[$key->C]+1;
if (($a[5]==2) && ($a[7]==1)) {
  printf("YES\n");
}
else {
  printf("NO\n");
}


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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		//int res = 0; ;
		//int n = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		int n = int.Parse(Console.ReadLine());

		
		for ( int i = 0; i < str.Length; i+=n ) {

			Console.Write(str[i]);
		}



		Console.WriteLine("");

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}
	
	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}

Measured memory_bytes: 13140
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    int A, B, C, D, E, F; 
    cin >> A >> B >> C >> D >> E >> F;

    // 100A*i + 100B*j + C*k + D*l <= F
    // (C*k+D*l)/(100A*i+100B*j) <= E/100

    int ansWt = 100 * A, ansSg = 0;
    REP(j,31) {
        REP(i,31) {
            int water = 100 * A*i + 100 * B*j;
            if (water > F) continue;

            int SgMax = water/100 * E;
            int KMAX = SgMax / C;
            int LMAX = SgMax / D;
            REP(l,LMAX+1) {
                REP(k,KMAX+1) {
                    int sugar = C * k + D * l;

                    if (water + sugar <= F &&
                        (100+E)*(sugar) <= E*(water+sugar)){

                        // sugar/(water+sugar) > ansSg/(ansWt+ansSg)
                        if (sugar*(ansWt+ansSg) > ansSg*(water+sugar)) {
                            ansWt = water;
                            ansSg = sugar;
                        }
                    }
                }
            }
        }
    }

    cout << ansWt + ansSg << " " << ansSg << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
	static String[] hash = new String[1000005];

	/*
	 * BufferedWriterのテスト
	 */

	public static void main(String[] args) {
		try (
				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));) {

			int n = Integer.parseInt(br.readLine());
			br.lines().limit(n).forEach(line -> {

				String[] str = line.split(" ");
				if (str[0].equals("insert")) {
					insert(str[1]);
				} else {
					String ans = find(str[1]) ? "yes" : "no";
					try {
						bw.write(ans);
						bw.newLine();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}

			});
			bw.flush();

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	// 文字から数値に変換
	static int getChar(char c) {
		switch (c) {
		case 'A':
			return 1;
		case 'C':
			return 2;
		case 'G':
			return 3;
		case 'T':
			return 4;
		default:
			return 0;
		}
	}

	// 文字列から数値に変換してkeyを生成する
	static long getKey(String str) {
		long sum = 0;
		for (int i = 0, p = 1; i < str.length(); i++, p *= 5) {
			sum += p * str.charAt(i);
		}
		return sum;
	}

	// ハッシュ関数
	static int h1(long key) {
		return (int) (key % hash.length);
	}

	static int h2(long key) {
		return (int) (key % hash.length - 1) + 1;
	}

	static boolean find(String str) {
		long key;
		int index;
		key = getKey(str);
		// TODO 配列エラーが起こるかもしれない
		for (int i = 0;; i++) {
			index = (h1(key) + i * h2(key)) % hash.length;
			if (hash[index] == null) {
				return false;
			} else if (hash[index].equals(str)) {
				return true;
			}
		}

	}

	static boolean insert(String str) {
		long key;
		int index;
		key = getKey(str);
		// TODO 配列エラーが起こるかもしれない
		for (int i = 0;; i++) {
			index = (h1(key) + i * h2(key)) % hash.length;
			// TODO 重複した文字列を格納して良いのか？
			if (hash[index] == null) {
				hash[index] = str;
				return true;
			} else if (hash[index].equals(str)) {
				return false;
			}
		}
	}

}



Measured memory_bytes: 192444
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[32];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int w, n;
    cin >> w >> n;
    for (int i = 1; i <= 30; ++i)
        arr[i] = i;

    for (int i = 1; i <= n; ++i)
    {
        int a, b;
        char c;
        cin >> a >> c >> b;
        //cout << a << " " << b << endl;
        swap(arr[a], arr[b]);
    }

    for (int i = 1; i <= w; ++i)
    {
        cout << arr[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int n,m;
ll x[100010],y[100010];
void solve(){
  ll xsum=0,ysum=0;
  rep(i,n/2){
    xsum=(xsum+((n-1-i*2)*x[n-1-i])%MOD)%MOD;
  }
  rep(i,n/2){
    xsum=(xsum-((n-1-i*2)*x[i])%MOD)%MOD;
  }
  rep(i,m/2){
    ysum=(ysum+((m-1-i*2)*y[m-1-i])%MOD)%MOD;
  }
  rep(i,m/2){
    ysum=(ysum-((m-1-i*2)*y[i])%MOD)%MOD;
  }
  ll res=((xsum*ysum)%MOD+MOD)%MOD;
  prin(res);
}
int main(){
  cin>>n>>m;
  rep(i,n) cin>>x[i];
  rep(i,m) cin>>y[i];
  solve();
  return 0;
}


Measured memory_bytes: 1792
def create(month, days):
    day = 1
    while day <= days:
        calendar[(month, day)] = week[0]
        week.append(week[0])
        del week[0]
        day += 1
        
week = ['Thursday','Friday','Saturday','Sunday','Monday','Tuesday','Wednesday']
calendar = {}
for i in range(12):
    month = i+1
    if month == 2:
        create(month, 29)
    elif month in (4,6,9,11):
        create(month, 30)
    else:
        create(month, 31)
    
while True:
        month, day = map(int, raw_input().split())
        if month == 0 and day == 0: break
        print calendar[(month, day)]

Measured memory_bytes: 4292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <math.h>

using namespace std;

typedef long long ll;

namespace Knap22
{
	ll N, W;
	ll ws[101], vs[101];
	//i個目までで、価値vのときの、最小の重さ
	vector<vector<ll>> dp;
	void solve()
	{
		cin >> N >> W;
		ws[0] = 0; vs[0] = 0;
		for (int i = 1; i <= N; ++i) {
			cin >> ws[i] >> vs[i];
		}

		dp.resize(N + 1, vector<ll>(N * 1000 + 1, 1LL << 60));

		for (int i = 0; i <= N; ++i)
			dp.at(i).at(0) = 0;

		int maxV = 0;
		int maxSumV = N * 1000 + 1;
		for (int i = 0; i < N; ++i) {
			for (int v = 0; v < maxSumV; ++v) {
				//軽い方をメモ
				//選べる
				if (v - vs[i+1] >= 0) {
					dp.at(i + 1).at(v) = min(dp.at(i).at(v), dp.at(i).at(v - vs[i+1]) + ws[i+1]);
				}
				else {
					//選ばない
					dp.at(i + 1).at(v) = dp.at(i).at(v);
				}

				if (dp.at(i + 1).at(v) <= W) {
					maxV = max(v, maxV);
				}
			}
		}
		cout << maxV << endl;
	}
}

int main()
{
	Knap22::solve();
}


Measured memory_bytes: 82876
N,X,Y=map(int,input().split())
b=[0]*(N)
for i in range(N):
  for j in range(i+1,N):
    p=max(X-1-i,1+i-X)
    q=max(Y-1-j,1+j-Y)
    b[min(j-i,p+1+q)]+=1
for i in range(1,N):
  print(b[i])

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

int main() {
  string S, T;
  cin >> S >> T;
  int count = 0;
  rep(i, 3) count += (S[i] == T[i]);
  cout << count << endl;
  return 0;
}

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

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

  set<int> A;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(A.find(a) == A.end()){
      A.insert(a);
    }else{
      A.erase(a);
    }
  }
  cout << A.size() << endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
using namespace std;
 
static const int MAX = 200000;

int main() {
    int R[MAX], n;

    cin >> n;
    for (int i =0; i<n;i++)cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];

    for ( int i = 1; i<n ; i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;

}


Measured memory_bytes: 3892
/* BABA JAGAAAAAA  */  

#include<bits/stdc++.h>
#define pb push_back
#define un unordered_map
#define us unordered_set
#define ll long long
#define fast ios:: sync_with_stdio(false);cin.tie(NULL)
#define l long 
using namespace std;
const int  mod= 1e9+7;
const int inf=1e9+3;
 int main()
 {
     fast;  
    // 1st//
    int d,s,t; 
     cin>>d>>t>>s;
     double t1= ((double)d/(double)(s));
    //   cout<<t1<<endl;
     double t2= double(t);
      if(t1<=t2)
      cout<<"Yes";
      else 
       cout<<"No";
        cout<<endl;
       return 0;
     
 }
  

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

#define ten(n) ((int)1e##n)
#define uni(x) x.erase(unique(all(x)),x.end())
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

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

int main() {
  ll n;cin>>n;
  vi x;
  ll t;
  rep(i,n){
    cin>>t;
    x.pb(t-i-1);
  }

  sort(all(x));

  ll res=0;
  rep(i,n){
    res+=abs(x[i] - x[n/2]);
  }

  cout << res << endl;

  return 0;
}


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

int main(void){
  int n;
  int b,f,r,v;
  int bi,fi,ri;
  int i;
  int R[4][3][10];

  memset(R, 0, sizeof(R));
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    R[b-1][f-1][r-1] += v;
  }

  for (bi = 0; bi < 4; bi++) {
    for (fi = 0; fi < 3; fi++) {
      for (ri = 0; ri < 10; ri++) {
        printf(" %d", R[bi][fi][ri]);
      }
      printf("\n");
    }
    if (bi != 3) printf("####################\n");
  }



  return (0);
}



Measured memory_bytes: 2056
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll get(ll x, ll y)
    {
    ll s = 0;
    while(x)
        {
        s += x%y;
        x/=y;
    }
    return s;
}
int main()
    {
    ll n,s;
    scanf("%lld%lld",&n,&s);
    if(n==1)
        {
        if(s==1)return printf("2\n")*0;
        return printf("-1")*0;
    }
    set<ll> pos;
    ll x;
    pos.insert(n+1);
    if(n!=1)
    pos.insert(n);
    if(n > s)
        {
        ll dif = n-s;
        
        for(x=2;x*x<=dif;x++)if(dif%x==0)
            {
            pos.insert(x);
            pos.insert(x+1);
            if(x*x!=dif){
                pos.insert(dif/x);
                pos.insert(dif/x+1);
            }
        }
        if(dif!=1){
        pos.insert(dif);
            pos.insert(dif+1);
        }
    }
    for(x=2;x*x<=n;x++)pos.insert(x);
    set<ll>::iterator I;
    for(I=pos.begin();I!=pos.end();I++){
     //   printf("checking for %lld\n",*I);
        if(get(n,*I)==s)return printf("%lld\n",*I)*0;
   
}
        return printf("-1\n")*0;
  //  if(s==1)return printf("%lld\n",n)*0;
    
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int a; cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    else return gcd(b,a%b);
}
vector<ll>A(200010);
vector<vector<ll> >dp(200010,vector<ll>(3,-inf*inf));
ll solve1(ll a,ll b){
    if(dp[a][b]!=-inf*inf){
        return dp[a][b];
    }
    ll res=A[a];
    if(b==0){
        res+=max(solve1(a+2,b),max(solve1(a+3,b+1),solve1(a+4,b+2)));
    }else if(b==1){
        res+=max(solve1(a+2,b),solve1(a+3,b+1));
    }else{
        res+=solve1(a+2,b);
    }
    dp[a][b]=res;
    return res;
}
ll solve2(ll a,ll b){
    if(dp[a][b]!=-inf*inf){
        return dp[a][b];
    }
    ll res=A[a];
    if(b==0){
        res+=max(solve2(a+3,b+1),solve2(a+2,b));
    }else if(b==1){
        res+=solve2(a+2,b);
    }
    dp[a][b]=res;
    return res;
}

signed main(){
    ll n;cin>>n;
    rep(i,n)cin>>A[i];
    if(n%2==0){
        ll ans;
        dp[n-1][1]=A[n-1];
        dp[n-2][0]=A[n-2];
        ans=max(solve2(0,0),solve2(1,1));
        cout<<ans<<endl;
    }else{
        ll ans;
        dp[n-1][2]=A[n-1];
        dp[n-2][1]=A[n-2];
        dp[n-3][0]=A[n-3];
        ans=max(solve1(0,0),max(solve1(1,1),solve1(2,2)));
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 25084
module Main where

iota :: [Int] -> [Int]
iota [x, y] = [x..y]

main :: IO ()
main = do
  n <- getLine >>= \x -> return (read x::Int)
  l_r <- sequence (take n (repeat (getLine >>=
                                   \line -> return $ iota (map read (words line)))))
  print $ length $ concat l_r


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

int main(){
    int n;
    vector<int64_t> xs, ys, idx;
    cin >> n;
    xs.reserve(n);
    ys.reserve(n);
    idx.resize(n);

    for(int i=0;i<n;++i){
        int x, y;
        cin >> x >> y;
        xs.emplace_back(min(x, y));
        ys.emplace_back(max(x, y));
    }
    
    int64_t rs = INT64_MAX, rb = 0, bs = INT64_MAX, bb = 0;
    int64_t ans;
    for(int i=0;i<n;++i){
        rs = min(rs, xs[i]);
        rb = max(rb, xs[i]);
        bs = min(bs, ys[i]);
        bb = max(bb, ys[i]);
    }
    ans = (rb-rs) * (bb-bs);

    iota(idx.begin(), idx.end(), 0);
    sort(idx.begin(), idx.end(), [&](auto x, auto y){ return make_pair(ys[x], xs[x]) > make_pair(ys[y], xs[y]); });

    int64_t cs = ys[idx[n-1]], cb = ys[idx[0]], xb = 0;
    int64_t rr = ys[idx[0]] - *min_element(xs.begin(), xs.end());
    
    for(int i=0;i+1<n;++i){
        xb = max(xb, xs[idx[i]]);
        cb = max(xb, ys[idx[i+1]]);
        cs = min(cs, xs[idx[i]]);
        ans = min(ans, rr * (cb-cs));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int a[m];
  int pt[n];
  for(int i = 0; n > i; i++)pt[i] = 0;
  for(int i = 0; m > i; i++)cin>>a[i];
  for(int i = 0; m > i; i++){
    int sm = 0;
    for(int j = 0; n > j; j++){
      int t;cin>>t;
      if(t == a[i])pt[j]++;
      else sm++;
    }
    pt[a[i]-1]+=sm;
  }
  for(int i = 0; n > i; i++){
    cout << pt[i] << endl;
  }
}


Measured memory_bytes: 3100
s = input()
ans = 0

def dfs(index, ret):
    if index == len(s) - 1:
        ret += s[index]
        ret2 = map(int, ret.split("+"))
        global ans
        ans += sum(ret2)
        return
    dfs(index + 1, ret + s[index]) or dfs(index + 1, ret + s[index] + "+")

dfs(0, "")
print(ans)


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    
    cout << st[0] << st[1] << st[2] << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 2e5 + 5 ;
int n ;
ll d , a ;
ll c[maxn] ;
struct node
{
	ll x ;
	ll h ;
	bool operator <(const node &s) const
	{
		return x < s.x ;
	}
} b[maxn] ;
ll max1[maxn << 2] ;
ll add[maxn << 2] ;
int ls(int x)
{
    return x << 1 ;
}
int rs(int x)
{
    return x << 1 | 1 ;
}
void push_up(int p)
{
    max1[p] = max(max1[ls(p)] , max1[rs(p)]) ;
}
void f(int id , int l , int r , int k)
{
    add[id] += k ;
    max1[id] += k ;
}
void push_down(int id , int l , int r)
{
    int mid = (l + r) >> 1 ;
    f(ls(id) , l , mid , add[id]) ;
    f(rs(id) , mid + 1 , r , add[id]) ;
    add[id] = 0 ;
}
void update(int id , int l , int r , int x , int y , int k)
{
	if(x > y)  return ;
    if(x <= l && r <= y)
    {
    	f(id , l , r , k) ; 
        return ;
    }
    push_down(id , l , r) ;
    int mid = (l + r) >> 1 ;
    if(x <= mid) update(ls(id) , l , mid , x , y , k) ;
    if(y > mid)  update(rs(id) , mid + 1 , r , x , y , k) ;
    push_up(id) ;
}
ll query(int id , int l , int r , int x , int y)
{
    ll ans = 0 ;
    if(x <= l && r <= y)
      return max1[id] ;
    int mid = (l + r) >> 1 ;
    push_down(id , l , r) ;
    if(x <= mid) ans = max(ans , query(ls(id) , l , mid , x , y)) ;
    if(y > mid) ans = max(ans , query(rs(id) , mid + 1 , r , x , y)) ;
    return ans ;
}
int main()
{
	ll ans = 0 ;
	scanf("%d%lld%lld" , &n , &d , &a) ;
	for(int i = 1 ; i <= n ; i ++)  scanf("%lld%lld" , &b[i].x , &b[i].h) ;
	sort(b + 1 , b + n + 1) ;
	for(int i = 1 ; i <= n ; i ++)  c[i] = b[i].x ;
	for(int i = 1 ; i <= n ; i ++)  update(1 , 1 , n , i , i , b[i].h) ;
	for(int i = 1 ; i <= n ; i ++)
	{
		ll x = query(1 , 1 , n , i , i) ;
		if(x <= 0)  continue ;
		ll num = x / a + (x % a != 0) ;
		int l = i ;
		int r = upper_bound(c + 1 , c + n + 1 , b[i].x + 2 * d) - c ;
		r -- ;
		update(1 , 1 , n , l , r , -1ll * num * a) ;
		ans += num ;
	}
	printf("%lld\n" , ans) ;
	return 0 ;
}


Measured memory_bytes: 17408
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
char a[50000];
int main()
{
  scanf("%s",a);
  for(int i=0;a[i]!='\0';i++)
  {
     if(a[i]!=',')
        printf("%c",a[i]);
     else
        printf(" ");
  }
  printf("\n");
}


Measured memory_bytes: 256