akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

// nをある偶数としたときn^n+1=1となる性質を用いて、0からxまでの排他的論和0^1^...^xを求める
ll func(ll x){
    // 2のn乗なので必ずn^n+1偶数セット+ x(このとき常に100...0の形) ⇒ 000...と100...の排他的論理和
    if(x%4==0) return x;
    // n^n+1奇数セットのみ ⇒ 1
    if(x%4==1) return 1;
    // n^n+1奇数セット + x(このとき常に111...10の形) ⇒ 0とxの排他的論理和
    if(x%4==2) return x+1;
    // n^n+1偶数セットのみ ⇒ 0
    return 0;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    ll a,b; cin >> a >> b;
    // func(b)=0^1^...^a-1^a^a+1^...^b=func(a-1)^f(a,b)からf(a,b)=～に変形
    ll ans = func(a-1)^func(b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, a, b = gets.strip.split.map(&:to_i)

def digit_sum n
    sum = 0
    while n > 0 do
        sum += n % 10
        n /= 10
    end
    sum
end

ans = (1..n)
        .map { |i| [i, digit_sum(i)] }
        .select { |d| a <= d[1] && d[1] <= b }
        .reduce(0) { |sum, d| sum + d[0] }

puts ans

Measured memory_bytes: 2172
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String A=sc.next();
String B=sc.next();
if(A.length()>B.length()){
    out.println("GREATER");
}else if(A.length()<B.length()){
    out.println("LESS");
}else{
int n=A.length();
int[] a=new int[n];
int[] b=new int[n];
    for (int i = 0; i < n; i++) {
        a[i]=Integer.parseInt(Character.toString(A.charAt(n-1-i)));
        b[i]=Integer.parseInt(Character.toString(B.charAt(n-1-i)));
    }
    int c=0;
    for (int i =n-1; i >=0; i--) {
        c=a[i]-b[i];
        if(c>0){
            out.println("GREATER");
        break;
        }else if(c<0){
            out.println("LESS");
        break;
        }
    }
    if(c==0)out.println("EQUAL");
}
}
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

const int MAXN = 1001010;

long long fac[MAXN], finv[MAXN], inv[MAXN];

// 前処理 O(n)
void math_init(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(long long i = 2; i < MAXN; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算 O(1)
long long COM(long long n, long long k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


// before your coding, you have to write a line "math_init()"
int main() {
  
  lint n, k; cin >> n >> k;
  math_init();
  
  lint ans = 0;
  for(lint i = 0; i <= min(n-1,k); i++) {
    ans += COM(n-1,i) * COM(n, i) % MOD;
    ans %= MOD;
  }

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


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

int main() {
  int N , M ; 
  cin >> N >> M ; 
  
  vector<bool> broken(N+1);
  
  rep(i,M){
    int a ; 
    cin >> a ; 
    broken.at(a) = 1 ; 
  }
  
  vector<int> dp(N+2) ;
  const int mod = 1000000007 ; 
  dp[N] = 1 ; 
  
  for(int i = N-1 ; i >=0 ; i--){
    if(broken.at(i)){
      dp.at(i) = 0 ; 
      continue ; 
    }
    dp.at(i) = (dp.at(i+1) + dp.at(i+2)) % mod ;
  }
  cout << dp.at(0) << endl ; 
  return 0 ; 

}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  set<int> s;
  rep(i, n){
    int tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  cout<<(s.size()+1)/2*2-1 <<endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] obs = new int[N][3];
		for (int i = 0; i < N; ++i) {
			obs[i][0] = sc.nextInt();
			obs[i][1] = sc.nextInt();
			obs[i][2] = sc.nextInt();
		}
		sc.close();

		int firstNonZero = 0;
		int minX = obs[0][0], maxX = obs[0][0];
		int minY = obs[0][1], maxY = obs[0][1];
		for (int i = 1; i < N; ++i) {
			if(obs[0][2] == 0 && obs[i][2] != 0 && firstNonZero == 0)
				firstNonZero = i;
			if (minX > obs[i][0])
				minX = obs[i][0];
			else if (maxX < obs[i][0])
				maxX = obs[i][0];
			if (minY > obs[i][1])
				minY = obs[i][1];
			else if (maxY < obs[i][1])
				maxY = obs[i][1];
		}

		int[] ans = new int[3];
		for (int x = minX; x <= maxX; ++x) {
			for (int y = minY; y <= maxY; ++y) {
				int h = Math.abs(obs[firstNonZero][0] - x) + Math.abs(obs[firstNonZero][1] - y) + obs[firstNonZero][2];
				boolean flag = true;
				for (int i = 0; i < N; ++i) {
					int tmpH = Math.max(h - Math.abs(obs[i][0] - x) - Math.abs(obs[i][1] - y), 0);
					if (tmpH != obs[i][2]) {
						flag = false;
						break;
					}
				}
				if (flag) {
					ans[0] = x;
					ans[1] = y;
					ans[2] = h;
					break;
				}
			}
		}

		System.out.println(String.format("%d %d %d", ans[0], ans[1], ans[2]));
	}
}


Measured memory_bytes: 22740
import java.util.*;

public class Main {

    static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}

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

        System.out.println(A * B);

    }

}

Measured memory_bytes: 35740
ma = lambda :map(int,input().split())
ni = lambda:int(input())

n,m = ma()
H = list(ma())
Hm = [True]*n
ab = []
tr = [[] for i in range(n)]
for i in range(m):
    a,b = ma()
    tr[a-1].append(b-1)
    tr[b-1].append(a-1)
    if H[a-1] > H[b-1]:
        Hm[b-1] = False
    elif H[a-1] < H[b-1]:
        Hm[a-1] =False
    else:
        Hm[b-1] = False
        Hm[a-1] = False
ans = 0
for f in Hm:
    if f:ans+=1
print(ans)


Measured memory_bytes: 30212
#include <iostream>
#include <bits/stdc++.h>
#define mod 998244353
typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

ll fact[1000006], inv[1000006];

ll fp(ll base, ll exp)
{
    if (exp == 0)
        return 1;
    ll ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void calcFacAndInv(ll n)
{
    fact[0] = inv[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) ;
        inv[i] = fp(fact[i], mod - 2);
    }
}

ll ncr(ll n, ll r)
{
    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}

ll npr(ll n, ll r)
{
    return (fact[n] * inv[n - r]) % mod;
}

long double  NCR(int n, int m){
    long double res = 1;
    m = min(m, n - m);
    for(int i = 0; i < m; i++){
        res = res * ( n - i) / (i + 1);
 }
    return res;
}
ll tol(string a){
    ll res=0;
    while(a[0]=='0'){
        a.erase(a.begin());
    }
    if(a=="")a="0";
    for(int i=0; i<a.size(); i++){
        res*=10; res+=a[i]-'0';
    }
    return res;
}
int check(string a, string b){
    for(int i=0; i<a.size(); i++){
        if(a[i]>b[i])return 1;
        if(b[i]>a[i])return -1;
    }
    return 0;
}
class data{
public:
    ll v,d,p;
    data(){}
    data(ll vv, ll dd, ll pp){
        v=vv;  d=dd; p=pp;
    }
};

int primeFactors(int n)
{
    ll c=0;
    while (n % 2 == 0)
    {
        c++;
        n = n/2;
    }
    for (int i = 3; i*i <= n; i = i + 2)
    {
        while (n % i == 0)
        {
            c++;
            n = n/i;
        }
    }
    if (n > 2)
        c++;
    return c;
}

void lcs(string a, string b){
    a='.'+a; b='.'+b;
    int n=a.size(), m=b.size();
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=1; i<n; i++){
        for(int y=1; y<m; y++){
            if(a[i]==b[y])dp[i][y]=1+dp[i-1][y-1];
            else dp[i][y]=max(dp[i-1][y], dp[i][y-1]);
        }
    }
    int r=n-1, c=m-1;
    string res="";
    while(r>0 && c>0){
        if(dp[r][c]>max(dp[r-1][c], dp[r][c-1]))
        {
            res+=a[r]; c--; r--;
        }
        else if(dp[r][c-1]>dp[r-1][c])c--;
        else r--;
    }
    reverse(res.begin(),res.end());
    cout<<res<<'\n';
    return ;
}

int main()
{
    Fastio();
    string a,b; cin>>a>>b;
    lcs(a,b);

    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll k;
  cin >> k;
  ll ans = -1, now = 7;
  rep(i, 1e6) {
    
    if(now%k==0){
      cout << i+1 << endl;
      return 0;
    }
    now *=10;
    now += 7;
    now %= k;
  }
  cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 3524
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    if (s == "SUN") cout << 7 << '\n';
    else if (s == "MON") cout << 6 << '\n';
    else if (s == "TUE") cout << 5 << '\n';
    else if (s == "WED") cout << 4 << '\n';
    else if (s == "THU") cout << 3 << '\n';
    else if (s == "FRI") cout << 2 << '\n';
    else if (s == "SAT") cout << 1 << '\n';
    return 0;
}


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

using namespace std;

int main(){
  int h, w;

  cin >> h >> w;

  vector<string> data;
  string s;
  for (int i = 0; i < h; i++){
    cin >> s;
    data.push_back(s);
  }
  /*
  for (int i; i < h; i++){
    cout << data[i] << endl;
  }
  */

  /*
  cout << data[1][1] << endl;
  cout << data[-1][0] << endl;
  cout << data[h][w] << endl;
    cout << data[0][-1] << endl;

  */

  bool ispossible = true;
  //bool inc = false;
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j ++){
      if (data[i][j] == '#'){
        //inc = true;
        if (i == 0 && j == 0){
          ispossible = ((data[i][j+1] == '#') || (data[i+1][j] == '#'));
        }else if (i == 0 && j == w-1){
          ispossible = ((data[i][j-1] == '#') || (data[i+1][j] == '#'));
        }else if (i == h-1 && j == w-1){
          ispossible = ((data[i][j-1] == '#') || (data[i-1][j] == '#'));
        }else if (i == h-1 && j == 0){
          ispossible = ((data[i][j+1] == '#') || (data[i-1][j] == '#'));
        }else if (i == 0){
          ispossible = ((data[i+1][j] == '#') || (data[i][j+1] == '#') || (data[i][j-1] == '#'));
        }else if (i == h-1){
          ispossible = ((data[i-1][j] == '#') || (data[i][j+1] == '#') || (data[i][j-1] == '#'));
        }else if (j == 0){
          ispossible = ((data[i-1][j] == '#') || (data[i][j+1] == '#') || (data[i+1][j] == '#'));
        }else if (j == w-1){
          ispossible = ((data[i-1][j] == '#') || (data[i][j-1] == '#') || (data[i+1][j] == '#'));
        }else{
          ispossible = ((data[i-1][j] == '#') || (data[i][j+1] == '#') || (data[i][j-1] == '#') || (data[i+1][j] == '#'));
        }
      }
      if (!ispossible) break;
    }
    if (!ispossible) break;
  }

  if (ispossible){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair


int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    int ans = 0;
    int n, T;
    int st = 0, fin = 0;
    scanf("%d%d", &n, &T);
    while(n--)
    {
        int x;
        scanf("%d", &x);
        if (x <= fin)
            fin = x + T;
        else
        {
            ans += fin - st;
            st = x;
            fin = x + T;
        }
    }
    ans += fin - st;
    printf("%d\n", ans);


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b){
            System.out.println("a < b");
        }
        else if(a > b){
            System.out.println("a > b");
        }
        else if(a == b){
            System.out.println("a == b");
        }
    }
}


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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  for (char c : s) {
    cout << char((c - 'A' + n) % 26 + 'A');
  }

  return 0;
}


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

#define MAX_N 100000
long long N, C, X[MAX_N], V[MAX_N];
long long R0, R1;

vector<pair<int, long long>> M;

long long solve() {
  long long acc = 0;
  M.push_back(make_pair(-1, acc));
  for(int i = 0; i < N; ++i) {
    acc += V[i]; acc -= X[i] - (i == 0 ? 0 : X[i - 1]);
    if(M.back().second < acc) M.push_back(make_pair(i, acc));
  }
  long long res = M.back().second;
  acc = 0;
  for(int i = N - 1; i >= 0; --i) {
    if(M.back().first == i) M.pop_back();
    acc += V[i]; acc -= 2 * ((C - X[i]) - (i == N - 1 ? 0 : (C - X[i + 1])));
    res = max(res, M.back().second + acc);
  }
  return res;
}

int main() {
  cin >> N >> C;
  for(int i = 0; i < N; ++i) cin >> X[i] >> V[i];
  R0 = solve();
  reverse(X, X + N); reverse(V, V + N);
  for(int i = 0; i < N; ++i) X[i] = C - X[i];
  R1 = solve();
  cout << max(R0, R1) << endl;
  return 0;
}


Measured memory_bytes: 3956
#include <iostream>
using namespace std;
int main(void){
    int N, A, max, min;
    cin >> N;
    cin >> A;
    min = A;
    max = A;
    for(int i=1; i<N;i++){
        cin >> A;
        min = (A < min) ? A : min;
        max = (A > max) ? A : max;
    }
    cout << abs(max-min) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int collatz(int x){
    if(x % 2 == 0){
        return x / 2;
    }
    else{
        return x * 3 + 1;
    }
}
int main(void){
    int N;
    cin >> N;
    int h[N];
    for(int i=0;i<N;i++)cin>>h[i];
    
    bool OK = false;
    int ans = 0;
    while(!OK){
        OK = true;
        for(int i=0;i<N;i++){
            if(h[i] > 0){
                for(int j=i;j<N;j++){
                    if(h[j] > 0)h[j]--;
                    else break;
                }
                OK = false;
                ans ++;
                break;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3156
//
//  main.cpp
//  ITP1_7-B
//
//  Created by ?????¶??? on 15/8/15.
//  Copyright (c) 2015??´ ?????¶???. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {

    int n,x;
    
    while (true) {
        cin >> n >> x;
        
        if (n == 0 && x == 0){
            break;
        }
        
        vector<vector<int> > numbers;
        
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                for (int k = 1; k <= n; k++) {
                    
                    if (i + j + k == x){
                        
                        if (i == j || i == k || j == k) {
                            continue;
                        }
                       
                        
                        
                        bool isMatch = false;
                        
                        // ????????????????????°???????????????????????\?????????
                        if (numbers.size() > 0){

                            for (int m = 0; m < (int)numbers.size(); m++) {
                                
                                int judge = 0;

                                
                                for (int n = 0; n < 3; n++) {
                                    
                                    if (i == numbers[m][n] || j == numbers[m][n] || k == numbers[m][n]){
                                        judge++;
                                    }
                                }
                                
                                // ???????????£??????????????????????????????????????????
                                if (judge > 2){
                                    isMatch = true;
                                    break;
                                }
                            }
                            
                        }
                         
                        
                        if (!isMatch) {

                            numbers.push_back({i, j, k});
                            
//                            printf("%d + %d + %d = %d ??\??????\n", i, j, k, x);
                        }else{
//                            printf("%d %d %d ????????????\n", i, j, k);
                        }
                        
                       
                    }
                         
                    
                }
            }
        }
        
        printf("%d\n", static_cast<int>(numbers.size()));
        
        
    }
    
    
    return 0;
}

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

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

  int n,x,y;

  std::cin >> n >> x >> y;

  int c[2000] = {};
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int d = std::min(j - i, std::abs(x - 1 - i) + 1 + std::abs(y - 1 - j));
      ++c[d];
    }
  }

  for (int k = 1; k < n; ++k) {
    std::cout << c[k] << "\n";
  }
  std::cout << std::flush;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> dis = new List<int>();
            for(int i = 0; i < 5; i++)
            {
                dis.Add(int.Parse(Console.ReadLine()));
            }
            int k = int.Parse(Console.ReadLine());

            for(int i = 0; i < 4; i++)
            {
                for(int j = 1; j <= 4 - i; j++)
                {
                    if(Math.Abs(dis[i] - dis[j+i]) > k)
                    {
                        Console.WriteLine(":(");
                        return;
                    }
                }
            }
            Console.WriteLine("Yay!");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    vector<int>num(3);
    rep(i,3) cin >> num[i];
    sort(all(num));
    int d=2*num[2]-num[1]-num[0];
    if(d%2==0){
        cout << d/2 <<endl;
    }
    else{
        cout << (d+1)/2 +1 << endl;
    }
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    cin >> s;

    string res = "";

    for (int i = 0; i < s.size(); i += 2)
    {
        res += s[i];
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 592
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]

# 元々の黒マスの数を数える
black = 0
for g in G:
    black += g.count("#")

# コスト管理
C = [[-1] * W for i in range(H)]
C[0][0] = 0

# queue準備
que = deque()
que.append((0, 0))

# BFS
direction = [(0, 1), (1, 0), (0, -1), (-1, 0)]
while que:
    nh, nw = que.pop()
    for dh, dw in direction:
        # 例外条件
        if not 0 <= nh + dh < H:
            continue
        if not 0 <= nw + dw < W:
            continue
        if G[nh + dh][nw + dw] == "#":
            continue
        if C[nh + dh][nw + dw] > 0:
            continue

        C[nh + dh][nw + dw] = C[nh][nw] + 1
        que.appendleft((nh + dh, nw + dw))

print(H * W - C[H - 1][W - 1] - black - 1 if C[H - 1][W - 1] > 0 else -1)


Measured memory_bytes: 3316
a,b,k = map(int,input().split())
if (b-a+1) <= 2*k:
    for k in range(a,b+1):
        print(k)
else:
    for i in range(a,a+k):
        print(i)
    for j in range(b-k+1,b+1):
        print(j)

Measured memory_bytes: 3060
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)


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


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

  int rain = 0, sun = 0;
  rep(i,3) {
    if(s.at(i)=='R')
      rain++;
  }
  if(rain>1){
    if(s.at(1)=='S')
      rain = 1;
  }

  cout << rain << endl;

  return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner (System.in);

    int x = scan.nextInt();
    int y = scan.nextInt();
    int z = scan.nextInt();
    int change;

  change = x;
    x = y;
    y = change;

    change = x;
    x = z;
    z = change;

    System.out.println(x+" "+y+" "+z);
  }
}


Measured memory_bytes: 23892
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *p, const void *q)
{
	return *(int*)p - *(int *)q;
}

int main(void)
{
	int i;
	int a[10];
	int n;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &a[i]);
	}
	
	n = sizeof(a) / sizeof(int);
	qsort(a, n, sizeof(int), cmp);
	
	for (i = 9; i > 6; i--){
		printf("%d\n", a[i]);
	}
	
	return (0);
}

Measured memory_bytes: 604
using System;

namespace ITP1_2_B
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split(' ');
			int a = int.Parse(vs[0]);
			int b = int.Parse(vs[1]);
			int c = int.Parse(vs[2]);

			if(a < b && b < c) {
				Console.WriteLine("Yes");
			}
			else {
				Console.WriteLine("No");
			}
		}
	}
}



Measured memory_bytes: 15940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX_N 100000

int main() {
  string S, T;
  cin >> S;
  cin >> T;

  int ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] != T[i]) ans++;
  }

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


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

const int mod = 1e9+7;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<pair<int, int>> s(N);
    ll ac[N+1];
    for(int i=0;i<N;++i) cin >> s[i].first >> s[i].second;
    sort(s.begin(), s.end());
    ac[0] = 0;
    for(int i=1;i<=N;++i) {
        ac[i] = ac[i-1]+s[i-1].second;
    }
    int ans;
    for(int i=1;i<=N;++i) {
        if(K <= ac[i]) {
            ans = s[i-1].first;
            break; 
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
const int MAX = 100000;
const int INFTY = (1 << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
	queue<int> q;
	q.push(s);
	V[s] = true;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		out.push_back(u);
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			indeg[v]--;
			if (indeg[v] == 0 && !V[v]) {
				V[v] = true;
				q.push(v);
			}
		}
	}
}

void toposort() {
	for (int i = 0; i < N; i++)
		indeg[i] = 0;
	for (int u = 0; u < N; u++)
		for (int i = 0; i < G[u].size(); i++) {
			int v = G[u][i];
			indeg[v]++;
		}
	for (int u = 0; u < N; u++)
		if (indeg[u] == 0 && !V[u]) bfs(u);
	for (list<int>::iterator it = out.begin(); it != out.end(); it++)
		cout << *it << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int s, t, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++)
		V[i] = false;
	for (int i = 0; i < M; i++) {
		cin >> s >> t;
		G[s].push_back(t);
	}
	toposort();
	return 0;
}


Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

const u64 B = 100'000'007ULL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  V<pair<size_t, string>> S(N);
  REP(i, N) {
    string s;
    cin >> s;
    S[i] = {s.size(), s};
  }
  sort(S.begin(), S.end());
  map<pair<int, u64>, int> mp;
  i64 ans = 0;
  REP(i, N) {
    int len = S[i].first;
    const string& ss = S[i].second;
    V<int> char_cnt(26);
    REP(j, len) {
      int ch = ss[j] - 'a';
      char_cnt[ch]++;
    }
    u64 shash = 0;
    u64 base = B;
    if (len > 1) {
      for (int j = len - 1; j >= 1; --j) {
        REP(c, 26) {
          if (char_cnt[c] > 0) {
            auto it = mp.find({c, shash});
            if (it == mp.end()) continue;
            ans += it->second;
          }
        }
        shash += base * ss[j];
        base *= B;
        --char_cnt[ss[j] - 'a'];
      }
    }
    int prefix = ss[0] - 'a';
    ++mp[{prefix, shash}];
  }
  cout << ans << endl;
}


Measured memory_bytes: 23412
#include <cstdio>
#include <cstring>
#include <iostream>

int dxy[]={1,0,-1,0,1};
int ans=0;

char tile[21][21];
int H,W;

void dfs(int x, int y){
	if(tile[x][y]=='.'){
		ans++;
		tile[x][y]='#';
	}
	for(int i = 0; i < 4; ++i){
		int nx = dxy[i] + x, ny = y + dxy[i + 1];
		if(nx < H && nx >= 0 && ny >= 0 && ny < W){
			if(tile[nx][ny] == '.')dfs(nx, ny);
		}
	}
}

int main(){
	while(std::cin>>W>>H && W+H){
		ans = 0;
		memset(tile, '#', sizeof(tile));
		int sx,sy;
		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				char c;
				std::cin>>c;
				tile[i][j]=c;
				if(tile[i][j] == '@')sx = i, sy = j;
			}
		}
		tile[sx][sy] = '.';
		dfs(sx,sy);
		printf("%d\n",ans);
	}
}

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

Measured memory_bytes: 2756
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int l, r, d;
	cin >> l >> r >> d;
	int result = 0;
	RANGE(i, l, r + 1) {
		if(i % d == 0) {
			result++;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 3620
import java.io.*;
import java.util.*;


class Main {
    static long rec(long x,long y){
        if(x==y)return 0;
        if(x==0)return 0;
        long q=y/x;
        long ans=0;
        ans+=(q-1)*x;
        y-=(q-1)*x;
        long z=y-x;
        if(z==0)return ans;
        long q2=x/z;
        ans+=q2*z;
        x-=q2*z;
        return ans+rec(x,x+z);
    }
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        long n=sc.nextLong();
        long x=sc.nextLong();
        out.println(rec(x,n)*3);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define TESTCASES 0

using namespace std;

int n;

int Go(){

  scanf("%d",&n);

  ll sum = 0;

  for(int i = 1 ; i <= n ; ++i)
    for(int j = 1 ; j <= n ; ++j)
      for(int k = 1 ; k <= n ; ++k) 
        sum += (ll) __gcd(i,__gcd(j,k));

  printf("%lld\n",sum);

  return 0;
}


int main(){

  int t;
  if(TESTCASES) scanf("%d",&t); 
  else          t = 1;
  
  while(t--) Go();
} 

Measured memory_bytes: 3792
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string n;
  C(n);
  if(n[0] == n[2] )
    Yes;
  else
    No;

  ret 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  double T, A, x;
  cin >> T >> A;
  double H;
  int ret = 0;
  double m = 1000000000;
  for (int i=1; i<=N; i++) {
    cin >> x;
    double t = T - x * 0.006;
    double d = fabs(t - A);
    if (m > d) {
      ret = i;
      m = d;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long int n,X,x[5000000];

int gcd(int x,int y){
    int k;
    while(y!=0){
        k=y;
        y=x%y;
        x=k;
    }
    return x;
}

int main(){
    cin>>n>>X;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        x[i]-=X;
        if(x[i]<0)x[i]*=-1;
    }
    int gg=gcd(x[0],x[1]);
    for(int i=0;i<n;i++){
        gg=gcd(x[i],gg);
    }
    cout<<gg<<endl;;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k,a,b;
    cin>>k>>a>>b;
    bool can=false;
    rep(i,a,b+1){ 
        if(i%k==0)can=true;
    }
    if(can)cout<<"OK\n";
    else cout<<"NG\n";
    return 0;   
}

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

string s;
int main() {
	string n;
	cin>>n;
    int num = stoi(n);
    int ans =0;
    for(int i=1; i<=num;i++){
        int keta = (int)log10((double)i) + 1;
        if(keta%2!=0){
            ans += 1;
        }
    }
  
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;
  ll N = s.size();

  ll ans = 0LL;
  for (ll S = 0; S < std::pow(2, N-1); S++) {
    ll state = S;
    std::string str(1, s[0]);
    ll cnt = 0LL;
    for (ll i = 0; i < N-1; i++) {
      if (state % 2 == 1) {
	cnt += atoll(str.c_str());
	str = "";
      }
      str += s[i+1];
      state /= 2;
    }
    cnt += atoll(str.c_str());
    ans += cnt;
  }

  print(ans);
  return 0;
}






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

int main () {
  int A[MAX][MAX];
  int B[MAX];
  int C[MAX];

  int n, m;
  int i, j;

  // input n, m
  scanf("%d%d", &n, &m);

  // input A
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      scanf("%d", &A[i][j]);
  
  // input B
  for (j = 0; j < m; j++)
    scanf("%d", &B[j]);

  // initialize C
  for (i = 0; i < n; i++)
    C[i] = 0;

  // mul
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      C[i] += A[i][j] * B[j];
  
  // output
  for (j = 0; j < n; j++)
    printf("%d\n", C[j]);

  return 0;
}



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

const int INF = 1000000007;

int main()
{
    int n, k, a[5003];
    cin >> n >> k;
    int least = INF;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] >= k) least = min(least, a[i]);
    }
    sort(a, a + n, greater<int>());
    int dp[10005];
    fill(dp, dp + 10005, -1);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = k * 2; j >= a[i]; j--){
            if(dp[j - a[i]] != -1){
                if(j - a[i] < k) dp[j] = a[i];
                else dp[j] = dp[j - a[i]];
            }
        }
    }
    for(int i = k; i <= k * 2; i++){
        if(i - k < dp[i]){
            least = min(least, dp[i]);
        }
    }
    if(least == INF) cout << n << endl;
    else{
        reverse(a, a + n);
        cout << lower_bound(a, a + n, least) - a << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c,d,e;
	int x[6]={0,0,0,0,0,0};
	cin>>a>>b>>c>>d>>e;
	x[a]=1;x[b]=1;x[c]=1;x[d]=1;x[e]=1;
	for(int i=0;i<=5;i++)
	{
		if(x[i]==0)cout<<i;
	}
	return 0;
} 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#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 pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;

int main() {
    int a , b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n;
    char s[55][111];
    int t[55];
    char x[111];
    int ans = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%s %d", s[i], &t[i]);
    }
    scanf("%s", x);
    int i;
    for (i = 0; strcmp(s[i], x) != 0; i++)
    {
    }
    for (i++; i < n; i++)
    {
        ans += t[i];
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
ans = 0
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        ans += i

print(ans)


Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
using ll = long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 - (y2 - y1);
    int y3 = y2 + (x2 - x1);
    int x4 = x3 - (x2 - x1);
    int y4 = y3 - (y2 - y1);
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}

Measured memory_bytes: 3736
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[100000], B[100000], C[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N) cin >> C[i];
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);
  long long s = 0;
  rep(i, N) {
    int b = B[i];
    s += 1LL*(lower_bound(A, A+N, b) - A)*((C+N) - upper_bound(C, C+N, b));
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 1408
//
// じょえチャンネル
// https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
//
// Created by yamunaku on 2020/02/22.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n,k;
    cin >> n >> k;
    int ans = 0;
    while(n){
        n/=k;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int a,b,p,x,y;
    cin>>a>>b>>p;
    if(a%p>0)  x=a/p+1;
    else  x=a/p;
    y=b/p;
    cout<<y-x+1<<endl;
    return 0;
}

Measured memory_bytes: 256
s = input()

s = list(s)

if s[-1] == "s":
  t = "es"
  t = list(t)
  s = s + t
  s =''.join(s)
  print(s)
else:
  t = "s"
  t = list(t)
  s = s + t
  s =''.join(s)
  print(s)

Measured memory_bytes: 61648
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[35]={0,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;
    scanf("%d",&k);
    printf("%d",a[k]);
    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll choose(int n, int r) {
    ll acc = 1;
    rep(i,r) acc = acc * (n-i) / (i+1);
    return acc;
}
signed main()
{   
    gearup;
    ll k; cin >> k;
    ll res = 0;
    rep1(i,k+1){
        rep1(j,k+1){
            rep1(l,k+1){
                int n = __gcd(i,j);
                res += __gcd(n,l);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3648
K = int(input())

a = list(range(1, 10))
i = 0
while len(a) < K:
  A = []
  for j in range(3):
    n = str(a[i])
    if j == 0 and int(n[-1]) - 1 >= 0:
      A.append(int(n + str(int(n[-1]) - 1)))
    elif j == 1:
      A.append(int(n + n[-1]))
    elif j == 2 and int(n[-1]) + 1 < 10:
      A.append(int(n + str(int(n[-1]) + 1)))
  a += A
  i += 1
print(a[K-1])

Measured memory_bytes: 13072
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
ans = ""
while n > 0:
    m = n%26
    nya = m-1 if m-1 >= 0 else 25
    ans += chr(ord('a') + nya)
    n -= nya
    n //= 26
print(ans[::-1])


Measured memory_bytes: 10404
#include<stdio.h>
int main(void)
{
    int n,m,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<9;i++){
			scanf("%d",&m);
			n=n-m;
		}
		printf("%d\n",n);
	}
    return 0;
} 

Measured memory_bytes: 2684