akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

vector<string> all;
string s;
void rec(int n, int prev){
    if(s.size() == n){
        all.push_back(s);
        return;
    }
    for(int i = max(0, prev - 1); i <= min(prev + 1, 9); ++i){
        s += (i + '0');
        rec(n, i);
        s.pop_back();
    }
}

void solve(){
    for(int i = 1; i <= 9; ++i){
        all.push_back(to_string(i));
    }
    int numDigs = 2;
    const int N = 1e5;
    while(all.size() < N){
        for(int i = 1; i <= 9; ++i){
            s = (i + '0');
            rec(numDigs, i);
        }
        numDigs++;
    }
    int k;
    cin >> k;
    cout << all[k - 1] << endl;
}

int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;
    t = 1;
    while(t--)
        solve();

}


Measured memory_bytes: 11720
a,b=map(int,input().split())
a1=(a*100)//8
a2=((a+1)*100)//8
b1=b*10
b2=(b+1)*10
if (a*100)%8>0:
    a1+=1
if ((a+1)*100)%8>0:
    a2+=1
la=range(a1,a2)
lb=range(b1,b2)
l=list(set(la) & set(lb))
if len(l)==0:
    print("-1")
else:
   l.sort()
   print(l[0])

Measured memory_bytes: 38456
#include<iostream>
using namespace std;
int main(){
  int n[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;cin>>k;
  cout<<n[k-1];}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc090/tasks/abc090_b
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
  int A, B;
  cin >> A >> B;

  int num = 0;

  for (int i = A; i <= B; i++){
    int tmp = i, sum = 0;
    int j = 10000;
    
    while (tmp > 0){
      sum += tmp % 10 * j;
      tmp /= 10;
      j /= 10;
    }
    if (sum == i)
      num++;
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
int main()
{
string s,st;
int n;
cin >> n >> s >> st;
int ans=2*n;
for (int q=0;q<n;q++){
for (int i=0;i+q<n;i++){
if (i+q==n-1 && s[i+q]==st[i])
{
cout << n+q << endl;
return 0;
}
if (s[i+q]==st[i])
{
continue;
}
break;
}
}
cout << ans;
 
 
 
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	ll q, h, s, d; cin >> q >> h >> s >> d;
	ll mi1, mi2;
	mi1 = mi2=INF;
	for (ll i = 0; i <= 8; i++) {
		for (ll j = 0; j <= 4; j++) {
			for (ll k = 0; k <= 2; k++) {
				for (ll l = 0; l <= 1; l++) {
					if (i + 2 * j + 4 * k + 8 * l == 8) {
						mi1 = min(mi1, q*i + h * j + s * k + d * l);
					}
					if (i + 2 * j + 4 * k + 8 * l == 4) {
						mi2 = min(mi2, q*i + h * j + s * k + d * l);
					}
				}
			}
		}
	}
	ll out = 0; ll n; cin >> n;
	out += mi1 * (n / 2);
	if (n % 2) {
		out += mi2;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<iomanip>
#define pi 3.141592653589793238462643383279

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int a,b,h,m;
double w1=0.5,w2=6;

double min(double a,double b) {return a<b?a:b;}

double max(double a,double b) {return a>b?a:b;}

int main() {
	read(a),read(b),read(h),read(m);
	double jiao1=w1*(h*60.0+m*1.0),jiao2=w2*m*1.0;
	double jiajiao=max(jiao1,jiao2)-min(jiao1,jiao2);
	//std::cout<<jiajiao<<'\n';
	double hudu=jiajiao*pi/180.0;
	//std::cout<<std::fixed<<std::setprecision(20)<<hudu<<'\n';
	//std::cout<<cos(hudu)<<'\n';
	std::cout<<std::fixed<<std::setprecision(20)<<sqrt(a*a*1.0+b*b*1.0-2.0*a*1.0*b*1.0*cos(hudu));
	//std::cout<<()
	return 0;
}

Measured memory_bytes: 4228
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        int count = 0;
        for (int i = 0; i < arr.length - 2; i++) {
            if (arr[i] == 'A' && arr[i + 1] == 'B' && arr[i + 2] == 'C') {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main(){
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
 }

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#define ll long long int
using namespace std;
 
int main()
{
  ll n;
  cin>>n;
  ll k;
  cin>>k;
  vector <ll> arr;
  for(ll i=0;i<n;i++)
  {
  ll temp;
  cin>>temp;
  arr.push_back(temp);
 
  }
 
  vector <ll> ans(n,0);
  ans[0]=0;
 
  for(ll i=1;i<n;i++)
  {
      ll min=ans[i-1]+abs(arr[i]-arr[i-1]);
      ll temp=0;
      for(ll j=1;j<=k,i-j>=0;j++ )
      {
          if(j>k)
          break;
          temp=ans[i-j]+abs(arr[i]-arr[i-j]);
       //   cout<<temp<<" "<<i<<" "<<" "<<j<<" "<<k<<" "<<endl;
          if(min>temp)
          min=temp;

      }
      ans[i]=min;

  }
  
  
 // for(int i=0;i<n;i++)
 // cout<<ans[i]<<" ";
// cout<<endl;
  cout<<ans[n-1];
  cin>>n;
  return 0;
}

Measured memory_bytes: 4908
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a, b;
  cin >> a >> b;
  string s = a + b;
  int n = stoi(s);
  for (int i = 0; i < 318; i++)
  {
    if (i * i == n)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 0
n= int(input())
if n==1:
    print(0)
else:
    for a,b in factorization(n) :
        for i in range(1,10**12):
            if b < i:
                break
            else:
                b -= i
                ans += 1
    print(ans)

Measured memory_bytes: 9328
import sys
n=int(input())
word=[]
word.append('０')
for i in range(1,n+1):
    word.append(input())
    for j in range(0,i):
        if word[j]==word[i]:
            print('No')
            sys.exit()
        else:
            j+=1
    if (i>1)& (word[i-1][len(word[i-1])-1]!=word[i][0]):
        print('No')
        sys.exit()

print('Yes')

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

int main(){

  int n,i,len;
  cin >> n;
  string s;
  cin >> s;
  len=0;
  for(i=0;i<n;i++){
    if(s[i]==s[i+1]){
      continue;

    }else{
    len+=1;
  }
  }

  cout << len << endl;
  return 0;


}

Measured memory_bytes: 512
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;

typedef pair<int, int> P;



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

	int A, B, C;
	ll K;
	cin >> A >> B >> C >> K;
	int res = A - B;
	if (K % 2) res = -res;
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
	int l;
	int r;
	int h;
}a[200000];
ll c[200000]={0};
bool cmp(struct node a1,struct node a2)
{
	return a1.l<a2.l;
}
int main(void)
{
	int n,d,health;
	scanf("%d%d%d",&n,&d,&health);
	int i;
	for(i=0;i<n;i++)
	{
		int x,h;
		scanf("%d%d",&x,&h);
		a[i].l=x-d;
		a[i].r=x+d;
		int c=h/health;
		if(h%health!=0)
		{
			c++;
		}
		a[i].h=c;
	}
	sort(a,a+n,cmp);
	ll sum=0;
	int j=0;
	for(i=0;i<n;i++)
	{
		while(j<n&&a[i].r>=a[j].l)
		{
			j++;
		}
		ll ok;
		ok=a[i].h-c[i];
		if(ok<0) ok=0;
		sum+=ok;
		c[i]+=ok;
		c[j]-=ok;
		c[i+1]+=c[i];
	}
	printf("%lld",sum);
}

Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#include <vector>

#define MAX_H (400)
#define MAX_W (400)
#define SIZE_BUF (30)

using namespace std;

int main(int argc, char *argv[]) {
  // read inputs
  long H, W;
  char S[MAX_H][MAX_W], buf[SIZE_BUF];
  scanf("%ld %ld", &H, &W);
  fgets(buf, SIZE_BUF, stdin);
  for (long i = 0; i < H; i++) {
    for (long j = 0; j < W; j++) {
      S[i][j] = fgetc(stdin);
    }
    fgets(buf, SIZE_BUF, stdin);
  }
  // for (long i = 0; i < H; i++) {
  //   for (long j = 0; j < W; j++) {
  //     printf("%c", S[i][j]);
  //   }
  //   printf("\n");
  // }

  // dfs
  long gs[MAX_H][MAX_W];
  for (long i = 0; i < H; i++) {
    for (long j = 0; j < W; j++) {
      gs[i][j] = -1;
    }
  }
  long g = 0;
  vector<long> stack_i, stack_j, cntbs, cntws;
  const long dis[] = {1, 0, -1, 0}, djs[] = {0, 1, 0, -1};
  for (long i = 0; i < H; i++) {
    for (long j = 0; j < W; j++) {
      if (gs[i][j] < 0) {
        long cntb = 0, cntw = 0;
        stack_i.push_back(i);
        stack_j.push_back(j);
        gs[i][j] = g;
        if (S[i][j] == '#') {
          cntb++;
        } else {
          cntw++;
        }
        while (!stack_i.empty()) {
          const long i0 = stack_i.back(), j0 = stack_j.back();
          const char c0 = S[i0][j0];
          stack_i.pop_back();
          stack_j.pop_back();
          for (long k = 0; k < 4; k++) {
            const long i1 = i0 + dis[k], j1 = j0 + djs[k];
            if (i1 >= 0 && i1 < H && j1 >= 0 && j1 < W && gs[i1][j1] < 0) {
              const char c1 = S[i1][j1];
              if (c1 != c0) {
                stack_i.push_back(i1);
                stack_j.push_back(j1);
                gs[i1][j1] = g;
                if (S[i1][j1] == '#') {
                  cntb++;
                } else {
                  cntw++;
                }
              }
            }
          }
        }
        g++;
        cntbs.push_back(cntb);
        cntws.push_back(cntw);
      }
    }
  }
  // for (long i = 0; i < H; i++) {
  //   for (long j = 0; j < W; j++) {
  //     printf("%d ", gs[i][j]);
  //   }
  //   printf("\n");
  // }
  long ans = 0;
  for (long i = 0; i < g; i++) {
    ans += cntbs[i] * cntws[i];
    // printf("i = %d, cntb = %d, cntw = %d\n", i, cntbs[i], cntws[i]);
  }
  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int plugs = 1;
    while(true){
        if(b <= plugs){
            break;
        } else {
            plugs += a -1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
pos = [[0,0], [1,0]]
way = [[0,1], [0,1]]
ans = 0
w, h = map(int, input().split())
n = int(input())
li = list(map(int, input().split()))
for p in li:
    ni = pos[p][0]+way[p][0]
    nj = pos[p][1]+way[p][1]
    if p == 0:
        if nj >= w or ni >= h:
            way[p][0],way[p][1]=way[p][1],-way[p][0]
            ni = pos[p][0]+way[p][0]
            nj = pos[p][1]+way[p][1]
    else:
        if nj >= w-1 or ni >= h-1:
            way[p][0],way[p][1]=way[p][1],-way[p][0]
            ni = pos[p][0]+way[p][0]
            nj = pos[p][1]+way[p][1]
    pos[p][0] = ni
    pos[p][1] = nj
    if abs(pos[0][0]-pos[1][0])+abs(pos[0][1]-pos[1][1]) == 1:
        ans += 1
print(ans)


Measured memory_bytes: 5608
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 1ll<<60
using namespace std;
const int N=2e5+100;
const int M=4e5+100;
const int mod=1e9+7;

int main(){
	int n;
	string s1,s2;
	while(cin>>n){
		
		cin>>s1>>s2;
		LL ans=1;
		for(int i=0;i<n;i++){
			if(s1[i]==s2[i]){
				if(i==0)ans*=3;
				else{
					
					if(s1[i-1]==s2[i-1]){
						ans=(ans*2)%mod;
					}else{
						ans=ans;
					}
				}
			}else {
				if(i==0)ans*=6;
				else{
					if(s1[i-1]==s2[i-1]){
						ans=(ans*2)%mod;
					}else{
						ans=(ans*3)%mod;
					}
				}
				i++;
			}
			
			
		}
		cout<<ans<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    int x;
    scanf("%d", &x);// don't forget &
    while (x) {
        int y = x % 10;
        x /= 10;
        if (y == 7) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include<map>
#include<fstream>
#include<vector>
using namespace std;
int main()
{
	
	int t;
	string inputs;
	
	cin >> t;

	map<string, int> freq;
	freq.emplace("AC", 0);
	freq.emplace("WA", 0);
	freq.emplace("TLE", 0);
	freq.emplace("RE", 0);

	for (int i = 0; i < t; i++) {
		cin >> inputs;
		if (freq.end() != freq.find(inputs)) {
			freq.find(inputs)->second++;
		}

	}
		
	
		cout <<freq.find("AC")->first << " x " << freq.find("AC")->second<< endl;
		cout << freq.find("WA")->first << " x " << freq.find("WA")->second << endl;
		cout << freq.find("TLE")->first << " x " << freq.find("TLE")->second << endl;
		cout << freq.find("RE")->first << " x " << freq.find("RE")->second << endl;

}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)
#define REV(i, a, b) for (int i = a; i > (b); --i)
#define debug(a) cerr << #a << " " << a << endl
#define debug2(a, b) cerr << #a << " " << a << ", " << #b << " " << b << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double pi = 6.28318530717958623200;
  double r; cin >> r;
  cout << r*pi << endl;
}

Measured memory_bytes: 3784
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int m = fr.nextInt();
		int n = fr.nextInt();
		Integer[][] sum = new Integer[m][n];
		String[] mine = new String[m];
		for (int i=0; i<m; i++) {
			mine[i] = fr.nextLine();
		}
		for (int i=0; i<m; i++) {
			for (int j=0; j<n; j++) {
				if (mine[i].charAt(j) == '#') {
					continue;
				}
				sum[i][j] = 0;
				if (i>0 && j>0) {
					sum[i][j] += mine[i-1].charAt(j-1) == '#' ? 1 : 0;
					sum[i][j] += mine[i-1].charAt(j) == '#' ? 1 : 0;
					sum[i][j] += mine[i].charAt(j-1) == '#' ? 1 : 0;
				} else if (i>0) {
					sum[i][j] += mine[i-1].charAt(j) == '#' ? 1 : 0;
				} else if (j>0) {
					sum[i][j] += mine[i].charAt(j-1) == '#' ? 1 : 0;
				}
				if (i < m-1 && j < n-1) {
					sum[i][j] += mine[i+1].charAt(j+1) == '#' ? 1 : 0;
					sum[i][j] += mine[i+1].charAt(j) == '#' ? 1 : 0;
					sum[i][j] += mine[i].charAt(j+1) == '#' ? 1 : 0;
				} else if (i < m-1) {
					sum[i][j] += mine[i+1].charAt(j) == '#' ? 1 : 0;
				} else if (j < n-1) {
					sum[i][j] += mine[i].charAt(j+1) == '#' ? 1 : 0;
				}
				if (i < m-1 && j> 0) {
					sum[i][j] += mine[i+1].charAt(j-1) == '#' ? 1 : 0;
				}
				if (i > 0 && j < n-1) {
					sum[i][j] += mine[i-1].charAt(j+1) == '#' ? 1 : 0;
				}
			}
		}
		for (int i=0; i<m; i++) {
			for (int j=0; j<n; j++) {
				if (sum[i][j] == null) {
					System.out.print("#");
				} else {
					System.out.print(sum[i][j]);
				}
			}
			System.out.println();
		}
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 26628
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]

dp = [[0, 0, 0] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])

print(max(dp[-1]))


Measured memory_bytes: 105408
#include<bits/stdc++.h>
using namespace std;
string s;
bool lag,fla;
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
			lag=1;
		if(s[i]=='F'&&lag)
			fla=1;
	}
	if(fla)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 100000000

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

	int point = 0;
	int ans1 = -1, ans2 = -1;

	for (int i = 0; i < s.size()-2; i++) {
		if (s[point] == s[point + 1]) {
			ans1 = point+1;
			ans2 = point+2;
			break;
		} else if(s[point] == s[point + 2]){
			ans1 = point + 1;
			ans2 = point + 3;
			break;
		}
		point++;
	}

	if (s[0] == s[1]) {
		ans1 = 1;
		ans2 = 2;
	} else if (s[s.size() - 2] == s[s.size() - 1]) {
		ans1 = s.size() - 1;
		ans2 = s.size();
	}

	cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
#define MAX_N 500000
int bit_[MAX_N + 1], n_;

int sum(int i) {
  int s = 0;
  while (i > 0) {
    s += bit_[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  while (i <= n_) {
    bit_[i] += x;
    i += i & -i;
  }
}

signed main() {
  int n, q, com, x, y;
  cin >> n >> q;
  n_ = n;
  rep(_, q) {
    cin >> com >> x >> y;
    if (com) {
      cout << sum(y) - sum(x - 1) << endl;
    } else {
      add(x, y);
    }
  }
}



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

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int up[70][n+1];
    for (int i = 1; i <= n; i++) {
        cin >> up[0][i];
    }
    for (int i = 1; i < 70; i++) {
        for (int node = 1; node <= n; node++) {
            up[i][node] = up[i-1][up[i-1][node]];
        }
    }
    int pow[70];
    pow[0] = 1;
    for (int i = 1; i < 70; i++) {
        pow[i] = pow[i-1]*2;
    }
    int u = 1;
    while (k != 0) {
        int log = 0;
        while (pow[log+1] < k) {
            log++;
        }
        u = up[log][u];
        k -= pow[log];
    }
    cout << u << endl;
}
/*

 */

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

int main(){
  vector<char>vec1(3);
  vector<char>vec2(3);
  vector<char>vec3(3);
  
  for(int i=0;i<3;i++){
    cin>>vec1[i];
  }
   for(int i=0;i<3;i++){
    cin>>vec2[i];
  }
   for(int i=0;i<3;i++){
    cin>>vec3[i];
  }
  
  cout<<vec1[0]<<vec2[1]<<vec3[2]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c; cin >> a >> b >>c;
  vector<int> P(3);
  P={a,b,c};
  sort(P.begin(),P.end());
  
  if(P[0]+P[1]==P[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

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

    int n;
    cin >> n;

    if(n%1000 == 0){
    	cout << 0;
    } else {
    	cout << (1000 - n%1000);
    }

    return 0;
}


Measured memory_bytes: 3652
// 失敗するからこそ そこから立ち向かって行く強さがあって そんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/pavan/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;


int main(){
	FIO
	set<int> s;
	int a, b, c;cin >> a >> b >> c;
	s.insert(a);s.insert(b);s.insert(c);
	if(s.size() == 2)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
num = 0
cakes = []
for _ in range(h):
    row = input()
    a_row = []
    for r in row:
        if r=='.':
            a_row.append(r)
        elif r=='#':
            num+=1
            a_row.append(num)
    cakes.append(a_row)

for x in range(h):
    for y in range(w):
        if cakes[x][y] == '.':
            continue
        else:
            val = cakes[x][y]
            nx = x-1
            while(nx>=0)and(cakes[nx][y] == '.') :
                cakes[nx][y] = val
                nx -= 1
            nx = x+1
            while (nx<=h-1)and(cakes[nx][y] == '.'):
                cakes[nx][y] = val
                nx += 1

for x in range(h):
    for y in range(w):
        if cakes[x][y] == '.':
            continue
        else:
            val = cakes[x][y]
            ny = y-1
            while (ny>=0)and(cakes[x][ny]=='.'):
                cakes[x][ny] = val
                ny -= 1
            ny = y+1
            while(ny<=w-1)and(cakes[x][ny] == '.'):
                cakes[x][ny] = val
                ny += 1

for c in cakes:
    for s in c:
        print(str(s) + ' ', end='')
    print('')


Measured memory_bytes: 57560
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n, m, x;
	cin >> n >> m >> x;

	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));

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

		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}

	int min = (int)1e8;

	for (int i = 0; i < (1<<n); i++)
	{
		int price = 0;
		vector<int> sum(m, 0);

		for (int j = 0; j < n; j++)
		{
			if (i & (1<<j))
			{
				price += c[j];

				for (int k = 0; k < m; k++)
				{
					sum[k] += a[j][k];
				}
			}
		}

		int flg = 1;

		for (int k = 0; k < m; k++)
		{
			if (sum[k] < x) flg = 0;
		}

		if (flg)
		{
			if (min > price) min = price;
		}
	}

	if (min == (int)1e8) cout << -1 << endl;
	else cout << min << endl;

	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#define MIN(x,y)	((x)<(y)?(x):(y))
#define ABS(x)		((x)<0 ? -(x):(x))
typedef long long ll;

int main(){
    ll x,k,d,ans=0;
    scanf("%lld %lld %lld", &x, &k, &d);
    x=ABS(x);

    if( x / d > k ){ printf("%lld\n", x-(d*k)); return 0; }

    ll rem = x, remk = k;
    rem   = (x % d);
    remk -= (x / d);

    if( remk%2!=0 ){ ans = MIN(ABS(rem+d), ABS(rem-d)); }
    else           { ans = rem; }

    printf("%lld\n",ABS(ans));
    return 0;
}

Measured memory_bytes: 1724
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import System.IO.Unsafe
import Debug.Trace

solve :: Int -> Int -> B.ByteString -> Int
solve n k ss = maximum
  [ accums
    VU.! ((i + k') `min` (gn - 1))
    -    (if i - k' - 1 >= 0 then accums VU.! (i - k' - 1) else 0)
  | i <- [0 .. gn - 1]
  , let k' =
          if is0AtNthGroup i then ((k - 1) `div` 2) * 2 + 1 else (k `div` 2) * 2
  ]
 where
  bss = unsafePerformIO $ VU.freeze $ fst $ B.foldl'
    ( \(acc, i) ch ->
      (unsafePerformIO $ VM.write acc i (ch == '1') >> return acc, i + 1)
    )
    (unsafePerformIO $ VM.new n, 0)
    ss

  (_, irevstream, gn) = fix
    ( \f (bs, acc, g) -> if VU.length bs == 0
      then (bs, acc, g)
      else if not (VU.head bs)
        then
          let (zeros, other) = VU.span not bs
          in  f (other, VU.length zeros : acc, g + 1)
        else
          let (ones, other) = VU.span id bs
          in  f (other, VU.length ones : acc, g + 1)
    )
    (bss, [], 0)

  accums :: VU.Vector Int
  accums = unsafePerformIO $ VU.freeze $ (\(x, _, _) -> x) $ foldr'
    ( \k (acc, i, prev) ->
      let cur = prev + k
      in  cur
            `seq` ( unsafePerformIO $ (VM.write acc i cur >> return acc)
                  , i + 1
                  , cur
                  )
    )
    (unsafePerformIO $ VM.new gn, 0, 0)
    irevstream

  is0AtNthGroup n = if not (VU.head bss) then even n else odd n

main = do
  let readInt = fmap (second B.tail) . B.readInt

  nk <- V.unfoldrN 2 readInt <$> B.getLine

  ss <- B.getLine
  print $ solve (nk V.! 0) (nk V.! 1) ss


Measured memory_bytes: 23932
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }


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

  ll h,w,m; cin >> h >> w >> m;

	if (w*m >= h) cout << "Yes" << endl;
	else cout << "No" << endl;
}



Measured memory_bytes: 3612
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main(){
    string s, p;
    cin >> s >> p;
    int canmake;

    for (int i = 0; i < s.size(); i++)
    {
        canmake = 1;
        for (int j = 0; j < p.size(); j++)
        {
            if (s[(i + j)%(s.size())] != p[j])
            {
                canmake = 0;
                break;
            }else{
                if(j == p.size() - 1){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
            
            
        }
        
    }
    
    cout << "No" << endl;
    

    return 0;
}


Measured memory_bytes: 3224
import numpy as np

N = int(input())
tb = np.zeros((10, 10), dtype=int)

for n in range(1, N+1):
    n = str(n)
    lhs, rhs = int(n[0]), int(n[-1])
    tb[lhs][rhs] += 1


ret = 0
for lhs in range(1, 10):
    for rhs in range(1, 10):
       ret += tb[lhs][rhs] * tb[rhs][lhs]

print(ret) 



Measured memory_bytes: 21368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

//選択ソート（０オリジン）
int selectionSort(int A[], int N){
    int i,j,sw = 0,minj;
    for(i=0; i<N-1; i++){
        minj=i;
        for(j=i; j<N; j++){
            if(A[j] < A[minj]) minj=j;
        }
        swap(A[i], A[minj]);
        if(i != minj) sw++;
    }
    return sw;
}

int main() {
    int A[100], N, i, sw;

    scanf("%d", &N);
    for(i=0; i<N; i++) scanf("%d", &A[i]);

    sw = selectionSort(A, N);

    for(i=0; i<N; i++){
        if(i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;

}


Measured memory_bytes: 3208
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    let (r, c, n) = readl!(usize, usize, usize);
    let check = |x, y| {
        x == 0 || x == r || y == 0 || y == c
    };
    let po: Vec<_> = (0..n).map(|_| readl!(usize, usize, usize, usize))
        .filter(|&(x1, y1, x2, y2)| check(x1, y1) && check(x2, y2))
        .collect();

    let mut v = vec![Vec::new(); 4];
    for (k, &(x1, y1, x2, y2)) in po.iter().enumerate() {
        let mut add = |x, y| {
            if x == 0 {
                v[0].push((y, k));
            } else if y == c {
                v[1].push((x, k));
            } else if x == r {
                v[2].push((y, k))
            } else {
                v[3].push((x, k));
            }
        };
        add(x1, y1);
        add(x2, y2);
    }
    for i in 0..4 {
        v[i].sort();
        if i >= 2 {
            v[i].reverse();
        }
    }
    let mut stack = Vec::new();
    for v in &v {
        for &(_, e) in v {
            match stack.pop() {
                Some(t) if t == e => (),
                Some(t) => {
                    stack.push(t);
                    stack.push(e);
                },
                None => {
                    stack.push(e);
                }
            }
        }
    }
    if stack.len() == 0 {
        printfln!("YES");
    }  else {
        printfln!("NO");
    }
}



Measured memory_bytes: 16520
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define MN(a,b,c)  min(a,min(b,c))
#define pr         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
ll dolog(ll n)
{
    int y=1,x=0;
    while(y<=n){y*=2;x++;}
  x--;
  return x;
}
ll pow2(ll x)
{
    ll y=1;
    while(x--){y*=2;}
    return y;
}
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
   int n;cin>>n;
   vector <int> v(n);
   umap <int,int> freq;
   int z;
   f(i,n)
   {cin>>z;freq[z]++;
    if(freq[z]==1){v.pb(z);}
   }
   ll ans=0;
   sort(all(v));
   n=v.size();
   for(int i=0;i<n;i++)
   {
      for(int j=i+1;j<n;j++)
      {
        for(int k=j+1;k<n;k++)
        {
          if(v[k]<(v[i]+v[j]))
            {ans+=(freq[v[i]]*freq[v[j]]*freq[v[k]]);}
          else 
            break;
        }
      }
   }
   cout<<ans;
 }

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

int main(){
    int a,b,x;
    cin>>a>>b>>x;
    if(a>x){
        cout<<"NO"<<endl;
    }
    else if(a+b>=x){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string temp;
    while(cin>>temp){
        vector<string>tiya;
        vector<pii>gotiusa;
        tiya.push_back(temp);
    rep(i,7){
        string temp;
        cin>>temp;
        tiya.push_back(temp);
    }
    rep(i,8)rep(j,tiya[i].size())
        if(tiya[i][j]=='1')gotiusa.push_back(pii(7-i,j));
    int tate=0;
    int yoko=0;
    pii t=pii(-INF,INF),y=pii(-INF,INF);
    rep(i,gotiusa.size()){
        cmax(t.first,gotiusa[i].first);
        cmin(t.second,gotiusa[i].first);
        cmax(y.first,gotiusa[i].second);
        cmin(y.second,gotiusa[i].second);
    }
    tate=t.first-t.second;
    yoko=y.first-y.second;
    if(tate==3) puts("B");
    else if(yoko==3) puts("C");
    else if(yoko==1&&tate==1)puts("A");
    else if(tate==2&&yoko==1){
        int a = 0,b = 0;
        rep(i,gotiusa.size()){
            if(t.first==gotiusa[i].first)a=gotiusa[i].second;
            else if(t.second==gotiusa[i].first)b=gotiusa[i].second;
        }
            (a>b ? puts("D"):puts("F"));
    }
    else if(tate==1&&yoko==2){
        int a = 0,b = 0;
        rep(i,gotiusa.size()){
            if(y.first==gotiusa[i].second)a=gotiusa[i].first;
            else if(y.second==gotiusa[i].second)b=gotiusa[i].first;
        }
         (a>b ? puts("G"):puts("E"));
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll x = (n / 500);
    n -= 500 * x;
    ll y = n / 5;
    cout << (x * 1000 + y * 5) << "\n";
    return 0;
}

Measured memory_bytes: 256
def ip():
    return int(input())
    
def ipp():
    return map(int,input().split())
    
def sar():
    return list(ipp())
    
def pars(a):
    print(' '.join(list(map(str, a))))
    print('\r')
    
def parl(a):
    print('\r'.join(list(map(str, a))))
    print('\r')
    
#template ends   

if __name__=='__main__':
    T=1
    #T=int(input().strip())
    for _ in range(T):
        a,b = ipp()
        if a%b == 0:
            print(0)
        else:
            print(1)

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

int n;
int arr[100];
long double avg;
long double diff;
int main()
{
    while(cin >> n)
    {
        avg = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> arr[i];
            avg += arr[i];
        }
        avg /= n;
        diff = 1000;
        int res;
        for(int i = 0; i < n; i++)
        {
            if(abs(arr[i] - avg) < diff)
            {
                res = i;
                diff = abs(arr[i] - avg);
            }
        }

        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=get_nsp
ans=[]
S.each do|c|
  case c
  when "0" then
    ans.push(0)
  when "1" then
    ans.push(1)
  when "B" then
    ans.pop
  end
end
if ans==[]
    puts ""
else
    puts ans.join("")
end

Measured memory_bytes: 1788
#include <cstdint>
#include <iostream>

void Call_A_CirclePond(std::istream &input_stream) {
  input_stream.tie(0);
  std::ios::sync_with_stdio(false);
  try {
    double input;
    input_stream >> input;
    std::cout << (6.28318530717958623200 * input);
  } catch (...) {
    std::cerr << "ERROR: CallQuickSort()" << std::endl;
    throw;
  }
}

int main(int argc, char *argv[]) {
  try {
    Call_A_CirclePond(std::cin);
  } catch (...) {
    std::cerr << "ERROR: main()" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3832
#include <iostream>
#include <string>
using namespace std;
string s, t, u;
int a, b;
int main()
{
	cin >> s >> t >> a >> b;
	cin >> u;
	if (u == s)
		a--;
	else if (u == t)
		b--;
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		long min = ((long)N-1) * (long)A + (long)B;
		long max = (long)A + ((long)N-1) * (long)B;

		if(A!=B && N==1){
			System.out.print(0);
		}else if(A>B){
			System.out.print(0);
		}else if(A<=B){
			System.out.print(max-min+1);
		}

	}

}

Measured memory_bytes: 21844
import math
N = input()
nums= list(map(int,input().split(" ")))
flag  =True
for num in nums:
    if num % 2 == 0:
        if num % 3== 0 or num % 5 == 0:
            pass
        else:
            flag = False

if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38384
#include <stdio.h>
int main()
{
	int r,d,x,a[10];
	scanf("%d %d %d",&r,&d,&x);
	for(int i=0;i<10;i++)
	{
		x=x*r-d;
		a[i]=x;
	}
	for(int i=0;i<10;i++)
	{
		printf("%d\n",a[i]);
	}
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>

using namespace std;


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

    vector<string> S;
    for(int i=0;i<N;++i)
    {
        string n;
        cin >> n;
        S.push_back(n);
    }

    int AC=0,WA=0,TLE=0,RE=0;
    
    for(auto&s:S)
    {
        if(s == "AC")
        {
            ++AC;
        }
        else if(s == "WA")
        {
            ++WA;
        }
        else if(s == "TLE")
        {
            ++TLE;
        }
        else if(s == "RE")
        {
            ++RE;
        }
        else
        {
            continue;
        }
        
    }

    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x "<< TLE << endl;
    cout << "RE x " << RE  << endl;
	
  	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  M mp;
  rep(i, n - 1){
    int x;
    cin >> x;
    mp[x]++;
  }
  rep(i, n){
    cout << mp[i + 1] << endl;
  }

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
using ll = long long;
typedef pair<int, int> Pair;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for (int i = 2; i < n; i++) {
    int cost1 = abs(h[i] - h[i - 1]);
    int cost2 = abs(h[i] - h[i - 2]);
    dp[i] = min(dp[i - 1] + cost1, dp[i - 2] + cost2);
  }
  
  int ans = dp[n - 1];
  cout << ans << endl;
}


Measured memory_bytes: 4020
#include <stdio.h>
 
int main () {
 
    int a, b, d, r;
    double f;
 
    scanf("%d", &a); scanf("%d", &b);
 
    d = a / b;
    r = a % b;
    f = a * 1.0 / b * 1.0;
 
    printf("%d %d %f\n", d, r, f);
 
    return 0;
 
}


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

using namespace std;
bool sev[1000000+7] = {};
int cnt[1000000+7] = {};
int main()
{
    int n; cin >> n;
    vector<int> v;
    for(int i =0; i < n; i++)
    {
       int x; cin >> x;
       cnt[x]++;
       v.push_back(x);
    }
    sort(v.begin(), v.end());
   for(int i =0; i < n; i++)
   {
      if(!sev[v[i]])
      {
         if(cnt[v[i]] >= 2)
            sev[v[i]] = true;
         for(int j = v[i]*2; j <= v[n-1] ; j+=v[i])
            sev[j] = true;
      }
   }
   int res = 0;
   for(int i = 0; i < n ; i++)
   {
      if(!sev[v[i]])
         res++;
   }
   cout << res;

}


Measured memory_bytes: 8812
def main():
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    N = int(input())

    tasks = []
    for _ in range(N):
        tasks.append(tuple(map(int, input().split())))  # (A,B)
    tasks.sort(key=itemgetter(1))

    t = 0
    cond = True
    for a, b in tasks:
        t += a
        if t > b:
            cond = False
            break

    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
typedef signed long long int ll;
#define ALL(a)  (a).begin(),(a).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//Union find,添字のz


ll par[100005];//iの一つ上にあるやつ
ll r[100005];//iの属する塊，グループの高さ"（計算を速くするため）
ll s[100005];//大きさ
void init(ll n){
    for(int i=0;i<n;i++){
        par[i]=i;
        r[i]=0;
        s[i]=1;
    }
}//全部バラバラの状態

ll find(ll x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}//一番上の付け根を求める

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    ll sum=s[find(x)]+s[find(y)];
    s[find(x)]=sum;
    s[find(y)]=sum;
    if(r[x]<r[y]){
        par[x]=y;
        
    }else{
        par[y]=x;
        if(r[x]==r[y]) r[x]++;
    }
}//xとyのグループを付け根でくっつける

bool same(ll x,ll y){
    return find(x)==find(y);
}//同じグループにいるかどうか

int main(){
    ll n,m;
    cin>>n>>m;
    ll a[100005],b[100005];
    rep(i,m){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        
    }
    
    init(n);
    ll ans[100005]={0};//通れる組
    ans[m]=0;
    for(ll i=m-1;i>0;i--){
        if(find(a[i])==find(b[i])){
            //cout<<"iminasi"<<endl;
            ans[i]=ans[i+1];
            //cout<<i<<" "<<ans[i]<<endl;
            continue;
        }
        //cout<<"sa*sb"<<" "<<s[a[i]]*s[b[i]]<<endl;
        ans[i]=ans[i+1]+s[find(a[i])]*s[find(b[i])];
        //cout<<i<<" "<<ans[i]<<endl;
        unite(a[i],b[i]);
    }
    
    for(int i=1;i<=m;i++){
        ans[i]=(n*(n-1)/2)-ans[i];
        cout<<ans[i]<<endl;
    }
    return 0;
}


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

int main() {
int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> A(Q);
  vector<int> B(N,0);
  for(int i=0;i<Q;i++){
  cin>>A.at(i);
  }

  int k; 
  for(int i=0;i<Q;i++){
  k=A.at(i)-1;
    B.at(k)++;
  }

    for(int i=0;i<N;i++){
  if(B.at(i)>Q-K){
cout<<"Yes"<<endl;
  }
  else{
cout<<"No"<<endl;
  }
  }

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
unordered_map<int, int> freq;
string s;
char c;
long long nr, res, p(1);
int main() {
    DAU
    cin >> s;
    freq[0] = 1;
    reverse(s.begin(), s.end());
    for (const char& c : s) {
        nr = (nr + (c - '0') * p) % 2019;
        p = (p * 10) % 2019;
        res += freq[nr];
        ++freq[nr];
    }
    cout << res;
    PLEC
}


Measured memory_bytes: 3736