akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
#define DEBUG
#ifdef DEBUG
#endif

int main()
{
    std::ios::sync_with_stdio(false);
    LL n, h, w, N;
    cin >> N;
    for(n = 1; n <= 3500; n++)
    {
    	for(h = 1; h <= 3500; h++)
    	{
    		LL a = N*h*n;
    		LL b = 4*h*n-N*h-n*N;
    		if(b <= 0)continue;
    		if(a%b==0)
    		{
    			w = a/b;
    			cout << h << " " << n << " " << w << endl;
    			return 0;
    		}
    	}
    }






















    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int W,H,x,y,r;

  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);

  if( x-r < 0 || x+r > W )printf("No\n");
  else if( y-r < 0  || y+r > H )printf("No\n");
  else if( x-r >= 0  || x+r <= W )printf("Yes\n");
  else if( y-r >= 0  || y+r <= H )printf("Yes\n");

  return 0;
}

Measured memory_bytes: 584
import sys

def main():
    n = int(input())

    if n <= 2:
        print(1)
        sys.exit()

    w = [tuple(map(int,input().split())) for x in range(n)]
    w.sort()

    pqs = {}
    for i in range(n-1):
        for j in range(i+1,n):
            xy = (w[j][0] - w[i][0], w[j][1] - w[i][1])
            if xy not in pqs:
                pqs[xy] = 1
            else:
                pqs[xy] += 1
    print(n - max(pqs.values()))

if __name__=='__main__':
    main()

Measured memory_bytes: 3188
N = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(1,N):
  if a[i] == a[i-1]:
    if i == N-1:
      a[i] = a[i-1]*2
    else:
      a[i] = a[i-1]+a[i+1]
    count += 1
print(count)
      

Measured memory_bytes: 2940
use proconio::{input, fastout};

const MOD: usize = 1000000007;

struct DFS {
    n: usize,
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
    G: Vec<Vec<usize>>,
    ans: Vec<usize>,
    size: Vec<usize>
}

impl DFS {
    fn new(n: usize) -> DFS {
        let mut fact = vec![1; n];
        let mut inv_fact = vec![1; n];
        for i in 1..n {
            fact[i] = fact[i-1] * i % MOD;
        }
        inv_fact[n-1] = Self::modinv(fact[n-1]);
        for i in (1..n).rev() {
            inv_fact[i - 1] = inv_fact[i] * i % MOD;
        }

        DFS { n, fact, inv_fact, 
            G: vec![Vec::new(); n],
            ans: vec![1; n],
            size: vec![1; n]
        }
    }
    fn nCr(&self, n: usize, r: usize) -> usize {
        let ret = {self.fact[n] * self.inv_fact[r] % MOD
                   * self.inv_fact[n-r] % MOD};
        ret
    }

    fn modinv(x:usize) -> usize{
        Self::pow(x, MOD-2)
    }

    fn pow(mut x:usize, mut y:usize) -> usize {
        let mut res: usize = 1;
        while y > 0 {
            if y & 1 > 0 { res = res * x % MOD;}
            x = x * x % MOD;
            y >>= 1;
        }
        res
    }
    fn add_edge(&mut self, u:usize, v:usize) -> () {
        self.G[u].push(v);
        self.G[v].push(u);
    }

    fn dfs_1(&mut self, v:usize, p:usize) {
        for x in self.G[v].clone() {
            if x == p {continue;}
            self.dfs_1(x, v);
            self.ans[v] = self.ans[v] * self.ans[x] % MOD * self.inv_fact[self.size[x]] % MOD;
            self.size[v] += self.size[x];
        }
        self.ans[v] = self.ans[v] * self.fact[self.size[v] - 1] % MOD;
    }

    fn dfs_2(&mut self, v:usize, p:usize) {
        for x in self.G[v].clone() {
            if x == p {continue;}
            let c = self.ans[v] * Self::modinv(self.nCr(self.n-1, self.size[x])) % MOD;
            self.ans[x] = c * self.nCr(self.n-1, self.n - self.size[x]) % MOD;
            self.dfs_2(x, v);
        }
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
        edges: [(usize, usize); n-1]
    }
    let mut d = DFS::new(n);
    for (u, v) in edges {d.add_edge(u-1, v-1)}
    d.dfs_1(0, 0);
    d.dfs_2(0, 0);
    for i in 0..n {
        println!{"{}", d.ans[i]}
    }
}

Measured memory_bytes: 26432
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = n;
		for(int i=0; i<=n; i++){
			int nin = i;
			int six = n - i;
			int cnt  = 0;
			while(nin!=0){
				cnt += nin % 9;
				nin /= 9;
			}
			while(six!=0){
				cnt += six % 6;
				six /= 6;
			}
			min = Math.min(min, cnt);
		}	
		System.out.println(min);
	}
}

Measured memory_bytes: 23760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
#define inf 0x7fffffff
/*------------------------------------------------------------*/
int n,m; 
int main(){
	cin>>n>>m;
	if((n+m)%2){
		out((n+m)/2+1);
	}
	 else out((n+m)/2);
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, x, m; cin >> n >> x >> m;

    vector<ll> v = {x};
    bool use[m]; memset(use, 0, sizeof(use)); use[x] = true;
    ll at = x, lst = x;
    
    while(1){
        at = at * at % m;
        lst = at;

        if(use[at])break;
        use[at] = true;

        v.push_back(at);
    }

    vector<ll> u;
    while(v.back() != lst){
        u.push_back(v.back());
        v.pop_back();
    }
    u.push_back(lst);
    v.pop_back();
    reverse(u.begin(), u.end());

    ll ans = 0;
    zep(i, 0, v.size()){
        ans += v[i];
        n--;
        if(n == 0){
            print(ans) return 0;
        }
    }

    ll sm = 0;
    zep(i, 0, u.size())sm += u[i];
    ans += sm * (n / u.size());
    n %= u.size();
    zep(i, 0, n)ans += u[i];
    print(ans)

    return 0;
}

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

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


int main(){
	int k;
	string s;

	cin >> k >> s;
	if(s.length()<=k){
		cout << s << endl;
	}else{
		for(int i=0;i<k;i++){
			cout << s[i];
		}
		cout <<"..."<<endl;
	}



	return 0;
}


Measured memory_bytes: 3552
import java.util.Scanner;

class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String num = sc.next();
			if(num.equals("0")) break;
			int sum = 0;
			for(int i = 0; i < num.length(); i++) {
				sum += num.charAt(i) - 48;
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 26164
#include<iostream>
#include<algorithm>
//#include<array>
#include<vector>
using namespace std;
int main(){
        //array<int,3>ar;
        vector<int>ar(3);
        for(auto&e:ar){
                scanf("%d",&e);
        }
        sort(ar.begin(),ar.end());
        printf("%d %d %d\n",ar[0],ar[1],ar[2]);
        return 0;
}

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

int main(){
  using lint= long long int;
  int N;
  lint MPwalk, MPtele;
  cin >> N >> MPwalk >> MPtele;

  lint ans= 0;
  lint from, to;
  cin >> from;
  for(int i=1; i<N; i++){
    cin >> to;
    ans+= min(MPtele, MPwalk*(to- from));
    from= to;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
 
__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
 
 
int main() {
  ll n;
  while(cin >> n) {
    if(n == 0) return 0;
 
    ll p[n], j[n - 1], na = 0, h = n;
    rep(i, 0, n) cin >> p[i], na += p[i];
    rep(i, 0, n - 1) cin >> j[i];
 
    sort(j, j + n - 1);
    ll ma = 0;
    rep(i, 1, n) {
      ma = max(ma, na * h);
      na += j[n - (i + 1)];
      h--;
    }
 
    ma = max(ma, na * h);
    cout << ma << endl;
  }
}

Measured memory_bytes: 4084
TIME = 10 ** 5
n, c = gets.split.map(&:to_i)
recordings = []
n.times { recordings << gets.split.map(&:to_i) }
channels = Array.new(c) { Array.new(TIME + 1, 0) }
# いもす法準備
recordings.each do |from, to, channel|
  channels[channel - 1][from - 1] += 1
  channels[channel - 1][to - 1] -= 1
end
# いもす法加算
channels.each do |channel|
  (1..TIME).each do |i|
    channel[i] += channel[i - 1]
  end
end
# 録画に途切れがあるところは、他のチャンネルの次に録画するため、開始時間を 1 早める
channels.each do |channel|
  (0..TIME - 1).each do |i|
    channel[i] += 1 if channel[i + 1] > channel[i]
  end
end
ans = []
# 最も録画中のチャンネルが多い時間帯を求める
(0...TIME).each do |i|
  sum = 0
  channels.each do |channel|
    sum += channel[i]
  end
  ans << sum
end
puts ans.max


Measured memory_bytes: 34100
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
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;
}
const ll mod = 1000000007;
ll powmod(ll a, ll b)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
// head

int main()
{
    int n, t, a, h, k;
    cin >> n >> t >> a;
    double ans = mod;
    rep(i, 0, n)
    {
        cin >> h;
        if (chmin(ans, (abs(a - t + h * 0.006))))
        {
            k = i;
        }
    }
    cout << k + 1;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r, l, c, a;
string s;

// <------------- Implement Functions Here ----------> //

vpll decode() {
	vpll p;
	ll i = 0;
	while (i < n) {
		pll X;
		ll cou = 0;
		while (i < n && s[i] == 'R') {
			cou ++;
			i ++ ;
		}
		X.f = cou;
		cou = 0;
		while (i < n && s[i] == 'L') {
			cou++;
			i ++;
		}
		X.s = cou;
		p.pb(X);
	}
	return p;
}

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s;
	n = s.length();
	vpll p = decode();
	/*for(auto it : p) {
		cout<<it.f<<" "<<it.s;newl;
	}*/
	n = p.size();
	ll sum;

	for (ll i = 0; i < n; i++) {
		sum = (p[i].f + p[i].s);
		if (sum % 2 == 0) {
			for (ll j = 1; j < p[i].f; j++) cout << 0 << " ";
			cout << sum / 2 << " ";
			cout << sum / 2 << " ";
			for (ll j = 1; j < p[i].s; j++) cout << 0 << " ";
		}
		else {
			for (ll j = 1; j < p[i].f; j++) cout << 0 << " ";
			//cout<<"--"<<p[i].f<<" "<<p[i].s;newl;
			ll turn = max(p[i].f, p[i].s) - 1;
			if (turn % 2 == 0) {
				if (p[i].f > p[i].s) {
					cout << sum / 2 + 1 << " ";
					cout << sum / 2 << " ";
				}
				else {
					cout << sum / 2  << " ";
					cout << sum / 2 + 1<< " ";
				}
			}
			else {
				if (p[i].f > p[i].s) {
					cout << sum / 2  << " ";
					cout << sum / 2 + 1<< " ";
				}
				else {
					cout << sum / 2 + 1<< " ";
					cout << sum / 2 << " ";
				}	
			}
			for (ll j = 1; j < p[i].s; j++) cout << 0 << " ";
		}
	}
	newl;
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 13772
N, M = map(int, input().split())
S = input()
T = input()

# ユークリッドの互除法
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

length = N * M // gcd(N, M)

if S[0::length//M] == T[0::length//N]:
    print(length)
else:
    print(-1)


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

int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;

    int cnt=0;
    while(A>=B){
        B*=2;
        cnt++;
    }
    while(B>=C){
        C*=2;
        cnt++;
    }
    if(K>=cnt){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
int idx[27], pre[27];
int main() {
  string s;
  cin>>s;
  int n =s.size();
  vector<int> ans={-1, -1};
  for (int i = 0; i < 26; ++i) {
    int minv1 = 0;
    int minv2 = 1000000000;
    int idx1= 0;
    int idx2=0;
    int sum=0;
    int tmp=2*0-1;
    if (s[0] == 'a' + i) {
      tmp=2 * 1-1;
      sum++;
    }
    // if (tmp < minv1) {
    //   minv2 = minv1;
    //   idx2=idx1;
    //   minv1 = tmp;
    //   idx1 = 1;
    // } else if (tmp >= minv1 && tmp < minv2) {
    //   minv2 = tmp;
    //   idx2 = 1;
    // }
    for (int j = 2; j <= n; ++j) {
      if (s[j-1] == 'a' + i) {
        sum++;
      }
      if (2 * sum - j > minv1 && j-idx1 >= 2) {
        ans[0] = idx1+1;
        ans[1] = j;
        break;
      } else if (2 * sum - j > minv2 && j - idx2 >= 2) {
        ans[0] = idx2+1;
        ans[1] = j;
        break;
      }
      if (tmp < minv1) {
        minv2 = minv1;
        idx2=idx1;
        minv1 = tmp;
        idx1 = j-1;
      } else if (tmp >= minv1 && tmp < minv2) {
        minv2 = tmp;
        idx2 = j-1;
      }
      tmp = 2 *sum-j;
    }
    if (ans[0] >= 0) break; //{cout<<i<<endl; break;}
  }
  cout<<ans[0]<<" "<<ans[1]<<endl;
  // for (int i= 0; i < 26; ++i) {
  // 	idx[i] = 0;
  //   pre[i] = 0;
  //   int tmp = 0;
  //   int sum=0;
  //   if (s[0] == 'a' + i) {
  //     tmp = 2 * 1 - 1;
  //     sum++;
  //   } else {
  //     tmp = 2 * 0 - 1;
  //   }
  //   for (int j = 2; j <= n; ++j) {
  //     if (s[j-1] == 'a' + i) {
  //       sum++;
  //     	if (2*sum - j > pre[i]) {
  //         ans[1] = j;
  //         ans[0] = idx[i]+1;
  //         break;
  //       }
  //       if (tmp < pre[i]) {
  //         pre[i] = tmp;
  //         idx[i] = j-1;
  //       }
  //       tmp = 2*sum - i;
  //     }
  //   }
  //   if (ans[0] >= 0) break;
  // }
  // if (ans[0] < 0) cout<<"-1 -1"<<endl;
  // else cout<<ans[0]<<" "<<ans[1]<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

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

Measured memory_bytes: 256
n,m=map(int,input().split())
s=input()
t=input()
import fractions
g=fractions.gcd(n,m)
m0=m//g
n0=n//g
i=0
while i*n0<n and i*m0<m:
  if s[i*n0]==t[i*m0]:
    pass
  else:
    print(-1)
    exit()
  i+=1
print(n*m//g)


Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if (b == 0) {
    cout << "Zero";
  }
  else if (b > 0) {
  	if (a <= 0) {
      cout << "Zero";
    }
    else {
      cout << "Positive";
    }
  }
  else {
    if ((b-a+1)%2==0) {
      cout << "Positive";
    }
    else {cout << "Negative";}
  }
}

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

int main()
{
    int a,b;
    int cnt= 0;

    int n;
    cin>>n;

    while(n--)
    {
        cin>>a>>b;

        if(a==b)
            cnt++;
        else
            cnt= 0;

        if(cnt==3)
            return cout<<"Yes\n", 0;
    }

    cout<<"No\n";
}






Measured memory_bytes: 3636
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int ma=sc.nextInt();
		int mb=sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();
		}
		int dp[][][] = new int[n+1][400+1][400+1];

		int max = 100*40+5;
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=400; j++) {
				for(int k=0; k<=400; k++) {
					dp[i][j][k]=max;
				}
			}
		}
		dp[0][0][0]=0;

		for(int i=1; i<=n; i++) {
			for(int j=0; j<=400; j++) {
				for(int k=0; k<=400; k++) {
					dp[i][j][k] = dp[i-1][j][k];
					if(j-a[i-1]>=0 && k-b[i-1]>=0 && dp[i-1][j-a[i-1]][k-b[i-1]]!=max) {
						dp[i][j][k] = Math.min(dp[i-1][j][k], dp[i-1][j-a[i-1]][k-b[i-1]] + c[i-1]);
					}
				}
			}
		}

		int ans = 100*40+5;
		for(int i=1; i<=400; i++) {
			for(int j=1; j<=400; j++) {
				if(dp[n][i][j] != max) {
					if(i*mb == j*ma) {
						ans = Math.min(ans, dp[n][i][j]);
					}
				}
			}
		}
		if(ans == max) {
			System.out.println(-1);
		}else {
			System.out.println(ans);
		}
		sc.close();
	}


}


Measured memory_bytes: 68556
k,x=map(int,input().split())


min_x = x - (k-1)
max_x = x + (k-1)
ans = []
for i in range(min_x, max_x+1):
  ans.append(i)
  if(i == max_x):
  	print(i)
  else:
    print(i,end=" ")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a,b;
  cin >> n >> a >>b;
  int A=0;
  int B=0;
  for(int i=0;i<n;i++){
    char w;
    cin >> w;
    if( w=='c'){
      cout << "No";
    }
    else if(w =='a'){
      if(A+B < a+b){
        A++;
        cout <<"Yes";
      }
      else{
        cout <<"No";
      }
    }
    else{
      if(A+B<a+b&&B<b){
        B++;
        cout << "Yes";
      }
      else{
      cout << "No";
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t x;
	uint64_t ans;
	if (scanf("%"SCNu64, &x) != 1) return 1;
	ans = (x / 11) * 2; /* 6 -> 5 -> 6 -> ... -> 5 */
	if (x % 11 > 0) ans++; /* -> 6 */
	if (x % 11 > 6) ans++; /* -> 5 */
	printf("%"PRIu64"\n", ans);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var s = Console.ReadLine();
            var ans = "Yes";
            if (s == "AAA" || s == "BBB") ans = "No";
            Console.WriteLine(ans);


        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
 long n,i,ans=0;
 cin>>n;
 long long a[n+1];
 for(i=0;i<n;i++)
 {
  cin>>a[i];
  while(a[i]%2==0)
  {
   a[i]/=2;
   ans++;
  }
 }
 cout<<ans;
 return 0;
}

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

using namespace std;

typedef long long ll;

bool sortByVal(const pair<int, int> &a, 
               const pair<int, int> &b) 
{ 
    return (a.second < b.second); 
} 

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> tmp(N+1);
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        tmp[a]++;
    }

    vector<int> cnt;
    for (int i = 1; i <= N; i++) {
        if (tmp[i] == 0) { continue; }
        cnt.push_back(tmp[i]);
    }

    sort(cnt.begin(), cnt.end());
    int num = 0;
    ll sz = cnt.size();
    for (int i = 0; i < sz - K; i++) {
        num += cnt[i];
    }

    cout << num << endl;

    /*
    
    map<int, int> cnt;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;

        auto found = cnt.find(A);
        if (found == cnt.end()) {
            cnt[A] = 1;
        } else {
            cnt[A]++;
        }
    }

    vector<pair<int, int>> vec;
    for (auto const& x : cnt) {
        vec.push_back(pair<int, int>(x.first, x.second));
    }
    sort(vec.begin(), vec.end(), sortByVal); 

    int num = 0;
    int lim = max((unsigned long)0, vec.size() - K);
    for (int i = 0; i < lim; i++) {
        num += vec[i].second;
    }

    cout << num << endl;
    */
}

Measured memory_bytes: 4816
package main

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

func main() {
	var N, C, K int
	fmt.Scan(&N, &C, &K)
	T := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range T {
		sc.Scan()
		T[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Ints(T)
	var bus, i int
	for i < N {
		passenger := 0
		start := T[i]
		for i < N && T[i]-start <= K && passenger < C {
			passenger++
			i++
		}
		bus++
	}
	fmt.Println(bus)
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  sort(ALL(s));
  bool a = true;
  rep(i,s.size()-1){
    if(s.at(i)==s.at(i+1)){
      a=false;
    }
  }
  if(a){
    cout << "yes" << endl;
  }else{
    cout <<  "no" << endl;
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<unordered_set>
#include<complex>
#include <cassert>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios::sync_with_stdio(false); cin.tie(0);
    LL a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a + b) {
        cout << min(k, a) << endl;
        return 0;
    }

    cout << a - (k - (a + b)) << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int k;
    string s;
    cin >> k >> s;

    if (s.size() <= k) cout << s << endl;
    else cout << s.substr(0, k) + "..." << endl;
    return 0;
}



Measured memory_bytes: 3656
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 998244353

    n,k = get_nums_l()

    steps = []
    for _ in range(k):
        l,r = get_nums_l()
        steps.append((l,r))
    
    # log(steps)

    # dp[i] = iマスまで行く方法のパターン数
    dp = [0] * (n)
    ruiseki = [0] * (n+1)

    dp[0] = 1
    ruiseki[1] = 1

    for i in range(1, n):
        for a,b in steps:
            l = max(0, i-b)
            r = i-a
            # log("A", i,l,r)
            if r < 0:
                continue

            add = (ruiseki[r+1] - ruiseki[l])
            dp[i] = (dp[i] + add) % MOD
            # log("  B", add)
        ruiseki[i+1] = (ruiseki[i] + dp[i]) % MOD
        # log(dp, ruiseki)

    print(dp[n-1] % MOD)

main()

Measured memory_bytes: 71936
def main():
  n, m, q = map(int, input().split() )
  a = [0] * q
  b = [0] * q
  c = [0] * q
  d = [0] * q
  for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split() )
  A = [1] * (n + 1)
  A[0] = 0
  ans = 0
  while A[0]==0:
    tmp = 0
    for i in range(q):
      if( A[b[i]]-A[a[i]]==c[i] ):
        tmp += d[i]
    ans = max(ans, tmp)
    A[n] += 1
    for i in range(1,n+1):
      if( A[i]>m ):
        i-=1
        A[i] += 1
        t = A[i]
        for j in range(i,n+1):
          A[j] = t
        break
  print(ans)

main()

Measured memory_bytes: 68480
N,A,B=map(int,input().split())
Sum=0
ans=0

for i in range(N):
    s=str(i+1)
    for j in range(len(s)):
        Sum+=int(s[j])
    if A<=Sum and Sum<=B:
        ans+=int(s)
    else:
        pass
    Sum=0

print(ans)


Measured memory_bytes: 3060
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }

n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Measured memory_bytes: 6724
unittest
{
	assert( [ "9" ].solve == 0 );
	assert( [ "10" ].solve == 1 );
	assert( [ "100" ].solve == 543 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	auto ps = n.primes;
	auto cs = new long[ n + 1 ];
	foreach( i; 2L .. n + 1 )
	{
		foreach( p; i.primefactorize( ps ) )
		{
			cs[ p ]++;
		}
	}
	return solve2( cs, 1L );
}

auto solve2( long[] cs, long m )
{
	if( m == 75 ) return 1L;
	if( cs.empty ) return 0L;
	auto t = 0L;
	foreach( i; [ 1L, 3L, 5L, 15L, 25L, 75L ] )		// 75の約数
	{
		if( cs.front + 1 < i || 75 < m * i ) break;
		t += solve2( cs[ 1 .. $ ], m * i );
	}
	return t;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}

// 素因数分解
auto primefactorize( long x, long[] ps )
{
	Appender!( long[] ) fs;
	if( x < 2 ) return fs.data;
	
	auto s = cast( long ) x ^^ 0.5L;
	foreach( p; ps )
	{
		if( s < p ) break;
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
		if( x < 2 ) break;
	}
	if( 2 <= x ) fs ~= x;
	return fs.data;
}


Measured memory_bytes: 2772
package main

import "fmt"

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

	flagFirstHalf := checkMonth(s[0:2])
	flagSecondHalf := checkMonth(s[2:4])

	ans := ""
	switch {
	case flagFirstHalf == true && flagSecondHalf == true:
		ans = "AMBIGUOUS"
	case flagFirstHalf == true && flagSecondHalf == false:
		ans = "MMYY"
	case flagFirstHalf == false && flagSecondHalf == true:
		ans = "YYMM"
	case flagFirstHalf == false && flagSecondHalf == false:
		ans = "NA"
	}
	fmt.Println(ans)
}

func checkMonth(s string) bool {
	if s == "01" || s == "02" || s == "03" || s == "04" || s == "05" || s == "06" || s == "07" || s == "08" || s == "09" || s == "10" || s == "11" || s == "12" {
		return true
	}
	return false
}


Measured memory_bytes: 512
#include <stdio.h>

int main( void ) {
	double n;
	int i, ni;

	for ( ; scanf( "%lf", &n ), ( n *= 16 ) >= 0; putchar( '\n' ) )
		if ( n - ( ni = n ) > 0 || ni > 4095 )
			printf( "NA" );
		else
			for ( i = 12; i--; printf( "%d%s", ni >> i & 1, i == 4 ? "." : "" ) ) ;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

  ll a,b,x;
    cin>>a>>b>>x;
    
    int ct;
    if(a%x==0)
      ct=1;
      else
      ct=0;
   
   cout<<(b/x)-(a/x)+ct;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    k = len(str(N))

    result = 0
    for k_i in range(1, k, 2):
        result += 9 * 10 ** (k_i - 1)
    if k % 2 != 0:
        result += N - 10 ** (k - 1) + 1

    print(result)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int SC[4];

int main(){
    int minn=20000000;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        switch(s[i]){
            case 'K':
                SC[0]++;
                break;
            case 'U':
                SC[1]++;
                break;
            case 'P':
                SC[2]++;
                break;
            case 'C':
                SC[3]++;
        }
    }
    for(int i=0;i<4;i++){
        minn=min(minn,SC[i]);
    }
    cout<<minn<<endl;
    return 0;
}



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

c = [list(map(int, input().split())) for _ in range(3)]

a = [0] * 3
b = [0] * 3

for j in range(3):
    b[j] = c[0][j] - a[0]

for i in range(1,3,1):
    a[i] = c[i][0] - b[0]

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 9100
N = int(input())
a = list(map(int, input().split()))

cnt = 0

for i in range(N):
    if i+1 != a[i] and i+1 == a[a[i]-1]:
        a[a[i]-1] = 0
        a[i] = 0

print(a.count(0) // 2)

Measured memory_bytes: 20640
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#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 show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n,m,lft[2005][2005],rgt[2005][2005],up[2005][2005],down[2005][2005];
char a[2005][2005];

int main()
{
    fastio();
    cin>>n>>m;
    rep(i,1,n) cin>>a[i]+1;
    rep(i,1,n){
        int now = 0;
        rep(j,1,m){
            if(a[i][j]=='#') now = j;
            else lft[i][j] = j-now;
        }
    }
    rep(i,1,n){
        int now = m+1;
        per(j,m,1){
            if(a[i][j]=='#') now = j;
            else rgt[i][j] = now-j;
        }
    }
    rep(j,1,m){
        int now = 0;
        rep(i,1,n){
            if(a[i][j]=='#') now = i;
            else up[i][j] = i-now;
        }
    }
    rep(j,1,m){
        int now = n+1;
        per(i,n,1){
            if(a[i][j]=='#') now = i;
            else down[i][j] = now-i;
        }
    }
    int ans = 0;
    rep(i,1,n) rep(j,1,m) if(a[i][j]=='.') ans = max(ans,lft[i][j]+rgt[i][j]+up[i][j]+down[i][j]-3);
    cout<<ans<<endl;
    return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    ll x, k, d;
    cin >> x >> k >> d;
    // x = k = d = 1e18;
    // --k;
    // x = abs(x);
    ll t = abs(x) / d;
    db(x, t, d, k);
    if (t > k)
    {
        cout << abs(x - ((x > 0) - (x < 0)) * k * d) << '\n';
    }
    else
    {
        db(x, t, d, k);
        x = x - ((x > 0) - (x < 0)) * t * d;
        db(x);
        k -= t;
        ll y = min(abs(x + d), abs(x - d));
        if (k & 1)
            cout << y << '\n';
        else
        {
            cout << abs(x) << '\n';
        }
    }
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n; cin>>n;
	int x[200020], y[200020];
	char u[200020];
	vector<int> vx[200020], vy[200020];
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i]>>u[i];
		if(u[i]=='R' || u[i]=='L'){
			vy[y[i]].push_back(i);
		}else{
			vx[x[i]].push_back(i);
		}
	}
	int mn=1e9+7;
	for(int i=0; i<=200000; i++){
		if(vx[i].empty()) continue;
		sort(vx[i].begin(), vx[i].end(), [&](int p, int q){ return y[p]<y[q];});
		int mx=-1;
		for(auto k:vx[i]){
			if(u[k]=='D'){
				if(mx!=-1) mn=min((y[k]-mx)*5, mn);
			}else{
				mx=y[k];
			}
		}
	}
	for(int i=0; i<=200000; i++){
		if(vy[i].empty()) continue;
		sort(vy[i].begin(), vy[i].end(), [&](int p, int q){ return x[p]<x[q];});
		int mx=-1;
		for(auto k:vy[i]){
			if(u[k]=='L'){
				if(mx!=-1) mn=min((x[k]-mx)*5, mn);
			}else{
				mx=x[k];
			}
		}
	}
	const int geta=200000;
	vector<int> v1[400040], v2[400040];
	for(int i=0; i<n; i++){
		v1[x[i]+y[i]].push_back(i);
		v2[x[i]-y[i]+geta].push_back(i);
	}
	for(int i=0; i<=400000; i++){
		if(v1[i].empty()) continue;
		sort(v1[i].begin(), v1[i].end(), [&](int p, int q){ return x[p]<x[q];});
		int mxr=-1, mxd=-1;
		for(auto k:v1[i]){
			if(u[k]=='R') mxr=x[k];
			else if(u[k]=='D') mxd=x[k];
			else if(u[k]=='U'){
				if(mxr!=-1) mn=min(mn, (x[k]-mxr)*10);
			}else{
				if(mxd!=-1) mn=min(mn, (x[k]-mxd)*10);
			}
		}
	}
	for(int i=0; i<=400000; i++){
		if(v2[i].empty()) continue;
		sort(v2[i].begin(), v2[i].end(), [&](int p, int q){ return x[p]<x[q];});
		int mxr=-1, mxu=-1;
		for(auto k:v2[i]){
			if(u[k]=='R') mxr=x[k];
			else if(u[k]=='U') mxu=x[k];
			else if(u[k]=='D'){
				if(mxr!=-1) mn=min(mn, (x[k]-mxr)*10);
			}else{
				if(mxu!=-1) mn=min(mn, (x[k]-mxu)*10);
			}
		}
	}
	if(mn>1e9) cout<<"SAFE"<<endl;
	else cout<<mn<<endl;
	return 0;
}

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

using namespace std;

int N, C[500], S[500], F[500];

int main()
{
    scanf("%d",&N);
    for(int i=0; i<N-1; i++)
        scanf("%d%d%d",&C[i],&S[i],&F[i]);
    for(int i=0; i<N; i++)
    {
        int t=0;
        for(int j=i; j<N-1; j++)
        {
            if(t<S[j])t=S[j];
            else if(t%F[j]==0);
            else t=t+F[j]-t%F[j];
            t+=C[j];
        }
        printf("%d\n",t);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;

  cin >> s;

  bool ans = true;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'U' || s[i] == 'D') continue;
    if(i % 2 == 1){
      if(s[i] != 'L'){
        ans = false;
        break;
      }
    } else {
      if(s[i] != 'R'){
        ans = false;
        break;
      }
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;

ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a;
    a.resize(n);
    for(int i=0;i<n;i++)cin >> a[i];
/////2で割り切れるところまで割る///
    bool flag1 = 0;
    bool flag2;
    int cnt = 0;
    while(1){
        flag2 = 0;
        for(int i=0;i<n;i++){
            if(a[i]%2 == 1)flag1 = 1;
            if(a[i]%2 == 0)flag2 = 1;
        }
        if(flag1)break;
        
        for(int i=0;i<n;i++)a[i] = a[i]/2;
        cnt++;
    }
    if(flag2){
        cout << 0 << endl;
        return 0;
        }
   ////////////最小公倍数の決定////////
   sort(a.begin(),a.end(),greater<int>());
   int g=a[0];//最小公倍数
   bool flagg = 0;
   bool allflag = 1;
   for(int i=1;i<n;i++){
       for(int j=1;g*j*intpow(2,cnt-1)<=m;j+=2){
           if(g*j%a[i] == 0){
               g = g*j;
               flagg = 1;
               break;
               }
            }
            allflag = allflag && flagg;
            flagg=0;
        }
    
    if(allflag == 0){
        cout << 0 << endl;
        return 0;
    }//g>m
    
    cout << 1+(m-g*intpow(2,cnt-1))/(g*intpow(2,cnt)) << endl;
    
}

Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll N, D;
    cin >> N >> D;
    cout << ceil((double)N / (1 + 2 * D)) << endl;

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;

int main()
{
	int a,b;
	while(cin >> a >> b){
		if(a<0 || b<0 ||a>1000000 || b>1000000)
			break;
		int temp = a+b,count;
		for(count = 0;;++count)
			if(!(temp/=10))
				break;
		cout <<count+1<<endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(void){
    
    string a,b,c;
    cin>>a>>b>>c;
     
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
        cout<<"YES"<<endl;
    } 
    else {
        cout<<"NO"<<endl;
    }
    
}
   


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll x, y; cin >> x >> y;
	int n = 1;
	for(; x * 2 <= y; x *= 2) n++;
	cout << n << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp
h = 0
d = 0
n.times do |i|
  if s[i] == "("
    d += 1
  else
    d -= 1
  end
  if d == -1
    h += 1
    d += 1
  end
end
print "("*h,s,")"*[d,0].max,"\n"

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

int main() {
    int p, q, r, ans;
    cin >> p >> q >> r;
    ans = p + q + r - max(p, max(q, r));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int cntA=0, cntB=0;
  rep(i, N) {
    if(S[i] == 'a') {
      if(cntA+cntB<A+B) {
        cout << "Yes" << endl;
        cntA++;
      } else {
        cout << "No" << endl;
      }
    } else if(S[i] == 'b') {
      if(cntA+cntB<A+B && cntB<B) {
        cout << "Yes" << endl;
        cntB++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 896
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;


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

	if (s == "SUN") cout << "7" << endl;
	if (s == "MON") cout << "6" << endl;
	if (s == "TUE") cout << "5" << endl;
	if (s == "WED") cout << "4" << endl;
	if (s == "THU") cout << "3" << endl;
	if (s == "FRI") cout << "2" << endl;
	if (s == "SAT") cout << "1" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
const int MAXN = 1e6 + 7;
using namespace std;
int n;
int a[MAXN];
long long sum;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; i * j < n; j++) {
			a[i * j] ++;
			//cout << "i  is " << i <<" j is "<< j << endl;
		}
	}
	for (int i = 1; i < n; i++) sum += a[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 7464