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

typedef double f64;
typedef long long i64;
typedef int i32;
typedef pair<i32, i32> pi32;
typedef unsigned long long u64;
typedef unsigned int u32;
typedef vector<i32> vi32;
typedef deque<i32> di32;

#define all(c) (c).begin(), (c).end()
#define REP(i, a, b) for (auto i = a; i < b; i++)
#define REPA(i, a, b, acc) for (auto i = a; i < b; i += acc)
#define PB push_back
#define PF push_front
#define PRINT(x) cout << #x ": " << (x) << endl;
#define TR(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); (it)++)
#define MAX_PRECISION cout << setprecision(numeric_limits<double>::max_digits10);

i32 main() {
  ios::sync_with_stdio(false);  // Makes IO faster, remove this line if C style scanf/printf needed.

  i32 a, b;
  cin >> a >> b;
  i32 ret = 0;
  if (a < b) {
    swap(a, b);
  }
  ret += a--;
  if (a < b) {
    swap(a, b);
  }
  ret += a;

  cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  int count=0;
  for(int i=0;i<N;i++){
    std::cin >> a[i];
    if(a[i]!=i+1) count++;
  }
  if(count==2||count==0) std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;

using namespace std;

int main() {
    ll N;
    cin >> N;
    //素数生成
    bool isPrime[55556];
    for(int i = 0; i < 55556; i++){
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i < 55556; i++){
        if(isPrime[i]){
            //ふるい実行
            for(int x = i * 2; x < 55556; x += i){
                isPrime[x] = false;
            }
        }
    }
    vector<int> pNs = vector<int>();
    for(int i = 2; i < 55556; i++){
        if(isPrime[i])
        pNs.push_back(i);
    }
    int count = 0;
    int i = 0;
    while (count < N){
        int tmp = pNs[i];
        if(tmp % 5 == 1){
            cout << tmp << " ";
            count++;
        }
        i++;
    }
    cout << endl;
}


Measured memory_bytes: 384
import sys
from collections import deque
# sys.setrecursionlimit(10**7)

def main():
    n, q = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(n-1)]
    px = [list(map(int, input().split())) for i in range(q)]
    adj = [[] for _ in range(n+1)]
    for a, b in ab:
            adj[a].append(b)
            adj[b].append(a)
    # indexが直接初めにノードに加えられる得点
    v = [0] * (n+1)
    for p,x in px:
        v[p] += x
    # 子をindexで、親ノードを要素で
    parent = [None] * (n+1)
    q = deque([1])
    while q:
        par = q.pop()
        for chl in adj[par]:
            if chl == parent[par]:
                continue
            v[chl] += v[par]
            parent[chl] = par
            q.append(chl)
    ans = ' '.join(map(str,v[1:]))
    print(ans)
    
    # def dfs(cur, parent):
    #     for chl in adj[cur]:
    #         print('p', parent)
    #         if chl == parent: 
    #             continue
    #         v[chl] += v[cur]
    #         print('chl,cur', chl, cur)
    #         dfs(chl, cur)

    # dfs(1, 1)
    # ans = ' '.join(map(str,v[1:]))
    # print(ans)

if __name__ == '__main__':
    main()

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;
const int mod = 1e9+7;

int a[N], t[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", t+i);
  for (int i = 0; i < n; ++i) scanf("%d", a+i);
  if (t[n-1] != a[0]) {
    puts("0");
    return;
  }
  long long ans = 1;
  for (int i = 1; i < n-1; ++i) {
    if (a[i] != a[i+1]) {
      if (a[i] > t[i]) {
	puts("0");
	return;
      }
      continue;
    }
    if (t[i] != t[i-1]) {
      if (t[i] > a[i]) {
	puts("0");
	return;
      }
      continue;
    }
    ans = ans * min(a[i], t[i]) % mod;
  }
  printf("%lld", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 4548
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
#define ll long long
#define ld long double
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
 
#define mp make_pair
#define pb push_back
 
#define ft first
#define sd second
 
 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
 
const ll N = 100005;
const ll M = 1000000007;
 
int main(){
  ll h;
  cin>>h;
  ll n;
  cin>>n;
  ll a[n];
  cin>>a[0];
  ll sum=a[0];
  f(i,1,n){
  	cin>>a[i];
  	sum=sum+a[i];
  }
  if(sum>=h){
  	cout<<"Yes";
  }
  else{
  	cout<<"No";
  }
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();

		int k = n/x;
		if ( n%x>0 ) k++;

		System.out.println(k*t);
	}
}

Measured memory_bytes: 35672
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  // bin search
  int N,K; cin >> N >> K;
  vll A(N);
  rep(i,N)cin>>A[i];
  double hi = 1e9;
  double lo = 0;
  double ans = 0;
  auto f = [&](double t) {
    ll cnt = 0;
    rep(i,N){
      cnt += ceil(A[i]/t);
      cnt--;
    }
    return cnt <= K;
  };
  rep(i,100) {
    double mid = (hi+lo)/2.;
    if (f(mid)) hi = mid;
    else lo = mid;
    ans = mid;
  }
  int out = ceil(ans);
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endll '\n'
#define sz(a) (int)(a).size()
#define RWFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e6 + 5, oo = 1e9;
const double pi = acos(-1);
using namespace std;

int main()
{
    assem99
    int n; cin>>n;
    int arr[n + 5], brr[n + 5];
    for(int i = 0; i <= n; i++) cin>>arr[i];
    for(int i = 0; i < n; i++) cin>>brr[i];
    ll ans = 0;
    for(int i = n - 1; i >= 0; i--)
    {
        int cur = min(arr[i + 1], brr[i]);
        ans += cur;
        brr[i] -= cur;
        cur = min(arr[i], brr[i]);
        ans += cur;
        arr[i] -= cur;
    }
    cout<<ans;

    return 0;
}

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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

class edge{
    public:
        int to, from;
};

int N, M;
vector<int> G[MAX];
vector<edge> E;
bool vis[MAX];

void dfs(int n, edge e){
    vis[n] = true;
    for(int i : G[n]){
        if( (n == e.to && i == e.from) or (n == e.from && i == e.to) ){

        } else if(!vis[i]) {
            dfs(i, e);
        }
    }
}

int main(){
    cin >> N >> M;
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge e;
        e.from = a;
        e.to = b;
        E.push_back(e);
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int ans = 0;
    rep(i, M){
        rep(j, N) vis[j] = false;
        dfs(0, E[i]);
        bool flg = true;
        rep(j, N){
            if(!vis[j]) flg = false;
        }
        if(!flg) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
<?php
    $count= array_fill_keys(range("a","z"),0);

    while($string = trim(fgets(STDIN))){
        $char = str_split($string);

        foreach($char as $value){
            if(preg_match('/[a-z]/i',$value)){
                $count[strtolower($value)]++;
            }
        }
    }

    foreach($count as $key => $value){
        echo "$key : $value\n";
    }
    

Measured memory_bytes: 15612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s.at(i);
    }
    
    sort(s.begin(),s.end());
    int count=1;
    for (int i = 0; i < n-1; i++)
    {
        if (s.at(i)!=s.at(i+1))
        {
            count++;
        }
    }
    
    cout << count << endl;
}



Measured memory_bytes: 9540
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();
        int c = sc.nextInt();

        if((b-a) == (c-b)){
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 22996
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N = I()
S = [0]+LI()
S += [0]
dp = [INF]*(N+5)
dp[1] = 0
for i in range(N):
    dp[i+2] = min(dp[i+2],dp[i] + abs(S[i+2]-S[i]))
    dp[i+1] = min(dp[i+1],dp[i] + abs(S[i+1]-S[i]))
print(dp[N])


Measured memory_bytes: 73544
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i]==0){
            cout << 0 << "\n";
            return 0;
        }
    }
    ll ans=a[0];
    for(int i=1; i<n; ++i){
        if(1000000000000000000/ans < a[i]){
            cout << -1 << "\n";
            return 0;
        }
        ans*=a[i];
    }
    cout << ans << "\n";
    return 0;
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"

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

void solve()
{
	ll n,m,k;
	cin>>n>>m>>k;
	vector<int> a(n);
	vector<int> b(m);
	for(auto &x:a)cin>>x;
	for(auto &x:b)cin>>x;
	vector<ll> pa(n+1);
	vector<ll> pb(m+1);
	for(int i=0;i<n;i++){
		pa[i+1]=pa[i]+a[i];
	}
	for(int i=0;i<m;i++){
		pb[i+1]=pb[i]+b[i];
	}
	ll ans=0;
	for(int i=0;i<=n;i++){
		if(pa[i]>k)break;
		int l=0,r=m,best=0;
		ll rem=k-pa[i];
		while(l<=r){
			int mid=l+(r-l)/2;
			if(pb[mid]<=rem){
				l=mid+1;
				best=mid;
			}else r=mid-1;
		}
		ans=max(ans,(ll)i+best);
	}
	cout<<ans<<"\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 7932
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int[] ps = new int[N];
			for(int i = 0; i < N; i++) {
				ps[i] = sc.nextInt();
			}
		
			int answer = 0;
			for(int i = 1; i < N - 1; i++) {
				final int prev = ps[i - 1];
				final int curr = ps[i + 0];
				final int next = ps[i + 1];
				
				if(prev < curr && curr < next) {
					answer++;
				}else if(prev > curr && curr > next) {
					answer++;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int d[n];
  rep(i,n) cin >> d[i];
  sort(d,d+n);
  int a,b;
  int ans;
  if(n%2==0){
    a = d[n/2-1];
    b = d[n/2];
    ans = b-a;
  }else{
    ans = 0;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
using System;

namespace abc109A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            if (A == 2 || B == 2)
                Console.WriteLine("No");
            else
                Console.WriteLine("Yes");
        }
    }
}


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

#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
#define bad gooood

#define left not_right
#define y1 what

using namespace std;

const int N = (int) 1e7 + 10;
const int M = (int) 350;
const int K = (int) 350;
const ll LINF = (ll) 1e18;
const int INF = (int) 1e9 + 7;
const int ALPHA = 26;
const int mod = INF + 2;
const double PI = 3.14159265359;
const ld EPS = (ld) 1e-12;

ll get(int l1, int r1, int l2, int r2) {
  ll ans = 0;
  while (r1 - l1 > 3) {
    ll m1 = l1 + (r1 - l1) / 3;
    ll m2 = r1 - (r1 - l1) / 3;
    if (m1 * (r2 - m1 + 1) > m2 * (r2 - m2 + 1)) {
      r1 = m2;
    } else {
      l1 = m1;
    }
  }
  for (int i = l1; i <= r1; i++) {
    ans = max(ans, i * 1ll * (r2 - i + 1));
  }
  return ans;
}

int main() {
  #define fn "saddle"
  #ifdef witch
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #else
      //freopen(fn".in", "r", stdin);
      //freopen(fn".out", "w", stdout);
  #endif
  int t;
  cin >> t;
  while (t--) {
    int a, b;
    cin >> a >> b;
    ll mult = a * 1ll * b;
    int ptr1 = 0, ptr2 = 0;
    int l = 1, r = a - 1;
    while (l <= r) {
      int m = (l + r) / 2;
      if (get(1, m, b + 1, b + m) >= mult) {
        r = m - 1;
      } else {
        l = m + 1;
        ptr1 = m;
      }
    }
    l = 1, r = b - 1;
    while (l <= r) {
      int m = (l + r) / 2;
      if (get(1, m, a + 1, a + m) >= mult) {
        r = m - 1;
      } else {
        l = m + 1;
        ptr2 = m;
      }
    }
    ptr1++;
    ptr2++;
    ll cnt = 0;
    cnt += ptr1 - 1 + ptr2 - 1;
    cnt += min(a - ptr1, b - ptr2);
    cout << cnt << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool is_palidrome(int s,int e,string str)
{
  int i=s,j=e;
  while(i<j)
  {
    if(str[i]!=str[j])
      return false;
    i++;
    j--;
  }
  return true;
}
int main()
{
  string str;
  cin>>str;
  int n=str.length();
  if(is_palidrome(0,(n-1)/2-1,str)&&is_palidrome(0,n-1,str))
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

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

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N = nextInt();

	vector<int> A;
	inputVector(A, N);

	priority_queue<int> q;
	rep(i, N) {
		q.push(A[i]);
	}

	map<int, int> m;
	for (int i = N - 1; i >= 0; i--) {
		m.insert(make_pair(q.top(), i));
		q.pop();
	}

	int cnt = 0;
	rep(i, N) {
		A[i] = m[A[i]];
		if (i % 2 != A[i] % 2) {
			cnt++;
		}
	}

	cout << cnt / 2 << endl;

    return 0;
}


Measured memory_bytes: 8052
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	string a;
	cin>>n;
	for(int k=0;k<n;k++){
		int answer=0;
		for(int j=0;j<2;j++){
		cin>>a;
		int count=1;
		for(int i=0;i<a.size();i++){
			bool t=true;
			if(a[i]=='m'){
				answer+=count*1000;
				count=1;
				t=false;
			}
			if(a[i]=='c'){
				answer+=count*100;
				count=1;
				t=false;
			}
			if(a[i]=='x'){
				answer+=count*10;
				count=1;
				t=false;
			}
			if(a[i]=='i'){
				answer+=count;
				count=1;
				t=false;
			}
			if(t==true)
				count=a[i]-'0';
		}
		}
		if(answer>=1000&&answer<2000){
			cout<<"m";
			answer-=1000;
		}
		if(answer>=2000){
			cout<<answer/1000<<"m";
			answer%=1000;
		}

		if(answer>=100&&answer<200){
			cout<<"c";
			answer-=100;
		}
		if(answer>=200){
			cout<<answer/100<<"c";
			answer%=100;
		}

		if(answer>=10&&answer<20){
			cout<<"x";
			answer-=10;
		}
		if(answer>=20){
			cout<<answer/10<<"x";
			answer%=10;
		}
		
		if(answer==1){
			cout<<"i";
			answer--;
		}
		if(answer>=2)
			cout<<answer<<"i";
		cout<<endl;
	}
    return 0;
}

Measured memory_bytes: 1204
n = int(input())
t = input()
lef = 0
rig = 0
cl = 0
cr = 0

for i in range(n):
    if t[i] == ")":
        rig += 1
        if rig > lef+cl:
            cl += 1
    if t[i] == "(":
        lef += 1
lef = 0
rig = 0
for i in reversed(range(n)):
    if t[i] == "(":
        lef += 1
        if lef > rig+cr:
            cr += 1
    if t[i] == ")":
        rig += 1

for i in range(cl):
    print("(",end="")
print(t,end="")
for i in range(cr):
    print(")",end="")

Measured memory_bytes: 3064
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
const int MOD = 1e9 + 7;

// mod p （pは素数）の下でのべき乗を求める
ll mod_pow(ll a, ll n, ll p) {
		ll result = 1;
		while (n > 0) {
			if (n & 1) result = result * a % p;
			a = a * a % p;
			n >>= 1;
		}
		return result;
	};

// mod p （pは素数）の下での逆元を求める（フェルマーの小定理を利用）
ll mod_inverse(ll a, ll p) {
	return mod_pow(a, p-2, p);
}

// mod p （pは素数）の下での除算 (a / b)
ll mod_devide(ll a, ll b, ll p) {
	return a * mod_inverse(b, p) % p;
}

// mod p （pは素数）の下での組み合わせ（nCk）を計算
ll mod_comb(ll n, ll k, ll p) {
	ll numerator = 1;
	for (int i=n; i>n-k; i--) {
		numerator *= i;
		numerator %= p;
	}

	ll denominator = 1;
	for (int i=k; i>0; i--) {
		denominator *= i;
		denominator %= p;
	}

	return mod_devide(numerator, denominator, p);
}


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

	ll comb_a = mod_comb(n, a, MOD);
	ll comb_b = mod_comb(n, b, MOD);

	ll ans = mod_pow(2, n, MOD) - 1;
	if (ans < 0) ans += MOD;

	ans -= comb_a;
	if (ans < 0) ans += MOD;

	ans -= comb_b;
	if (ans < 0) ans += MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def judge(lists):
    lists.sort()
    if lists[0] ** 2 + lists[1] ** 2 - lists[2] ** 2:
        return False
    else:
        return True


def run():
    N = int(input())
    for _ in range(N):
        if judge([int(x) for x in input().split()]):
            print("YES")
        else:
            print("NO")

if __name__ == '__main__':
    run()


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

using namespace std;

typedef long long ll;

//int d[4*100000];



int main ()
{
    ios_base::sync_with_stdio(false);
  //  freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    set<char> st;
    st.insert(s.begin(), s.end());
    cout << (st.size() == 3 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(uniqu7e(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s == "SUN") cout << 7 << endl;
	else if (s == "MON") cout << 6 << endl;
	else if (s == "TUE") cout << 5 << endl;
	else if (s == "WED") cout << 4 << endl;
	else if (s == "THU") cout << 3 << endl;
	else if (s == "FRI") cout << 2 << endl;
	else if (s == "SAT") cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
  #define rep(i, n) for (int i = 0; i < (int)(n); i++)
  #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
  typedef long long ll;
  #define all(x) (x).begin(),(x).end()
  int INF = 1000000000;

  int main() {
    string O, E; cin >> O >> E;
    string ans = "";
    if (O.size() == E.size()) {
      rep(i, O.size()) {
        ans += O[i];
        ans += E[i];
      }
    }
    else {
      rep(i, O.size()-1) {
        ans += O[i];
        ans += E[i];
      }
      ans += O[O.size() - 1];
    }
    cout << ans << endl;
  }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
using namespace std;

int main()
{
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	int x = h * w - a * w;
	cout << x - (h-a)*b << endl;;


}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	a, b, m := nextInt(), nextInt(), nextInt()
	as := make([]int, a)
	ac := make([]int, a)
	bs := make([]int, b)
	bc := make([]int, b)
	for i := 0; i < a; i++ {
		as[i] = nextInt()
		ac[i] = as[i]
	}
	for i := 0; i < b; i++ {
		bs[i] = nextInt()
		bc[i] = bs[i]
	}
	sort.Ints(as)
	sort.Ints(bs)
	min := as[0] + bs[0]
	for i := 0; i < m; i++ {
		x, y, c := nextInt(), nextInt(), nextInt()
		disc := ac[x-1] + bc[y-1] - c
		if disc < min {
			min = disc
		}
	}
	fmt.Println(min)
}


Measured memory_bytes: 6016
#include <stdio.h>
#include <math.h>
#define N 1000001
#define M 1000000007
typedef long long LL;

int mp[N], pc[N];
int a[10001], m = 0;

LL qpow(LL x, int y)
{
	if(!y) return 1;
	LL t = qpow(x, y >> 1);
	t = t * t % M;
	if(y & 1) t = t * x % M;
	return t;
}

int main()
{		
	int n, i, j, x, k, p[22], c, y, tc;
	LL e = 1, s = 0;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &x);
		if(x > m) m = x;
		a[i] = x;
	}
	for(i = 0; i <= m; i++) mp[i] = pc[i] = 0;
	for(i = 2, k = sqrt(m); i <= k; i++){
		if(mp[i]) continue;
		for(j = i * i; j <= m; j += i){
			if(!mp[j]) mp[j] = i;
		}
	}
	for(i = 1; i <= m; i++){
		if(!mp[i]) mp[i] = i;
	}
	for(i = 0; i < n; i++){
		x = a[i];
		if(x == 1) continue;
		c = 0;
		while(x > 1){
			p[c++] = mp[x];
			x /= mp[x];
		}
		for(j = 0; j < c; j = k){
			for(y = p[j], k = j + 1; k < c && p[k] == y; k++);
			tc = k - j;
			if(pc[y] < tc) pc[y] = tc;
		}
	}
	for(i = 2; i <= m; i++){
		if(pc[i]) e = e * qpow((LL)i, pc[i]) % M;
	}
	for(i = 0; i < n; i++){
		s += e * qpow((LL)a[i], M - 2) % M;
	}
	printf("%lld\n", s %= M);
			
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n;i++)

int main()
{
    int D;
    cin >> D;
    cout << "Christmas";
    for (int i = 0; i < 25 - D;i++){
        cout << " Eve";
    }
    cout << endl;
}

Measured memory_bytes: 256
n=int(input())
s=input()
ans=""
for i in range (len(s)):
    if ord(s[i])+n>ord('Z'):
        tmp=ord(s[i])-ord('Z')
        tmp+=ord('A')+n-1
    else:
        tmp=ord(s[i])
        tmp+=n
    ans+=chr(tmp)
print(ans)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    long int A, B, C;
    cin >> A >> B >> C;
    
    if( A == B && B == C ){
        if( A%2 == 1 ) cout << 0 << endl;
        else cout << -1 << endl;
        return 0;
    }
    
    long int ans = 0;
    while( (A%2 || B%2 || C%2) == 0 ){
        long int a = A, b = B, c = C;
        A = b/2 + c/2;
        B = a/2 + c/2;
        C = a/2 + b/2;

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

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

#define int long long
#define ii pair<int, int>

signed main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    cout << (1000 - n%1000)%1000 << endl;
}


Measured memory_bytes: 3644
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int K;
    string S;
    cin >> K >> S;

    if (SIZE(S) > K) {
        cout << S.substr(0, K) << "...";
        return;
    }

    cout << S;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3636
#!/usr/bin/env python3
#CODEFESTIVAL2017 qual A C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
s = [input() for _ in range(h)]
cnt = defaultdict(lambda : 0)
for i in range(h):
    for j in range(w):
        cnt[s[i][j]] += 1
g1,g2,g4 = (w%2)&(h%2),(w%2)*h//2 + (h%2)*w//2,h//2 * w//2
for k in cnt.keys():
    if (g1 > 0) and cnt[k] % 4 == 1 or cnt[k] % 4 == 3:
        g1 -= 1
        cnt[k] -= 1
    while (g4 > 0) and cnt[k] >= 4:
        g4 -= 1
        cnt[k] -= 4
    while (g2 > 0) and cnt[k] >= 2:
        g2 -= 1
        cnt[k] -= 2
for i,j in cnt.items():
    if j == 0:
        continue
    print('No')
    quit()
print('Yes')


Measured memory_bytes: 39152
janken = {"r": "p",
          "s": "r",
          "p": "s"}


n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
T = list(input())
score = {"r": r,
         "s": s,
         "p": p}

ans = 0
for i in range(n):
    if i < k:
        ans += score[janken[T[i]]]
    else:
        if T[i] == T[i - k]:
            T[i] = "-"
        else:
            ans += score[janken[T[i]]]
print(ans)


Measured memory_bytes: 80060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int a[5], k;
  rep(i,5) cin >> a[i];
  cin >>  k;
  
  bool flag = true;
  for (int i = 1; i < (5); ++i){
    if(a[i]-a[0] > k) flag = false;
  }
  for (int i = 2; i < (5); ++i){
    if(a[i]-a[1] > k) flag = false;
  }
  for (int i = 3; i < (5); ++i){
    if(a[i]-a[2] > k) flag = false;
  }
  for (int i = 4; i < (5); ++i){
    if(a[i]-a[3] > k) flag = false;
  }
  
  if(flag) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		String ans="Yes";
		for(int i = 0; i < s.length(); i++)
			//ある文字がそれ以降再度出てくる時、その位置関係が対等なら置換可能
			//例1では2文字目に出てきた文字が3文字目にも出てくるという状況がs1,s2共に起こり、それ以外の文字は重複しない
			if(s.indexOf(s.charAt(i), i+1) != t.indexOf(t.charAt(i), i+1)) {
				ans="No";break;
			};
		System.out.println(ans);
	}
}

Measured memory_bytes: 30044
#include <iostream>
#include <cstdio>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node {
  int parent,left,right;
};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d) {
  if (u==NIL) {
    return;
  }
  D[u]=d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}
int setHeight(int u) {
  int h1=0,h2=0;
  if (T[u].left!=NIL) {
    h1=setHeight(T[u].left)+1;
  }
  if (T[u].right!=NIL) {
    h2=setHeight(T[u].right)+1;
  }
  return H[u]=max(h1,h2);
}
int getSibling(int u) {
  if (T[u].parent==NIL) {
    return NIL;
  }
  if (T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) {
    return T[T[u].parent].left;
  }
  if (T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) {
    return T[T[u].parent].right;
  }
  return NIL;
}
void print(int u) {
  cout<<"node "<<u<<": "<<flush;
  cout<<"parent = "<<T[u].parent<<", "<<flush;
  cout<<"sibling = "<<getSibling(u)<<", "<<flush;
  int deg=0;
  if (T[u].left!=NIL) {
    deg++;
  }
  if (T[u].right!=NIL) {
    deg++;
  }
  cout<<"degree = "<<deg<<", "<<flush;
  cout<<"depth = "<<D[u]<<", "<<flush;
  cout<<"height = "<<H[u]<<", "<<flush;
  if (T[u].parent==NIL) {
    cout<<"root"<<endl;
  } else if (T[u].left==NIL && T[u].right==NIL) {
    cout<<"leaf"<<endl;
  } else {
    cout<<"internal node"<<endl;
  }
}
int main() {
  scanf("%d",&n);
  for (int i=0; i<n; i++) {
    T[i].parent=NIL;
  }
  int v,l,r;
  for (int i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if (l!=NIL) {
      T[l].parent=v;
    }
    if (r!=NIL) {
      T[r].parent=v;
    }
  }
  int root=0;
  for (int i=0; i<n; i++) {
    if (T[i].parent==NIL) {
      root=i;
    }
  }
  setDepth(root,0);
  setHeight(root);
  for (int i=0; i<n; i++) {
    print(i);
  }
  return 0;
}




Measured memory_bytes: 3156
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include<bitset>

using namespace std;
#define loop(i,n) for(int i = 0; i < (n); ++i)
#define loops(i,f,n) for(int i = (f); i < (n); ++i)
#define INF 9999999
#define lint long long int
#define VEC vector<int>
#define VEC2 vector<vector<int>>

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> nums(n);
	loop(i, n)cin >> nums[i];
	cout << ((n - k) % (k - 1) == 0 ? (n - k) / (k - 1) + 1 : (n - k) / (k - 1) + 2) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,k = 0;
  ll ans = 1000000000;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(),h.end());
  rep(i,n-k+1) {
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const LL INF = 1e18;




int main(){
	int p,num;
	LL sum=0,value=0,cnt=0;
	char c;
	while(cin>>p>>c>>num){
		cnt++;
		sum+=num;
		value+=p*num;
	}
	cout<<value<<endl;
	cout<<sum/cnt+((sum%cnt>=cnt/2)?1:0)<<endl;
	return 0;
}
/*

*/

Measured memory_bytes: 1156
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = (mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value)) % mod_value;
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0) return 0;
		if (n < r) return 0;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_combination<long long> fc(N, MOD);
//int result = fc.process(n, r);

const long long MOD = 1e9 + 7;

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

	fast_combination<long long> fc(3e6, MOD);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	cout << (fc.process(r2 + 1 + c2 + 1, r2 + 1) + (MOD - fc.process(r2 + 1 + c1, c1)) + (MOD - fc.process(r1 + c2 + 1, r1)) + fc.process(r1 + c1, r1)) % MOD;

	return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
  FORe(len, 1, n){
    for(int i = 0; i + len <= n; i++){
      int j = i + len;
      if((n-len)%2 == 0){
        dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
      }else{
        dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1]);
      }
    }
  }

  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 72616
#include <stdio.h>

int main(void){

	int n;
	int debt = 100000;
	int i;

	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		debt *= 1.05;
		if (debt % 1000 != 0){
			debt +=1000 -debt % 1000;
		}
	}

	printf("%d\n", debt);

	return 0;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<en;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3604
using System;

class Program
{
    static void Main()
    {
        var X = int.Parse(Console.ReadLine());

        static int Pow5(int x) => x * x * x * x * x;
        for (int i = -118; i <= 119; i++)
        {
            for (int j = -119; j <= 118; j++)
            {
                if (Pow5(i) - Pow5(j) == X)
                {
                    Console.WriteLine($"{i} {j}");
                    return;
                }
            }
        }
    }
}


Measured memory_bytes: 27528
n = gets.to_i
ss = gets.chomp

r = ss.count("R")
g = ss.count("G")
b = ss.count("B")
ans = r * g * b

0.upto(n) do |i|
  j = 1

  while i + 2 * j < n
    k = i + 2 * j

    a = ss[i]
    b = ss[i + j]
    if a == b
      j += 1
      next
    end

    c = ss[k]
    ans -= 1 if b != c && c != a

    j += 1
  end
end

puts ans


Measured memory_bytes: 14376
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
        ll n;

        cin>>n;
        ll r =pow(n,3ll);
        printf("%lld\n",r);


        //printf("Case %d: ",++te);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  vector<long long> s(n), t(m);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < m; i++) cin >> t[i];
  while (q--) {
    long long x;
    cin >> x;
    long long ret = 9e18;
    int ind = lower_bound(s.begin(), s.end(), x) - s.begin();
    int jnd = lower_bound(t.begin(), t.end(), x) - t.begin();
    if (ind < n && jnd < m) {
      ret = min(ret, max(s[ind], t[jnd]) - x);
    } if (ind > 0 && jnd > 0) {
      ret = min(ret, x - min(s[ind - 1], t[jnd - 1]));
    } if (ind > 0 && jnd < m) {
      ret = min(ret, (x - s[ind - 1]) * 2 + (t[jnd] - x));
      ret = min(ret, (x - s[ind - 1]) + 2 * (t[jnd] - x));
    } if (ind < n && jnd > 0) {
      ret = min(ret, (s[ind] - x) * 2 + (x - t[jnd - 1]));
      ret = min(ret, (s[ind] - x) + 2 * (x - t[jnd - 1]));
    }
    cout << ret << '\n';
  }
  return 0;
}

Measured memory_bytes: 2944
dic = {'a':0, 'b':0, 'c':0, 'd':0, 'e':0, 'f':0,
        'g':0, 'h':0, 'i':0, 'j':0, 'k':0, 'l':0,
        'm':0, 'n':0, 'o':0, 'p':0, 'q':0, 'r':0,
        's':0, 't':0, 'u':0, 'v':0, 'w':0, 'x':0,
        'y':0, 'z':0}

while True:
    try:
        S = input()

    except:
        break

    for s in S:
        for i in range(len(s)):
            if s[i].lower() in dic:
                dic[s[i].lower()] += 1


for k in dic:
    print("{} : {}".format(k, dic[k]))



Measured memory_bytes: 5568
package main

import "fmt"

func Watch(S int){
	h := (int)(S / 3600)
	m := (int)( (S % 3600) / 60 )  
	s := S % 60

	fmt.Printf("%d:%d:%d\n", h, m, s)
}

func main(){
	S := 0
	fmt.Scan(&S)
	Watch(S)
}


Measured memory_bytes: 1160