akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

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

    int n;
    cin >> n;
    vi a(n+1);
    rep(i,0,n+1) cin >> a[i];
    vi b(n);
    rep(i,0,n) cin >> b[i];


    ll t= 0;
    rep(i,0,n) {
      if (b[i] >= a[i]) {
        t += a[i];
        b[i] -= a[i];
        a[i] = 0;
      } else {
        t += b[i];
        a[i]-=b[i];;
        b[i]=0;
      }

      if (b[i] >= a[i+1]) {
        t += a[i+1];
        a[i+1]=0;
      } else {
        t += b[i];
        a[i+1] -= b[i];
      }
    }

    cout << t << endl;
}


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

int main()
{
    int month, day;
    cin >> month >> day;
    if (month < 4 || day < 22)
    {
        cout << 0 << endl;
        return 0;
    }

    vector<int> array;

    // Dを分析して配列を作る
    int first = day % 10;
    int second = day / 10;

    int counter = 0;
    for (int i = 2; i < second; i++)
    {
        for (int j = 2; j <= 9; j++)
        {
            int num = i * j;
            if (num <= month)
            {
                counter++;
            }
        }
    }

    for (int i = 2; i <= first; i++)
    {
        int num = second * i;
        if (num <= month)
        {
            counter++;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<functional>
using namespace std;
int main(){
  int n,t_h,ux,uy,uh,xi,yi;
  bool use=false,high=false;
  scanf("%d",&n);
  int x[n],y[n],h[n];
  for(int i=0;i<n;i++){    
    scanf("%d%d%d",&x[i],&y[i],&h[i]);
    if(use==false){
      if(h[i]!=0){
        ux=x[i];
        uy=y[i];
        uh=h[i];
        use=true;
      }
    }
  }
  for(xi=0;xi<=100;xi++){
    for(yi=0;yi<=100;yi++){
     t_h = uh+abs(ux-xi)+abs(uy-yi);
     high=true;
     for(int i=0;i<n;i++){
       if(h[i]!=max(t_h-abs(x[i]-xi)-abs(y[i]-yi),0)){
         high=false;
           break;
       }
     }
     if(high){
       break;
     }
    }
    if(high){
      break;
    }
  }
  printf("%d %d %d\n",xi,yi,t_h);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int a[1000001];
using namespace std;
int main()
{
    // 文字列の入力
    int K;
	cin >> K;
	
    int result = -1;
	a[1] = 7 % K;
	for(int i = 2; i <= K; i++) {
		a[i] = (a[i - 1]*10 + 7) % K;
	}
	
	for(int i = 1; i <= K; i++) {
		if(a[i] == 0) {
			printf("%d\n", i);
			return 0;
		}
	}
	
	printf("-1\n");
	
    return 0;
}

Measured memory_bytes: 7496
#include <bits/stdc++.h> 
using namespace std;
int main()
{
    int k;
    cin >> k;
    deque<int> ans;
    for(int i=0;i<k;i++) {
        int p =ans.size()- 1;
	    while (p >= 0 && ans[p] == 9) {
	        ans[p] = 0;
	        p--;
	    }
	    if (p == -1) {
	        ans.push_front(1);
	    } else {
	        ans[p]++;
	    }
	    while (1) {
	        int b = -1;
	        for(int j=0;j<ans.size()-1;j++) {
	            if (abs(ans[j] - ans[j+ 1]) > 1) {
	                b =j;
	                break;
	            }
	        }
	        if (b == -1) {
	            break;
	        }
	        if (ans[b + 1] >ans[b]) {
	            ans[b]++;
	        }
	        int x=max(ans[b]-1,0);
	        for(int j=b + 1;j<ans.size();j++) {
	            ans[j] = x;
	            x=max(x-1,0);
	        }
	    }
    }
    for (deque<int>::iterator i=ans.begin();i<ans.end();i++) {
        cout << *i;
    }
    return 0;
}
 

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

using namespace std;

int main()
{	
	int count=0;
	string a,b;
	cin>>a;
	
	while((cin>>b)&&(b!="END_OF_TEXT"))
	{
		for(int i=0;i<b.size();i++){
			b[i] = tolower(b[i]);
		}
		if(a==b){count++;}
	}
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define NN 55
using namespace std;
set<int> Edge[NN];
int Low[NN],Depth[NN];
bool Vis[NN];
void Dfs(int X)
{
	Vis[X]=1;
	for(auto To:Edge[X])
	{
		if(Vis[To])
		{
			continue;
		}
		Dfs(To);
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N,M;
	cin>>N>>M;
	int x[55],y[55]; 
	for(int i=1;i<=M;i++)
	{
		int X,Y;
		cin>>X>>Y;
		x[i]=X;
		y[i]=Y;
		Edge[X].insert(Y);
		Edge[Y].insert(X);
	}
	int Cnt=0;
	for(int i=1;i<=M;i++)
	{
		Edge[x[i]].erase(y[i]);
		Edge[y[i]].erase(x[i]);
		memset(Vis,0,sizeof Vis);
		int Pos=-1;
		for(int j=1;j<=N;j++)
		{
			if(j!=x[i]&&j!=y[i])
			{
				Pos=j;
				break;
			}
		}
		if(Pos==-1)
		{
			continue;
		}
		Dfs(1);
		bool flag=true;
		for(int j=1;j<=N;j++)
		{
			if(!Vis[j])
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			Cnt++;
		}
		Edge[x[i]].insert(y[i]);
		Edge[y[i]].insert(x[i]);
	}
	cout<<M-Cnt<<endl;
	return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

int main() {
	ll n;
	cin >> n;
	vector<ll> dp(n + 1);
	dp[0] = 1;
	dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){

    int n;
    cin>>n;
    while(n--){

        string str;
        cin>>str;
        if(str[0]!='>')cout<<"NA"<<endl;
        else{
            if(str[1]=='\''&&str[2]=='='){
                int e=2;
                for(;str[e]=='=';e++);
                if(str[e]=='#'){
                    int f=e+1;
                    for(;str[f]=='=';f++);
                    if(e==f-e+1&&str[f]=='~'&&str[f+1]=='\0')cout<<"A"<<endl;
                    else cout<<"NA"<<endl;
                }
                else cout<<"NA"<<endl;
            }
            else if(str[1]=='^'&&str[2]=='Q'){
                int e,flg=0;
                for(e=2;str[e]=='Q';e+=2){
                    if(str[e+1]!='='){
                        cout<<"NA"<<endl;
                        flg=1;
                        break;
                    }
                }
                if(!flg){
                    if(str[e]=='~'&&str[e+1]=='~'&&str[e+2]=='\0')cout<<"B"<<endl;
                    else cout<<"NA"<<endl;
                }
            }
            else cout<<"NA"<<endl;
        }

    }

    return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <iostream>

using namespace std;

const int N = 1000000;

int stack[N], top;

int main() {
	int n;
	top = 0;
	while (scanf("%d", &n) != EOF) {
		if (n) stack[top++] = n;
		else printf ("%d\n", stack[--top]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define read(type) readInt<type>() // Fast read
#define ll long long
#define nL "\n"
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++) {
        if(i % d == 0) {
            ans ++;
        }
    }
    cout << ans;
    // if(l / d == 1) {
    //     cout << r / d - l / d + 1;
    // }
    // else {
    // cout << r / d - l / d;

    // }
    return 0;
}

Measured memory_bytes: 3592
import sys
bbn=1000000007
	
#+++++
		
def main():
	n, k = map(int, input().split())
	r, s, p =  map(int, input().split())
	t = input()
	dd={'s':r, 'p':s, 'r':p}
	point = lambda c : dd[c]
	
	max_p=sum([point(c) for c in t])
	same_k={'s':0, 'p':0, 'r':0}
	tn=list(t)
	for i in range(k,n):
		if tn[i]==tn[i-k] and tn[i]!='_':
			same_k[tn[i]] += 1
			tn[i] = '_'
	down=0
	#print(tn)
	for cc in ['r','s','p']:
		down+=same_k[cc]*point(cc)
			
	print(max_p-down)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 4120
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val h, w = sc.nextInt()
  val a = Array.fill(h)(sc.next().toList)
  
  println("#" * (w+2))
  for (i <- a){
    print("#")
    for (j <- i) {
      print(j)
    }
    println("#")
  }
  println("#" * (w+2))
}

Measured memory_bytes: 56444
nx = input().split()
n = int(nx[0])
x = int(nx[1])
ls = input().split()
ls = [int(num) for num in ls]

def main():
    c = 1
    ds = [0]
    for i in range(1,n+1):
        nxt = ds[i-1] + ls[i-1] 
        if nxt > x:
            print(c)
            return
        ds.append(nxt)
        c += 1
    print(c)
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    int N,M,C,ans=0,ans2=0;

	cin >> N >> M >> C;

    int B[M],A[N][M];

    rep(i,0,M){
        cin >> B[i];
    }

    rep(i,0,N){
        rep(j,0,M){
            cin >> A[i][j];
        }
    }

    rep(i,0,N){
        ans2 = 0;
        rep(j,0,M){
            ans2 += A[i][j]*B[j];
        }
        if(ans2+C>0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  if(A == 5 && B == 5 && C == 7){
    cout << "YES" << endl;
  }
  else if(A == 5 && B == 7 && C == 5){
    cout << "YES" << endl;
  }
  else if(A == 7 && B == 5 && C == 5){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

struct Plus{
	int a, b;
	Plus(int x, int y){
		a = x, b = y;
	}
	bool operator<(Plus ope){
		return a < ope.a;
	}
};


struct Minus{
	int a, b;
	Minus(int x, int y){
		a = x, b = y;
	}
	bool operator<(Minus ope){
		return b > ope.b;
	}
};


int n;
vector<Plus> pvec;
vector<Minus> mvec;

int main(void)
{
	cin >> n;
	
	int a, b;
	string S;
	for(int i = 0; i < n; i++){
		cin >> S;
		stack<char> stk;
		for(int j = 0; j < S.size(); j++){
			if(S[j] == ')' && stk.size() && stk.top() == '(') stk.pop();
			else stk.push(S[j]);
		}
		a = b = 0;
		while(stk.size()){
			if(stk.top() == ')') a++;
			else b++;
			stk.pop();
		}
		if(a > b) mvec.push_back( Minus(a, b) );
		else pvec.push_back( Plus(a, b) );
	}
	
	sort(pvec.begin(), pvec.end());
	sort(mvec.begin(), mvec.end());
	
	int cnt = 0;
	for(int i = 0; i < pvec.size(); i++){
		if(pvec[i].a > cnt){
			cout << "No" << endl;
			return 0;
		}
		cnt += pvec[i].b - pvec[i].a;
	}
	
	for(int i = 0; i < mvec.size(); i++){
		if(mvec[i].a > cnt){
			cout << "No" << endl;
			return 0;
		}
		cnt += mvec[i].b - mvec[i].a;
	}
	
	if(cnt == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3192
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月08日 星期一 01时45分23秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=505;
int C[N],s[N],f[N];

void solve(){

	int n;
	scanf("%d",&n);
	for(int i=1;i<n;i++) scanf("%d%d%d",C+i,s+i,f+i);

	for(int i=1;i<=n;i++){
		int ans=0,cur=0;
		for(int j=i;j<n;j++){
			if(cur<s[j]) ans+=s[j]-cur,cur=s[j];
			else{
				int tmp=((cur+f[j]-1)/f[j])*f[j];
				ans+=tmp-cur;
				cur=tmp;
			}
			cur+=C[j];
			ans+=C[j];
		}
		printf("%d\n",ans);
	}

}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    if(abs(N - M) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1,MOD = 1000000007;
    REPP(i,1,N+1){
        ans *= i;
        ans %= MOD;
    }
    REPP(i,1,M+1){
        ans *= i;
        ans %= MOD;
    }
    if(N == M){
        ans *= 2;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int s, b1, b2, b3;
  cin >> s;
  b1 = s / 100;
  b2 = s % 100 / 10;
  b3 = s % 100 % 10;
  cout << b1 + b2 + b3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

int32_t main(){_
   
   cin >> n;

   map<string, int> M;
   for (int i = 0; i < n; ++i)
   {
      string s;
      cin >> s;
      M[s]++;
   }
      
   cout<<(int)(M.size());

   return 0;
}

Measured memory_bytes: 19252
n=int(input())
cnt=[0]*(n+1)

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            tmp=x*x + y*y + z*z + x*y + y*z + z*x
            if tmp <=n:
                cnt[tmp]+=1


for i in range(1, n+1):
    print(cnt[i])

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

int main() {
  kyun;
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,3) if(s[i] == t[i]) ans++;
  cout << ans;
  hinata;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		ArrayList<String> param = new ArrayList<String>();
		int system = 0; // 文字の空白区切り　0:ON　1:OFF

		while (sc.hasNext()) {
			if (sc.hasNextInt()) {
				num.add(sc.nextInt());
			} else {
				if(system==0) param.add(sc.next());
				if(system==1) param.add(sc.nextLine());
			}
		}
		Method(num, param);
	}

	static void Method(ArrayList<Integer> num, ArrayList<String> param) {
		
		int total = num.get(0) + num.get(1);
		if(total >= 10){
			System.out.println("error");
		} else {
			System.out.println(total);
		}
	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

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

        int s = sc.nextInt();

        int h = s / 3600;

        int m = s % 3600 / 60;

        int sb = s % 60;

        System.out.println(h + ":" + m + ":" + sb);
    }

}


Measured memory_bytes: 26268
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    N = int(input())
    S = input()
    cnt0 = S.count("1")

    if cnt0 == 0:
        print(*[1]*N, sep="\n")
        return

    X = int(S, 2)

    def f2():
        cache = [-1] * max(9, cnt0+1)
        cache[0] = 0
        for i in range(3): cache[1<<i] = 1
        def f2(x):
            if cache[x] != -1:
                #hit[x] += 1
                return cache[x]

            y = bin(x).count("1")
            z = 1 + f2(x % y)
            cache[x] = z

            return z
        f2.cache = cache
        return f2
    f2 = f2()

    dc = {}
    for k, v in (("0", 1), ("1", -1)):
        x = cnt0 + v
        y = X % x if x else 0
        dc[k] = (x, v, y, [1, N-1])

    ans = [0] * N
    for i in reversed(range(N)):
        si = S[i]
        cnt, v, n, m1 = dc[si]

        if cnt == 0:
            ans[i] = 0
            continue

        ni = N - i - 1
        m2 = (m1[0]<<(m1[1]-i)) % cnt
        n = (n + v*m2) % cnt
        m1[0] = m2; m1[1] = i

        ans[i] = 1 + f2(n)

    print(*ans, sep="\n")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 85488
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    String n = sc.next();
    if(n.equals("Sunny")){
        System.out.println("Cloudy");
    }else if(n.equals("Cloudy")){
        System.out.println("Rainy");
    }else{
        System.out.println("Sunny");
    }
    
    

    }
}

Measured memory_bytes: 20820
def main():
    import sys
    input = sys.stdin.readline
    
    H,W = map(int, input().split())
    A = [list(map(int, input().split())) for i in range(H)]
    
    for i in range(H):
        for j in range(W):
            if A[i][j] %2 == 0:
                A[i][j] = 0
            else:
                A[i][j] = 1
    ans = 0
    Ans = []
    for i in range(H):
        for j in range(W):
            if i %2 == 0:
                k = j
            else:
                k = W-1-j
            if A[i][k] == 1:
                A[i][k] = 0
                if i%2==0:
                    if k != W-1:
                        A[i][k+1] += 1
                        A[i][k+1] %= 2
                        Ans.append([i+1,k+1,i+1,k+2])
                        ans += 1
                    else:
                        if i != H-1:
                            A[i+1][k] += 1
                            A[i+1][k] %= 2
                            Ans.append([i+1,k+1,i+2,k+1])
                            ans += 1
                else:
                    if k != 0:
                        A[i][k-1] += 1
                        A[i][k-1] %= 2
                        Ans.append([i+1,k+1,i+1,k])
                        ans += 1
                    else:
                        if i != H-1:
                            A[i+1][k] += 1
                            A[i+1][k] %= 2
                            Ans.append([i+1,k+1,i+2,k+1])
                            ans += 1
                            
    print(ans)
    for i in Ans:
        print(*i)
                
    
    
    
main()

Measured memory_bytes: 72668
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++)
	{
		if(!(i%3==0 or i%5==0 or i%15==0))
			sum+=i;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<limits>

using namespace std;


int main(){
    int n;
    cin >> n;
    int v[n];

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

    int nn = n-1;
    int m = numeric_limits<int>::max();

    for(int i = 0; i <= v[0]; i++){
        v[0] -= i;
        for(int j = 0; j <= v[nn]; j++){
            v[nn] -= j;

            int rest = v[0];
            int local_sum = 0;
            for(int p = 1; p < n; p++){
                    local_sum += 2 * rest;
                if(rest >= v[p]){
                    rest = 0;
                } else {
                    rest = v[p] - rest;
                }
            }
            local_sum += 2 * rest;

            local_sum += i + j;
            m = min(m, local_sum);

            v[nn] += j;
        }
        v[0] += i;
    }

    cout << m << endl;

}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  LL h,w,n;
  cin >> h >> w >> n;
  vector<LL> ans(10,0);
  ans[0]=(h-2)*(w-2);
  int a,b;
  map<int,set<int>> field;
  field[-2]=set<int>();
  field[-1]=set<int>();
  field[h]=set<int>();
  field[h+1]=set<int>();
  map<int,set<int>>::iterator mitr;
  set<int>::iterator sitr;
  vector<vector<int>> f(6,vector<int>(6));
  int count;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    a--;
    b--;
    for(int j=0;j<6;j++){
      for(int k=0;k<6;k++){
        f[j][k]=0;
      }
    }
    mitr=field.find(a);
    if(mitr==field.end()){
      field[a]=set<int>();
      mitr=field.find(a);
      mitr->second.insert(-2);
      mitr->second.insert(-1);
      mitr->second.insert(w);
      mitr->second.insert(w+1);
    }
    sitr=mitr->second.find(b);
    if(sitr==mitr->second.end()){
      mitr->second.insert(b);
    }
    mitr=field.lower_bound(a-2);
    for(;mitr->first<=a+2&&mitr!=field.end();mitr++){
      sitr=mitr->second.lower_bound(b-2);
      for(;(*sitr)<=b+2&&sitr!=mitr->second.end();sitr++){
        f[mitr->first-a+3][(*sitr)-b+3]++;
      }
    }
    for(int i=1;i<6;i++){
      for(int j=1;j<6;j++){
        f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
      }
    }
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(0<=a-2+i&&a+i<h&&0<=b-2+j&&b+j<w){
          count=f[i+3][j+3]-f[i+3][j]-f[i][j+3]+f[i][j];
          ans[count-1]--;
          ans[count]++;
        }
      }
    }
  }
  for(int i=0;i<10;i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 33024
import collections

N=int(input())

A=[int(input()) for i in range(N)]

A.sort()

ans=[A[0],A[-1]]
ans=collections.deque(ans)
l=1
r=-2
n=[0]*4
ansn=abs(A[0]-A[-1])
for i in range(N-2):
    n[0]=abs(A[l]-ans[0])
    n[1]=abs(A[l]-ans[-1])
    n[2]=abs(A[r]-ans[0])
    n[3]=abs(A[r]-ans[-1])
    if n[0]==max(n):
        ansn+=n[0]
        ans.appendleft(A[l])
        l+=1
    elif n[1]==max(n):
        ansn+=n[1]
        ans.append(A[l])
        l+=1
    elif n[2]==max(n):
        ansn+=n[2]
        ans.appendleft(A[r])
        r-=1
    elif n[3]==max(n):
        ansn+=n[3]
        ans.append(A[r])
        r-=1

print(ansn)

Measured memory_bytes: 8120
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 1;
	for ( int i=0; i<n; ++i ) {
		int x;
		cin >> x;
		if ( x%2 == 0 ) {
			if ( x%3!=0 && x%5!=0 ) {
				ans = 0;
			}
		}
	}
	if ( ans )	cout << "APPROVED\n";
	else	cout << "DENIED\n";
	return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>a;
cout<<a*a;






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    A, B, C = ILI()
    return (A, B, C)

def solve(A, B, C):
    ans = "No"
    if C >= A and C <= B:
        ans = "Yes"
    
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 4300
N = int(input())
H = list(map(int, input().split()))

prev = H[0]
r = True
for i in range(1,N):
  if prev < H[i]:
    H[i] -= 1
    prev = H[i]
    continue
  if prev == H[i]:
    continue
  r = False
  break

if r:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 14224
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
//#pragma GCC optimize(3,"Ofast","inline")
//for (register int i=1;i<=n;++i)
using namespace std;
int mmax,a[2001][2001],b[2001][2001],l[2001][2001],r[2001][2001],o[2001][2001],u[2001][2001],n,m;
char x;
inline void read(int &nw){
    nw=0;
    int fw=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-'){
            fw=-1;
        }
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        nw=(nw<<1)+(nw<<3)+(ch-48);
        ch=getchar();
    }
    nw*=fw;
}
inline void write(int nw){
    char Fw[2000];
    if(nw<0){
    	putchar('-');
        nw=0;
    }
    int cnt=0;
    do{
        Fw[++cnt]=nw%10+'0';
        nw/=10;
    }while(nw);
    while(cnt){
    	putchar(Fw[cnt--]);
    }
}
int main(){
    read(n),read(m);
    for (register int i=1;i<=n;++i){
    	for (register int j=1;j<=m;++j){
    		cin>>x;
    		if (x=='#'){
    			a[i][j]=1;
			}
    		b[i-1][j-1]=(a[i][j]+a[i-1][j]+a[i][j-1]+a[i-1][j-1]+1)%2;
    		l[i-1][j-1]=j-1,r[i-1][j-1]=j,o[i-1][j-1]=2;
		}
	}
	for (register int i=1;i<n;++i){
		for (register int j=2;j<m;++j){
			if (b[i][j-1]==1&&b[i][j]==1){
				l[i][j]=l[i][j-1];
			}
		}
		for (register int j=m-2;j>=1;--j){
			if (b[i][j+1]==1&&b[i][j]==1){
				r[i][j]=r[i][j+1];
			}
		}
	}
	for (register int i=1;i<n;++i){
		for (register int j=1;j<m;++j){
			if (b[i][j]==1&&b[i-1][j]==1&&i!=1){
				l[i][j]=max(l[i][j],l[i-1][j]);
				r[i][j]=min(r[i][j],r[i-1][j]);
				o[i][j]=o[i-1][j]+1;
			}
			mmax=max(mmax,(r[i][j]-l[i][j]+1)*(o[i][j]));
		}
	}
	write(max(mmax,max(n,m)));
    return 0;
}


Measured memory_bytes: 79744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N, k=0;


    cin >> N;
    char s[N+1], t[N+1];
    char st[N+N];
    cin >> s >> t;


    for(int i=0; i<N; i++)
    {
        st[k++]=s[i];
        st[k++]=t[i];
    }

    for(int i=0; i<N+N; i++)
    {
        cout << st[i] ;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main(){

    ll a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;


}

Measured memory_bytes: 256
// ========================================================================================================
// Library
// ========================================================================================================
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>
using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ========================================================================================================
// ========================================================================================================

int main()
{
	fastIOS();

	string s; cin >> s;
    
    if(s != "AAA" && s!= "BBB")
    {
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 3;
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.sort(a);
		System.out.println(a[0]+a[1]);
	}

}


Measured memory_bytes: 22100
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, m;
vector<int> g[maxn];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < m; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  return true;
}

int col[maxn];
int used[maxn];

int dfs1(int v) {
  used[v] = true;
  int res = 1;
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (used[u]) {
      continue;
    }
    res += dfs1(u);
  }
  return res;
}

pair<int, int> dfs2(int v) {
  pair<int, int> p(0, 0);
  if (col[v]) {
    p.second++;
  } else {
    p.first++;
  }
  for (int i = 0; i < sz(g[v]); i++) {
    int u = g[v][i];
    if (col[u] != -1) {
      if (col[u] == col[v]) {
        return make_pair(-1, -1);
      }
      continue;
    }
    col[u] = !col[v];
    pair<int, int> q = dfs2(u);
    if (q.first == -1) {
      return q;
    }
    p.first += q.first;
    p.second += q.second;
  }
  return p;
}

void solve() {
  for (int i = 0; i < n; i++) {
    col[i] = -1;
    used[i] = false;
  }
  long long res = -m;
  for (int i = 0; i < n; i++) {
    if (col[i] == -1 && !used[i]) {
      col[i] = 0;
      pair<int, int> p = dfs2(i);
      if (p.first == -1) {
        int k = dfs1(i);
        res += (long long) k * (k - 1) / 2;
      } else {
        res += (long long) p.first * p.second;
      }
    }
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N, A, B, arr[100000];

bool check(lint k) {
	lint cnt = 0;
	REP(i, N) {
		if (arr[i] > B * k) {
			cnt += ((arr[i] - B * k) - 1) / (A - B) + 1;
		}
	}
	return cnt > k;
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> A >> B;
	REP(i, N) {
		cin >> arr[i];
	}

	lint lb = -1, ub = 1e9 + 1;
	while (ub - lb > 1) {
		lint mid = (lb + ub) / 2;
		if (check(mid)) lb = mid;
		else ub = mid;
	}
	cout << ub << endl;
}


Measured memory_bytes: 4372
n = gets.to_i
as = gets.split.map(&:to_i)
bs = gets.split.map(&:to_i)

diff = Array.new(n) { |i| as[i] - bs[i] }

remains = diff.select { |i| i > 0 }.sort
requires = diff.select { |i| i < 0 }.sort

valid = true
changed = 0
charge = 0
while !(requires.empty?)
  req = -requires.pop
  # [req, requires].tapp
  changed += 1
  # remains.tapp
  while !(remains.empty?) && charge < req
    charge += remains.pop
    changed += 1
  end
  # [charge, remains].tapp
  if remains.empty? && charge < req
    valid = false
    break
  end
  charge -= req
end
puts(valid ? changed : -1)

Measured memory_bytes: 17892
S = input()
T = input()
n = len(S)

for i in range(len(S) - len(T)+1):
  k_i = 0
  for j in range(len(T)):
    if T[j] != S[i + j]:
      k_i += 1
  if k_i < n:
    n = k_i
print(n)

Measured memory_bytes: 9112
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

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

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

	          int ans=0;
	          set<char> s;
	          REP(i,N){
	        	  s.insert(A[i]);
	        	  s.insert(B[i]);
	        	  s.insert(C[i]);
	        	  int n=s.size();
	        	  ans+=n-1;
	        	  s.clear();
	          }

	          cout << ans << endl;

	          return 0;
}


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

using namespace std;

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

int S, T, U, N, O, D;
int e[101], c[101], h[101], a[101];

int dpD[101][10010];
int dpT[101][101][101];
int dp[101][101];

int main()
{
  cin >> S >> T >> U >> N >> O >> D;
  rep(i, T) cin >> e[i] >> c[i];
  rep(i, N) cin >> h[i] >> a[i];

  memset(dpT, -1, sizeof(dpT));
  dpT[0][0][0] = 0;
  rep(i, T) rep(j, U+1) rep(k, S+1) {
    if(dpT[i][j][k] == -1) continue;
    dpT[i+1][j][k] = max(dpT[i+1][j][k], dpT[i][j][k]);
    if(k + e[i] <= S) dpT[i+1][j+1][k+e[i]] = max(dpT[i+1][j+1][k+e[i]], dpT[i][j][k] + c[i]);
  }

  dpD[0][0] = 0;
  rep(i, N) rep(j, 10010) {
    if(j < a[i]) dpD[i+1][j] = dpD[i][j];
    else dpD[i+1][j] = max(dpD[i][j], dpD[i + 1][j - a[i]] + h[i]);
  }

  memset(dp, -1, sizeof(dp));
  dp[0][S] = 0;
  rep(i, D) rep(j, S+1) {
    if(dp[i][j] == -1) continue;
    rep(k, S+1) {
      //dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if(dpT[T][U][k] == -1) continue;
      if(j - k >= 0) dp[i+1][min(S, j - k + O)] = max(dp[i+1][min(S, j - k + O)], dp[i][j] + dpD[N][dpT[T][U][k]]);
    }
  }

  int ans = 0;
  rep(i, S+1) ans = max(ans, dp[D][i]);

  cout << (ans != 0 ? ans : -1) << endl;
  
  return 0;
}

Measured memory_bytes: 11076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn = 100005;
ll N, W;
ll w[maxn], v[maxn], dp[maxn];
ll solve() {
    ll i, j;
    for(i = 0; i < N; i++)
        for(j = W; j >= w[i]; j--)
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    return dp[W];
}
int main() {
    ll i;
    scanf("%lld %lld", &N, &W);
    for(i = 0; i < N; i++)
        scanf("%lld %lld", &w[i], &v[i]);
    printf("%lld\n", solve());
    return 0;
}

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

namespace _0257
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = RArInt();
            Console.WriteLine(vs[2] == 1 || vs[0] + vs[1] == 2 ? "Open" : "Close");
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

int main() {
  string s;
  int a=0,b=0;
  cin >> s;
  for(int i=0;i<s.size();i++) {
    if(i%2==0) {
      if(s.at(i)=='0') a++;
      else b++;
    } else {
      if(s.at(i)=='1') a++;
      else b++;
    };
  };
  
  cout << min(a,b) << endl;
}

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


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

    int a, b;
    cin >> a >> b;
    if (max(a, b) > 9)
        cout << -1;
    else
        cout << a*b;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

bool check(int n,int ng[]){
  bool bad = false;
  rep(i,3)bad |= n == ng[i];
  return !bad;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;cin>>n>>m;
  vector<int> a(m);rep(i,m)cin>>a[i];
  while (true){
    int tmp = n;
    bool ok = true;
    
    while(tmp){
      int t = tmp % 10;
      rep(i,m){
        ok &= a[i] != t;
      }
      tmp/=10;
      if(!ok)break;
    }

    if(ok)break;
    ++n;
  }
  print(n);
  return 0;
} 

Measured memory_bytes: 892
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const ll LINF = (ll)1 << 60;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint p(n);
  rep(i,n){
    cin>>p[i];
  }

  int max=0;
  for(int a=1;a<=100;a++){
    int count=0;
    rep(i,n){
      if(a<=p[i]){
        count++;
      }
    }
    if(count>=a){
      count=a;
    }
    chmax(max,count);
  }
  cout<<max<<'\n';
  return(0);
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<queue>

using namespace std;
  
#define NOT -1
#define VMAX 100000

int main(void){
	
	int V,E,r;
	int s,t,d;
	int v[VMAX];
	vector<int> ed[VMAX];
	vector<int> edco[VMAX];
	queue<int> no;

	cin>>V>>E>>r;

	for(int i=0;i<V;i++) v[i]=NOT;

	for(int i=0;i<E;i++){
		cin>>s>>t>>d;
		ed[s].push_back(t);
		edco[s].push_back(d);
	}

	no.push(r);
	v[r]=0;
	while(!no.empty()){
		for(int i=0;i<ed[no.front()].size();i++){
			if(v[no.front()]+edco[no.front()][i]<v[ed[no.front()][i]]||v[ed[no.front()][i]]==NOT){
				v[ed[no.front()][i]]=v[no.front()]+edco[no.front()][i];
				no.push(ed[no.front()][i]);
			}
		}
		no.pop();
	}

	for(int i=0;i<V;i++){
		if(v[i]!=NOT) cout<<v[i]<<endl;
		else cout<<"INF"<<endl;
	}
}

Measured memory_bytes: 14668
import statistics

N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

medA = statistics.median(A)
medB = statistics.median(B)

if N % 2 == 1:
    print(medB - medA+1)
else:
    print(int((medB - medA)*2) + 1)

Measured memory_bytes: 28792
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def main():
    A, B, C, X, Y = srl(int)
    r = X * A + Y * B
    for i in xrange(2, 2*max(X, Y) + 2, 2):
        r = min(r, i * C + max(0, (X - i/2)) * A + max(0, (Y - i/2)) * B)
    print r


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+5;
const ll INF = 0x3f3f3f3f;
ll dp[MAXN];
inline ll min(ll a,ll b){
    return a<b?a:b;
}
int main(){
    memset(dp,INF,sizeof(dp));
    int N,W;
    cin>>N>>W;
    ll maxx=0;
    dp[0]=0;
    for(int i=0;i<N;++i){
        ll w,v;
        // dp[j]=dp[j-v[i]]+w;
        cin>>w>>v;
        for(int j=1e5;j>=v;--j){
            dp[j]=min(dp[j],dp[j-v]+w);
        }
    }
    // for(int i=30;i<=100;++i)
    //     cout<<i<<" "<<dp[i]<<endl;
    for(int i=1e5;i>=0;--i){
        if(dp[i]<=W){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#define I(i,n)for(int i=0;i<n;i++)
long long M=1e9+7,n,a[2],s[100000],w[2][100001],e[2],l[2][100000],p,v[2];
int main(){
	std::cin>>n>>a[0]>>a[1];
	I(i,n)std::cin>>s[i];
	I(k,2){
		p=0;
		I(i,n){
			while(s[i]-s[p]>=a[k]&&p<i-1)p++;
			l[k][i]=p;
		}
	}
	I(k,2){e[k]=-1;w[k][0]=1;}
	I(i,n){if(i){
		I(k,2)v[k]=(e[1-k]<l[k][i]?w[1-k][l[k][i]]:0);
		I(k,2)if(s[i]-s[i-1]<a[k]){e[k]=i-1;}else{(v[k]+=w[k][i-1])%=M;}
		I(k,2)w[k][i+1]=w[k][i]=v[k];
	}
	}
	std::cout<<(w[0][--n]+w[1][n])%M;
	return 0;
}

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

using namespace std;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;

int n, k;
int niz[maxn];
int dp[maxn];

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", niz+i);
		
	dp[0] = 0;
	for (int i = 1; i < k; i++) {
		dp[i] = inf;
		for (int j = 0; j < i; j++)
			dp[i] = min(dp[i], dp[j] + abs(niz[j] - niz[i]));
	}
	for (int i = k; i < n; i++) {
		dp[i] = inf;
		for (int j = 1; j <= k; j++)
			dp[i] = min(dp[i], dp[i - j] + abs(niz[i - j] - niz[i]));
	}
	printf("%d", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1024