akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF 99999999
#define LINF 9999999999999999
#define SINF "%"
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll long long
#define ull unsigned ll
#define uchar unsigned char
#define sint short int
#define usint unsigned sint
#define xsize(a) sizeof(a)/1024/1024
#define fr(aaaaa,bbbbb) for(aaaaa = 1;aaaaa <= bbbbb;aaaaa++)
#define frr(aaaaa,bbbbb,ccccc) for(aaaaa = ccccc;aaaaa <= bbbbb;aaaaa++)
using namespace std;
#define MAXN 100100
 
int n;
vector<int> xiaomie[MAXN];
int mem[MAXN];

void dp(int pos){
	vector<int> ls;
	for(uint i = 0;i < xiaomie[pos].size();i++){
		dp(xiaomie[pos][i]);
		ls.pb(mem[xiaomie[pos][i]]);
	}
	sort(ls.begin(),ls.end());
	int l = ls.size();
	for(int i = 0;i < l;i++)
		mem[pos] = max(  mem[pos]  ,  ls[i] + l - i  );
}

int main(){
	//freopen("A.txt","r",stdin);
	ms(mem);
	
	scanf("%d",&n);
	for(int i = 2;i <= n;i++){
		int x;
		scanf("%d",&x);
		xiaomie[x].pb(i);
	}
	
	dp(1);
	
	printf("%d\n",mem[1]);
	
	return 0;
}

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

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

    int ans = 0;
    for(int karen = a; karen <= b; karen++){
        if(karen / 10000 != karen % 10){
            continue;
        }
        if(karen / 1000 % 10 != karen % 100 / 10){
            continue;
        }
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int v[n],c[n],sum=0;
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<n;i++){
        if(v[i]>c[i]) sum+=v[i]-c[i];
    }
    cout<<sum;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> line(5);
    for(int i=0;i<line.size();i++){
        cin >> line.at(i);
        if (line.at(i)==0){
            cout << i+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 3468
from itertools import product

n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 10 ** 20
for bit in product([0, 1], repeat=n):
    if sum(bit) != k or bit[0] == 0:
        continue
    cnt = 0
    tmp = a[0]
    for i, v in enumerate(bit):
        if v == 1:
            if i != 0:
                cnt += max(tmp + 1 - a[i], 0)
                tmp = max(tmp + 1, a[i])
        else:
            tmp = max(tmp, a[i])
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3064
s = int(input())
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1
a = s
dp = [a]
li = [0 for i in range(10**6)]
li[a] +=1
for i in range(1,10**6):
    a = f(dp[i-1])
    dp.append(a)
    li[a]+=1
    if li[a]>=2:
        break
print(len(dp))

Measured memory_bytes: 10904
N = (int)(input())
A = list(map(int, input().split()))

check = True
for i in A:
    if(i % 2 == 0):
        if(i % 3 != 0 and i % 5 != 0):
            check = False

if(check):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
N = int(input())
S = input()

d = {"R": 0, "G": 1, "B": 2}
ctr = [[0] * 3 for _ in range(N + 1)]
for i in range(N):
    ctr[i + 1][d[S[i]]] += 1
    for j in range(3):
        ctr[i + 1][j] += ctr[i][j]


ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if S[i] != S[j]:
            c = (set("RGB") - set([S[i], S[j]])).pop()
            cnt = ctr[-1][d[c]] - ctr[j + 1][d[c]]

            k = 2 * (j + 1) - (i + 1) - 1
            if j < k < N and c == S[k]:
                cnt -= 1

            ans += max(0, cnt)

print(ans)


Measured memory_bytes: 69276
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  char b;
  rep(i, 0, 3){
    char c;
    cin >> c;
    if(i == 0){
      b = c;
    }
    if(i == 2){
      if(b == c){
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=55;
const int MAXM=5005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())
struct edge {
    int v,a,b;
    edge (int _v=0, int _a=0, int _b=0): v(_v), a(_a), b(_b) {}
};


int N,M,S,C[MAXN],D[MAXN],dist[MAXN];
vector<edge> adjList[MAXN];
int dp[MAXN][MAXM]; //min time to reach i with j silver

void go(){
	FOR(i,1,N){
		FOR(j,0,MAXM-1){
			if (j>=C[i]) dp[i][j] = min(dp[i][j], dp[i][j-C[i]] + D[i]);
			for (auto k:adjList[i]){
				if (j-k.a >= 0) dp[k.v][j-k.a] = min(dp[k.v][j-k.a], dp[i][j] + k.b);
			}
		}
	}	
}

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>M>>S;
	FOR(i,1,M){
		int u,v,a,b;cin>>u>>v>>a>>b;
		adjList[u].pb(edge(v,a,b));
		adjList[v].pb(edge(u,a,b));
	}
	FOR(i,1,N) cin>>C[i]>>D[i];
	FOR(i,1,N) FOR(j,0,MAXM-1) dp[i][j]=1e18;
	dp[1][min(S, 5000LL)]=0;
	FOR(tt,1,1000){
		go();
	}
	
	FOR(i,2,N){
		cout << *min_element(dp[i], dp[i]+MAXM)<<"\n";
	}
}


Measured memory_bytes: 5584
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
#include <array>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

double distance(int x1, int x2, int y1, int y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1- y2) * (y1 - y2));
}

int main(int argc, const char * argv[]) {
    // source code
    int N = 0;
    cin >> N; 
    vector<array<int, 2>> p(N);
    int a, b;
    rep (i, N) {
        array<int, 2> t;
        cin >> t[0] >> t[1];
        p[i] = t;
    }
    std::sort(p.begin(), p.end());
    double total = 0;
    do {
        for (int i = 1; i< N; ++i) {
           total += distance(p[i-1][0], p[i][0] , p[i-1][1], p[i][1]); 
        }
    } while (next_permutation(p.begin(), p.end()));
    int num= 1;
    repd (i, 1, N+1) num *= i;
    cout << setprecision(10) <<total/ num;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;

    if ((a*b) % 2 == 0) {
        cout << "No";
    }
    
    else {
        cout << "Yes";
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,LL>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define SE second
#define PI acos(-1.00)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define edl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v,w,zz;
map<LL,LL>ww,u,st;
V<LL>uuu[500005];
V<pair<LL,LL> >uu;
map<pair<LL,LL>,LL> vo,vu,uh,ve;
set<LL>uo;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    char ch;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    cin>>tt;
    while(tt--)
    {
    cin>>a;
    k=0;
    for(i=0;a[i];i++)
    {
       if(a[i]=='?')
       {
           if(i>0 && a[i-1]=='P')
           {
               a[i]='D';
           }
           else if(i<a.SZ-1 && (a[i+1]=='D' || a[i+1]=='?'))
           {
               a[i]='P';
           }
           else
           {
               a[i]='D';
           }

       }
    }
       cout<<a<<endl;
    }
    return 0;
}


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

/*
dp[i][j]=先頭i文字として考えられる数値のうち、13で割った余りがjであるものの数　とする。
この時、例えばsが.........1であるなら、この数を13で割った余りが、
(m*10+1)%13となる個数：dp[i-1][m*10+1] (を10^9+7で割った値)となる。
すなわち、各m=0~12について、
dp[i][(m*10+s[i])%13]=dp[i-1][m]*10+s[i]とすればいい。
s[i]が？の時は、各k=0~9について、各m=0~9で
dp[i][(m+10+1)%13]=dp[i-1][m]*10+kとする。

例：s=123
dp[0][_]=0
dp[1][0]=
*/

void solve(){
    int MOD = 1e9+7;
    string s;
    cin >> s;
    uint64_t res = 0;
    int n = s.size();
    uint64_t dp[n+10][13];
    rep(i,n+1){
        rep(j,13){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=1; i<=n; i++){
        if(s[i-1]!='?'){
            int number = s[i-1] - '0';
            rep(m,13){
                dp[i][(m*10+number)%13] = (dp[i-1][m]) % MOD;
                //cout << "dp[" << i << "][" << (m*10+number)%13 << "]=" << dp[i-1][m]+1 << endl;
            }
        }
        else{
            rep(k,10){
                rep(j,13){
                    dp[i][(j*10+k)%13] = (dp[i][(j*10+k)%13] + dp[i-1][j]) % MOD;
                }
            }
        }
    }
    res = dp[n][5];
    cout << res << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 10624
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    sqrt_intN = int(N ** 0.5 + 1)
    l = [1 if i % 2 else 2 for i in range(N+1)]
    if N == 1:
        print(1)
        return
    if N == 2:
        print(5)
        return
    ans = 5
    for i in range(3, N+1):
        ans += (l[i] + 1) * i
        t = i * 2
        while t <= N:
            l[t] += 1
            t += i
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 219372
import java.util.Arrays;
import java.util.Scanner;

//Convenient Location
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[][] c = new int[10][10];
			for(int[]a:c)Arrays.fill(a, 1<<25);
			for(int i=0;i<10;i++)c[i][i]=0;
			int max = 0;
			while(n--!=0){
				int s = sc.nextInt();
				int t = sc.nextInt();
				int d = sc.nextInt();
				c[s][t]=c[t][s]=Math.min(c[s][t], d);
				max = Math.max(max, Math.max(s, t));
			}
			for(int k=0;k<10;k++)for(int i=0;i<10;i++)for(int j=0;j<10;j++)c[i][j]=Math.min(c[i][j], c[i][k]+c[k][j]);
			int k = 0;
			int w = 1<<25;
			for(int i=0;i<10;i++){
				int s = 0;
				for(int j=0;j<=max;j++)s+=c[i][j];
				if(s<w){
					k = i;
					w = s;
				}
			}
			System.out.println(k+" "+w);
		}
	}
}

Measured memory_bytes: 12000
X, Y, A, B, C = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
R = [int(i) for i in input().split()]

P = sorted(P, reverse=True)
Q = sorted(Q, reverse=True)
R = sorted(R, reverse=True)

 
A= P[:X] + Q[:Y] + R
A = sorted(A, reverse=True)
print(sum(A[:X+Y]))


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;

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

    int ans = 0;
    for(int i = 0; i < 1000; i++){
        string p;
        if(i < 10) p = "00" + to_string(i);
        else if(i < 100) p = "0" + to_string(i);
        else p = to_string(i);
        int k = 0;
        for(int j = 0; j < n; j++){
            if(p[k] == s[j]) k++;
            if(k == 3) break;
        }
        if(k == 3) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

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

    LL i,j,n,ans=0;
    cin >> n;
    LL a[n+2];
    for(i=1;i<=n;i++)cin >> a[i];
    for(i=1;i<n;i++)
    {
        for(j=i+1;j<=n;j++)ans+=(a[i]*a[j]);
    }
    cout << ans;
    return 0;
}


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

int c[26],n,m;
char s[105];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%s",s);
		for(int j=0;j<m;j++)c[s[j]-'a']++;
	}
	if(n%2==0&&m%2==0){
		for(int i=0;i<26;i++)if(c[i]%4){
			printf("No\n");
			return 0;
		}
		printf("Yes\n");return 0;
	}
	if(n%2==1&&m%2==1){
		int t=0;
		for(int i=0;i<26;i++)if(c[i]%2)t++;
		if(t>1){
			printf("No\n");return 0;
		}
		for(int i=0;i<26;i++)if(c[i]%2)c[i]--;
		t=0;
		for(int i=0;i<26;i++)if(c[i]%4==2)t++;
		if(t>n/2+m/2){
			printf("No\n");return 0;
		}
		printf("Yes\n");return 0;
	}
	int r;
	if(n&1)r=m/2;else r=n/2;
	for(int i=0;i<26;i++)if(c[i]&1){
		printf("No\n");return 0;
	}
	for(int i=0;i<26;i++)if(c[i]%4==2)r--;
	if(r<0){
		printf("No\n");return 0;
	}
	printf("Yes\n");
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  int x[n][n], y[n][n];
  int a[n];
  
  rep(i, n) {
    cin >> a[i];
    rep(j, a[i]) {
      cin >> x[i][j] >> y[i][j];
      --x[i][j];
    }
  }

  int ans = 0;
  rep(i, 1<<n) {
    vector<bool> v(n);
    vector<int> tf(n, -1);
    rep(j, n) {
      v[j] = (i>>j&1);
    }
    
    bool flag = 1;
    rep(j, n) {
      if(v[j]) {
	if(tf[j] == 0) {
	  flag = 0;
	  break;
	}
	
	tf[j] = 1;
	rep(k, a[j]) {
	  if(tf[x[j][k]] == -1) {
	      tf[x[j][k]] = y[j][k];
	    } else if(tf[x[j][k]] != y[j][k]) {
	      flag = 0;
	      break;
	  }
	}
      } else {
	if(tf[j] == 1) {
	  flag = 0;
	  break;
	} else tf[j] = 0;
      }
    }
    int cnt = 0;
    if(flag) rep(k, n) cnt += tf[k];
    ans = max(ans, cnt*flag);      
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N, T; cin >> N >> T;
	vector<int> t(N);

	REP(i,N) cin >> t[i];


	int ans = 0;
	REP(i,N-1){
		ans += min(T, t[i+1] - t[i]);
	}
	ans += T;
		
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 1024
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
S = [int(x) - ord('A') for x in readline().rstrip()]
S = [(x + N)%26 for x in S]

ans = ''.join(chr(x+ord('A')) for x in S)
print(ans)


Measured memory_bytes: 3188
N,M=map(int,input().split())
S=input()
cur=N
can_points=[N]
while cur>0:
  point=cur
  for i in range(min(M,cur)):
    if int(S[cur-1-i])==0:
      point=cur-1-i
  if point==cur:
    break
  else:
    cur=point
    can_points.append(point)
if cur>0:
    print(-1)
else:
    l=[]
    s=len(can_points)
    for i in range(s-1):
        l.append(str(can_points[s-2-i]-can_points[s-1-i]))
        l.append(' ')
    print(''.join(l))

Measured memory_bytes: 58204
#include <iostream>
#include <vector>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	vector<int> dp(3);
	for(int day=0; day<n; ++day) {
		vector<int> new_dp(3,0);
		vector<int> c(3);
		for(int i=0; i<3; ++i)
			cin >> c[i];

		for(int i=0; i<3; ++i) {
			for(int j=0; j<3; ++j) {
				if(i!=j) {
					new_dp[j] = max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout << max(dp[0],max(dp[1],dp[2])) << "\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>

using namespace std;

void solve(){
    int n;
    string s, t, result;
    cin >> n >> s >> t;
    result = "";
    for(int i = 0; i < n; i++){
        result += s.substr(i,1);
        result += t.substr(i, 1);
    }
    cout << result << endl;
}

int main() {
    solve();
    return 0;
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;




int main() {
	
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
	else cout << "No" << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
typedef long long ll;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    ll N,K;
    cin >> N >> K;
    double ans = 0;
    double res = 0;
    for(ll i = 1; i < N + 1; i++)
    {
        double j = 0;
        int me = i;
        double tmp = 1;
        while(me < K)
        {
            me *= 2;
            tmp /= 2.0;
            j++;
        }
        res += tmp;
    }
    ans = res/N;
   cout <<  setprecision(10) <<ans << endl;

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(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) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) 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> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int L;
    cin >> L;
    
    vi bits;
    while (L > 1) {
        bits.pb(L % 2);
        L >>= 1;
    }
    reverse(ALL(bits));

    vector<vector<pii>> g(20);
    int w = 1;
    int M = 0;
    REP(i, SZ(bits)) {
        g[i].pb({i + 1, 0});
        g[i].pb({i + 1, w});
        M += 2;
        w <<= 1;
        if (bits[i]) {
            g[0].pb({i+1, w});
            w++;
            M++;
        }
    }

    cout << SZ(bits) + 1 << " " << M << endl;
    REP(i, SZ(bits) + 1) {
        FORE(e, g[i]) {
            cout << i + 1 << " " << e.first + 1 << " " << e.second << endl;
        }
    }
    return (0^_^0);
}



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

int main() {
  int N, K, sum=0;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for (int i = 0; i < K; i++) {
    sum += vec.at(i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	double EPS = 10.e-08;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			boolean flg = false;
			for(int i = 1; i < 10; i++){
				for(int j = 1; j < 10; j++){
					if(n == i * j){
						flg = true;
						break;
					}
				}
				if(flg){
					break;
				}
			}
			System.out.println(flg ? "Yes" : "No");
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const int INF = 1e9 + 7;
int h[MAXN];
int dp[MAXN];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N; cin >> N;
	for (int i = 0; i < N; ++i) cin >> h[i];
	fill(dp, dp + MAXN, INF);
	dp[0] = 0;
	for (int i = 0; i < N - 1; ++i) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
		if(i < N-2	) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
	}
	cout << dp[N - 1] << '\n';
	return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, aaa=0, bbb=0;
    cin >> a >> b;

    if(a<b){
        for(int i=0; i<b; i++){
            aaa+=a*pow(10,i);
        }
        cout<<aaa<<endl;
    }

    else if(a>=b){
        for(int i=0; i<a; i++){
            bbb+=b*pow(10,i);
        }
        cout<<bbb<<endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3

N = int(input())
A = sorted(list(map(int, input().split())))[::-1]

h = A[0]/2
r = 10**9
v = 0
for a in A[1:]:
    if r > abs(a-h):
        r = abs(a-h)
        v = a

print(str(A[0]) + ' ' + str(v))


Measured memory_bytes: 14428
#include<bits/stdc++.h>
using namespace std ;
int main()
{
int n ;
cin>>n ;
int a[n] ;
int sum = 0 ;
for(int i=0;i<n;i++) cin>>a[i], sum+=a[i] ;
if(!(sum%10))
{
sort(a,a+n) ;
bool found = false ;
int num ;
for(int i=0;i<n;i++)
{
if(a[i]%10) {found = true;  num = a[i] ; break ; }
}
if(found) sum -= num ;
else { cout<<0; return 0 ; }
}
cout<<sum ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 1e18
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
ll ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    vector<int> a(n), index(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) index[a[i]-1] = i;
    set<int> v;
    v.insert(-1); v.insert(n);
    rep(i, 0, n) {
        auto itr = v.lower_bound(index[i]);
        ll right = (*itr) - index[i];
        itr--;
        ll left = index[i] - (*itr);
        ans += (a[index[i]] * left * right);
        v.insert(index[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11264
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] list = new int[N];
		for (int i = 0; i < N; i++) {
			list[i] = sc.nextInt();
		}
		int sum = 0;

		for (int i = 0; i < N; i++) {
			int eat = 1;
			int cnt = 1;
			while (eat <= D) {
				sum++;
				eat = 1 + cnt * list[i];
				cnt++;
			}
		}
		System.out.println(sum + X);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int main()
{
	int n, a[510][510], s[510]={}, t[510]={};
	char x;
	cin >> n;
	rep(i, n) rep(j, n)
	{
		cin >> x;
		if(x=='.') a[i][j]=0;
		else a[i][j]=1, s[i]++, t[j]++;
	}
	int tmp=0;
	reps(i, n-1)
	{
		if(s[i]>s[tmp]) tmp=i;
		else if(s[i]==s[tmp]) if(t[i]!=0) tmp=i;
	}
	if(s[tmp]==0) cout << "-1" << endl;
	else
	{
		int kuro=0;
		rep(j, n) if(t[j]!=n) kuro++;
		int ans=0;
		ans+=kuro;
		ans+=n-s[tmp];
		if(t[tmp]==0) ans++;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
<?php
$array = explode(" ", trim(fgets(STDIN)));
$a = $array[0];
$b = $array[1];
$ans = 'Zero';
if($a > 0) $ans = 'Positive';
if($b < 0) {
  if(($b - $a + 1) % 2 == 1) {
    $ans = 'Negative';
  } else {
    $ans = 'Positive';
  }
}
print($ans);
?>

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

all_sunuke = list(range(1, N+1))

have_sunuke = []

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    have_sunuke += A

print(len(list(set(all_sunuke)-set(have_sunuke))))

Measured memory_bytes: 9204
data Direction = N | V | H deriving Eq

main = do
  getLine
  s1 <- getLine
  s2 <- getLine
  print (domino N 1 s1 s2 `mod` (10^9+7))

domino _ acc "" "" = acc
domino N acc [_] [_] = acc*3
domino V acc [_] [_] = acc*2
domino H acc [_] [_] = acc
domino N acc (d1:e1:s1) (d2:e2:s2)
 | d1 == d2  = domino V (acc*3) (e1:s1) (e2:s2)
 | otherwise = domino H (acc*6) s1 s2
domino V acc (d1:e1:s1) (d2:e2:s2)
 | d1 == d2  = domino V (acc*2) (e1:s1) (e2:s2)
 | otherwise = domino H (acc*2) s1 s2
domino H acc (d1:e1:s1) (d2:e2:s2)
 | d1 == d2  = domino V acc (e1:s1) (e2:s2)
 | otherwise = domino H (acc*3) s1 s2

Measured memory_bytes: 508
#include <iostream>
#include <iomanip>
#include <fstream>

#include <cmath>
#include <string>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int dp[3005][3005];
int back[3005][3005];

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

	string s, t;	
	cin >> s >> t;
	for (int i = 0; i < 3005; i++) {
		dp[i][0] = 0;
		dp[0][i] = 0;
	}

	for (int i = 1; i < s.size()+1; i++) {
		for (int j = 1; j < t.size()+1; j++) {
			if (s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				back[i][j] = 0;
			}
			else if(dp[i-1][j] >= dp[i][j-1]) {
				dp[i][j] = dp[i-1][j];
				back[i][j] = 1;
			}
			else {
				dp[i][j] = dp[i][j-1];
				back[i][j] = 2;
			}
		}
	}

	string ans = "";
	int i, j;
	i = s.size();
	j = t.size();
	while((i > 0) && (j > 0)) {
		if (back[i][j] == 0) {
			ans += s[i-1];
			--i;
			--j;
		}
		else if (back[i][j] == 1) --i;
		else --j;
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>
int main(){
	int h1,h2,m1,m2,s1,s2,h,m,s;
	for(;scanf("%d %d %d %d %d %d",&h1,&m1,&s1,&h2,&m2,&s2)!=EOF;){
		if(s2-s1<0){
			s=60+(s2-s1);
			m2--;
		}
		else s=s2-s1;
		if(m2-m1<0){
			m=60+(m2-m1);
			h2--;
		}
		else m=m2-m1;
		h=h2-h1;
		printf("%d %d %d\n",h,m,s);
	}
	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
X = map(int, input().split())

if N > M:
    print(0)
    sys.exit()
sorted_x = sorted(list(X))

sub_X = [abs(sorted_x[i+1] - sorted_x[i]) for i in range(0,M-1)]

sorted_sub_x = sorted(sub_X,reverse=True)

print( sorted_x[M-1] -sorted_x[0] - sum([ sorted_sub_x[i] for i in range(0,N-1)]) )

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

#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1000;

int N;
vector<pii> nxt[MAX_N+1][MAX_N+1];
int cnt[MAX_N+1][MAX_N+1];
int vst[MAX_N+1][MAX_N+1];

deque<pii> dq;

vector<int> v;
bool chk[MAX_N+1];
int ans = 1;

int main(){
	cin>>N;
	for(int i=1; i<=N; i++){
		int prv;
		for(int k=1; k<N; k++){
			int x; scanf("%d", &x);
			if(k!=1){
				nxt[min(i, prv)][max(i, prv)].pb({min(i, x), max(i, x)});
				cnt[min(i, x)][max(i, x)]++;
			}
			prv = x;
		}
	}
	for(int i=1; i<=N; i++){
		for(int j=i+1; j<=N; j++){
			if(cnt[i][j]==0){
				dq.pb({i, j});
			}
		}
	}
	while(!dq.empty()){
		pii now = dq.front(); dq.pop_front();
		vst[now.first][now.second] = true;
		if(chk[now.first] || chk[now.second]){
			ans++;
			while(!v.empty()){
				chk[v.back()] = false; v.pop_back();
			}
		}
		chk[now.first] = true; chk[now.second] = true;
		v.pb(now.first); v.pb(now.second);
		for(pii p : nxt[now.first][now.second]){
			cnt[p.first][p.second]--;
			if(cnt[p.first][p.second]==0){
				dq.push_back(p);
			}
		}
	}
	for(int i=1; i<=N; i++){
		for(int j=i+1; j<=N; j++){
			if(!vst[i][j]){
				printf("-1");
				return 0;
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 47232
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (a.charAt(i) == b.charAt(i) && b.charAt(i) == c.charAt(i)) {
                continue;
            }else if(a.charAt(i) != b.charAt(i) && b.charAt(i) != c.charAt(i)
                                && c.charAt(i) != a.charAt(i)){
                count += 2;
            }else{
                count++;
            }
        }
        System.out.println(count);

        sc.close();

    }

    public static void intArrayScan(int[] array) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        sc.close();
    }

    public static void longArrayScan(long[] array, int n) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextLong();
        }
        sc.close();
    }

    public static void intArrayPrint(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[i]);
        }
    }

    public static void intSquareArrayScan(int[][] array, int h, int w) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                array[i][j] = sc.nextInt();
            }
        }
        sc.close();
    }

    public static void intArrayListScan(List<Integer> list, int n) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        sc.close();
    }

    public static void intArrayListPrint(List<Integer> list) {
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));  
        }
    }
}

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

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	int n;
	
	cin >> n;
	
	int a[n];
	
	int f0 = 0;
	int f2 = 0;
	int f4 = 0;
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		
		if(a[i] % 4 == 0) {
			f4++;
		}
		else if(a[i] % 2 == 0) {
			f2++;
		}
		else {
			f0++;
		}
	}
	
	if(f4 < f0 - n%2) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 4408
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}


int main(){
	string S;
	cin >> S;
	ll ans = 0;
	ll length = 1;
	string Si = S.substr(0,1);
	for(ll i = 0;true;i++){
		string Si_1 = S.substr(i+1,length);
		if(Si == Si_1){
			length++;
			i -= 1;
		} else {
			ans++;
			i += length-1;
			length = 1;
			Si = Si_1;
		}
		if(i+length+1 == S.size()){
			ans++;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import copy
import sys
input = sys.stdin.readline

n, m = map(int,input().split())
edge = []
graph = [[] for i in range(n+1)]
for i in range(m):
    edge.append(list(map(int,input().split())))
    graph[edge[-1][0]].append(edge[-1][1])
s, g = map(int,input().split())

INF = 10**18
ans = [[INF, INF, INF] for i in range(n+1)]
q = [s]
d = 0
while q:
    nq = []
    d += 1
    p = d % 3
    for cf in q:
        for ct in graph[cf]:
            if ans[ct][p] == INF:
                ans[ct][p] = d
                nq.append(ct)
    q = copy.deepcopy(nq)
if ans[g][0] == INF:
    print(-1)
else:
    print(ans[g][0]//3)

Measured memory_bytes: 57568
import numpy as np


def solve(string):
    num_max = 100000
    primes = np.asarray([True for _ in range(num_max + 1)])
    for i in range(num_max + 1):
        if i == 0 or i == 1:
            primes[i] = False
        elif primes[i]:
            primes[i * 2::i] = False
    primes = set(np.arange(num_max + 1)[primes])
    like2017 = [1 if i in primes and (i + 1) // 2 in primes else 0 for i in range(num_max + 1)]
    cumsum = np.cumsum(like2017)

    q, *lr = map(int, string.split())
    return "\n".join([str(cumsum[r] - cumsum[l - 1]) for l, r in zip(lr[::2], lr[1::2])])


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 36920
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private Scanner stdin;
    private PrintWriter stdout;

    public void execute() {
        this.stdin = new Scanner(new BufferedInputStream(System.in));
        this.stdout = new PrintWriter(new BufferedOutputStream(System.out));

        while (this.stdin.hasNext()) {
            int n = stdin.nextInt();
            int m = stdin.nextInt();
            int foo = 0;
            for (int i = 1; i * i <= m; ++i) {
                if (m % i != 0) continue;
                int j = m / i;
                if (i >= n) foo = Math.max(j, foo);
                if (j >= n) foo = Math.max(i, foo);
            }
            this.stdout.printf("%d\n", foo);
        }

        this.stdin.close();
        this.stdout.close();
    }

    public static void main(String[] args) throws Exception {
        Main instance = new Main();
        instance.execute();
    }

}

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

int main(){
  int N, K;
  cin >> N >> K;
  int S[N];
  for (int i=0; i<N; i++){
    cin >> S[i];
  }
  sort(S, S+N, greater<int>());
  int sum=0;
  for (int i=0; i<K; i++){
    sum+=S[i];
  }
  cout << sum << endl;
}

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

int main(){
    long double w,h,x,y;
    cin >> w >> h >> x >> y;
    int ans;
    if(w == x*2.0 && h == y*2.0) ans = 1;
    else ans = 0;
    cout << w*h/2.0 << " " << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A = 0;
  int B = 0;
  int C = 0;
  int N;
  cin >> N;

  for(int i = 0; i < N; i++){
  	string S;
  	cin >> S;
    if(A >= 1 && B >= 1 && C >= 1){
    if(S == "Y"){
     cout << "Four" << endl;
     break;
    
   }
    else if(i == N -1 && S !="Y"){
     cout << "Three" << endl;
    break;
    }
    }
   else if(S == "W"){
      A++; 
  }
    else if( S == "P"){
      B++;
  }
    else if( S == "G"){
      C++;
  }
          
       }
    }
  


Measured memory_bytes: 3632
n, w = list(map(int, input().split()))
nums = []
for _ in range(n):
  nums.append(list(map(int, input().split())))
  
dp = [[0 for _ in range(w+1)] for _ in range(n+1)]

for i in range(1, n+1):
  for j in range(1, w+1):
    if j < nums[i-1][0]:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = max(dp[i-1][j], dp[i-1][j-nums[i-1][0]] + nums[i-1][1])
print(dp[-1][-1])

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

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

  int A, B, C;
  cin >> A >> B >> C;

  if(A == B) cout << C << endl;
  else if(A == C) cout << B << endl;
  else cout << A << endl;

    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
string a;
int b=0;
cin>>a;
if(a[0]=='1')
b++;
if(a[1]=='1')
b++;
if(a[2]=='1')
b++;
cout<<b;
system("pause");
return 0;
}

Measured memory_bytes: 504
n = int(input())
A = [int(input()) for _ in range(n)]
ans = 0
prev = 0
if A[0]!=0:
  print(-1)
  exit()
for i in range(n):
    a = A[i]
    if prev == None and a!=0:
        ans = -1
        break
    if prev != None:
        dif = a-prev
        if dif >= 2:
            ans = -1
            break
        elif dif<=0:
            ans += prev
    prev = a
if ans!=-1:
    ans += prev
print(ans)

Measured memory_bytes: 11048
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define inf 100000000000000000
#define ll long long 
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define test ll t ; cin>>t; while(t--)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

bool ps(string str){
	for(ll i=0 , j=str.length()-1;i<j;i++,j--){
		if(str[i]!=str[j])return 0;
	}
	return 1;
}

bool check(string str , ll n ){
	string str1,str2;
	str1=str.substr(0,(n-1)/2);
	str2=str.substr((n+1)/2);
	// cerr<<str1<<" "<<str2<<" "<<str;
	if(ps(str1) && ps(str2) && ps(str))return 1;
	return 0;
}

int main(){
	//mahakal(),fast;
	
	ll n ;
	string str;
	cin>>str;
	n=str.length();
	if(check(str , n)){
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
	int n;cin>>n;
	char s[n];
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	int ans=0;
	for(int i=1;i<n;i++){
		vector<int> l(50,0),r(50,0);
		for(int j=0;j<i;j++){
			l[s[j]-'a']=1;
		}
		for(int j=i;j<n;j++){
			r[s[j]-'a']=1;
		}
		int count=0;
		for(int j=0;j<50;j++){
			if(l[j]==r[j]){
				if(l[j]){
				count++;
				}
			}
		}
		if(ans<count)ans=count;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    // メンバ変数---
    int N;
    int[] L;
    // -------------

    void calc()
    {
        N = cin.nextInt();
        L = cin.ArrayInt(N);
        Array.Sort(L);
        long cnt = 0;
        for(int i = N-1;0 < i; i--)
        {
            for(int j = i-1;0 < j; j--)
            {
                int min = L[i] - L[j];
                min = UpperBound(L, min);
                cnt += Math.Max(0, N-min-(N-j));
            }
        }

        Write<long>(cnt);
    }

    public static int UpperBound(int[] arr, int value)
    {
        int low = 0;
        int high = arr.Length;
        int mid;
        while (low < high)
        {
            // 1つ右シフトすることで、半分にする
            mid = ((high - low) >> 1) + low;
            if (arr[mid] <= value)
            {
                low = mid + 1;
            }
            else
            {
                high = mid;
            }
        }
        return low;
    }

    void Write<T>(T v)
    {
        Console.WriteLine(v);
    }

    int Pow(int x, int y)
    {
        return (int)Math.Pow(double.Parse(x.ToString()), double.Parse(y.ToString()));
    }

    double Pow(double x, double y)
    {
        return Math.Pow(x, y);
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13396