akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define int long long
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

vi G[10001];
int in[10001];

signed main()
{
    int V, E; cin >> V >> E;

    for (int i = 0; i < E; ++i) {
        int s, t; cin >> s >> t;

        G[s].PB(t);
        in[t]++;
    }

    vi ans;

    queue<int> St;

    for (int i = 0; i < V; ++i) {
        if (in[i] == 0) St.push(i);
    }

    while (St.size()) {
        int st = St.front(); St.pop();

        ans.push_back(st);

        for (int v : G[st]) {
            in[v]--;

            if (in[v] == 0) St.push(v);
        }
    }

    for (int a : ans) cout << a << endl;
}

Measured memory_bytes: 4196
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int x = in.readInt();
		int y = in.readInt();
		System.out.println(x+y >= 10 ? "error" : x+y); 
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 21076
#!/usr/bin/env python3

from collections import deque

def main():
    h, w = map(int, input().split())
    s = [input() for i in range(h)]
    res = 0
    for i in range(h):
        for j in range(w):
            di = maxdistfrom(s, i, j, h, w)
            res = max(res, di)
    print(res)

def maxdistfrom(s, i, j, h, w):
    if s[i][j] == "#":
        return 0
    queued = [[False for l in range(w)] for k in range(h)]
    queue = deque()
    queue.append((i, j, 0)); queued[i][j] = True
    res = 0
    while queue:
        k, l, d = queue.popleft()
        res = max(res, d)
        for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
            k2 = k + dy
            l2 = l + dx
            if not ((0 <= k2 < h) and (0 <= l2 < w)):
                continue
            if s[k2][l2] == "#":
                continue
            if queued[k2][l2]:
                continue
            queue.append((k2, l2, d + 1)); queued[k2][l2] = True
    return res

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int out[200000];
	int n, x;
	cin >> n >> x; x--;
	if (x == 0 || x == 2*n-2) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		int mod = 2 * n - 1;
		for (int i = 0; i < mod; i++) {
			out[(n-1 + i+mod)%mod] = (x+i+mod)%mod;
		}
		swap(out[n - 2], out[n]);
		for (int i = 0; i < 2 * n - 1; i++) {
			cout << out[i]+1 << endl;
		}
	}
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 2304
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
ma = A[0]
for i in range(1,n):
    if ma < A[i]:
        A[i] -= 1
    if ma <= A[i]:
        ma = A[i]
    else:
        print('No')
        exit()
print('Yes')    


Measured memory_bytes: 22004
import sys
import math

N = int(input())
A = []
B = []

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

'''
print(A)
print(B)
'''

ans = 0

for i in range(N - 1, -1, -1):
    r = A[i] % B[i]
    ans += (B[i] - r) % B[i]

    if i == 0:
        break

    A[i - 1] += ans

print(ans)


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

int main(){
	vector<ll> vet,vet1;
	ll n,val;
	cin >> n;
	ll soma =0 ;
	for(int i= 0;i<n;i++){
		cin >> val;
		if(val < 0)
			vet1.push_back(abs(val));
		else{
			vet.push_back(abs(val));
			soma += val;
		}
	}
	
	int sz = vet1.size()/2;
	int sz1 = vet1.size();
	
	sort(vet1.begin(),vet1.end());
	sort(vet.begin(),vet.end());
	for(int i = sz1-1;i>=sz1-sz*2;i--){
		soma += vet1.back();
		vet1.pop_back();
	}
	
	if((vet1.size() & 1) and vet.size()){
		if(vet[0] < vet1[0]){
			
			soma +=vet1[0];
			soma -=2*vet[0];
		}else
			soma-=vet1[0];
	}else if((vet1.size()&1))
		soma -= vet1[0];
	cout<<soma<<endl;

}

Measured memory_bytes: 1656
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    string s;
    map<string,int> a;
    vector<string> b(n);
    rep(i,n){
        cin>>s;
        b[i]=s;
        if(a.count(s)) a[s] ++;
        else a[s]=1;
    }
    int m;
    cin>>m;
    rep(i,m){
        cin>>s;
        if(a.count(s)) a[s] --;
    }
    int ans=0;
    rep(i,n){
        s=b[i];
        ans =max(ans,a[s]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double INF = 1000000;
int main(){
  cout << fixed << setprecision(3);
  while (1){
    int n, m, p, a, b;
    cin >> n >> m >> p >> a >> b;
    if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0){
      break;
    }
    a--;
    b--;
    vector<int> t(n);
    for (int i = 0; i < n; i++){
      cin >> t[i];
    }
    int V = m << n;
    vector<vector<pair<double, int>>> E(V);
    for (int i = 0; i < p; i++){
      int x, y;
      double z;
      cin >> x >> y >> z;
      x--;
      y--;
      for (int j = 0; j < (1 << n); j++){
        for (int k = 0; k < n; k++){
          if (j >> k & 1){
            E[(x << n) + j].push_back(make_pair(z / t[k], (y << n) + j - (1 << k)));
            E[(y << n) + j].push_back(make_pair(z / t[k], (x << n) + j - (1 << k)));
          }
        }
      }
    }
    vector<double> d(V, INF);
    priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> pq;
    pq.push(make_pair(0, (a << n) + (1 << n) - 1));
    while (!pq.empty()){
      double c = pq.top().first;
      int v = pq.top().second;
      pq.pop();
      if (d[v] == INF){
        d[v] = c;
        for (auto P : E[v]){
          int w = P.second;
          pq.push(make_pair(c + P.first, w));
        }
      }
    }
    double ans = INF;
    for (int i = 0; i < (1 << n); i++){
      ans = min(ans, d[(b << n) + i]);
    }
    if (ans == INF){
      cout << "Impossible" << endl;
    } else {
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 40732
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  float N, M;
  cin >> N >> M;
  vector<float> A(N);
  float sum = 0;
  rep(i,N) {
          cin >> A[i];
          sum += A[i];
  }

  int tmp = 0;
  rep(i,N) {
          if(A[i] >= sum/(4*M)) ++tmp;
  }
  cout << (tmp >= M ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3792
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> d(10);
    rep(i,k){int dk; cin >> dk; d[dk] = 1;}
    FOR(i,n,100000){
        int tmp = i;
        while(tmp){
            int last = tmp%10;
            if (d[last]){
                goto E;
            }
            tmp /= 10;
        }
        cout << i;break; E:;
    }
}


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

const long long INF = 1e18 + 5;
template<typename Type>
struct SegmentTree {
        vector<Type> data;
        int n;
        SegmentTree(int x) {
                n = pow(2, ceil(log2(x)));
                data.resize(2 * n - 1, INF); //initial value
        }
        Type merge(Type x, Type y) { //merge function
                return min(x, y);
        }
        void update(int k, Type p) { //update k-th value to p
                k += n - 1;
                data[k] = p;
                while (k > 0) {
                        k = (k - 1) / 2;
                        data[k] = merge(data[k * 2 + 1], data[k * 2 + 2]);
                }
        }
        // [l, r)
        Type query(int a, int b) { return query(a, b, 0, 0, n); }
        Type query(int a, int b, int k, int l, int r) {
                if (r <= a || b <= l) return INF; //initial value
                if (a <= l && r <= b) return data[k];
                int m = (l + r) / 2;
                return merge(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
        }
};

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<vector<pair<int, int>>> g(n);
        rep(i, m) {
                int l, r, c;
                scanf("%d%d%d", &l, &r, &c);
                l --, r --;
                g[r].push_back({l, c});
        }
        SegmentTree<long long> seg(n);
        rep(i, n) {
                seg.update(i, INF);
        }
        seg.update(0, 0);
        rep(i, n) if (i) {
                for (auto a : g[i]) {
                        int l = a.first;
                        int c = a.second;
                        seg.update(i, min((long long) c + seg.query(l, i), seg.query(i, i + 1)));
                }
        }
        if (seg.query(n - 1, n) >= INF) {
                printf("-1\n");
        } else {
                printf("%lld\n", seg.query(n - 1, n));
        }
        return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define endl "\n"
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define ss second
#define ff first
#define vpii vector<pii>
#define vvi vector<vi >
#define vs vector<string>
#define all(x) x.begin(),x.end()
#define mii map<int,int>
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>0;i--)
#define repeat(i,start,n) for(ll i=start;i<n;i++)
#define print(a,n) for(ll i=0;i<n;i++){ cout<<a[i]<<" ";}
#define M 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int arr[n];
        rep(i,n)
            cin>>arr[i];
        int cost[n];
        cost[0]=0,cost[1]=abs(arr[1]-arr[0]);
        repeat(i,2,n)
        {
            cost[i]=min(cost[i-1]+abs(arr[i]-arr[i-1]),cost[i-2]+abs(arr[i]-arr[i-2]));
        }
        cout<<cost[n-1];
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, m; cin >> n >> m;
    if (!n) break;
    if (n < 25) {
      V< bitset<500> > bs(n); for (auto&& e : bs) cin >> e;
      int res = 0;
      for (int bit = 0; bit < 1 << n; ++bit) {
        bitset<500> curr;
        for (int i = 0; i < n; ++i) if (bit >> i & 1) {
          curr ^= bs[i];
        }
        if (!curr.count()) res = max(res, __builtin_popcount(bit));
      }
      cout << res << '\n';
    } else {
      V<> a(n);
      for (auto&& e : a) {
        string s; cin >> s;
        e = stoi(s, nullptr, 2);
      }
      V<> dp(1 << m, -1e9);
      dp[0] = 0;
      for (int i = 0; i < n; ++i) {
        auto ndp = dp;
        for (int x = 0; x < 1 << m; ++x) {
          ndp[x ^ a[i]] = max(ndp[x ^ a[i]], dp[x] + 1);
        }
        swap(dp, ndp);
      }
      cout << dp[0] << '\n';
    }
  }
}


Measured memory_bytes: 11364
#include<bits/stdc++.h>
using namespace std;
map<pair<int,pair<int,int> >,int>mp;
int main()
{
	pair<int,pair<int,int> >p;
	scanf("%d%d%d",&p.first,&p.second.first,&p.second.second);
	int t=0;
	while(!mp[p])
	{
		mp[p]=1;
		if(p.first&1||p.second.first&1||p.second.second&1){printf("%d\n",t);return 0;}
		p=make_pair(p.second.first/2+p.second.first/2,make_pair(p.first/2+p.second.second/2,p.first/2+p.second.first/2));
		t++;
	}
	puts("-1");
	return 0;
}

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

using namespace std;

#define ll long long int

const int mod = (int)1e9+7;
int m,n;

ll dp[1005][1005];
string mat[3005];

int safe(int i,int j) {
    if (i >=  0 && j >= 0 && i < m && j < n) {
        return 1;
    }
    return 0;
}

ll solve(int i, int j) {
    if (i >= m || j >= n) {
        return 0;
    }
    if (i == m - 1 && j == n-1)return 1;

    if (dp[i][j] != -1) {
        return dp[i][j];
    }
    ll ans = 0;
    if (safe(i,j+1) && mat[i][j+1] == '.') {
        ans += solve(i,j+1);
        ans %= mod;
    }
    if (safe(i+1,j) && mat[i+1][j] == '.') {
        ans += solve(i+1,j);
        ans %= mod;
    }
    return dp[i][j] = ans % mod;
}

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

    for (int i = 0; i < m; i++) {
        cin >> mat[i];
    }
    memset(dp,-1,sizeof(dp));
    ll ans = solve(0,0);
    cout << ans % mod  << endl;

    return 0;
}
        


Measured memory_bytes: 9344
import java.io.*;
import java.util.*;

public class Main {

	

	public static void main(String[] args) throws Exception 
	{
		Scanner sc = new Scanner(System.in); 
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int N=1<<n;
		int []a=new int [N];
		PriorityQueue<Integer>[]pq=new PriorityQueue[N];
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			pq[i]=new PriorityQueue();
			pq[i].add(a[i]);
		}
		
		for(int k=0;k<n;k++) {
			for(int x=0;x<N;x++) {
				if((x & (1<<k))>0)
					continue;
				int z=x,z2=x|1<<k;
				for(int y:pq[z])
					pq[z2].add(y);
				while(pq[z2].size()>2)
					pq[z2].poll();
			}
			
		}
		int ans=0;
		for(int k=1;k<N;k++) {
			ans=Math.max(ans,pq[k].poll()+pq[k].poll());
			out.println(ans);
		}
		
		out.close();
	}

	

	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}

		public boolean ready() throws IOException {return br.ready();}

		public boolean nextEmpty() throws IOException
		{
			String s = br.readLine();
			st = new StringTokenizer(s);
			return s.isEmpty();
		}


	}
}

Measured memory_bytes: 155752
#include<iostream>
#include<cstdio>
#include<algorithm>
#define endl '\n'
using namespace std;
int main()
{
    int n,x[101];
    cin>>n;
    for(int i = 0; i<n; i++)
        cin>>x[i];
    sort(x,x+n);
    int Min = x[0], Max = x[n-1],sum = 0,m;
    //cout<<Min<<" "<<Max<<" ";
    for(int i = Min; i<= Max; i++){
            int p = i;
            sum = 0;
        for(int j = 0; j<n; j++)
            sum+=( ( x[j] - p ) * ( x[j] - p ) );
        if(p == Min)m = sum;
        else{
            if(sum<m) m = sum;
        }
    }
    //cout<<m<<" "<<sum;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** 幾何ライブラリ **/
// to do : 1183

#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;

typedef double D;
typedef complex<D> P; // Point

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) { return a < b - EPS ? -1 : (a > b + EPS ? 1 : 0); }

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 線分abに対する点cの位置
enum CCW{FRONT=1, LEFT=2, BACK=4, RIGHT=8, ON=16};
int ccw(P a, P b, P c)
{
	b -= a, c -= a;
	D s = sig(cross(b, c));
	if (s) return s>0 ? LEFT : RIGHT;
	if (sig(dot(b, c))<0) return BACK;
	if (sig(abs(c), abs(b))>0) return FRONT;
	return ON;
}

// 直線abと点cの距離
D distLP(P a, P b, P c)
{
	return abs(cross(b-a, c-a))/abs(b-a);
}

// 線分abと点cの距離
D distLSP(P a, P b, P c)
{
	if (sig(dot(b-a, c-a))<0) return abs(c-a);
	if (sig(dot(a-b, c-b))<0) return abs(c-b);
	return abs(cross(b-a, c-a))/abs(b-a);
}

/** Problem CGL_1-A : Points/Vectors **/
int main()
{
	P a, b, c;
	cin>>a.X>>a.Y;
	cin>>b.X>>b.Y;
	
	int q; cin>>q;
	rep(i, q) {
		cin>>c.X>>c.Y;
		 cout << fixed << setprecision(15);
		P tmp = a + (b-a)/abs(b-a) * dot(b-a, c-a)/abs(b-a);
		cout << tmp.X << " " << tmp.Y << endl;
	}
}

Measured memory_bytes: 1320
//***********************
//Author:kibi11
//Quarantine Days
//***********************

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define fr(i, n) for(int i = 0; i < n; i++)
#define fr1(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,k) for(int i=a;i>=k;i--)
#define same int t;cin>>t;while(t--)
#define check(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define f first
#define s second
#define XOX
#define pi = 3.14159265358979323846;

//////////////////////////////////////////////////////////////////////////
/////////////////DEBUGING ZONE//////////////////////////////

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
///////////////////////////////////////////////////////////////////////////
 
ll powermod(ll base, ll exp, ll mod) {
	ll result = 1;
	while (exp != 0) {
		if ((exp % 2) == 1) {
			result = (result * base) % mod;
		}
		base = (base * base) % mod;
		exp /= 2;
	}
	return result;
}

///////////////////////////////////////////////////////////////////////////
//Fuctions if any:





///////////////////////////////////////////////////////////////////////////
int main() 
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = clock();
//ios_base& scientific (ios_base& str);

int n,w;
cin>>n>>w;
ll dp[n][w+1];
memset(dp,0,sizeof(dp));
// ll a[100000];
std::vector<pair<int,ll> > a(n);
int sum=0;
fr(i,n)
{
	int b;
	ll c;
	cin>>b>>c;
	a[i]=mp(b,c);
	sum+=b;



}
	sort(a.begin(), a.end());
fr(i,w+1)
{
// check(a[0].f);
	if(a[0].f<=i)
		dp[0][i]=a[0].s;

}
// fr(i,n)
// {
// fr(j,w+1)
// {	cout<<dp[i][j]<<" ";
// }
// cout<<endl;}
fr1(i,1,n)
{
	fr1(j,1,w+1)
	{
		if(a[i].f>j)
		{
			dp[i][j]=dp[i-1][j];

		}
		else
		{
			dp[i][j]=max(dp[i-1][j],a[i].s+dp[i-1][j-a[i].f]);

		}

	}
}
// fr(i,n)
// {
// fr(j,w+1)
// {	cout<<dp[i][j]<<" ";
// }
// cout<<endl;}
cout<<dp[n-1][w]<<endl;


cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
return 0;
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

void solve(int idx, int c, vector< int > & dp, vector< bool > & v, vector< set< int > > & dpl) {
  if (v[idx]) return;
  v[idx] = true;
  dpl[dp[idx]].insert(idx);
  for (int i=idx-c-1; i>=0; --i) {
    if (dp[i] > 0 && dp[idx]-dp[i] >= 2) break;
    solve(i, c, dp, v, dpl);
  }
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;
  vector< int > dp(n, 0);
  vector< vector< int > > d(k+1, vector< int >(0));
  d[0].push_back(-c-1);
  int largest = 0;
  for (int i=0; i<n; ++i) {
    if (s[i]=='x') continue;
    dp[i] = (d[largest][0]+c < i ? largest+1 : largest);
    /*    
    for (int j=i-c-1; j>=0; --j) {
      if (dp[j] > 0 && dp[j] <= dp[i]-2) break;
      dp[i] = max(dp[i], dp[j]+1);
    }
    */
    if (dp[i] > k) return 0;
    largest = dp[i];
    d[dp[i]].push_back(i);
  }
  //for (int i=0; i<n; ++i) cout << dp[i];
  //cout << endl;
  /*
  vector< set< int > > dpl(k+1, set< int >());
  vector< bool > v(n, false);
  for (int i=n-1; i>=0; --i) {
    if (v[i]) continue;
    if (dp[i] < k) continue;
    solve(i, c, dp, v, dpl);
  }
  for (int i=1; i<=k; ++i) {
    if (dpl[i].size() == 1) cout << *(dpl[i].begin())+1 << endl;
  }
  */
  vector< int > dpl(k+1, -1), dpr(k+1, -1);
  int cur = -1;
  for (int i=n-1; i>=0; --i) {
    if (dp[i] == 0) continue;
    if (cur == -1) {
      dpr[dp[i]] = i;
      cur = dp[i];
    } else if (i+c < dpr[cur]) {
      dpr[dp[i]] = i;
      cur = dp[i];
    }
    dpl[dp[i]] = i;
  }
  for (int i=1; i<=k; ++i) {
    //cout << dpl[i] << " " << dpr[i] << endl;
    if (dpl[i]==dpr[i]) cout << dpr[i]+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 14996
import sys
sys.setrecursionlimit(1000000)

n = int(raw_input())
a = map(int, raw_input().split())

memo = dict()
def dp(pos, flag):
  if pos == n - 1:
    if flag == 0:
      return a[pos]
    else:
      return -a[pos]
  if (pos, flag) in memo:
    return memo[(pos, flag)]
  elif flag == 0:
    memo[(pos, flag)] = max(dp(pos + 1, 0) + a[pos], dp(pos + 1, 1) - a[pos])
    return memo[(pos, flag)]
  else:
    memo[(pos, flag)] = max(dp(pos + 1, 0) - a[pos], dp(pos + 1, 1) + a[pos])
    return memo[(pos, flag)]
print dp(0, 0)

Measured memory_bytes: 114172
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[100009];

void win(int cnt){
    cout1(cnt)
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,XOR=0;
    cin>>N;
    
    rep(i,N) cin>>nums[i],XOR^=nums[i];
    if(XOR==0) win(0);
    
    int cnt=0;
    rrep(k,32)if(XOR&(1ll<<k)){
        ll x=(1ll<<(k+1))-1;
        int idx=-1;
        rep(i,N){
            if(x==(nums[i]^(nums[i]-1))){
                idx=i;
                break;
            }
        }
        if(idx==-1) win(-1);
        nums[idx]=0,XOR^=x;
        cnt++;
    }
    win(cnt);
}

Measured memory_bytes: 640
#include <iostream>

int main() {
	int i=1;
	int n,x;
	std::cin >> n;
	while(n>=i){
		x=i;
		if(x%3==0){
			std::cout << " " << i;
		}else{
			while(x!=0){
				if(x%10==3){std::cout << " " << i;break;}
				x=x/10;
			}
		}
		i++;
	}
	std::cout <<std::endl;
	return 0;
}

Measured memory_bytes: 3100
import math,heapq,sys
input = sys.stdin.readline
xs,ys,xe,ye = map(int,input().split())
cs = [(xs,ys,0), (xe,ye,0)]
N = int(input())
for i in range(N):
    cs.append(tuple(map(int,input().split())))

def calc_cost(i,j):
    if i == j: return float('inf')
    x1,y1,r1 = cs[i]
    x2,y2,r2 = cs[j]
    cost = max(0, math.hypot(x1-x2,y1-y2) - r1 - r2)
    return cost

INF = float('inf')
direct = calc_cost(0,1)
hq = []
for i in range(1,N+2):
    c = calc_cost(0,i)
    if c > direct: continue
    hq.append((c,i))
heapq.heapify(hq)
not_visited = set(range(1,N+2))
cost = [0] + [INF] * (N+1)
while hq:
    c,v = heapq.heappop(hq)
    if v not in not_visited: continue
    if v == 1:
        print(c)
        exit()
    cost[v] = c
    not_visited.remove(v)
    for to in not_visited:
        newcost = calc_cost(v, to)
        if cost[to] <= cost[v] + newcost: continue
        if direct < cost[v] + newcost: continue
        heapq.heappush(hq, (cost[v] + newcost, to))

Measured memory_bytes: 116568
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(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 Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};



in pow_alt(in n,in m){
  if(n==1) return 1;
  if(m==0) return 1;
  return n*(pow_alt(n,m-1)%MOD);
}



int main(){
  in k,n;
  cin>>n>>k;
  
  vector<in> powal(k+1,0);
  rep(i,k){
    if(i!=0 && k/i==k/(i+1)) continue;
    powal.at(k/(i+1)) = pow_alt(k/(i+1),n);
  }
  
  vector<in> number(k+1,0);
  for(int i=k;i>0;i--){
    
    number.at(i)+=powal.at(k/i);
    for(int j=2*i;j<=k;){
      number.at(i)-=number.at(j);
      j+=i;
    }
  }
  in sum=0;
  for(int i=1;i<=k;i++){
    sum=(sum+i*number.at(i))%MOD;
    //cout<<i<<":"<<number.at(i)<<endl;
  }
  cout<<sum<<endl;
  //cout<<powal.at(2)<<endl;
}

Measured memory_bytes: 6416
import java.util.Scanner;
import java.util.Arrays;
public class Main
{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String S = scan.next();
		String T = scan.next();
		for(int i = 0; i< n; i++){
		    char s = S.charAt(i);
		    char t = T.charAt(i);
		    System.out.print(s);
		    System.out.print(t);
		}
		
	}
}

Measured memory_bytes: 35812
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
	return 0;
}
//////////////////

Measured memory_bytes: 256
a,b,x = gets.chomp.split.map(&:to_f)
if x >= a ** 2 * b/2
  puts Math.atan((2 * a**2 * b - 2 * x) / a ** 3) * 180 / Math::PI
else
  puts Math.atan(a * b**2.0 / (2.0 * x )) * 180 / Math::PI
end

Measured memory_bytes: 2044
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int D = Integer.parseInt(sc.next());
    int a = D*2+1;
    int ans = N%a == 0 ? N/a : N/a +1;
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//var min, min2, count: Int!
//for i in 1...10 {
//    let x = Int(readLine()!)!
//    if i == 1 {
//        min = x
//        count = 1
//    } else if x < min {
//        min2 = min
//        min = x
//        count = 1
//    } else if x == min && count == 1 {
//        min2 = x
//        count = 2
//    }
//}
//print(min2)

/*************** メインプログラム ***************/

let N = readInt()!
var A = readIntSplit(by: " ")
loop: for i in 0..<30 {
    for j in 0..<N {
        if A[j] % 2 > 0 {
            print(i)
            break loop
        } else {
            A[j] /= 2
        }
    }
}


Measured memory_bytes: 1152
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include <map>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()


int main() {
	ll n;
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	ll mod = 1e9 + 7;
	ll al = 10;
	ll al08 = 9;
	ll al19 = 9;
	ll al18 = 8;
	rep(i, n-1) {
		al = al * 10;
		al08 *= 9;
		al19 *= 9;
		al18 *= 8;
		al = al % mod;
		al08 = al08 % mod;
		al19 = al19 % mod;
		al18 = al18 % mod;
	}
	al = al % mod;
	ll ans = al - al19 - al08 + al18;
	ans += mod;
	ans %= mod;
	while (ans < 0) {
		ans += mod;
	}
	cout << ans << endl;

	
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
int A, B;
int main() {
    cin >> A >> B;
    int cnt = 0;
    for(int i = A; i <= B; ++i) {
        int t, s, u, v = 0;
        t = i / 10000;
        s = i % 10000 / 1000;
        u = i % 100 / 10;
        v = i % 10;
        if(t == v && s == u) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>


#define rep(i,a,b)(long i=a;i<b;i++)

using namespace std;


int main(void){

	while(1){

	int ary[50]={0};
	int wan=0;
	int num;

	cin >> num >> wan;

	if(!num&&!wan)
		break;

	int i=0;
	while(1){
		if(wan){
			ary[i]++;
			wan--;

			if(!wan){
				bool flag=0;
				for(int j=0;j<num;j++){
					if(ary[j]&&j!=i){
						flag=1;break;
					};
				}
				if(!flag)
					break;
			}

		}else{
			wan=ary[i];
			ary[i]=0;
		}

		i++;
		if(i==num)
			i=0;
	
	}

	cout << i<<endl;

	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm> // sort
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <utility>

using namespace std;

typedef long long int lli;
typedef pair<lli,lli> p_ii;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl
int bug = 1;

int main(){
	IOS
	lli i;
	lli x, y;
	lli ans = 0;

	cin >> x >> y;

	if(x <= 3){
		ans += (4-x) * 100000;
	}
	if(y <= 3){
		ans += (4-y) * 100000;
	}

	if(x == 1 && y == 1){
		ans += 4 * 100000;
	}

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


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int coun[105][105][105]={};
vector<int>x,y,z;
int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  int a[55],b[55],c[55],d[55],e[55],f[55];
  for(int i=0;i<n;i++)
    {
      scanf("%d %d %d %d %d %d",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i]);
       x.push_back(a[i]);
       x.push_back(d[i]);
       y.push_back(b[i]);
       y.push_back(e[i]);
       z.push_back(c[i]);
       z.push_back(f[i]);
    }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  sort(z.begin(),z.end());
  x.erase(unique(x.begin(),x.end()),x.end());
  y.erase(unique(y.begin(),y.end()),y.end());
  z.erase(unique(z.begin(),z.end()),z.end());
  for(int i=0;i<n;i++)
    {
      int r1=lower_bound(x.begin(),x.end(),a[i])-x.begin();
      int r2=lower_bound(x.begin(),x.end(),d[i])-x.begin();
      int r3=lower_bound(y.begin(),y.end(),b[i])-y.begin();
      int r4=lower_bound(y.begin(),y.end(),e[i])-y.begin();
      int r5=lower_bound(z.begin(),z.end(),c[i])-z.begin();
      int r6=lower_bound(z.begin(),z.end(),f[i])-z.begin();
      for(int i=r1;i<r2;i++)
    {
      for(int j=r3;j<r4;j++)
        {
          for(int k=r5;k<r6;k++)
        {
          coun[i][j][k]++;
        }
        }
    }
    }
  long long ans=0;
  for(int i=0;i<=100;i++)
    {
      for(int j=0;j<=100;j++)
    {
      for(int k=0;k<=100;k++)
        {
          if(coun[i][j][k]>=m)
        {
          long long s1=(x[i+1]-x[i]),s2=(y[j+1]-y[j]),s3=(z[k+1]-z[k]);
          ans+=s1*s2*s3;
        }
        }
    }
    }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 6612
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <ctime>
#include <list>
#include <numeric>
#include <fstream>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> PI;
#ifndef M_PI
const double M_PI=acos(-1.0);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
void pkuassert(bool b){if(!b){int a=0;cout << 1/a << endl;}};
int dx[]={0,-1,0,1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};


int main(){
  ll q,su=0;
  cin >> q;
  rep(i,q){
    int p,n;
    char c;
    cin >> p >> c >> n;
    if(c=='(') su += n;
    else su -= n;
  cout << (su?"No":"Yes") << endl;    
  }

}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main ()
{
	int a, b, x, y, min ,signal{0};
	scanf ("%d %d", &a, &b);
	cin>>x>>y;
	int kingdomx[a], kingdomy[b];
	for (int i=0; i<a; i++) cin>>kingdomx[i];
	for (int j=0; j<b; j++)
	{
		cin>>kingdomy[j];
		if (j==0) min=kingdomy[j];
		else if ((min>kingdomy[j])) min=kingdomy[j];
	}
	for (int k=0; k<a; k++)
	{
		if (kingdomx[k]>=min) signal=1;
	}
	if (x>=min) signal=1;
	if (y<min) signal=1;
	if (signal==1) cout<<"War"<<endl;
	else cout<<"No War"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const int maxv = 1e5+10;
long long  w[maxn],c[maxn];
long long dp[maxv];

int main() {
	int n,v;cin>>n>>v;
	for(int i = 1;i <= n;i++) cin>>w[i]>>c[i];
	for(int i = 1;i <= n;i++) {
		for(int j = v;j >= w[i];j--) {
			dp[j] = max(dp[j],dp[j-w[i]]+c[i]);
		}
	}
	cout<<dp[v];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int x;
    cin >> x;
    if (x == 1) {
        println("Hello World");
    }
    else if (x == 2) {
        int a, b;
        cin >> a >> b;
        println(a + b)
    }
    
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String strS[] = sc.next().split("");
    String strT[] = sc.next().split("");
    for (int i=strS.length-1; i >= 0 ; i--){
        String tmp = strS[strS.length-1];
        for (int j=strS.length-1; j > 0 ; j--){
            strS[j] = strS[j-1];
        }
        strS[0] = tmp;
        if(Arrays.equals(strS,strT)){
            System.out.println("Yes");
            return;
        }        
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 23124
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    n,k = LI()
    r = 0

    for i in range(1,n+1):
        t = 0
        while i < k:
            t += 1
            i *= 2
        r += 1 / pow(2,t)

    return '{:0.9f}'.format(r/n)


print(main())




Measured memory_bytes: 6852
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, n, ans = 0;
  scanf("%lld", &n);
  char s[20];
  set< pair<string, ll> > se;
  set< pair<string, ll> >::iterator it;
  pair<string, ll> p;
  for(i = 0; i < n; ++i) {
    scanf("%s", s);
    sort(s, s + strlen(s));
    string a = "";
    for(j = 0; j < strlen(s); ++j) a += s[j];
    p = make_pair(a, 1);
    it = se.lower_bound(p);
    if(it != se.end() && (*it).first == a) ans += (*it).second, p.second = (*it).second + 1, se.erase(it);
    se.insert(p);
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 12800
//ALDS1_11_A:Graph
#include <bits/stdc++.h>
using namespace std;
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    int n;
    cin >> n;
    int V[101][101];
    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
            V[i][j] = 0;
    for(int i=0; i<n; i++){
        int u,k;
        cin >> u >> k;
        for(int j=0; j<k; j++){
            int v;
            cin >> v;
            V[u][v] = 1;
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(j-1) cout << " ";
            cout << V[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, A; cin >> N >> A;
    cout << N * N - A << "\n";
}

Measured memory_bytes: 256