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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 4e3 + 41;
int const INF = 1e9 + 41;

int n;
char col[MAX];
int val[MAX];
int posw[MAX];
int posb[MAX];

int d[MAX][MAX];

int sufw[MAX][MAX];
int sufb[MAX][MAX];

void init() {
	fi(0, MAX - 1) {
		fj(0, MAX - 1) {
			d[i][j] = INF;
		}
	}
	fi(1, n * 2) {
		if (col[i] == 'B') {
			posb[val[i]] = i;
		} else {
			posw[val[i]] = i;
		}
	}
	fdi(n * 2, 1) {
		memcpy(sufw[i], sufw[i + 1], sizeof(sufw[i]));
		memcpy(sufb[i], sufb[i + 1], sizeof(sufb[i]));
		fj(val[i], n) {
			if (col[i] == 'B') {
				sufb[i][j]++;
			} else {
				sufw[i][j]++;
			}
		}
	}	
}

void solve() {
	init();
	d[0][0] = 0;
	fi(0, n * 2 - 1) {
		fj(0, n) {
			if (d[i][j] == INF) continue;
			int w = j;
			int b = i - w;
			int nw = w + 1;
			int nb = b + 1;
			if (nw <= n) {
				int p = posw[nw];
				int np = p;
				np += sufw[p][nw - 1];
				np += sufb[p][nb - 1];
				int dist = np - i - 1;
				assert(dist >= 0);
				d[i	+ 1][j + 1] = min(d[i + 1][j + 1], d[i][j] + dist);
			}	
			if (nb <= n) {
				int p = posb[nb];
				int np = p;
				np += sufb[p][nb - 1];
				np += sufw[p][nw - 1];
				int dist = np - i - 1;
//				err("i = %d j = %d nw = %d nb = %d dist = %d\n", i, j, nw, nb, dist);
				assert(dist >= 0);
				d[i + 1][j] = min(d[i + 1][j], d[i][j] + dist);
			}
		}
	}
	printf("%d\n", d[n * 2][n]);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	scanf("%d", &n);
	fi(1, n * 2) {
		scanf(" %c %d", &col[i], &val[i]);		
	}  
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

Measured memory_bytes: 191616
def solve():
    import collections
    N = int(input())
    A = [int(i) for i in input().split()]
    counter = collections.Counter(A)
    combis = {}
    total = 0
    for k,v in counter.items():
        combi = v * (v-1) // 2
        combis[k] = combi
        total += combi
    for i in range(N):
        cnt = counter[A[i]]
        if cnt > 1:
            combi = (cnt-1) * (cnt-2) // 2
        else:
            combi = 0
        print(total - combis[A[i]] + combi)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 34368
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,ans=0,x;
  cin>>n;
  x=ceil(n/11.0);
  ans=x*2;
  if(x*11-n>=5)
    ans--;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<ll> c(n+1,0);
    rep(i,n-1){
        if (s[i] == 'A' && s[i+1] == 'C'){
            c[i+2]++;
        }
    }
    rep(i,n) c[i+1] += c[i];
    rep(i,q){
        ll l,r;
        cin >> l >> r;
        PRINT(c[r]-c[l]);
    }
}


Measured memory_bytes: 1872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_149
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] abk = ReadLongs();
            long a = abk[0];
            long b = abk[1];
            long k = abk[2];
            long remain = k;
            remain -= Min(a, k);
            a -= Min(a, k);
            b -= Min(b, remain);
            WriteLine(a + " " + b);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int maxn = 10005, maxm = 2000005, inf = 1000000007; 
using namespace std;
bool vis[maxn];
int n, N[5], bel[maxn], m, e, ter[maxm], nxt[maxm], lnk[maxn], w[maxm], dis[maxn][8], opt[maxn];
void add(int x, int y, int z) { ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e, w[e] = z; }
void spfa(int st) {
	int he = 0, ta = 0;
	rep(i, 1, n) vis[i] = true;
	rep(i, 1, n) if (dis[i][st] != inf) opt[++ ta] = i, vis[i] = false;
	for ( ; he != ta; ) {
		he = (he + 1) % maxn; int u = opt[he];
		for (int i = lnk[u]; i; i = nxt[i]) {
			if (dis[u][st] + w[i] < dis[ter[i]][st]) {
			dis[ter[i]][st] = dis[u][st] + w[i];
			if (vis[ter[i]]) vis[ter[i]] = false, ta = (ta + 1) % maxn, opt[ta] = ter[i];
		}
	}
		vis[u] = true;
	}
}
int main() {
	scanf("%d%d%d%d", &n, &N[1], &N[2], &N[3]); int x, las, y;
	rep(col, 1, 3) {
		las = 0;
		rep(i, 1, N[col]) {
			scanf("%d", &x), bel[x] = col;
			if (las) add(las, x, 0), add(x, las, 0);
			las = x;
		}
	}
	scanf("%d", &m);
	rep(i, 1, m) scanf("%d%d", &x, &y), add(x, y, 1), add(y, x, 1);
	rep(i, 1, n) rep(j, 0, 7) dis[i][j] = inf;
	rep(col, 1, 3) {
		int st = (1 << (col - 1));
		rep(i, 1, n) if (bel[i] == col) dis[i][st] = 0;
		spfa(st);
	}
	int st = 3;
	rep(i, 1, n) dis[i][st] = min(dis[i][1] + dis[i][2], inf);
	spfa(st);
	st = 5;
	rep(i, 1, n) dis[i][st] = min(dis[i][1] + dis[i][4], inf);
	spfa(st);
	st = 6;
	rep(i, 1, n) dis[i][st] = min(dis[i][2] + dis[i][4], inf);
	spfa(st);
	st = 7;
	rep(i, 1, n) 
		dis[i][st] = min(dis[i][st], min(dis[i][1] + dis[i][2], inf) + dis[i][4]),
		dis[i][st] = min(dis[i][st], dis[i][1] + dis[i][6]),
		dis[i][st] = min(dis[i][st], dis[i][2] + dis[i][5]),
		dis[i][st] = min(dis[i][st], dis[i][4] + dis[i][3]);
	spfa(st);
	int ans = inf, id = 0;
	rep(i, 1, n) 
		if (dis[i][7] < ans) {
			ans = dis[i][7], id = i;
		}
	printf("%d %d\n", ans, id); 
	return 0;
}

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

int main()
{
  string a;
  string b;
  cin >> a >> b;
  
  int num = 0;
  for (int i=0; i<a.length(); ++i) {
    if (a[i] != b[i]) {
      num++;
    }
  }
  
  cout << num;
    return 0;
}


Measured memory_bytes: 3848
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        k: usize,
        a: usize,
        b: usize,
    }

    for i in a..b+1{
        if i%k==0 {
            println!("OK");
            return;
        }
    }

    println!("NG");

}

Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
const int maxn=5e5+5;
using namespace std;
struct node{
    int x,y,index;
}N[maxn];
vector<int> ans;
bool cmpx(node n1,node n2){
    return n1.x<n2.x;
}
bool cmpy(node n1,node n2){
    return n1.y<n2.y;
}
void build_tree(int l,int r,int level){
    if(l<r){
        if(level&1){
            sort(N+l,N+r,cmpx);
        }
        else{
            sort(N+l,N+r,cmpy);
        }
        int root=(l+r)/2;
        build_tree(l,root,level+1);
        build_tree(root+1,r,level+1);
    }
}

void search_tree(int l,int r,int sx,int tx,int sy,int ty,int level){
   // cout<<l <<' '<<r<<endl;
    if(l<r){
       int root=(l+r)/2;
        if(level&1){
            if(N[root].x<=tx&&N[root].x>=sx){
                if(N[root].y<=ty&&N[root].y>=sy)ans.push_back(N[root].index);
                search_tree(l,root,sx,tx,sy,ty,level+1);
                search_tree(root+1,r,sx,tx,sy,ty,level+1);
            }
            else if(tx<N[root].x){
                search_tree(l,root,sx,tx,sy,ty,level+1);
            }
            else if(sx>N[root].x){
                search_tree(root+1,r,sx,tx,sy,ty,level+1);
            }
        }
        else{
            if(N[root].y<=ty&&N[root].y>=sy){
                if(N[root].x<=tx&&N[root].x>=sx)ans.push_back(N[root].index);
                search_tree(l,root,sx,tx,sy,ty,level+1);
                search_tree(root+1,r,sx,tx,sy,ty,level+1);
            }
            else if(ty<N[root].y){
                search_tree(l,root,sx,tx,sy,ty,level+1);
            }
            else if(sy>N[root].y){
                search_tree(root+1,r,sx,tx,sy,ty,level+1);
            }
        }
    }

}
int main(){
   // freopen("in.txt","r",stdin);
    int kase;
    scanf("%d",&kase);
    for(int i=0;i<kase;i++){
        scanf("%d%d",&N[i].x,&N[i].y);
        N[i].index=i;
    }
    build_tree(0,kase,0);
    int Q;
    scanf("%d",&Q);
    for(int i=0;i<Q;i++){
        ans.clear();
        int sx,tx,sy,ty;
        scanf("%d%d%d%d",&sx,&tx,&sy,&ty);
        search_tree(0,kase,sx,tx,sy,ty,0);
        sort(ans.begin(),ans.end());
        for(int j=0;j<ans.size();j++)printf("%d\n",ans[j]);
        printf("\n");
    }
}



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

long long oddsolve(long long a) { return (a+1)/2 % 2; }
long long solve(long long a) {
    if (a % 2 == 1) return oddsolve(a);
    else return oddsolve(a+1) ^ (a+1);
}
int main() {
    long long A, B; cin >> A >> B;
    cout << (solve(B) ^ solve(A-1)) << endl;
}

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

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

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        double ave = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            ave += x;
            list.add(x);
        }

        ave = Math.round(ave / n);

        long result = 0;
        for (int i = 0; i < n; i++) {
            result += Math.pow(list.get(i) - ave, 2);
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int C = scanner.nextInt();
    int D = scanner.nextInt();
    if ((A + D - 1) / D >= (C + B - 1) / B) System.out.println("Yes");
    else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 35764
#include<iostream>
using namespace std;
int main()
{
    long long q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    if ( q * 4 < s )
        s = q * 4;
    if ( h * 2 < s )
        s = h * 2;
    if ( s * 2 < d )
        d = s * 2;
    if ( n % 2 == 1 )
        cout<<d * ( n / 2 ) + s;
    else
        cout<<d * ( n / 2 );
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

coins = [10000, 5000, 1000]

ans = []
def dfs(sum_v, now, i):
    if len(ans) != 0:
        return

    used = sum(now)

    if len(now) == 3:
        if sum_v == Y:
            ans.append(now)
        return

    if sum_v + coins[i] * (N - used) < Y:
        return

    if sum_v > Y:
        return

    if i == 2:
        ne = now + [N - used]
        dfs(sum_v + coins[i] * (N - used), ne, i + 1)
    else:
        for j in range(N - used + 1):
            ne = now + [j]
            dfs(sum_v + coins[i] * j, ne, i + 1)

dfs(0, [], 0)
if len(ans) == 0:
    print("-1 -1 -1")
else:
    print(" ".join(map(str, ans[0])))


Measured memory_bytes: 3064
#include <stdio.h>

int main (){
	int N;
	scanf ("%d", &N);
	
	if (N % 10 == 7 || (N/10)%10 == 7 || N /100 == 7){
		puts ("Yes");
	}
	else {
		puts ("No");
	}
	return 0;
}

Measured memory_bytes: 1664
#include <cstdio>

using namespace std;

int a[10];

bool dfs(int i, int l, int r)
{
	if (i == 10) return true;

	if (l < a[i] && dfs(i + 1, a[i], r)) return true;
	if (r < a[i] && dfs(i + 1, l, a[i])) return true;

	return false;
}

int main()
{
	int n; scanf("%d", &n);

	while (n--) {
        for (int i = 0; i < 10; ++i) scanf("%d", &a[i]);
        printf("%s\n", (dfs(0, 0, 0) ? "YES" : "NO"));
	}
}

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




int main()
{	
	ll n;
	cin>>n;
	string s;
	cin>>s;
	s+='0';
	ll ans=0;
	for(ll i=0;i<s.size()-1;i++)if(s[i]!=s[i+1])ans++;
	
	cout<<ans;
}

Measured memory_bytes: 512
def main():
    n,t=map(int,input().split())
    ab=[list(map(int,input().split())) for _ in [0]*n]
    ab.sort(key=lambda x:x[0])
    dp=[0]*(t+1)
    for a,b in ab:
        for i in range(t-1,-1,-1):
            if a+i>=t:
                dp[t]=max(dp[t],dp[i]+b)
            else:
                dp[i+a]=max(dp[i+a],dp[i]+b)
    print(max(dp))
main()

Measured memory_bytes: 44268
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin>>h>>w;
	char a[100][100];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<=1+w;i++){
		cout<<'#';
	}
	cout<<endl;
	for(int i=0;i<h;i++){
		cout<<'#';
		for(int j=0;j<w;j++){
			cout<<a[i][j];
		}
		cout<<'#'<<endl;
	}
	for(int i=0;i<=1+w;i++){
		cout<<'#';
	}
	cout<<endl;
}


Measured memory_bytes: 256
a = [input().split() for l in range(3)]
n = int(input())
b = list(input() for i in range(n))
c = [[0] * 3 for i in range(3)]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                c[j][k] = 1

if (c[0][0] == 1 and c[0][1] == 1 and c[0][2] == 1) or(c[1][0] == 1 and c[1][1] == 1 and c[1][2] == 1) or(c[2][0] == 1 and c[2][1] == 1 and c[2][2] == 1) or(c[0][0] == 1 and c[1][0] == 1 and c[2][0] == 1) or(c[0][1] == 1 and c[1][1] == 1 and c[2][1] == 1) or(c[0][2] == 1 and c[1][2] == 1 and c[2][2] == 1) or(c[0][0] == 1 and c[1][1] == 1 and c[2][2] == 1) or (c[0][2] == 1 and c[1][1] == 1 and c[2][0] == 1):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9276
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


n=int(input())
f=make_divisors(n)
f1=set(make_divisors(n-1))
f.remove(1)
f1.remove(1)

for i in f:
    if (n//i)%i==0:
        _n=n//i
        while _n%i==0:
            _n//=i
        if _n%i==1:
            f1.add(i)

    elif (n//i)%i==1:
        f1.add(i)

print(len(f1))

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int prime[15000];
bool is_prime[150000];

void prime_judge(){
  int p=0;
  rep(i,150000)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<150000;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=i*2;j<=150000-1;j+=i)is_prime[j]=false;
    }
  }
}


int binary_search(int n){
  int l=0,r=13848;
  int i;
  while(r-l>=1){
    i=(l+r)/2;
    if(prime[i]==n)return i+1;
    else if(prime[i]<n) l=i+1;
    else r=i;
  }
  if(prime[i]<n)i++;
  return i;
}

void matuzaki(int n,int p){
  vi v;
  int near=binary_search(n);
  for(int i=near;i<=near+21;i++){
    for(int j=i;j<=near+21;j++){
      v.pb(prime[i]+prime[j]);
    }
  }
  sort(all(v));
  printf("%d\n",v[p-1]);
}

int main(){
  int n,p;
  prime_judge();
  while(1){
    scanf("%d%d",&n,&p);
    if(n==-1&&p==-1)break;
    matuzaki(n,p);
  }
  return 0;
}

Measured memory_bytes: 3312
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
      #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
       ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
      #    # #   #  #              #    # #      #    # #    # #    # #      #   #
       ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<long long> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LLi i = 0; i < (n); i++)
#define FOR(in) for(LLi i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 

 
 
int main()
{
	
	string a,b,c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[0]<<c[0]<<endl;
	
			
    exit()
 
 
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int dp[3][100005];

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

    int N;
    cin>>N;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; i++) {
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < N; i++) {
        dp[0][i] = a[i] + max(dp[1][i-1], dp[2][i-1]);
        dp[1][i] = b[i] + max(dp[0][i-1], dp[2][i-1]);
        dp[2][i] = c[i] + max(dp[0][i-1], dp[1][i-1]);
    }
    cout << max(max(dp[0][N-1], dp[1][N-1]), dp[2][N-1]) <<endl;

    return 0;
}

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

const int N = 3005;
double dp[N][N];
bool vis[N][N];
double prob[N];
int n;

double rec(int pos,int h)
{
    if(pos==n+1)
    {
        if(h>n/2) return 1.0;
        return 0.0;
    }
    double &ret=dp[pos][h];
    if(vis[pos][h]) return ret;
    vis[pos][h]=1;
    ret=0;
    ret+=prob[pos]*rec(pos+1,h+1);
    ret+=(1.0-prob[pos])*rec(pos+1,h);
    return ret;
}


int main()
{
   scanf("%d",&n);
   for(int i=1; i<=n; i++) scanf("%lf",&prob[i]);
   printf("%.12f\n",rec(1,0));

}


Measured memory_bytes: 79744
#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>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	string s; cin >> s;
	map<char, int> ans;
	if (s.size() % 2 == 1 || s.size() < 2) {
		cout << "No" << endl;
		return;
	}
	for (int i = 0; i + (n / 2) < n; ++i) {
		if (s[i] != s[i + (n / 2)]) {
			cout << "No" << endl;
			return;
		}
	}
	cout << "Yes" << endl;
	return;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#define LL long long
#define MAXN 110
#define debug(x) cerr << #x << " " << x << endl
using namespace std;

inline int read() { int x = 0, f = 1; char ch = getchar();
    for(; !isdigit(ch); ch = getchar()) f = ch == '-' ? -1 : 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; return x * f;
}

const int MOD = 1e9 + 7;int n;
int p[MAXN];

int main() {
    n = read();int maxx = 0, maxi;

    for(int i = 1; i <= n; ++i) {
        p[i] = read();
        if(maxx < p[i]){
            maxx = p[i];
            maxi = i;
        }
    }
    int sum = 0;
    for(int i = 1; i <= n; ++i) {
        if(i == maxi) {
            sum += p[i] / 2;
        }
        else
            sum += p[i];
    }
    cout << sum << 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)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
    cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	ll ans = a[0];
	for(int i = 1; i < n; ++i){
		ans = gcd(ans, a[i]);
	}
	cout << ans << endl;
	return 0;
}



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



namespace Test1 {

    class ClassMain {

        public static void Main(String[] args) {
            string line;

            while ((line = Console.ReadLine())!=null) {
                int n = int.Parse(line); if (n == 0) { break; }
                int cnt = 0;
                while (n != 1) {
                    if (n % 2 == 0) { n /= 2; }
                    else { n = n * 3 + 1; }
                    cnt++;
                }
                Console.WriteLine(cnt);


            }
        }
        
    }
}

Measured memory_bytes: 5596
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

ll calc_cost(PLL a, PLL b) {
    ll af, as, bf, bs;
    tie(af, as) = a;
    tie(bf, bs) = b;
    return abs(af - bf) + abs(as - bs);
}

int main() {
    ll H, W, D;
    cin >> H >> W >> D;
    V<PLL> field(H * W);
    for(ll i = 0; i < H; i++) for(ll j = 0; j < W; j++) {
        ll a;
        cin >> a;
        field[a - 1] = make_pair(i, j);
    }
    
    auto sum = make_v((ll)0, D, H * W / D + 10);
    for(ll i = 0; i < D; i++) {
        for(ll j = 0; i + (j + 1) * D < H * W; j++) {
            ll now = i + j * D;
            ll nxt = i + (j + 1) * D;
            sum[i][j + 1] = sum[i][j] + calc_cost(field[now], field[nxt]);
        }
    }

    ll Q;
    cin >> Q;
    while(Q--) {
        ll l, r;
        cin >> l >> r;
        l--;
        r--;
        ll i = l % D;
        ll ld = l / D;
        ll rd = r / D;
        cout << sum[i][rd] - sum[i][ld] << endl;
    }
    return 0;
}


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

int main(){
    string S, T;
    int N;
    cin>>N>>S;
    T= S.substr(0, N/2);
    if(T+T == S){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int F[N][10], P[N][11];
	rep(i, 0, N) rep(j, 0, 10) {
		cin >> F[i][j];
	}
	rep(i, 0, N) rep(j, 0, 11) cin >> P[i][j];

	int res = -(1 << 30);
	for(int bit = 1; bit < 1 << 10; bit++) {
		int tmp = 0;
		for(int n = 0; n < N; n++) {
			int idx = 0;
			for(int i = 0; i < 10; i++) {
				if((bit & 1 << i) && F[n][i] == 1) idx++;
			}
			tmp += P[n][idx];
		}
		res = max(res, tmp);
	}

	cout << res << endl;


	

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
const int MAX=1e6+1;

typedef long long Int;

Int cnt(int& p);

Int get_num(int& p){
  int res=0;
  while(isdigit(s[p])){
    res*=10;
    res+=(s[p]-'0');
    p++;
  }
  return res;
}

Int cnt_large(int& p){
  Int res=0;
  while(s[p]!=')'){
    Int val=cnt(p);
    res+=val;
    if(res>MAX) res=MAX;
  }
  return res;
}


Int cnt(int& p){
  if(isalpha(s[p])){
    p++;
    return 1;
  }
  if(isdigit(s[p])){
    Int num=get_num(p);
    if(isalpha(s[p])){
      p++;
      return num;
    }
    assert(s[p]=='(');
    p++;
    Int val=cnt_large(p);
    assert(s[p]==')');
    p++;
    if(val>MAX){
      return MAX;
    }
    if(num*val>MAX) return MAX;
    return num*val;
  }
  return -1000000;
}

char target(int &p,Int x){
  while(p<s.size()){
    int prep=p;
    Int val=cnt(p);
    if(val>=x){
      p=prep;
      if(isalpha(s[p])){
	return s[p];
      }
      Int num=get_num(p);
      if(isalpha(s[p])){
	return s[p];
      }
      assert(s[p]=='(');
      p++;
      int prep2=p;
      Int val2=cnt_large(p);
      p=prep2;
      return target(p,(x%val2==0) ? val2 : x%val2);
    }
    x-=val;
  }
  return '0';
}

int main(){
  int n;
  while(cin>>s>>n,s!="0"){

  int p=0;
  cout<<target(p,n+1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)


int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL
	int n;
	int sum = 0;
	scanf("%d", &n);
	while (n-- ){
		int t;
		scanf("%d", &t);
		sum += t - 1;
	}
	printf("%d\n", sum);

	return 0;
}

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

using namespace std;
using ll = long long;
const int INF = 1 << 30;

int main() {
    int N = 0;
    cin >> N;
    int K = 0;
    cin >> K;
    vector<int> A(N*2,0);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> ans(2*N,INF);
    ans.at(0) = 0;
    for (size_t i = 0; i < N+1; i++)
    {
        for (size_t j = 1; j < K+1; j++)
        {
            if (i+j>N)
            {
                continue;
            }
            
            ans.at(i+j) = min(ans.at(i) + abs(A.at(i+j)-A.at(i)),ans.at(i+j));
        }
        
    }
    cout << ans.at(N-1) << endl;
    

    return 0;
}

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

using namespace std;

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=1;i<1001;i++){
        int n = i*k;
        if(a<=n&&n<=b){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

	if (a == b) cout << "Draw" << endl;
	else if (a == 1) cout << "Alice" << endl;
	else if (b == 1) cout << "Bob" << endl;
	else if (a > b) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}


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

int main() {
    size_t N;
    cin >> N;
    size_t min_val = pow(10, 9);
    size_t max_val = 1;
    for (size_t i = 0; i < N; i++) {
        size_t target;
        cin >> target;
        if (target < min_val) min_val = target;
        if (max_val < target) max_val = target;
    }
    cout << max_val - min_val << endl;
    return 0;
}


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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= 0x3f3f3f3f;
void solve(){
int n;
sl(n);
Vl arr(n);
bool check=true;
for(auto &it:arr){
	sl(it);
	if(it%2==0){
		if(!(it%3==0 || it%5==0)){
		  check=false;
	  }
  }
}
if(check)cout<<"APPROVED"<<endl;
else cout<<"DENIED"<<endl;




}

signed main(){
   int test=1;
   //sl(test);
   while(test--){
      solve();

   }
  return 0;
}


Measured memory_bytes: 256
long a[16][16],dp[1<<16],sum[1<<16];
i,j,I;
main(n)
{
	scanf("%d",&n);
	for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%ld",a[i]+j);
	for(I=0;I<1<<n;I++)
	{
		for(i=0;i<n;i++)for(j=0;j<n;j++)if(I&1<<i&&I&1<<j)sum[I]+=a[i][j];
		//for(j=I;~j;dp[I]=fmax(dp[I],dp[j]+sum[I&~j--]/2))j&=I;
		//for(j=I;j;j=j-1&I)dp[I]=fmax(dp[I],dp[I&~j]+sum[j]/2);
		for(j=I;j;j&=I)dp[I]=fmax(dp[I],dp[I&~j]+sum[j--]/2);
	}
	printf("%ld",dp[I-1]);
}


Measured memory_bytes: 1280
N, W = map(int, input().split())
goods = [list(map(int, input().split())) for i in range(N)]
dp = [[0]*(N+1) for i in range(W+1)]
for i in range(W):
    for j in range(N):
        if i+1 >= goods[j][0]:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i+1-goods[j][0]][j]+goods[j][1])
        else:
            dp[i+1][j+1] = dp[i+1][j]
print(dp[W][N])

Measured memory_bytes: 130780
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; string s; cin >> s; vl num(27); ll ans = 1;
  
  rep(i,n){
    rep(j,27){
      if(small[j] == s[i]){
        num[j]++;
      }
    }
  }
  
  rep(i,27){
    ans *= num[i]+1;
    ans = mod(ans);
  }
  
  cout << ans - 1 << endl;
  
}

Measured memory_bytes: 3716
import java.util.Scanner


object Main {

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val s = sc.next()
    val nLose = s.count(c => c=='x')

    val result = if(nLose <= 7) "YES" else "NO"

    println(result)
  }
}

Measured memory_bytes: 27440
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String c = sc.next();
    String ans = "A";
    if (c.equals("A")){ans = "T";}
    if (c.equals("T")){ans = "A";}
    if (c.equals("C")){ans = "G";}
    if (c.equals("G")){ans = "C";}
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    int H, W, N; cin >> H >> W >> N;
    int sh, sw; cin >> sh >> sw;
    string S; cin >> S;
    string T; cin >> T;
    string SS;
    for (int i = 0; i < N; i++) {
        SS.push_back(S[i]);
        SS.push_back('#');
    }
    for (int i = 0; i < N; i++) {
        SS[2*i+1] = T[i];
    }
    
    int lh = 1;
    int uh = H;
    int lw = 1;
    int uw = W;
    
    int ans = 1;
    for (int i = 2*N-1; 0 <= i; i--) {
        if (i%2) {
            if (SS[i] == 'U') {
                uh++;
                uh = min(H, uh);
            }
            if (SS[i] == 'D') {
                lh--;
                lh = max(1, lh);
            }
            if (SS[i] == 'L') {
                uw++;
                uw = min(W, uw);
            }
            if (SS[i] == 'R') {
                lw--;
                lw = max(1, lw);
            }
        } else {
            if (SS[i] == 'U') {
                lh++;
            }
            if (SS[i] == 'D') {
                uh--;
            }
            if (SS[i] == 'L') {
                lw++;
            }
            if (SS[i] == 'R') {
                uw--;
            }
        }
        if (uh - lh < 0 || uw - lw < 0) ans = 0;
    }
    if (!(lw <= sw && sw <= uw && lh <= sh && sh <= uh)) ans = 0;
    
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1292
H,W = [int(s) for s in input().split()]
dp = [[0]*(1001) for _ in range(1001)]
dp[0][0] = 1

a = [[0]*W for _ in range(H)]
for i in range(H):
    lis = list(input())
    for j in range(W):
        a[i][j] = lis[j]

for i in range(H):
    for j in range(W):
        if i+1 < H and a[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
        if j+1 < W and a[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
ans = dp[H-1][W-1]%(10**9+7)
print(ans)

Measured memory_bytes: 285188
#include<bits/stdc++.h>
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<int(N);I++)
#define REPP(I, N) for(int I=1;I<=int(N);I++)
#define ll long long
#define SZ(x) (int)(x).size()
#define F first
#define S second
#define PB(x) push_back(x)
#define N 100000
#define modn 1000000007
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
using namespace std;
typedef pair<int,int> P;
map<int,bool> mp;
vector<int> vct;
int n,m,u,v;
int main(void){
	RII(n,m);
	REP(i,m){
		RII(u,v);
		if(u==1) mp[v] = true;
		if(v==n) vct.PB(u);
	}
	for(auto it:vct){
		if(mp[it]){
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
}

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

int ri() {
    int n;
    scanf("%d", &n);
    return n;
}
int main() {
	int n = ri(), k = ri();
	std::string s;
	std::cin >> s;
	for (auto &c : s) c -= '0';
	int dp[n + 1];
	for (int i = 0; i <= n; i++) dp[i] = 1000000000;
	dp[n] = 0;
	for (int i = n; i; ) {
		int ind = -1;
		for (int j = i - 1; j >= i - k && j >= 0; j--) {
			if (!s[j]) dp[j] = dp[i] + 1, ind = j;
		}
		if (ind != -1) i = ind;
		else break;
	}
	if (dp[0] == 1000000000) {
		std::cout << -1 << std::endl;
		return 0;
	}
	int head = 0;
	std::vector<int> res;
	while (head < n) {
		int cnt = 0;
		int org_head = head;
		while (dp[head] >= dp[org_head]) head++, cnt++;
		res.push_back(cnt);
	}
	for (auto i : res) std::cout << i << " ";
	std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 1528
N=int(input())
a=[0]+[int(i) for i in input().split()]
par=[0 for i in range(N+1)]
size=[0 for i in range(N+1)]
def find(x):
    if (par[x]==x):
        return x
    par[x]=find(par[x])
    return par[x]
def unite(x,y):
    x=find(x)
    y=find(y)
    res=size[x]*size[y]
    size[x]+=size[y]
    par[y]=x
    return res
for i in range(N+1):
    par[i]=i
    size[i]=1
b=[0 for i in range(N+1)]
for i in range(N+1):
    b[a[i]]=i
ans=0
for j in range(1,N+1)[::-1]:
    i=b[j]
    ans+=a[i]
    if i-1>=1 and a[i-1]>a[i]:
        ans+=unite(i-1,i)*a[i]
    if i+1<=N and a[i+1]>a[i]:
        ans += unite(i+1,i)*a[i]
print(ans)

Measured memory_bytes: 29604
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>

using namespace std;

const int inf = 1e9;
vector<vector<int>> min_distance;

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

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

	cout << (a ^ b ^ c) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int w, h, n; cin >> w >> h >> n;
	vector<vi> pos(h + 1);
	rep(i, n){
		int x, y; cin >> x >> y;
		pos[y].pb(x);
	}
	rep(i, h + 1){
		pos[i].pb(w + 1);
		sort(all(pos[i]));
	}
	
	int x = 1, y = 1, ans = w;
	while(1){
		int k = lower_bound(all(pos[y]), x) - pos[y].begin();
		ans = min(ans, pos[y][k] - 1);
		
		if(pos[y][k] == ++x) break;
		
		if(y < h && !binary_search(all(pos[y + 1]), x)) y++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11392
#include<stdio.h>
#include<stdlib.h>
int a[3],i;
int comp(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) return -1;
    else if ( *val1 == * val2 ) return 0;
    else return 1;
}
int main()
{
    for((scanf("%d",&i));i>0;i--)
    {
        scanf("%d %d %d",&a[0],&a[1],&a[2]);
        qsort(a,3,sizeof(int),(int (*)(const void *,const void *))comp);
        a[0] = a[0]*a[0];
        a[1] = a[1]*a[1];
        a[2] = a[2]*a[2];
        if(a[2]==a[0]+a[1]) printf("YES\n");
        else printf("NO\n");
    }
}

Measured memory_bytes: 584
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var H = Scanner.Scan<long>();
            var answer = 0L;
            var depth = 0;
            while (H > 0)
            {
                H /= 2;
                answer += 1L << depth++;
            }
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28372
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
using ll = long long;
const ll MOD=1000000007;

ll n, m, a, b, add, ans, A[101010], B[101010];
string s, str;
int main() {
	cin >> s;
	rep(i, s.size()) {
		A[s[i] - 'a']++;
	}
	rep(i, 30) {
		if (A[i] % 2 == 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline

n, m, l = map(int, input().split())

def warshall_floyd(dp):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k][j])
    return dp

dp = [[float('inf')]*n for _ in range(n)]

for _ in range(m):
    a, b, c = map(int,input().split())
    dp[a-1][b-1] = dp[b-1][a-1] = c

for i in range(n):
    dp[i][i] = 0

dp = warshall_floyd(dp)

dp2 = [[float('inf')]*n for _ in range(n)]

for i in range(n):
    for j in range(n):
        if dp[i][j] <= l:
            dp2[i][j] = 1
    dp2[i][i] = 0
dp2 = warshall_floyd(dp2)

q = int(input())

ans = [0]*q
for i in range(q):
    s, t = map(int,input().split())
    tmp = dp2[s-1][t-1]
    ans[i] = -1 if tmp == float('inf') else tmp - 1

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


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

int a[3];

int main()
{
	in >> a[0] >> a[1] >> a[2];

	std::sort(a, a + 3);
	if (a[0] == a[1] && a[1] == a[2])
	{
		out << 1 << std::endl;
	}
	else if (a[0] == a[1] || a[1] == a[2])
	{
		out << 2 << std::endl;
	}
	else
	{
		out << 3 << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256