akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;

typedef pair<int,int> P;

int n;
int d[20][20];
int dp[1<<15][20];
bool use[20];
vector<string> s;

int rec(int st, int prv){
  if(st==(1<<n)-1)return 0;
  if(prv>=0 && dp[st][prv]>=0)return dp[st][prv];

  int res = 10000;
   
  for(int i=0;i<n;i++){
    if( (st>>i) & 1 )continue;
    int cost = s[i].size();
    if(prv>=0)cost -= d[prv][i];
    res = min(res,rec(st|(1<<i),i)+cost);
  }
  return dp[st][prv] = res;
}

int main(){
  while(cin >> n,n){
    s.resize(n);
    for(int i=0;i<n;i++){
      cin >> s[i];
      use[i] = false;
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	if(s[i].size() > s[j].size())continue;
	int l = s[i].size();
	for(int k=0;k+l<=s[j].size();k++){
	  if(s[i] == s[j].substr(k,l)){
	    use[i] = true;
	    break;
	  }
	}
      }
    }

    int p = 0;
    for(int i=0;i<n;i++){
      if(use[i])s.erase(s.begin()+p);
      else p++;
    }

    n = s.size();

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(i==j)continue;
	d[i][j] = 0;
	int l = min(s[i].size(),s[j].size()) - 1;
	for(int k=l;k>=1;k--){
	  if(s[i].substr(s[i].size()-k,k) == s[j].substr(0,k)){
	    d[i][j] = k;
	    break;
	  }
	}
      }
    }

    for(int i=0;i<(1<<n);i++){
      for(int j=0;j<n;j++)dp[i][j] = -1;
    }
    
    cout << rec(0,-1) << endl;
  }
}

Measured memory_bytes: 2500
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

#define SIZE 100000

int main(){
    int n,a,b;
    int ans = 0;
    vector<int> day[31];
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&a,&b);
        a--;
        b--;
        
        day[a].push_back(b);
    }
    
    priority_queue<int> pq;
    
    
    for(int i=0;i<31;i++){
        while(pq.size() && pq.top() > -i) pq.pop();

        for(int j=0;j<day[i].size();j++){
            pq.push(-day[i][j]);
        }
        
        if(pq.size()){
            ans += 100;
            pq.pop();
        }else{
            ans += 50;
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 1196
using System;

namespace ABC120B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);
            int K = int.Parse(s[2]);

            int count = 1;
            for (int i = 100; i >= 1; i--)
            {
                if(A % i != 0) { continue; }
                if(B % i != 0) { continue; }
                if (count != K) { count++; continue;}
                Console.WriteLine(i);
                return;
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    if (nap[0] == nap[1] && nap[1] == nap[2])
        cout << "Yes";
    else
    {
        if (nap[1] == nap[2] && nap[2] == nap[3])
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#define ff(i,m,n) for(int i=m;i<n;i++)
#define i64 int64_t
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(2));//座標
	vector<vector<double>> b(n, vector<double>(n));//距離
	ff(i, 0, n) {
		cin >> a.at(i).at(0);
		cin >> a.at(i).at(1);
	}
	double c = 0;
	ff(i, 0, n) {
		ff(j, 0, n) {
			int x = a.at(i).at(0) - a.at(j).at(0);
			int y = a.at(i).at(1) - a.at(j).at(1);
			b.at(i).at(j) = sqrtl(x * x + y * y);
			c += b.at(i).at(j);
		}
	}
	double z = c / n;
	cout <<setprecision(12)<< z << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <set>
using namespace std;


int main()
{
  long n, w;
  scanf("%ld %ld", &n, &w);
  vector<long> values(n, 0);
  vector<long> weights(n, 0);
  long long max_value = 1;
  long long max_weight = 1;
  for(int i = 0; i<n; i++){
    scanf("%ld %ld", &weights[i], &values[i]);
    max_value = max_value + values[i];
    max_weight = max_weight + weights[i];
  }
  vector<long long> arr(n * max_value, max_weight);

  for (int j=0; j<n; j++){
    arr[j] = 0;
  }
  arr[values[0] * n] = weights[0];
  
  for (int j=1; j<n; j++) {
    for (long i=0; i<max_value; i++){
      if (i < values[j]){
        arr[i*n + j] = arr[i*n+j-1]; 
      } else {
        arr[i*n + j] = std::min(arr[i*n+j-1], arr[(i-values[j])*n + j-1] + weights[j]);
      }
    }
  }
  //for (int j=0; j<n; j++) {
  //  for (int i=0; i<max_value; i++){
  //    printf("%lld ", arr[i*n+j]);
  //  }
  //  printf("\n");
  //}
  for (long i=max_value - 1; i>-1; i--){
    //printf("%lld %ld\n", arr[i*n + n -1], i);
    if(arr[i*n + n - 1] <= w){
      printf("%ld\n", i);
      break;
    }
  }
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10, md = 1e9 + 7;
using ll = long long ;

ll sum_to (int x) {
    if (x <= 0) return 0;
    return (1LL * x * (x + 1)) / 2;
}

ll sum_to (int l, int r) {
    return sum_to(r) - sum_to(l - 1);
}

int main () {
    int n, k;

    ll ans = 0;

    scanf("%d %d", &n, &k);


    for (int i = k; i <= n + 1; ++ i) {
        ll lb = sum_to(i - 1);

        ll rb = sum_to(n - i + 1, n);

     //   fprintf(stderr, "lb rb %lld %lld\n", lb, rb);
        ans = (ans + (rb - lb + 1) % md) % md;
    }

    ans %= md;

    printf("%d\n", ans);
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 3824
from collections import Counter

n=int(input())
l=[]
for i in range(n):
    l.append(input())
l=Counter(l).most_common()
Max=l[0][1]
ans=[]
for i,j in l:
    if j==Max:
        ans.append(i)
for i in sorted(ans):
    print(i)

Measured memory_bytes: 120144
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

intext = input()
[r, g, b, n] = map(int, intext.split())

rgb_list = [r, g, b]
rgb_list.sort(reverse=True)
[x, y, z] = rgb_list

cnt = 0
for x_val in range(0, n+1, x):
    # for y_val in range(0, n+1, y):
    for y_val in range(0, (y*((n-x_val)//z))+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
/*
我的心脏怦怦跳，监管者就在附近
*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
int a[10001],s[10001];
int main()
{
	int n,m;
	int i;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(i=0;i<=n;i++){
		for(int j=0;j<=i;j++){
			s[i]+=a[j];
		}
	}
	int g=0;
	for(i=0;i<=n;i++){
		if(s[i]<=m) g++;
	}
	cout<<g;
	return 0;
}


Measured memory_bytes: 256
/* ****Enigma27**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,i,j,k,l,ans=0,cnt=0,flag=0,a[100005];
map<ll,ll> m;
vi v;
int main()
{	ios
	cin>>n>>k;
	
	for(i=0;i<n;i++){
	
		cin>>j;
		m[j]++;
	}	
	if(m.size()<=k) {cout<<0;return 0;}
	for(auto j:m){
		v.pb(j.second);
	}
	sort(all(v));
	reverse(all(v));
	for(j=k;j<v.size();j++) ans+=v[j];
		cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 14964
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999

using namespace std;

typedef long long ll;

ll d[22];

int main()
{
	int n;
	cin >> n;

	d[1] = 1;
	for (int i = 2; i <= n; i++) {
		d[i] = d[i - 1] * i;
	}
	cout << d[n] << endl;
	
	return 0;
}

Measured memory_bytes: 3096
from copy import deepcopy
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    H,W,K = map(int, readline().split())
    C = [list(readline().strip()) for _ in range(H)]
    
    ans = 0
    for i in range(2**(H+W)):
        c = deepcopy(C)
        for j in range(H+W):
            if (i >> j) & 1:
                if j < H:
                    for s in range(W):
                        c[j][s] = "."
                else:
                    for k in range(H):
                        c[k][j-H] = "."
        cnt = 0
        for line in c:
            cnt += line.count("#")
        if cnt == K:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9268
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
j = []
h = []
index = 1
for i in range(n):
    s, p = readms()
    p = -(int(p))
    heapq.heappush(h, (s, p,index))
    index += 1
index = 1
while(h):
    s,p,index = heapq.heappop(h)
    print(index)


Measured memory_bytes: 6352
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tlll tuple<ll, ll, ll>

int main() {
    char s[1];
    cin >> s;
    cout << char(s[0] + 1) << endl;

}


Measured memory_bytes: 256
N = gets.to_i
Ss = gets.split.map(&:to_i)

ans = 0
(1 .. N/2).each do |c|
  l, r, x = 0, N - 1, 0
  while ((N - 1) % c == 0 && l < r) || ((N - 1) % c != 0 && l + c < N - 1)
    x += Ss[l] + Ss[r]
    l += c; r -= c
    ans = x if x > ans
  end
end
puts ans

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

int main() {
	int n;
    cin>>n;
    int c1=0,c2=0,c3=0,c4=0;
   string s;
   for(int i=0;i<n;i++){
        cin>>s;
      if(s=="AC"){
           c1++;
       }
     else if(s=="WA"){
            c2++;
      }
     else if (s=="TLE"){
           c3++;
     }
     else{
      c4++;
    }
 }
  cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;
 
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main() {
	//入力;
	string s;
	cin >> s;
	if (s[5] == '0' && s[6] - '0' <= 4) cout << "Heisei" << endl;
	else cout << "TBD" << endl;


	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a == c-b)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<ll,ll>
const int N = 3e5+5;

ll n,m,tar,col[N],rows[N],ans;
vector<ll> v[N]; //positions in rows
bool vis[N];
priority_queue< pii > q;

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

    cin >> n >> m >> tar;
    for(int i=1; i<=tar; i++)
    {
        int x,y;
        cin >> x >> y;
        v[x].push_back(y) , col[y]++;
    }

    for(int i=1; i<=m; i++)
    {
        q.push({col[i] , i});
    }

    ll tmp=0;
    for(int i=1; i<=n; i++)
    {
        ans = max(ans , (ll)v[i].size() + q.top().f - 1); //assume that this cell contains target
        vector<int> del;
        for(int j=0; j<(int)v[i].size(); j++)
        {
            vis[v[i][j]] = 1;
        }
        while(q.size() && vis[q.top().s])
        {
            del.push_back(q.top().s);
            q.pop();
        }
        for(int j=0; j<(int)v[i].size(); j++)
        {
            vis[v[i][j]] = 0;
        }

        tmp = (ll)v[i].size();
        if (q.size() > 0) tmp += q.top().f;
        ans = max(ans , tmp);

        for(int j=0; j<(int)del.size(); j++)
        {
            q.push({col[del[j]] , del[j]});
        }
    }

    cout << ans << '\n';


    return 0;
}



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

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int k=sc.nextInt();
		long h[]=new long[n];
		for(int i=0;i<n;i++) {
			h[i]=sc.nextLong();
		}
		Arrays.sort(h);
		long min=h[k-1]-h[0];
		for(int j=1;j<n-k+1;j++) {
			min=Math.min(min,h[j+k-1]-h[j]);
		}
		System.out.println(min);
	}
		
	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			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;
		}

	}
	//--------------------------------------------------------

}





Measured memory_bytes: 38348
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,A = ilint()
A = [0]+A[:]+[0]
B = [abs(A[i+1]-A[i]) for i in range(N+1)]
ans = sum(B)
for i in range(N):
    tmp = ans-B[i]-B[i+1]+abs(A[i+2]-A[i])
    print(tmp)

Measured memory_bytes: 96360
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn;
	cin >> nn;
	string ss, tt;
	cin >> ss >> tt;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cout << ss[ii] << tt[ii];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3632
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[100], b, c, d, tmp, m, h, w, x[100][100], y[100][100], sum, k,
    q;

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

  cin >> n;
  rep(i, n) {
    cin >> a[i];
    rep(j, a[i]) { cin >> x[i][j] >> y[i][j]; }
  }

  for (int bit = 0; bit < (1 << (n)); bit++) {
    ll dat[100] = {};
    cnt = 0;
    rep(i, n) {
      if (bit & (1 << i)) {
        cnt++;
        dat[i] = 1;
      }
    }
    int ok = 0;
    rep(i, n) {
      if (dat[i] == 0) continue;
      rep(j, a[i]) {
        if (dat[x[i][j] - 1] != y[i][j]) ok = 1;
      }
    }
    if (ok) continue;
    ans = max(ans, cnt);
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<P>vec;
int sum[405];
int par[405],ran[405];
void init(){ for(int i=0;i<405;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
int cnt[405],X;
set<int>S;
int main(){
	cin>>n>>m;init();
	rep(i,n){
		int a,b,c,d;cin>>a>>b>>c>>d;
		if(c==0) a+=200; else a=c;
		if(d==0); else b=200+d;
		vec.pb(mp(a,b));//cout<<a<<" "<<b<<endl;
		sum[a]++; sum[b]--; unite(a,b);S.insert(a);S.insert(b);X=a;
	}
	int val = 0,val2 = 0;
	for(int i=1;i<=m;i++){
		if(sum[i]>0){
			puts("NO");return 0;
		}
		else cnt[i] = -1*sum[i];
		val+=cnt[i];
		if(sum[200+i]<0){
			puts("NO");return 0;
		}
		else cnt[200+i] = sum[200+i];
		val2 += cnt[200+i];
	}
	assert(val==val2);
	if(!val){puts("NO");return 0;}
	while(1){
		bool upd = 0;
		{
			repn(i,m)repn(j,m){
				if(cnt[i]>=1&&cnt[j+200]>=1&&!same(i,j+200)){
					unite(i,j+200);cnt[i]--;cnt[j+200]--;upd=1;
				}
			}
		}
		if(!upd) break;
	}
	for(set<int>::iterator it=S.begin();it!=S.end();++it){
		if(!same(*it,X)){
			puts("NO");return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 1412
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_126
{
    class Program
    {

        static void Main(string[] args)
        {

            int[] cntRow = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);     
            string data = Console.ReadLine();

            string ret = "";
            for (int i = 0; i < cntRow[0]; i++)
            {
                string tmp = data[i].ToString();
                if (i + 1 == cntRow[1])
                {
                    tmp = tmp.ToLower(); ;
                }
                ret += tmp;
            }

            Console.WriteLine(ret);

        }

    }
}



Measured memory_bytes: 11092
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}

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

	int A, B;
	cin >> A >> B;
	vector<int> ret;
	map<int, bool>F;
	for (int i = 1; i*i <= A; ++i)
	{
		if (A%i == 0)
		{
			//ret.push_back(i);
			F[i] = true;
			if (i*i != A)
			{
				//ret.push_back(A / i);
				F[A / i] = true;
			}
		}
	}
	for (int i = 1; i*i <= B; ++i)
	{
		if (B%i == 0)
		{
			if(F[i])ret.push_back(i);
			if (i*i != B)
			{
				if(F[B/i])ret.push_back(B / i);
			}
		}
	}
	
	//cout << ret.size() << endl;
	SORT(ret);
	//REP(i, ret.size())cout << ret[i] << " ";
	//cout << endl;
	VI ans;
	ans.push_back(ret[0]);
	FOR(i, 1, ret.size()) {
		bool f = true;
		REP(j, ans.size()) {
			if (gcd(ret[i], ans[j]) != 1)f = false;
		}
		if (f)ans.push_back(ret[i]);
	}
	cout << ans.size() << endl;
	return 0;
}



Measured memory_bytes: 768
"use strict";

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function main(input) {
  var lines = input.split('\n');
  var hs = splitNum(lines[0]).slice(0, 3);
  hs.sort(function (a, b) {
    return a - b;
  });
  console.log(hs[0] * hs[1] / 2);
}

var P = 1e9 + 7;
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return (Array.isArray(line) ? line : line.split(/\s+/)).map(function (n) {
    return parseInt(n);
  });
}
/**
 * Iterates over integers in [start, end).
 */


function* range(start, end) {
  for (var i = start; i < end; i++) {
    yield i;
  }
}
/**
 * Iterates over integers in [end, start) in desc order.
 */


function* rangeRev(start, end) {
  for (var i = start - 1; i >= end; i--) {
    yield i;
  }
}
/**
 * Runs a recursive function expressed as a generator function.
 */


function runRecursive(func) {
  // 最終結果を受け取るオブジェクトを用意
  var rootCaller = {
    lastReturnValue: null
  }; // 自前のコールスタックを用意

  var callStack = []; // 最初の関数呼び出しを追加

  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  callStack.push({
    iterator: func.apply(void 0, args),
    lastReturnValue: null,
    caller: rootCaller
  });

  while (callStack.length > 0) {
    var stackFrame = callStack[callStack.length - 1];
    var iterator = stackFrame.iterator,
        lastReturnValue = stackFrame.lastReturnValue,
        caller = stackFrame.caller; // 関数の実行を再開

    var _iterator$next = iterator.next(lastReturnValue),
        value = _iterator$next.value,
        done = _iterator$next.done;

    if (done) {
      // 関数がreturnしたので親に返り値を記録
      caller.lastReturnValue = value;
      callStack.pop();
    } else {
      // 関数がyieldした（valueは再帰呼び出しの引数リスト）
      callStack.push({
        iterator: func.apply(void 0, _toConsumableArray(value)),
        lastReturnValue: null,
        caller: stackFrame
      });
    }
  }

  return rootCaller.lastReturnValue;
}


Measured memory_bytes: 22076
/*
   Username : moondancer
   Name : Moon Dancer
*/


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

#define int long long

int pw(int a,int b,int p){
    if(b==0)return 1;
    int t=pw(a,b/2,p);
    if(b%2)return (((a*t)%p)*t)%p;
    else return ((t*t)%p);
}

int modInverse(int A,int m)
{
    return pw(A,m-2,m);
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i){
        cin >> a[i];
    }
    int m1=1e9+7;
    int x1=0,x2=0;
    for (int i = 0; i < n; ++i)
    {
        x1=(x1+a[i])%m1;
        x2=(x2+(a[i]*a[i])%m1)%m1;
    }
    x1=(x1*x1)%m1;
    int ans=(x1-x2+m1)%m1;
    cout<<(ans*modInverse(2,m1))%m1;
    return 0;
}

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


int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    ll sum = 0;
    for (ll i = 1; i <= n; ++i) {
        if (i%5==0 || i%3==0) continue;
        sum += i;
    }

    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  if(4 * M * A.at(M - 1) < sum) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
using namespace std;
int main(void) {
    string st, ss;
    cin >> st;
    cin >> ss;
    ss.erase(ss.size() - 1);
    if (st == ss)printf("Yes\n");
    else           printf("No\n");
    return 0;
}

Measured memory_bytes: 3624
def warshalFloyd(v,e):
    inf=float("inf")
    G=[[inf if i!=j else 0 for i in range(v)] for j in range(v)]

    for _ in range(e):
        s,t,d=map(int,input().split())
        G[s][t]=d

    for k in range(v):
        for i in range(v):
            for j in range(v):
                G[i][j]=min(G[i][j],G[i][k]+G[k][j])

    return G


v,e=map(int,input().split())
Graph=warshalFloyd(v,e)

for i in range(v):
    if Graph[i][i]<0:
        print("NEGATIVE CYCLE");exit()

for i in range(v):
    Graph[i]=list(map(str,Graph[i]))
    for j in range(v):
        if Graph[i][j]=="inf":
            Graph[i][j]="INF"

for i in range(v):
    print(*Graph[i])


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

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; } 
};

vector<int> deg(100100);
vector<int> to[100100];

int main() {
    int N, M, K; cin >> N >> M >> K;
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int A, B; cin >> A >> B;
        A--, B--;
        deg[A]++;
        deg[B]++;
        uf.unite(A, B);
    }

    for (int i = 0; i < K; i++) {
        int C, D; cin >> C >> D;
        C--, D--;
        to[C].push_back(D);
        to[D].push_back(C);
    }

    for (int i = 0; i < N; i++) {
        int ans = uf.size(i) - 1 - deg[i];
        for (int j : to[i]) {
            if (uf.same(i, j)) ans--;
        }
        if (i) cout << " ";
        cout << ans;
    }
    cout << endl;
}



Measured memory_bytes: 9060
#include<bits/stdc++.h>
#define mo 924844033ll
using namespace std;
long long a[800010],b[800010],c[800010],ym[800010],fac[200010],nifac[200010];
vector<int> des[200010];
int n;
int getmi(int a,int x)
{
	int ans=1;
	while (x)
	{
		if (x&1) ans=(long long)ans*a%mo;
		a=(long long)a*a%mo;
		x>>=1;
	}
	return ans;
}
long long C(int n,int m)
{
	if ((n<0)||(m<0)||(n<m)) return 0;
	return (long long)fac[n]*nifac[m]%mo*nifac[n-m]%mo;
}
int dfs(int s,int pre=0)
{
	int ans=1;
	for (int k=0;k<des[s].size();k++) if (des[s][k]!=pre) ans+=dfs(des[s][k],s);
	if (pre) {a[ans]++;a[n-ans]++;}
	return ans;
}
void fft(long long a[],int n)
{
	if (n==1) return;
	long long l[n>>1],r[n>>1];
	for (int i=0;i<(n>>1);i++)
	{
		l[i]=a[i<<1];
		r[i]=a[(i<<1)+1];
	}
	fft(l,n>>1);fft(r,n>>1);
	long long wn=ym[n],w=1;
	for (int i=0;i<(n>>1);i++)
	{
		a[i]=(l[i]+w*r[i])%mo;
		a[i+(n>>1)]=(l[i]-w*r[i])%mo;
		w=w*wn%mo;
	}
}
int main()
{
	scanf("%d",&n);
	fac[0]=nifac[0]=1;
	for (int i=1;i<=n;i++)
	{
		fac[i]=(long long)fac[i-1]*i%mo;
		nifac[i]=getmi(fac[i],mo-2);
	}
	if (fac[n]*nifac[n]%mo!=1) assert(0);
	for (int i=1;i<n;i++)
	{
		int u,v;scanf("%d%d",&u,&v);
		des[u].push_back(v);des[v].push_back(u);
	}
	dfs(1);
	for (int i=0;i<=n;i++)
	{
		a[i]=(long long)a[i]*fac[i]%mo;
		c[i]=nifac[n-i];
	}
	//for (int i=0;i<=2*n;i++) cout<<i<<' '<<a[i]<<' '<<c[i]<<endl;
	/*for (int i=0;i<=n;i++)
	for (int j=0;j<=2*n;j++)
		b[i+j]=(b[i+j]+a[i]*c[j])%mo;*/
	//for (int i=0;i<=3*n;i++) cout<<i<<' '<<b[i]<<endl;
	//for (int i=1;i<=n;i++) printf("%lld\n",(mo-b[i+n]*nifac[i]%mo+n*C(n-1,i-1)+n*C(n-1,i))%mo);
	
	int mi=1;while (mi<=2*n+10) mi<<=1;
	for (int i=1;i<=mi;i<<=1) ym[i]=getmi(5,(mo-1)/i);
	fft(a,mi);fft(c,mi);
	for (int i=0;i<mi;i++) a[i]=a[i]*c[i]%mo;
	fft(a,mi);
	for (int i=1;i<(mi>>1);i++) swap(a[i],a[mi-i]);
	int ni=getmi(mi,mo-2);
	for (int i=0;i<mi;i++) a[i]=a[i]*ni%mo;
	for (int i=0;i<mi;i++) a[i]+=mo;
	//for (int i=0;i<=n;i++) cout<<a[i+n]*nifac[i]%mo<<endl;
	for (int i=1;i<=n;i++) printf("%lld\n",(mo-a[i+n]*nifac[i]%mo+n*C(n-1,i-1)+n*C(n-1,i))%mo);
	/*for (int i=1;i<=n;i++)
	{
		int ans=(n*C(n-1,i-1)+n*C(n-1,i))%mo;
		for (int j=0;j<=n;j++)
		{
			ans-=(a[j]+b[j])*C(j,i);
		}
		cout<<(ans%mo+mo)%mo<<endl;
	}*/
}

Measured memory_bytes: 43648
def main():

    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i):
            for k in range(j):
                lv = [L[i], L[j], L[k]]
                lv.sort()
                # print(lv)
                if len(set(lv)) == 3 and lv[2] < lv[1] + lv[0]:
                    ans += 1
    return ans



if __name__ == '__main__':
    print(main())

Measured memory_bytes: 68200
#include<stdio.h>
#include<string.h>
int main()
{
    int a;
    char s[10];
    scanf("%d",&a);
    scanf("%s",s);
    if(a>=3200)
    {
       printf("%s\n",s);;
    }
    else
    {
         printf("red\n");;
    }
   return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    rep(i,n){
        cin >> to[0][i];
        --to[0][i];
    }
    rep(i,59)rep(j,n) to[i+1][j] = to[i][to[i][j]];
    int cur = 0;
    for(int i = 59; i >= 0; --i){
        ll tmp = 1LL << i;
        if(tmp <= k){
            cur = to[i][cur];
            k -= tmp;
        }
    }
    ++cur;
    cout << cur << endl;
	return 0;
}

Measured memory_bytes: 50548
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll maeA[100001], maeB[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	ll N, X, D;
	scanf("%lld %lld %lld", &N, &X, &D);
	if (D == 0) {
		if (X == 0) printf("1");
		else printf("%lld", N + 1);
		return 0;
	}
	if (D < 0) {
		D *= -1;
		X *= -1;
	}

	ll R = (X ? D / __gcd(abs(X), D) : 1);
	ll Z = (X ? X / __gcd(abs(X), D) : 0);
	ll kininaru = max(0ll, min(N + 1 - R, R));

	int r = 0;
	ll a = 0;
	ll b = 0;
	ll kotae = 0;
	rep(i, kininaru) {
		maeA[i] = a;
		maeB[i] = b;
		kotae += b - a + 1;
		a += i;
		b += N - i - 1;
	}
	for (int i = kininaru; i < min(N + 1, R); i++) {
		kotae += b - a + 1;
		a += i;
		b += N - i - 1;
	}
	ll zure = Z;
	for (int i = min(N + 1, R); i <= N; i++) {
		ll A = a + zure;
		ll B = b + zure;
		if (maeA[r] >= A && maeB[r] <= B) {
			kotae += B + maeA[r] - A - maeB[r];
		}
		else if (maeA[r] <= A && maeB[r] >= B) {
			break;
		}
		else if (maeA[r] <= A) {
			kotae += B - max(maeB[r] + 1, A) + 1;
		}
		else {
			kotae += min(maeA[r] - 1, B) - A + 1;
		}
		maeA[r] = A;
		maeB[r] = B;

		a += i;
		b += N - i - 1;
		if (++r >= R) {
			r = 0;
			zure += Z;
		}
	}
	printf("%lld", kotae);

	Would you please return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    auto f = [&](double xx){
        return floor((xx * xx + 4.0) / 8.0);
    };

    cin >> n >> a;
    vector<string> v(n);
    for(auto& x : v)
        cin >> x;
    sort(v.begin(), v.end());
    for(auto& x : v)
        cout << x;
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define sz size()
#define FORN(i,j,n) for(int i=j; i<(int)n;i++) 
#define FOR(i,n) FORN(i,0,n)
#define FORIT(i,x) for( auto i = x.begin() ; i != x.end() ; i++ )
#define MOD 998244353LL
#define LIM 262150
#define ones(x) __builtin_popcount(x)
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
using namespace std;
 
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;
ll n,k;
ll arr[100005];
ll dp[100005];
int main() {
	fastio;
	cin>> n >> k;
	FOR(i,n) cin>> arr[i];
	FOR(i,k+1){
	    FOR(j,n){
			if(i >= arr[j]){
				dp[i] = max(dp[i],1-dp[i-arr[j]]);
			}
		}
	}
	if(dp[k] == 1) cout<< "First\n";
	else cout<< "Second\n";
	return 0;
}

Measured memory_bytes: 4396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b, q, i;
        String str0, str1, str2, cmd, p;
        
        str0 = sc.next();
        str1 = str0;
        q = sc.nextInt();
        
        for(i = 0; i < q; i++) {
        	cmd = sc.next();
        	if(cmd.equals("replace")) {
        		a = sc.nextInt();
        		b = sc.nextInt();
        		p = sc.next();
        		
        		str1 = str0.substring(0, a);
        		str1 = str1.concat(p);
        		str0 = str1.concat(str0.substring(b + 1));
        	} else if (cmd.equals("reverse")) {
        		a = sc.nextInt();
        		b = sc.nextInt();
        		
        		StringBuffer strB = new StringBuffer(str0.substring(a, b+1));
        		str1 = strB.reverse().toString();
        		
        		str2 = str0.substring(0, a);
        		str2 = str2.concat(str1);
        		str2 = str2.concat(str0.substring(b + 1));
        		str0 = str2;
        	} else {
        		a = sc.nextInt();
        		b = sc.nextInt();
        		System.out.println(str0.substring(a, b+1));
        		
        	}
        }
        
    }
}


Measured memory_bytes: 29852
//#define _GLIBCXX_DEBUG
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;

int main() {
    IOS;
    int K;
    cin >> K;
    string ans;
    for (int i=0; i<K; i++) ans += "ACL";
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

int T[200], A[200], B[200], C[200];

int dp[201][200];

signed main()
{
    int D, N; cin >> D >> N;

    rep(i, D) {
        cin >> T[i];
    }

    rep(i, N) {
        cin >> A[i] >> B[i] >> C[i];
    }

    for (int i = 1; i < D; ++i) {
        rep(j, N) {
            if (T[i - 1] < A[j] || T[i - 1] > B[j]) continue;

            rep(k, N) {
                if (T[i] < A[k] || T[i] > B[k]) continue;

                chmax(dp[i][k], dp[i - 1][j] + abs(C[j] - C[k]));
            }
        }
    }

    int ans = 0;

    rep(i, D + 1) rep(j, N) chmax(ans, dp[i][j]);

    cout << ans << endl;
}

Measured memory_bytes: 1476
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
//最大公約数
template<typename T>
constexpr T gcd(T a, T b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

//最小公倍数
template<typename T>
constexpr T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}
int main() {
	string s;
	cin >> s;
	int c = 0;
	for (int i = 0; i < 3; ++i) {
		if (s[i] == 'o') ++c;
	}
	PRI(700 + c * 100);
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

//refering to exp.
int main(){
	string s,t;
	cin>>s>>t;
	
	string ss=s+s;
	
	vvi p(26);
	REP(i,ss.size()) p[ss[i]-'a'].push_back(i+1);
	
	llong ans=0;
	int now_p=0;
	REP(i,t.size()){
		if(p[t[i]-'a'].size()==0){
			cout<<-1<<endl;
			return 0;
		}
		
		auto itr=upper_bound(ALL(p[t[i]-'a']),now_p);
		ans+=*itr-now_p;
		now_p=*itr;
		if(now_p>=ss.size()) now_p=0;
		if(now_p>=s.size()) now_p-=s.size();
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 1980
#include<stdio.h>
#include<string.h>
int main(void)
{	int i;
	char s[4];
	char t[][4]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
	scanf("%s",s);
	
	for(i=0; i<7; i++){
		if(strcmp(s,t[i])==0){
		printf("%d",i+1);
		return 0;
		}
	}
	

	return 0;
	
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll l=0,r=0;
	for(ll i=0;i<k;i++){
		l+=i;
		r+=n-i;
	}
	ll ans=0;
	for(ll i=k;i<=n+1;i++){
		ans+=r-l+1;
	//	cout <<ans<<endl;
		l+=i;
		r+=n-i;
		ans%=inf;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c[200000];
	scanf("%s",c);
	int s=0;
	for(int i=0;i<strlen(c);i++)
	{
		if(c[i]==c[i+1])
		{
		c[i+1]='1'-c[i+1]+'0';
		s++;
		}
	}
	printf("%d",s);
}


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;

    bool a = false;
    bool b = false;
    bool c = false;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'a') {
            a = true;
        }
        if (s[i] == 'b') {
            b = true;
        }
        if (s[i] == 'c') {
            c = true;
        }
    }

    if (a && b && c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include"math.h"
using namespace std;
int main(){
  int N;
  cin >>N;
  vector<double> v(N);
  for(int i=0;i<N;i++){
    cin >> v.at(i);}
  sort(v.begin(),v.end());
  double sum = (v.at(1)+v.at(0))/2;

  for(int i =2; i<N;i++){
    sum=(sum+v.at(i))/2;}
  cout << sum << endl;}
    

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)

	answer := 0
	if a < b {
		answer = answer + a
	} else {
		answer = answer + b
	}
	if c < d {
		answer = answer + c
	} else {
		answer = answer + d
	}

	fmt.Printf("%d\n", answer)
}


Measured memory_bytes: 512
k,t=map(int,input().split())
a=list(map(int,input().split()))
a_m=0
sm =0
for i in range(1,t):
  if a[a_m] < a[i]:
    sm += a[a_m]
    a_m = i
  else:
    sm += a[i]

print(max(0, a[a_m]-sm-1))

Measured memory_bytes: 61888