akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    a = list(map(int, readline().split()))
    ans = [0] * n
    v = 2 ** 30
    for i in range(30):
        v //= 2
        check = [False] * n
        cnt = 0
        for j, aa in enumerate(a):
            if aa >= v:
                a[j] -= v
                check[j] = True
                cnt += 1
        if cnt % 2 == 1:
            for j, c in enumerate(check):
                if not c:
                    ans[j] += v
        else:
            for j, c in enumerate(check):
                if c:
                    ans[j] += v
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28232
from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
upper = defaultdict(int)
for i in range(1,n+1):
    upper[i] = 0
for i in a:
    upper[i] += 1
ans = sorted(upper.items())
for k,v in ans:
    print(v)

Measured memory_bytes: 49492
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    l, r = map(int, input().split())
    if r - l >= 2018:
        print(0)
    else:
        ans = 2018
        for i, j in itertools.combinations(range(l, r+1), 2):
            ans = min(ans, i * j % 2019)
        print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9092
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int n;
VI pena;
VVI gain;
int pena_sum;
int eval(VI &order)
{
    VI last(26, -1);
    int ret = 0;
    rep(i, n)
    {
        ret += gain[i][order[i]];
        last[order[i]] = i;
        rep(j, 26)
        {
            ret -= pena[j] * (i - last[j]);
        }
    }
    return ret;
}
void print(VI &order)
{
    for (auto &&x : order)
    {
        cout << x + 1 << endl;
    }
}

int choice_weighted()
{
    int r = mt() % pena_sum;
    rep(i, 26)
    {
        r -= pena[i];
        if (r <= 0)
            return i;
    }
}

void search()
{
    auto starttime = clock();
    typedef pair<int, VI> Tact;
    priority_queue<Tact> pque;
    VI base(n);
    VI last(26, -1);
    rep(i, n)
    {
        int cur = -IINF;
        int penasum = 0;
        rep(j, 26)
        {
            penasum += pena[j] * (i - last[j]);
        }
        rep(j, 26)
        {
            if (cur < gain[i][j] - penasum + pena[j] * (i - last[j]))
            {
                base[i] = j;
                cur = gain[i][j] - penasum + pena[j] * (i - last[j]);
            }
        }
        last[base[i]] = i;
    }
    auto best = base;
    int bscore = eval(base);
    //pque.push({eval(base), base});
    cerr << bscore << endl;
    int loopnum = 0;
    while (double(clock() - starttime) / CLOCKS_PER_SEC < 1.9)
    {
        rep(i, 2)
            base[mt() % n] = choice_weighted();
        int cscore = eval(base);
        if (cscore > bscore)
        {
            best = base;
            bscore = cscore;
        }
        else
        {
            base = best;
        }
        loopnum++;
    }
    print(best);
    cerr << bscore << endl;
    cerr << loopnum << endl;
}
int main()
{
    cin >> n;
    pena = VI(26);
    gain = VVI(n, VI(26));
    rep(i, 26)
    {
        cin >> pena[i];
        pena_sum += pena[i];
    }
    rep(i, n)
    {
        rep(j, 26)
        {
            cin >> gain[i][j];
        }
    }
    search();
    return 0;
}

Measured memory_bytes: 3696
n, m = map(int, input().split())
h = list(map(int, input().split()))
s = set(range(1, n+1))
a, b = [], []

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

    if h[A-1] < h[B-1]:
        if A in s:
            s.remove(A)
    elif h[A - 1] > h[B - 1]:
        if B in s:
            s.remove(B)
    else:
        if A in s:
            s.remove(A)
        if B in s:
            s.remove(B)

# print(a, b)
# print(s)

print(len(s))

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

int main(){
    int N = 10000;
    int tmp = 0;
    vector<int> vec(N);
    for (int i = 0; i <= N; i++) {
        int value;
        cin >> value;
        if (value == 0){
            tmp = i - 1;
            break;
        }
        vec.at(i) = value;
    }
  for (int i = 0; i <= tmp; i ++){
      cout << "Case " << i + 1 << ": " << vec[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3048
using System;
class Program
{
    public static void Main()
    {
        string[] imp = Console.ReadLine().Split(' ');
        int k, s;
        k = int.Parse(imp[0]);
        s = int.Parse(imp[1]);
        int count = 0;
        for (int x = 0; x <= k; x++)
            for (int y = 0; y <= Math.Min(s - x, k); y++)
                if (0 <= s - x - y && s - x - y <= k)
                    count++;
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13140
xy = list(map(int, input().split()))

x = xy[2]-xy[0]
y = xy[3]-xy[1]

print("R"*x+"U"*y, end="")
print("L"*x+"D"*y, end="")
print("D"+"R"*(x+1)+"U"*(y+1)+"L",end="")
print("U"+"L"*(x+1)+"D"*(y+1)+"R",end="")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
from collections import deque, defaultdict
N, M = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]

graph = defaultdict(set)
visited = [False for _ in range(N)]

for x,y in xy:
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

def dfs(v):
    que = deque()
    vis_list = []
    visited[v] = True
    vis_list.append(v)
    que.append(v)
    while len(que) > 0:
        i = que.pop()   #深さ優先探索
        # i = que.popleft() #幅優先探索
        for n in list(graph[i]):
            if visited[n] == False:
                visited[n] = True
                vis_list.append(n)
                que.append(n)

    return vis_list

grps = []
for i in range(N):
    if visited[i] == False:
        grps.append(dfs(i))

ans = 0
for g_list in grps:
    if len(g_list) == 1:
        if g_list[0] == p[g_list[0]]-1:
            ans += 1
    else:
        tmp = set([])
        for i in g_list:
            tmp.add(p[i]-1)
        ans += len( set(g_list) & tmp)

print(ans)


Measured memory_bytes: 93244
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;

int a[510][510];
int n, m;

pii get_nxt(int x, int y){
	y += x & 1 ? 1 : -1;
	if (y == m + 1) x++, y--;
	if (y == 0) x++, y++;
	return mp(x, y);
}

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	int x = 1, y = 1;
	vector <pii> v;
	while (1){
		pii t = get_nxt(x, y);
		int xx = t.fi, yy = t.se;
		if (xx == n + 1) break;
		if (a[x][y] & 1) a[x][y]--, a[xx][yy]++, v.push_back(mp(x, y));
		x = xx, y = yy;
	}
	printf("%d\n", v.size());
	for (int i = 0; i < v.size(); i++){
		pii t = get_nxt(v[i].fi, v[i].se);
		printf("%d %d %d %d\n", v[i].fi, v[i].se, t.fi, t.se);
	}
	return 0;
}


Measured memory_bytes: 4212
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<ctime>
#include<bitset>
//#include<unordered_map>
using namespace std;
#define ull unsigned long long int
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

inline ll max(ll a,ll b) { return a>b?a:b; }
inline ll min(ll a,ll b) { return a<b?a:b; }
inline ll abs1(ll a) { return a>0?a:-a; }

const int maxn=1e5+10;

const int seed=2333;
ull base[maxn];
ull h[maxn];

int n,len;
string str;

inline ull get_hash(int left,int right)//区间hash 
{
	return h[right]-h[left-1]*base[right-left+1];
}

inline bool judge(int x)
{
	for(int i=1;i+x-1<=len;i++)
	{
		ull res=get_hash(i,i+x-1);
		
		for(int j=i+x;j+x-1<=len;j++)
		{
			ull res1=get_hash(j,j+x-1);
			
			if(res == res1)
				return true;
		}
	}
	return false;
}

int main()
{
	while(cin>>n)
	{
		cin>>str;
		len=str.size();
		str.insert(0,"#");//下标从1开始
		
		h[0]=0,base[0]=1;
		for(int i=1;i<=len+1;i++)
		{
			h[i]=h[i-1]*seed+str[i];
			base[i]=base[i-1]*seed;
		} 
		
		int left=1,right=len+1,mid;
		while(left<=right)
		{
			mid=(left+right)>>1;
			if(judge(mid))
				left=mid+1;
			else
				right=mid-1;
		}
		cout<<right<<endl;
	}
	return 0;
}

Measured memory_bytes: 3700
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0]*N, [0]*M

total = 0
for i in range(N):
    total += A[i]
    a[i] = total

a = [0] + a

total = 0
for i in range(M):
    total += B[i]
    b[i] = total

b = [0] + b

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] + a[i] > K:
        j -= 1
    #print(a[i], b[j], i, j)
    ans = max(ans, i + j)

print(ans)

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

int main(){
    string S;
    cin >> S;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    int len = S.size();
    string last;
    while(true){
        
        if(len < 5){
            cout << "NO" << endl;
            return 0;
        }
        
        //dream
        last = S.substr(len - 5, 5);
        if(last == divide[0]){
            len = len - 5;
            if(len == 0){
                cout << "YES" << endl;
                return 0;
            }
            continue;
        }

        //erase
        last = S.substr(len - 5,5);
        if(last == divide[2]){
            len = len - 5;
            if(len == 0){
                cout << "YES" << endl;
                return 0;
            }
            continue;
        }

        if(len < 6 ) continue;

         //eraser
        last = S.substr(len - 6,6);
        if(last == divide[3]){
            len = len - 6;
            if(len == 0){
                cout << "YES" << endl;
                return 0;
            }
            continue;
        }
        
        if(len < 7 ) continue;

        //dreamer
        last = S.substr(len - 7,7);
        if(last == divide[1]){
            len = len - 7;
            if(len == 0){
                cout << "YES" << endl;
                return 0;
            }
            continue;
        }

        cout << "NO" << endl;
        return 0;
    }
}

Measured memory_bytes: 512
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-5;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=16000+10,maxn=2000000+10,inf=0x3f3f3f3f;

map<int,int>ma;
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        ma[x]++;
    }
    if(ma.size()==1)return 0*puts(ma.begin()->fi?"No":"Yes");
    if(ma.size()==2)
    {
        if(ma.begin()->fi!=0)return 0*puts("No");
        if(((--ma.end())->se)!=ma.begin()->se*2)return 0*puts("No");
        return 0*puts("Yes");
    }
    if(n%3!=0||ma.size()>3)puts("No");
    else
    {
        auto te=ma.begin();
        int x=te->fi;
        if(te->se!=n/3)return 0*puts("No");
        te++;
        int y=te->fi;
        if(te->se!=n/3)return 0*puts("No");
        te++;
        int z=te->fi;
        if(te->se!=n/3)return 0*puts("No");
        puts(((x^y)==z)?"Yes":"No");
    }
    return 0;
}
/********************
5
1 0 1 0 2
********************/


Measured memory_bytes: 3840
N, M = map(int, input().split())

aedge = set()
bedge = set()

for i in range(M):
  a, b = map(int, input().split())
  if a == 1: aedge.add(b-1)
  if b == N: bedge.add(a-1)

print("POSSIBLE" if len(aedge & bedge) else "IMPOSSIBLE")

Measured memory_bytes: 18948
n=int(input())
a = list(map(int,input().split()))
cnt={}
for i in a:
    if i not in cnt:
        cnt[i]=1
    else:
        cnt[i]+=1
ans=0
for i in cnt:
    if cnt[i]>i:
        ans+=cnt[i]-i
    elif cnt[i]<i:
        ans+=cnt[i]
print(ans)

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  vector<double> inv(N);
  for(int i=0;i<N;i++){
    cin>> d[i];
    inv[i]= double(1)/double(d[i]);
  }
 // cout<<inv[0];

  double invsum=0;
for(int i=0;i<N;i++){
  invsum += inv[i];
}
cout<<1.0/invsum<<endl;

  }


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

n, q = map(int, input().split())
p = []
x = [0] * (n+1)
for _ in range(n-1):
    p.append(list(map(int, input().split())))

for _ in range(q):
    tmp1, tmp2 = map(int, input().split())
    x[tmp1] += tmp2

# 隣接リスト
l = [[] for _ in range(n+1)]
for pi in p:
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
p = [0] * (n+1)

import sys
sys.setrecursionlimit(10000000)


def dfs(n, v, par):
    p[n] = v
    for chl in l[n]:
        if chl == par:
            continue  # parent
        dfs(chl, v+x[chl], n)
    return

dfs(1, x[1], 0)
print(*p[1:])

Measured memory_bytes: 250908
from collections import Counter

n = int(input())
P = [x-1 for x in map(int, input().split())]

ctr = Counter()
seq = 0
for i, p in enumerate(P):
    if i == p:
        seq += 1
    else:
        ctr[seq] += 1
        seq = 0

ctr[seq] += 1

ans = 0
for k, v in ctr.items():
    ans += (k+1)//2 * v

print(ans)

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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N),B(N);
  for(int i=0;i<N;i++) cin >> A[i] >> B[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  
  if(N%2==1) cout << B[N/2] - A[N/2] + 1 << endl;
  else cout << (B[N/2-1]+B[N/2]) - (A[N/2-1]+A[N/2]) + 1 << endl;
  return 0;
}


Measured memory_bytes: 6372
n = int(input())
d = {'A': 0, 'C': 1, 'G': 2, 'T': 3}
law = 10 ** 9 + 7

dp = {'TTT': 1}
def check(s):
    if 'AGC' in s or 'GAC' in s or 'ACG' in s:
        return False
    if s[0] + s[2:] == 'AGC':
        return False
    if s[:2] + s[3] == 'AGC':
        return False
    return True
for _ in range(n):
    # print(dp)
    new = {}
    for i, c in dp.items():
        for add in 'ACGT':
            s = i + add
            if check(s):
                s = s[1:]
                if s not in new:
                    new[s] = c % law
                else:
                    new[s] += c
                    new[s] %= law
    dp = new
print(sum(dp.values()) % law)

Measured memory_bytes: 3064
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)



        
def main(): #startline--------------------------------------------
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    dp = [-1]*(k+1)
    for i in range(k+1):
        dp[i] = 0
        for j in range(n):
            if a[j] > i:
                break
            if 1 ^ dp[i-a[j]]:
                dp[i] = 1
                break

    print("First" if dp[k] else "Second")
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 5944
#include <iostream>
#include <vector>

using namespace std;

int main() 
{
    int N, M;
    int64_t K;

    cin >> N >> M >> K;

    int64_t A[N];
    int64_t B[M];

    for ( int i = 0; i < N; i ++ ) {
        cin >> A[i];
     }
    for ( int i = 0; i < M; i ++ ) {
        cin >> B[i];
    }

    vector <int64_t> sumA( N+1, 0 ), sumB( M+1, 0 );
    for ( int i = 1; i <= N; i ++ ) sumA[i] = sumA[i-1] + A[i-1];
    for ( int i = 1; i <= M; i ++ ) sumB[i] = sumB[i-1] + B[i-1];

/*
    for ( int i = 0; i < N+1; i ++ ) cout << sumA[i] << " ";
    cout << endl;
    for ( int i = 0; i < M+1; i ++ ) cout << sumB[i] << " ";
    cout << endl;
*/

    int maxcount = 0;
    int n = 0;
    int m = M;
    for ( n = 0; n <= N; n ++ ) {
        if ( K < sumA[n] ) break;
        // cout << " test A " << n << " sum:" << sumA[n] << " remain " << K-sumA[n] << endl;
        while ( K - sumA[n] < sumB[m] ) m --;
        // cout << "   test B " << m << " sumB: " << sumB[m] << " total " << sumA[n] + sumB[m] << endl;
        // cout << "   count " << n+m << endl;        

        maxcount = max( maxcount, n+m );        
    }

    cout << maxcount << endl;
    

    return 0;
}

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;

const int N = 100001;
const int MOD = 998244353;

struct Fenwick{
  vector<int> tree;
  Fenwick(int n){
    tree.resize(n + 1);
  }
  Fenwick(){}
  void add(int in, int val){
    in++;
    while(in < tree.size()){
      tree[in] += val;
      in += in & -in;
    }
  }
  ll get(int in){
    in++;
    ll res = 0;
    while(in){
      res += tree[in];
      in -= in & -in;
    }
    return res;
  }
  ll get(int l, int r){
    if(l == 0)return get(r);
    return get(r) - get(l - 1);
  }
  ll get_at(int in){
    return get(in, in);
  }
};

bool done[301][301];
int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);

  int n;
  cin >> n;
  int A[n][n];
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      cin >> A[i][j];
    }
  }
  for(int i = 0;i < n;i++)
    for(int j = 0;j < n;j++)
      for(int k = 0;k < n;k++)
        if(A[i][j] + A[j][k] < A[i][k] || A[i][j] != A[j][i]){
          cout << -1;
          return 0;
        }
  for(int i = 0;i < n;i++){
    for(int j = 0;j < n;j++){
      for(int k = 0;k < n;k++){
        if(i == j || i == k || j == k)continue;
        if(A[i][j] + A[j][k] == A[i][k]){
          done[i][k] = 1;
        }
      }
    }
  }
  ll res = 0;
  for(int i = 0;i < n;i++){
    for(int j = i + 1;j < n;j++){
      if(!done[i][j])
        res += A[i][j];
    }
  }
  cout << res;
}



Measured memory_bytes: 640
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(s=="E869120") {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3224
#include<iostream>
using namespace std;
int main(){
    string s;
    int adjust=0,count=0;
    cin >> s;
    if(s.size() == 1){
        cout << 0 << endl;
        return 0;
    }
    if((s.at(0) - '0') == 1) adjust = 1;
    for(int i=0;i<s.size();i++){
        if((s.at(i) - '0') != adjust) count++;
        adjust = !adjust;
    }
    cout << count << endl;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main() {
    long long n, k; cin >> n >> k;
    long long a[n]; for (int i = 0; i < n; i++) cin >> a[i];

    long long ans1 = 0, ans2 = 0;
    int e0 = 0;
    while ((1LL << e0) <= k) e0++;
    e0--;
    long long dp[2][100] = {};
    for (int e = 0; e <= 61; e++) {
        long long m = 1LL << e;
        int count = 0;
        for (long long v : a) if (v & m) count++;
        long long amt0 = m * count, amt1 = m * (n - count);
        if (e > 0) dp[0][e] = dp[0][e-1];
        dp[0][e] += max(amt0, amt1);
        if (e > 0)
            if (k & m) {
                dp[1][e] = max(dp[0][e-1] + amt0, dp[1][e-1] + amt1);
            } else
                dp[1][e] = dp[1][e-1] + amt0;
        else
            if (k & m) {
                dp[1][e] = max(amt0, amt1);
            } else
                dp[1][e] = amt0;
    }
    cout << dp[1][61] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>

#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define fs first
#define sc second
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, ll> P;

ll gcd(ll xx, ll yy){
  ll x, y;
  x = (xx >= 0) ? xx : -xx;
  y = (yy >= 0) ? yy : -yy;

  ll a, b;
  if(x > y){ 
    a = y; b = x;
  } else {
    a = x; b = y;
  }
  return (a == 0) ? b : gcd(b % a, a);  
}
     
int main(){
  ll N, X;

  cin >> N >> X;

  ll ans;
  cin >> ans;
  ans = abs(ans - X);
  for(int i = 1; i < N; ++i){ 
    ll tmp;
    cin >> tmp;
    ans = gcd(ans, tmp - X);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int n;
    cin>> n;
    map<string, int> m;
    rep(i, 0, n){
        string s;
        cin>> s;
        m[s]++;
    }
    cout<< "AC x "<< m["AC"]<< "\n";
    cout<< "WA x "<< m["WA"]<< "\n";
    cout<< "TLE x "<< m["TLE"]<< "\n";
    cout<< "RE x "<< m["RE"]<< "\n";
    return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

def main():
    n, m = map(int, input().split())
    A = []
    B = [''] * m
    for i in range(m):
        p, y = map(int, input().split())
        A.append([p,y,i])
    A.sort()
    count = 0
    i, x = 1, 1
    for a in A:
        if a[0] == i:
            B[a[2]] = '{:06}{:06}'.format(a[0], x)
        else:
            i, x = a[0], 1
            B[a[2]] = '{:06}{:06}'.format(a[0], x)
        x += 1
    for b in B:
        print(b)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31352
//approach 3 dp
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int32_t main(){
    int n;
    cin>>n;
    int a[401];
    int sum[401];
    sum[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    int dp[401][401];
    
    int inf=LONG_LONG_MAX;
    //memset(dp,inf,sizeof dp);
    memset(dp,0,sizeof dp);
    for(int i=1;i<=n;i++){
        dp[i][i]=0;
    }
    for(int d=0;d<=n-1;d++){
        for(int i=1,j=d+1;i<=n-d && j<=n;i++,j++){
            if(i==j){
                continue;
            }
            int ans=LONG_LONG_MAX;
            for(int k=i;k<=j-1;k++){
                ans=min(ans,dp[i][k]+dp[k+1][j]);
            }
            dp[i][j]=(sum[j]-sum[i-1])+ans;
        }
    }    
    cout<<dp[1][n]<<endl;
    return 0;
}

Measured memory_bytes: 1536
N,K = (int(x) for x in input().split())

people_list = [0 for i in range(N)]

for i in range(K):
  input()
  for x in input().split():
    people_list[int(x)-1] += 1
    
num = 0

for x in people_list:
  if(x == 0):
    num += 1
    
print(num)

Measured memory_bytes: 9164
#include <algorithm>
#include <cassert>
#include <set>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;
const ll inf = 2e18;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

struct Line {
	mutable ll k, m, p;
	bool operator<(const Line& o) const { return k < o.k; }
	bool operator<(ll x) const { return p < x; }
};
struct LineContainer : multiset<Line, less<>> {
	ll div(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
	bool isect(iterator x, iterator y) {
		if (y == end()) { x->p = inf; return false; }
		if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
		else x->p = div(y->m - x->m, x->k - y->k);
		return x->p >= y->p;
	}
	void add(ll k, ll m) {
		auto z = insert({k, m, 0}), y = z++, x = y;
		while (isect(y, z)) z = erase(z);
		if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
		while ((y = x) != begin() && y->p <= (--x)->p)
			isect(x, erase(y));
	}
	ll query(ll x) {
		assert(!empty());
		auto l = *lower_bound(x);
		return l.k * x + l.m;
	}
};

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

	int n; ll c; cin >> n >> c;
	ll h[n]; rep(i, 0, n) cin >> h[i];
	LineContainer L; L.add(2 * h[0], - h[0] * h[0]);
	ll t = 0;
	rep(j, 1, n) {
		t = c + h[j] * h[j] - L.query(h[j]);
		L.add(2 * h[j], - t - h[j] * h[j]);
	}
	cout << t;
}

Measured memory_bytes: 14336
k = int(input())
A = [x for x in range(50)]

plus = k // 50
A_plus = [x + plus for x in A]

res = k % 50
for i in range(res):
    A_plus = sorted(A_plus)
    A_plus[0] = A_plus[0] + 50
    for j in range(1,50):
        A_plus[j] = A_plus[j] -1

print(50)
print(' '.join([str(x) for x in A_plus]))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.Magic_Square", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		vector<vector<int> > board (n, vector<int> (n, 0 ) );
		int num = 1;
		int row = n/2+1;
		int col = n/2;
		board[row][col] = num++;
		while (num <= n*n ){
			row = (row + 1 ) % n;
			col = (col + 1 ) % n;
			if (board[row][col] == 0 ){
				board[row][col] = num++;
			}else{
				do{
					row = (row + 1 ) % n;
					col = (n + col - 1 ) % n;
				}while (board[row][col] != 0 );
				board[row][col] = num++;
			} // end if
		} // end while
		rep (i, n ){
			rep (j, n ){
				printf ("%4d", board[i][j] );
			} // end rep
			printf ("\n" );
		} // end rep
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1224
N=int(input())
ab=[[int(i) for i in input().split()] for j in range(N)]
total = sum([sum(row) for row in ab])//2
diff = [row[1] for row in ab if row[0]>row[1]]
if len(diff)==0:
    print(0)
else:
    print(total-min(diff))


Measured memory_bytes: 7412
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
    io;
    ll h, n;
    cin >> h >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    sort(v.rbegin(), v.rend());
    rep(i,n) {
        h -= v[i];
        if (h <= 0) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
#define mod 1000000007
using namespace std;
vector<vector<int>> g(1000000);
int vis[1000000]={0};
int dfs(int s)
{
	vis[s]=1;
	int count=0;
	for(auto i : g[s])
		if(!vis[i])
		{
			count+=dfs(i)+1;
		}
		return count;
}

void solve()
{
	set<pair<int, int>> s;

	int n,m;
	cin>>n>>m;

	for(int i=0,a,b;i<m;i++)
	{
		cin>>a>>b;
		if(a>b)
			swap(a,b);
		s.emplace(a,b);
	}

	int count[n+1]={0};
	for(auto i : s)
	{
		g[i.first].push_back(i.second);
		g[i.second].push_back(i.first);
	}
	int ans=1;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			int t = dfs(i)+1;
			ans=max(ans,t);
		}
	}

	cout<<ans<<endl;




}
signed main()

{
	FAST_IO;
	int t = 1;

	// cin>>t;

	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 57864
while 1:
    n=int(input())
    if n==0:break
    DP=[0 for _ in range(24*10**4+1)]
    for i in range(n):
        a,b=map(lambda x:int("".join(x.split(":"))),input().split())
        DP[a] +=1
        DP[b] -=1
    for i in range(1,24*10**4+1):
        DP[i]=DP[i]+DP[i-1]
    print(max(DP))


Measured memory_bytes: 16532
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int k = sz(s);
  int ans = 0;
  for(int i = 0; i < k;i++) {
    if(s[i] != s[k-i-1]) {
      ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())
x, y, a = [0] * n, [0] * n, [0] * n

for i in range(n):
    x[i], y[i], a[i] = map(int, input().split())
fill_area = [[0] * w for _ in range(h)]

def fill(l, r, d, u, area):
    for i in range(d, u):
        for j in range(l, r):
            if area[i][j] == 0:
                area[i][j] = 1
        
    

for i in range(n):
    if a[i] == 1:
        fill(0, x[i], 0,  h, fill_area)
    elif a[i] == 2:
        fill(x[i], w, 0, h, fill_area)
    elif a[i] == 3:
        fill(0, w, h - y[i], h, fill_area)
    else:
        fill(0, w, 0, h - y[i], fill_area)
    """
    for j in range(h):
        print(fill_area[j])
    print()
    """
#print(sum(map(sum, fill_area)))
print(h * w - sum(map(sum, fill_area)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}

signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,d[110][2];
    bool b[110];
    cin>>n;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        b[i]=(x==y);
    }
    rep(i,n-2){
        if(b[i]&&b[i+1]&&b[i+2]){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 3644
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n;
int a[200000];

int cnt[60];


bool f(int alpha) {
	memset(cnt, 0, sizeof(cnt));

	rep(i,n){
		int p = a[i];
		if (p >= 60)continue;

		if (cnt[p] == 0)
			for (int j = 1; j <= p; j++)cnt[j] = max(1, cnt[j]);
		else cnt[p]++;
		for (int j = p + 1; j < 60; j++)cnt[j] = 0;

		if (cnt[p] == alpha + 1) {
			while (1<=p && cnt[p] == alpha + 1) {
				cnt[p] = 1;
				cnt[--p]++;
			}
			if (cnt[0])return false;
		}	
	}
	return true;
}



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


	cin >> n;
	rep(i, n)cin >> a[i];

	int lb = 0, ub = n;
	rep(i, n-1) {
		if (a[i] >= a[i+1]) {
			lb = 1;
			break;
		}
	}
	if (lb==0) {
		cout << 1 << endl;
		return 0;
	}


	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		if (f(mid))ub = mid;
		else lb = mid;
	}
	cout << ub << endl;



	return 0;
}

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

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define REP(i, n) for(size_t i = 0; i < (n); i++)
#define REPR(i, n) for(size_t i = (n); i >= 0; i--)
#define FOR(i, a, b) for(size_t i = (a); i < (b); i++)
#define FOREACH(x, a) for(auto& (x) : (a))

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    string S; cin >> S;
    replace(S.begin(), S.end(), '?', 'D');
    cout << S << "\n";
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define mm memset
#define PI 3.14159265358979323846264338327950288419716939937510
#define MAXI (ll)2e5+3
#define M 998244353 
ll power(ll a,ll b){

  ll ans=1;
  while(b--){
    ans=ans*a;
  } 
  return ans;
}
void solve(){

  ll i=0;
  ll n;
  cin>>n;
  ll ans=0;
  for(int i=1;i<=n;i++){
    ll str=i;
    ll no_of_terms=n/i;
    ll common=i;
    ll res=no_of_terms*(2*i+(no_of_terms-1)*i)/2;
 //   cout<<res<<" ";
    ans+=res;
  }
  cout<<ans<<endl;
}
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t=1;
  //cin>>t;
  for(ll i=0;i<t;i++){
    solve();
  }
  return 0;
} 

Measured memory_bytes: 3648
// https://atcoder.jp/contests/abc162/tasks/abc162_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int K_MAX = 200;

int K;

void solve() {
  int ans = 0;
  FOR(a, 1, K) FOR(b, 1, K) {
    int ab = gcd(a, b);
    FOR(c, 1, K) ans += gcd(ab, c);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &K);
}

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


Measured memory_bytes: 3812
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
long long gcd(long long a, long long b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int main() {
	long long n, a, k, sum = 1; cin >> n >> k;
	int test[123456] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a; test[h] = abs(a - k);
	}
	if (n == 1) {
		cout << abs(a - k) << endl; return 0;
	}
	for (int h = 1; h < n; h++) {
		if (h == 1) {
			sum = gcd(test[h - 1], test[h]);
		}
		else {
			sum = gcd(sum, gcd(test[h - 1], test[h]));
		}
	}
	cout << sum << endl;
	cin >> n;
}

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

using namespace std;


#define int long long
#define endl '\n'


void solve() {
    long double a , b , x;
    cin>>a>>b>>x;
    if(x <= 0.5 * b * a * a){
        // triangle
        long double r = atan((b * b * a) / (2 * x));
        r = r * 180.0 / acos(-1);
        cout<<fixed<<setprecision(10)<<r<<endl;
    }else {
       long double k = (2.0 * x / (a * a) ) - b;
       k = b - k;
       long double r = atan(k / a);
       r = r * 180.0 / acos(-1);
       cout<<fixed<<setprecision(10) <<r<<endl;
    }
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
int n,d;
main()
{
	while(cin>>n>>d,n)
	{
		vector<int>s(n,0);
		vector<stack<int> >p(n);
		int M=0;
		for(int i=0;i<n;i++)
		{
			int m;cin>>m;
			for(int j=0;j<m;j++)
			{
				int a;cin>>a;
				s[i]+=a;
				p[i].push(a);
			}
			M=max(M,s[i]);
		}
		for(;M;)
		{
			bool flag=false;
			for(int i=0;i<n;i++)
			{
				if(p[i].size()&&M-s[i]+p[i].top()<=d)
				{
					s[i]-=p[i].top();
					p[i].pop();
					flag=true;
				}
			}
			M=0;
			int cnt=0,mi;
			for(int i=0;i<n;i++)M=max(M,s[i]);
			for(int i=0;i<n;i++)
			{
				if(M==s[i])
				{
					cnt++;
					mi=i;
				}
			}
			if(cnt==1)
			{
				int LM=0;
				for(int i=0;i<n;i++)if(mi!=i)LM=max(LM,s[i]);
				if(p[mi].size()&&LM-s[mi]+p[mi].top()<=d)
				{
					s[mi]-=p[mi].top();
					p[mi].pop();
					flag=true;
					M=LM;
				}
			}
			if(!flag)
			{
				break;
			}
		}
		cout<<(M?"No":"Yes")<<endl;
	}
}



Measured memory_bytes: 3152
s=input()
x,y=map(int,input().split())
xpossible=[0]
ypossible=[0]
j=0
while s[j]=='F':
  j+=1
  xpossible[0]+=1
  if j==len(s):
    break
counter=0
i=j
while i<len(s):
  current=0
  while s[i]=='F':
    i+=1
    current+=1
    if i==len(s):
      break
  r=set()
  if counter==0:
    for j in xpossible:
      r.add(j+current)
      r.add(j-current)
    xpossible=[]
    for j in r:
      xpossible.append(j)
  else:
    for j in ypossible:
      r.add(j+current)
      r.add(j-current)
    ypossible=[]
    for j in r:
      ypossible.append(j)
  if i==len(s):
    break
  current=0
  while s[i]=='T':
    i+=1
    current+=1
    if i==len(s):
      break
  counter=(counter+current)%2
if x in xpossible and y in ypossible:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 50012
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x) (x.begin(),x.end()) 
#define sz(v) ((int)(v.size()))
#define endl '\n'
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 
 
int32_t main(){
  fast; 
/*  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif */
    
  int T=1; //cin>>T; 
  while(T--){

    int n; cin>>n; 
    int x=n/1000; x++; x*=1000; 
    cout<<(x-n)%1000<<endl; 







  






  }
    


  return 0; 
} 

Measured memory_bytes: 3664
import java.util.*;
import java.lang.*;



public class Main {
    static void possible(){
        System.out.println("Yes");
        System.exit(0);
    }
    static void impossible(){
        System.out.println("No");
        System.exit(0);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        char[][] picture = new char[N][N];
        for(int h=0; h<N; h++) {
            String line = sc.next();
            for(int w=0; w<N; w++) picture[h][w]=line.charAt(w);
        }

        char[][] pattern = new char[M][M];
        for(int h=0; h<M; h++) {
            String line = sc.next();
            for(int w=0; w<M; w++) pattern[h][w]=line.charAt(w);
        }

        for(int cx=0; cx<=N-M; cx++) for(int cy=0; cy<=N-M; cy++){
            boolean match = true;
            for(int dx=0; dx<M; dx++) for(int dy=0; dy<M; dy++){
                if(picture[cx+dx][cy+dy]!=pattern[dx][dy]) match=false;
            }
            if(match) possible();
        }
        impossible();

    }
}


Measured memory_bytes: 21588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    String[] str = new String[n];
    int[] l = new int[n];
    int[] r = new int[n];
    int sum = 0;
    for(int i=0; i<n; i++) {
      str = in.readLine().split(" ");
      l[i] = Integer.parseInt(str[0]);
      r[i] = Integer.parseInt(str[1]);
      sum += r[i] - l[i] + 1;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 33800