akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
const long INF = 10000000000000;

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

    vector<long> s, t;
    s.push_back(-1*INF);
    t.push_back(-1*INF);
    for(int i=0; i<A; i++){
        long a;
        cin >> a;
        s.push_back(a);
    }
    for(int i=0; i<B; i++){
        long b;
        cin >> b;
        t.push_back(b);
    }
    s.push_back(INF);
    t.push_back(INF);

    long x[Q];
    for(int i=0; i<Q; i++){
        cin >> x[i];
    }

    long ans[Q];
    for(int i=0; i<Q; i++){
        ans[i] = 100000000000000;

        auto sind = lower_bound(s.begin(), s.end(), x[i]);
        auto tind = sind;
        vector<long> sl;
        sl.push_back(*sind);
        sl.push_back(*(--sind));
        for(auto se : sl){
            tind = lower_bound(t.begin(), t.end(), se);
            ans[i] = min(ans[i], abs(x[i]-se)+abs(se-(*tind)));
            tind--;
            ans[i] = min(ans[i], abs(x[i]-se)+abs(se-(*tind)));
        }

        tind = lower_bound(t.begin(), t.end(), x[i]);
        vector<long> tl;
        tl.push_back(*tind);
        tl.push_back(*(--tind));
        for(auto te : tl){
            sind = lower_bound(s.begin(), s.end(), te);
            ans[i] = min(ans[i], abs(x[i]-te)+abs(te-(*sind)));
            sind--;
            ans[i] = min(ans[i], abs(x[i]-te)+abs(te-(*sind)));
        }
    }

    for(int i=0; i<Q; i++){
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4596
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

inline int read() 
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();}
    return x * f;
}

inline void write(int x)
{
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9) 
		write(x/10);
    putchar(x%10+'0');
}

char c[100000005];
__int128 tmp=0;
int main()
{
	scanf("%s",c+1);
	for (int i=1;i<=strlen(c+1);i++)
	{
		tmp+=c[i]-'0';
		if (tmp%9==0) tmp=0;
	}
	if (tmp%9==0) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 3872
#include <cmath>
#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 N = 505, M = 1e7, E = N * N * 2, inf = 1e9 + 7 ;
using namespace std ;

int n, pr[M], a[N], s, t, e, ter[E], nxt[E], lnk[N], w[E], rec[E], cur[N], dis[N], opt[N] ;
bool vis[M + 5] ;

void pre() {
	rep(i, 1, M) vis[i] = true ; 
	rep(i, 2, M) {
		if (vis[i]) pr[++ pr[0]] = i ;
		for (int j = 1; j <= pr[0] && (ll) i * pr[j] <= M ; ++ j) {
			vis[i * pr[j]] = false ;
			if (i % pr[j] == 0) break ;
		}
	}
	vis[1] = vis[2] = false ;
}

void add(int x, int y, int z) {
	ter[++ e] = y, nxt[e] = lnk[x], lnk[x] = e, w[e] = z, rec[e] = e + 1 ;
	ter[++ e] = x, nxt[e] = lnk[y], lnk[y] = e, w[e] = 0, rec[e] = e - 1 ;
}

bool bfs() {
	rep(i, s, t) dis[i] = inf ;
	dis[s] = 0 ;
	int he = 0, ta = 1 ;
	opt[1] = s ;
	for ( ; he != ta ; ) {
		++ he ; 
		int u = opt[he] ;
		for (int i = lnk[u]; i; i = nxt[i]) if (dis[ter[i]] == inf && w[i]) {
			dis[ter[i]] = dis[u] + 1 ;
			opt[++ ta] = ter[i] ;
		}
	}
	return dis[t] < inf ;
}

int dfs(int p, int sum) {
	if (p == t) return sum ;
	int res = 0 ;
	for (int i = cur[p] ; i; i = nxt[i]) if (dis[ter[i]] == dis[p] + 1 && w[i]) {
		int tmp = dfs(ter[i], min(sum - res, w[i])) ;
		res += tmp, w[i] -= tmp, w[rec[i]] += tmp ;
		if (w[i]) cur[p] = i ;
		if (res == sum) return res ;
	}
	return res ;
}

int dinic() {
	int res = 0 ;
	for ( ; bfs() ; ) {
		rep(i, s, t) cur[i] = lnk[i] ;
		res += dfs(s, inf) ;
	}
	return res ;
}

int main() {
	pre() ;
	scanf("%d", &n) ;
	int las , p, cnt[2] = {0} ;
	scanf("%d", &las) ;
	a[++ a[0]] = las ;
	rep(i, 2, n) {
		scanf("%d", &p) ;
		if (p != las + 1) { a[++ a[0]] = las + 1, a[++ a[0]] = p ; } 
		las = p ;
	}
	a[++ a[0]] = las + 1 ;
	rep(i, 1, a[0]) ++ cnt[a[i] & 1] ;
	s = 0, t = a[0] + 1 ;
	rep(i, 1, a[0]) if (a[i] & 1) add(s, i, 1) ; else add(i, t, 1) ;
	rep(i, 1, a[0]) if (a[i] & 1) rep(j, 1, a[0]) if (!(a[j] & 1) && vis[abs(a[i] - a[j])]) add(i, j, 1) ;
	int k = dinic() ;
	int ans = k + (cnt[0] - k) / 2 * 2 + (cnt[1] - k) / 2 * 2 + (cnt[0] - k) % 2 * 3 ;
	printf("%d\n", ans) ;
	return 0 ;
}


Measured memory_bytes: 20736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

int main() {
    
    int k;
    cin >> k;
    int o,e;
    if(k/2 * 2 ==k){
        o=k/2;
        e=k/2;
    }else{
        o=k/2+1;
        e=k/2;
    }
    int ans = o*e;
    
    cout << ans <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


int main() {

	ll N;
	cin >> N;

	vector<ll> a(N);
	rep(i, N) cin >> a[i];

	string ans = "Yes";

	if (N % 3 != 0) { 
		rep(i, N) {
			if (a[i] != 0) { ans = "No"; }
		}
		 }
	else {

		ll M = N / 3;
		sort(a.begin(), a.end());

		rep(i, N) {
			ll j = i % M;
			if (a[i] != a[i - j]) { ans = "No"; }
			//cout << a[i] << a[i - j];
		}

		if ((a[0] ^ a[M]) != a[2 * M]) { ans = "No"; }
	}
	
	cout << ans;
	system("PAUSE");

}





Measured memory_bytes: 1272
N=int(input())
a=[[0 for i in range(N)] for j in range(3)]
for i in range(N):
    a[0][i],a[1][i],a[2][i]=map(int,input().split())
dp=[[0 for i in range(N)] for j in range(3)]
dp[0][0]=a[0][0]
dp[1][0]=a[1][0]
dp[2][0]=a[2][0]
for i in range(1,N):
    dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[0][i]
    dp[1][i]=max(dp[2][i-1],dp[0][i-1])+a[1][i]
    dp[2][i]=max(dp[0][i-1],dp[1][i-1])+a[2][i]
print(max(dp[0][N-1],dp[1][N-1],dp[2][N-1]))

Measured memory_bytes: 26856
#include <iostream>
#include <cstdio>
#define IsDigit(x) ((x) >= '0' && (x) <= '9')
using namespace std;

int n, m;
int b[201][5001], in_r[201][5001], in_l[201][5001];
long long dist[5001], d[5002][5002];
struct Elem{
	int b, id;
	Elem() {}
	Elem(int x, int y)
		: b(x), id(y)
	{}
}s[5000];


int Read(void)
{
	int c, ret(0);
	
	c = getchar();
	while (!IsDigit(c))
		c = getchar();
	do
		ret = ret * 10 + c - '0';
	while ((c = getchar()) && IsDigit(c));
	return ret;
}


int main()
{
	int pos, l, r;
	long long ans(0), t;
	
	n = Read();
	m = Read();
	for (int i = 2; i <= n; ++i)
		dist[i] = Read() + dist[i - 1];
	for (int j = 1; j <= n; ++j)
		for (int i = 1; i <= m; ++i)
			b[i][j] = Read();
	for (int i = 1; i <= m; ++i) {
		pos = 0;
		s[pos++] = Elem(b[i][1], 1);
		for (int j = 2; j <= n; ++j) {
			while (pos && b[i][j] >= s[pos - 1].b) {
				in_r[i][s[pos - 1].id] = j - 1;
				--pos;
			}
			s[pos++] = Elem(b[i][j], j);
		}
		while (pos) {
			in_r[i][s[pos - 1].id] = n;
			--pos;
		}
		s[pos++] = Elem(b[i][n], n);
		for (int j = n - 1; j; --j) {
			while (pos && b[i][j] >= s[pos - 1].b) {
				in_l[i][s[pos - 1].id] = j + 1;
				--pos;
			}
			s[pos++] = Elem(b[i][j], j);
		}
		while (pos) {
			in_l[i][s[pos - 1].id] = 1;
			--pos;
		}
	}
	for (int i = 1; i <= m; ++i)
		for (int j = 1; j <= n; ++j) {
			l = in_l[i][j];
			r = in_r[i][j];
			t = b[i][j];
			d[l][j] += t;
			d[l][r + 1] -= t;
			d[j + 1][j] -= t;
			d[j + 1][r + 1] += t;
		}
	for (int i = 1; i <= n + 1; ++i)
		for (int j = 1; j <= n + 1; ++j)
			d[i][j] += d[i - 1][j];
	for (int i = 1; i <= n + 1; ++i)
		for (int j = 1; j <= n + 1; ++j)
			d[i][j] += d[i][j - 1];
	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= n; ++j)
			ans < (t = d[i][j] - dist[j] + dist[i]) && (ans = t);
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 207488
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.StringTokenizer;



public class Main {

	public static void main(String[] args) {
		 FastScanner sc =new FastScanner();
		int n=sc.nextInt();
	
		int val=7%n;
		for(int i=1;i<1e7;i++) {
			if(val==0) {
				System.out.println(i);
				return;
			}
			val=(val*10+7)%n;
		}
		 System.out.println("-1");
		  
		
		    	
		    }
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
}

		    
		}

Measured memory_bytes: 32804
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = 0L;

		if (a % 2 == 1) {
			a = a - 1;
			x = a;
		}

		long sub = b - a;
		if (sub % 4 == 0) {
			System.out.println(b ^ x);
		
		} else if (sub % 4 == 1) {
			System.out.println(b ^ (b - 1) ^ x);
		
		} else if (sub % 4 == 2) {
			System.out.println(b ^ 1 ^ x);
		
		} else if (sub % 4 == 3) {
			System.out.println(b ^ (b - 1) ^ 1 ^ x);
		
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n,k;
	cin>>n>>k;

	vector<lli> a(n);
	REP(i,0,n)cin>>a[i];

	lli ans=0;
	lli nowL=0;

	while(nowL+k<n){
		nowL+=(k-1);
		ans++;
	}
	cout<<ans+1<<endl;

	return 0;
}

Measured memory_bytes: 1024
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! {
        n: i32,
    }

    let mut ans = "No";
    for x in 1..10 {
        for y in 1..10 {
            if n == x * y {
                ans = "Yes";
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << (s.back() != 's' ? s + 's' : s + "es") << '\n';
  return 0;
}


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

using LL = long long;

constexpr int MOD = 1e9+7;

int dp[41][(1<<17)];
void add (int &x, int y) {
        if (x + y >= MOD) x = x + y - MOD;
        else x = x + y;
}
void sub (int &x, int y) {
        //if (y) cerr << x << " - " << y << " = " << x - y << endl;
        if (x - y < 0) x = x - y + MOD;
        else x = x - y;
}
void gao (int x) {
        vector <int> v;
        while (x) v.push_back(x%2), x>>=1;
        reverse (v.begin(),v.end());
        for (auto &x : v) cout << x << " "; cout << endl; 
}
int main () {
        int n, x, y, z; cin >> n >> x >> y >> z;
        int need = ((1 << (x-1)) | (1 << (x+y-1)) | (1 << (x+y+z-1)));
        int full = (1 << (x+y+z)) - 1; 
        //gao (need), gao(full);
        int ans = 1;
        dp[0][0] = 1;
        for (int i = 0; i < n; ++i) {
                ans = ans * 10LL % MOD;
                for (int mask = 0; mask <= full; ++mask) if (dp[i][mask]) {
                        for (int j = 1; j <= 10; ++j) {
                                int sta = (mask << j) | (1 << (j-1));
                                sta &= full;
                                if ((sta & need) == need) continue;
                                add (dp[i+1][sta], dp[i][mask]);
                        }
                }
        } 
        cerr << "ans = " << ans << endl;
        for (int mask = 0; mask <= full; ++mask) sub (ans, dp[n][mask]);
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 19328
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint s[100100];
vector<lint> sum[100100],rsum[100100];
int n;
lint cal(int A,int x){
	if(A<=x) return 0;
	if(A%x==0){
		if(A*2<=n-1) return 0;
	}
	return sum[x][(n-1-A)/x]+rsum[x][(n-1-A)/x];
}
int main()
{
	lint out=0;
	cin>>n;
	rep(i,n) cin>>s[i];
	REP(i,1,100050){
		lint su=0;
		for(int j=0;j<n;j+=i){
			su+=s[j];sum[i].pb(su);
		}
		su=0;
		for(int j=n-1;j>=0;j-=i){
			su+=s[j];rsum[i].pb(su);
		}
	}
	REP(A,2,n-1){
		for(int i=1;i*i<=(n-1-A);i++){
			if((n-1-A)%i==0){
				out=max(out,cal(A,i));
				out=max(out,cal(A,(n-1-A)/i));
			}
		}
	}
	cout<<out<<endl;
}


Measured memory_bytes: 36804
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;


#define INF 1e18
#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for(int i = 0; i < n; i++) cin >> a[i + 1];

    vector<int> b(n + 1);
    for(int i = n; i >= 1; i--) {
        int sum = 0;
        for(int j = i * 2; j <= n; j += i) {
            sum ^= b[j];
        }
        b[i] = a[i]^sum;
    }

    vector<int> ans;
    for(int i = 1; i < n + 1; i++) {
        if(b[i]) ans.push_back(i);
    }

    cout << ans.size() << endl;
    if(ans.size() != 0) {
        for(int i = 0; i < ans.size(); i++) {
            cout << ans[i] << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 4980
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'


void solve(){
  int n;
  cin >> n;
  int a = 0;
  int b = 0;
  int p = 0;
  forn(i,n){
    int t, x, y;
    cin >> t >> x >> y;
    int d = abs(x-a)+abs(y-b);
    int dd = t - p;
    if (d > dd or (dd - d)%2) {
      cout << "No";
      return;
    }
    a = x;
    b = y;
    p = t;
  }
  cout << "Yes";
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 



*/

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

void Possible(){
	cout<<"Possible"<<endl;
	exit(0);
}

void Impossible(){
	cout<<"Impossible"<<endl;
	exit(0);
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

template<class T>
void ResetVector(vector<T>& v,int n,const T& t){
	v.clear();
	v.resize(n,t);
}

int main(){
	int n=read();
	vi a;
	REP(i,n)
		a.PB(read());
	int dia=*max_element(a.begin(),a.end());
	vi c(n,0);
	int mn=(dia+1)/2;
	REP(i,n){
		if(a[i]<mn)
			Impossible();
		c[a[i]]++;
	}
	if(dia%2==1){
		FOR(i,mn,dia+1)
			if(c[i]<2)
				Impossible();
		if(c[mn]>2)
			Impossible();
	}else{
		FOR(i,mn+1,dia+1)
			if(c[i]<2)
				Impossible();
		if(c[mn]>1)
			Impossible();
	}
	Possible();
}


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

int main(){
    //入力
    int a,b,c;
    cin >> a >> b >> c ;

    //出力
    if((b-a)==(c-b)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<long long> V;
typedef vector<V> VV;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n;
	string s;
	int ans=0;
	int at=0;
	int aa=0,ab=0,ac=0;
	cin >>n>>s;
	rep(a,10){
		at=0;
		while(s[at]!=a+'0' and at <n){
			at++;
		}
		if(at<n){
			aa=at+1;
		}else{
			continue;
		}
		rep(b,10){
			at=aa;
			while (s[at] != b + '0' and at < n){
				at++;
			}
			if (at < n){
				 ab=at+1;
			}else{
				continue;
			}
			rep(c,10){
				at=ab;
				while (s[at] != c + '0' and at < n){
					at++;
				
				}
				if(at < n){
					ans++;
				//	cout<<a<<b<<c<<endl;
				}
				
			}
		}
	}

	cout<<ans<<endl;
}

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

int main(void) {
    string S;cin>>S;
    int sum = 0;
    int cur = 0;
    for (int i = 0; i < S.size(); i++) {
        char s = S[i];
        if (s == 'A' || s == 'C' || s == 'G' || s == 'T') cur++;
        else {
            if (sum < cur) {
                sum = cur;
            }
            cur = 0;
        }
    }
    if (sum < cur) sum = cur;
    cout << sum << endl;
    return 0;
}

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

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

def main():
    def scc(Edge):
        N = len(Edge)
        Edgeinv = [[] for _ in range(N)]
        for vn in range(N):
            for vf in Edge[vn]:
                Edgeinv[vf].append(vn)
        
        used = [False]*N
        dim = [len(Edge[i]) for i in range(N)]
        order = []
        for st in range(N):
            if not used[st]:
                stack = [st, 0]
                while stack:
                    vn, i = stack[-2], stack[-1]   
                    if not i and used[vn]:
                        stack.pop()
                        stack.pop()
                    else:
                        used[vn] = True
                        if i < dim[vn]:
                            stack[-1] += 1
                            stack.append(Edge[vn][i])
                            stack.append(0)
                        else:
                            stack.pop()
                            order.append(stack.pop())
        res = [None]*N
        used = [False]*N
        cnt = -1
        for st in order[::-1]:
            if not used[st]:
                cnt += 1
                stack = [st]
                res[st] = cnt
                used[st] = True
                while stack:
                    vn = stack.pop()
                    for vf in Edgeinv[vn]:
                        if not used[vf]:
                            used[vf] = True
                            res[vf] = cnt
                            stack.append(vf)
        M = cnt+1
        components = [[] for _ in range(M)]
        for i in range(N):
            components[res[i]].append(i)

        return res, components
    
    N,M=MI()
    adj=[[]for _ in range(N)]
    for i in range(M):
        a,b=MI()
        adj[a].append(b)
        
    res,compo= scc(adj)
    
    M=max(res)+1
    
    print(M)
    for i in range(M):
        length = len(compo[i])
        print(' '.join(map(str, [length]+compo[i])))
    
    

main()


Measured memory_bytes: 241508
using System;

class Program
{
    static void Main(string[] args)
    {
        string input;
        int n, train, taxi, totalTrain;

        input = Console.ReadLine();
        string[] inputValues = input.Split(' ');

        n = Int32.Parse(inputValues[0]);
        train = Int32.Parse(inputValues[1]);
        taxi = Int32.Parse(inputValues[2]);

        totalTrain = n * train;
        if (taxi <= totalTrain)
        {
            Console.WriteLine(taxi);
        }
        else
        {
            Console.WriteLine(totalTrain);
        }
    }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    vector<ll> divisorA, divisorB, intersection;
    divisorA = divisor(A);
    divisorB = divisor(B);
    REPV(iter, divisorA)
    {
        if (binary_search(ALL(divisorB), *iter)) intersection.push_back(*iter);
    }

    ll ans = 0;
    vector<ll> searchVec = intersection;
    while(searchVec.size() > 0)
    {
        vector<ll> nextSearchVec;
        ll div = searchVec[0];
        ans++;
        for (int i = 1; i < searchVec.size(); ++i)
        {
            if (div == 1) nextSearchVec.push_back(searchVec[i]);
            else
            {
                if (searchVec[i] % div != 0) nextSearchVec.push_back(searchVec[i]);
            }
        }
        searchVec = nextSearchVec;
    }

    cout << ans << endl;
}


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

void find(map<string, int> T){
	
}

int main(){
	
	int n;
	cin>>n;
	map<string, int> T;
	char str[10],com[13];
	
	for(int i=0;i<n;i++){
		cin>>com>>str;
		if(com[0]=='i')
			T[string(str)]=true;
		else{
			if(T[string(str)])
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}
	
	return 0;
} 


Measured memory_bytes: 47492
import math


def read():
    X = int(input())
    return X, 


def f(a, b):
    return a**5 - b**5


def solve(X):
    for i in range(0, 1001):
        for j in range(-1000, 1001):
            if f(i, j) == X:
                return "{} {}".format(i, j)

if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    print("{}".format(outputs))


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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans;
    if ((a + b) <= 2 * c) ans = a * x + b * y;
    else {
        ans = 2 * c * min(x, y);
        int rest = abs(x - y);
        if (x < y) {
            ans += min(b * rest, 2 * c * rest);
        } else {
            ans += min(a * rest, 2 * c * rest);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int cards[4*13];
int main(void){
  int suitID[127];
  int n;
  suitID['S']=0; suitID['H']=1;
  suitID['C']=2; suitID['D']=3;
  cin >> n;
  for (int i=0; i<n; i++){
    char s;
    int r;
    cin >> s >> r;
    cards[suitID[s]*13+r-1]=1;
  }
  for (int i=0; i<52; i++){
    int s,r;
    if (cards[i]) continue;
    s = i/13; r = i%13+1;
    cout << "SHCD"[s] << " " << r << endl;
  }
  return 0;
}



Measured memory_bytes: 3132
#include <iostream>

using namespace std;

void insertionSort(int A[], int N);

int main()
{
	int N;
	cin >> N;
	int A[1000];
	
	for (int i = 0; i < N; i++) cin >> A[i];

	insertionSort(A, N);

	return 0;
}

void insertionSort(int A[], int N)
{
	for (int i = 0; i < N; i++){
		int v = A[i];
		int j = i - 1;

		while (j >= 0 && A[j] > v){
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		
		cout << A[0];
		for (j = 1; j < N; j++) cout << " " << A[j];
		cout << endl;
	}
}

Measured memory_bytes: 1164
n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
kitai = []
for i in range(n):
    kitai.append((1+p[i])/2)
wa = []
a = 0
for i in range(n):
    a += kitai[i]
    wa.append(a)
if n == k:
    print(wa[n-1])
    exit()
ans = 0
for i in range(n-k):
    ans = max(ans, wa[i+k] - wa[i])

print(ans)

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

int main() {
    double A, B;
    cin >> A >> B;
    int D = A / B;
    int R = int(A) % int(B);
    double F = A / B;
    cout << D << " " << R << " " << fixed << setprecision(6) << F << endl;
}


Measured memory_bytes: 3276
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	
	int A, B, X;
	scanf("%d%d%d", &A, &B, &X);

	if (X - A <= B && X >= A)printf("YES");
	else printf("NO");



}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   int n;
   cin>>n;
   vector<ll> a(n);
   rep(i,n){
      cin>>a[i];
   }
   ll ans=0;
   rep(i,n){
      for(int j=i+1;j<n;j++){
         ans=max(ans,abs(a[i]-a[j]));
         
      }
   }
   cout<<ans;

   
}

Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long  ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007
#define si(x) int(x.size())
#define FOOR(i, a, b)  for (int i=a; i<=(b); i++)
#define FOR(i, a)  for (int i=0; i<(a); i++)
#define FOORd(i,a,b)  for (int i = (b)-1; i >= a; i--)
#define FORd(i,a)  for (int i = (a)-1; i >= 0; i--)




int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll pos=x/d;
    if(pos>=k)pos=k;
    x=x-(pos*d);
    k-=pos;
    if(k%2==0)
    {
        cout<<x<<endl;
    }else{

    cout<<min(abs(x-d),abs(x+d));
    }

}


Measured memory_bytes: 3616
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

vector<int> rs;
vector<int> gs;
vector<int> bs;

ll solve(const string S, const int N) {
    ll ans = 0;
    ll exclusive_cnt = 0;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            if (S[i] == S[j]) continue;
            const int diff = j - i;
            const int third_pos = j + diff;
            if (third_pos >= N) continue;
            if (S[i] == S[third_pos] || S[j] == S[third_pos]) continue;
            exclusive_cnt++;
        }
    }

    ans = rs.size() * gs.size() * bs.size() - exclusive_cnt;
    return ans;
}

// Based on the soltuion pdf.
int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    for (int i = 0; i < N; i++) {
        char c = S[i];
        if (c == 'R') {
            rs.push_back(i);
        } else if (c == 'G') {
            gs.push_back(i);
        } else {
            bs.push_back(i);
        }
    }

    cout << solve(S, N) << endl;

    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
using namespace std;

int main(void){
	ios::sync_with_stdio(false);
	string s,a;
	cin >> s;
	int n=s.size();
	if (n == 3) {
		a[0] = s[2];
		s[2] = s[0];
		s[0] = a[0];
	}

	cout << s;
	return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

ans = [1] * n
for x in a:
    for i in x:
        ans[i - 1] = 0

print(sum(ans))


Measured memory_bytes: 9136
/*
	dp[i][j] = min. wt. of items from a[i, i+1, .... N] with j value left to add
	dp[i][j] = min(dp[i+1][j], dp[i+1][j-v[i]]+w[i])

	Base Cases
	-----------
	dp[N-1][v[N-1]] = w[N-1]
	dp[N-1][0] = 0
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 1<<30;

int main(){
	int N, W;
	vector<ll> w, v;
	vector<vector<ll> > dp;
	cin>>N>>W;
	w.assign(N+1, 0);
	v.assign(N+1, 0);
	dp.assign(N+1, vector<ll>(100005, INF));
	for(int i=0;i<N;i++){
		cin>>w[i]>>v[i];
	}
	
	dp[N][0] = 0;
	
	for(int i=N-1;i>=0;i--){
		dp[i][0] = 0;
		for(int j=100000;j>=1;j--){
			dp[i][j] = dp[i+1][j];
			if(j>=v[i])
				dp[i][j] = min(dp[i][j], w[i]+dp[i+1][j-v[i]]);
		}
	}

	for(int i=100000;i>=0;i--){
		if(dp[0][i] <= W){
			cout<<i<<"\n";
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int n;
 	cin >> n;
 	long long int ans=1145141919810;
 	for (int i = 0; i < n; i++){
 		int x,ann=0;
 		cin >> x;
 		for (int j = 0; j < 114514; j++){
 			if(x%2==0){
 				x=x/2;
 				ann++;
 			}else{
 				break;
 			}
 		}
 		if(ann<ans){
 			ans=ann;
 		}
 	}
 	cout << ans << endl;
 }

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

int main(){
  int a,b;
  cin >> a >> b;
  cout << ( a % ( 2 * b + 1 ) == 0 ? a / ( 2 * b + 1 ) : a / ( 2 * b + 1 ) + 1 ) << endl;
}

Measured memory_bytes: 3600
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
s = lines.pop(0)

ans = 0
for i in range(n):
    intersection = set(s[:i]) & set(s[i:])
    num = len(intersection)
    if num > ans:
        ans = num
print(ans)


Measured memory_bytes: 8964
#include<bits/stdc++.h>
using namespace std;
int main(){
	int A,B;
	cin>>A>>B;
	int c=A+B;
	int d=A-B;
	int e=A*B;
	if(c>=d&&c>=e){
		cout<<c<<endl;
		}if(d>c&&d>e){
			cout<<d<<endl;
		}if(e>c&&e>=d){
			cout<<e<<endl;
		}
	}

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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int 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; }
void put_double(double obj){printf("%.12f\n",obj);};
//lambda: [](int x, int y){return x<y;}

signed main(void){
    ll h,w;cin>>h>>w;

    ll ans=h*w/2;
    if(w%2&&h%2){
        ans++;
    }
    if(w==1||h==1)ans=1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// Problem: 
// 			C - Repsept
// 			Editorial
// 		
// Contest: AtCoder - AtCoder Beginner Contest 174
// URL: https://atcoder.jp/contests/abc174/tasks/abc174_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n;
	cin>>n;
	if(n%2 == 0 || n %5 == 0)
	{
		cout << "-1";
	}
	else
	{
		int ans = 1;
		long long int num = 7;
		while(ans <= n)
		{
			if(num%n == 0) break;
			num = (num%n)*10 + 7;
			ans++;
		}
		if(ans > n) cout << "-1";
		else cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main()
{
int n,c=0,k=0;
cin>>n;
long int  a[200];
int i;
for(i=0;i<n;i++)
    cin>>a[i];
while(1)
{
for(i=0;i<n;i++)
{
    if(a[i]%2==0)
    {
     a[i]=a[i]/2;
    }
    else
    {
        cout<<c;
        k=1;
        break;
    }

}

 if(k==1)
        break;
        c++;
}
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int a, b, c;
   scanf("%d %d %d", &a, &b, &c);
   if(a == b && a != c){
      printf("Yes");
   } else if(a == c && a != b){
      printf("Yes");
   } else if(b == c && a != b){
      printf("Yes");
   } else {
      printf("No");
   }

   return 0;
}


Measured memory_bytes: 1688
#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 A[100100];
//int B[100100];
vector<int> A[100100];
vector<int> B[100100];

int main(){
    int N, M;
    cin >> N >> M;
    REP(i,M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        A[a].push_back(i);
        B[b].push_back(i);
    }

    ll ans = 0;
    set<int> se;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < B[i].size(); j++){
            if(se.find(B[i][j]) != se.end()){
                ans++;
                se.clear();
            }
        }
        for(int j = 0; j < A[i].size(); j++){
            se.insert(A[i][j]);
        }
    }

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


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

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> W(n), E(n);
    for(int i = 0; i < n; i++){
        if(s[i] == 'W') W[i]++;
        else E[i]++;
        if(i > 0){
            W[i] += W[i - 1];
            E[i] += E[i - 1];
        }
    }

    int mini = 1e9;
    for(int i = 0; i < n; i++){
        int a = (i > 0 ? W[i - 1] : 0);  // iまでのWの数
        int b = E[n - 1] - E[i]; 
        mini = min(mini, a + b);
    }
    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 2964
import collections

N = int(input())
S = [input() for _ in range(N)]
S_count = collections.Counter(S)
S_count_sort = sorted(S_count.items(), key=lambda x: x[1], reverse=True)

ans_list = []
for i, k in enumerate(S_count_sort):
    if i == 0:
        before_v = k[1]
        ans_list.append(k[0])
    else:
        if k[1] != before_v:
            break
        else:
            ans_list.append(k[0])
ans_list.sort()
for ans in ans_list:
    print(ans)

Measured memory_bytes: 120912
import sys, re
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from collections import deque, defaultdict, Counter
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop, heapify
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if 0 > self.parents[x]:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if 0 > x]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = MAP()

tree = UnionFind(N)
friends = [[] for _ in range(N)]

for _ in range(M):
	A, B = MAP()
	tree.union(A-1, B-1)
	friends[A-1].append(B-1)
	friends[B-1].append(A-1)

blocks = [[] for _ in range(N)]

for _ in range(K):
	C, D = MAP()
	blocks[C-1].append(D-1)
	blocks[D-1].append(C-1)

for i in range(N):
	ans = tree.size(i) - 1 - len(friends[i])
	blocks_cnt = 0
	for j in  blocks[i]:
		if tree.same(i, j):
			blocks_cnt += 1
	ans -= blocks_cnt
	print(ans, end=" ")
print()

Measured memory_bytes: 46524
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
          char s[3];
          cin >> s;
          int count=0;
          REP(i,3){
                    if(s[i]=='o'){
                              count+=1;
                    }
          }
          cout << 700+100*count << endl;
          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, k, ans = 0, i = 0;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.rbegin(), h.rend());
    while(h[i] >= k) {
        i++;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int b[22],h[22];
double hh[22];
int m;
double a[22];

double prec(double add,int pos,int l,int r){
  double rest=add;
  if(l+1<r){
    int idx=l+1;
    repl(i,l+1,r){
      if(h[idx]<h[i])idx=i;
    }
    if(pos<idx){
      rest=prec(rest,pos,l,idx);
      rest=prec(rest,pos,idx,r);
    }else{
      rest=prec(rest,pos,idx,r);
      rest=prec(rest,pos,l,idx);
    }
  }
  double maxh=min(h[l],h[r]);
  double addh=rest/(b[r]-b[l]);
  repl(i,l,r){
    double preh=hh[i];
    if(addh+hh[i]>maxh){
      hh[i]=maxh;
    }else{
      hh[i]+=addh;
    }
    rest-=(b[i+1]-b[i])*(hh[i]-preh);
  }
  return rest;
}

int main(){
	cin.sync_with_stdio(false);
  int cases;
  cin>>cases;
  while(cases--){
    cin>>n;
    repl(i,1,n+1)cin>>b[i]>>h[i];
    b[0]=0; b[n+1]=100;
    h[0]=INF; h[n+1]=INF;
    n+=2;
    cin>>m;
    memset(a,0,sizeof(a));
    rep(i,m){
      int ff;
      double aa;
      cin>>ff>>aa;
      rep(j,n-1){
        if(b[j]<=ff&&ff<=b[j+1]){
          a[j]+=aa/30.0;
        }
      }
    }
    int q;
    cin>>q;
    rep(i,q){
      int p;
      double t;
      cin>>p>>t;
      rep(j,n-1)hh[j]=0.0;
      rep(j,n-1)prec(a[j]*t,j,0,n-1);
      rep(j,n-1){
        if(b[j]<=p&&p<=b[j+1]){
          printf("%.10f\n", min(50.0,hh[j]));
        }
      }
    }
  }
  return 0;
}

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

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> Lucas(N+1);
  Lucas.at(0) = 2;
  if(N+1 > 1)Lucas.at(1) = 1;
  if(N+1 > 2){
    for(int i=2;i<N+1;i++){
      Lucas.at(i) = Lucas.at(i-1)+Lucas.at(i-2);
    }
  }
  cout << Lucas.at(N) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile(" ");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


Measured memory_bytes: 181152
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> a(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];
	vector<ll> acc(N + 1, 0), acc_pos(N + 1, 0);
	for (int i = 1; i <= N; ++i) {
		acc[i] = acc[i - 1] + a[i - 1];
		acc_pos[i] = acc_pos[i - 1] + (a[i - 1] > 0 ? a[i - 1] : 0);
	}
	ll res = 0;
	for (int i = 0; i <= N - K; ++i) {
		ll tmp = acc_pos[i];
		tmp += acc_pos[N] - acc_pos[i + K];
		ll lst = acc[i + K] - acc[i];
		if (lst > 0) tmp += lst;
		res = max(tmp, res);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d[6];
    for (int i = 0; i < 6; i++) {
        cin >> d[i];
    }
    string cmd;
    cin >> cmd;
    int tmp;
    for (unsigned i = 0; i < cmd.size(); i++) {
        switch (cmd.at(i)) {
            case 'N':
                tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; 
                break;
            case 'S':
                tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp;
                break;
            case 'E':
                tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp;
                break;
            case 'W':
                tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp;
        }
    }
    cout << d[0] << "\n";
}

Measured memory_bytes: 3208