akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
char buf[20000];sz;
inline int rd()
{
	int ret=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		ret=ret*10+k-'0';
	}
	return ret;
}
int d[3001];
const int mod=998244353;
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=0;i<N;i++)
	{
		++d[S];
		int A=rd();
		for(int j=0;j<=S-A;j++)
		{
			d[j]+=d[j+A];
			d[j]-=mod*(d[j]>=mod);
		}
		ans+=d[0];
		if(ans>=mod)ans-=mod;
	}
	printf("%d",ans);
}

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

int main() {
    int n, cnt = 0;;
    cin >> n;
    vector<string> s(n);
    map<string, bool> already_have;
    for(int i=0; i<n; i++){
        cin >> s[i];
    }
    for(int i=0; i<n; i++){
        if(already_have.find(s[i])==already_have.end()){
            cnt++;
            already_have[s[i]] = true;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 25088
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int j = scanner.nextInt();
        int k = scanner.nextInt();
        int tmp = 0;
        
        if(i>j){
            tmp = i;
            i = j;
            j = tmp;
        }
        if(i>k){
            tmp = i;
            i = k;
            k = tmp;
        }
        if(j>k){
            tmp = j;
            j = k;
            k = tmp;
        }
        System.out.println(Integer.toString(i) + " " + Integer.toString(j) + " " + Integer.toString(k));
    }
    
 
}


Measured memory_bytes: 26228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    ll t;
    cin >> n >> t;
    ll now = t;
    ll ans = t;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        if (now > tmp) {
            ans += tmp+t-now;
            now = tmp+t;
        }
        else{
            ans+=t;
            now = tmp+t;
        } 
    }
    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	int n, m;
	cin >> n >> m;
	REP(i, n + 1) {
		REP(j, n - i + 1) {
			int k = n - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == m) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
import sys
n, c, k = map(int, input().split())
a = list(map(int, sys.stdin.readlines()))+[10**10]
a.sort()
ans, cnt, tmp = 0, 1, a[0]+k
for i in a[1:]:
    if i <= tmp and cnt < c:
        cnt += 1
    else:
        tmp, cnt = i + k, 1
        ans += 1

print(ans)

Measured memory_bytes: 20096
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define fast_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265358979323
typedef long long ll;
const int INF = 1e9+5;
ll MOD(ll ans, ll m)
{
    return (ans % m + m) % m;
}
/*ll dp(int i)
{
    if(i >= n-1)
    {
        return 0;
    }
    if(mem[i] != -1)
        return mem[i];
    ll p1 = 0, p2 = 0;
    //if(i+1 <= n-1)
    p1 = abs( a[i] - a[i+1] ) + dp(i+1);
    //if(i+2 <= n-1)
    p2 = abs( a[i] - a[i+2] ) + dp(i+2);
    return mem[i] = min(p1,p2);
}*/
int main()
{
    fast_IO;
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i=0; i<n; i++)
    {
        cin>>h[i];
    }
    vector<int> dp(n,INF);
    dp[0] = 0;
    for(int i=0;i<n;i++)
    {
        for(int j = i+1 ; j <= i+k ; j++)
        {
            if(j < n)
            {
                dp[j] = min(dp[j] , dp[i] + abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007
#define pi atan(1) * 4

int main()
{
	int n;
	cin >> n;
	map<int, int> cnt;
	for(int i = 0; i < n; i++){
		int d;
		cin >> d;
		if(cnt.find(d) == cnt.end()) cnt[d] = 1;
		else cnt[d]++;
	}
	int m;
	cin >> m;
	int t[200001];
	for(int i = 0; i < m; i++){
		cin >> t[i];
	}
	for(int i = 0; i < m; i++){
		if(cnt.find(t[i]) == cnt.end() || cnt[t[i]] == 0){
			cout << "NO" << endl;
			return 0;
		}
		cnt[t[i]]--;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 10368
N, A, B = [int(x) for x in input().split()]

ans = 0

for i in range(1, N + 1):
	SUM = 0
	n = i
	while n > 0:
		SUM += n % 10
		n = n // 10
	if SUM >= A and SUM <= B:
		ans += i

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> chair1(N),chair2(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>chair1.at(i)>>chair2.at(i);
    ans+=1+chair2.at(i)-chair1.at(i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif len(e)%2:d.pop()
   else:d.popleft()
 print(*d)
if'__main__'==__name__:s()


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

void solve() {
    int N, M;
    cin >> N >> M;
    vector<int> S(N);
    rep(i, M) {
        int k; cin >> k;
        rep(j, k) {
            int s; cin >> s;
            s--;
            S[s] |= 1 << i;
        }
    }
    auto rec = [&](auto &&rec, int depth, int oi) -> int {
        if(depth == N) {
            if(oi == 0) return 1;
            else return 0;
        }
        return rec(rec, depth + 1, oi) + rec(rec, depth + 1, oi ^= S[depth]);
    };
    int bit = 0;
    rep(i, M) {
        int p; cin >> p;
        if(p) bit |= 1 << i;

    }
    cout << rec(rec, 0, bit) << '\n';
}

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


Measured memory_bytes: 3628
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

a,b,c,d =map(int,input().split())
e = (c*d)//gcd(c,d)
ac = a//c   
if a % c == 0:
    ac-=1
bc = b//c 

ad=a//d 
if a % d == 0:
    ad-=1
bd= b//d


acd = a//e 
if a % e == 0:
    acd-=1
bcd= b//e 


count = b-a+1
count -= bc-ac
count -= bd-ad
count += bcd-acd

print(count)
##print(e)
#print(bcd-acd)
#print(bd-ad)
#print(bc-ac)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double n,m,x,y;
    cin>>n>>m;
    int count=0;
    while(n--)
    {
        cin>>x>>y;
        if(x*x + y*y <= m*m)
        count++;
    }
    cout<<count;
    return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>
int main()
{
    int A,B,C,D;
    scanf("%d%d%d%d", &A, &B, &C, &D);
    if(A+B <= C+D){
        if(A+B < C+D)
        {printf("Right\n");}
        else{printf("Balanced\n");}
    }else{
       printf("Left\n") ;

    }

    return 0;
}


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

using namespace std;


int main() {
    int month;
    int day;
    int year;
    char data[10];

    cin >> data;

    sscanf(data, "%d/%d/%d", &year, &month, &day);

    if (year <= 2018) {
        cout << "Heisei";
    } else if (year == 2019 && month <= 4 && day <= 30) {
        cout << "Heisei";
    } else {
        cout << "TBD";
    }

    return 0;
}

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

int main(){
    long int m,f,b,a,sum;
    cin >> m >> f >> b;
    a=m+f;

     if(a>=b){
         if(m>=b){
             cout << "0" << '\n';
         }else{
             sum=b-m;
             cout << sum << '\n'; 
         }
        
    }else if(a<b){
        cout << "NA" << '\n';  
     }

    return 0;

}


Measured memory_bytes: 3092
import sys
h,w=map(int,input().split())
if w==1:
  print(1)
  sys.exit()
if h==1:
  print(1)
  sys.exit()
if w%2==0:
  l=w//2
  print(l*h)
else:
  l=(w+1)//2
  m=(h+1)//2
  n=h-m
  print(l*m+(l-1)*n)
  


Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n;
	cin >> n;
	int parity=n%2;
	int a[n+1];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2 == parity){
			cout << "0\n";
			return 0;
		}
	}
	if(n==1){
		cout << (a[0]==0) << "\n";
	}else{
		a[n]=INF;
		sort(a,a+n+1);
		int prev=a[0],num=1,ans=1;
		for(int i=1;i<=n;i++){
			if(prev==a[i]) num++;
			else{
				if(prev!=0 && num==2){
					//printf("%d %d\n",prev,a[i]);
					ans*=2;
					ans%=MOD;
				}
				else if(prev==0 && num==1){}
				else{
					cout << "0\n";
					return 0;
				}
				num=1;
			}
			prev=a[i];
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 640
mod = 10**9+7
N = int(input())
A = list(map(int,(input().split())))
bi = [[0]*2 for _ in range(60)]
for i in range(N):
    c = 0
    while c < 60:
        if A[i] & 1 == 0:
            bi[c][0] += 1
        else:
            bi[c][1] += 1
        A[i] >>= 1
        c += 1
ans = 0
for i in range(60):
    ans += bi[i][0] * bi[i][1] * pow(2,i)
    ans %= mod
print(ans)

Measured memory_bytes: 125624
n=int(input())
ac,wa,tl,re=0,0,0,0
for i in range(n):
  s=input()
  if(s=="AC"):
    ac+=1
  elif(s=="WA"):
    wa+=1
  elif(s=="TLE"):
    tl+=1
  else:
    re+=1
print("AC",'x',ac)
print("WA",'x',wa)
print("TLE",'x',tl)
print("RE",'x',re)
   


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

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


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

int main(){
  string a, b;
  cin >> a;
  cin >> b;
  if(a.size()>b.size())cout << "GREATER" << endl;
  else if(a.size()<b.size())cout << "LESS" << endl;
  else{
    for(int i=0;i<a.size();i++){
      if(a[i]>b[i]){
        cout << "GREATER" << endl;
        break;
      }
      else if(a[i]<b[i]){
        cout << "LESS" << endl;
        break;
      }
      else{
        if(i==a.size()-1)cout << "EQUAL" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
require "prime"
A = Prime.each(30).to_a.select{|v|v>2}

n = gets.to_i
ans = 0
A.permutation(2) do |i,j|
    if i ** 3 * j <= n
        ans += 1 
    end
end
A.combination(3) do |i,j,k|
    if i * j * k <= n
        ans += 1 
    end
end
puts ans

Measured memory_bytes: 2044
import heapq

n = int(input())
v = list(map(int, input().split()))
heapq.heapify(v)
while len(v) > 1:
    x = heapq.heappop(v)
    y = heapq.heappop(v)
    heapq.heappush(v, (x + y) / 2)
print(v[0])

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}




int main(){
	ll n, m, x;
	cin >> n >> m >> x;
	vector<ll> c(n);
	vector<vector<ll>> a(n, vector<ll>(m));
	rep(i, n)
	{
		cin >> c[i];
		rep(j,m){
			cin >> a[i][j];
			a[i][j];
		}
	}
	ll ans = Inf;
	rep(i, 1 << n)
	{
		vector<ll> temp(m, 0);
		ll tc = 0;
		rep(j, n)
		{
			if(((i>>j)&1)==1){
				tc += c[j];
				rep(k, m)
				{
					temp[k] += a[j][k];
				}
			}
		}
		int f = 1;
		rep(k, m)
		{
			if(temp[k] < x){
				f = 0;
			}
		}
		if(f == 1){
			ans = min(tc, ans);
		}
	}
	if(ans == Inf)
		cout << -1 << endl;
	else 
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int n,x,ar[105];
int32_t main(){
	cin>>n>>x;
	for(int i=1;i<=n;i++) cin>>ar[i];
	sort(ar+1,ar+n+1);
	int ans = 0;
	for(int i=1;i<=n;i++){
		x-=ar[i];
		if(x>=0) ans++;
		else break;
	}
	if(x>0) ans-=!!ans;
	cout<<ans;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
a.sort(reverse=True)
ans = 0
for i in range(1, 2 * n, 2):
    ans += a[i]
print(ans)

Measured memory_bytes: 39224
/*
    Solution by:- 
	--------------Sannidhay Vashal
	----------------NIT SRINAGAR
 
*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<climits>
#include<set> 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ull unsigned long long int
#define cinll(x) ll x;cin>>x;
#define cini(x) int x;cin>>x;
#define cout(x) cout<<x;
#define vect(x) vector<ll> x;
#define vect1(x) vector<ll> x;x.push_back(0);
#define vectdef(x,size,val) vector<ll> x;for(ll i=0;i<size;i++){x.push_back(val);}
#define vectdef1(x,size,val) vector<ll> x;for(ll i=0;i<=size;i++){x.push_back(val);}
#define pb(x) push_back(x);
#define MAX INT_MAX;
#define MIN INT_MIN;
#define MOD 1000000007;
 
using namespace std;

int main(){
	cinll(a);cinll(b);cinll(c);
  	cout<<c<<" "<<a<<" "<<b;	
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import numpy

K , N = map(int,input().split())
A = list(map(int,input().split()))

sorted(A)

total = K

for i in range(N):
    tmp =0
    if i < N -1:
        tmp = A[i+1] - A[i]
        total = min(K-tmp , total)
    else:
        tmp = K - A[i] + A[0]
        total = min(K-tmp , total)


print(total)

Measured memory_bytes: 42968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,s.size()){//A=65
    s[i] = (s[i]-'A'+ n)%26 + 'A';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())

links = [[] for _ in range(N + 1)]
for _ in range(M):
    L, R, D = map(int, input().split())
    links[L].append((R, D))
    links[R].append((L, -D))

t = [None] * (N + 1)
for i in range(1, N + 1):
    if t[i] is not None:
        continue
    t[i] = 0
    s = deque([i])
    while s:
        j = s.popleft()
        for k, l in links[j]:
            if t[k] is None:
                t[k] = t[j] + l
                s.append(k)
            else:
                if t[k] != t[j] + l:
                    print('No')
                    exit()
print('Yes')


Measured memory_bytes: 66248
#include <cstdio>
#include <iostream>

using namespace std;

int w, h;
int d1[4] = {1, -1, 0, 0};
int d2[4] = {0, 0, 1, -1};
char room[105][105];

void dfs(int x, int y, char c){
	room[x][y] = 'X';
	int xx, yy;
	for(int i = 0; i < 4; i++){
		xx = x + d1[i];
		yy = y + d2[i];
		if(0 <= xx && xx < h && 0 <= yy && yy < w && room[xx][yy] == c){
			dfs(xx, yy, c);
		} 
	}
}

int main(){
	while(scanf("%d %d", &h, &w) == 2){
		if(!h && !w){
			break;
		}
        getchar();
		for(int i = 0; i < h; i++){
			scanf("%s", room[i]);
		}
		int res = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(room[i][j] != 'X'){
					dfs(i, j, room[i][j]);
					res++;
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define mod  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
ll n;

vector<vector<ll> > product(vector<vector<ll> >v,vector<vector<ll> >u){
    vector<vector<ll> > res(n,vector<ll>(n));
    rep(i,n){
        rep(j,n){
            rep(k,n){
                res[i][j] += v[i][k]*u[k][j]%mod;
                res[i][j] %= mod;
            }
        }
    }
    return res;
}
vector<vector<ll> > I;
vector<vector<ll> > ruijo(vector<vector<ll> >v,ll k){
    if(k==0){
        return I;
    }else if(k==1){
        return v;
    }
    if(k%2==0){
        vector<vector<ll> > tmp = ruijo(v,k/2);
        return product(tmp,tmp);
    }else{
        vector<vector<ll> > tmp = ruijo(v,k/2);
        return product(product(tmp,tmp),v);
    }

}

int main(){
    ll k;
    cin >> n >> k;
    I.resize(n);
    rep(i,n){
        I[i].resize(n);
    }
    rep(i,n){
        rep(j,n){
            if(i==j){
                I[i][j] = 1;
            }
        }
    }
    vector<vector<ll> > s(n,vector<ll>(n));
    rep(i,n){
        rep(j,n)cin >> s[i][j];
    }
    vector<vector<ll> > res = ruijo(s,k);
    ll ans = 0;
    rep(i,n){
        rep(j,n){
            //cerr << res[i][j] << " ";
            ans += res[i][j];
            ans %= mod;
        }
        //cerr << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s = sc.next();

        int tmp = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            char c = s.charAt(i);
            if (c == 'I') {
                tmp++;
                max = Math.max(max, tmp);
            } else {
                tmp--;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(lcm(in.nextInt(), in.nextInt()));
    }
    public static long lcm(long number1, long number2) {
        long absNumber1 = Math.abs(number1);
        long absNumber2 = Math.abs(number2);
        long absHigherNumber = Math.max(absNumber1, absNumber2);
        long absLowerNumber = Math.min(absNumber1, absNumber2);
        long lcm = absHigherNumber;
        while (lcm % absLowerNumber != 0) {
            lcm += absHigherNumber;
        }
        return lcm;
    }
}

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

char mas[257][257];
int dx[]={-1,0,1,1,1,0,-1,-1};
int dy[]={-1,-1,-1,0,1,1,1,0};
int dfs(int x,int y,int k);
int n;

int main(){
  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin >> mas[i][j];
      }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(mas[i][j] == '1'){
	  for(int k=0;k<8;k++){
	    ans = max(ans,dfs(j,i,k) + 1);
	  }
	}
      }
    }
    cout << ans << endl;
  }
}

int dfs(int x,int y,int k){
  int nx = x + dx[k];
  int ny = y + dy[k];
  if(mas[ny][nx] == '1' && ny >= 0 && nx >= 0 && ny < n && nx < n){
    return (dfs(nx,ny,k) + 1);
  }
  return 0;
}
  

Measured memory_bytes: 1224
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt() * 2;
		
		if (a <= b ){
			System.out.print(0);
		}else{
			System.out.print(a-b);
		}
		
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int D = scn.nextInt();
        long[] c = new long[26];
        long[][] s = new long[D][26];
        int cNum = 0;
        int[] ld = new int[26];
        Arrays.fill(ld,0);

        for(int i=0;i<26;i++){
            c[i]=scn.nextLong();
        }

        for(int i=0;i<D;i++){
            long cCheck = 0;

            for(int j=0;j<26;j++){
                if((i-ld[j])*c[j]>cCheck){
                    cCheck=(i-ld[j])*c[j];
                    cNum = j;
                }
            }
            ld[cNum]=i;
            System.out.println(cNum+1);

        }


        scn.close();

    }


}


Measured memory_bytes: 27964
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def unchi(x,m,n):
  r=x//m+x//n-x//(m*n//(gcd(m,n)))
  return r
a,b,c,d=(int(i) for i in input().split())
print(b-a+1-(unchi(b,c,d)-unchi(a-1,c,d)))

Measured memory_bytes: 3060
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4448283280358331064;

/*
int main(){
    int n;
    cin>>n;
    ll k;
    cin>>k;
    vector<ll> pos(0), neg(0);
    int zero=0;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a>0) pos.push_back(a);
        if(a==0) zero++;
        if(a<0) neg.push_back(-a);
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    ll ub=INF;
    ll lb=-INF;
    while(ub-lb>1){
        ll m=(ub+lb)/2;
        ll num=0;
        //cout<<m<<endl;
        if(m<=0){
            for(ll u:neg){
                num+=pos.end()-upper_bound(pos.begin(),pos.end(),-m/u);
            }
        }else{
            num+=neg.size()*pos.size();
            num+=zero*(neg.size()+pos.size());
            num+=zero*(zero-1)/2;
            for(int i=0;i<pos.size();i++){
                num+=lower_bound(pos.begin()+i, pos.end(), m/pos[i])-(pos.begin()+i);
            }
            for(int i=0;i<neg.size();i++){
                num+=lower_bound(neg.begin()+i, neg.end(), m/neg[i])-(neg.begin()+i);
            }
        }
        if(num<=k){
            lb=m;
        }else{
            ub=m;
        }
    }
    cout<<ub<<endl;
}

*/

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.length()<=n){
        cout<<s<<endl;
        return 0;
    }
    string ans;
    for(int i=0;i<n;i++){
        ans+=s[i];
    }
    ans+="...";
    cout<<ans<<endl;
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a[4], b, c, ans;
	
	cin>>a[0]>>a[1]>>a[2];
	
	
	if(a[0] > a[1] && a[0] > a[2]) {
		cout<<'A'<<endl;
	} 
	else if(a[1] > a[0] && a[1] > a[2]){
		cout<<'B'<<endl;
	} else {
		cout<<'C'<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3216
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC138B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var nums = Console.ReadLine().Split(' ').Select(x => decimal.Parse(x));

            decimal sum = 0;
            foreach(var num in nums)
            {
                sum += (1 / num);
            }

            Console.WriteLine(1 / sum);
        }
    }
}


Measured memory_bytes: 13268
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] R=new int[n];
		for(int i=0;i<n;i++){
			R[i]=sc.nextInt();
		}
		int maxv=R[1]-R[0];
		int minv=R[0];
		for(int j=1;j<n;j++){
			maxv=Math.max(maxv,R[j]-minv);
			minv=Math.min(minv,R[j]);
		}
		System.out.println(maxv);
	}
}


Measured memory_bytes: 101180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


Measured memory_bytes: 32976
#include <stdio.h>

typedef struct {
    char suit;
    int value;
} Card;

void swap_Card(Card *x, Card *y)
{
    Card temp = *x;
    *x = *y;
    *y = temp;
}

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

    int i;
    Card BC[N];
    Card SC[N];

    for (i = 0; i < N; i++) {
        Card c;
        scanf("%c", &c.suit);
        scanf("%d ", &c.value);
        BC[i] = c;
        SC[i] = c;
    }

    int j;

    /* Bubble Sort */
    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].value < BC[j - 1].value)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }

    /* Selection Sort */
    for (i = 0; i < N - 1; i++) {
        int min_i = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].value < SC[min_i].value)
                min_i = j;
        }
        swap_Card(&SC[i], &SC[min_i]);
    }

    /* Output */
    for (i = 0; i < N - 1; i++)
        printf("%c%d ", BC[i].suit, BC[i].value);
    printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);

    puts("Stable");

    for (i = 0; i < N - 1; i++)
        printf("%c%d ", SC[i].suit, SC[i].value);
    printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

    for (i = 0; i < N; i++) {
        if (BC[i].suit != SC[i].suit) {
            puts("Not stable");
            return 0;
        }
    }
    puts("Stable");

    return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		while(x%2==0)
		{
			ans++;
			x/=2;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll a, b;
string str;

int main(){
	cin >> a >> b;
	
	ll buf = 1;
	ll ans = 0;
	while(buf < b){
		buf += -1+a;
		ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	static int n;
	static int w;
	static int[] weights;
	static int[] values;
	static HashMap<String, Long> memo;
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		n = in.nextInt();
		w = in.nextInt();
		weights = new int[n];
		values = new int[n];
		
		for (int i = 0; i < n; i++) {
			weights[i] = in.nextInt();
			values[i] = in.nextInt();
		}
		memo = new HashMap<String, Long>();
		
		System.out.println(solve2(0, 0));
	}
	
	public static long solve2(int index, long weight) {
		String s = index + "," + weight;
		if (w < weight) {
			return Integer.MIN_VALUE;
		} else if (index == n) {
			return 0;
		} else if (memo.containsKey(s)) {
			return memo.get(s);
		}
		
//		long temp = solve2(index + 1, weight);
//		if (weight + weights[index] <= w) {
//			long temp = Math.max(temp, values[index] + solve2(index + 1, weight + weights[index]));
//		}
		long temp = Math.max(solve2(index + 1, weight), values[index] + solve2(index + 1, weight + weights[index]));
		
		memo.put(s, temp);
		return temp;
	}
	
	public static long solve(int index, long weight, long value) {
		String s = index + "," + weight;
		if (w < weight) {
			return Integer.MIN_VALUE;
		} else if (index == n) {
			return value;
		} else if (memo.containsKey(s)) {
			return memo.get(s);
		}
		
		long temp = Math.max(
				solve(index + 1, weight, value),
				solve(index + 1, weight + weights[index], value + values[index])
		);
		memo.put(s, temp);
		
		return temp;
	}
}

Measured memory_bytes: 59996
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a,b=map(int,input().split())
if a%b==0:
    print(0)
else :
    print(1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int N, W;
    cin>>N>>W;
    vector<long long> w(N), v(N);
    
    long long s = 0;
    for(int i = 0; i<N; i++)
    {
        cin>>w[i]>>v[i];
        s += v[i]; 
    }
    vector<vector<long long>> dp(N+1, vector<long long>(s+1,INT_MAX));
    for(int i = 0; i<=N; i++)
    {
        dp[i][0] = 0;
    }
    for(int i = 1; i<=N; i++)
    {
        for(int j = 1; j<=s; j++)
        {
            if(v[i-1] <= j)
            {
                dp[i][j] = min(dp[i-1][j], w[i-1] + dp[i-1][j - v[i-1]]);
            }
            else
                dp[i][j] = dp[i-1][j];
        }
    }
    
    // for(auto j : dp)
    // {
    //     for(auto i : j)
    //         cout<<i<<" ";
    //     cout<<"\n";
    // }
    
    long long ans = -1;
    for(int j = 0; j<=s; j++)
    {
        if(dp[N][j] <= W)
        {
            ans = j;
        }
    }
    
    
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 83248
import sys
n = int(input())
s = list(map(int, input().split()))
c = 0
a = 'a'
def merge(A, left, mid, right):
    global c
    L = A[left:mid]
    R = A[mid:right]
    L.append(sys.maxsize)
    R.append(sys.maxsize)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergesort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)

mergesort(s, 0, n)

for i in range(n-1):
    print(s[i], end=' ')
print(s[n-1])
print(c)


Measured memory_bytes: 63432
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;


public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] a = sc.nextIntList(N);
		
		Arrays.sort(a);
		for (int i = 0; i < N / 2; i ++) {
			int tmp = a[i];
			a[i] = a[N - i - 1];;
			a[N - i - 1] = tmp;
		}

		int v = 0;
		while (v < a.length - 1 && a[v + 1] > v + 1) {
			v ++;
		}
		int x = 0;
		while (v + x < a.length && a[v + x] > v) {
			x ++;
		}

		int y = a[v] - v;
		
		
		System.out.println(x % 2 == 1 && y % 2 == 1 ? "Second" : "First");
	}
	
}



class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 12432
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include<string>
#include <algorithm>
#include <functional>
#include <cmath>
using namespace std;
typedef vector <int> ivector;


int main(){
	int N;
	cin >> N;
	for (int i = 0; i < N; i++){
		int a, b, c;
		cin >> a >> b >> c;
		int ma = max(a, max(b, c));
		int mi = min(a, min(b, c));
		int mid = a + b + c - ma - mi;
		if (pow(ma,2)==pow(mi,2)+pow(mid,2)){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	

	return 0;
}

Measured memory_bytes: 1152
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut vec: Vec<usize> = vec![];
    for _ in 0..N {
        vec.push(read());
    }
    let mut tmp = 0;
    for i in vec {
        if i == tmp + 1 {
            tmp += 1;
        }
    }
    if tmp == 0 {
        println!("-1");
    } else {
        println!("{}", N - tmp);
    }
}


Measured memory_bytes: 6396
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------

VVB path(10, VB(10, false));
// 与えられたグラフの隣接行列
// path[a][b] = true <=> a-b間に辺がある

int N, M;
int ans = 0;
int vcount = 0;         // いくつの頂点を訪れたかを記録する
VB visited(10, false);  // 各頂点に訪れたか否かを記録する


void dfs(int from) {

  visited[from] = true;
  vcount++;

  if (vcount == N) {
    ans++;
  } else {

    NREP(to, N) {
      if (!visited[to] && path[from][to]) {
        dfs(to);
      }
    }
  }

  visited[from] = false;
  vcount--;
  return;
}


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

  cin >> N >> M;

  REP(i, M) {
    int a, b;
    cin >> a >> b;
    path[a][b] = path[b][a] = true;
  }

  dfs(1);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
map<ll,ll>mp;

int main ()
{
    ll n,s=0,t=0;
    cin>>n;
    ll a[n+10],b[n+10];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
       cin>>b[i];
   }
   for(int i=0;i<n;i++)
   {
       if(a[i]>b[i])
       {
           s+=a[i];
           t+=b[i];
       }
   }
    cout<<s-t<<endl;
    return 0;

}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int L;
	cin >> L;

	double ans = (double)(L) * (double)(L)* (double)(L) / 27.0;

	cout << setprecision(20) << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)
const ll MOD=1e9+7;

template<typename T,bool Mono>
struct ConvexHullTrick{
    typedef function<bool(T,T)> C;
    #define F first
    #define S second
    using Line=pair<T,T>;
    C cmp;
    deque<Line> Lines;
    ConvexHullTrick(C cmp=[](T l,T r){return l>=r;})
        :cmp(cmp){}
    bool check(Line l1,Line l2,Line l3){
        if (l1<l3) swap(l1,l3);
        return (l3.S-l2.S)*(l2.F-l1.F)>=(l2.S-l1.S)*(l3.F-l2.F);
    }
    void add(T a,T b){
        Line line(a,b);
        while(Lines.size()>=2&&check(*(Lines.end()-2)
        ,Lines.back(),line)) Lines.pop_back();
        Lines.emplace_back(line);
    }
    T f(int i,T x){
        return Lines[i].F*x+Lines[i].S;
    }
    T f(Line line,T x){
        return line.F*x+line.S;
    }
    T query(T x){
        if (Mono){
            while(Lines.size()>=2
            &&cmp(f(0,x),f(1,x))) Lines.pop_front();
            return f(0,x);
        } else {
            int lb=-1,ub=Lines.size()-1;
            while(ub-lb>1){
                int mid=(lb+ub)>>1;
                (cmp(f(mid,x),f(mid+1,x))?lb:ub)=mid;
            }
            return f(ub,x);
        }
    }
    #undef F
    #undef S
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,C; cin >> N >> C;
    vector<ll> h(N);
    rep(i,N) cin >> h[i];
    ConvexHullTrick<ll,true> CHT;
    vector<ll> dp(N,0);
    rep(i,N){
        if (i) dp[i]=CHT.query(h[i])+h[i]*h[i]+C;
        CHT.add(-2*h[i],h[i]*h[i]+dp[i]);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5632
#include <iostream>

using namespace std;

int main() {
    int x,y,z;
    cin>>x>>y>>z;
    if(x==y and y!=z){
        cout<<"Yes\n";
    }
    else if(x==z and y!=z){
        cout<<"Yes\n";
    }
    else if(z==y and x!=z){
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string debug_string(const string& s) {
	return '"' + s + '"';
}
string debug_string(bool b) {
	return (b ? "true" : "false");
}
string debug_string(const char* s) {
	return debug_string((string)s);
}
template<class T, class U>
string debug_string(const pair<T, U>& p);
template<class U>
struct can_be_string {
	template<typename...>
	static int f(...) {
		return 0;
	}
	template<typename T>
	static char f(decltype(to_string(T()), char())) { 
		return 'a';
	}
	static const bool value = sizeof(f<U>(char())) == sizeof(char);
};
template<class T> 
typename enable_if<can_be_string<T>::value, string>::type debug_string(const T& a) {
	string s = to_string(a);
	return s;
}
template<class T>
typename enable_if<!can_be_string<T>::value, string>::type debug_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += debug_string(x);
	}
	s += "}";
	return s;
}
template<class T, class U>
string debug_string(const pair<T, U>& p) {
	string s = "(";
	s += debug_string(p.first);
	s += ", ";
	s += debug_string(p.second);
	s += ")";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << debug_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int mod2 = 1e9 + 9;
const int inf = 1e9 + 100;
const ll inf64 = 1e18l + 100;
int n, answer = 0;
string s;
vector<int> z;
void max_self(int& a, int b) {
	a = max(a, b);
}
void calculate_z() {
	int l = 0, r = 0;
	z[0] = 0;
	for (int i = 1;i < n;++i) {
		if (i <= r) {
			z[i] = min(z[i - l], r - i + 1);
		}
		while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
			++z[i];
		}
		if (i + z[i] - 1 > r) {
			r = i + z[i] - 1;
			l = i;
		}
	}
}
void solve() {
	for (int i = 1;i < n;++i) {
		max_self(answer, min(z[i], i));
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	cin >> n;
	cin >> s;
	z.resize(n);
	calculate_z();
	while(n > 0) {
		z.clear();
		z.resize(n);
		calculate_z();
		solve();
		s.erase(s.begin());
		--n;
		assert(n == (int)s.size());
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 384
N = gets.to_i
a = N.times.map { gets.split.map(&:to_i) }

dp = [[0, 0, 0]]

1.upto(N) do |i|
  dp[i] = []
  dp[i][0] = [dp[i - 1][1] + a[i - 1][0], dp[i - 1][2] + a[i - 1][0]].max
  dp[i][1] = [dp[i - 1][0] + a[i - 1][1], dp[i - 1][2] + a[i - 1][1]].max
  dp[i][2] = [dp[i - 1][0] + a[i - 1][2], dp[i - 1][1] + a[i - 1][2]].max
end

puts dp[N].max

Measured memory_bytes: 24192