akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

char horz[5][4+1];
char vert[4][5+1];
int x, y, vx, vy;

void turn_left() {
	int temp = vx;
	vx = vy;
	vy = -temp;
}

void turn_right() {
	int temp = vx;
	vx = -vy;
	vy = temp;
}

inline bool ok(char c) { return (c == '1'); }

bool avail() {
	if (vx == 1) {
		if (x < 4 && ok(horz[y][x]))
			return true;
	} else if (vx == -1) {
		if (x > 0 && ok(horz[y][x-1]))
			return true;
	} else if (vy == 1) {
		if (y < 4 && ok(vert[y][x]))
			return true;
	} else /* if (vy == -1) */ {
		if (y > 0 && ok(vert[y-1][x]))
			return true;
	}
	return false;
}

void print() {
	if (vx == 1) cout << "R";
	else if (vx == -1) cout << "L";
	else if (vy == 1) cout << "D";
	else /* if (vy == -1) */ cout << "U";
}

int main() {
	for (int i = 0; i < 4; i++)
		cin >> horz[i] >> vert[i];
	cin >> horz[4];

	x=0, y=0, vx=0, vy=-1;
	do {
		while (!avail()) turn_right();
		print();
		x += vx, y += vy;
		turn_left();
	} while (x != 0 || y != 0);
	cout << endl;
	return 0;
}

Measured memory_bytes: 0
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left, bisect_right
def resolve():
    n, m = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    AB.sort()
    AB.append([INF, 0])
    for i in range(n, 0, -1):
        AB[i][1] ^= AB[i - 1][1]

    E = [[] for _ in range(n + 1)]
    for i in range(m):
        u, v = map(int, input().split())
        l = bisect_left(AB, [u, 0])
        r = bisect_right(AB, [v, 1])
        E[l].append((r, i + 1))
        E[r].append((l, i + 1))

    ans = []
    used = [False] * (n + 1)
    def dfs(v):
        used[v] = True
        res = AB[v][1]
        for nv, i in E[v]:
            if used[nv]:
                continue
            r = dfs(nv)
            if r:
                ans.append(i)
            res ^= r
        return res

    for v in range(n + 1):
        if used[v]:
            continue
        if dfs(v):
            print(-1)
            return

    print(len(ans))
    if ans:
        print(*sorted(ans))
resolve()

Measured memory_bytes: 184100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
	This is D. Knapsack 1 (Atcoder DP contest)
*/

int main(){
	//You are gonna wish
	ll n,W; cin>>n>>W;
	ll w,v;
	vector<ll>  dp(W+1);
	for(int i=0;i<n;i++){
		cin>>w>>v;
		//dp[0]->dp[3] 
		for(int j=W-w;j>=0;j--){
			dp[j+w]=max(dp[j+w],dp[j]+v);
		}
	}
	ll an=0;
	for(ll i=0;i<=W;i++){
		an=max(an,dp[i]);
	}
	cout<<an;
    return 0;
}




Measured memory_bytes: 1024
s = input()

li = ["0" if i % 2 == 0 else "1" for i in range(len(s))]


count1 = 0
count2 = 0
ans = 0
for i in range(len(s)):
    if s[i] == li[i]:
        count1 += 1
    else:
        count2+= 1

print(min(count1, count2))

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int A,B,K; cin>>A>>B>>K;
    FOR(i,1,K+1){
        if(i%2==1){
        A = A/2;
        B += A;
        }
        else{
            B = B/2;
            A +=B;
        }
    }
    cout<<A<<" "<<B<<endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;
typedef tuple<ll,ll,ll> T;

ll mo(ll x){
    ll ans=x%mod;
    if(x>=0)return ans;
    return ans+mod;
}

long long euclid(long long x,long long y){
    long long a=max(x,y);
    long long b=min(x,y);
    if(a%b==0)return b;
    else{
        return euclid(b,a%b);
    }
}
long long ruijou(long long x, long long y){
    if(y==0) return 1;
    else if(y%2==0) return ruijou(x*x%mod,y/2);
    else return x*ruijou(x,y-1)%mod;
}


ll i,j,k;

int main(){
   ll N;
   cin>>N;
   V A(N),B(N);
   rep(i,N)cin>>A[i]>>B[i];
   map<P,P> kosuu;
   ll zako=0;
   rep(i,N){
      if(A[i]==0&&B[i]==0){
        zako++;
        continue;
      }
      else if(A[i]==0){
         if(kosuu.count(P(1,0)))kosuu[P(1,0)].first++;
         else{
             kosuu[P(1,0)].first=1;
              kosuu[P(1,0)].second=0;

         }
         
      }
      else if(B[i]==0){
         if(kosuu.count(P(1,0)))kosuu[P(1,0)].second++;
         else{
            kosuu[P(1,0)].first=0;
            kosuu[P(1,0)].second=1;

         } 

      }
      else{
         if((A[i]>0&&B[i]>0)||(A[i]<0&&B[i]<0)){
            ll a=abs(A[i]);
            ll b=abs(B[i]);
            ll gcd=euclid(a,b);
            if(kosuu.count(P(a/gcd,b/gcd)))kosuu[P(a/gcd,b/gcd)].first++;
            else{
               kosuu[P(a/gcd,b/gcd)].first=1;
               kosuu[P(a/gcd,b/gcd)].second=0;

            }

         }
         else{
            ll a=abs(A[i]),b=abs(B[i]);
            ll gcd=euclid(a,b);
            if(kosuu.count(P(b/gcd,a/gcd)))kosuu[P(b/gcd,a/gcd)].second++;
            else{
               kosuu[P(b/gcd,a/gcd)].first=0;
               kosuu[P(b/gcd,a/gcd)].second=1;

            }


         }
      }
   }
   ll ans=1;
   for(auto itr=kosuu.begin();itr!=kosuu.end();itr++){
      
         
         ll jud=(ruijou(2,itr->second.first)+ruijou(2,itr->second.second)-1);
         jud%=mod;
         ans=(ans*jud)%mod;

      
      
   }
   cout<<mo(zako+ans-1)<<endl;
   

}

Measured memory_bytes: 21872
using System;
using System.Linq;

namespace abc148_d
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var al = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            long b = 1;

            for (int i = 0; i < N; i++) 
                if(al[i] == b) 
                    b++;

            Console.WriteLine(b == 1 ? -1 : N - b + 1);
        }
    }
}


Measured memory_bytes: 35676
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    AB = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    AB.sort()
    pro = 0
    cost = 0
    for a, b in AB:
        if pro + b >= M:
            cost += (M - pro) * a
            break
        pro += b
        cost += a * b
    
    print(cost)


if __name__ == '__main__':
    main()

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

int main() {
  int N, A=0, B=1;
  cin >> N;
  rep(i, 11){
    A=A+(N/B)%10;
    B=B*10;
  }
  if(N%A==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
	int N, count = 0;
	double ans;
	cin >> N;

	for (int i = 1; i <= N; i++) {
		if (i % 2 != 0) {
			count++;
		}
	}

	ans = double(count) / N;
	cout << ans << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        a: i32,
        mut b: i32,
    }

    solve(a, b);
}

fn solve(a: i32, mut b: i32) {
    if b == 1 {
        println!("0");
        return;
    }
    let mut cnt = 0;
    while b > 0 {
        if cnt == 0 {
            b -= a;
        } else {
            b -= a - 1;
        }
        cnt += 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2152
# ITP1_5_C: Print a Chessboard

def make_line(width, is_even)
  is_white = is_even
  width.times.inject('') do |line|
    is_white = ! is_white
    line << ( is_white ? '.' : '#' )
  end
end

while true
  height, width = gets.split.map &:to_i
  break if height == 0 && width == 0

  even_line = make_line width, true
  odd_line  = make_line width, false

  (height / 2).times do
    puts even_line, odd_line
  end
  puts even_line if height % 2 == 1
  puts
end

Measured memory_bytes: 8636
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> set = new HashSet<>();

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (!set.add(a)) {
				set.remove(a);
			}
		}
		System.out.println(set.size());
		sc.close();
	}

}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

const int MAXN = 3e2 + 5;

int g[MAXN][MAXN];

vector<pair<int, pii> > pp;

void solve(){
	int n;
	scanf("%d", &n);
	REPN(i, 1, n){
		REPN(j ,1 ,n){
			scanf("%d", &g[i][j]);
		}
	}
	REPN(i, 1, n){
		REPN(j, 1, n){
			REPN(k, 1, n){
				if (i != j && j != k && i != k && g[i][j] + g[j][k] < g[i][k]){
					printf("-1\n");
					return;
				}
			}
		}
	}
	
	REPN(i, 1, n){
		REPN(j ,i + 1 ,n){
			pp.pb(mp(g[i][j], mp(i, j)));
		}
	}
	SORT(pp);
	for(int a = SZ(pp) - 1; a >= 0; a--){
		int i = pp[a]._2._1;
		int j = pp[a]._2._2;
		REPN(k, 1, n){
			if (i != j && j != k && i != k && g[i][j] != INF && g[i][k] != INF && g[j][k] != INF && g[i][k] + g[j][k] == g[i][j]){
				g[i][j] = g[j][i] = INF;
				break;
			}
		}
	}
	
	ll ans = 0;
	REPN(i, 1, n){
		REPN(j ,i + 1 ,n){
			if (g[i][j] != INF){
				ans += g[i][j];
			}
		}
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m, x, y;
    cin >> n >> m;
    vector<pii> e, p;
    fore(i,0,n) {
        cin >> x >> y;
        e.pb({x, y});
    }
    fore(i,0,m) {
        cin >> x >> y;
        p.pb({x, y});
    }
    fore(i,0,n) {
        int mn = 1e9, id;
        fore(j,0,m) {
            int d = abs(e[i].F - p[j].F) + abs(e[i].S - p[j].S);
            if (d < mn) {
                mn = d;
                id = j+1;
            }
        }
        cout << id << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int a, b, k;
	cin >> a >> b >> k;
	if (a > b)swap(a, b);
	int kk = 0;
	for (int i = b;i > 0;i--) {
		if (a % i)continue;
		if (b % i)continue;
		kk++;
		if (kk == k) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

//----------------------------------
//----------------------------------

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

signed main()
{
    ios::sync_with_stdio(false);
        int a, b;
        cin >> a >> b;
        cout << gcd(a,b) << '\n';
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0;i < n;i++)
    {
        int l,r;
        cin >> l >> r;
        sum += r - l + 1;
    }
    cout << sum;

    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var inputValues = Console.ReadLine().Split(' ');
        var a = int.Parse(inputValues[0]);
        var b = int.Parse(inputValues[1]);
        var t = int.Parse(inputValues[2]);

        int biscuitCreateTiming = (int)(t + 0.5) / a;
        int biscuitSum = biscuitCreateTiming * b;

        Console.WriteLine(biscuitSum);
    }
}



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

using namespace std;

int main()
{
    int N, l, r, sum = 0;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> l >> r;
        sum = r - l + 1 + sum;
    }

    cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,c,h[100005],dp[100005]={};
  int k;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>h[i];
    dp[i]=1000000000;
  }
  dp[1]=0;
  for(int i=2;i<=n;i++){
    c=min(i-1,k);
    for(int j=1;j<=c;j++){
      dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    }
  }
  cout<<dp[n]<<endl;
  return(0);
}


Measured memory_bytes: 1024
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, k = mi()
    s = input()
    print(s[:(k-1)] + s[k-1].lower() + s[k:])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
  ll n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n;i++){
    cin >> a[i];
  }
  int count = 0;
  for (int i = 0; i < n;i++){
    for (int j = i + 1; j < n;j++){
      for (int k = j + 1; k < n;k++){
        if(a[i] != a[j] && a[j] != a[k] && a[i] != a[k]){
          int len =  a[i] +  a[j] + a[k];
          int m = max( a[i], max(a[j], a[k]));
          int rest = len - m;
          if(m<rest){
            count++;
          }

        }
      }
    }
  }
  cout << count << endl;

  return 0;
}

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

int main(){
    int N,M;cin>>N>>M;
    if(N==M){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;

int main(void)
{
  char cA,cB;
  bool bA,bB;
  cin >> cA >> cB;
  if(cA == 'H'){
    bA = true;
  }
  else{
    bA = false;
  }
  if(cB == 'H'){
    bB = true;
  }
  else{
    bB = false;
  }
  if(!(bA^bB)){
    cout << 'H' << endl;
  }
  else{
    cout << 'D' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x;
  cin >> x;
  //vowel と、そうでないとき consonant と
  if(x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o')
    cout << "vowel" << endl;
  else
    cout <<"consonant" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector< tuple<string, int, int> > r;
  for(int i = 0; i < n; ++i){
    string s;
    int p;
    cin >> s >> p;
    auto pair = make_tuple(s, p, i);
    r.push_back(pair);
  }
  sort(r.begin(), r.end(), [](auto l, auto r){
                             if (get<0>(l) != get<0>(r) ){
                               return get<0>(l) < get<0>(r);
                             }
                             return get<1>(l) > get<1>(r);
                           });
  for(auto&& x: r){
    cout << get<2>(x) + 1 << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s = sc.next();
        String[] sp = s.split("");
        String[] al = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
        for(int i = 0; i < sp.length; i++) {
            for(int j = 0; j < 26; j++) {
                if(sp[i].equals(al[j])) {
                    if(j+N >=26) {
                        System.out.print(al[j+N-26]);
                    }else {
                        System.out.print(al[j+N]);
                    }
                    break;
                }
            }   
        }	
        System.out.println("");
	}
}

Measured memory_bytes: 25812
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;
int N,M,S;
vector<P> E[50];
int a[101],b[101],c[50],d[50];
ll dist[50][3010];
bool vis[50][3010];
ll ans[50];

int main() {
  cin >> N >> M >> S;
  chmin(S,3000);
  for(int i=0;i<M;i++){
    int u,v; cin >> u >> v; u--;v--;
    cin >> a[i] >> b[i];
    E[u].push_back({v,i});
    E[v].push_back({u,i});
  }
  rep(i,N) cin >> c[i] >> d[i];
//init
  rep(i,N) rep(j,3001) dist[i][j] = infl;
  rep(i,N) rep(j,3001) vis[i][j] = false;
  rep(i,N) ans[i] = infl;

  min_priority_queue<pair<ll,int>> que;

  dist[0][S] = 0;
  que.push({0,0*5010+S});
  while(!que.empty()){
    auto q = que.top();que.pop();
    ll cst = q.first;
    int cu = q.second / 5010;
    int s = q.second % 5010;

    if(vis[cu][s]) continue;
    vis[cu][s] = true;

    chmin(ans[cu],cst);

    for(auto p : E[cu]){
      int to = p.first;
      int i = p.second;
      if(s < a[i]) continue;//枝狩り

      ll cst2 = cst + b[i];
      if(chmin(dist[to][s-a[i]],cst2)) que.push({dist[to][s-a[i]],to*5010+s-a[i]});//更新したとき
    }
    ll cst2 = cst + d[cu];
    int s2 = min(3000,s+c[cu]);
    if(chmin(dist[cu][s2],cst2)) que.push({dist[cu][s2],cu * 5010 + s2});
    
  }
  for(int i=1;i<N;i++) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 6644
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	llint cnt;
	llint min = 4000000;
	for (int i = a[0];i <= a[n - 1];i++) {
		cnt = 0;
		rep(j, n) {
			if (i == a[j]) {
				continue;
			}
			cnt += (a[j] - i)*(a[j] - i);
		}
		if (min > cnt) {
			min = cnt;
		}
	}
	cout << min << endl;
	return 0;
}


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

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, X, L=0;
    cin>>N>>X;
    
    ll a=X, b=N-a;
    while(b>0){
        if(b<a){
            swap(a,b);
        }
        ll n=b/a;
        L+=a*3*n;
        b%=a;
    }
    cout1(L)
}

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

int main() {
  int N, N1, N2, N3, N4;
  cin >> N;
  N1 = N / 1000;
  N2 = N % 1000 / 100;
  N3 = N % 100 / 10;
  N4 = N % 10;
  if (N1 == N2 && N2 == N3) {
    cout << "Yes" << endl;
  }
  else if (N2 == N3 && N3 == N4) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int x, a;
  cin >> x >> a;
  if(x < a){
    cout << 0 << endl;
    return 0;
  }
  cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,N,K,p[200010];
int dat[800001];
void init(int n_){
	N=1;
	while(N<n_)N*=2;
	rep(i,N*2-1)dat[i]=INF;
}
void update(int k,int a){
	k+=N-1;
	dat[k]=a;
	while(k>0){
		k=(k-1)/2;
		dat[k]=min(dat[k*2+1],dat[k*2+2]);
	}
}
int query(int a,int b,int k,int l,int r){
	if(r<a||b<l)return (int)1000000;
	if(a<=l&&b>=r)return dat[k];
	int vl=query(a,b,k*2+1,l,(l+r)/2);
	int vr=query(a,b,k*2+2,(l+r)/2+1,r);
	return min(vl,vr);
}
bool f[200010];
int cnt=1;
signed main(){
	cin>>n>>K;
	init(n);
	rep(i,n){
		cin>>p[i];
		update(i,p[i]);
	}
	for(int i=1;i<K;i++){
		if(p[i]>p[i-1])cnt++;
		else cnt=1;
	}
	bool flag=(cnt==K);
	int ans=n-K+1;
	for(int i=0;i+K<n;i++){
		if(query(i,i+K,0,0,N-1)==p[i])f[i]=true;
	}
	rep(i,N*2-1)dat[i]=INF;
	rep(i,n){
		p[i]*=-1;
		update(i,p[i]);
	}
	for(int i=0;i<n-K;i++){
		if(p[i+K-1]>p[i+K])cnt++;
		else cnt=1;
		if(cnt>=K&&flag)ans--;
		else if(query(i,i+K,0,0,N-1)==p[i+K]){
			if(f[i])ans--;
		}
		if(cnt>=K)flag=true;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
#include <cassert>
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
int x, y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> y;

  ll ans;
  if((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int a = (2 * x - y) / 3;
  int b = (2 * y - x) / 3;
  combination c(a + b + 1);

  if(a >= 0 && b >= 0) {
    cout << c(a + b, a) << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 16288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin >> n;
    for (int i = 0; i < 3; i++) {
        if (n[i] == '7') {
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 3636
from functools import reduce
from operator import mul

def fact_factors(n):
    f = []

    x = 2
    c = 0
    while x <= n:
        c += n // x
        x *= 2
    if c > 0:
        f.append((2, c))

    sv = [1] * (n + 1)
    lim = int(n**0.5) + 1
    for i in range(3, lim + 1, 2):
        if sv[i]:
            for j in range(i + i, n + 1, i):
                sv[j] = 0

    for i in range(3, n + 1, 2):
        if sv[i]:
            x = i
            c = 0
            while x <= n:
                c += n // x
                x *= i
            f.append((i, c))

    return f

import sys

def D(*a, **kwa):
    print(*a, file=sys.stderr, **kwa)

# 75 = 3 * 5**2
# 七五数 a**74, a**2 * b**24, a**4 * b**14, a**2 * b**4 * c**4
x_list_list = [[74], [24, 2], [14, 4], [4, 4, 2]]
div = [1, 1, 1, 2]

N = int(input())

f = fact_factors(N)
# D(f)

fx = [0] * (N+1)
afx = [0] * (N+1)
for f in fact_factors(N):
    fx[f[1]] += 1
for i in range(N, -1, -1):
    afx[i] = fx[i] if i == N else fx[i] + afx[i+1]
# D(fx)
# D(afx)

ans = 0
for i, x_list in enumerate(x_list_list):
    c = []
    for j, x in enumerate(x_list):
        if x > N:
            break
        c.append(afx[x]-j)
    if len(c):
        ans += reduce(mul, c) // div[i]

print(ans)

Measured memory_bytes: 3572
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

vector<long long> tree[100005];
pair<long long, long long> val[100005];
bool odev[100005];
long long ans[100005];
long long N, K;
bool ng;

//     minimum, maximum
pair<long long, long long> dfs(long long pa, long long cur){
	//cout << "dfs pa:" << pa << " cur:" << cur << endl;
	pair<long long, long long> ret = make_pair(-INT_MAX, INT_MAX);

	for(int i = 0; i < tree[cur].size(); i++){
		if(tree[cur][i] != pa){
			pair<long long, long long> tmp = dfs(cur, tree[cur][i]);
			ret.first = max(ret.first, tmp.first);
			ret.second = min(ret.second, tmp.second);
		}
	}
	ret.first--;
	ret.second++;

	val[cur].first = max(val[cur].first, ret.first);
	val[cur].second = min(val[cur].second, ret.second);
	return val[cur];
}

void create(long long pa, long long cur, bool odd, long long paval){
	//cout << "create pa:" << pa << " cur:" << cur << " odd:" << odd << " paval:" << paval << endl;
	pair<long long, long long> ret = make_pair(-INT_MAX, INT_MAX);
	if(pa == -1){
		ans[cur] = paval;
	}else{
		if(((paval + 1 + 10000000) % 2) != odd){
			//cout << "odd error" << endl;
			ng = true;
			return;
		}

		if(paval - 1 >= val[cur].first && paval - 1 <= val[cur].second){
			ans[cur] = paval - 1;
		}else if(paval + 1 >= val[cur].first && paval + 1 <= val[cur].second){
			ans[cur] = paval + 1;
		}else{
			ng = true;
			return;
		}
	}

	for(int i = 0; i < tree[cur].size(); i++){
		if(tree[cur][i] != pa){
			create(cur, tree[cur][i], !odd, ans[cur]);
		}
	}



}



int main(){
	cin >> N;
	for(int i = 0; i < N-1; i++){
		long long A, B;
		cin >> A >> B;
		A--;B--;
		tree[A].push_back(B);
		tree[B].push_back(A);
	}

	for(int i = 0; i < 100005; i++){
		val[i] = make_pair(-INT_MAX, INT_MAX);
	}

	cin >> K;
	long long V, P;
	for(int i = 0; i < K; i++){
		cin >> V >> P;
		V--;
		val[V] = make_pair(P, P);
	}
	/*
	for(int i = 0; i < N; i++){
		cout << i << ":" << val[i].first << "-" << val[i].second << endl;
	}
	cout << endl;
	*/

	dfs(-1, V);
	/*
	for(int i = 0; i < N; i++){
		cout << i << ":" << val[i].first << "-" << val[i].second << endl;
	}
	*/

	create(-1, V, P%2, P);
	if(ng){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
		for(int i = 0; i < N; i++){
			cout << ans[i] << endl;
		}
	}
}

Measured memory_bytes: 16512
//************************
//*  Date: 2018.8.3      *
//*  Problem:            *
//*  Author: xuziyuan    * 
//************************

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,q;
vector <int> dis[510];

int main()
{
	cin>>n>>m>>q;
	rep(i,m)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		dis[x].pb(y);
	}
	repn(i,n) sort(dis[i].begin(),dis[i].end());
	rep(i,q)
	{
		int x,y,ans=0;
		scanf("%d%d",&x,&y);
		for(int j=x;j<=y;j++)
		{
			//cout<<j<<' '<<upper_bound(dis[j].begin(),dis[j].end(),y)-dis[j].begin()<<endl;
			ans+=upper_bound(dis[j].begin(),dis[j].end(),y)-dis[j].begin();
		}
		printf("%d\n",ans);
	}
	rt0;
}

Measured memory_bytes: 2176
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<int,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=2e5+5;
const ll inf=1ll<<60;
ll sum[N],ans=inf;int pos[N],n,Q;
inline void cmin(ll &x,ll y){if(x>y)x=y;}
struct Segment_tree
{
#define lc k<<1
#define rc k<<1|1
	ll val[N];int mi[N<<2];
	inline int cmp(const int &x,const int &y){return val[x]<val[y]?x:y;}
	void build(int l,int r,int k)
		{
			if(l==r)return val[mi[k]=l]=inf,void();
			int mid=l+r>>1;
			build(l, mid ,lc),build(mid+1,r,rc);
			mi[k]=cmp(mi[lc],mi[rc]);
		}
	void upd(int l,int r,int k,int p,ll v)
		{
			if(l==r)return cmin(val[l],v);
			int mid=l+r>>1;
			if(p<=mid)upd(l,mid,lc,p,v);
			else upd(mid+1,r,rc,p,v);
			mi[k]=cmp(mi[lc],mi[rc]);
		}
	int query(int L,int R,int l,int r,int k)
		{
			if(L<=l&&r<=R)return mi[k];
			int mid=l+r>>1;
			if(L> mid)return query(L,R,mid+1,r,rc);
			if(R<=mid)return query(L,R,l, mid ,lc);
			return cmp(query(L,R,l,mid,lc),query(L,R,mid+1,r,rc));
		}
}A,B,C;
inline int abs(int x){return x<0?-x:x;}
inline void solve(int x)
{
	for(int i=2;i<=Q;++i)sum[i]=sum[i-1]+abs(pos[i]-pos[i-1]);
	A.build(1,n,1),B.build(1,n,1),C.build(1,n,1);
	A.upd(1,n,1,x,0-x),B.upd(1,n,1,x,0+x),C.upd(1,n,1,x,0);
	for(int i=2;i<=Q;++i)
	{
		int le=A.query(1,pos[i],1,n,1),ri=B.query(pos[i],n,1,n,1);
		int res=abs(pos[i]-pos[i-1]);
		if(A.val[le]+pos[i]>B.val[ri]-pos[i])
		{
			C.upd(1,n,1,pos[i-1],B.val[ri]-pos[i]-res);
			A.upd(1,n,1,pos[i-1],B.val[ri]-pos[i]-res-pos[i-1]);
			B.upd(1,n,1,pos[i-1],B.val[ri]-pos[i]-res+pos[i-1]);
		}
		else
		{
			C.upd(1,n,1,pos[i-1],A.val[le]+pos[i]-res);
			A.upd(1,n,1,pos[i-1],A.val[le]+pos[i]-res-pos[i-1]);
			B.upd(1,n,1,pos[i-1],A.val[le]+pos[i]-res+pos[i-1]);
		}
	}
	cmin(ans,C.val[C.mi[1]]+sum[Q]);
}
int main()
{
	n=in(),Q=in()+1;int a=in(),b=in();
	for(int i=2;i<=Q;++i)pos[i]=in();
	pos[1]=a;solve(b);pos[1]=b;solve(a);
	return printf("%lld\n",ans),0;
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	int ans = 1;
	for(int i=1;i<n;i++){
		if( s[i] != s[i-1] ) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
D, G = map(int, input().split())
PC = [0] + [list(map(int, input().split())) for _ in range(D)]
#print(PC)
def dfs(i, g):
  if i == 0:
    return 1e9
  m = min(g // (i * 100), PC[i][0])
  #print("m: " + str(m))
  s = 100 * i * m
  #print("s: " + str(s))
  if m == PC[i][0]:
    s += PC[i][1]
  if s < g:
    m += dfs(i - 1, g - s)
  return min(m, dfs(i - 1, g))
print(dfs(D, G))

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>


using ui = unsigned int;

int main() {

	std::string s, t;

	std::cin >> s >> t;


	for (ui i{}; i < s.size(); ++i) {

		auto it = std::find(std::begin(t), std::end(t), s[i]);

		//std::cout << s[i] << " ";
		if (it != std::end(t)) {
			auto ad = std::distance(std::begin(t), it);
			bool eval = true;
			//std::cout << ad << "\n";
			for (ui j{}; j < s.size(); ++j) {
			//	std::cout << j << " " << (j + ad)%s.size() << "\n";

				eval &= s[(i+j)%s.size()] == t[(j + ad) % s.size()];
				if (!eval)
					break;
			}

			if (eval) {
				std::cout << "Yes\n";
				std::exit(0);
			}
		}
	}

	std::cout << "No\n";


	return 0;
}

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

using namespace std;

ll func(vector<ll> &v, vector<ll> &dp){
    for(ll i=2;i<v.size();i++){
        dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
    }

    return dp[v.size()-1];
}

int main(){

    ll n;
    cin>>n;

    vector<ll> v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];

    vector<ll> dp(n, -1);
    dp[0] = 0;
    dp[1] = abs(v[1] - v[0]);
    ll ans = func(v, dp);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
N = int(input())
ans = []
def recur(x, flag3, flag5, flag7):
    if(x > N):
        return
    if(flag3 and flag5 and flag7 ):
        ans.append(x)
    recur(10*x+3, True, flag5, flag7)
    recur(10*x+5, flag3, True, flag7)
    recur(10*x+7, flag3, flag5, True)


recur(0,False,False,False)
print(len(ans))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n,l; cin >> n >> l;
    vector<string> S(n);
    rep(i,n){
        cin >> S[i];
    }
    sort(S.begin(),S.end());
    string ans;
    rep(i,n){
        ans += S[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
		B.at(i)=0;
		B.at(0)+=A.at(i)*pow(-1,i);
	}
	cout << B.at(0);
	for(int i=1;i<N;i++){
		B.at(i)=A.at(i-1)*2-B.at(i-1);
		cout <<" "<< B.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll 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 mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long K)
{
    cout << (K / 2) * (K / 2 + K % 2) << endl;
}

int main()
{
    long long K;
    scanf("%lld", &K);
    solve(K);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
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;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;



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


    string s; cin >> s;
    ll iti = 0,zero = 0;
    REP(i,s.length()) s[i] == '0' ? zero++ : iti++;
    cout << 2*min(zero,iti) << endl;

    return 0;
}

Measured memory_bytes: 512
s = str(input())
for i in range(0,len(s),1):
    if s[i] == "A":
        tmp_1 = int(i)
        break
for j in range(tmp_1,len(s),1):
    if s[j] == "Z":
        tmp_2 = int(j)
print(tmp_2-tmp_1+1)


Measured memory_bytes: 3516
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==-1){
				break;
			}
			String str = Integer.toBinaryString(N);
			if(str.length()%2!=0){
				str= "0"+str;
			}
			String ans = "";
			for(int i = 0;i<str.length();i+=2){
				int value = Integer.parseInt(str.substring(i,i+2));
				if(value==0){
					ans= ans+"0";
				}
				else if(value==1){
					ans= ans+"1";
				}
				else if(value==10){
					ans= ans+"2";
				}
				else if(value==11){
					ans= ans+"3";
				}
			}
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 12000
# import bisect
import heapq
# import math
# import queue
import sys


def main():
    # 読み込み回数が多い場合
    input = sys.stdin.readline
    N = int(input())
    
    # heap queue
    h = []
    for i in range(N):
        A, B = map(int, input().split())
        heapq.heappush(h, (B, A))
	
    time = 0
    while len(h) > 0:
        B, A = heapq.heappop(h)
        time += A
        if B < time:
            print("No")
            sys.exit()
    
    print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 28764