akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int x; scanf("%d", &x); return x; }
long long lin() { long long x; scanf("%lld", &x); return x; }

signed main() { 
        int n;
        cin >> n;
        string s;
        cin >> s;
        deque<char> ans;
        int cnt = 0;
        rep(i, n) {
                if (s[i] == '(') {
                        cnt ++;
                        ans.push_back('(');
                } else {
                        if (cnt > 0) {
                                ans.push_back(')');
                                cnt --;
                        } else {
                                ans.push_front('(');
                                ans.push_back(')');
                        }
                }
        }
        while (cnt --) {
                ans.push_back(')');
        }
        while (!ans.empty()) {
                cout << ans.front();
                ans.pop_front();
        }
        cout << endl;
        return 0;
}               


Measured memory_bytes: 256
class Task:
    count=0
    def __init__(self,time,deadline):
        Task.count+=1
        self.time=time
        self.deadline=deadline
        self.count=Task.count
    
    def __gt__(self,other):
        if self.deadline<other.deadline:
            return True
        if self.deadline==other.deadline:
            if self.time<other.time:
                return True
            if self.time==other.time:
                if self.count<other.count:
                    return True
        return False
    
    def __lt__(self,other):
        if self.deadline>other.deadline:
            return True
        if self.deadline==other.deadline:
            if self.time>other.time:
                return True
            if self.time==other.time:
                if self.count>other.count:
                    return True
        return False
    

tasklist=[]    
n=int(input())
for i in range(n):
    time,deadline=[int(j) for j in input().split()]
    task=Task(time,deadline)
    tasklist.append(task)
check=0
time=0
tasklist.sort()



while tasklist:
    task=tasklist.pop()
    if task.time+time>task.deadline:
        check+=1
        print("No")
        break
    else:
        time+=task.time
        
if check==0:
    print("Yes")



Measured memory_bytes: 87384
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
int main(){
    long long int a, b, c, k;

    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::cin >> k;

    long long int result=0;

    while(k>0){
        if(a>0){
            result++;
            a--;
        }else if(b>0){
            ;
            b--;
        }else if(c>0){
            result--;
            c--;
        }

        k--;
    }

    std::cout << result << std::endl; 
    //::system("pause");
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[55];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll mx = 0, mn = 0;
    REP(i, N) {
        cin >> A[i];
    }
    REP(i, N) {
        if (A[i] > A[mx])
            mx = i;
        if (A[i] < A[mn])
            mn = i;
    }

    vector<pll> v;
    if (abs(A[mx]) >= abs(A[mn])) {
        v.push_back(pll(mx + 1, 2));
        v.push_back(pll(2, 2));
        v.push_back(pll(2, 2));
        for (ll i = 3; i <= N; ++i) {
            v.push_back(pll(i - 1, i));
            v.push_back(pll(i, i));
        }
    }
    else {
        v.push_back(pll(mn + 1, N - 1));
        v.push_back(pll(N - 1, N - 1));
        v.push_back(pll(N - 1, N - 1));
        for (ll i = N - 2; i > 0; --i) {
            v.push_back(pll(i + 1, i));
            v.push_back(pll(i, i));
        }
    }

    cout << v.size() << endl;
    REP(i, v.size()) {
        cout << v[i].first << " " << v[i].second << endl;
    }
    return 0;
}

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

int main()
{

	int n;
	cin>>n;
	double p[n];
	for (int i = 0; i < n; i++)
	{
		/* code */
		cin>>p[i];
	}
	// for (int i = 0; i < n; i++)
	// {
	// 	/* code */
	// 	cout<<p[i]<<" ";
	// }
	double dp[n+1][n+1];
	for (int i = 0; i < n+1; ++i)
	{
		/* code */
		for (int j = 0; j < n+1; ++j)
		{
			/* code */
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	// dp[row][col]--> row=no. of trials and col=heads
	for(int row=1;row<n+1;row++){
		for (int col = 0; col<=n; col++)
		{
			/* code */
			if(col==0){
				dp[row][col]=(1-p[row-1])*dp[row-1][col];
			}
			else{
				dp[row][col]=(p[row-1]*dp[row-1][col-1])+((1-p[row-1])*dp[row-1][col]);
			}
		}
	}


	double sum=0;
	for(int i=n;i>n/2; i--){
		sum+=dp[n][i];
	}
	cout<<setprecision(10)<<sum;



}


Measured memory_bytes: 70528
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int main() {
  LL n, k;
  cin >> n >> k;
  LL s1, s2;
  s1 = n % k;
  if (s1 == 0) {
    cout << '0' << endl;
  } else {
    s2 = k * ((n / k) + 1) - n;
    cout << min(s1, s2) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,a,b;
  cin >> x >> a >> b;
  int A=x-a,B=x-b;
  if (A<0){
    A*=-1;
  }
  if (B<0){
    B*=-1;
  }
  if (A<B){
    cout << 'A' << endl;
  }
  else {
    cout << 'B' << endl;
  }
}  

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    long long i, N, a[100001], b=0;

    cin >> N;
    
    for(i=1; i<=N; i++){
        cin >> a[i];
        b ^= a[i];
    }

    if(b==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
	int a, b,joint;

	cin >> a >> b;
	if (b == 100)joint = 1000 * a + b;
	else if (b < 10) joint = 10 * a + b;
	else joint = 100 * a + b;
	for (int i = 1; i< sqrt(100100); i++) {
		if (joint == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
N, A = map(int, raw_input().split())
x = map(lambda x: int(x) - A, raw_input().split())
tmp = {}
for xi in x:
    new_tmp = {}
    for k, v in tmp.items():
        new_tmp[k + xi] = v
    new_tmp[xi] = new_tmp.get(xi, 0) + 1
    for k, v in new_tmp.items():
        tmp[k] = tmp.get(k, 0) + v
print tmp.get(0, 0)

Measured memory_bytes: 2820
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct uft {
    uft (int s) : ps {new int[s]}, ds {new int[s]}, s {s} {
        for(int i = 0; i < s; ++i){
            ps[i] = i;
            ds[i] = 0;
        }
    };
    void unite(int x, int y){
        int px = parent(x);
        int py = parent(y);
        if(ds[px] < ds[py]){
            ps[px] = py;
        } else if(ds[px] > ds[py]){
            ps[py] = px;
        } else {
            ps[px] = py;
            ++ds[py];
        }
    };
    int parent(int p){
        return p == ps[p] ? p : ps[p] = parent(ps[p]);
    };
    bool same(int x, int y){
        return parent(x) == parent(y);
    };
    int* ps;
    int* ds;
    int s;
};

struct user {
    user() {};
    user(int i) : id {i}, fs {}, group {-1} {};
    int id;
    vector<int> fs;
    int group;
};

void add_friends(user *us, int x, int y){
    us[x].fs.push_back(y);
    us[y].fs.push_back(x);
}

void dfs(user* us, int id, int g){
    stack<int> ss {};
    ss.push(id);
    while(ss.size()){
        int p = ss.top();
        ss.pop();
        us[p].group = g;
        vector<int> fs = us[p].fs;
        for(auto x : fs){
            if(us[x].group == g){
                continue;
            }
            ss.push(x);
        }
    }
}

void make_group(user* us, int n){
    int g = 0;
    for(int i = 0; i < n; ++i){
        if(us[i].group < 0){
            dfs(us, i, g);
            ++g;
        }
    }
}

int main(){
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    //user us[n];
    auto us = uft(n);
    /*for(int i = 0; i < n; ++i){
        us[i] = user(i);
    }*/
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        us.unite(a, b);
    //    add_friends(us, a, b);
    }
    //make_group(us, n);
    int q;
    cin >> q;
    for(int i = 0; i < q; ++ i){
        int a, b;
        cin >> a >> b;
        //if(us[a].group == us[b].group){
        if(us.same(a, b)){
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}

Measured memory_bytes: 1980
#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 n = s.size();
  string str;
  for (int i = 0; i < (n); ++i){
    if(i%2==0) str += s[i];
  }
  cout << str << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    long long int A,B,X,Y,Num_snack;
    scanf("%lld%lld",&A,&B);
    if(A>B)
    {
        X=A;
    }
    else
    {
        X=B;
    }
    for(;X>=1;X--)
    {
        if(A%X==0&&B%X==0)
        {
            Y=X;
            break;
        }
    }
    Num_snack=(A*B)/Y;
    printf("%lld\n",Num_snack);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,a,c) for(auto it=c.begin()+a;it!=c.end();it++)
#define fr(i,a,n)	for(int i=a;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;


int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
}

bool comp1(pi a, pi b)
{
	if(a.first==b.first)return a.second<b.second;
	else return a.first>b.first;
}

template<typename T> 
istream& operator>>(istream& in, vector<T>& v)
{
	for (T& x : v) in >> x; return in;
}

template<typename T> 
ostream& operator<<(ostream& out, vector<T>& v)
{
	for (T& x : v) out << x<<" "; return out;
}

// template<typename T>
int sum1(vector<int>& v)
{
	int sum=0;
	// for(auto x: v)sum+=x;
	fr(i,0,v.size())sum+=v[i];
	return sum;
}





 void solve()
{
	int n,x,c;
	cin>>n>>x>>c;
	if(n%x==0)cout<<c*(n/x);
	else
	{
		cout<< c*(n/x)+c;
	}

}

signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;	
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> b(n);
    for(int i=0;i<n;i++){
        cin >> b[i];
        b[i]--;
    }

    vector<int> ans(n);
    for(int i=0;i<n;i++){
        int idx_max = -1;
        for(int j=0;j<n-i;j++){
            if(j == b[j])
                idx_max = j;
        }
        if(idx_max == -1){
            cout << -1 << endl;
            return 0;
        }
        else {
            ans[n-i-1] = idx_max;
            // erase b[j]
            for(int j=idx_max;j<n-i-1;j++)
                b[j] = b[j+1];
        }
    }

    for(auto t: ans)
        cout << t + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1<<17;
int n,tp;
bool w[N];
inline void solve(int A,int B,int d) {
    if(d==2) {
	printf("%d %d ",A,B);
	return;
    }
    for(int i=1;i<n;i<<=1)
	if((A&i)!=(B&i)) {
	    int x=A;w[i]=1;
	    for(int j=1;j<n;j<<=1)
		if(!w[j]) {x^=j;break;}
	    solve(A,x,d>>1),solve(x^i,B,d>>1);
	    w[i]=0;break;
	}
}
int main() {
    int A,B,t=1;
    cin>>n>>A>>B,n=1<<n;
    for(int i=1;i<n;i<<=1)
	if((A&i)!=(B&i)) t^=1;
    if(t) return puts("NO"),0;
    puts("YES");
    solve(A,B,n);
    return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n , q ; cin>>n>>q;
    string s; cin>>s;
    int dp[10000000] = {0};
    for(int i = 0 ; i < n; ++i){
        string x = "";
        x += s[i]; x+= s[i + 1];
        dp[i+1] = dp[i] + ((x == "AC")?1 : 0);
    }
    for(;q--;){
        int l , r ; cin>>l>>r;
        cout<<dp[r - 1] - dp[l - 1]<<endl;
    }
}


Measured memory_bytes: 40144
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++){
    p[i] = n - i - 1;
  }
  for (int i = 0; i < m; i++){
    int e;
    cin >> e;
    e--;
    p[e] = n + i;
  }
  vector<pair<int, int>> P(n);
  for (int i = 0; i < n; i++){
    P[i] = make_pair(p[i], i + 1);
  }
  sort(P.rbegin(), P.rend());
  for (int i = 0; i < n; i++){
    cout << P[i].second << endl;
  }
}


Measured memory_bytes: 5212
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

using Graph = vector<vector<int>>;
vector<int> weight;

void dfs(const Graph& G, int v, int p) {
	for (auto nv : G[v]) {
		if (nv == p) continue; // nv が親 p だったらダメ

		weight[nv] += weight[v];

		dfs(G, nv, v); // v は新たに nv の親になります
	}
}

signed main() {

	int N, Q;
	cin >> N >> Q;
	Graph G(N);
	weight.assign(N, 0);

	rep(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, Q) {
		int p, x;
		cin >> p >> x;
		p--;
		weight[p] += x;
	}

	int root = 0;
	dfs(G, root, -1);

	rep(i, N) cout << weight[i] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
#define getdate() (getchar() - '0') * 10 + (getchar() - '0')
int main () {
  int a = getdate(), b = getdate();
  bool afirst = a > 0 && a < 13, bfirst = b > 0 && b < 13;
  printf (afirst && bfirst ? "AMBIGUOUS\n" : (afirst ? "MMYY\n" : (bfirst ? "YYMM\n" : "NA\n")));
  return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val o = inputs(0)
  val e = inputs(1)

  println(solve(o, e))

  private def solve(o: String, e: String): String = {
    val size = e.size
    var result = ""
    (0 until size).foreach { i =>
      result = result + o(i) + e(i)
    }

    if(o.size != e.size) {
      result = result + o(o.size - 1)
    }
    return result
  }
}

Measured memory_bytes: 54856
fun main(args: Array<String>) {
    val n = readInteger()
    val xList = readIntegerList()
    var ans = Int.MAX_VALUE
    for (i in 1..100) {
        var tmp = 0
        for (x in xList) {
            tmp += (x - i) * (x - i)
        }

        ans = Math.min(ans, tmp)
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37908
mod = 10**9 + 7
def solve():
    s = input() + 'S'
    ans = 0
    tmp = 0
    for c in s:
        if c == 'R':
            tmp += 1
        else:
            tmp = 0
        ans = max(ans, tmp)
    print(ans)
t = 1
while t > 0:
    solve()
    t -= 1

Measured memory_bytes: 61700
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


K = int(input()) + 1
sum = 0
for i in range(1, K):
    for j in range(1, K):
        for k in range(1, K):
            sum += gcd(i, j, k)

print(sum)


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<vector<int>> dp(n+5, vector<int>(n+5,0));
	for(int i = n - 1; i >= 0; i--){
		for(int j = n - 1; j >= 0; j--){
			if(s[j] == s[i]){
				dp[i][j] = dp[i+1][j+1] + 1;
			}
		}
	}
	int ans = 0;
	rep(i,n){
		rep(j,n){
			if(i >= j) continue;
			int now = min(dp[i][j],j-i);
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 101444
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        rep(i, a) cout << b;
        cout << endl;
    }
    else{
        rep(i, b) cout << a;
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
#define P pair<int,int>
#define F first
#define S second

using namespace std;

int main(){
  int n,k,x,y,ans=0;
  cin >> n >> k >> x >> y;
  Srep(k){
    ans += x;
    n--;
    if(n == 0){
      cout << ans << endl;
      return 0;
    }
  }
  while(n > 0){
    ans += y;
    n--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        boolean flag = false;
        int p[] = new int[n];
        if(n==0){
            System.out.println(x);
            return;
        }
        for(int i=0;i<n;i++){
            p[i] = sc.nextInt();
        }
        int min = 999;
        int ans = 999;
        for(int i=0;i<=101;i++){
            flag = false;
            for(int j=0;j<n;j++){
                if(i == p[j]){
                    flag = true;
                    break;
                }
            }
            if(flag)continue;
            if(Math.abs(i-x)<min){
                min = Math.abs(i-x);
                ans = i;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 35660
n,t = map(int,input().split())
ct= [list(map(int,input().split())) for _ in range(n)]

cost= 1111
for cti in ct:
  if cti[1]<=t:
    if cti[0] < cost:
      cost=cti[0]

if cost==1111:
  print('TLE')
else:
  print(cost)

Measured memory_bytes: 3060
n = int(input())

m = [[0]*10 for _ in range(0,10)]
for i in range(1,n+1):
  s = str(i)
  a = int(s[0])
  b = int(s[-1])
  m[a][b] += 1

ans = 0
for a in range(1,10):
  for b in range(1,10):
    ans += m[a][b] * m[b][a]

print(ans)

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

int da[100 + 5];
int main(){
    int n, m, q, t;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; ++i){
		cin >> da[i];
		sum = sum + da[i];
    }
    cin >> m;
    for(int i = 0; i < m; ++i){
		cin >> q >> t;
		cout << t - da[q - 1] + sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Data.List
import Control.Monad

main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  input <- replicateM m $ (map read . words) <$> getLine :: IO [[Int]]
  -- input <- map read . words <$> getContents :: IO [Int]
  let connect = concat input
  mapM_ print (map (pred . length) $ group $ sort $ [1..n] ++ connect)

Measured memory_bytes: 1020
import math

n = int(input())
n1 =  str(n)

if n /100 >= 20:
    print("1")
elif n < 100:
    print("0")
elif math.ceil(int(n1[-2] + n1[-1]) / 5) <= math.floor(n / 100):
    print("1")
else:
    print("0")

Measured memory_bytes: 3060
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a__: v) cin>>a__;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a__: v) cin>>a__;
}

template<class N> void resiz(N n) {} // empty
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}


int H1,M1,H2,M2,K;

void input() {
	cin>>H1>>M1>>H2>>M2>>K;
}

void solve() {
	int dist=H2*60+M2-H1*60-M1;
	cout<<dist-K<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
	int a, b, A = 2010, B = 2010;
	for (int i = 0; i < 3; i++){
		cin >> a;
		if (a < A){
			A = a;
		}
	}
	for (int i = 0; i < 2; i++){
		cin >> b;
		if (b < B){
			B = b;
		}
	}
	cout << A + B - 50 << endl;
	return 0;
}


Measured memory_bytes: 3088
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	din(n);
	/*while(t--)
	{

	}*/
	ll ans;
	if(n%1000!=0)ans=(n/1000 + 1)*1000 - n;
	else ans=0;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

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

template <typename T>
void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  string s, t;
  cin >> s >> t;
  string t2 = t.erase(s.size());
  if (s == t2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
 }

	return 0;
}

Measured memory_bytes: 3632
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i).tally
h.default = 0
m.times do
  b, c = gets.split.map(&:to_i)
  h[c] += b
end
ans = 0
cnt = 0
h.sort.reverse.each do |k, v|
  if cnt + v < n
    ans += k * v
    cnt += v
  else
    ans += k * (n - cnt)
    break
  end
end
puts ans

Measured memory_bytes: 34212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

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

    vector<int> t(n), x(n), y(n);

    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    int pt = 0, px = 0, py = 0;

    for (int i = 0; i < n; i++) {
        int dt = t[i] - pt;
        int dx = abs(px - x[i]);
        int dy = abs(py - y[i]);

        if (dt < dx + dy || dt % 2 != (dx + dy) % 2) {
            cout << "No" << endl;
            return 0;
        }

        pt = t[i];
        px = x[i];
        py = y[i];
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
N = int(input())
"""
yとzで残り
"""
memo = {}
from math import sqrt
for x in range(1,int(sqrt(N))+1):
    for y in range(1,int(sqrt(N))+1):
        for z in range(1,int(sqrt(N))+1):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n not in memo:
                memo[n] = 0
            memo[n] += 1

for i in range(1,N+1):
    if i in memo:
        print(memo[i])
    else:
        print(0)

Measured memory_bytes: 72720
N=int(input())
p=list(map(float,input().split()))

DP=[[0]*(N+1) for _ in range(N)]

DP[0][0]=1-p[0]
DP[0][1]=p[0]
for i in range(1,N):
    for j in range(i+2):
        if j==0:
            DP[i][j]=DP[i-1][j]*(1-p[i])
        else:
            DP[i][j]=DP[i-1][j-1]*p[i]+DP[i-1][j]*(1-p[i])
ans=sum(DP[N-1][(N+1)//2:])

print(ans)

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

int main(){
  int N, M;
  cin >> N >> M;
  set<int> st;
  int fail = 0;
  vector<int> f(N+1, 0);
  rep(i, M){
    int a;
    string b;
    cin >> a >> b;
    if(b == "AC" && !(st.count(a))){
      st.insert(a);
      fail += f[a];
    }else{
      if(st.count(a)){
        continue;
      }else{
        f[a]++;
      }
    }
  }
  cout << st.size() << " " << fail << endl;
}


Measured memory_bytes: 5376
N,X=map(int,input().split())
def an(n):
    return 2**(n+1)-1
def bn(n):
    return 2**(n+2)-3
ans=0
while(N+1):
    if X==0:

        print(ans)
        quit()
    if X==bn(N):
        ans+=an(N)
        print(ans)
        quit()
    if X<=(bn(N)-1)/2:
        X-=1
        N-=1
    elif X==(bn(N)-1)/2+1:
        ans+=an(N-1)+1
        print(ans)
        quit()
    else:
        X=X-(bn(N-1)+2)
        ans+=an(N-1)+1
        N-=1
print(ans)



Measured memory_bytes: 38468
n,m,x,y = map(int,input().split())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))

a1.sort()
a2.sort()

left = a1[-1]
right = a2[0]

flag = False
for i in range(x+1,y):
    if i > left and i <= right:
        flag = True

if flag:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3064
#include <iostream>

using namespace std;


int main()
{
    int m[50],d[50];
    int x = 0;
    string Day[7] = {"Thursday", "Friday","Saturday","Sunday","Monday", "Tuesday", "Wednesday"};
    int BanyakHari[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    string ThatDayIs[50];

    do
    {
        int DayinBetween = 0;
        cin >> m[x] >> d[x];
        if((m[x] == 0) && (d[x] == 0))
        {
            break;
        }
        //Check banyak hari antara 1 Januari - Input
        for(int y = 0; y < m[x]-1; y++)
        {
            DayinBetween = DayinBetween + BanyakHari[y];
        }
        DayinBetween = (DayinBetween + d[x] - 1)%7;


        ThatDayIs[x] = Day[DayinBetween];

        x++;
    }
    while(x < 50);

    for(int z = 0; z < x; z++)
    {
        cout << ThatDayIs[z] << endl;
    }


}

Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(' ');
            int[] numbers = new int[3];
            int i = 0;
            foreach(string token in tokens)
            {
                numbers[i] = int.Parse(token);
                i++;
            }


            List<int> list = numbers.ToList();
            list.Sort();

            //Console.WriteLine(list[0] + " " + list[1] + " " + list[2]);
            Console.WriteLine((list[2] - list[1]) + (list[1] - list[0]));

            //Console.ReadKey();
        }
    }
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;
int A[100100];
P BC[100100];

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

    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    for(int i=0;i<M;++i){
        int B, C;
        std::cin >> B >> C;

        BC[i] = std::make_tuple(C, B);
    }

    std::sort(A, A + N);
    std::sort(BC, BC + M);
    std::reverse(BC, BC + M);

    int i = 0, j = 0;
    ll res = 0;

    for(;i<M;++i){
        int C, B;
        std::tie(C, B) = BC[i];

        while(B > 0 && j < N && A[j] < C){
            B -= 1;
            res += C;
            j += 1;
        }
    }

    for(;j<N;++j){
        res += A[j];
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    int sum=0;
    cin>>s>>t;
    for(int i=0;i<s.length();i++ ){
        if(s[i]!=t[i])
        sum+=1;
    }
    cout<<sum<<endl;

    
    
    return 0;
}


Measured memory_bytes: 3856
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string S, T;
    cin>>S>>T;
    ll count=0;
    rep(i, 3){
        if(S[i]==T[i]) count++;
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
require "scanf"
data = scanf("%d %d\n")
line = gets
times = line.split(" ")
sum = 0
times.map! do |time|
  time.to_i
end
data[0].times do |i|
  if i != 0
    time = times[i] - times[(i-1)]
  else
    time = 0
  end
  if time > data[1]
    sum += data[1]
  else
    sum += time
  end
end
sum += data[1]
puts sum

Measured memory_bytes: 13972
#include<bits/stdc++.h>
#define boost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
using namespace std;
void sol(){
  	int h,a;
  	cin >> h >> a;
  	int attack=0;
  		for(int i=0;i<=10000;i++){
  			h-=a;
  			attack++;
  			if(h<=0){
  				break;
  			}
  		}
  		cout << attack;
 	}


int main()
{
	boost;
	sol();
}

Measured memory_bytes: 3552
n = int(input())

strings = [input() for _ in range(n)]

st2 = [[]] * n
for i in range(n):
	st2[i] = sorted(strings[i])
st2.sort()

ans = 0
same = 1
for i in range(1, n):
	if st2[i] == st2[i-1]:
		same += 1
	else:
		ans += int(same * (same-1)//2)
		same = 1

ans += int(same * (same-1)//2)
print(ans)


Measured memory_bytes: 31828
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

bool change_min(ll& a, ll b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

const int N_MAX = 110;
const int V_MAX = 101000;
ll dp[N_MAX][V_MAX];

int main() {
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  ll INF = 1LL << 60;
  for (int i = 0; i < N_MAX; i++) {
    for (int j = 0; j < V_MAX; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int next_total_v = 0; next_total_v < V_MAX; next_total_v++) {
      if (next_total_v - v[i] >= 0) {
        change_min(dp[i + 1][next_total_v], dp[i][next_total_v - v[i]] + w[i]);
      }
      change_min(dp[i + 1][next_total_v], dp[i][next_total_v]);
    }
  }
  ll ans = -INF;
  for (int i = 0; i < V_MAX; i++) {
    if (dp[N][i] <= W) {
      ans = max(ans, (ll)i);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 87040
import static java.lang.System.out;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import java.io.File;
import java.util.List;
import java.util.Scanner;

public class Main extends BaseExe {

    public static void main(String[] args) {
        new Main().exeSysIn();
    }

    @Override
    protected void execute() throws Exception {
        List<Integer> nums = asList(nextLine().split(" ")).stream().map(Integer::parseInt)
                .collect(toList());
        if (nums.get(0) < nums.get(1)) {
            out.println("a < b");
        } else if (nums.get(0) > nums.get(1)) {
            out.println("a > b");
        } else {
            out.println("a == b");
        }
    }
}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) throws Exception {
        this.scan = scan;
        execute();
    }

    protected abstract void execute() throws Exception;

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        inData = nextLine();
        return !inData.isEmpty();
    }

    protected String getInData() throws Exception {
        if (inData.isEmpty())
            throw new Exception("inData is Empty.");
        return inData;
    }
}

Measured memory_bytes: 32356
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-9
# define MOD 1000000000
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=100005;
//Code begin...

LL sum[N];
int main ()
{
    int n;
    scanf("%d",&n);
    FOR(i,1,n) scanf("%lld",sum+i), sum[i]+=sum[i-1];
    int flag=1;
    LL d=0, tmp=0, ans=(LL)1<<60;
    FOR(i,1,n) {
        if (flag) {
            if (sum[i]+d<=0) tmp+=(1-(sum[i]+d)), d+=(1-(sum[i]+d));
        }
        else {
            if (sum[i]+d>=0) tmp+=(sum[i]+d+1), d-=(sum[i]+d+1);
        }
        flag^=1;
    }
    ans=min(ans,tmp);
    flag=0; tmp=0; d=0;
    FOR(i,1,n) {
        if (flag) {
            if (sum[i]+d<=0) tmp+=(1-(sum[i]+d)), d+=(1-(sum[i]+d));
        }
        else {
            if (sum[i]+d>=0) tmp+=(sum[i]+d+1), d-=(sum[i]+d+1);
        }
        flag^=1;
    }
    ans=min(ans,tmp);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

long long int f[200001] = {};

int main() {

  long long int n, m;
  cin >> n >> m;

  bool ans = false;

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

    long long int a, b;
    cin >> a >> b;
    if ( a == 1 ) {
      if ( f[b] == 2 ) ans = true;
      f[b] |= 1;
    }else if ( b == n ) {
      if ( f[a] == 1 ) ans = true;
      f[a] |= 2;
    }

  }

  if ( ans == true ) {
    cout << "POSSIBLE" << endl;
  }else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, cnt, ans;
string s[100005];
int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }
    sort(s, s + n);
    cnt = 1;
    for(int i = 1; i <= n; i++){
        if(s[i] == s[i - 1]){
            cnt++;
        }else{
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }
    cout << ans;
//    for(int i = 0; i < n; i++){
//        cout << s[i] << endl;
//    }
    return 0;
}


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

using namespace std;

int c[6] = {1, 5, 10, 50, 100, 500};

int getNum(int t){
	int res = 0;
	for(int i=5;i>=0;i--){
		res += t/c[i];
		t %= c[i];
	}
	return res;
}

int main(){
	int P, N[6];
	while(cin >> P, P){
		int end = 0;
		for(int i=0;i<6;i++){
			cin >> N[i];
			end += c[i]*N[i];
		}
		int ans = 10000000;
		for(int i=P;i<=end;i++){
			int cur = getNum(i-P);
			int l = i;
			for(int j=5;j>=0;j--){
				int tmp = l/c[j];
				cur += min(N[j], tmp);
				l -= min(N[j], tmp)*c[j];
			}
			if(l != 0) continue;
			ans = min(ans, cur); 
		}
		cout << ans << endl;
	}
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

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

    int sum = 0;
    for(int i=1; i<=(b-a); i++){
        sum+=i;
    }
    cout << sum - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

template <class T>
T pow5(T x) {
  return x*x*x*x*x;
}

// 解けなかった悲しい
// 1 <= A**5 - B**5 <= 10**9 が条件
// X**5 - (X-1)**5 の値の変化を考える
// 例えば X = 200 とすると上式は 8080401001 となり、条件に反する。
// そのためこの問題におけるA, Bの上界の1つは200。下界も-200くらいまで調べればいい。

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

  ll X;
  cin >> X;

  for (ll i = -200; i <= 200; ++i) {
    for (ll j = -200; j <= 200; ++j) {
      ll a = pow5(i);
      ll b = pow5(j);
      if (a - b == X) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;
ll n,k,ans;
int main(){

	ios::sync_with_stdio(0);
	
	cin>>n>>k;
	ans=n%k;
	if(k-ans<ans)ans=k-ans;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0 for i in range(N + 1)]

for a in A:
    B[a] += 1
nums = [b for b in B if b > 0]
nums.sort()
n = len(nums)
print(0 if n<=K else sum(nums[:n - K]))

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

int main() {
	int K, A, B;
	cin >> K;
	cin >> A >> B;
	int ans = 0;
	ans = B / K;
	if (ans * K >= A) {
		cout << "OK";
	}
	else {
		cout << "NG";
	}


	return 0;
}

Measured memory_bytes: 3592
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
n,k=reads()
ls=[]
a=list(reads())#インデックスと場所のさ１ インデックス版の場所のテレポ先
dic={1:0}#keyの場所を何回めに訪れたか
ls=[1]#index回移動した時の場所
loopcount=loopstart=0
for i in range(1,k+1):
  hoge=ls[-1]
  hoge-=1
  if a[hoge] in dic:
    loopcount=i-dic[a[hoge]]
    loopstart=dic[a[hoge]]
    break
  ls.append(a[hoge])
  dic[a[hoge]]=i
else:
  print(ls[-1])
  exit()
k=(k-loopstart)%loopcount
print(ls[k+loopstart])


Measured memory_bytes: 113652
#include <cstdio>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
using namespace std;

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)

typedef long long ll;

ll Sum(ll n) {
    return n*(n+1)/2;
}

int main () {
    string S;
    cin >> S;
    
    vector<pair<ll, char> > v;
    for (int i=0; i<S.size(); i++) {
        char c = S[i];
        int j = i;
        for (; j<S.size(); j++) {
            char c1 = S[j];
            if (c1 != c) {
                break;
            }
        }
        v.push_back({ j-i, c});
        i = j-1;
    }
    ll sum = 0;
    for (int i=0; i<v.size(); i++) {
        pair<ll, char> par0 = v[i];
        if (i < v.size()-1) {
            pair<ll, char> par1 = v[i+1];
            if (par1.second == '>') {
                sum += Sum(max(par0.first, par1.first)) +
                    Sum(min(par0.first, par1.first) - 1);
                i++;
                continue;
            }
        }
        sum += Sum(par0.first);
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 6776
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] b = sc.next().toCharArray();
        for(int i=0;i<b.length;i++){
            if(b[i] == 'A'){
                System.out.print('T');
            }else if(b[i] == 'T'){
                System.out.println('A');
            }else if(b[i] == 'C'){
                System.out.println('G');
            }else{
                System.out.println('C');
            }
        }
        sc.close();
    }
    
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll a;
    cin>>a;
    cout<<a + pow(a,2) + pow(a,3)<<endl;
 
    return 0;
}


Measured memory_bytes: 4308
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
int a,b,c;
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    cin>>a>>b;
    cout<<max(max(a+b,a-b),a*b)<<endl;
    return 0;
}


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

int main(void){
  int N, M;
  cin >> N >> M;
  
  vector<int> mati(N);
  
  for( int i=0 ; i < M ; i++ ){
    int a, b;
    cin >> a >> b;
    mati.at(a-1)++;
    mati.at(b-1)++;
  }
  
  for( int i=0 ; i < N ; i++ ){
    cout << mati.at(i) << endl;
  }
}

Measured memory_bytes: 3596