akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define forn(i,n,m) for(int (i)=(n);i<=(int)(m);(i)++)
#define push_back pb
#define make_pair mp
using namespace std;
typedef long long ll;
typedef long double ld;
int a,b;
int main(){
	cin>>a>>b;
	cout<<max(max(a+b,a-b),a*b)
	;return 0;
}

Measured memory_bytes: 256
// B - Sum of Three Integers
#include <stdio.h>

int main(void){
    int k, s, x, y, z, cnt=0;
    scanf("%d%d", &k, &s);

    for(x=0; x<=k; x++){
        for(y=0; y<=k; y++){
            z = s-x-y;
            if(0<=z && z<=k){
                cnt++;
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

class BinaryIndexedTree:
    def __init__(self, n):
        '''1-index'''
        self.size = n + 1
        self.data = [0] * self.size
        self.element = [0] * self.size
        self.depth = 1 << n.bit_length() - 1
    
    def build(self, array):
        for i, x in enumerate(array):
            self.add(i, x)

    def add(self, i, v):
        self.element[i] += v; i += 1 # 1-index
        while i < self.size:
            self.data[i] += v
            i += i & -i
    
    def _sum(self, i):
        ret = 0
        while i > 0:
            ret += self.data[i]
            i -= i & -i
        return ret
    
    def get_sum(self, l, r=None):
        '''get sum [l, r)'''
        if r == None: return self.element[l]
        return self._sum(r) - self._sum(l-1)

    def lower_bound(self, v):
        if v <= 0: return 0
        k = self.depth; i = 0
        while k > 0:
            if i+k < self.size and self.data[i+k] < v:
                v -= self.data[i+k]
                i += k
            k >>= 1
        return i+1

def Main():
    n, q = read_ints()
    c = read_int_list()
    query = [(read_ints()) for _ in range(q)]
    
    que = defaultdict(list)
    for i, (l, r) in enumerate(query):
        que[r].append([l, i])

    ans = [0] * q    
    last = [-1] * (n + 1)
    bit = BinaryIndexedTree(n)
    
    for i, x in enumerate(c):
        if last[x] > 0:
            bit.add(last[x]-1, -1)
        last[x] = i + 1
        bit.add(last[x]-1, 1)
        
        if len(que[i + 1]) > 0:
            for l, j in que[i + 1]:
                ans[j] = bit.get_sum(l, i+1)
    
    print(*ans, sep='\n')

if __name__ == '__main__':
    Main()

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

int main(){
  int i,j,cnt=0;
  int n;
  cin>>n;
  string s;
  cin>>s;
  s+='#';
  int w=0;
  for(i=0;i<=n;i++){
    if(s[i]=='.')w++;
  }
  int rw=w,lb=0,mi=INT_MAX;
  for(i=0;i<=n;i++){
    mi=min(lb+rw,mi);
    if(s[i]=='#'){
      lb++;
    }else{
      rw--;
    }
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    deque<int>q;
    rep(i,s.length()){
        if(s[i]=='0'){
            q.push_back(0);
        }
        else if(s[i]=='1'){
            q.push_back(1);
        }
        else{
            if(q.empty()){
                continue;
            }
            else{
                q.pop_back();
            }
        }
    }
    for_each(q.begin(),q.end(),[](int x){
        cout<<x;
    });
}

Measured memory_bytes: 256
import java.util.*;

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

        int ans = k;
        if(n >= 2){
            for(int i = 2; i <= n; i++){
                ans *= k - 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21204
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = True
show_flg = False


def main():
    N, K = MI()
    x = LI()
    x.append(0)
    x.sort()

    for i in range(N+1):
        if x[i] == 0:
            zero_index = i

    ans = 10**9

    for i in range(N+1):
        # print(i, zero_index, i <= zero_index, zero_index <= i + K + 1)
        if i <= zero_index and zero_index <= i + K and i + K < N + 1:
            # print(x[i:i+K+1])
            left = x[i]
            right = x[i+K]
            mn = min(abs(left), abs(right))
            ans = min(ans, abs(left) + abs(right) + mn)
            # print(left, right)
            # print(ans)

    print(ans)


if __name__ == '__main__':
    main()


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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >> S;
    
    bool f = false;
    if (S.length() == 4) {
        sort(ALL(S));
        if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2])
            f = true;
    }

    Yes(f);
}


Measured memory_bytes: 256
readline()
S=chomp(readline())
cl=0
for c=S
	if c=='.'
		cl+=1
	end
end
nc=0
as=cl
i=0
for c=S
	i+=1
	if c=='.'
		nc+=1
	end
	as=min(as,i-nc+cl-nc)
end
println(as)


Measured memory_bytes: 153340
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

map<int, int> prime_factor(int n)
{
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n;
    cin >> n;
    map<int, int> mp = prime_factor(n);
    int ans = 0;
    int cnt = 1;
    while (true)
    {
        bool flg = true;
        for (auto m : mp)
        {
            // cout << m.first << " " << m.second << endl;
            if (m.second >= cnt)
            {
                ans++;
                mp[m.first] -= cnt;
                flg = false;
            }
        }
        cnt++;
        if (flg)
            break;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<vector<int> > G(n);
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  
  vector<int> mx(n,0);
  function<void(int, int, int)> dfs1=
    [&](int v,int p,int d){
      chmax(mx[v],d);
      for(int u:G[v]){
        if(u==p) continue;
        dfs1(u,v,max(v,mx[v]));
      }      
    };
  dfs1(0,-1,0);
  
  vector<map<int, int> > dp(n);
  function<int(int, int, int)> dfs4=
    [&](int v,int p,int d){
      if(dp[v].count(d)) return dp[v][d];
      int &res=dp[v][d];
      res=v<d;
      for(int u:G[v]){
        if(u==p||u>d) continue;
        res+=dfs4(u,v,d);
      }
      return res;
    };
  
  vector<int> ans(n,0);
  function<void(int, int)> dfs2=
    [&](int v,int p){      
      for(int u:G[v]){
        if(u==p) continue;
        dfs2(u,v);
      }
      if(p<0) return;
      if(mx[v]<v) ans[v]=1+dfs4(v,p,mx[v]);
      else ans[v]=dfs4(v,p,mx[v])-(v<mx[p]?dfs4(v,p,mx[p]):0);      
    };
  dfs2(0,-1);
  
  function<void(int, int)> dfs3=
    [&](int v,int p){
      for(int u:G[v]){
        if(u==p) continue;
        ans[u]+=ans[v];
        dfs3(u,v);
      }
    };
  dfs3(0,-1);

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


Measured memory_bytes: 54784
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int fa[N],rk[N];
int query(int x){
	if(x==fa[x]) return x;
	return fa[x]=query(fa[x]);
}
void unite(int x,int y){
	x=query(x),y=query(y);
	if(x==y) return;
	fa[x]=y;
	rk[y]+=rk[x];
}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int ans=1;
	for(int i=1;i<=n;i++) rk[i]=1,fa[i]=i;
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		if(query(a)!=query(b)){
			unite(a,b);
		}
	}
	for(int i=1;i<=n;i++) ans=max(ans,rk[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5356
#include <stdio.h>
#include <math.h>
int main( void ){
	int i, n;
	double a[8];
	for( scanf("%d",&n); n--; ){
		for( i = 0; i < 8; i++ )scanf("%lf",a+i);
		puts(fabs((*a-a[2])*(a[5]-a[7])-(a[1]-a[3])*(a[4]-a[6]))<1e-8?"YES":"NO");
	}
	return 0;
}

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

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

int main(void) {
    int n, m, k, a, ans = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<int> cnt(m, 0);
    REP(i, n) {
        cin >> k;
        REP(j, k) {
            cin >> a;
            cnt[a - 1]++;
        }
    }

    REP(i, m) {
        if (cnt[i] == n) {
            ans++;
        }
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
void Dice(char p, int []);
int Count(int[]);

int main() {
	int d[6], d2[6], i, flg = 0;
	char str[2][4] = { "No","Yes" };
	for (i = 0; i < 6; i++)  scanf("%d", &d[i]);
	for (i = 0; i < 6; i++)  scanf("%d", &d2[i]);
	if (Count(d) >= 10) { printf("Yes\n"); return 0; }
	if (d[0] == d2[0]);
	else if (d[5] == d2[0]) Dice('N', d), Dice('N', d);
	else if (d[1] == d2[0]) Dice('N', d);
	else if (d[4] == d2[0]) Dice('S', d);
	else if (d[2] == d2[0]) Dice('W', d);
	else if (d[3] == d2[0]) Dice('E', d);
	if (d[1] == d2[1]);
	else if (d[4] == d2[1]) Dice('L', d), Dice('L', d);
	else if (d[2] == d2[1]) Dice('R', d);
	else if (d[3] == d2[1]) Dice('L', d);
	for (i = 3; i < 6; i++) {
		if (d[i] != d2[i]) break;
		if(i==5) flg = 1;
	}
    printf("%s\n", str[flg]);
	return 0;
}

void Dice(char p, int d[]) {
	int tmp;
	if (p == 'S') { tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp; }
	if (p == 'W') { tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp; }
	if (p == 'E') { tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; }
	if (p == 'N') { tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; }
	if (p == 'L') { tmp = d[1]; d[1] = d[3]; d[3] = d[4]; d[4] = d[2]; d[2] = tmp; }
	if (p == 'R') { tmp = d[1]; d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = tmp; }
}

int Count(int d[]){
	int cnt = 0, i, j;
	for (i = 0; i < 5; i++) {
		for (j = i + 1; j < 6; j++)
			if (d[i] == d[j])++cnt;
	}
	return cnt;
}

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

typedef long long ll;
 
int main() {
    int N; cin >> N;
    map<ll, int> mp;

    mp[0] = 1;
 
    ll s = 0, ans = 0;
 
    for (int i = 0; i < N; i++) {
        ll a; cin >> a;
        s += a;
        ans += mp[s];
        mp[s]++;
    }

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

Measured memory_bytes: 12800
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <set>
#include <queue>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define pb(x) push_back(x)
typedef long long LL;
typedef unsigned long long ull;
const int mod=1e9+7;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=1e5+5;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n/10==9||n%10==9) puts("Yes");
        else puts("No");
    }
    return 0;
}

/*
9
1 2 4 9 5 8 7 3 6
5
1 4 3 5 2
8
1 2 4 3 5 6 8 7
*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	vector<vector <int> > A(n+1);
	vector<int>::iterator itr; 
	int key,t,x;
	for(int i=0;i<q;i++){
		cin>>key;
		if(key==0){
			cin>>t>>x;
			A[t].push_back(x);
		}else if(key==1){
			cin>>t;
			if(A[t].size()==0){
				cout<<endl;
			}else{
				for(itr=A[t].begin();itr!=A[t].end();++itr){
					if(itr==A[t].end()-1) cout<<*itr<<endl;
					else cout<<*itr<<" ";
				}
			}
		}else if(key==2){
			cin>>t;
			A[t].erase(A[t].begin(),A[t].end());
		}
	}

	return 0;
}


Measured memory_bytes: 5836
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-9;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
 
char in[55];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a<6)printf("0\n");
	else if(a<13)printf("%d\n",b/2);
	else printf("%d\n",b);
}

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

int main (int argc, char const* argv[]){
  int n, max1, a[5001];
  
  while(cin >> n && n!=0){
    for(int i=0;i<n;i++) cin >> a[i];
    
    max1 = a[0];
    for (int i = 0; i < n; i += 1){
      int sum = 0;
      for(int j=i;j<n;j++){
        sum += a[j];
        max1 = max(max1,sum);
      }
    }
    cout << max1 << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1176
import java.util.*;

public class Main{
    public static void main(String[] args){
        int i = 1;
        int x;
        Scanner scanner = new Scanner(System.in);
        while(true){
            x = scanner.nextInt();
            if(x == 0) break;
            else{
                System.out.println("Case " + i + ": " + x);
                i++;
            }
        }
    }
}


Measured memory_bytes: 42848
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <queue>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 1e6;

int n;
string s, t;
queue<int> q;
int ans;

int main()
{
	n = read();
	cin >> s;
	cin >> t;

	if (s == t) {
		printf("0\n");
		return 0;
	}
	int from = n - 1, to = n - 1;
	while (to >= 0) {
		while (to && t[to - 1] == t[to])
			to--;
		while (from >= 0 && (s[from] != t[to] || from > to))
			from--;
		if (from < 0) {
			printf("-1\n");
			return 0;
		}
		while (!q.empty() && to + q.size() <= q.front())
			q.pop();
		if (from != to)
			q.push(from);
		if (q.size() + 1 > ans)
			ans = (q.size() + 1);
		to--;
	}

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


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


    class Program
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string Input2 = Console.ReadLine();
            string T = Input2.Substring(0,Input2.Length - 1);
            if(Input == T){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }



Measured memory_bytes: 17404
c = []
for _ in range(3):
    c.append(list(map(int, input().split())))
ans = False
for a1 in range(min(c[0]) + 1):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1

    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    if c[1][1] - b2 == a2 and c[1][2] - b3 == a2:
        if c[2][1] - b2 == a3 and c[2][2] - b3 == a3:
            ans = True
            break
if ans == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// 最大公約数
long long gcd(long long a, long long b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

// 最小公倍数
long long lcm(long long a, long long b){
    long long g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    bool flag = false, odd = false, even = false;
    ll ans = a[0];
    for(int i = 1; i < n; i++){
        ans = gcd(ans, a[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ENDL '\n'
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define sayy cout<<"YES"<<ENDL;
#define sayn cout<<"NO"<<ENDL;

typedef long long ll;
using namespace std;

int main(){
    io

    ll n,ans(0);
    cin >> n;

    for(int i(1); i<=n; i++){
        string s = to_string(i);
        if(s.length() % 2 == 1) ans++;
    }
    cout << ans << ENDL;
    return 0;
}


Measured memory_bytes: 3732
#include<cstdio>
#include<cstring>
using namespace std;
const int N=102;
char s[N];
int main()
{
	scanf("%s",s+1);register int len=strlen(s+1);
	bool g=0;
	for(register int i=1;i<=len;++i){
		if(s[i]=='C') g=1;
		if(g&&s[i]=='F') return puts("Yes"),0;
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
import math
while True :
    n = int(input())
    if n == 0 :
        break
    data = list(map(int, input().split()))
    mean = sum(data) / n
    variance = 0
    stdev = 0
    for d in data :
        variance += (d - mean) ** 2
    variance = variance / n
    stdev = math.sqrt(variance)
    print(stdev)


Measured memory_bytes: 5700
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[])
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        while(t-->0)
        {
         Map<Long,Long> m=new TreeMap<>(Collections.reverseOrder());
         int n=sc.nextInt();
         for(int i=0;i<n;i++) m.merge(sc.nextLong(),1l,Long::sum);
         long ans=0,temp=0,f=0;
         for(Long w:m.keySet())
           {
               if(m.get(w)>=2) 
               {
                   temp++;
                   if(m.get(w)>=4 && temp==1) 
                   {pw.println(w*w);ans=1;break;}
                   if(temp==2) {pw.println(ans*w);ans=1;break;}
                   ans=w;
               }
           }
           if(ans!=1)
           pw.println(0);
        }
           pw.close();
    }
}
  

Measured memory_bytes: 52640
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) {
    val n = readInt()
    val s = readString()

    val alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

    for (c in s) {
        val i = alphabet.indexOf(c)
        print(alphabet[(i + n) % 26])
    }
  
    println("")
}

Measured memory_bytes: 31988
#include<stdio.h>

int main()
{
    int N,i,j,k,t;
    int l[3];
    scanf("%d",&N);
    for(i=1;i<=N;i++){
        for(j=0;j<3;j++) scanf("%d",&l[j]);

        for (j=0;j<3;j++){
        for(k=j+1;k<3;k++){
            if(l[k]<l[j]){
                t=l[k];
                l[k]=l[j];
                l[j]=t;
            }
        }
        }
        if((l[0]*l[0]+l[1]*l[1])==(l[2]*l[2])) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const int MAX_N = 10005, MAX_P=1000005, mod = 1e9+7;
int n;
LL A[MAX_N];

LL pow_mod(LL a, LL b=mod-2) {
  LL res=1;
  for(;b;b>>=1, a=a*a%mod) {
    if(b&1) res=res*a%mod;
  }
  return res;
}

LL inv(int x) {
  return pow_mod(x, mod-2);
}

int f[MAX_P]={};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
    
  cin >> n;
  REP(i, n) cin >> A[i];

  // prime factors
  REP(i, n) {
    int x = A[i];
    for(int j=2; j*j<=x; j++) if(x%j==0) {
      int cnt=0;
      while(x%j==0) {
        x/=j; cnt++;
      }
      f[j] = max(f[j], cnt);
    }
    if(x > 1) f[x] = max(f[x], 1);
  }

  // compute lcm
  LL lcm=1;
  REP(i, MAX_P) while(f[i]--) {
    lcm=lcm*i%mod;
  }
  LL ans=0;
  REP(i, n) {
    ans = (ans + lcm*inv(A[i])%mod)%mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int h[N];
vector<int> g[N];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        bool bad = 0;
        for (int j: g[i]) {
            if (h[j] >= h[i]) {
                bad = 1;
                break;
            }
        }
        ans += !bad;
    }
    cout << ans;
}


Measured memory_bytes: 10272
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
S=sys.stdin.readline().strip()

def isok(d):    #長さdの文字列で重ならない2つの文字列が存在するかを判定
    D={}    #出てきた文字列:スタート位置
    for i in range(N-d+1):
        x=S[i:i+d]
        if x not in D:  #前に文字列が出てきていない場合
            D[x]=i
        else:  #既に文字列が出てきている場合
            if d<=i-D[x]:   #文字列が重なっていない場合
                return True
            else:           #文字列が重なっていた場合は
                pass        #更に右側の文字列を探すために処理を継続する
    else:
        return False

h=N
l=0
while h-l!=1:
    m=(h+l)/2
    if isok(m):
        l=m
    else:
        h=m
print l


Measured memory_bytes: 74524
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>

using namespace std;

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

	vector<long long> list(N);
	for (int i = 0; i < N; i++)
	{
		cin >> list[i];
	}

	sort(list.begin(), list.end());

	long long ans = LLONG_MAX;
	for (int i = 0; i < N - K + 1; i++)
	{
		ans = min(ans, list[i + K - 1] - list[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
typedef long long LL;

int read()
{
    int x=0,flag=1;
    char c=getchar ();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

int main()
{
    //freopen("input.txt","r",stdin);
    LL n=read();
    cout<<n*(n-1)/2;

	return 0;
}


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

int main(){
  int ans;
  string s;cin>>s;
  if(s=="SUN") ans=7;
  if(s=="MON") ans=6;
  if(s=="TUE") ans=5;
  if(s=="WED") ans=4;
  if(s=="THU") ans=3;
  if(s=="FRI") ans=2;
  if(s=="SAT") ans=1;
  cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>

using namespace std;

#define INF 1e9 + 1

int main(){
    int N, M, L;
    cin >> N >> M >> L;
    int G[N][N]; 

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            G[i][j] = INF;
        }
    }

    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        G[a-1][b-1] = c;
        G[b-1][a-1] = c;
    }

    for(int k =0; k<N; k++){
        for(int i = 0;i <N; i++){
            for(int j =0; j<N; j++){
                if(G[i][j] > G[i][k] + G[j][k]){
                    G[i][j] = G[i][k] + G[j][k];
                }
            }
        }
    }

    int t[N][N];
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(G[i][j] <= L) t[i][j] = 1;
            else t[i][j] = INF;
        }
    }

    for(int k =0; k<N; k++){
        for(int i = 0;i <N; i++){
            for(int j =0; j<N; j++){
                if(t[i][j] > t[i][k] + t[j][k]){
                    t[i][j] = t[i][k] + t[j][k];
                }
            }
        }
    }

    int Q;
    cin >> Q;
    int x[Q], y[Q];
    for(int i=0; i<Q; i++){
        int w ,z;
        cin >> w >> z;
        x[i] = w-1;
        y[i] = z-1;
    }
    for(int i=0; i<Q; i++){
        if(t[x[i]][y[i]] == INF) cout << -1 << endl;
        else cout << t[x[i]][y[i]] -1 << endl;
    }
    
    return 0;  

}

Measured memory_bytes: 1920
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    S = input()[::-1]

    flag = True
    while S:
        if S[:5] == 'maerd':
            S = S[5:]
        elif S[:7] == 'remaerd':
            S = S[7:]
        elif S[:5] == 'esare':
            S = S[5:]
        elif S[:6] == 'resare':
            S = S[6:]
        else:
            flag = False
            break

    if flag:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    solve()


Measured memory_bytes: 9296
using System;
using System.Collections.Generic;
class Solve{
    string s;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        int count = 0;
        string ss = "CODEFESTIVAL2016";
        for(int i=0;i<s.Length;i++){
            if(s[i] != ss[i]){
                count++;
            }
        }
        Console.WriteLine(count);
    }
    void getinput(){
        s = Console.ReadLine();
    }    
}

Measured memory_bytes: 2776
#include <stdio.h>
main()
{
    int a,b,count,i;
    scanf("%d %d",&a,&b);
    int arr[a];
    for(i=0;i<a;i++)
        scanf("%d",&arr[i]);

    for(i=0;a>1;i++)
    {
        a=a-b;
        a=a+1;

    }
    printf("%d",i);
}


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

const int N = 2e5 + 5;
ll n, a[N], f[N], sum[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = (i > 1 ? sum[i - 2] : 0) + a[i];
    }
    for (int i = 2; i <= n; i++) {
        if (i & 1)
            f[i] = max(f[i - 2] + a[i], f[i - 1]);
        else
            f[i] = max(f[i - 2] + a[i], sum[i - 1]);
    }
    cout << f[n] << '\n';
}


Measured memory_bytes: 8300
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max(0, min(b, d) - max(a, c)) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

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

map<ll, ll> prime_factor(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n]++;
    }
    return res;
}

int a[20000];

int main()
{
    int n;
    cin >> n;
    map<ll, ll> L;
    rep(i, 0, n)
    {
        cin >> a[i];
        auto mp = prime_factor(a[i]);
        for (auto &p : mp)
        {
            L[p.first] = max(L[p.first], p.second);
        }
    }
    ll A = 1;
    for (auto &p : L)
    {
        (A *= ppow(p.first, p.second)) %= MOD;
    }
    ll ans = 0;
    rep(i, 0, n)
    {
        (ans += A * ppow(a[i], MOD - 2)) %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)
#define emax(l, r) l = max(l, r)
#define vmin(l, r) l = min(l, r)

template<class T, class U>
bool contains(const T & vec, const U & value) {
    return vec.find(value) != vec.end();
}

ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

vector<ll> dfs(ll now, ll before, ll len, vector<vector<ll>>& connection) {
  if ((connection.at(now).size() == 1) && (before != -1)) {
    return {len, now};
  }
  vector<ll> res = {0, now};
  for (ll i = 0; i < connection.at(now).size(); ++i) {
    ll next = connection.at(now).at(i);
    if (next == before) {
      continue;
    }
    vector<ll>  temp = dfs(next, now, len + 1, connection);
    if (temp.at(0) > res.at(0)) {
      res = temp;
    }
  }
  // res.at(0) += len;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<vector<ll>> connection(N);
  for (ll i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    a -= 1;b -= 1;
    connection.at(a).push_back(b);
    connection.at(b).push_back(a);
  }
  vector<bool> visted(N, false);
  visted.at(0) = true;
  ll now = 0;
  ll L;
  while (true) {
    vector<ll> temp = dfs(now, -1, 0, connection);
    if (visted.at(temp.at(1)) == true) {
      L = temp.at(0);
      break;
    }
    visted.at(temp.at(1)) = true;
    now = temp.at(1);
  }
  L += 1;
  if (L % 3 == 2) {
    cout << "Second" << "\n";
  }
  else {
    cout << "First" << "\n";
  }
}


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

const int MOD = 1e9 + 7;

void solve_test() {
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << '\n';
}

int32_t main() {
	int T; 
	// cin >> T;
	T = 1;
	while (T--)
		solve_test();

	return 0;
}


Measured memory_bytes: 3568
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto N = readln.chomp.to!int;
    auto LS = readln.split.to!(long[]);
    sort(LS);
    int r;
    foreach (i; 0..N-2) {
        foreach (j; i+1..N-1) {
            foreach (k; j+1..N) {
                if (LS[i] != LS[j] && LS[j] != LS[k] && LS[i] + LS[j] > LS[k]) {
                    ++r;
                }
            }
        }
    }
    writeln(r);
}

Measured memory_bytes: 2776
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main() {
	int ans;
	double tmp = 100000.0;

	int n, t, a;
	cin >> n >> t >> a;

	vector<int>h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (tmp > abs((t - h[i] * 0.006)-a))
			tmp = abs((t - h[i] * 0.006)-a), ans = i + 1;
	}
	cout << ans << endl;

	return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }

    vector<ll> index(n);
    iota(index.begin(), index.end(), 0);

    sort(index.begin(), index.end(),
         [&](const int &x, const int &y) { return a[x] < a[y]; });

    ll count = 0;
    rep(i, n) { count += abs(index[i] - i) % 2; }
    cout << count / 2 << endl;
    return 0;
}



Measured memory_bytes: 4788
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC106D
{
    class ABC106D
    {
        static void Main(string[] args)
        {
            var dg = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
            var n = dg[0];
            var m = dg[1];
            var q = dg[2];

            var map = new int[n + 1, n + 1];
            for (int i = 0; i < m; ++i)
            {
                var data = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
                var x = data[0];
                var y = data[1];
                ++map[x, y];
            }

            for (int i = 1; i <= n; ++i)
            {
                for (int j = 1; j <= n; ++j)
                {
                    var x = j - 1;
                    map[j, i] += map[x, i];

                }

                var y = i - 1;
                for (int j = 1; j <= n; ++j)
                {
                    map[j, i] += map[j, y];
                }
            }

            var count = new List<int>(q);
            for (int i = 0; i < q; ++i)
            {
                var ques = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                var s = ques[0];
                var e = ques[1];

                count.Add(map[e, e] - map[s - 1, e] - map[e, s - 1] + map[s - 1, s - 1]);
            }

            foreach (var v in count)
            {
                Console.WriteLine(v);
            }
        }
    }
}


Measured memory_bytes: 19052
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, A[112345], B[112345], C[112345];
LL resA[112345], resB[112345];
LL ans;
LL minC[112345];

int main()
{
	in >> N;
	rep(i, N) { in >> A[i]; }
	rep(i, N) { in >> B[i]; }
	rep(i, N) { in >> C[i]; }

	std::sort(A, A + N);
	std::sort(B, B + N);
	std::sort(C, C + N);
	rep(i, N)
	{
		auto it = std::upper_bound(B, B + N, A[i]);
		resA[i] = (it - B) - 1;
	}
	rep(i, N)
	{
		auto it = std::upper_bound(C, C + N, B[i]);
		resB[i + 1] += N - (it - C);
		resB[i + 2] += resB[i + 1];
	}
	rep(i, N)
	{
		LL res = 0;
		res = resB[N] - resB[resA[i] + 1];
		ans += res;
	}

	out << ans << std::endl;
	return 0;
}

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

int main() {
  string AL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string S;
  int N;
  cin >> N >> S;
  
  for(int i=0;i<S.size();i++){
    for(int j=0; j<26;j++){
      if(S.at(i) == AL.at(j)){
        S.at(i) = AL.at( (j+N)%26 );
        break;
      }
    }
  
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long dp[200007];

int main()
{
    int N,W;
    cin >> N >> W;
    for(int i=0; i<N; i++)
    {
        long long n,w;
        cin >> n >> w;
        if(n > W)
            continue;
        for(int j=W; j>0; j--)
            if(dp[j] != 0)
                dp[j+n]=max(dp[j+n], dp[j]+w);
        dp[n]=max(dp[n], w);
    }
    long long wynik=0;
    for(int i=1; i<=W; i++)
        wynik=max(wynik, dp[i]);
    cout << wynik;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>H(N);
	rep(i, N) in >> H[i];

	for (LL i = N - 2; i >= 0; --i)
	{
		if (H[i] > H[i + 1])
		{
			if (H[i] - H[i + 1] >= 2)
			{
				out << "No" << std::endl;
				return 0;
			}
			--H[i];
		}
	}
	out << "Yes" << std::endl;
}


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

const int maxN=110;
const int inf=2147483647;

int n,m;
int A[maxN];

int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>A[i];
	sort(&A[1],&A[n+1]);
	int sum=0;
	int p=0;
	while (p<n){
		if (sum+A[p+1]>m) break;
		p++;sum+=A[p];
	}
	if ((p==n)&&(sum!=m)) p--;
	cout<<p<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)
a, b, c, d, e, f = map(int, input().split())
def dfs(g, a, b, can, base=100):
    if not base*g <= f:
        return
    if g in can:
        return
    can[g] = 1
    dfs(g + a, a, b, can, base)
    dfs(g + b, a, b, can, base)
can1 = {}
dfs(0, a, b, can1)
can2 = {}
dfs(0, c, d, can2, 1)

ans = (0, 0, 0)
for g in can1:
    if g == 0:
        continue
    rest = f - 100*g
    result = max([0]+[h for h in can2 if h <= min(rest, e*g)])
    ans = max(ans, (result / (100.*g + result), 100*g+result, result))
print(*ans[1:])


Measured memory_bytes: 41584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int tmp;
    int count = 0;
    for(int i=0; i<n-1; ++i){
        for(int j=n-1; j>i; --j){
            if(a[j] < a[j-1]){
                tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
                count++;
            }
        }
    }
    rep(k, n){
        cout << a[k];
        if(k != n-1){
            cout << " ";
        }
    } 
    cout << "\n" << count << endl;

    return 0;
}


Measured memory_bytes: 3116
// ref: https://drken1215.hatenablog.com/entry/2019/04/27/224100_1

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

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

int64 gcd_range(vector<int> vA, int l, int r){
    int64 ret=vA[l];
    for(int i=l+1; i<r; ++i){
        ret = gcd(vA[i], ret);
    }
    return ret;
}

int64 max(int64 l, int64 r){ return (r>=l ? r:l); }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> vA(N); for(int i=0; i<N; ++i){ cin >> vA[i]; }
    
    vector<int> vL(N+1, 0); for(int i=0; i< N; ++i){ vL[i+1] = gcd(vL[i], vA[i  ]); }
    vector<int> vR(N+1, 0); for(int i=N; i>=1; --i){ vR[i-1] = gcd(vR[i], vA[i-1]); }
    
    int ret = 0;
    for(int i=0; i<N; ++i){
        ret = max(ret, gcd(vL[i], vR[i+1]));
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 1408
N, M = map(int, input().split())
pS = list(input().split() for _ in range(M))

result = ["WA"] * N
penalty = [0] * N

for i in range(M):
  I = int(pS[i][0]) - 1
  if result[I] == "WA" and pS[i][1] == "WA":
    penalty[I] += 1
  elif result[I] == "WA" and pS[i][1] == "AC":
    result[I] = "AC"

ans = [0] * 2
for j in range(N):
  if result[j] == "AC":
    ans[0] += 1
    ans[1] += penalty[j]

print(" ".join(map(str, ans)))

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

int main()
{
    int a,b,c;
    int sum=0;
    cin>>a>>b>>c;
    if (a>=1 && b>=1 && c>=1)
    {
    if(a<=13 && b<=13 && c<=13 )
    
    {
    sum =a+b+c;
    if (sum>=22)
      {cout<<"bust";}
    else
     { cout<<"win";}
    }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	int X;
	cin>>X;
	int left = 400, right = 600;
	int kyu = 8;
	while(right<=2000)
	{
		if(X>=left && X<right)
		{
			cout<<kyu<<"\n";
			return;
		}
		left+=200;
		right+=200;
		kyu--;
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
MOD = 10 ** 9 + 7
num = [0] * (10 ** 5 + 1)
N = int(input())
A = list(map(int,input().split()))
for i in range(len(A)):
	num[A[i]] += 1
if N % 2 == 1:
	for i in range(0,N,2):
		cnt = num[i]
		if i == 0:
			if cnt != 1:
				print(0)
				exit()
		else:
			if cnt != 2:
				print(0)
				exit()
	print(2 ** (N // 2) % MOD)
else:
	for i in range(1,N,2):
		cnt = num[i]
		if cnt != 2:
			print(0)
			exit()
	print(2 ** (N // 2) % MOD)

Measured memory_bytes: 21356