akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n, t;
	cin >> n >> t;
	vector<P> ab(n);
	REP(i, n) cin >> ab[i].first >> ab[i].second;

	sort(all(ab));

	Matrix dp(n + 1, Array(t + 1, -1));

	dp[0][0] = 0;
	REP(i, n) {
		
		REP(j, t) {
			if (dp[i][j] != -1) {
				chmax(dp[i + 1][j],dp[i][j]);
				if (j + ab[i].first < t) {
					chmax(dp[i + 1][j + ab[i].first], dp[i][j] + ab[i].second);
				}
				else {
					chmax(dp[i + 1][t], dp[i][j] + ab[i].second);
				}
			}
		}

		if (dp[i][t] != -1) {
			chmax(dp[i + 1][t], dp[i][t]);
		}
	}

	ll ans = 0;
	REP(i, t + 1) {
		chmax(ans, dp[n][i]);
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    int n,k,s;
    std::cin >> n >> k >> s;
    std::vector<long long> a(n,1000000000);
    if(s != 1000000000){
        for(int i = 0; i < k; i++){
            a[i] = s;
        }
    }else{
        for(int i = 0; i < n; i++){
            a[i] = 1000000000 - 1;
        }
        for(int i = 0; i < k; i++){
            a[i] = s;
        }
    }
    for(int i = 0; i < n; i++){
        std::cout << a[i] << " ";
    }

}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  int ans=0;
  rep(i,0,3){
    int a;cin>>a;
    ans+=a;
  }

  if(ans>=22)out("bust");
  else out("win");



  return 0;
}


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

long long N, M, Color[100000] = {};
vector<int> V[100000];

void init(int X) {
	for (int i = 0; i < X; i++) Color[i] = -1;
}

bool DFS(int X, int C) {
	Color[X] = C;
	for (int Y : V[X]) {
		if (Color[Y] == -1) {
			if (!DFS(Y, 1 - C)) return false;
		}
		else if (Color[Y] == Color[X]) return false;
	}
	return true;
}

int main() {
	cin >> N >> M;
	init(N);
	for (int i = 0; i < M; i++) {
		int A, B;
		cin >> A >> B;
		A--, B--;
		V[A].push_back(B);
		V[B].push_back(A);
	}
	if (DFS(0, 0)) {
		long long Black = 0, White = 0;
		for (int i = 0; i < N; i++) {
			if (Color[i] == 0) Black++;
			else White++;
		}
		cout << Black * White - M;
	}
	else {
		cout << N * (N - 1) / 2 - M;
	}
}

Measured memory_bytes: 6912
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;
using ll = long long;

bool makable(vector<long long> b,long long remove_i){
    if (b[remove_i] !=  remove_i + 1){
        return false;
    }

    for(int i = 0;i< b.size();i++){
        long long c = i+1;
        if (remove_i == i){
            continue;
        }else if (i > remove_i ){
            c--;
        }

        if (b[i] > c){
            return false;
        };

    }
    return true;
}



int main()
{
    // 整数の入力
    long long  N,temp;
    vector<long long> b;
    vector<long long> tejun;

    cin >> N;

    for(int i = 0; i< N;i++){
        cin >> temp;
        b.push_back(temp);
    }

    while(b.size() > 0){
        bool changed = false;
        for (int i = b.size() - 1;i>=0;i--){
            if (makable(b,i)){
                tejun.push_back(b[i]);
                b.erase(b.begin() +i);
                changed = true;
                break;
            }
        }

        if (!changed){
            break;
        }
    }


    if (b.size() != 0){
        cout << -1 << endl;
    }else{
        for (int i = N - 1 ;i >= 0;i--){
            cout << tejun[i] << endl;
        }
    }
    return 0;
}

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

const int N = 100005;
const int MOD = 1000000007;
typedef pair<int, int> pii;
#define mp(a,b) make_pair(a,b)
#define se second
#define fi first

int n, x;
vector<pii> a;
int cnt[2];

int main() {
	scanf("%d", &n);
	for (int s = 0; s < 2; s++) {
		for (int i = 1; i <= n; i++) {
			scanf("%d", &x);
			a.push_back(mp(x, s));
		}
	}
	sort(a.begin(), a.end());
	int ans = 1;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < a.size(); i++) {
		if (cnt[!a[i].se] - cnt[a[i].se] > 0)  
			ans = 1LL * ans * (cnt[!a[i].se] - cnt[a[i].se]) % MOD;
		cnt[a[i].se]++;
	}
	printf("%d\n", ans);
	return 0;
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

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

    ll ans(0); 
    if (n == 1){
        ans = k;
    }else{
        ans = k * pow(k - 1, n-1);
    }

    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 3924
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    int t = 100 * (N - M) + M * 1900;
    cout << t * (1 << M) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;class Program
{
	static void Main(string[] args)
	{
        //var exStdIn = new System.IO.StreamReader( "stdin.txt" );System.Console.SetIn( exStdIn );
		
		
		var kxd = Console.ReadLine().Split().Select(long.Parse).ToArray();
		long x = kxd[0], k = kxd[1], d = kxd[2];
		x = Abs(x);

		if(k<=x/d){
			Console.WriteLine(x-k*d);
			return;
		}
		k-=x/d;
		x = x%d;
		if(k%2==0)Console.WriteLine(x);
		else Console.WriteLine(d-x);
	}
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> vec(n);
    vector<string> vec2(n);
    rep(i,n){
        cin >> vec2[i] >> vec[i];
    }
    
    string ss;
    cin >> ss;
    int now;
    rep(i,n){
        if(ss==vec2[i]){
            now=i;
        }
    }
    
    ll ans=0;
    
    for(int i=now+1;i<n;i++){
        ans+=vec[i];
    }
     
    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 < (n); i++)

int main() {
    int x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    int x3, y3, x4, y4;
    x4 = x0 + y0 - y1;
    y4 = y0 - x0 + x1;
    x3 = x1 + y0 - y1;
    y3 = y1 + x1 - x0;
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
 }

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

int main(){
    int n,t_;
    cin >> n >> t_;
    int mincost = 1001;
    for(int i = 0;i < n;i ++){
        int c,t;
        cin >> c >> t;
        if(t > t_) continue;
        if(mincost > c) mincost = c;
    }
    if(mincost == 1001){
        cout << "TLE" << endl;
        return 0;
    }
    cout << mincost << endl;
    return 0;   
}


Measured memory_bytes: 256
#include <vector>
#include <set>
#include <cstdio>
using namespace std;
int main(){
    int N,L;
    scanf("%d%d",&N,&L);
    vector<int>v(N);
    for(int i=0;i<N;i++)scanf("%d",&v[i]);
    multiset<int>se;
    for(int i=0;i<L-1;i++)se.insert(v[i]);
    for(int i=L-1;i<N;i++){
        se.insert(v[i]);
        printf(i<N-1?"%d ":"%d\n",*se.begin());
        se.erase(se.find(v[i-L+1]));
    }
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    string S, T;
    cin >> S >> T;
    vector<char> A, B;
    vector<int> Sn(S.size()), Tn(T.size());
    REP(i,S.size()){
        if(i == 0){
            A.push_back(S[i]);
            B.push_back(T[i]);
            Sn[i] = 0;
            Tn[i] = 0;
        }
        else{
            bool Sa, Ta;
            Sa = Ta = false;
            REP(j,A.size()){
                if(A[j] == S[i]){
                    Sa = true;
                    Sn[i] = j;
                }
            }
            REP(j,B.size()){
                if(B[j] == T[i]){
                    Ta = true;
                    Tn[i] = j;
                }
            }
            if(!Sa){
                Sn[i] = A.size();
                A.push_back(S[i]);
            }
            if(!Ta){
                Tn[i] = B.size();
                B.push_back(T[i]);
            }
        }
    }
    bool can = true;
    REP(i,S.size()){
        if(Sn[i] == Tn[i]) continue;
        else can = false;
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 2312
def make_divisors(n):
    divisors = []
    min_k = 10
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            k = max(len(str(int(i))), len(str(int(n // i))))
            min_k = min(min_k, k)

    # divisors.sort()
    return min_k

N = int(input())
# min_k = len(str(N)) + 1
# for i in range(1, N):
#     if N % i != 0:
#         continue
#     if i ** 2 > N:
#         break
#     else:
#         ii = N // i
#         k = max(len(str(i)), len(str(ii)))
#         # print(i, ii, k, min_k)
#         if min_k > k:
#             min_k = k
print(make_divisors(N))

Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
int main(){
	for(int n;cin>>n,n;){
		vector<P>V;
		for(int a,b;n--;){
			cin>>a>>b;
			V.push_back(P(a,b));
		}
		cin>>n;
		for(int a,b;n--;){
			cin>>a>>b;
			V.push_back(P(a,b));
		}
		V.push_back(P(0,0));
		sort(V.begin(),V.end());
		int dp[201]={0};
		int ans=0;
		
		for(int i=0;i<V.size();i++){
			ans = max(ans,dp[i]);
			for(int j=i+1;j<V.size();j++){
				if(V[i].first<V[j].first && V[i].second<V[j].second){
					dp[j] = max(dp[i]+1,dp[j]);
				}
			}
		}
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;

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

void reg(ll & a, ll & b) {
    ll g = gcd(abs(a), abs(b));
    a = a / g;
    b = b / g;
    if (a < 0 && b < 0) {
        a = -a;
        b = -b;
    } else if (a <= 0 && b > 0) {
        a = -a;
        b = -b;
    }
}

#define M 1000000007

ll
mpow(ll x, ll n)
{
    ll ans = 1;
    while (n > 0){
        if (n & 1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
int main() {
    ll n;
    cin >> n;
    map<pair<ll,ll>, pair<ll,ll>> m;

    ll zeros = 0;
    for (ll i = 0; i < n; ++ i) {
        ll a, b;
        cin >> a >> b;
        if (a == 0 && b != 0) {
            m[make_pair(0,0)].first++;
            continue;
        }
        if (a != 0 && b == 0) {
            m[make_pair(0,0)].second++;
            continue;
        }
        if (a == 0 || b == 0) {
            ++zeros;
            continue;
        }
        reg(a, b);
        //cerr << "Checking:" << a << "," << b << endl;
        if ((a >= 0 && b>= 0) || (a <= 0 && b <= 0)) {
            m[make_pair(a,b)].first++;
        } else {
            m[make_pair(abs(b),abs(a))].second++;
        }
    }
    ll res = 1;
    for (auto p : m) {
        //cerr << p.first.first << "," << p.first.second << ":" << p.second.first << "," << p.second.second << endl;
        res = res * (mpow(2, p.second.first) + mpow(2,p.second.second) - 1);
        //cerr << res << endl;
        res %= M;
    }
    res = (res+zeros+M-1)%M;
    cout << res << endl;
}


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

int main() {
  ll n,k,ans;
  cin>>n>>k;
  for(int i=1; i<=n; i++){
    if(n < pow(k,i)) {
      cout<<i;
      return 0;
    }
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1;i <= 9;i++){
		if(n % i == 0){
			int k = n / i;
			if(k <= 9){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}
//do smt instead of nothing! never give up!


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		List<Integer> left = new ArrayList<Integer>();
		List<Integer> right = new ArrayList<Integer>();

		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		for(int i = 0; i < 4; i++){
			left.add(0);
			right.add(0);
		}

		String str;
		while((str=br.readLine())!=null){
			String[] sp = str.split(" ");

			double l = Double.parseDouble(sp[0]);
			double r = Double.parseDouble(sp[1]);

			if(1.1 <= l){
				left.set(0, left.get(0) + 1);
			} else if(0.6 <= l && l < 1.1){
				left.set(1, left.get(1) + 1);
			} else if(0.2 <= l && l < 0.6){
				left.set(2, left.get(2) + 1);
			} else{
				left.set(3, left.get(3) + 1);
			}

			if(1.1 <= r){
				right.set(0, right.get(0) + 1);
			} else if(0.6 <= r && r < 1.1){
				right.set(1, right.get(1) + 1);
			} else if(0.2 <= r && r < 0.6){
				right.set(2, right.get(2) + 1);
			} else{
				right.set(3, right.get(3) + 1);
			}

		}

		for(int i = 0; i < 4; i++){
			System.out.println(left.get(i) + " " + right.get(i));
		}
	}

}

Measured memory_bytes: 24364
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b,c,d,p,y;
  cin>>a>>b>>c>>d>>p;
  if(p < c){// unlimit c
    y = b;
  } else {
    y = b + (p-c) * d;
  }
  cout<<min(a * p, y)<<endl;


}

Measured memory_bytes: 1160
# ABC145D

import sys
input=sys.stdin.readline
MOD=10**9+7

factorial=[1]*(2*10**6+1)
for i in range(1,2*10**6+1):
    factorial[i]=factorial[i-1]*i
    factorial[i]%=MOD

def modinv(x):
    return pow(x,MOD-2,MOD)
    
def comb(n,r):
    return (factorial[n]*modinv(factorial[n-r])*modinv(factorial[r]))%MOD

def main():
    X,Y=map(int,input().split())
    a=(2*Y-X)
    b=(2*X-Y)
    A=a//3
    B=b//3
    ans=0
    if a%3==0 and b%3==0 and a>=0 and b>=0:
        ans=comb(A+B,A)
    print(ans)
    
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 87852
def main():
    N,M = map(int, input().split())
    x = ["0"]*N
    hfixed = [False]*N
    flag = False
    for _ in range(M):
        s,c = input().split()
        # 左からsけた目がc
        idx = int(s)-1
        if hfixed[idx] and x[idx]!=c:
            flag = True
            break
        else:
            hfixed[idx] = True
            x[idx] = c

    if flag:
        print("-1")
    else:
        if N==1:
            print("".join(x))
        else:
            if x[0]=="0":
                if hfixed[0]:
                    print("-1")
                else:
                    x[0] = "1"
                    print("".join(x))
            else:
                print("".join(x))

main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>

int solve(std::vector<int> l)
{
    int result = 0;
    for (auto i = l.begin(); i < l.end() - 2; ++i)
    {
        for (auto j = i + 1; j < l.end() - 1; ++j)
        {
            auto it = std::lower_bound(j + 1, l.end(), *i + *j);
            result += std::distance(j + 1, it);
        }
    }

    return result;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> l(n);

    for (auto i = 0; i < n; ++i)
    {
        std::cin >> l[i];
    }
    std::sort(l.begin(), l.end());

    std::cout << solve(l) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }


void solve(long long W, long long H, long long x, long long y){
	ll can = 0;
	if (W==x*2 && H==y*2) can = 1;
	double S = W*H / 2.0;
	cout << S << " " << can << "\n";
}

int main(){
    long long W;
    scanf("%lld",&W);
    long long H;
    scanf("%lld",&H);
    long long x;
    scanf("%lld",&x);
    long long y;
    scanf("%lld",&y);
    solve(W, H, x, y);
    return 0;
}


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


int main() {
    int N;
    cin >> N;
    int judge = 0;
    //配列の初期化
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0){
                judge = 1;
            }
        }
    }

    if(judge == 1){
        cout << "DENIED" << endl;
    }

    else{
        cout << "APPROVED" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main () {
	int balik, harga, a, b;
	scanf ("%d", &harga);
	if (harga % 1000 != 0) {
		a = harga / 1000;
		b = (a + 1) * 1000;
		balik = b - harga;
		printf ("%d", balik);
	}
	else printf ("0");
	
	
	return 0;
}

Measured memory_bytes: 1700
#include<iostream>
#include<cstdio>
#include<complex>
using namespace std;

typedef complex<double> Point;

Point project(Point a,Point b,Point c){
	c-=a; b-=a;
	double t=(c.real()*b.real()+c.imag()*b.imag())/abs(b);
	Point z=t/abs(b)*b+a;
	return z;
}

int main(){
	double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	Point p1(x1,y1),p2(x2,y2);
	int z;
	cin>>z;
	while(z--){
		double q1,q2;
		cin>>q1>>q2;
		Point p(q1,q2);
		Point y=project( p1,p2,p);
		printf("%.10lf %.10lf\n",2*y.real()-p.real(),2*y.imag()-p.imag());
	} 
	return 0;
}


Measured memory_bytes: 3352
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100025;
const int MOD = 1000000007;
typedef long long ll;
int eid,p[MAX_N];
ll dp[MAX_N][2];
struct edge{
    int v,next;
}e[MAX_N<<2];
void init(){
    memset(p,-1,sizeof(p));
    eid = 0;
}
void add(int u,int v){
    e[eid].v = v;
    e[eid].next =p[u];
    p[u] = eid++;
}
void dfs(int u,int fa){
    ll x = 1, y = 1;
    if(e[p[u]].next==-1&&e[p[u]].v == fa){
        dp[u][0] = dp[u][1] = 1;
        return ;
    }
    for(int i = p[u];i+1;i=e[i].next){
        int v = e[i].v;
        if(v==fa) continue;
        dfs(v,u);
        x = (x*((dp[v][0] + dp[v][1])%MOD))%MOD;
        y = (y*(dp[v][0]))%MOD;
    }
    dp[u][0] = x,dp[u][1] = y;
}
int main(){
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,a,b;
    init();
    scanf("%d",&n);
    for(int i = 1;i<n;++i){
        scanf("%d%d",&a,&b);
        add(a,b);
        add(b,a);
    }
    dfs(1,0);
    printf("%d\n",(dp[1][0]+dp[1][1])%MOD);
    return 0;
}

Measured memory_bytes: 11776
n=int(input())
mas=list(map(int,input().split()))
out=[]
mx=0
i=0
while i<n:
  if mx>n-i:
    break
  j=i
  ans=0
  while j<n-1:
    if mas[j]>=mas[j+1]:
      ans+=1
    else:
      break
    j+=1
  
  if ans>mx:
    mx=ans
  i+=ans+1
  
print(mx)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

ll calcNumOfCombination(ll n, ll r){
        ll num = 1;
        for(ll i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if (C - A + B > 0) cout << C - (A-B) << endl;
    else cout << 0 << endl;

}

Measured memory_bytes: 3584
int main(void){
 int a = 0;
 int b = 0;
 int c = 0;
 int d = 0;
 int i = 0;
 int j = 0;
    
 scanf("%d %d %d",&a,&b,&c);
  for(i = a;i<=b;i++){
   d = c%i;
   if(d==0){
    j++;
   }
  }
 printf("%d\n",j);
 return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	set<int> st;
	rep(i,N){
		int x; cin >> x;
		st.insert(x);
	}
	int x = st.size();
	if(x%2==0) x--;
	cout << x << endl;
}


Measured memory_bytes: 4992
#include <stdio.h>
int main(){
int n,ans;
char a[100000],last;
scanf("%d",&n);
scanf("%s",a);
last=a[0];
ans=n;
for(int i=1;i<n;i++){
if(a[i]=='x'&&last=='x'){
printf("%d\n",i);
return 0;
}
last=a[i];
}
printf("%d\n",n);
}

Measured memory_bytes: 2796
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

#define EPS (1e-7)
#define IINF ((int)1e9)

MY_NAMESPACE(testbed)
int main()
{
	ll modval = 1000000007;  // 10^9 + 7

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

	int n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> pos, neg;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] < 0)
			neg.push_back(a[i]);
		else
			pos.push_back(a[i]);
	}

	bool neg_answer = false;
	if (pos.size() == 0)
		neg_answer = (k % 2 == 1);
	else if (n == k)
		neg_answer = (neg.size() % 2 == 1);

	ll res = 1;
	if (neg_answer) {
		sort(a.begin(), a.end(), [](ll x, ll y) -> bool {
			return abs(x) < abs(y);
			});
		for (int i = 0; i < k; i++)
		{
			res *= a[i]; res %= modval; res += modval; res %= modval;
		}
	}
	else
	{
		sort(pos.begin(), pos.end());    // the biggest at last
		sort(neg.rbegin(), neg.rend());  // the biggest abs(negative) at last

		if (k % 2 == 1)
		{
			res = pos.back(); pos.pop_back();
		}

		vector<ll> multvals;
		while (pos.size() > 1)
		{
			ll multval = pos.back(); pos.pop_back();
			multval *= pos.back(); pos.pop_back();
			multvals.push_back(multval);
		}
		while (neg.size() > 1)
		{
			ll multval = neg.back(); neg.pop_back();
			multval *= neg.back(); neg.pop_back();
			multvals.push_back(multval);
		}
		sort(multvals.rbegin(), multvals.rend());

		for (int i = 0; i < k / 2; i++)
		{
			ll multval = multvals[i];
			multval %= modval;
			res *= multval;
			res %= modval;
		}
	}

	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 8180
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
		int total;
		int num;
	while (1){
		scanf("%d", &total);
		if (total == 0) return 0;
		for (int a = 0; a < 9; a++){
			scanf("%d", &num);
			total -= num;
		}
		printf("%d\n", total);
	}
	return 0;
}

Measured memory_bytes: 2528
/*
PROG: arc085d
LANG: C++
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
*/
#include <bits/stdc++.h>
 
using namespace std;
 
long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
void prints(string output)
{
	for (int i = 0; i < output.length(); i++)
	{		
		putchar(output[i]);
	}
	return;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound

#define SINF 10007
#define MOD 1000000007
#define INF 1000000861
#define LLINF 1000000000000000861ll
#define CO 1000861
#define EPS 0.000000000000001
#define PI 3.141592653589793
#define MAXN 2002

typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
int arr[MAXN];
bool seen[MAXN][2];
int dp[MAXN][2];

int solve(int u, bool turn)
{
	if (seen[u][turn])
	{
		return dp[u][turn];
	}
	seen[u][turn] = true;
	if (turn)
	{
		//first guy's turn
		for (int i = u + 1; i < N - 1; i++)
		{
			dp[u][1] = max(dp[u][1], solve(i, 0));
		}
		dp[u][1] = max(dp[u][1], abs(arr[N - 1] - arr[u]));
	}
	else
	{
		dp[u][turn] = 2 * INF;
		for (int i = u + 1; i < N - 1; i++)
		{
			dp[u][0] = min(dp[u][0], solve(i, 1));
		}
		dp[u][0] = min(dp[u][0], abs(arr[N - 1] - arr[u]));
	}
	return dp[u][turn];
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	srand(time(NULL));
	//	cout << fixed << setprecision(10);	
	//	cerr << fixed << setprecision(10);
	//	if (fopen("arc085d.in", "r"))
	//	{	
	//		freopen ("arc085d.in", "r", stdin);
	//		freopen ("arc085d.out", "w", stdout);
	//	}
	cin >> N;
	N += 2;
	for (int i = 0; i < N; i++)
	{
		cin >> arr[i];
	}
	cout << solve(1, 1) << '\n';
	return 0;
}


Measured memory_bytes: 512
import bisect
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
for i in range(n):
    a[i + 1] += a[i]
ans = 0
for i in range(n):
    a[i + 1] -= i + 1
    a[i + 1] %= k
d = dict()
for i, x in enumerate(a):
    if x in d:
        d[x].append(i)
    else:
        d[x] = [i]
ans = 0
for v in d.values():
    for i, x in enumerate(v):
        t = bisect.bisect_right(v, x + k - 1) - i - 1
        ans += t
print(ans)


Measured memory_bytes: 122952
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define mx *max_element
#define mi *min_element
#define fn for(long long int i =0 ;i <n;i++)
#define fn1 for(long long int i =1;i<=n;i++)
#define fm for(long long int j =0 ;j <m;j++)
#define fm1 for(long long int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6;
ll ar[N];
ll tree[2*N];
ll dp[N];
int main(){
	Fast;
	ll n ;
	cin >> n;
	fn{
	    cin >> ar[i];
	}
	memset(dp,N,sizeof(dp));
	dp[0]=0;
	fn{
	    for(int j : {i+1,i+2}){
	        if(j<n){
	            dp[j]=min(dp[j],dp[i]+abs(ar[j]-ar[i]));
	        }
	    }
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 10496
/*
g++ -std=c++11 -o2 -Wall Nikkei_B.cpp -o .\out\Nikkei_B.out
.\out\Nikkei_B.out
*/

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

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if(a[i] == b[i] && b[i] == c[i]) {
      ans += 0;
    } else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
      ans += 1;
    } else {
      ans += 2;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    cout << n*800 - (n/15*200) << endl; 
}

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

#define all(x) (x).begin(), (x).end()
#define make_unique(vec) sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define dbg(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

bool tests = false;

void solve(){
    int k; cin >> k;
    string str; cin >> str;
    if (str.size() <= k){
        cout << str << endl;
        return;
    }
    for (int i=0; i<k; i++){
        cout << str[i];
    }cout << "..." << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1;
    if (tests){
        cin >> t;
    }
    while (t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int MAX=2e5+7,MOD=1e9 + 7;
typedef long long int ll;
ll ispow5(ll x){
    for(ll i=-2000;i<=2000;i++){
        if( x == i*i*i*i*i)return i;
    }
    return -1e18;
}
void solve(){
    int x;cin>>x;
    for(ll i=-2000;i<=2000;i++){
        ll a = i;
        ll a_5 = a*a*a*a*a;
        ll b_5 = a_5 - x;
        ll b = ispow5(b_5);
        if(b!=-1e18 && a_5 - b_5 == x){
            cout<<a<<" "<<b<<endl;
            return;
        }
    }
}
int main (){
    int t=1;
    while(t--)solve();
    return 0;
}


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

int main()
{
    int x,i;
    for(i=1;i<=5;i++)
    {
        cin>>x;
        if(x==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}




Measured memory_bytes: 3544
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m>>k;
		// n=s.length();
		// ll a[n];
		swap(n,m);
		swap(n,k);
		
		cout<<n<<" "<<m<<" "<<k<<" ";

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

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

vector<long long> lun;

void solve(int k,int p,long long x){
	if(k==p && x>0)lun.push_back(x);
	else{
		if(p==0)for(int i=1;i<=9;i++)solve(k,p+1,i);
		else{
			int c=x%10;
			if(c>0)solve(k,p+1,x*10+c-1);
			solve(k,p+1,x*10+c);
			if(c<9)solve(k,p+1,x*10+c+1);
		}
	}
}

int main(){
	for(int i=1;i<=10;i++)solve(i,0,0);
	int K;
	cin >> K;
	cout << lun[K-1] << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
using namespace std;
int n, m, mn, mj, a[55], b[55], c[55], d[55];
int main() {
	int i, j, x;
	cin>>n>>m;
	for(i=1; i<=n; i++) cin>>a[i]>>b[i];
	for(j=1; j<=m; j++) cin>>c[j]>>d[j];
	for(i=1; i<=n; i++) {
		mn = 2e9;
		for(j=1; j<=m; j++) {
			x = (int)abs(a[i]-c[j]) + (int)abs(b[i]-d[j]);
			if(x<mn) mn = x, mj = j;
		}
		cout<<mj<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var cnmsd=arr.shift().split(" ").map(Number);
   if(cnmsd.join(" ")=="0 0 0 0 0")break;
   var c=cnmsd[0];
   var n=cnmsd[1];
   var m=cnmsd[2];
   var s=cnmsd[3];
   var d=cnmsd[4];
   var ary=[];
   for(var i=0;i<m;i++)ary.push(arr.shift().split(" ").map(Number));
   var dp=[];
   for(var i=0;i<=n;i++){
      dp[i]=[];
      for(var j=0;j<=c;j++){
         dp[i][j]=Infinity;
      }
   }
   dp[s][0]=0;
   var bomb=[s];
   var obj={};
   while(true){
      if(bomb.length==0)break;
      var S=bomb.shift();
      if(obj.hasOwnProperty(S))continue;
      obj[S]=true;
      ary.forEach(function(v){
         var a=v[0];
         var b=v[1];
         var f=v[2];
         if(a==S){
            dp[a].forEach(function(v,i){
               dp[b][i]=Math.min(dp[b][i],v+f);
               if(i<c)dp[b][i+1]=Math.min(dp[b][i+1],v+f/2);
            });
            bomb.push(b);
         }else if(b==S){
            dp[b].forEach(function(v,i){
               dp[a][i]=Math.min(dp[a][i],v+f);
               if(i<c)dp[a][i+1]=Math.min(dp[a][i+1],v+f/2);
            });
            bomb.push(a);
         }
      });
   }
   var ans=Infinity;
   dp[d].forEach(function(v){
      ans=Math.min(ans,v);
   });
   console.log(ans);
}

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

typedef long long ll;
vector<vector<int> > v(100007);
int n;
ll mod = 1e9+7;
ll dp[100007][2];
/*int answer(int a, int curr, vector<int> color){
	if(v[a].size() == 0) {return 1;}
	if(v[a].size() == 1 && color[v[a][0]] != -1) return 1;
	if(dp[a][curr] != -1){return dp[a][curr];}
	//if(dp[a] != -1) return dp[a];
	int ans = 1;
	//cout << "vertex " << a << " color : " << curr << endl;
	color[a] = 1;
	for(auto x : v[a]){
		if(color[x] == -1){
			color[x] = 1;
			if(curr == 0){
				ans *= (answer(x, 0, color) + answer(x, 1, color))%mod;
				ans %= mod;
			//	cout << ans << a << curr << endl;
			}
			else  {ans *= answer(x, 0, color); ans %= mod;}// cout << ans << a << curr << endl;}
		}
	}
	return dp[a][curr] = ans;
}
*/
ll answer1(int a, int curr, int par){
	if(v[a].size() == 0) {return 1;}
	//ll &ans = dp[a][curr];
	//if(v[a].size() == 1 && color[v[a][0]] ) return 1;
	//if(ans != -1){return ans;}
	if(dp[a][curr] != -1) return dp[a][curr];
	ll ans = 1LL;
	//cout << "vertex " << a << " color : " << curr << endl;
	//color[a] = 1;
	for(auto x : v[a]){
		if(x != par){
			//color[x] = 1;
			if(curr == 0){
				ans = (ans * ((answer1(x, 0, a) + answer1(x, 1, a))%mod))%mod;
				ans %= mod;
			//	cout << ans << a << curr << endl;
			}
			else  {ans *= answer1(x, 0, a); ans %= mod;}// cout << ans << a << curr << endl;}
			ans %= mod;
		}
	}
	return dp[a][curr] = ans;
}
int main(){
	cin >> n;
	int a, b;
	vector<int>color(n+1, -1);
	memset(dp, -1, sizeof(dp));
	//memset(color, -1, sizeof(color));
	for(int i=1; i<=n-1; i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
//cout << answer(1, 0, color) + answer(1, 1, color) << endl;
	ll ans = (answer1(1, 0, 0) + answer1(1, 1, 0)) % mod;
	cout << ans;
	return 0;
}



Measured memory_bytes: 16000
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N = 3e5 + 7;
int32_t main(){
    IOS;
    int n,k; 
    cin>>n>>k;
    int arr[n];
    for(int &x:arr) cin>>x;
    int dp[n];
	int i=0;
	while(i<=k&&i<n){
		dp[i] = abs(arr[i] - arr[0]);
		i++;
	}
	while(i<n){
		int ans = dp[i-1]+abs(arr[i]-arr[i-1]);
		for(int j=2;j<=k;j++) ans = min(ans, dp[i-j]+abs(arr[i] - arr[i-j]));
		dp[i] = ans;
		i++;
	}
	cout << dp[n-1];
     
    return 0;
}



Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010
#define A_max 1000000

int main()
{
    int N;
    cin >> N;
    vector<int> a(N),b(N);
    rep(i,N){
        cin >> a[i];
        b[i]=a[i];
    }

    ssort(b);
    int pre=INF;
    vector<bool> dp(A_max+1);
    rep(i,A_max+1){
        dp[i]=true;
    }
    rep(i,N){
        if(pre==b[i]){
            dp[b[i]]=false;
            pre=b[i];
        }else{
            int j=2;
            while(b[i]*j<=A_max){
                dp[b[i]*j++]=false;
            }
            pre=b[i];
        }
    }

    int count=0;
    rep(i,N){
        if(dp[a[i]]==true){
            count++;
        }
    }

    cout << count << endl;

    
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n;
    cin >> n;

    unordered_map<int64_t, int64_t> a;
    for (auto _ : irange(0L, n)) {
        int64_t aa;
        cin >> aa;
        ++a[aa];
    }

    for (auto i : irange(1L, 1000001L)) {
        if (!a.count(i)) {
            continue;
        }

        for (int64_t j = i * 2; j <= 1000000L; j += i) {
            a.erase(j);
        }

        if (a[i] > 1) {
            a.erase(i);
            continue;
        }
    }

    cout << a.size() << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int L[10];
string S[500];
//string SS[9][9*9*9+600];
int idx;
int iidx[9];
int N;

void dfs(int n, string s){
    if(n == N){
        S[idx++] = s;
        return;
    }
    dfs(n+1, s+"0");
    dfs(n+1, s+"1");
}

//void dfs2(int n, int m, string s){
//    if(n == m){
//        SS[m][iidx[m]++] = s;
//        return;
//    }
//    dfs2(n+1, m, s+"0");
//    dfs2(n+1, m, s+"1");
//    dfs2(n+1, m, s+"2");
//}

string calc(int k, int len){
    string ret = "";
    int keta = 0;
    while(k > 0){
        int n = k % 3;
        ret += '0'+n;
        k /= 3;
        keta++;
    }
    for(; keta < len; keta++){
        ret = "0" + ret;
    }
    return ret;
}

int main(){
    int A, B, C;
    cin >> N >> A >> B >> C;
    REP(i,N){
        int l;
        cin >> l;
        L[i] = l;
    }
    
    dfs(0, "");
    //for(int i = 0; i < pow(3,3); i++){
    //    cout << calc(i, 3) << endl;
    //}

    ll ans = LLONG_MAX;
    for(int i = 0; i < (1<<N); i++){
        //cout << S[i] << endl;
        vector<int> use;
        for(int j = 0; j < N; j++){
            if(S[i][j] == '1')
                use.push_back(j);
        }
        int len = use.size();
        if(len < 3) continue;


        for(int k = 0; k < pow(3, len); k++){
            ll num = 0;
            //string s = SS[len][k];
            string s = calc(k, len);
            //cout << len << " "  << k << " " << s << endl;
            int X,Y,Z;
            X = Y = Z = 0;
            int mgx, mgy, mgz;
            mgx = mgy = mgz = -1;

            for(int j = 0; j < len; j++){
                if(s[j] == '0'){
                    mgx++;
                    X += L[use[j]];
                }
                else if(s[j] == '1'){
                    mgy++;
                    Y += L[use[j]];
                }
                else if(s[j] == '2'){
                    mgz++;
                    Z += L[use[j]];
                }
            }
            if(mgx == -1 || mgy == -1 || mgz == -1) continue;

            num += 10*(mgx+mgy+mgz);

            int arr[3] = {C, B, A};
            int tmp = num;
            do{
                num = tmp;
                num += abs(arr[0]-X);
                num += abs(arr[1]-Y);
                num += abs(arr[2]-Z);
                ans = min(ans, num);
            }while(next_permutation(arr, arr+3));
        }

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


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

struct UnionFind {
  vector< int > par;
 
  UnionFind(int x) {
    par.assign(x, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return (false);
    if(par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return (true);
  }
 
  int find(int x) {
    if(par[x] < 0) return (x);
    return (par[x] = find(par[x]));
  }
 
  int size(int x) {
    return (-par[find(x)]);
  }
};

int main(){
    int N,M;
    cin>>N>>M;
    UnionFind T(N);

    for(int i=0; i<M; i++){
        int A,B;
        cin>>A>>B;
        A--,B--;
        T.unite(A,B);
    }

    int ans = 0;

    for(int i=0; i<N; i++){
        ans = max(T.size(i),ans);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4052
n = int(input())
L = list(map(int, input().split()))
result = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a = L[i]
            b = L[j]
            c = L[k]
            if a == b or b == c or c == a:
                continue
            if a+b > c and b+c > a and c+a > b:
                result += 1
                # print(i, j, k)

print(result)


Measured memory_bytes: 68084
#include <stdio.h>
#include <string.h>
int main(){
  char s[100];
  int i;
  int len=0;
  char c;
  while(1){
    scanf("%c",&c);
    if(c=='\n')break;
    else {
      if('a'<=c && c<= 'z')printf("%c",c-32);
      else printf("%c",c);
    }
  }
    printf("\n");
  return 0;
}

Measured memory_bytes: 520