akhauriyash/Code-Regression huggingface dataset:
using System;
namespace ConsoleApplication4.Properties
{
    public class Class1
    {
        public static void Main()
        {
            
            var a =Console.ReadLine();
            String [] v= a.Split();
            double sum = 0;
            var d = int.Parse(v[0]);
            var n = int.Parse(v[1]);
            if (d>=0&&d<=5)
            {
                sum = 0;
            }else if (d >= 6 && d <= 12)
            {
                sum = n / 2;
            }
            else
            {
                sum = n;
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>

using namespace std;

int main(void){

    int n;
    string str;
    int count = 0;
    int ans = 0;

    cin >> n >> str;

    for(int i = 0;i < n-2;i++){
        if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C') ans++;
    }

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

Measured memory_bytes: 384
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var buf = make([]byte, 0, 100000)

func nextLine() []string {
	line := readLine()
	return strings.Split(line, " ")
}

func readLine() string {
	buf = buf[:0]
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	tmp := nextLine()
	Q, _ := strconv.Atoi(tmp[1])

	//S := readLine()
	foundA := false
	sum := 0
	counter := make([]int, 0, 100000)

	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		for _, char := range l {
			switch char {
			case 'A':
				foundA = true
			case 'C':
				if foundA {
					sum++
				}
				foundA = false
			default:
				foundA = false
			}
			counter = append(counter, sum)
		}
		if !p {
			break
		}
	}

	for i := 0; i < Q; i++ {
		tmp = nextLine()
		l, _ := strconv.Atoi(tmp[0])
		r, _ := strconv.Atoi(tmp[1])
		fmt.Println(counter[r-1] - counter[l-1])
	}

	// resultCh := make(chan int, Q)
	// for i := 0; i < Q; i++ {
	// 	go func() {
	// 		tmp = nextLine()
	// 		l, _ := strconv.Atoi(tmp[0])
	// 		r, _ := strconv.Atoi(tmp[1])
	// 		resultCh <- counter[r-1] - counter[l-1]
	// 	}()
	// }
	// for i := 0; i < Q; i++ {
	// 	select {
	// 	case msg := <-resultCh:
	// 		fmt.Println(msg)
	// 	}
	// }
}

Measured memory_bytes: 6016
#include<cstdio>
#include<algorithm>
using namespace std;
 
const int INF = 2147483647;
 
int n,q,_n;
int data[262143];
 
void init(int n){
  _n = 1;
  while(_n<n){
    _n *= 2;
  }
  fill(data,data+2*_n-1,INF);
}
 //_n=2
void update(int i,int x){
  i += _n-1;
  data[i] = x;
  while(i>0){
    i = (i-1)/2;
    data[i] = min(data[2*i+1],data[2*i+2]);
  }
}
 //1 0 0 0 2
//1 0 2 1 2
//vl=INF
//vr=
//1 0 6 1 2
int query(int a,int b,int k,int l,int r){
  if(a<=l&&r<=b+1) return data[k];
  else if(b<l||a>=r) return INF;
  else{
    int vl = query(a,b,2*k+1,l,(l+r)/2);
    int vr = query(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
}
 
int main(){
  scanf("%d %d",&n,&q);
  init(n);
  for(int i=0;i<q;i++){
    int cmd,a,b;
    scanf("%d%d%d",&cmd,&a,&b);
    if(cmd==0) update(a,b);
    else if(cmd==1) printf("%d\n",query(a,b,0,0,_n));
  }
  return 0;
}

Measured memory_bytes: 3640
N=int(input())

C=[1]
for i in range(1,100):
    if 6**i<=100000:
        C.append(6**i)
    else:
        break
    
for i in range(1,100):
    if 9**i<=100000:
        C.append(9**i)
    else:
        break

dp=[10**6 for i in range(N+1)]
dp[0]=0
for i in C:
    for j in range(1,len(dp)):
        if j-i>=0:
            dp[j]=min(dp[j],dp[j-i]+1)
print(dp[N])

Measured memory_bytes: 44912
#include <stdio.h>

#define N 100

struct pair{
	int n;
	char m;
};

int main(){
	int n,i;
	struct pair card[N];
	char space;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%c%d%c",&card[i].m,&card[i].n,&space);
	}
	struct pair bubble[N],sel[N];
	///////////////bubble//////////////////
	for(i=0;i<n;i++){
		bubble[i] = card[i];
	}
	int j;
	struct pair tmp;
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(bubble[j].n < bubble[j-1].n){
				tmp=bubble[j];
				bubble[j] = bubble[j-1];
				bubble[j-1] = tmp;
			}
		}
	}
	////////////////selection///////
	int minj;
	for(i=0;i<n;i++){
		sel[i] = card[i];
	}
	for(i = 0;i < n -1; i++){
		minj = i;
		for(j = i+1; j< n;j ++){
			if(sel[j].n < sel[minj].n){
				minj = j;
			}
		}
		if(minj != i){
			tmp = sel[minj];
			sel[minj] = sel[i];
			sel[i] = tmp;
		}
	}
	for(i=0;i<n-1;i++){
		printf("%c%d ",bubble[i].m,bubble[i].n);
	}
	printf("%c%d\nStable\n",bubble[i].m,bubble[i].n);
	int flag=0;
	for(i=0;i<n-1;i++){
		if(sel[i].m != bubble[i].m) flag = 1;
		printf("%c%d ",sel[i].m,sel[i].n);
	}
	if(flag)printf("%c%d\nNot stable\n",sel[i].m,sel[i].n);
	else{printf("%c%d\nStable\n",sel[i].m,sel[i].n);}
	return 0;
}

Measured memory_bytes: 2744
/*input
4 11
11 3 7 15
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n>>k;
	for(int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+n);
	if(k>a[n-1]) return cout<<"IMPOSSIBLE",0;
	long long g=0;
	for(int i=0;i<n;++i) g=__gcd(g,a[i]);
	for(int i=0;i<n;++i)
		if((a[i]-k)%g==0) return cout<<"POSSIBLE",0;
	return cout<<"IMPOSSIBLE",0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
//#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main(){
    string a,b;
    cin >> a >> b;
    int c = stoi(a+b);

    for(int i=0; i<1000; i++){
        if(i*i == c){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
/*input
4 5
3 2 4 1
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int N = 200005;
vector < int > v[N];
bool visited[N];

int cycle = 0, cnt = 0;
int src = 0;
int get_len(int s)
{
	src = s;
	int x = s;
	int cnt = 0;
	do {
		cnt ++;
		for(auto y: v[x]) {
			x = y;
			break;
		}
	} while(x != s);
	return cnt;
}

void dfs(int s)
{
	visited[s] = 1;
	cnt ++;
	for(auto x: v[s]) {
		if(visited[x]) {
			cycle = get_len(x);
			return;
		} else {
			dfs(x);
		}
	}
}

int main()
{
  ll n, k;
  cin >> n >> k;

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

  dfs(1);

  int s = 1;
  while(s != src) {
  	for(auto y: v[s]) {
			s = y;
			break;
		}
  	k --;
  	if(k ==0) break;
  }

  k %= cycle;
  while(k > 0) {
  	for(auto y: v[s]) {
			s = y;
			break;
		}
  	k --;
  }
  cout << s;
  return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans;
    if (a > c)
    {
        if (b > d)
        {
            ans = d - a;
        }
        else
        {
            ans = b - a;
        }
    }
    else
    {
        if (b > d)
        {
            ans = d - c;
        }
        else
        {
            ans = b - c;
        }
    }
    cout << max(ans, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 
const int MAXN = 1e6 + 10;
const int MOD = 10000000;
const int INF = 10000000;
 
int c; 

int main(){
	int n,m;
	cin>>n>>m;
	int x[n+1];
	int vis[n+1];
	memset(vis,1,sizeof(vis));
	for(int i=1;i<=n;i++){
		cin>>x[i];
	}
	int a[m+1],b[m+1];
	for(int i=1;i<=m;i++){
		cin>>a[i]>>b[i];
		int aa =x[a[i]],bb = x[b[i]];
		if(aa > bb){
			vis[b[i]]=0;
		}
		else if(aa < bb)vis[a[i]]=0; 
		else {
			vis[b[i]]=0;
			vis[a[i]]=0;
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(vis[i])ans++;
	}
	cout<<ans<<endl;
	
	
	
	return 0;
}

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

int main(){
  
  int n;
  cin>>n;
  int v[n];
  pair<int,int> P[100100],Q[100100];
  for(int i=0;i<100100;i++) {
    P[i].first=0;
    P[i].second=i;
    Q[i].first=0;
    Q[i].second=i;
  }
  for(int i=0;i<n;i++) {
    cin>>v[i];
    if(i%2==0){
    	P[v[i]].first++;
        P[v[i]].second=v[i];
    }
    else {
      Q[v[i]].first++;
      Q[v[i]].second=v[i];
    }
  }
  sort(P,P+100100);
  reverse(P,P+100100);
  sort(Q,Q+100100);
  reverse(Q,Q+100100);
  int ans;
  if(P[0].second==Q[0].second){
    ans=n/2-P[0].first+n/2-max(P[1].first,Q[1].first);
  }
  else ans=n-P[0].first-Q[0].first;
  cout<<ans<<endl;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> ans(N,0);
	
	for(int i=0;i<M;i++){
		int a,b;
		cin >> a >> b;
		ans[a-1]++;
		ans[b-1]++;
	}
	for(int i=0;i<N;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e8;
int main()
{
	int n;
	cin >> n;
	vector<int>x(n);
	rep(i, n) cin >> x[i];
	ll ans = Max;
	rep(i, 101) {
		ll sum = 0;
		rep(j, n) {
			sum += (i - x[j]) * (i - x[j]);
		}
		ans = min(ans, sum);
	}
	cout << ans;
}


Measured memory_bytes: 3596
import scala.io.StdIn.{readLine,readInt}

object Main {

  def add(s:String,t:String):String = {
    val (x,y) = if(s.length>t.length) (s,t) else (t,s)
    val r = new StringBuilder
    var carryOver = 0
    var (i,j) = (x.length-1,y.length-1)

    for(k <- j to 0 by -1) {
      val z = x(i).asDigit+y(k).asDigit+carryOver
      r.insert(0,z%10)
      carryOver = z/10
      i -= 1
    }

    for( k <- i to 0 by -1){
      val z = x(k).asDigit + carryOver
      r.insert(0,z%10)
      carryOver = z/10
    }

    if(carryOver>0) r.insert(0,"1")
    r.result
  }

  def main(args:Array[String]) = {
    val n = readInt
    for(i<-1 to n) {
      val s = readLine
      val t = readLine
      if(s.length > 80 || t.length > 80) println("overflow")
      else {
        val result = add(s,t)
        if(result.length > 80) println("overflow") else println(result)
      }
    }
  }
}

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

int main(){
  int n, count, maxcount;
  cin >> n;
  count = 0;
  maxcount = 50;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    for(; a % 2 == 0; a /= 2){
      count++;
    }
    if(maxcount > count){
      maxcount = count;
    }
    count = 0;
  }
  cout << maxcount <<endl;
}
    


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

import sys

def merge(A, left, mid, right):
    global count
    n1 = mid-left
    n2 = right-mid
    L = [0]*(n1+1)
    R = [0]*(n2+1)
    for i in range(n1):
        L[i] = A[left+i]
    for i in range(n2):
        R[i] = A[mid+i]
    L[n1] = R[n2] = sys.maxint
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            count += n1-i

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left+right)/2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(raw_input())
S = map(int, raw_input().split())
count = 0
mergeSort(S, 0, n)
print count

Measured memory_bytes: 23616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int x,y,z,k;
ll temp;
vector<ll> a,b,c;
priority_queue<ll> ab,abc;


int main(){
    cin >> x >> y >> z >> k;
    for(int i = 0; i < x; ++i){ cin >> temp; a.push_back(temp);}
    for(int i = 0; i < y; ++i){ cin >> temp; b.push_back(temp);}
    for(int j = 0; j < z; ++j){ cin >> temp; c.push_back(temp);}
    
    for(int i = 0; i < x; ++i){
        for(int j = 0; j < y; ++j){
            ab.push(a[i] + b[j]);
        }
    }

    
    for(int i = 0; i < k && !ab.empty(); ++i){
        ll temp = ab.top();
        ab.pop();
        for(int j = 0; j < z; ++j){
            abc.push(c[j]+temp);
        }
    }
    
    for(int i = 0; i < k; ++i){
        ll ans = abc.top();
        cout << ans << '\n';
        abc.pop();
    }
}



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)



int main(){
	int M,N; cin >> N >> M;
	int ans = 0;
	for(int i = 1 ; i*i <= M ; ++i){
		if(M%i) continue;
		if(M/i >= N) ans = max(ans,i);
		if(i >= N) ans = max(ans,M/i);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int R, C, K;
  cin >> R >> C >> K;
  vector<vector<int64_t>> field(R, vector<int64_t> (C, 0));
  for(int i = 0; i < K; i++) {
    int r, c;
    int64_t v;
    cin >> r >> c >> v;
    field.at(r - 1).at(c - 1) = v;
  }
  // dp.at(i).at(j).at(k) i行j列にいてi行でk個拾った状態での最大値
  vector<vector<vector<int64_t>>> dp(R, vector<vector<int64_t>> (C, vector<int64_t> (4, 0)));
  for(int i = 0; i < R; i++) {
    for(int j = 0; j < C; j++) {
      if(i == 0 && j == 0) {
        dp.at(i).at(j).at(1) = field.at(i).at(j);
      }
      if(j > 0) {
        // ここのifいらないかも
        if(field.at(i).at(j) == 0) {
          for(int k = 0; k < 4; k++) {
            dp.at(i).at(j).at(k) = dp.at(i).at(j - 1).at(k);
          }
        }
        else {
          dp.at(i).at(j).at(0) = dp.at(i).at(j - 1).at(0);
          for(int k = 1; k < 4; k++) {
            dp.at(i).at(j).at(k) = max(dp.at(i).at(j - 1).at(k - 1) + field.at(i).at(j), dp.at(i).at(j - 1).at(k));
          }
        }
      }
      if(i > 0) {
        for(int k = 0; k < 4; k++) {
          dp.at(i).at(j).at(0) = max(dp.at(i).at(j).at(0), dp.at(i - 1).at(j).at(k));
        }  
        if(field.at(i).at(j) != 0) {
          for(int k = 0; k < 4; k++) {
            dp.at(i).at(j).at(1) = max(dp.at(i).at(j).at(1), dp.at(i - 1).at(j).at(k) + field.at(i).at(j));
          }
        }
      }
    }
  }
  int64_t ans = dp.at(R - 1).at(C - 1).at(0);
  for(int k = 1; k < 4; k++) {
    ans = max(ans, dp.at(R- 1).at(C - 1).at(k));
  }
  cout << ans << endl;    
}


Measured memory_bytes: 706760
N = int(input())
t = [0] * (N + 1)
x = [0] * (N + 1)
y = [0] * (N + 1)
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())

for i in range(N):
    dt = t[i + 1] - t[i]
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dt < dist:
        print("No")
        exit(0)

    if dist % 2 != dt % 2:
        print("No")
        exit(0)

print("Yes")

Measured memory_bytes: 11636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Miguel Mini
 */

#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define trav(v, x) for (auto v : x)
#define re(x, y, z) for (int x=y; x<z; ++x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int cnt[300];

class D {
public:
    int testNumber = 0;
	void solve(istream& in, ostream& out) {
        //out << "Case #" << ++testNumber << ": ";
        int n;
        in >> n;
        string s;
        in >> s;
       // out << s.size() << endl;
        for (auto c : s) cnt[c] += 1;
        long long ans = 1ll* cnt['R'] * cnt['G'] * cnt['B'];
        //out << cnt['R'] << " " << cnt['G'] << " " << cnt['B'] << endl;
        for (int i = 0; i < n; ++i) {
            for (int j = 1; j < n; ++j) {
                if (i - j < 0) break;
                if (i + j >= n) break;
                if (s[i] != s[i-j] and s[i] != s[i+j] and s[i+j] != s[i-j]) {
                    ans -= 1;
                }
            }
        }
        out << ans << endl;
	}
};

int main() {
	D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
  

  
int a[100000]={0};
 int find(int N){
    if(N==a[N])
    return N;
    return a[N] = find(a[N]);
}
  
int Conect(int x,int y){
    if(find(x)==find(y))
    return 1;
    else return 0;
}
  
void Component(int x,int y){
    x=find(x);
    y=find(y);
      
    if(x==y)return ;
     
    else a[y]=x;
}
 
 int main(void){
  int i,n,m,q,s,t;
  for(i=0;i<100000;i++){
     a[i] = i;
  }
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d%d",&s,&t);
       Component(s,t);
    }
    scanf("%d",&q);
    for(i=0; i<q;i++){
        scanf("%d%d",&s,&t);
        if(Conect(s,t)==1) 
        printf("yes\n");
        else 
        printf("no\n");
    }
    return 0;
}
 

Measured memory_bytes: 2076
#include <iostream>

using namespace std;

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

    bool ok = true;
    for (int i = 0; i < str.size();) {
        if (str[i] == 'h' && str[i + 1] == 'i') {
            i += 2;
        } else {
            ok = false;
            break;
        }
    }

    cout << (ok ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int n;
vector<int> a, b;

int main(void) {
	cin >> n;
	for (int i = 0; i < n-1; i++) {
		int bi;
		cin >> bi;
		b.push_back(bi);
	}
	a.push_back(b[0]);
	for (int i = 1; i < n - 1; i++) {
		a.push_back(min(b[i - 1], b[i]));
	}
	a.push_back(b.back());
	cout << accumulate(a.begin(), a.end(), 0) << endl;
	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int i, j, n, d[N], f[N], color[N], time, G[N][N] = {};

void visit(int u){

  int v;
  
  color[u] = 1;
  d[u] = ++time;
  for(v = 0 ; v < n ; v++){
    if(G[u][v] != 0){
      if(color[v] == 0){
	visit(v);
      }
    }
  }
  color[u] = 2;
  f[u] = ++time;
}

void dfs(){
  
  for(i = 0 ; i < n ; i++){
    color[i] = 0;
  }
  time = 0;
  
  for(i = 0 ; i < n ; i++){
    if(color[i] == 0){
      visit(i);
    }
  }
}

int main(){

  int a, k, u;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    scanf("%d%d", &u, &k);
    for(j = 0 ; j < k ; j++){
      scanf("%d", &a);
      G[u-1][a-1] = 1;
    }
  }

  dfs();
  
  for(i = 0 ; i < n ; i++){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define ll long long
#define endl "\n"
#define ar array
#define deb(x) cout << #x << " = " << x << endl
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

template <class T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
inline ll add(ll a, ll b) { return ((a % mod) + (b % mod)) % mod; }
inline ll sub(ll a, ll b) { return ((a % mod) - (b % mod) + mod) % mod; }
inline ll mul(ll a, ll b) { return ((a % mod) * (b % mod)) % mod; }
struct comp
{
    bool operator()(const pair<ll, ll> &x, const pair<ll, ll> &y) const
    {
        return x.first < y.first;
    }
};
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll pwr(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n & 1)
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    else
        return pwr(mul(x, x), n / 2);
}
ll modInv(ll n)
{
    return pwr(n, mod - 2);
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }

    if (x < 0)
        x += m0;

    return x;
}
ll a[4000];
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        string s, t;
        cin >> s >> t;
        int ans = INT_MAX;
        for (int i = 0; i < s.size(); i++)
        {
            int p = 0, count = 0;
            for (int j = i; j < s.size() && p < t.size(); j++)
            {
                if (s[j] != t[p])
                    count++;
                p++;
            }
          // cout << "i " << i << " count " << count << " p " << p << endl;
            if (p == t.size())
                ans = min(ans, count + (int)t.size() - p);
        }
        cout << ans << endl;
    }
}

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

int main() {
  int r,g,b,k;
  cin >> r >> g >> b >> k;
  
  for(int i=0;i<k;i++){
    if(r >= g){
      g *= 2;
    }else if(g >= b){
      b *= 2;
    }
  }
  
  if(r < g && g < b){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
      
  return(0);
}

Measured memory_bytes: 3644
N,K = (int(num) for num in input().split())
S = input()
pos_10 = []
chgpos = []
if S[0] == "0":
    chgpos.append((0,0))
cur = "0"
a,b = 0,0
for i in range(N):
    if cur=="0" and S[i]=="1":
        a = i
        cur = "1"
    if cur=="1" and S[i]=="0":
        b = i
        cur = "0"
        chgpos.append((a,b))
if S[-1] == "1":
    chgpos.append((a,N))
if S[-1] == "0":
    chgpos.append((N,N))
    
l = len(chgpos)
if K>l-1:
    print(N)
else:
    ans = 0
    for i in range(l-K):
        if chgpos[i+K][1] - chgpos[i][0] > ans:
            ans = chgpos[i+K][1] - chgpos[i][0]
    print(ans)

Measured memory_bytes: 43120
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  string s;
  cin >> s;
  REP(i,3){
    if(s[i]=='1') s[i] = '9';
    else if(s[i]=='9') s[i] = '1';
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    int n,k;
    cin>>n>>k;
    map < int , int > M;
    vi s;
    while (n --)
    {
        int v;
        cin>>v;
        ++M[v];
    }
    for (auto it : M)
        s.pb(it.se);
    sort(all(s));
    s.resize(max(0,(int)(s.size()) - k));
    cout << (accumulate(all(s),0)) << '\n';
    return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define CEIL(a, b) ((a) + (b)-1) / (b)

ll N;
vi C, S, F;

int main()
{
    cin >> N;
    C = vi(N - 1);
    S = vi(N - 1);
    F = vi(N - 1);
    REP(i, N - 1)
    {
        cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N)
    {
        ll ans = 0;
        if (i < N - 1)
        {
            ans = 0;
            for (ll j = i; j < N - 1; ++j)
            {
                ans = S[j] + CEIL(max(0LL, ans - S[j]), F[j]) * F[j] + C[j];
            }
        }
        OUT(ans);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll>
#define INF 1123456789012
using namespace std;



int main(){
	ll a, b, c; cin >> a >> b >> c;
	if (c >= a && c <= b) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
/************************************************
*Author        :  lrj124
*Created Time  :  2018.12.02.19:10
*Mail          :  1584634848@qq.com
*Problem       :  a
************************************************/
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x;
	scanf("%d",&x);
	if (x == 3  || x == 5 || x == 7) printf("YES");
	else printf("NO");
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

if __name__ == '__main__':
    s = raw_input()
    q = int(raw_input())

    for _ in range(q):
        op = raw_input().split()
        a, b = map(int, op[1:3])
        p = ''.join(op[3:])
        op = op[0]

        if op == 'print':
            print s[a:b+1]
        elif op == 'reverse':
            s = s[:a] + s[a:b+1][::-1] + s[b+1:]
        elif op == 'replace':
            s = s[:a] + p + s[b+1:]


Measured memory_bytes: 4668
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
using namespace __gnu_pbds; 
#define mod 998244353 
#define int long long
#define ll long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000005
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define PI M_PI
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, 
         tree_order_statistics_node_update> pbds;
int add(int a, int b) {a=(a%mod + b%mod)%mod;return a;}
int sub(int a, int b) {a =(a%mod - b%mod + mod)%mod ;return a;}
int mul(int a, int b) {return (a%mod * b%mod) % mod;}


void solve()
{  
   int a;
   cin >> a;
   cout << a + a*a + a*a*a;
}

signed main()
{ 
    boost
    int test=0,t;
    //cin >> t ;
    t=1;
   while(test++ <t){
	  //cout<<"Case #"<<test<<": ";
	   solve();}
  
}

Measured memory_bytes: 3632
N=int(input())
*A1,=map(int,input().split())
*A2,=map(int,input().split())

ans=[0]*N
i=0
while i<N:
    ans[i]+=sum(A1[:i+1])
    ans[i]+=sum(A2[i:])
    i+=1

print(max(ans))

Measured memory_bytes: 3060
# 2019-11-12 21:58:02(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    a, b, c = [int(x) for x in sys.stdin.readline().split()]
    if b >= a * c:
        ans = c
    else:
        ans = b // a
    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    string s;
    cin >> s;
    const int inf = 1 << 30;
    int n = s.size();
    vector<int> dp_1(n+1, -inf), dp_2(n+1, -inf);
    dp_1.at(0) = 0, dp_2.at(0) = 0;
    for (int i = 1; i < n+1; ++i) {
        dp_1.at(i) = dp_2.at(i-1) + 1;
        if (2 <= i && s.at(i-2) != s.at(i-1)) {
            dp_1.at(i) = max(dp_1.at(i), dp_1.at(i-1) + 1);
        }
        if ( 2 <= i) {
            dp_2.at(i) = dp_1.at(i-2) + 1;
            if (4 <= i && (s.at(i-4) != s.at(i-2) || s.at(i-3) != s.at(i-1))) {
                dp_2.at(i) = max(dp_2.at(i), dp_2.at(i-2) + 1);
            }
        }
    }
    cout << max(dp_1.at(n), dp_2.at(n)) << endl;
    return 0;
}

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

const int N = 10000;

class DisjointSet {
  int parent[N], rank[N];
  
public:
  // initialize
  DisjointSet(int n) {
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }
  
  void make_set(int x) {
    rank[x] = 0;
    parent[x] = x;
  }

  int find(int x) {
    if (x != parent[x]) parent[x] = find(parent[x]);
    return parent[x];
  }

  void unite(int x, int y) {
    int root_x = find(x), root_y = find(y);
    if (rank[root_x] > rank[root_y]) {
      parent[root_y] = root_x;
    } else if (rank[root_x] < rank[root_y]) {
      parent[root_x] = root_y;
    } else {
      parent[root_x] = root_y;
      root_y++;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int i, n, q, com, x, y;

  cin >> n >> q;

  DisjointSet ds(n);

  for (i = 0; i < q; i++) {
    cin >> com >> x >> y;
    if (com) {
      // same
      cout << ds.same(x, y) << endl;
    } else {
      // unite
      ds.unite(x, y);
    }
  }
    
  return 0;
}



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

using namespace std;

#define forn(i,n) for (int i = 0; i < int(n); i++)
#define ford(i,n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i,l,r) for (int i = int(l); i < int(r); i++)
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define x first
#define y second

template<typename X> inline X abs(const X& a) { return a < 0 ? -a : a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

typedef __int128 li;
typedef long long oli;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9;
const ld PI = acosl(ld(-1));

mt19937 mt(time(NULL));

const int N = 1000 + 13;
int n;
pt a[N];

inline bool read()
{
	if (scanf ("%d", &n) != 1)
		return false;
		
	forn (i, n)
		assert(scanf ("%d%d", &a[i].x, &a[i].y) == 2);

	return true;
}

inline void solve()
{
	li x = 1, y = 1;
	forn (i, n)
	{
		while (a[i].x * y % a[i].y != 0)
			y++;
			
		if (x > a[i].x * y / a[i].y)
		{
			li need = (x - a[i].x * y / a[i].y);
			need = (need + a[i].x - 1) / a[i].x;
			y += need * a[i].y;
		}
		
		x = max(x, a[i].x * y / a[i].y);
		
		//cerr << x << ' ' << y << endl;
		//cerr << x * a[i].y << ' ' << y * a[i].x << endl;
		assert(x * a[i].y == y * a[i].x);		
	}
	
	cout << oli(x + y) << endl;
	
	/*x = 1, y = 1;
	forn (i, n)
	{
		while (a[i].y * x % a[i].x != 0)
			x++;
			
		y = max(y, a[i].y * x / a[i].x);
		
		cerr << x << ' ' << y << endl;
	}
	
	cout << x + y << endl;*/
}

int main()
{
#ifdef SU2_PROJ
	assert(freopen("input.txt", "r", stdin));
	assert(freopen("output.txt", "w", stdout));
#endif

	cout << setprecision(25) << fixed;
	cerr << setprecision(10) << fixed;

	assert(read());
	solve();

#ifdef SU2_PROJ
	cerr << "TIME: " << clock() << endl;
#endif

	return 0;
}


Measured memory_bytes: 384
//https://atcoder.jp/contests/abc116/tasks/abc116_d
//D - Various Sushi
//参考 http://drken1215.hatenablog.com/entry/2019/05/15/002400

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

const llong inf = 1ll<<40;
llong N, K;
vector<vector<llong>> sushi;

int main() {
    cin >> N >> K; sushi.resize(N);
    for (int i = 0; i < N; i++) {
        llong t, d;
        scanf("%Ld%Ld", &t, &d);
        t--;
        sushi[t].push_back(d);
    }
    for (auto &v : sushi) {
        sort(v.begin(), v.end(), greater<llong>());
        if (v.size() == 0) v.push_back(-inf);
    }

    sort(sushi.begin(), sushi.end(), [&](vector<llong> a, vector<llong> b){return a[0] > b[0];});

    //最大種類
    llong cur = 0;
    priority_queue<llong> que;
    for (int i = 0; i < K; ++i) {
        cur += sushi[i][0];
        for (int j = 1; j < sushi[i].size(); ++j) que.push(sushi[i][j]);
    }
    for (int i = K; i < N; i++) for (int j = 0; j < sushi[i].size(); ++j) que.push(sushi[i][j]);

    //やる
    llong res = cur + K*K;
    for (llong x = K-1; x >= 1; x--) {
        llong v = sushi[x][0];
        llong w = que.top();
        if (v < w) {
            que.pop(); cur += w;
            que.push(v); cur -= v;
        }
        res = max(res, cur + x*x);
    }
    cout << res << endl;
    return 0;
} 


Measured memory_bytes: 8696
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	m, _ := strconv.Atoi(s[5:7])
	d, _ := strconv.Atoi(s[9:10])

	if v := 100*m + d; v <= 430 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
    //  static int dx[]={1,-1,0,0};
    //  static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1}; 

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

//  int n=sc.nextInt();  
  // int n=sc.nextInt(), k=sc.nextInt();  
  // int s=sc.nextInt(), t=sc.nextInt(); 
        char a[] = sc.nextString().toCharArray();
        char b[] = sc.nextString().toCharArray();
        char c[] = sc.nextString().toCharArray();

        if( a[a.length - 1] == b[0] && b[b.length - 1] == c[0])out.println("YES");
        else out.print("NO");
        
    out.println();
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}







class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 22996
def main():
    A, B, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    ans = min(A) + min(B)
    for i in range(M):
        x, y, c = (int(i) for i in input().split())
        cur = A[x-1] + B[y-1] - c
        ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68180
#include<map>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=100005;
int f[15][5]={
	{-1,-1},{-1,0},{-1,1},
	{0,-1},{0,0},{0,1},
	{1,-1},{1,0},{1,1}
};
long long h,w;int n;
int ma1,mb1,ma2,mb2;
long long ans[15];
struct node{
	int x,y;
}s[MAXN];

map<pair<int,int>,int>T;
void check(int x,int y){
	for(int i=0;i<9;i++){
		int w1=x+f[i][0];
		int w2=y+f[i][1];
		if(w1>1&&w2>1&&w1<h&&w2<w){
			ans[T[make_pair(w1,w2)]]--;
			ans[++T[make_pair(w1,w2)]]++;
		}
	}
}
int main(){
	scanf("%lld%lld%d",&h,&w,&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&s[i].x,&s[i].y);
	ans[0]=(h-2)*(w-2);
	for(int i=1;i<=n;i++)
		check(s[i].x,s[i].y);
	for(int j=0;j<=9;j++)
		printf("%lld\n",ans[j]);
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INFLL=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

vector<pair<int,int>> graph[100000];

pair<int,int> dfs(int v,int p){
    pair<int,int> res(v,0);
    for(auto &e:graph[v]){
        if(e.first==p) continue;
        
        auto tmp=dfs(e.first,v);
        tmp.second+=e.second;
        if(res.second<tmp.second) res=tmp;
    }
    
    return res;
}

void solve(){
    int n;
    cin >> n;
    rep(i,0,n-1){
        int s,t,w;
        cin >> s >> t >> w;
        graph[s].push_back(make_pair(t,w));
        graph[t].push_back(make_pair(s,w));
    }
    
     int v=dfs(0,-1).first;
     cout << dfs(v,-1).second << endl;
}

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

Measured memory_bytes: 12920
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


i64 n, m, q, x[101010], ans[101010];
i64 dp[33][101010];

i64 dfs(int a, int b, i64 c){
	
	for(int i = 29; i > 0; i--){
		if(dp[i][a] < b){
			return dfs(dp[i][a], b, c+(1 << i));
		}
	}
	if(dp[0][a] >= b){
		return c + 1;
	}
	else return c + 2;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i];
	cin >> m >> q;
	
	for(int i = 0; i < n; i++){
		dp[0][i] = (upper_bound(x, x+n, x[i]+m)-1) - x;
	}
	int cnt = 0;
	for(int k = 2; k < INF; k*=2){
		cnt++;
		for(int i = 0; i < n; i++){
			if(dp[cnt-1][i] == dp[cnt-1][dp[cnt-1][i]]) dp[cnt][i] = INF;
			dp[cnt][i] = dp[cnt-1][dp[cnt-1][i]];
		}
	}
	
	for(int i = 0; i < q; i++){
		int a, b;
		cin >> a >> b;
		if(a > b) swap(a,b);
		
		ans[i] = dfs(a-1,b-1,0);
	}
	for(int i = 0; i < q; i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 28416
#include<stdio.h>
int main()
{
    char m[100],a[300];
    int n,i,j,b,t;
    while(~scanf("%d",&n))
    {
        scanf("%s",m);
        t=99;
        b=0;
        for(i=100;i<n+100;i++)
        {
            if(m[i-100]==')')
            {
                a[i]=')';
                if(b==0)
                {
                    a[t]='(';
                    t--;

                }
                else
                b--;
            }
            if(m[i-100]=='(')
            {
              b++;
              a[i]='(';
            }
        }
        for(j=1;j<=b;j++)
                a[i++]=')';
        for(j=t+1;j<=i-1;j++)
            printf("%c",a[j]);
        printf("\n");
    }
    return 0;
}


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

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

  for (int i = a; i <= b; i++)
  {
    if (i % k == 0)
    {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int ans = 0;
        if(N%1000 == 0) ans = 0;
        else ans = (N/1000+1)*1000 - N;
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 32824
#coding=UTF-8

N=int(input())
mozir=input()
hyo=mozir.split(' ')
a=[int(mono) for mono in hyo]

zentai=sum(a)

x=a[0]
y=zentai-x
ans=abs(x-y)
for idx in range(1,N-1,1):
    x+=a[idx]
    y=zentai-x
    tmpans=abs(x-y)
    if tmpans < ans:
        ans=tmpans

print(ans)


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

int arr(int x){
    if(x%2 == 0) return x/2;
    return x*3+1;
}

bool flag[5];

int main(){
    int s;
    cin >> s;
    int cnt = 0;
    while(1){
        cnt++;
        if(cnt == 1) s;
        else s = arr(s);
        if(s<=4 && flag[s]){
            cout << cnt << endl;
            return 0;
        }
        else if(s <= 4)flag[s] = true;
    }
    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) //vec.size()がnの時等の高速化
#define loop(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

bool smallc(char c){
  return 'a'<=c && c <= 'z' || c=='C';
}

int main(){
  string s;cin >> s; 
  bool ans=true;int len=(int)s.size();
  ans &= s[0]=='A'; 
  int c=0;
  loop(i,2,len-1) if(s[i]=='C') c++;
  ans &= c==1;
  loop(i,1,len) ans&=smallc(s[i]);
  cout << (ans?"AC":"WA") << endl;


  return 0;
}


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

using namespace std;

#define MOD 1000000007
#define N 102
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int b[N], a[N];

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, i, j, sum;
	cin>>n;
	for(i=1; i<n; i++){
		cin>>b[i];
	}
	a[1] = b[1];
	for(i=1; i<n; i++){
		a[i] = min(a[i], b[i]);
		a[i+1] = b[i];
	}
	sum = 0;
	for(i=1; i<=n; i++){
		sum = sum + a[i];
	}
	cout<<sum;
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int size=0,left=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='('){
			size++;	
		}else{
			if(size==0)left++;
			else size--;
		}
	}
	for(int i=0;i<left;i++){
		cout<<'(';
	}
	cout<<s;
	for(int i=0;i<size;i++){
		cout<<')';
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    vector<int> nums(N), sorted(N);
    rep(i,N) cin>>nums[i], sorted[i]=nums[i];
    
    sort(all(sorted));
    map<int,int> dic;
    rep(i,N){
        dic[sorted[i]]=(i%2);
    }
    
    int cnt=0;
    rep(i,N){
        if((i%2)!=dic[nums[i]]) cnt++;
    }
    
    cout1(cnt/2);
}

Measured memory_bytes: 7684
N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * 10 ** 7
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    y = i + 1 + A[i]
    if y < 10 ** 7:
        dp[y] += 1

print(ans)


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

int main() {
  string S;
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    if ((i % 2 == 1 && S[i] == 'R') || (i % 2 == 0 && S[i] == 'L')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main()
{
    int n;
    cin >> n;
    double ans = 0;
    for(int i =0; i<n; i++){
        double a;
        cin >> a;
        ans += (1/a);
    }
    
    cout << fixed << setprecision(10) << 1/ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut a: Vec<u64> = (0..n).map(|_| read()).collect();
    let mut bc: Vec<(u64,u64)> = (0..m).map(|_| (read(),read())).collect();

    a.sort();
    bc.sort_by(|x,y| y.1.partial_cmp(&x.1).unwrap());
    let mut b: Vec<u64> = Vec::new();
    for i in 0..m{
        for _ in 0..bc[i].0{
            b.push(bc[i].1);
        }
        if b.len() >= n{
            break;
        }
    }

    let mut ans = 0;
    for i in 0..n{
        if b.len() <= i{
            ans += a[i];
        }else if a[i] <= b[i]{
            ans += b[i];
        }else{
            ans += a[i];
        }
    }
    println!("{}",ans);

}


Measured memory_bytes: 5832