akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 100001;
struct node{
    int v,nxt,cost;
}edge[N<<1];
int head[N],k,tot;
int q[N*8],l,r,u,v;
int dist[N];
void addEdge(int u,int v,int val) {
    edge[++tot].v=v;
    edge[tot].cost=val;
    edge[tot].nxt=head[u];
    head[u]=tot;
}
int main() {
    //freopen("out.txt","w",stdout);
    scanf("%d",&k);
    for (int i=0;i<k;++i) {
        addEdge(i,i+1==k?0:i+1,1);
        addEdge(i,i*10%k,0);
        dist[i]=N;
    }
    dist[1]=0;
    l=-1;
    r=0;
    q[0]=1;
    while (l<r) {
        u = q[++l];
        for (int i=head[u];i;i=edge[i].nxt) {
            v=edge[i].v;
            if (dist[u]+edge[i].cost<dist[v]) {
                dist[v]=dist[u]+edge[i].cost;
                q[++r]=v;
            }
        }
    }
    printf("%d\n",dist[0]+1);
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int N, M, K, Q, W, H, R, C;
int table[55][55];
bool used[55][55];

void dfs(int x, int y) {
    used[x][y] = true;
    vector<int> dx = {1, -1, 0, 0, 1, 1, -1, -1};
    vector<int> dy = {0, 0, 1, -1, 1, -1, 1, -1};
    REP(i, 8) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (0 <= nx && nx < H && 0 <= ny && ny < W && !used[nx][ny] && table[nx][ny] == 1) {
            dfs(nx, ny);
        }
    }
}

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

    vector<int> ans;
    while (true) {
        cin >> W >> H;
        if (W == 0 && H == 0) break;
        memset(used, 0, sizeof(used));
        REP(i, H) {
            REP(j, W) { cin >> table[i][j]; }
        }

        int cnt = 0;
        REP(i, H) {
            REP(j, W) {
                if (table[i][j] == 1 && !used[i][j]) {
                    dfs(i, j);
                    cnt++;
                }
            }
        }
        ans.push_back(cnt);
    }
    for (auto i : ans) {
        cout << i << endl;
    }

    return 0;
}



Measured memory_bytes: 3396
#include <cstdio>

using namespace std;

int main(void){
	int w, n, i, j, m[30][30], a, b, l;
	scanf("%d%d",&w,&n);
	for(i = 0;i < n;i++){
		for(j = 0;j < w;j++){
			m[i][j] = j;
		}
	}
	for(i = 0;i < n;i++){
		scanf("%d%*c%d",&a,&b);
		m[i][b - 1] = a - 1;
		m[i][a - 1] = b - 1;
	}
	for(i = 0;i < w;i++){
		l = i;
		for(j = n - 1;j >= 0;j--){
			l = m[j][l];
		}
		printf("%d\n",l + 1);
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int fn = 0;
    int sq = sqrt(n-2);
    for(int x = 1; x < sq; x++) {//x<y<zで考える
      for(int y = x; y < sq; y++) {
        for(int z = y; z < sq; z++) {
          if((x*x + y*y + z*z + x*y + y*z + z*x) == i) {
            if(x == y && x == z) fn++;
            else if(x == y || y == z || z == x) fn += 3;
            else fn += 6;
          }
        }
      }
    }
    printf("%d\n", fn);
  }
}

Measured memory_bytes: 3704
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;

inline ll min(ll a, ll b) {
	return a < b ? a : b;
}

const int Max = 1e5 + 12;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	unordered_map<string, int> mp;
	ll n, ans = 0;
	cin >> n;
	vector<string> s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	for (int i = 0; i < n; ++i) {
		sort(s[i].begin(), s[i].end());
		++mp[s[i]];
	}
	for (auto f: mp) {
		int val = f.second;
		ans += 1LL * val * (val - 1) / 2;
	}
	cout << ans;
	//system("pause");
	return 0;
}


Measured memory_bytes: 16036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MIN(a,b) (((a)<=(b))?(a):(b))
#define MAX(a,b) (((a)>=(b))?(a):(b))
#define ll long long int
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > (2 * b))
        cout << (a - (2 * b)) << endl;
    else
        cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, h: "List[int]"):
    ans = 0
    for k in range(max(h)):
        r = [i for i in range(N) if h[i] > k]
        a = 0
        j = 0
        while j < len(r):
            a += 1
            while j + 1 < len(r) and r[j + 1] == r[j] + 1:
                j += 1
            j += 1
        ans += a
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  int cnt = 0, cnt_z = 0;
  rep(i,0,n) {
    cin >> a[i];
    if (a[i] < 0) cnt++;
    else if (a[i] == 0) cnt_z++;
  }
  ll ans = 0;
  rep(i,0,n) ans += abs(a[i]);
  if (cnt_z == 0 && cnt % 2 == 1) {
    ll b = 100000000000;
    rep(i,0,n) {
      b = min(b,abs(a[i]));
    }
    ans -= 2*b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#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 pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
# define M_PI 3.14159265358979323846
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 4;
const ll MOD = 998244353;
bool visited[N];
vector<int> edge[N];
vector<int> conc[N];
vector<int> sign(N);
int c = 0;

ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % mod;
        exponent = exponent >> 1;
        base = (base * base) % mod;
    }
    return result;
}

ll Inv(ll x){
    return POW(x, MOD - 2);
}

void DFS(int src){
    visited[src] = 1;
    conc[c].pb(src);
    for(auto i : edge[src]){
        if(!visited[i]) DFS(i);
    }
}

void BFS(int s, vector<int> &d){
    d[s] = 0;
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto to : edge[v]) {
            if (d[to] > d[v] + 1){
                d[to] = d[v] + 1;
                q.push(to);
                sign[to] = v;
            }
        }
    }
}

int main(){
    IOS
    int n, m;
    cin>>n>>m;
    rep(i, 0, m){
        int x, y;
        cin>>x>>y;
        edge[x].pb(y);
        edge[y].pb(x);
    }
    vector<int> d(n + 1, N);
    BFS(1, d);
    cout<<"Yes\n";
    rep(i, 2, n + 1) cout<<sign[i]<<'\n';
    return 0;
}

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

int main() {

	ll x; cin >> x;
	ll i = 1;
	ll sum = 0;
	while (true) {
		sum += i;
		if (x <= sum ) {
			break;
		}
		i++;
	}
	cout << i << endl;
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int A, B, C;

        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        
        if (A <= C && C <= B) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        
        sc.close();
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
#define noob (main)
typedef long long ll;
using namespace  std;
typedef vector<int> vi;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 2e5 +5 ;
vi primes(1,2);
void sieve(){
    vi m(N+1,0);
    for(int i = 4; i<N; i+=2)m[i]=1;
    for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
    for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}
bool isPrime(ll x){
    if(x==1)return 0;
    for(auto i:primes){
        if(i*i>x)return 1;
        if(x%i==0)return 0;
    }
    return 1;
}

int n,B[105];
int noob(){
    fastIO;
    cin>>n;
    for(int i = 0 ; i<n-1 ; i++){
        cin>>B[i];
    }
    int ans = B[0] + B[n-2] ;
    for(int i = 1  ; i<n-1 ;i++){
        ans+=min(B[i],B[i-1]);
    }
    cout<<ans;
}

//3
//3 3
//
//0 153 10 10 23
//0 10 10 10 23


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

#define INF (1 << 21)

using namespace std;

int N;

int check[100000];

queue<string> que, que_next;

int index(string str){
	
	int ref = 0;
	
	for(int i = 0; i < N; i++){
		ref *= 3;
		ref += str[i] - '0';
	}
	
	return ref;
}

int main(){
	
	while(true){
		string str;
		cin >> str;
		
		queue<string> que_emp;
		
		que = que_emp;
		que_next = que_emp;
		
		for(int i = 0; i < 100000; i++){
			check[i] = INF;
		}
		
		if(str[0] == '0'){
			break;
		}else{
			N = str.size();
			for(int i = 0; i < N; i++){
				if(str[i] == 'r'){
					str[i] = '0';
				}else if(str[i] == 'b'){
					str[i] = '1';
				}else{
					str[i] = '2';
				}
			}
		}
		
		que.push(str);
		
		int depth = 0;
		
		while(true){
			while(!que.empty()){
				string str = que.front();
				que.pop();
				if(check[index(str)] != INF){
					continue;
				}
				check[index(str)] = depth;
				for(int i = 0; i < N - 1; i++){
					if(str[i] != str[i + 1]){
						string str_copy = str;
						if(str[i] != '0' && str[i + 1] != '0'){
							str_copy[i] = '0';
							str_copy[i + 1] = '0';
						}else if(str[i] != '1' && str[i + 1] != '1'){
							str_copy[i] = '1';
							str_copy[i + 1] = '1';
						}else{
							str_copy[i] = '2';
							str_copy[i + 1] = '2';
						}
						que_next.push(str_copy);
					}
				}
			}
			que = que_next;
			que_next = que_emp;
			depth++;
			if(que.empty()){
				break;
			}
			//cout << depth << " " << que.size() << endl;;
		}
		
		string check_0 = "";
		string check_1 = "";
		string check_2 = "";
		
		for(int i = 0; i < N; i++){
			check_0 = check_0 + "0";
			check_1 = check_1 + "1";
			check_2 = check_2 + "2";
		}
		
		int ans = min(min(check[index(check_0)], check[index(check_1)]), check[index(check_2)]);
		
		if(ans == INF){
			cout << "NA" << endl;
		}else{
			cout << ans << endl;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool compare(pair<int,int>a,pair<int,int>b)
{
	if(a.second==b.second)
		return a.first>b.first;
	return a.second<b.second;
}
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	int n,f=0;
	cin>>n;
	vector<pair<int,int>>v;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		cin>>a>>b;
		v.push_back({a,b});
	}
	sort(v.begin(),v.end(),compare);
	for(int i=0;i<v.size();i++)
	{
		if(ans+v[i].first>v[i].second)
		{
			f=1;
			break;
		}
		ans+=v[i].first;

	}
	if(f)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;

	
	
}


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>

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

using namespace std;

typedef vector<int> vi;

int main(){
    int a, b;
    while(cin >> a >> b){
        vector<int> route(105, 0);
        do{
            route[a]++;
            route[b]++;
        } while(cin >> a >> b, a|b);
        route[1]++, route[2]++;
        bool ok = true;
        rep(i, route.size()) if(route[i]%2) ok = false; 
        cout << (ok?"OK":"NG") << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
n = int(input())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))

if sum(a_li) < sum(b_li):
    print(-1)
    exit()
    
check = [0]*n
cnt = 0
SUM_ma = 0

for i in range(n):
    check[i] = a_li[i] - b_li[i]
    
    if check[i] < 0:
        cnt += 1
        SUM_ma += check[i]

if SUM_ma < 0:
        
    check.sort(reverse=True)
    
    for i in check:
        SUM_ma += i
        cnt += 1
        
        if SUM_ma >= 0:
            break
        
print(cnt)

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

vi counter;
vvi g;
vector<bool> seen;

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

void dfs(int p)
{
    seen[p] = true;
    for (auto v : g[p])
    {
        if (seen[v])
        {
            continue;
        }
        counter[v] += counter[p];
        dfs(v);
    }
}

void solve()
{
    int n, q;
    in2(n, q);
    counter.assign(n, 0);
    g.resize(n);
    seen.assign(n, false);
    rep(i, n - 1)
    {
        int a, b;
        in2(a, b);
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i, q)
    {
        int p, x;
        in2(p, x);
        p--;
        counter[p] += x;
    }
    dfs(0);
    rep(i, n)
    {
        cout << counter[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 23552
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int k = in.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < n; i++)
			v[i] = in.nextInt();
		System.out.println(solve(n, k, v));
		in.close();
	}

	private static int solve(int n, int k, int[] v) {
		int a = 0;
		for (int l = 0; l <= k && l <= n; l++)
			for (int r = 0; r <= k - l && r <= n - l; r++) {
				int x = vSum(k, v, l, r);
				if (x > a)
					a = x;
			}
		return a;
	}

	private static int vSum(int k, int[] v, int l, int r) {
		int a = 0;
		int[] m = new int[l + r];
		int mi = 0;
		for (int i = 0; i < l; i++) {
			a += v[i];
			if (v[i] < 0)
				m[mi++] = v[i];
		}
		for (int i = v.length - 1; i > v.length - 1 - r; i--) {
			a += v[i];
			if (v[i] < 0)
				m[mi++] = v[i];
		}
		Arrays.sort(m);
		for (int i = 0; i < k - l - r && i < m.length; i++)
			a -= m[i];
		return a;
	}

}

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

int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<long>> dp1(n, vector<long>(n, 0)),
      dp2(n, vector<long>(n, 0));  // dp1:先手の得点, dp2:後手の得点
  for (int i = 0; i < n; i++) dp1[i][i] = a[i];
  for (int d = 1; d < n; d++) {
    // d=r-l;
    for (int l = 0; l < n - d; l++) {
      int r = l + d;
      long x1 = a[l] + dp2[l + 1][r], y1 = dp1[l + 1][r],
           x2 = a[r] + dp2[l][r - 1], y2 = dp1[l][r - 1];
      if (x1 - y1 >= x2 - y2) {
        dp1[l][r] = x1;
        dp2[l][r] = y1;
      } else {
        dp1[l][r] = x2;
        dp2[l][r] = y2;
      }
    }
  }
  cout << dp1[0][n - 1] - dp2[0][n - 1];
  return 0;
}

Measured memory_bytes: 142720
import itertools
import math
import fractions
import functools
import copy
from collections import deque

n, m = map(int, input().split())
ab = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

ans = [-1] * n
d = deque([0])

while d:
    f = d.popleft()
    for i in ab[f]:
        if ans[i] == -1:
            ans[i] = f
            d.append(i)

print("Yes")
for i in range(1,n):
    print(ans[i]+1)


Measured memory_bytes: 98220
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
  st=input()
  if st=='AC':
    ac+=1
  elif st=="WA":
    wa+=1
  elif st=="TLE":
    tle+=1
  elif st=="RE":
    re+=1
print('AC x '+ str(ac))
print("WA x "+ str(wa))
print("TLE x "+ str(tle))
print("RE x "+ str(re))

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    string s;
    cin >> s;
    ll count0 = 0, count1 = 0;
    rep(i, s.length()){
        if(s[i] == '0') count0++;
        else count1++;
    }
    print(min(count0, count1) * 2);
}

Measured memory_bytes: 512
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

a=a1-b1
b=a2-b2

if a<=0:
    a *= -1
    b *= -1

X=t1*a
Y=t2*b


if X+Y==0:
    print('infinity')
elif X+Y>0:
    print(0)
else:
    T=X//abs(X+Y)
    if X%abs(X+Y)==0:
        print(T*2)
    else:
        print(T*2+1)


Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n, x, t;
  cin >> n >> x >> t;
  ll ans = n / x * t;
  if (n % x != 0) {
    cout << ans + t << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

n, T = map(int, input().split())
c = ["" for _ in range(n)]
t = ["" for _ in range(n)]

for i in range(n):
    c[i], t[i] = map(int, input().split())

#print(c)
#print(t)

INF = 10**4
dp = INF
for i in range(n):
    if T >= t[i]:
        dp = min(dp, c[i])

if dp == INF:
    print("TLE")
else:
    print(dp)


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) return cout << "OK" << "\n", 0;
  }
  cout << "NG" << "\n";
}

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

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,r,n) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()

using ll = long long int;
using ull = unsigned long long int;
using vi = vector<ll>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> k >> s;
	int c[n+1];
	c[0] = 0;
	c[n] = 0;
	FOR(i,1,n) {
    	if (s[i-1]==s[i])
          c[i] = 0;
    	else
          c[i] = 1;
    }
	sum = accumulate(c,c+(n+1),0);
	sum -= k * 2;
	ans = n - sum;
    if (sum < 0) ans = n;
	cout << ans - 1 << endl;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[10000],m=1000000,M=-1000000;
  long long sum=0;
  cin >> n;
  for(int i=0; i<n; i++) {
      cin >> a[i];
      m=min(m,a[i]);
      M=max(M,a[i]);
      sum+=a[i];
  }
  cout << m << " " << M << " " << sum << endl;
}


Measured memory_bytes: 3132
N = int(input())
ans = 0
for x in range(105, N+1, 2):
    cnt = 1
    for y in range(2, x+1):
        if x % y == 0:
            c = 0
            while x % y == 0:
                c += 1
                x //= y
            cnt *= c+1
    if cnt == 8:
        ans += 1
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string>
using namespace std;

string s;
int t,na;
bool reject;
vector<int> ra;

void dfs(int sum,int pos,vector<int> &ans) {
    if(sum > t) return;
    if(pos == s.length()) {
        if(na == sum) reject = true;
        if(na < sum) {
            reject = false;
            na = sum;
            ra = ans;
        }
        return;
    }

    for(int i=0; i<s.length()-pos; ++i) {
        int tmp = atoi(s.substr(pos,i+1).c_str());
        ans.push_back(tmp);
        dfs(sum+tmp, pos+i+1, ans);
        ans.pop_back();
    }
}

int main() {
    while(cin>>t>>s) {
        if(t == 0 && s == "0") break;
        na = -1;
        reject = false;

        vector<int> r;
        dfs(0, 0, r);

        if(reject) cout<<"rejected"<<endl;
        else if(na == -1) cout<<"error"<<endl;
        else {
            cout<<na;
            for(int i=0; i<ra.size(); ++i) cout<<" "<<ra[i];
            cout<<endl;
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef pair <int,int> P;
ll gcd(ll a , ll b){ return b ? gcd(b,a%b) : a;}

int main()
{
    ll N;
    cin >> N;
    vector<ll> hp(N, 0);
    rep(i, N) {
        cin >> hp[i];
    }
    sort(hp.begin(), hp.end());
    ll min = hp[0];
    rep(i, N-1) {
        ll ret = gcd(min, hp[i + 1]);
        if (ret != 0 & ret < min) {
            min = ret;
        }
    }
    cout << min << endl;
    return 0;
}



Measured memory_bytes: 1024
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N=int(input())
An=list(map(int, input().split()))
def has_duplicates(seq):
    return len(seq) != len(set(seq))

if has_duplicates(An):
    print('NO')
else:
    print('YES')

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    if s[1] == s[2] and (s[1]==s[0] or s[2] == s[3]):
        return 'Yes'

    return 'No'



print(main())




Measured memory_bytes: 6736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int min;
		int max;
		if (N < A + B) {
			min = A+B-N;
		} else {
			min = 0;
		}
		max = Math.min(A, B);

		System.out.println(max + " " + min);
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    int M;
    int count=0;
    cin>>N>>M;
    
    if(N>=2)
    {
      count+=(N*(N-1))/2;
    }
    
    if(M>=2)
    {
      count+=(M*(M-1))/2;
    }
 	cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        checked {
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
        }
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        long sum = 1;

        if (ary.Any(x => x == 0)) return 0;

        long prev = -1;
        foreach (var a in ary) {
            sum *= a;
            if (sum < prev) return -1;
            if (sum > 1000000000000000000) return -1;
            prev = sum;
        }

        return sum;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

using namespace std;

int N,M,V,P;
int seq[100050];
long long sum[100050];

int main()
{
	scanf("%d%d%d%d",&N,&M,&V,&P);
	for(int i = 1;i <= N; ++ i)
		scanf("%d",&seq[i]);
	sort(seq + 1,seq + 1 + N);
	for(int i = 1;i <= N; ++ i) sum[i] = sum[i - 1] + seq[i];
	int las = seq[N - P + 1];
	seq[0] = -1; seq[N + 1] = 0x3f3f3f3f;
	for(int i = 1;i <= N; ++ i)
	{
		if(seq[i] == seq[i - 1]) continue;
		if(seq[i] >= las)
		{
			printf("%d\n",N - i + 1);
			return 0;
		}
		else
		{
			int po = i;
			while(seq[po + 1] == seq[i]) po ++;
			int cnt = V - po;
			if(N - cnt + 1 > N - P + 1)
			{
				if(seq[po] + M >= las)
				{
					printf("%d\n",N - i + 1);
					return 0;
				}
			}
			else
			{
				int tar = seq[po] + M;
				if(tar < las) continue;
				long long tot = tar * 1ll * (N - P - po + 1) - (sum[N - P + 1] - sum[po]);
				long long onc = V - po - P + 1;
				if(tot >= M * onc)
				{
					printf("%d\n",N - i + 1);
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 1536
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	    int digit = 0;
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    boolean no = true;
	    while(n != 0){
	        digit = n % 10;
	        if(digit == 7){
	            System.out.println("Yes");
	            no = false;
	            break;
	        }
	        n= Math.floorDiv(n, 10);
	        
	    }
	    if(no == true)
	    System.out.println("No");
	}
}


Measured memory_bytes: 35804
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }


int main(){
    int N; cin >> N;
    double gu[N];
    rep(i,N) cin >> gu[i];
    int v; //ソートの一時的なハコ
    for(int i = 0; i<N;i++){
        v = gu[i];
        int j = i - 1;
        while(j >=0 && gu[j] > v){
            gu[j+1] = gu[j];
            j--;
        }
        gu[j+1] = v;
    }
    double tmp,ans;
    for(int i=1;i<N;i++){
        tmp = (gu[i-1]+gu[i])/2;
        gu[i] = tmp;
    }
    cout << gu[N-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define mx(x,y) x=max(x,y)
int N,M,W,T;
string s[7];
int v[7],p[7],l[7],x[7],y[7],inf=1e9;
vector<int> itemid[7],itemp[7];
int dist(vector<int> towns){
	int mn=inf;
	int tn=towns.size();
	do{
		int now=abs(x[towns[0]])+abs(y[towns[0]]);
		rep(i,tn-1){
			now+=abs(x[towns[i+1]]-x[towns[i]])+abs(y[towns[i+1]]-y[towns[i]]);
		}
		now+=abs(x[towns[tn-1]])+abs(y[towns[tn-1]]);
		mn=min(mn,now);
	}while(next_permutation(all(towns)));
	return mn;
}
int knapsack(vector<int> items,vector<int> pro){
	int in=items.size();
	int dp[10001]={};
	rep(i,in){
		int id=items[i];
		rep(j,W+1){
			if(j+v[id]>W) break;
			mx(dp[j+v[id]],dp[j]+pro[i]);
		}
	}
	int ret=0;
	rep(j,W+1) mx(ret,dp[j]);
	return ret;
}
int dis[128],pro[128],dp[10001];
#undef int
int main(){
#define int long long
	cin>>N>>M>>W>>T;
	rep(i,M) cin>>s[i]>>v[i]>>p[i];
	rep(i,N){
		cin>>l[i]>>x[i]>>y[i];
		rep(j,l[i]){
			string rr;
			int pp;
			cin>>rr>>pp;
			rep(k,M){
				if(s[k]==rr){
					itemid[i].pb(k);
					itemp[i].pb(p[k]-pp);//benefit
				}
			}
		}
	}
	rep(i,1<<N){
		if(i==0) continue;
		vector<int> towns;
		rep(j,N) if((i>>j)&1) towns.pb(j);
		dis[i]=dist(towns);
		vector<int> pros(7,-inf);
		for(int u:towns){
			rep(k,l[u]){
				mx(pros[itemid[u][k]],itemp[u][k]);
			}
		}
		vector<int> items,prro;
		rep(j,M){
			if(pros[j]!=-inf){
				items.pb(j);
				prro.pb(pros[j]);
//				show(s[j]);
//				show(pros[j]);
			}
		}
		pro[i]=knapsack(items,prro);
//		show(i);
//		show(dis[i]);
//		show(pro[i]);
	}
	rep(i,1<<N){
		rep(j,T+1){
			if(j+dis[i]>T) break;
			mx(dp[j+dis[i]],dp[j]+pro[i]);
		}
	}
	int ans=0;
	rep(j,T+1) mx(ans,dp[j]);
	cout<<ans<<endl;
}

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

int main(void){
 char b;
  cin >> b;
  if(b == 'A') cout << 'T';
  else if(b == 'T') cout << 'A';
  else if(b == 'C') cout << 'G';
  else if(b == 'G') cout << 'C';
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    char x,y;
    cin >> x >> y;
    if(x > y)cout << ">" << endl;
    else if(x < y)cout << "<" << endl;
    else cout << "=" << endl;
    
    return 0;
}

Measured memory_bytes: 256
f = [-1 for i in range(45)]
f[0] = f[1] = 1

def fib(n):
    global f
    for i in range(2,n+1):
        f[i] = f[i - 1] + f[i - 2]
        #print(i,f[i])
    return f[n]

if __name__ == "__main__":
    n = input()
    n = int(n)
    #print(type(n))
    print(fib(n))



Measured memory_bytes: 5604
import java.lang.reflect.Array;
import java.util.*;
import java.lang.*;


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

        int N = sc.nextInt();
        List<Integer> a = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }

        Collections.sort(a);

        System.out.println(a.get(N - 1) - a.get(0));

    }
}




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

int main(){
    string S;cin>>S;
    int x,y;
    x = (S[0]-'0')*10+(S[1]-'0');
    y = (S[2]-'0')*10+(S[3]-'0');
    auto check=[&](int i){
        if(1<=i && i<=12){
            return true;
        }else{
            return false;
        }
    };
    if(check(x)){
        if(check(y)){
            cout<<"AMBIGUOUS"<<endl;
        }else{
            cout<<"MMYY"<<endl;
        }
    }else{
        if(check(y)){
            cout<<"YYMM"<<endl;
        }else{
            cout<<"NA"<<endl;
        }
    }
    return 0;
}

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

int64_t f(int64_t n){
    return n*(n-1)/2;
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i], a[i]--;
    
    vector<int64_t> m(n,0);
    rep(i,n)m[a[i]]++;
    
    int64_t ans = 0;
    rep(i,n)ans += f(m[i]);
    
    for(int i=0; i<n; i++){
        cout << ans -f(m[a[i]]) + f(m[a[i]]-1) << endl;
        //printf("%lld\n", ans -f(m[a[i]]) + f(m[a[i]]-1));
    }
    
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <cassert>

static const int MOD = 1000000007;

int main() {

  // Get input data
  int numTeam;
  std::cin >> numTeam;
  std::vector<char> orderChange(numTeam + 1);
  for (int i = 1; i <= numTeam; ++i) {
    char c;
    std::cin >> c;
    orderChange[i] = c;
    assert(c == 'D' or c == 'U' or c == '-');
  }

  // Init
  std::vector<std::vector<long long>> dp(numTeam + 1);
  for (int i = 0; i <= numTeam; ++i)
    dp[i].assign(numTeam + 2, 0);
  dp[0][0] = 1;

  // Main
  for (int i = 0; i < numTeam; ++i) {
    for (int j = 0; j <= i; ++j) {
      switch (orderChange[i + 1]) {
      case 'D':
        dp[i + 1][j + 1] += dp[i][j] * (i - j);
        dp[i + 1][j + 1] %= MOD;
        dp[i + 1][j + 2] += dp[i][j] * (i - j) * (i - j);
        dp[i + 1][j + 2] %= MOD;
        break;
      case '-':
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j + 1] %= MOD;
        break;
      case 'U':
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= MOD;
        dp[i + 1][j + 1] += dp[i][j] * (i - j);
        dp[i + 1][j + 1] %= MOD;
        break;
      default:
        assert(false);
      }
    }
  }

  // Output
  std::cout << dp[numTeam][numTeam] << std::endl;
}



Measured memory_bytes: 3212
#include <iostream>

using namespace std;

int main()
{
    long long n ;
    cin>> n ;
    int cnt =2 ;
    if (n<=1000)
    {
        cout<<1000-n<<endl ;
        return 0 ;
    }
    long long num =0 ;
    while (true)
    {
        if (1000*cnt>=n)
        {
            num=1000*cnt ;
            break ;
        }
        cnt++ ;
    }
    cout<< num-n<<endl ;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
#define AC ios::sync_with_stdio(0),cin.tie(0);

int main()
{
    AC
    int n,t,r=0;
    cin>>n;
    vector<int> a(n+1),c(n+1,0);
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>t,r+=t;
    for(int i=1;i<=n-1;i++) cin>>c[i];
    for(int i=1;i<n;i++) if(a[i+1]-a[i]==1) r+=c[a[i]];
    cout<<r<<'\n';
}


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

int main(){
  int n, m; cin >> n >> m;
  if(m > n){
    vector<int> x(m);
    for(int i = 0; i < m; i++)
    {
      cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    int mm = m-1;
    vector<int> diff(mm);
    int ans = 0;
    if (mm != 0) {  
    for(int i = 0; i < mm; i++)
    {
      diff.at(i) = x.at(i+1) - x.at(i);
      ans += diff.at(i);
    }
    sort(diff.begin(), diff.end());
    reverse(diff.begin(), diff.end());
    for(int i = 0; i < n-1; i++)
    {
      ans -= diff.at(i);
    }
    cout << ans << endl;
    return 0;
    }
    else
    {
      cout << 0 << endl;
      return 0;
    }
  }
  else
  {
    cout << 0 << endl;
  }
  
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_X = 1e5+10;

ll dp[MAX_X][2][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, X;
    cin >> N >> X;
    vector<ll> s(N);
    rep(i, N) cin >> s[i];
    sort(rall(s));
    int cur = 0, nxt = 1;
    dp[X][0][cur] = 1LL;
    rep(i, N) {
        rep(j, X+1) {
            dp[j][0][nxt] = 0LL;
            dp[j][1][nxt] = 0LL;
        }
        rep(j, X+1) {
            (dp[j][0][nxt] += dp[j][0][cur] * (N-1-i)) %= MOD;
            (dp[j][1][nxt] += dp[j][1][cur] * (N-1-i)) %= MOD;
            (dp[j%s[i]][1][nxt] += dp[j][0][cur] + dp[j][1][cur]) %= MOD;
        }
        swap(cur, nxt);
        // rep(j, X+1) {
        //     cout << " (" << dp[j][0][cur] << ", " << dp[j][1][cur] << ") " ;
        // }
        // cout << endl;
    }
    ll ans = 0LL;
    rep(i, s.back()+1) {
        ll tmp = dp[i][1][cur]*i % MOD;
        (ans += tmp) %= MOD;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int dp[3][100010];

int main(){

    rep(i,3){
        rep(j,100010){
            dp[i][j] = 0;
        }
    }

    int n;
    int tmp ;
    ll ans = 1;
    ll mod = 1e9+7;
    
    cin >> n;
    vector<int> vec(n);
    rep(j,n){
        cin >> tmp;
        vec[j] = tmp;
        rep(i,3){
            dp[i][j+1] = dp[i][j];
        }
        rep(i,3){
            if(dp[i][j+1] == tmp) {
                dp[i][j+1] = tmp+1;
                break;
            }
        }
    }
    
    rep(j,n){
        ll cnt = 0;
        rep(i, 3){
            if(dp[i][j] == vec[j]){
                cnt++;
            }
        }
        ans = (ans*cnt) % mod;
    }

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

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

int main()
{
    int n;
    cin >> n;
    map<string, int> cnt;
    rep(i, n) {
        string s;
        cin >> s;
        cnt[s]++;
    }
    cout << "AC x " << cnt["AC"] << endl;
    cout << "WA x " << cnt["WA"] << endl;
    cout << "TLE x " << cnt["TLE"] << endl;
    cout << "RE x " << cnt["RE"] << endl;
    return 0;
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    Int res = 0;
    rep(i, 0, 4) {
        if (s[i] == '+') res++;
        else res--;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
  int a=0,b=0,n,N[10000],i=0;
  long long  c=0;

scanf("%d",&n); 

  for( i =0; i< n ; i++){
    
    scanf("%d",&N[i]);
    a=N[0];
    b=N[0];
  }

  for(i=1; i<n ; i++){ 

    if(N[i] < b){ b =N[i];}
    if (N[i]> a){ a = N[i];}

  }

 for(i=0;i<n;i++){

 c=c+N[i];
 
  }

  printf("%d %d %lld\n",b,a,c);

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <bitset>
#include <map>
using namespace std;
std::map<int, long long> mp1;
std::map<int, long long> mp2;
unsigned long ans1 = 0;
unsigned long ans2 = 0;
std::map<int, long long> mp3;

long long pow(long long n, long long p, long long m)
{
    if(m == 0) return 0;
    if(p == 0) return (1 % m);
    long long ret = 1;
    for (; p > 0; p >>= 1, n = n * n % m){
		if (p%2 == 1){
			ret = ret * n % m;
		}
	}
	return ret;
}

unsigned long f(std::bitset<200000>& bs, int hibit, long long index, long long N)
{
    long long ret = -1;
    long long count = 0;
    
    // 初回だけmpを使って計算
    //int hibit = count;
    if(bs[index] == 0){
        ret = ans1 + mp1[index];
        hibit++;
    }else{
        ret = ans2 - mp2[index];
        hibit--;
        if(hibit <= 0) return count;
        if(ret < 0) ret += hibit;
    }
    if(ret >= hibit){
        //std::cout << ">> " << ret << std::endl;
        ret = ret % hibit;
    }
    count++;
    //std::cout << ">>>> " << ret << std::endl;

    
    std::map<int, long long>::iterator itr = mp3.find(ret);
    if(itr != mp3.end()){
        return itr->second;
    }
    int tmp = ret;
    
    
    while(ret != 0){
        //std::cout << ">>>> " << ret << std::endl;
        std::bitset<200000> tmpbs(ret);
        ret = ret % tmpbs.count();
        count++;
    }
    mp3.emplace(tmp, count);

    // nが0になるまでの操作回数を返す
    return count;
}
 
int main()
{
    long long N;
    std::cin >> N;
    std::string X;
    std::cin >> X;
 
    // 前準備
    std::bitset<200000> bs(X);
    //N = 200000;
    //std::bitset<200000> bs(std::string(N, '0'));
    //bs[0].flip();
    const int count = bs.count();

    // 制約から1<=Nなので、count=0のケースは考慮不要
    for(long long i=N-1; i>=0; i--){
        mp1[i] = pow(2, i, count+1);
        mp2[i] = pow(2, i, count-1);
        if(bs[i] == 1){
            ans1 += mp1[i];
            ans2 += mp2[i];
        }
    }
    //ans1 = ans1 % (count+1);
    //ans2 = ans2 % (count-1);
    
    // ここから本処理
    for(long long i=N-1; i>=0; i--){
        unsigned long result = f(bs, count, i, N);
        std::cout << result << std::endl;
    }
}
 

Measured memory_bytes: 29292
#入力取得
N, K = map(int, input().split())
S = input()

char = S[K-1]
small = char.lower()

if K == len(S):
    result = S[0:K-1] + small
elif K == 1:
    result = small + S[1:]
elif K != 1:
    result = S[0:K-1] + small + S[K:]

print(result)


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

int main(){
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	rep(i, n) {
		cout << s[i]<<t[i];
	}
	return 0;
}

Measured memory_bytes: 256
/**
 * @Author : Gaurang_Kothiya
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define bits(n) __builtin_popcountll(n)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9 +1;
const int inf64= 1e18 -1;
const int MOD= 1e9 +7;
const int MOD2= 998244353;


void Solve()
{
	int n;
	cin>>n;
	
	int a[n];
	f(i,0,n-1)
	{
		cin>>a[i];
	}
	int ans=0;
	int mx=a[0];
	f(i,1,n-1)
	{
		if(a[i]>=mx)
		{
			mx=a[i];
		}
		else
		{
			ans += mx-a[i];
		}
	}
	cout<<ans;
}
 
signed main() 
{
	speed		

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);	

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 5200
import numpy as np
from numba import njit

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


@njit
def search(a):
  B = np.zeros_like(a)
  for i in range(N):
    l = max(0, i-a[i])
    r = min(N-1, i+a[i])
    B[l]+=1
    if r+1 < N:
      B[r+1]-=1
  B = np.cumsum(B)
  return B

for _ in range(K):
  A = search(A)
  if min(A) == N:
      break
A = map(str, A)
print(' '.join(A))

Measured memory_bytes: 128948
/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<signal.h>
#include<unistd.h>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
#define ws wss
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
void read(int &x)
{
	char ch;int fu=1;
	while ((ch=getchar())<=32);
	x=0;
	if (ch=='-') fu=-1;else x=ch-48;
	while ((ch=getchar())>32) x=x*10+ch-48;
	x*=fu;
}
template<class T> void upmax(T &a,T b) { if (a<b) a=b;}
template<class T> void upmin(T &a,T b) { if (a>b) a=b;}

//---------template--------------
const int N=2100,p=1000000007;
int cas,n,m;
int a[N][N],f[N][N];
queue<PII> Q;
char s[N];
void get(int x,int y,int t)
{
	if (x==0||x>n||y==0||y>m) return;
	if (a[x][y]==1) return;
	a[x][y]=1;
	f[x][y]=t+1;
	Q.push(MP(x,y));
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s);
		for (int j=1;j<=m;j++)
		{
			a[i][j]=s[j-1]=='#';
			if (a[i][j]==1) Q.push(MP(i,j));
		}
	}
	while (!Q.empty())
	{
		PII now=Q.front();Q.pop();
		int t=f[now.FR][now.SC];
		get(now.FR+1,now.SC,t);
		get(now.FR-1,now.SC,t);
		get(now.FR,now.SC-1,t);
		get(now.FR,now.SC+1,t);
	}
	int ans=0;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
		ans=max(ans,f[i][j]);
	printf("%d\n",ans);
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    string s;
    cin>>s;
    ll ans=0;
    for(int bit=0;bit<(1<<(int)s.length()-1);bit++){
    	ll m=0;
    	for(int i=0;i<(int)s.length();i++){
    		m=m*10+s[i]-'0';
    		if(bit &(1<<i)){
    			ans+=m;
    			m=0;
    		}
    	}
    	ans+=m;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main(){
  int n;
  cin>>n;
  int m = 0;
  vector<int >a(n);
  int cnt = 0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(m <= a[i]){
       cnt++;
      m = a[i];
    }
  }
  cout<<cnt<<"\n";
  return 0;
}

Measured memory_bytes: 256