akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  bool nasu[2000000] = {false};
  int s, ans = 2;
  cin >> s;
  nasu[s] = true;
  while(true){
    s = (s % 2 == 0 ? s / 2 : 3 * s + 1);
    if(nasu[s]){
      cout << ans << '\n';
      break;
    }
    nasu[s] = true;
    ans ++;
  }
  return 0;
}


Measured memory_bytes: 2176
N = int(input())
data = []
for _ in range(N):
    A, B = map(int, input().split())
    data.append([B, A])
data.sort()

prefix_cost = []
current_cost = 0
for i in range(N):
    current_cost += data[i][1]
    prefix_cost.append(current_cost)

for i in range(N):
    if not prefix_cost[i] <= data[i][0]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 43552
#include<iostream>
 
using namespace std;
 
int main()
{
    int num = 0;
    int a[10000] = { };
    long int max = -1000000, min = 1000000, sum = 0;
     
    cin >> num;
     
    for(int i = 0; i < num; i++){
        cin >> a[i];
         
        if(max < a[i])
            max = a[i];
        if(min > a[i])
            min = a[i];
     
        sum += a[i];
    }
     
    cout << min << " " << max << " " << sum << endl;
     
    return 0;
}

Measured memory_bytes: 1212
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int A = sc.nextInt();
        int B = sc.nextInt();
        for(int i=1;i<3000;i++){
            if( Math.floor(i*0.08) == A && Math.floor(i*0.10) == B){
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }

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


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

int main()
{

    int arr[3];
    for(int i=0;i<3;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+3);
    if(arr[0]==5 && arr[1]==5 && arr[2]==7)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3568
// 2016-11-30
#include <iostream>
#include <string>
using namespace std;

int main() {
	int n, m;
	string u[256], t;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u[i];
	}
	cin >> m;
	bool o = false;
	for (int i = 0; i < m; i++) {
		cin >> t;
		int j;
		for (j = 0; j < n; j++) {
			if (t == u[j]) {
				cout << (o ? "Closed by " : "Opened by ") << t << endl;
				o ^= true;
				break;
			}
		}
		if (j == n) {
			cout << "Unknown " << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3212
require "prime"
require "set"

# @param num [Integer]
# @return Integer
def divisors(num)
  (1..Math.sqrt(num).floor).map do |divisor|
    next unless num % divisor == 0

    quotient = num / divisor
    quotient == divisor ? [divisor] : [divisor, quotient]
  end.compact.flatten.sort
end

n = gets.to_i
divs = divisors(n)

ans = 0
prime_divs = Prime.prime_division(n).to_h
divs.each do |d|
  next if d == 1

  ds = Prime.prime_division(d)
  next if ds.length > 1

  flg = true
  ds.each do |prime_num, exponent|
    unless prime_divs.key?(prime_num) && prime_divs[prime_num] >= exponent
      flg = false
      break
    end
  end

  next unless flg

  ds.each do |prime_num, exponent|
    prime_divs[prime_num] -= exponent
  end

  ans += 1
  n /= d
end

puts ans


Measured memory_bytes: 30492
import itertools
import math

A = []
for i in range(5):
    A.append(float(input()))

B = list(itertools.permutations(A))
M = 500 * 5
for i in range(120):
    c = 0
    for j in range(4):
        c += math.ceil(B[i][j]/10) * 10
    c += B[i][4]
    M = min(M, c)
print(int(M))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    for(int i = 1; i<=10000; i++){
        int x;
        cin >>x;
    if(x==0){
        break;
    }else{
         cout << "Case " <<i<<": "<<x<<endl;
        }
    }
}


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

long long int trade(long long int n, long long int *a, long long int *b) {
    long long int ans = n;
    for (long long int i = 0, A = n; A >= 0; i++, A -= a[0]) {
        if (a[0] >= b[0] && i > 0)
            break;

        if (a[2] >= b[2]) {
            long long int j = A / a[1], B = A % a[1];
            ans = max(ans, B + b[0] * i + b[1] * j);
            continue;
        }

        for (long long int j = 0, B = A; B >= 0; j++, B -= a[1]) {
            if (a[1] >= b[1] && j > 0)
                break;
            long long int k = B / a[2], C = B % a[2];
            ans = max(ans, C + b[0] * i + b[1] * j + b[2] * k);
        }
    }
    return ans;
}

int main() {
    long long int n;
    long long int a[3], b[3];
    cin >> n >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];
    n = max(n, trade(n, a, b));
    n = max(n, trade(n, b, a));
    cout << n << "\n";
}


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

using namespace std;

typedef long long ll;
const int maxn = 1e5 + 10, MOD = 1e9 + 7;
ll pos[maxn],fac[maxn],facm[maxn];

ll quick_pow(ll a,ll n,ll p)
{
    ll x = a;
    ll res = 1;
    while(n)
    {
        if(n & 1)
        {
            res = ((ll)res * (ll)x) % p;
        }
        n >>= 1;
        x = ((ll)x*(ll)x) % p;
    }
    return res;
}

ll C(ll n,ll k){
    if(k > n) return 0ll;
    ll ans = fac[k]*fac[n-k]%MOD;
    ans = (fac[n]*quick_pow(ans,MOD-2ll,MOD))%MOD;
    return ans;
}

int main()
{
    fac[0] = 1;
    for(ll i = 1;i < maxn;i++)
        fac[i] = (fac[i-1]*i)%MOD;
	ll n;
	scanf("%lld", &n);
	n++;
	ll m, x;
	for(ll i = 1;i <= n;i++)
	{
		scanf("%lld", &x);
		if (pos[x])
		{
			m = n - (i - pos[x] + 1);
			break;
		}
		pos[x] = i;
	}
	for(ll i = 1;i <= n;i++)
		printf("%lld\n", (C(n, i) - C(m, i-1)+MOD) % MOD);
	return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main{
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int N = s.nextInt();
    String M = s.next();
    if (N >= 3200){
      System.out.println(M);
    }
    else{
      System.out.println("red");
    }
    
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = -1e18;

struct seg {
  int n=1; vector<set<char>> v; set<char> nothing;

  seg(int m, string s) {
    while(m>n) n<<=1;
    v.resize(2*n-1);
    for(int i=n-1, j=0; j<m; i++, j++) {
      v[i] = set<char>({s[j]});
    }
    for(int i=n-2; i>=0; i--) {
      //v[i].clear();
      v[i].clear();
      merge(v[2*i+1].begin(), v[2*i+1].end(), v[2*i+2].begin(), v[2*i+2].end(), 
            inserter(v[i], v[i].begin()));
      //v[i].merge(v[2*i+1]); v[i].merge(v[2*i+2]);
    }
  }

  void update(int i, char c) {
    i += n-1;
    v[i] = set<char>({c});
    while(i>0) {
      i=(i-1)/2;
      v[i].clear();
      merge(v[2*i+1].begin(), v[2*i+1].end(), v[2*i+2].begin(), v[2*i+2].end(), 
            inserter(v[i], v[i].begin()));
    }
  }

  set<char> query(int a, int b, int k, int l, int r) {
    if (a<=l && r<=b) return v[k];
    else if (r <= a || b <= l) return set<char>({});
    else {
      set<char> x1 = query(a,b,2*k+1,l,(l+r)/2);
      set<char> x2 = query(a,b,2*k+2,(l+r)/2,r);
      set<char> x3;
      merge(x1.begin(), x1.end(), x2.begin(), x2.end(), 
            inserter(x3, x3.begin()));
      return x3;
    }
  }
  int query(int a, int b) {
    set<char> ss = query(a,b+1,0,0,n);
    //for(char c:ss) cout<<c<<" "; cout<<endl;
    return ss.size();
  }
  void print(){
    for(int i=0;i<2*n-1;i++) {
      cout<<i<<" "<<v[i].size()<<" ";
      for(char c:v[i]) cout<<c<<" ";
      cout<<endl;
    }
  }
};

int main(){
  int n; cin>>n;
  string s; cin>>s; seg se(n,s);
  //se.print();
  int q; cin>>q;
  for(int i=0;i<q;i++) {
    int qu; cin>>qu;
    if (qu == 1) {
      int ii; char cc; cin>>ii>>cc; ii--;
      se.update(ii, cc);
    } else {
      int l,r; cin>>l>>r; l--; r--;
      cout<<se.query(l, r)<<endl;
    }
    //se.print();
  }
}

Measured memory_bytes: 190488
#include<bits/stdc++.h>
#define to first
#define wgt second 

using namespace std;

const int MAXN=1010;

typedef pair<int,int> pii;
typedef vector<pii> vec;
typedef vector<vec> Graph;

Graph G(MAXN);
int n,d[MAXN],times[MAXN];
bool negative_cycle; 

void SPFA(int s)
{
	queue<int> que;
	negative_cycle=false;
	memset(times,0,sizeof(times));
	fill(d,d+n,INT_MAX);
	d[s]=0;
	times[s]=1;
	que.push(s);
	while(!que.empty())
	{
		int u=que.front();que.pop();
		for(int i=0;i<G[u].size();i++)
			if(d[G[u][i].to]>d[u]+G[u][i].wgt)
			{
				d[G[u][i].to]=d[u]+G[u][i].wgt;
				que.push(G[u][i].to);
				times[G[u][i].to]++;
				if(times[G[u][i].to]>n)
				{
					negative_cycle=true;
					while(que.empty()) que.pop();
					return ;
				}
			}
	}
}

int main()
{
	int e;
	scanf("%d%d",&n,&e);
	for(int i=0;i<e;i++)
	{
		int s,t,d;
		scanf("%d%d%d",&s,&t,&d);
		G[s].push_back(make_pair(t,d));
	}
	for(int r=0;r<n;r++)
	{
		SPFA(r);
		if(negative_cycle)
			break;
		for(int i=0;i<n;i++)
			if(d[i]==INT_MAX)
				printf("INF%c",i+1==n?'\n':' ');
			else
				printf("%d%c",d[i],i+1==n?'\n':' ');
	}
	if(negative_cycle)
		printf("NEGATIVE CYCLE\n");
	return 0;
}

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

int main() {
    string str;
    cin>>str;
    if(str[0]=='R'&&str[1]=='R'&&str[2]=='R')
    cout<<"3";
    else if(str[0]=='R'&&str[1]=='R')
    cout<<"2";
    else if(str[1]=='R'&&str[2]=='R')
    cout<<"2";
    else if(str[0]=='S'&&str[1]=='S'&&str[2]=='S')
    cout<<"0";
    else
    cout<<"1";
    
    
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{
	double d,t,s;
	cin>>d>>t>>s;
	if(d/s<=t) cout<<"Yes";
	else cout<<"No";
	return 0;	
} 

Measured memory_bytes: 3160
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    ll n,m;
    cin >> n >> m;
    ll ans;
    
    //処理
    if(n>=m/2) ans = m/2;
    else ans = (n+m/2)/2;

    //出力
    cout << ans << ENT;
    return 0;
}

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


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

typedef long long ll;

int main()
{
    int n, ans=0;
    cin >> n;
    map<int, int> a;
    rep(i, n)
    {
        int s;
        cin >> s;
        a[s]++;
    }
    for (auto i : a)
    {
        ans += i.second % 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define ll long long
#define ftt cin>>t;for(int tt=1;tt<=t;++tt)
#define nl cout<<"\n"
using namespace std;

bool isPrime(ll x)
{
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
ll lcm(ll x,ll y)
{
    ll z = x*y;
    return z/__gcd(x,y);
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll t,n,m,a,b=0,d,c,q,x=0,y=0,ans=0,sum=0,i,j,k;


  string s1,s2;
  cin>>s1>>s2;
  for(i=0;i<s1.size();i++)
  {
      if(s1[i]!=s2[i])
      {
          cout<<"No";
          return 0;
      }
  }
  cout<<"Yes";









    return 0;
}


Measured memory_bytes: 3628
from collections import Counter

n = int(input())
sl = []
for i in range(n):
    s = input()
    sl.append(s)

sc = Counter(sl)
#print(sc)

max = 0
ans = []
for i , word in enumerate(sc.most_common()):
    if i == 0:
        max = word[1]
        ans.append(word[0])
        #print(word[0])
    else:
        if max == word[1]:
            ans.append(word[0])
            #print(word[0])
        else:
            break

ans = sorted(ans)
for w in ans:
    print(w)


Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B;
    cin>>A>>B;
    if(A<=8 && B<=8){
        cout<<"Yay!"<<endl;
    }else{
        cout<<":("<<endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A=1;
  int count=0;
  vector<int> Bot(N);
  for(int i=0;i<N;i++)
    cin>>Bot.at(i);
  for(int i=0;i<N+1;i++){
    A=Bot.at(A-1);
    count++;
    if(A==2)
      break;
  }
  if(count>N)
    cout<<"-1"<<endl;
  else
    cout<<count<<endl;
}

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

int main(){
  int n;
  cin >> n;
  if (n == 1){
    cout << "Hello World" << endl;
    return 0;
  }
  int a,b;
  cin >> a >> b;
  cout << a + b << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
        import java.util.*;
        import java.io.*;
        import java.util.stream.IntStream;
        import java.util.stream.Stream;

public class Main {

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

    final IO io = new IO();
    final PrintWriter out = new PrintWriter(System.out);

    void stream() {
        solve();
        out.flush();
    }

    void solve() {
        int N = io.Int();
        int[] d = new int [N];
        for(int i = 0; i < N; i++) {
            d[i] = io.Int();
        }

        long ans = 0;
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                ans += d[i] * d[j];
            }
        }

        System.out.println(ans);
    }
}

class IO {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1 << 12];
    private int ptr = 0, buffLen = 0;

    private boolean hasNextByte() {
        if (ptr < buffLen) return true;
        ptr = 0;
        try {
            buffLen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return buffLen > 0;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    } //ASCII

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    private boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    private String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public String String() {
        return next();
    }

    public char Char() {
        return next().charAt(0);
    }

    public int Int() {
        return Integer.parseInt(next());
    }

    public long Long() {
        return Long.parseLong(next());
    }

    public double Double() {
        return Double.parseDouble(next());
    }

    public String[] StringArr(final int n) {
        final String[] arr = new String[n];
        for (int i = 0; i < n; ++i) arr[i] = String();
        return arr;
    }

    public char[] CharArr(final int n) {
        final char[] arr = new char[n];
        for (int i = 0; i < n; ++i) arr[i] = Char();
        return arr;
    }

    public int[] IntArr(final int n) {
        final int[] arr = new int[n];
        for (int i = 0; i < n; ++i) arr[i] = Int();
        return arr;
    }

    public long[] LongArr(final int n) {
        final long[] arr = new long[n];
        for (int i = 0; i < n; ++i) arr[i] = Long();
        return arr;
    }

    public double[] DoubleArr(final int n) {
        final double[] arr = new double[n];
        for (int i = 0; i < n; ++i) arr[i] = Double();
        return arr;
    }
}

Measured memory_bytes: 21332
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
int n;
cin>>n;
int u[100];
int ans=-9239;
int conti=0;
for(int i=0;i<n;i++){
cin>>u[i];
if(u[i]==1){conti++;}
else{ans=max(ans,conti);conti=0;}
}ans=max(ans,conti);
cout<<ans+1<<endl;

	return 0;
}


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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

const ll MODP = 1000000007;

int N;
ll t[131072], a[131072];

int main(void){
	cin >> N;
	for(int i=0;i<N;i++) cin >> t[i];
	for(int i=0;i<N;i++) cin >> a[i];
	ll ans = 1;
	
	vector<ll> ub(N), ub2(N), info(N), info2(N);
	for(int i=0;i<N;i++){
		if (i>0 && t[i-1]==t[i]){
			ub[i] = t[i];
		}else{
			info[i] = t[i];
		}
		if (i<N-1 && a[i]==a[i+1]){
			ub2[i] = a[i];
		}else{
			info2[i] = a[i];
		}
	}
	
	for(int i=0;i<N;i++){
		if (info[i]==0 && info2[i]==0){
			ans = (ans * min(ub[i], ub2[i])) % MODP;
		}else if (info[i]>0 && info2[i]>0){
			if (info[i]!=info2[i]){
				ans = 0; break;
			}
		}else{
			if (info[i]>0){
				if (info[i] > ub2[i]){
					ans = 0; break;
				}
			}else{
				if (info2[i] > ub[i]){
					ans = 0; break;
				}
			}
		}
	}
	cout << ans << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 4992
// B - Traveling AtCoDeer Problem
#include <bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<(n);++i)

int main(){
	int N; cin>>N;
	int minA = INT_MAX, maxA = 0;
	rp(i, N){
		int a; cin>>a;
		minA = min(minA, a);
		maxA = max(maxA, a);
	}
	cout<< maxA - minA <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main()
{
	char ch;
	cin>>ch;
	if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
	{
		cout<<"vowel"<<endl;
	}
	else
	{
		cout<<"consonant"<<endl;
	}
	return 0;
}
 

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

using namespace std;

int main(){

    string s,t;
    cin >> s >> t;

    bool ans = false;

    for(int i = 0; i < s.size(); i++){
        if(s == t){
            ans = true;
            break;
        }
        s = s.back() + s.substr(0,s.size()-1);
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

struct Node {
  int parent, left, right;
};

const int N = 25;
const int NIL = -1;

int find_root(int n, Node T[]) {
  int root = 0;
  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) root = i;
  }
  return root;
}

void preorder(int id, Node T[]) {
  cout << " " << id;
  if (T[id].left != NIL) preorder(T[id].left, T);
  if (T[id].right != NIL) preorder(T[id].right, T);
}

void inorder(int id, Node T[]) {
  if (T[id].left != NIL) inorder(T[id].left, T);
  cout << " " << id;
  if (T[id].right != NIL) inorder(T[id].right, T);
}

void postorder(int id, Node T[]) {
  if (T[id].left != NIL) postorder(T[id].left, T);
  if (T[id].right != NIL) postorder(T[id].right, T);
  cout << " " << id;
}

int main() {
  int i, n, id, left, right;
  Node T[N];

  cin >> n;
  for (i = 0; i < n; i++) T[i].parent = NIL;
  // input
  for (i = 0; i < n; i++) {
    cin >> id >> left >> right;
    T[id].left = left;
    T[id].right = right;
    if (left != NIL) T[left].parent = id;
    if (right != NIL) T[right].parent = id;
  }

  int root = find_root(n, T);
  // output
  cout << "Preorder" << endl;
  preorder(root, T);
  cout << endl;
  cout << "Inorder" << endl;
  inorder(root, T);
  cout << endl;
  cout << "Postorder" << endl;
  postorder(root, T);
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 3084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 51


int main(){
  int h, w;
  char s[SIZE][SIZE];

  scanf("%d%d", &h, &w);

  bool ans = true;

  for(int i=0;i<h;i++){
    scanf("%s", s[i]);
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      bool ok = s[i][j] != '#';
      if(i > 0) ok |= s[i-1][j] == '#';
      if(i < h-1) ok |= s[i+1][j] == '#';
      if(j > 0) ok |= s[i][j-1] == '#';
      if(j < w-1) ok |= s[i][j+1] == '#';
      ans &= ok;
      debug(ok);
    }
  }

  if(ans)
    puts("Yes");
  else
    puts("No");

  return 0;
}


Measured memory_bytes: 256
#


def main():
    s = input()
    n = len(s)
    i = 0
    j = n - 1
    while i < j:
        if s[i] != s[j]:
            print("No")
            return
        i += 1
        j -= 1
    i = 0
    mae_last = (n - 1) // 2 - 1
    usiro_first = (n + 3) // 2 - 1
    while i < mae_last:
        if s[i] != s[mae_last]:
            print("No")
            return
        i += 1
        mae_last -= 1
    i = n - 1
    while i > usiro_first:
        if s[usiro_first] != s[i]:
            print("No")
            return
        i -= 1
        usiro_first += 1
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N,M,Q=map(int,input().split())
dp=[[0 for i in range(N+1)] for i in range(N+1)]
for i in range(M):
    a=list(map(int,input().split()))
    dp[a[0]][a[1]]+=1
for i in range(N,0,-1):
    count=0
    for j in range(1,N+1):
        count+=dp[i][j]
        if i==N:
            dp[i][j]=count
        else:
            dp[i][j]=dp[i+1][j]+count
p=[list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
    print(dp[p[i][0]][p[i][1]])

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

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int MAXN = 1e5+10;

int K;
llint A[MAXN];

llint max_X[MAXN], min_X[MAXN];

int main(void) {
  scanf("%d", &K);
  for (int i = 0; i < K; ++i)
    scanf("%lld", &A[i + 1]);

  max_X[K] = min_X[K] = 2;
  A[0] = 1;

  if (A[K] != 2) {
    printf("-1\n");
    return 0;
  }

  for (int i = K; i > 0; --i) {
    min_X[i - 1] = min_X[i];
    max_X[i - 1] = max_X[i] + A[i] - 1;

    if (min_X[i - 1] % A[i - 1] != 0)
      min_X[i - 1] += A[i - 1] - (min_X[i - 1] % A[i - 1]);
    if (max_X[i - 1] % A[i - 1] != 0) {
      max_X[i - 1] -= (max_X[i - 1] % A[i - 1]);
    }

    if (min_X[i - 1] > max_X[i - 1]) {
      printf("-1\n");
      return 0;
    }
//    TRACE(min_X[i - 1] _ max_X[i - 1]);
  }

  printf("%lld %lld\n", min_X[0], max_X[0]);
  return 0;
}



Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
multiset<int> st;
int a[112345];
int main(){
	int n; scanf("%d", &n);
	for(int i(1); i <= n + 1; ++i){
		scanf("%d", &a[i]);
	}
	long long ans = 0;
	for(int i(1), tmp; i <= n; ++i){
		scanf("%d", &tmp);
		if(tmp >= a[i]){
			ans += a[i]; tmp -= a[i];
			if(tmp >= a[i + 1]) ans += a[i+1], a[i + 1] = 0;
			else a[i + 1] -= tmp, ans += tmp;
		}
		else ans += tmp;
	}
	printf("%lld\n", ans);
	return 0;	
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    int ans = 0;
    FOR(i,0,n) {
        cin >> a[i];
        int day = 1;
        while (day <= d) {
            day += a[i];
            ans ++;
        }
    }
    cout << ans + x << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int a[] = new int[n];
        int key;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        if((n-1)%(k-1)==0){
            System.out.println((n-1)/(k-1));
        }
        else{
            System.out.println((n-1)/(k-1)+1);      
        }

    }
}


Measured memory_bytes: 50588
#include <stdio.h>

int main(void) {
	int x[10];
	int i;
	int flag = 0;
	
	for(i=1; i<6; i++){
		scanf("%d",&x[i]);
		if(x[i]==0){
			flag = i;
		}
	}
	printf("%d",flag);
	printf("\n");	
	return 0;
}


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

using namespace std;

int fun(char a){
	if(a=='r') return 'p';
	else if(a=='s') return 'r';
	else return 's';
}

int main(){

	long long int n, k,r,s,p,na,ok=0;


	string t,resp,aux = "rsp";

	cin >> n >> k >> r >> s >> p >> t;

	for(int i=0;i<k;i++){
		if(t[i]=='s') resp.push_back('r');
		if(t[i]=='r') resp.push_back('p');
		if(t[i]=='p') resp.push_back('s');
	}

	for(int i=k;i<n;i++){
		if(t[i]=='s') na = 0;
		if(t[i]=='r') na = 2;
		if(t[i]=='p') na = 1;

		if(resp[i-k]==aux[na]){
			na++;
			na%=3;
				if(i+k<n and fun(t[i+k])==aux[na]){
					na++;
					na%=3;
				}
		}
		resp.push_back(aux[na]);

	}


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

		if(t[i]=='r' and resp[i]=='p') ok+=p;
		if(t[i]=='s' and resp[i]=='r') ok+=r;
		if(t[i]=='p' and resp[i]=='s') ok+=s;


	}


	cout << ok << endl;

	return 0;
}

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

int main(void){
  double l,r;
  double la=0;
  double ra=0;
  double lb=0;
  double rb=0;
  double lc=0;
  double rc=0;
  double ld=0;
  double rd=0;
  while(cin>>l>>r){
    if(l>=1.1)la+=1;
    else if(l>=0.6)lb+=1;
    else if(l>=0.2)lc+=1;
    else ld+=1;
    if(r>=1.1)ra+=1;
    else if(r>=0.6)rb+=1;
    else if(r>=0.2)rc+=1;
    else rd+=1;
  }
  cout<<la<<" "<<ra<<endl;
  cout<<lb<<" "<<rb<<endl;
  cout<<lc<<" "<<rc<<endl;
  cout<<ld<<" "<<rd<<endl;
  return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;
const ll N = 2003;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	vector<ll> a(n);
	FOR(i,0,n){
		cin>>a[i];
	}
	SORT(a);
	vector<ll> b(n,a[0]);
	FOR(i,1,n){
		b[i] = b[i-1]+a[i];
	}
	ll ans;
	for(ans=n-2;ans>=0;ans--){
		if(a[ans+1]>b[ans]*2){
			break;
		}
	}
	pri(n-ans-1);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b,long long m) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %m;
        a = a * a %m;
        b >>= 1;
    }
    return res;
}

vector<vector<pair<int,int> > >adj,adj2;
int dis[1005];
int n;
int mm1[1005],mm2[1005];
void dfs(int ver)
{
    mm1[ver]=1;
    for(auto i:adj[ver])
    {
        if(!mm1[i.first])
        {
            dfs(i.first);
        }
    }
}

void dfs2(int ver)
{
    mm2[ver]=1;
    for(auto i:adj2[ver])
    {
        if(!mm2[i.first])
        {
            dfs2(i.first);
        }
    }
}

int cnt[1004];

void dik()
{
    priority_queue<pair<int,int> >qq;
    qq.push({0,1});
    dis[1]=0;
    while (!qq.empty())
    {
        pair<int,int>pp=qq.top();
        qq.pop();
        if(dis[pp.second]>pp.first)
            continue;
        for(auto i:adj[pp.second])
        {
            if(dis[i.first]<pp.first+i.second && mm1[i.first])
            {
                cnt[i.first]++;
                if(cnt[i.first]>2000)
                    return ;
                dis[i.first]=pp.first+i.second;
                qq.push({dis[i.first],i.first});
            }
        }
    }    
}


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    fill_n(dis,1005,-1e17);
    int m;
    cin>>n>>m;
    adj.resize(n+1);
    adj2.resize(n+1);
    int x,y,z;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        adj[x].push_back({y,z});
        adj2[y].push_back({x,z});
    }    
    dfs(1);
    dfs2(n);
    for(int i=1;i<=n;i++)
    {
        if(mm1[i]&&mm2[i])
        {
            mm1[i]=1;
        }
        else
        {
            mm1[i]=0;
        }        
    }
    dik();
    for(int i=1;i<=n;i++)
    {
        if(cnt[i]>2000)
        {
            cout<<"inf";
            return 0;
        }
    }
    cout<<dis[n];
}       


Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long int;
template <class T>
T mygcd(T a, T b){
    T m, n, r;
    a = (a > 0) ? a: -a;
    b = (b > 0) ? b: -b;
    if(a > b){
        m = a;
        n = b;
    }else{
        m = b;
        n = a;
    }
    
    while(n != 0){
        r = m % n;
        m = n;
        n = r;
    }
    
    return m;
}


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

    int ans0 = a[0];
    for(int i = 1; i < n; i++) ans0 = mygcd(ans0, a[i]);
    if(ans0 > 1){
        cout << "not coprime" << endl;
        return 0;
    }

    vector<bool> is_prime(1000010, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(int i = 2; i < 1000010; i++){
        if(is_prime[i]){
            for(int j = 2; i*j < 1000010; j++) is_prime[i*j] = false;
        }
    }
    vector<int> prime;
    for(int i = 2; i < 1000010; i++){
        if(is_prime[i]) prime.push_back(i);
    }
    
    vector<bool> is_used(1000010, false);
    bool ispair = true;
    for(int i = 0; i < n; i++){
        int tmp = a[i];
        if(!ispair) break;
        for(int j = 0; prime[j] <= tmp; j++){
            if(prime[j]*prime[j] > a[i]){
                if(is_used[tmp]){
                    ispair = false;
                    break;
                }else{
                    is_used[tmp] = true;
                    break;
                }
            }
            if(tmp % prime[j] == 0){
                if(is_used[prime[j]]){
                    ispair = false;
                    break;
                }else{
                    is_used[prime[j]] = true;
                    while(tmp % prime[j] == 0) tmp /= prime[j];
                }
            }
        }
    }

    if(ispair){
        cout << "pairwise coprime" << endl;
    }else{
        cout << "setwise coprime" << endl;
    }
    return 0; 
}

Measured memory_bytes: 7860
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        m: i32,
    }
    println!("{} {}", n * m, 2 * n + 2 * m);
}


Measured memory_bytes: 5032
n,q=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]
px=[list(map(int,input().split())) for i in range(q)]

#グラフの状態を調べる
def Graph(ab):
    G=[[] for i in range(n)]
    #up_G=[0]*n#up_G[i]=頂点iの親
    for a,b in ab:
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    return G

from collections import deque
def bfs(G,v,p):
    #(G,v,p)=(グラフ(木の情報),探索中の頂点,vの親)
    #vの子の頂点を決めて、vをpに移す
    q=deque()
    q.append((v,p))
    while q:
        V,P=q.popleft()
        for new_v in G[V]:
            #new_vが頂点の時はアウト
            if new_v==P:continue
            ans[new_v]+=ans[V]
            q.append((new_v,V))

G=Graph(ab)
ans=[0]*n
#print(G)

for p,x in px:
    ans[p-1]+=x
bfs(G,0,-1)
print(*ans)


Measured memory_bytes: 121048
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

long long C[110][110];

int main() {
  int N; scanf("%d", &N);
  REP(i, N) REP(j, N) { scanf("%lld", &C[i][j]); }
  long long ans = 0;
  REP(i, N) FOR(j, i+1, N) { ans += min(C[i][j], C[j][i]); }
  printf("%lld\n", ans);
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    REP(i, N) A[i] -= (i+1);
    map<int, int> m;
    REP(i, N)
    {
        if(m.find(A[i]) == m.end()) m.insert(make_pair(A[i], 0));
        m[A[i]]++;
    }
    sort(ALL(A));
    int b = A[N/2];
    ll ans = 0;
    REP(i, N) ans += abs(A[i]-b);
    cout << ans << endl;
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 10368
nums = []
nums = input().split()
N = int(nums[0])
Y = int(nums[1])
Right = 0
for a in range(N+1) :
    for b in range(N + 1 - a):
        c = N - a - b
        if( Y == 10000 * a + 5000 * b + 1000 *c ):
            if (N == (a + b + c)):
                Right = 1
                break
            else:
                continue
    else:
        continue
    break
if( Right == 0 ):
    print("-1 -1 -1")
else :
    print(a,b,c)

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

int main(){
  int n,x;
  cin>> n >> x;
  vector<int> l(n);
  for (int i=0; i<n; i++) cin>> l.at(i);
  
  int d=0;
  int ans=n+1; //最後まで座標xを超えなければans=n+1
  for (int i=0; i<n; i++){
    d+=l.at(i);
    if (x<d){
      ans=i+1;
      break;
    }
  }
  cout<< ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	A,B,C = inputMap()

	if A == B:
		if A != C:
			print("Yes")
			sys.exit()
	elif A == C:
		if A != B:
			print("Yes")
			sys.exit()
	elif B == C:
		if A != B:
			print("Yes")
			sys.exit()

	print("No")

if __name__ == "__main__":
	main()


Measured memory_bytes: 38596
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func main() {
	sc := NewScanner()
	A, B, C, D := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	sum := B - A + 1
	lcm := lcm(C, D)
	cNum := B/C - (A-1)/C
	dNum := B/D - (A-1)/D
	lcmNum := B/lcm - (A-1)/lcm
	fmt.Println(sum - (cNum + dNum - lcmNum))
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;
const ll N = 1e7+7,Mod = 1e3;

int main()
{
    ll n;cin>>n;
    n = n+n;
    ll Arr[n+2];
    for(int i=1;i<=n;i++)cin>>Arr[i];
    sort(Arr+1,Arr+n+1,greater<ll>());
    ll Res = 0;
    for(int i=1;i<=n;i+=2)
    {
        Res += min(Arr[i],Arr[i+1]);
    }
    cout<<Res<< "\n";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) cin>>a[i];
  int sum=0;
  rep(i,n) sum ^= a[i];
  rep(i,n) a[i] ^= sum;
  rep(i,n) cout<<a[i]<< " ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 3980
#include <stdio.h>
#include <iostream>

int main(void){
    int n;
    scanf("%d", &n);

    int s[10000];
    for(int i = 0; i < n; i++){
       scanf("%d", &s[i]);
    }

    int q;
    scanf("%d", &q);

    int t[10000];
    for(int i = 0; i < q; i++){
       scanf("%d", &t[i]);
    }
   
    int cnt = 0;
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if (t[i] == s[j]){
                cnt += 1;
                break;
            }
        }
    }

    printf("%d\n", cnt);
}



Measured memory_bytes: 3248
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	int tmp=-1;
	rep(i,4){
		if(n%10==tmp){
			cout<<"Bad"<<endl;
			return 0;
		}
		tmp=n%10;
		n=n/10;
	}
	cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

int main() {
	long long N, A, B;
	std::cin >> N >> A >> B;
	A--; B--;
	auto ab = std::abs(A - B);
	if (ab % 2 == 0) {
		std::cout << ab / 2 << std::endl;
		return 0;
	}
	auto min1 = std::min(N - A - 1, N - B - 1);
	auto min2 = std::min(A, B);
	std::cout << std::min(min1, min2) + 1 + ab / 2 << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
 
N = int(input())
s1 = list(map(int,input().split()))
M = int(input())
s2 = list(map(int,input().split()))
 
c1 = Counter(s1)
c2 = Counter(s2)
 
for k,v in c2.items():
    if k in c1:
        if v > c1[k]:
            print('NO')
            sys.exit()
    else:
        print('NO')
        sys.exit()
print('YES')

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,C;
int A[404],B[404];
ll mo=1000000007;
ll ppow[404][404];
ll ppowS[404][404];

ll dp[404][404];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>C;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	
	ppow[0][0]=1;
	for(i=1;i<=400;i++) {
		ppow[i][0]=1;
		FOR(j,400) ppow[i][j+1]=ppow[i][j]*i%mo;
	}
	for(i=0;i<=400;i++) {
		for(j=0;j<=400;j++) (ppowS[j+1][i]=ppowS[j][i]+ppow[j][i])%=mo;
	}
	
	
	dp[0][0]=1;
	FOR(i,N) {
		for(x=0;x<=C;x++) {
			for(y=0;x+y<=C;y++) {
				ll p=(ppowS[B[i]+1][y]-ppowS[A[i]][y])%mo;
				if(p<0) p+=mo;
				
				(dp[i+1][x+y] += dp[i][x] * p) %= mo;
			}
		}
	}
	cout<<dp[N][C]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	int n ; 
	cin >> n ;
	vector<int> d1(n) , d2(n) ; 
	for(int i = 0 ; i < n ; ++i) {
		cin >> d1[i] >> d2[i] ; 
	}
	for(int i = 0 ; i + 2 < n ; ++i) {
		if(d1[i]==d2[i] && d1[i+1]==d2[i+1] && d1[i+2] == d2[i+2] ) {
			cout << "Yes" ; 
			return 0 ; 
		} 
	}
	cout << "No" ; 
	return 0 ; 
}

Measured memory_bytes: 3656