akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;


int main()
{
    int s; cin >> s;
    int l = s/100, r = (s % 100);

    if(0 < l && l < 13 && 0 < r && r < 13) printf("AMBIGUOUS");
    else if(0 < l && l < 13) printf("MMYY");
    else if(0 < r && r < 13) printf("YYMM");
    else printf("NA");
}


Measured memory_bytes: 764
#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>;

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now = 0;
        rep(i,q) {
            if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
typedef pair<ll,ll> P;

#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define rrep(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int chtoi(char ch){
  if(ch >= 'a' && ch <= 'z') return ch - 'a';
  if(ch >= 'A' && ch <= 'Z') return ch - 'A' + 26;
}

bool judge(char str[]){
  int var[100] = {};
  for(int i = 1; str[i - 1] != ')';){
    int t = str[i] == '~';
    var[chtoi(str[i + t])] |= t + 1;
    i += t + 2;
  }
  for(int i = 0; i < 52; ++i) if(var[i] == 3) return 0;
  return 1;
}

int main(){
  char buf[600];
  while(fgets(buf, sizeof buf, stdin), strcmp(buf, "#\n")){
  char *p = buf;
  bool ans = false;
  for(int i = 0;; ++i){
    if(buf[i] == '\n' || buf[i] == '|'){
      ans = ans || judge(p);
      if(buf[i] == '\n'){
        puts(ans ? "yes" : "no");
        break;
      }else{
        p = buf + i + 1;
      }
    }
  }
  }
}



Measured memory_bytes: 2948
import java.util.*;
	 
	class Main {
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int a = sc.nextInt();
			boolean f = true;
			while(f) {
			if(a%2==0) {
				int c = a/2;
				if(a==2) {
					System.out.println(2);
					f = false;
				}else {
				for(int i = a+1;f;i++) {
					
					for(int j=c; j>=1;j--) {
					
						if(i%j==0 && j!=1) {
							break;
						}
						if(j==1) {
							System.out.println(i);
							f = false;
						}
					}
				i++;
				}
				}
			}else {
				int c=(a-1)/2;
				for(int i = a;f;i++) {
					
					for(int j=c; j>=1;j--) {
						
						if(i%j==0 && j!=1) {
							break;
						}
						if(j==1) {
							System.out.println(i);
							f = false;
						}
					}
					i++;
					}
				
				
				
				
			}
		}
			
	
	
			sc.close();
		}
	}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  REP(i, n) cin >> a[i];

  ll prev = 0, current;
  REP(i, k) { prev += a[i]; }

  for(int i = 1; i <= n - k; i++) {
    current = prev - a[i - 1] + a[i + k - 1];
    if(current > prev) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4372
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    
	ll n;
	cin>>n;
	string ss,s="abcdefghijklmnopqrstuvwxyz";
	while(n!=0)
	{
		n--;
		ss+=s[n%26];
		n/=26;
	}
	reverse(ss.begin(),ss.end());
	cout<<ss;
	
End;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll n, a[200];
int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 768
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

ans = r * g * b

for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k < N:
            if sorted(S[i] + S[j] + S[k]) == ['B', 'G', 'R']:
                ans -= 1
                
print(ans)

Measured memory_bytes: 74172
#include <iostream>
#include <algorithm>

using namespace std;

using ll = long long;

int main()
{
	ll a, b, k;
  
  	cin >> a >> b >> k;
  
  	ll t = min(a, k);
  	
	cout << a - t << ' ' << max(b - k + t, 0LL) << '\n';
		
 	return 0; 
}

Measured memory_bytes: 256
n=int(input())
word=set()
pre=''
for i in range(n):
    w=input()
    if i!=0:
        if w[0]!=pre[-1]:
            print('No')
            exit()    
    if w in word:
        print('No')
        exit()
    word.add(w)
    pre=w
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int i,n,wa=0;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
    wa+=a[i];
  }
  for(i=0;i<n;i++){
    wa-=2*a[i];
    if(wa<=0){
      cout<<min({wa+(2*a[i]),abs(wa),abs(wa-(2*a[i+1]))});
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool OK=true;
  int ans=0,n,a;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
  while(OK){
    for(int j=0;j<n;j++){
      if(A[j]%2==0) A[j]/=2;
      else {OK=false;break;}
    }
        ans++;
  }
  cout<<ans-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n,m,a,b;
int d[N],vis[N];
vector<int> to[N];
int dfs(int x) {
	if(x==b)return 1;
	int ret=0;
	vis[x]=1;
	for(int y : to[x]) {
		if(vis[y]==0) ret+=dfs(y);
	}
	return ret;
}
int main() {
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		int a,b; scanf("%d %d", &a, &b);
		to[a].push_back(b);
		to[b].push_back(a);
		d[a]++,d[b]++;
	}
	int cnt6=0,cnt4=0;
	for(int i=1;i<=n;i++){
		if(d[i]%2!=0){
			printf("No\n");
			return 0;
		}
		if (d[i]>=6)cnt6++;
		if (d[i]==4)cnt4++;
	}
	if(cnt6||cnt4>2){
		printf("Yes\n");
	} else {
		if(cnt4==2){
			for(int i=1;i<=n;i++)if(d[i]==4){
				if(a==0)a=i;else b=i;
			}
			if(dfs(a)==2){
				printf("Yes\n");
				return 0;
			}
		}
		printf("No\n");
	}
}

Measured memory_bytes: 7296
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var i = 0;
			while ((i = int.Parse(Console.ReadLine())) != 0)
			{
				var a = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
				var r = 32;
				for(int j=0;true;j++)
				{
					r -= (r - 1) % 5;
					Console.WriteLine(r < 0 ? 0 : r);
					r -= a[j % i];
					Console.WriteLine(r < 0 ? 0 : r);
					if (r <= 0) break;
				}
			}
		}
	}
}

Measured memory_bytes: 5980
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

int n;

int main()
{
	cin >> n;
	int sum = 0;
	int num = n;
	while (num) {
		sum += num % 10;
		num /= 10;
	}
	printf("%s\n", n % sum == 0? "Yes": "No");
	return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  _n <- (read :: String -> Int) <$> getLine
  hs <- fmap (read :: String -> Int) . words <$> getLine
  print $ fst $ solve hs

solve hs = foldr acc (0,0) $ zipWith (>=) hs (tail hs)
  where
    acc a (m, c) = if a then (max m (c+1), c+1) else (max m c, 0)


Measured memory_bytes: 65916
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
const int dy[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
const int lr[4] = { 0, 1, 0, -1 };
const int ud[4] = { 1, 0, -1, 0 };



//LOVE Ayane Sakura



using namespace std;



int main() {
	int A, B, M;
	cin >> A >> B >> M;
	vector<int>a(A), b(B), x(M), y(M), c(M);
	int am, bm;
	am = bm = INT_MAX;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
		chmin(am, a[i]);
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
		chmin(bm, b[i]);
	}
	int ans = INT_MAX;
	chmin(ans, am + bm);
	for (int i = 0; i < M; i++) {
		cin >> x[i] >> y[i] >> c[i];
		chmin(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (a[n - 1] != 2) {
    cout << -1 << '\n';
    return 0;
  }
  vector<long long> mn(n + 1, 2), mx(n + 1, 2);
  for (int i = n - 1; i >= 0; i--) {
    mn[i] = mn[i + 1];
    mx[i] = mx[i + 1] + a[i] - 1;
    if (i > 0) {
      mn[i] += a[i - 1] - 1;
      mn[i] /= a[i - 1];
      mn[i] *= a[i - 1];
      mx[i] /= a[i - 1];
      mx[i] *= a[i - 1];
    }
    if (mn[i] > mx[i]) {
      cout << -1 << '\n';
      return 0;
    }
  }
  cout << mn[0] << " " << mx[0] << '\n';
  return 0;
}


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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) {
    cout << 1;
  }
  else if (b == 0) {
    cout << 2;
  }
  else if (c == 0) {
    cout << 3;
  }
  else if (d == 0) {
    cout << 4;
  }
  else {
    cout << 5;
  }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string s;
    cin >> s;
    
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
    return 0;
}

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

	int top = -1;
	int push(int);
	int pop(void);
	char in[6];
	int stack[100],n,m;

int main(void){
	
	while(scanf("%s",in) != EOF){
	
	if(in[0] == '+'){
		
		n=pop();
		m=pop();
		push(m+n);
		
		}
		
	else if(in[0] == '-'){
		
		n=pop();
		m=pop();
		push(m-n);
		
		}
	
	else if(in[0] == '*'){
		
		n=pop();
		m=pop();
		push(m*n);
		
		}
	
	else{
		
		push(atoi(in));
		
		}
	
	}
	
	printf("%d\n",pop());
	
return 0;}


int push(int plus){
	
	top++;
	stack[top] = plus;
	
return 0;}


int pop(void){
	
	int num;
	num = stack[top];
	stack[top] = NULL;
	top--;
	
return num;}

Measured memory_bytes: 548
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second

void solve()
{
    int a, b, n;
    cin>>a>>b>>n;
    n=min(n, b-1);
    int ans1=(a*n)/b;
    int ans2=a*(n/b);
    cout<<ans1-ans2<<endl;
}

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

Measured memory_bytes: 3640
from bisect import bisect_left
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(N-1):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append(v)
    G[v].append(u)
lis = [float('inf')] * N
ans = [0] * N

def dfs(v, p):
    i = bisect_left(lis, a[v])
    tmp = lis[i]
    lis[i] = a[v]
    ans[v] = bisect_left(lis, float('inf'))
    for c in G[v]:
        if c == p:
            continue
        dfs(c, v)
    lis[i] = tmp

dfs(0, -1)
print('\n'.join(map(str, ans)))

Measured memory_bytes: 354160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W, count = 0;
  cin >> H >> W;
  
  vector<string> a(H);
  
  for (int i = 0; i < H; i++) {
  	cin >> a.at(i);
  }
  
  for (int j = 0; j < H; j++) {
    for (int i = 0; i < W; i++) {
      if (a[j].at(i) == '#') {
        cout << '#';
      }
      else {
		for (int l = -1; l < 2; l++) {
          for (int k = -1; k < 2; k++) {
            if (i + k >= 0 && i + k < W && j + l >= 0 && j + l < H) {
              if (a[j + l].at(i + k) == '#') {
                count++;
              }
            }             
          }
        }
        cout << count;
        count = 0;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int f(int N) {
  int ret = 0;
  while (N) {
    ret += N % 10;
    N /= 10;
  }
  return ret;
}

int main() {
  int N;
  cin >> N;
  cout << (N % f(N) == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define clr(a) memset(a, 0, sizeof a)
#define sc scanf
#define pr printf
vector<int> small;
vector<int> big;
vector<int> arr;
int t,tc=1,n,nn,extra,cc,c;
bool chk(vector<int> v){
    //if(v.size()==0) return true;
    if(v.size()<=2) return true;
    cc=(v.size()-1)/2;
    small.clear();
    big.clear();
    for(c=0;c<v.size();c++){
        if( c!=cc && v[c]<v[cc]) small.push_back(v[c]);
        else if(c!=cc && v[c]>v[cc]) big.push_back(v[c]);
    }
    if(small.size()!=0 && big.size()!=0) return false;
    else return chk(small) && chk(big);
}




int main(){

    int a,b;
    scanf("%d",&a);
    scanf("%d",&b);
    int sz=a*a-b;
    printf("%d\n",sz);
	return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python3
import itertools
import numpy as np
import fractions
from itertools import combinations
from functools import reduce
from functools import lru_cache
import math
from collections import deque
import decimal
import bisect
import heapq
import sys
sys.setrecursionlimit(10**9)


YES = "Yes"  # type: str
NO = "No"  # type: str


def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def solve(N: str):
    s = 0
    for n in N:
        m = int(n)
        s += m
        s %= 9
 
    print(YES if s % 9 == 0 else NO)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: str
    solve(N)



if __name__ == "__main__":
    main()


Measured memory_bytes: 27348
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(' ').map { it.toLong() }

    var ans = 0
    for (i in 0 until n-2) {
        for (j in i+1 until n-1) {
            for (k in j+1 until n) {
                if (l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                    if ((l[i] + l[j]) > l[k] &&
                        (l[k] + l[i]) > l[j] &&
                        (l[j] + l[k]) > l[i]
                    ) ans++
                }
            }
        }
    }

    println(ans)
}


Measured memory_bytes: 38796
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(0),cin.tie(0);
#define ll long long int
int main(){
	AC
    int n;
    double ans =0,val;
    cin>>n;
    vector<double> dp(n+1);
    
    dp[0]=1;
    
    for(int i=0;i<n;i++){
       cin>>val;
       for(int j=i+1;j>=0;j--){
        dp[j]=(j==0?0:dp[j-1]*val)+dp[j]*(1-val);
       }
    }
    for(int i=n;i>n/2;i--)ans+=dp[i];
    cout<<fixed<<setprecision(10);
    cout<<ans;
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define endl "\n"
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e2+4;

int main()                  
{
	int n=5;

	rep(i,1,n+1)
	{
		int val; scn(val);

		if(val==0)
		{
			pri(i); return 0;
		}
	}
} 

Measured memory_bytes: 3828
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  const int N=n;
  int a[N];
  const int c=100000;
  int b[c]={};
for(int i=0;i<N;i++){
  cin>>a[i];
  b[a[i]]++;
  b[a[i]+1]++;
  b[a[i]-1]++;
}
int max;
for(int i=0;i<c;i++){
  if(i==0||max<b[i])max=b[i];
}
cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
long  long a[200005];
int main()
{
	long long int s,i,n,t;
	scanf("%lld%lld",&n,&t);
	scanf("%lld",&a[1]);
	s=t;
	for(i=2;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]-a[i-1]>t) s+=t;
		else s+=(a[i]-a[i-1]);
	}
	printf("%lld\n",s);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i < 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  int d = max({a, b, c});
  int e = a + b + c - d;
  ans = d * (int)pow(2, k) + e;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

bool isa(char c){
    if(c=='A'||c=='T'||c=='C'||c=='G'){
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int mx=0;
    int cnt=0;
    for(int i=0; i<s.length(); i++){
        if(isa(s[i])){
            cnt++;
        } else {
            cnt = 0;
        }
        mx = max(cnt, mx);
    }
    cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int N;
string S1, S2;

enum {
    def,
    vert,
    hori,
};

signed main()
{
    cin >> N;
    cin >> S1 >> S2;
    ll ans;
    int status = def;
    for (int i = 0; i < N; i++) {
        if (S1[i] == S2[i]) {
            if (status == vert) {
                ans *= 2;
                ans %= MOD;
            } else if (status == hori) {
                // do nothing
            } else {
                ans = 3;
            }
            status = vert;
        } else {
            if (status == hori) {
                ans *= 3;
                ans %= MOD;
            } else if (status == vert) {
                ans *= 2;
                ans %= MOD;
            } else {
                ans = 6;
            }
            status = hori;
            ++i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s,t;
	int ans=INF;
	cin >>s>>t;
	int cnt = 0;
	for (int i = 0; i <=s.size()-t.size() ;i++){
		cnt = 0;
		rep(j,t.size()){
			if(t[j]!= s[i+j]){
				cnt++;
			}
		}
		chmin(ans, cnt);
	} cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <numeric>
#include <functional>
#include <iomanip>
#include <math.h>
using namespace std;
using LL = long long;
int num_of_count;

int palindrome(string S) {
	if (S.size() <= 1) {
		return 0;
	}
	if (S[0] != S[S.size() - 1]) {
		num_of_count++;
	}
	S = S.erase(0,1);
	S = S.erase(S.size() - 1,1);
	return palindrome(S);
}

int main(void) {
	num_of_count = 0;
	string S;

	cin >> S;
	int a = palindrome(S);

	cout << num_of_count << endl;

	return 0;
}

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

int main(void)
{
  int x, y, z;
  int count = 0;
  cin >> x;
  cin >> y;
  cin >> z;
  for (int i = x; i <= y; i++)
  {
    if (z % i == 0)
    {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,wa=0,ac=0,tle=0,re=0;
    string s;
    cin>>n;
    rep(i,n){
        cin>>s;
        if(s=="WA") wa++;
        else if(s=="AC") ac++;
        else if(s=="TLE") tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3584
using System;
using System.Linq;
using System.Collections;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve();
        }

        public void Solve()
        {
            MyInputStream cin = new MyInputStream();

            var N = cin.ReadInt();

            var x = N * 800;
            var y = N / 15 * 200;
            WriteLine(x - y);
        }
    }

    public class MyInputStream
    {
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(char separator = ' ')
        {
            this.separator = separator;
            inputStream = new Queue<string>();
        }

        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = Console.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; i++)
            {
                inputStream.Enqueue(tmp[i]);
            }
            return inputStream.Dequeue();
        }
        public string ReadLine() => Console.ReadLine();
        public int ReadInt() => int.Parse(Read());
        public long ReadLong() => long.Parse(Read());
        public double ReadDouble() => double.Parse(Read());
    }

    public class Pair<T1, T2>
    {
        public T1 First;
        public T2 Second;
        public Pair() { First = default(T1); Second = default(T2); }
        public Pair(T1 f, T2 s) { First = f; Second = s; }
        public override string ToString() { return "(" + First + ", " + Second + ")"; }
        public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); }
        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj)) return true;
            else if (obj == null) return false;
            var tmp = obj as Pair<T1, T2>;
            return (object)tmp != null && First.Equals(tmp.First) && Second.Equals(tmp.Second);
        }
    }

    #region HashMap
    public class HashMap<K, V> : Dictionary<K, V>
    {
        public HashMap() : base() { }
        public HashMap(int cap) : base(cap) { }
        public HashMap(IDictionary<K, V> dictionary) : base(dictionary) { }
        new public V this[K i]
        {
            get
            {
                V v;
                return TryGetValue(i, out v) ? v : base[i] = default(V);
            }
            set { base[i] = value; }
        }
    }
    #endregion
}


Measured memory_bytes: 11220
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = 0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
# coding: utf-8
# Your code here!
a = input().split()
N = int(a[0])
M = int(a[1])
a = []
k = [int(input()) for i in range(N)]

temp = int(0)

for i in range(300001):
    a.append(0)
    
seg = SegTree(a, segfunc, ide_ele)

for i in range(N):
    temp = seg.query(max(0, k[i]-M), min(300001, k[i]+M+1))
    seg.update(k[i], temp+1)
    temp = 0
    
print(seg.query(0,300001))

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

int main(){
  //  freopen("C:\\Users\\ehab\\Desktop\\problems\\in.txt" , "r" , stdin);

    string s;
    cin >> s;
    if ( s[2] == s[3] && s[4] == s[5] )
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void print_vector(vector<vector<ll> >v){
    for(ll i=0;i<v.size();i++){
        for(ll j=0;j< v[i].size();j++){
            cout<<v[i][j]<<" ";
        }cout<<"\n";
    }
}

int main(){
    ll sum=0;
    ll n;
    cin>>n;
    for(ll i=0;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum=sum+i;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3620
use std::cmp::max;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    loop {
        let n: usize = sc.read();
        let m: usize = sc.read();
        if n == 0 {
            return;
        }
        let s: Vec<i64> = sc.vec(n);

        if solve(&s, s[0]) < m {
            println!("-1");
            continue;
        }

        let mut ok = s[0];
        let mut ng = 1 << 50;
        while ng - ok > 1 {
            let x = (ng + ok) / 2;
            if solve(&s, x) < m {
                ng = x;
            } else {
                ok = x;
            }
        }

        println!("{}", ok);
    }
}

fn solve(s: &[i64], x: i64) -> usize {
    assert!(s[0] < x + 1);
    let last = s[s.len() - 1];

    let mut cur = 1;
    let mut ans = 0;
    loop {
        if cur + x > last {
            return ans + 1;
        }

        match s.binary_search(&cur) {
            Ok(_) => {
                cur += x;
            }
            Err(next) => {
                let mut gain = 1;
                if next < s.len() {
                    gain = max(gain, x - (cur - s[next]).abs());
                }
                if next > 0 {
                    gain = max(gain, x - (cur - s[next - 1]).abs());
                }
                cur += gain;
            }
        }
        ans += 1;
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



Measured memory_bytes: 5056
n,m = map(int,input().split())
from collections import deque
a = []
for _ in range(n):
    a.append(list(input()))

count = 0
for x in a:
    count += x.count("#")
#print(count)

b = [[-1 for i in range(m)] for i in range(n)]
#print(a)

x = [0, 0, -1, 1]
y = [-1, 1, 0, 0]
queue = deque([[0,0]])
b[0][0] = 1
while queue:
    now = queue.popleft()
    if now == [n-1,m-1]:
        print(n * m - (b[n-1][m-1] + count))
        exit()
    a[now[0]][now[1]] = "#"
    for i in range(4):
        if 0 <= now[0] + y[i] < n and 0 <= now[1] + x[i] < m and b[now[0]+y[i]][now[1]+x[i]] == -1:
            if a[now[0]+y[i]][now[1]+x[i]] == '.':
                queue.append([now[0]+y[i],now[1]+x[i]])
                b[now[0]+y[i]][now[1]+x[i]] = b[now[0]][now[1]] + 1

print(-1)



Measured memory_bytes: 9476
import java.util.*;
import java.util.Scanner;
import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
 
public class Main
{
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
    public static void main (String[] args) 
	{
        //code by sushant kumar
        FastReader in=new FastReader();
        long n=in.nextLong();
       
        String s="";
        

        while(n>0)
        {
   
            long d=n%26;
           
            char ch=' ';
            if(d!=0)
                ch=(char)((int)d+96);
            else
                ch='z';
            
            s=ch+s;
            if(n%26!=0)
                n/=26;
            else

                n=n/26-1;
            
        }
       

        System.out.println(s);
    }
}

Measured memory_bytes: 25216
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int n,m;
int ans[100001];
int tmp[100001];
int scan_tmp[100001];
int scan_tmp2[100001];
int main(void)
{
  scanf("%d%d",&n,&m);
  for(int i=0;i<=n;i++){
    ans[i]=0;
    tmp[i]=0;
    scan_tmp[i]=0;
    scan_tmp2[i]=0;
  }
  
  int a[m+1],b[m+1];
  for(int i=0;i<m;i++){
    scanf("%d%d",&a[i],&b[i]);
    scan_tmp[a[i]]++;
    scan_tmp[b[i]]++;
  }

  int **class;
  class=malloc(sizeof(int *)*(n+2));
  for(int i=1;i<=n+1;i++){
    class[i]=(int *)malloc(sizeof(int)*(scan_tmp[i]+1));
  }
  for(int j=0;j<m;j++){
    scan_tmp2[a[j]]++;
    scan_tmp2[b[j]]++;
    class[a[j]][scan_tmp2[a[j]]]=b[j];
    class[b[j]][scan_tmp2[b[j]]]=a[j];
  }
  
  tmp[1]=1;
  int tmp_new[n],start=0,end=0,s=0,e=0;
  tmp_new[0]=1;
  while(1){
    for(int i=start;i<=end;i++){
      for(int j=1;j<=scan_tmp[tmp_new[i]];j++){
        if(tmp[class[tmp_new[i]][j]]==0){
          ans[class[tmp_new[i]][j]]=tmp_new[i];
          tmp[class[tmp_new[i]][j]]=1;
          tmp_new[e+1]=class[tmp_new[i]][j];
          e++;
        }
      }
    }
    if(e==end) break;
    start=end+1;
    end=e;
  }
  
  for(int i=2;i<=n;i++){
    if(ans[i]==0){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  for(int i=2;i<=n;i++){    
    printf("%d\n",ans[i]);
  }
  
  return 0;
}

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

int mypow(double a, int b) {
    int k = a;
    while(b > 1) {
        a *= k;
        b--;
    }
    return a;
}

int main(int argc, const char * argv[]) {
    int i,j,N;
    int A[200];
    
    cin >> N;
    for (i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    for (i = 1; i < 37; i++) {
        for (j = 0; j < N; j++) {
            //cout << (A[j] % mypow(2.0,i)) << endl;
            if ((A[j] % mypow(2.0,i)) != 0) {
                cout << i-1 << endl;
                exit(0);
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
/**
 * ITP1_1_D Watch
 */
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int s = sc.nextInt();
        int h = s / 3600;
        s -= h*3600;
        int m = s/60;
        s -= m*60;
        
        System.out.println(h + ":" + m + ":" + s);
    }
}

Measured memory_bytes: 26180
n = gets.to_i
w = n.times.map{gets.chomp}

if w.uniq.size != w.size
  puts 'No'
  exit
end

(n-1).times do |i|
  if w[i][-1] != w[i+1][0]
    puts 'No'
    exit
  end
end

puts 'Yes'

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<mp::cpp_int> A(N+1);
  rep(i, N+1) cin >> A[i];
  
  mp::cpp_int ans = 0;
  vector<mp::cpp_int> K(N+1);
  
  if(A[0] >= 1 && N != 0) {
    cout << -1 << endl;
    return 0;
  }
  if(N == 0) {
    if(A[0] != 1) {
      cout << -1 << endl;
      return 0;
    } else {
      cout << 1 << endl;
      return 0;
    }
  }
  
  mp::cpp_int k = 1;
  rep(i, N+1) {
    K[i] = k;
    if(A[i] > k) {
      cout << -1 << endl;
      return 0;
    } else {
      k -= A[i];
      k *= 2;
    }
    if(k == 0 && i != N) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  for(int i=N; i>=1; i--) {
    ans += A[i];
    if(A[i] < K[i-1]-A[i-1]) A[i-1] += A[i];
    else A[i-1] += K[i-1]-A[i-1];
  }
  
  cout << ans+A[0] << endl;
}

Measured memory_bytes: 621620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    string s; cin >> s;
    int ans = 0;
    rep(i, 4) if(s[i] == '2') ans++;
    print(ans);
}



Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <string>
#include <set>
#include <algorithm>

using namespace std;



bool judge(string s){
  for(int i = 1; i < s.length(); ++i) if(s[0] != s[i]) return false;
  return true;
}

int main(){
  char worm[16];
  while(scanf("%s", worm) && worm[0] != '0'){
    queue<string> q;
    q.push(string(worm));
    set<string>s;
    s.insert(string(worm));
    if(judge(q.front())){
      puts("0");
      continue;
    }
    int res = 1;
    while(!q.empty()){
      int q_size = (int)q.size();
      for(int j = 0; j < q_size; ++j){
	string tmp = q.front(); q.pop();
	int len = (int)tmp.length();
	for(int i = 0; i < len-1; ++i){
	  string n = tmp;
	  if(n[i] != n[i+1]){
	    if((n[i] == 'r' && n[i+1] == 'b') || (n[i] == 'b' && n[i+1] == 'r')) n[i] = n[i+1] = 'g';
	    else if((n[i]=='r'&&n[i+1]=='g') || (n[i]=='g'&&n[i+1]=='r')) n[i] = n[i+1] = 'b';
	    else if((n[i]=='g'&&n[i+1]=='b') || (n[i]=='b'&&n[i+1]=='g')) n[i] = n[i+1] = 'r';
	  }
	  ///	  puts(n.c_str());
	  if(s.find(n) != s.end()) continue;

	  if(judge(n)){
	    printf("%d\n", res);
	    goto end;
	  }
	  s.insert(n);
	  q.push(n);
	}
      }
      //      printf("%d\n", res);
      //      for(int i = 0; i < f.size(); ++i) puts(f[i].c_str());
      //      queue<string>t;
      //      t = q;
      //      while(!t.empty()){ puts(t.front().c_str()); t.pop();}
      //      puts("");
      
      res++;
    }
    puts("NA");
  end:;

  }
  return 0;
}

Measured memory_bytes: 2324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

ll T[100010], S[100010];

int main() {
	for (int i = 0;i < 100010;i++)T[i] = -1, S[i] = 0;
	ll N, X, M, fx, ans = 0;
	cin >> N >> X >> M;
	N--;
	T[X] = N;
	S[X] = X;
	ans += X;
	N--;
	while (N >= 0) {
		X = X * X % M;
		ans += X;
		if (T[X] >= 0) {
			ll tr = T[X] - N;
			ll ntr = N / tr;
			ans += ntr * (ans - S[X]);
			N %= tr;
			N--;
			break;
		}
		T[X] = N;
		S[X] = ans;
		N--;
	}
	while (N >= 0) {
		X = X * X % M;
		ans += X;
		N--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5188
import math
A,B,N= map(int,input().split())
x=[]
AB=A/B
if B==1:
    print("0")
elif N<B:
    #x.append(math.floor(AB*N-1)-A*(N//B)
    print(math.floor(AB*N))
else:
    x=[math.floor(AB*N)-A*(N//B)]
    for i in range(N//B):
        x.append(math.floor(AB*((i+1)*B-1))-i)
    print(max(x))

Measured memory_bytes: 61956
#include<bits/stdc++.h>
using namespace std;
const int M = 100001;
const int N = 2e5 + 10;

int n, a[N], b[N], sum[N], tr[N];

inline void Add(int x) {
	while (x < N) tr[x]++, x += x & -x;
}

inline int Query(int x) {
	int ans = 0;
	while (x) ans += tr[x], x -= x & -x;
	return ans;
}

int check(int mid) {
	long long tot =1LL * n * (n + 1) / 2;
	tot = tot / 2 + 1;
	memset(tr, 0, sizeof(tr));
	for (int i = 1; i <= n; ++i) b[i] = (a[i] <= mid) ^ 1;
	Add(M);
	long long res = 0;
	int s1 = 0, s0 = 0;
	for (int i = 1; i <= n; ++i) {
		if (!b[i]) s0++; else s1++;
		int s = s1 - s0;
		res += Query(N - 1) - Query(s + M);
//		cout << Query(N - 1) << ' ' << Query(s + M) << endl;
		Add(s + M);
	}
//	cout << res << endl;
	return (res >= tot);
}

int main() {
	cin >> n;
	int l = 1, r = 1e9;
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), r = max(r, a[i]);
	while (l < r) {
		int mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 1792
def computeGCD(x, y): 
   while(y): 
       x, y = y, x % y 
   return x 
   
   
def min(a, b):
	if a > b:
		return b
	else:
		return a

def max(a, b):
	if a > b:
		return a
	else:
		return b



def main():
	clocks = []
	n = int(input())
	for i in range(n):
		clocks.append(int(input()))
	x = clocks[0]
	for i in range(1, n):
		div = computeGCD(x, clocks[i])
		x = (x * clocks[i]) // div
	print(x)




if __name__ == "__main__":
	main()

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int k = Integer.parseInt(br.readLine());
        String s = br.readLine();
        if(s.length() > k) {
            s = s.substring(0,k);
            s += "...";
        }
        System.out.println(s);
    }
}


Measured memory_bytes: 36440
#include<cmath>
#include<vector>
#include<algorithm>

#define	EPS		1e-8

enum {CCW=1,CW=-1,ON=0};

#define	mp	make_pair
#define	pb	push_back

using namespace std;

class Point{
public:
	double x,y;
	Point(){}
	Point(double xx,double yy) : x(xx),y(yy){}
};

class Line : public vector<Point>{
public:
	Line(const Point &a,const Point &b){
		pb(a),pb(b);
	}
};

class Segment : public Line{
public:
	Segment(const Point &a,const Point &b):Line(a,b){}
};

class Polygon : public vector<Point>{};

class Circle{
public:
	Point c;
	double r;
	Circle(const Point &cc,double rr) : c(cc),r(rr){}
};

Point &operator +=(Point &a,const Point &b){
	a.x+=b.x;
	a.y+=b.y;
	return a;
}

Point &operator -=(Point &a,const Point &b){
	a.x-=b.x;
	a.y-=b.y;
	return a;
}

Point operator +(const Point &a,const Point &b){
	Point c=a;
	c+=b;
	return c;
}

Point operator -(const Point &a,const Point &b){
	Point c=a;
	c-=b;
	return c;
}

bool operator <(const Point &a,const Point &b){
	return (a.x==b.x)?(a.y<b.y):(a.x<b.x);
}

bool operator >(const Point &a,const Point &b){
	return b<a;
}

double dot(const Point &a,const Point &b){
	return a.x*b.x+a.y*b.y;
}

double cross(const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;
}

double dis2(const Point &a,const Point &b){
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}

int ccw(const Point &a,Point b,Point c){
	b-=a;
	c-=a;
	double rotdir=cross(b,c);
	if(rotdir>EPS)		return CCW;
	if(rotdir<-EPS)		return CW;
	return ON;
}

Polygon ConvexHull(vector<Point> ps){
	int n=ps.size();
	sort(ps.begin(),ps.end());

	vector<Point> ch_u(n);
	int n_u=0;
	for(int i=n-1;i>=0;i--){
		ch_u[n_u++]=ps[i];
		while(n_u>=3 && ccw(ch_u[n_u-3],ch_u[n_u-2],ch_u[n_u-1])!=CCW){
			ch_u[n_u-2]=ch_u[n_u-1];
			n_u--;
		}
	}

	vector<Point> ch_l(n);
	int n_l=0;
	for(int i=0;i<n;i++){
		ch_l[n_l++]=ps[i];
		while(n_l>=3 && ccw(ch_l[n_l-3],ch_l[n_l-2],ch_l[n_l-1])!=CCW){
			ch_l[n_l-2]=ch_l[n_l-1];
			n_l--;
		}
	}

	Polygon ch;
	for(int i=0;i<n_u-1;i++)	ch.pb(ch_u[i]);
	for(int i=0;i<n_l-1;i++)	ch.pb(ch_l[i]);
	return ch;
}

bool parallel(const Line &l,const Line &m){
	return abs(cross(l[1]-l[0],m[1]-m[0]))<EPS;
}

bool orthogonal(const Line &l,const Line &m){
	return abs(dot(l[1]-l[0],m[1]-m[0]))<EPS;
}

bool intersect(const Line &l,const Line &m,Point *p=NULL){
	// this routine also returns true in case "M is on L", "M sessuru L", etc,.
	return cross(l[1]-l[0],m[0]-l[0])*cross(l[1]-l[0],m[1]-l[0])<EPS;
}

bool intersect(const Segment &s,const Segment &t,Point *p=NULL){
	if(ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0
	&& ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0){
		return true;
	}
	return false;
}

Line perp_bisector(const Point &a,const Point &b){
	return Line(Point((a.x+a.y+b.x-b.y)/2,(b.x+b.y-a.x+a.y)/2),
				Point((b.x+b.y+a.x-a.y)/2,(a.x+a.y-b.x+b.y)/2));
}

double area(const Point &a,const Point &b,const Point &c){
	return abs(cross(b-a,c-a))/2;
}

double area(Polygon &pl){
	int n=pl.size();
	double a=0;
	for(int i=0;i<n-2;i++)	a+=area(pl[0],pl[i+1],pl[i+2]);
	return a;
}

#include<cstdio>

int main(){
	Polygon pl;
	for(double x,y;~scanf("%lf%*c%lf",&x,&y);)	pl.pb(Point(x,y));
	printf("%f\n",area(pl));
	return 0;
}

Measured memory_bytes: 0