akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	//ぜんぜんわからん
	int H, W, K;
	cin >> H >> W >> K;

	ll mod = 1e9 + 7;
	ll dp[101][10] = {};
	dp[0][1] = 1;

	ll zentai[9] = { 0,1,2,3,5,8,13,21,34 };
	ll yoko[10] = {};
	switch (W) {
	case 2:
		yoko[1] = 1;
		break;
	case 3:
		yoko[1] = 1;
		yoko[2] = 1;
		break;
	case 4:
		yoko[1] = 2;
		yoko[2] = 1;
		yoko[3] = 2;
		break;
	case 5:
		yoko[1] = 3;
		yoko[2] = 2;
		yoko[3] = 2;
		yoko[4] = 3;
		break;
	case 6:
		yoko[1] = 5;
		yoko[2] = 3;
		yoko[3] = 4;
		yoko[4] = 3;
		yoko[5] = 5;
		break;
	case 7:
		yoko[1] = 8;
		yoko[2] = 5;
		yoko[3] = 6;
		yoko[4] = 6;
		yoko[5] = 5;
		yoko[6] = 8;
		break;
	case 8:
		yoko[1] = 13;
		yoko[2] = 8;
		yoko[3] = 10;
		yoko[4] = 9;
		yoko[5] = 10;
		yoko[6] = 8;
		yoko[7] = 13;
		break;
	}

	rep(i, H) {
		rep1(ii, W) {
			dp[i + 1][ii] += (dp[i][ii - 1] * yoko[ii - 1]) % mod;
			dp[i + 1][ii] += (dp[i][ii + 1] * yoko[ii]) % mod;
			dp[i + 1][ii] += (dp[i][ii] * (zentai[W] - yoko[ii - 1] - yoko[ii])) % mod;
			dp[i + 1][ii] %= mod;
		}
	}

	co(dp[H][K]);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int main(){
	int coun0 = 0, coun1 = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++){
		if (s[i] == '0') coun0++;
		else coun1++;
	}
	cout << min(coun0, coun1)*2 << endl;
	return 0;
 }

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scan.nextInt();
        int[] p = new int[n];
        for (int i = 0 ; i < n; i++) {
            p[i] = scan.nextInt();
        }
        long answer = 0;
        for (int i = 0; i < n - 2; i++) {
            int j = i + 1;
            int k = j + 1;
            if (p[i] < p[j] && p[j] < p[k]) {
                answer +=1;
            }
            if (p[k] < p[j] && p[j] < p[i]) {
                answer +=1;
            }
        }
        System.out.println(answer);
    }
}


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

int main(){
  string s;
  long long k;
  cin >> s >> k;
  bool flag = true;
  for ( int i = 0; i < k; i++){
    if ( s[i] != '1'){
      cout << s[i] << endl;
      flag = false;
      break;
    }
  }
  if ( flag ){
    cout << '1' << endl;
  }

  return 0;
}

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

using namespace std;

int main() {

    int K, S;
    cin >> K >> S;

    int X, Y, Z;

    int ans = 0;

    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (0 <= z && z <= K) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	int A,B;
	n=n%12+11;
	rep(0,i,24){
		if(i%2==0){
			a=a-b;
			
			if(i==n){
				cout<<a<<" "<<b<<endl;
				return 0;
			}
		}
		else{
			b=a+b;
			if(i==n){
				cout<<a<<" "<<b<<endl;
				return 0;
			}
		}
	}
}		
		


Measured memory_bytes: 3120
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;


class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int min = int.MaxValue;
        int score = 0;
        for (int i = 0; i < n; i++)
        {
            int s = int.Parse(Console.ReadLine());
            score += s;
            if (s % 10 != 0) min = Min(min, s);
        }
        Console.WriteLine(score % 10 != 0 ? score : Max(0, score - min));
    }
}

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

int main(){
  int cnt = 0;
  int N;cin >> N;
  for(int i=0;i<N;i++){
    int a;cin >> a;
    if(i%2==0&&a%2==1){
      cnt ++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3580
#include <stdio.h>

int a,b;

int main() {
  scanf("%d %d",&a,&b);
  a = a % 3;
  b = b % 3;
  int c=(a+b)%3;
 if(a==0){printf("Possible\n");}
 
 else{
   if(b==0){printf("Possible\n");}
   
   else{
      if(c==0){printf("Possible\n");}
      
      else{
        printf("Impossible\n");} }}
 
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <climits>
#include <cmath>
#include <stdio.h>

using namespace std;

const int max_n = 5e5 + 1;

long long fact[max_n];

long long mod = 1e9 + 7;

long long mpow(long long a, long long x)
{
    if (x == 0 or a == 1) return 1;
    long long temp = mpow(a, x/2);
    if (x & 1) return (temp * ((temp * a) % mod)) % mod;
    else return (temp * temp) % mod;
}

long long inverse(long long a)
{
    return mpow(a, mod - 2);
}

long long npr(long long n, long long r)
{
    return (fact[n] * inverse(fact[n - r])) % mod;
}
long long ncr(long long n, long long r)
{
    return (fact[n] * ((inverse(fact[n - r]) * inverse(fact[r])) % mod)) % mod;
}

int main()
{
    long long n, m; cin >> n >> m;
    fact[0] = 1;
    for (long long i = 1; i < max_n; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
    long long t1 = npr(m, n);
    long long t2 = t1; 
    for (long long i = 1; i <= n; i++)
    {
        long long t = (npr(m - i, n - i) * ncr(n, i)) % mod;
        if (i & 1) t2 = (t2 - t) % mod;
        else t2 = (t2 + t) % mod;
    }
    long long ans = ((t1 * t2) % mod + mod) % mod;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 7468
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();



int main(){

  int n,x; cin>>n>>x;
  int res = 0,sum=0;
  int m[n];
  REP(i, n){
      cin >> m[i];
      sum += m[i];
  }
  sort(m, m + n);
  x -= sum;
  res = n+x/m[0];

  cout << res << endl;
}

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

int n;
pair<int,int> poi[57];

double f(double x, double y, int v)
{
	x-=poi[v].first;
	y-=poi[v].second;
	return x*x+y*y;
}

double q(double x, double y)
{
	double ret=0;
	for (int i=1; i<=n; i++)
		ret=max(ret, f(x, y, i));
	return ret;
}

double g(double x)
{
	double bsa=-1000;
	double bsb=1000;
	for (int h=0; h<100; h++)
	{
		double bs1=(2*bsa+bsb)/3;
		double bs2=(bsa+2*bsb)/3;
		if (q(x, bs1)<q(x, bs2))
			bsb=bs2;
		else
			bsa=bs1;
	}
	return q(x, bsa);
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%d%d", &poi[i].first, &poi[i].second);
	double bsa=-1000;
	double bsb=1000;
	for (int h=0; h<100; h++)
	{
		double bs1=(2*bsa+bsb)/3;
		double bs2=(bsa+2*bsb)/3;
		if (g(bs1)<g(bs2))
			bsb=bs2;
		else
			bsa=bs1;
	}
	printf("%.9lf\n", sqrt(g(bsa)));
	return 0;
}


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

const int N=3e3+2;
int n,ans,mod,f[N],g[N][N],C[N][N];

inline int mul(int x,int y) {return 1ll*x*y%mod;}
int modpow(int x,int y,int p,int res=1) {
	for(;y;y>>=1,x=1ll*x*x%p) if(y&1) res=1ll*res*x%p;
	return res;
}
int main() {
    scanf("%d%d",&n,&mod);
    for(int i=0;i<=n;++i) {
        C[i][0]=g[i][0]=1;
        for(int j=1;j<=i;++j) 
            C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod,
            g[i][j]=(g[i-1][j-1]+mul(j+1,g[i-1][j]))%mod;
    }
    for(int i=0;i<=n;++i) {
        int tmp=modpow(2,modpow(2,n-i,mod-1),mod);
        int num=modpow(2,n-i,mod),qaq=1,res=0;
        for(int j=0;j<=i;++j) res=(res+mul(g[i][j],qaq))%mod,qaq=mul(qaq,num);
        ans=(ans+mul(mul((i&1)?mod-C[n][i]:C[n][i],tmp),res))%mod;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector <vector <int>> ab(h,vector <int> (w));
    rep(i,h){
        rep(j,w){
            cin >> ab[i][j];
        }
    }

    int b;
    rep(i,h){
        rep(j,w){
            cin >> b;
            ab[i][j]-=b;
            if(ab[i][j]<0){
                ab[i][j]*=-1;
            }
        }
    }
    ll ma=80*160+2;
    vector <vector <vector <int>>> dp(h,vector <vector <int>> (w,vector <int> (ma,0)));
    dp[0][0][ab[0][0]]=1;

    ll ans;

    rep(i,h){
        rep(j,w){
            rep(k,ma){
                if(dp[i][j][k]==1){
                    if(i==(h-1) and j==(w-1)){
                        ans=k;
                        break;
                    }
                    if(i<h-1){
                        dp[i+1][j][k+ab[i+1][j]]=1;
                        dp[i+1][j][abs(k-ab[i+1][j])]=1;
                        
                    }
                    if(j<w-1){
                        dp[i][j+1][k+ab[i][j+1]]=1;
                        dp[i][j+1][abs(k-ab[i][j+1])]=1;
                        
                    }
                }
            }
        }
    }

    cout << ans << endl;

    

    

    return 0;
}

Measured memory_bytes: 327696
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << max(0,c-(a-b)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll A,B,K;
	cin >> A >> B >> K;
	if (B - A +1<= 2*K){
		for (int i = A;i<=B;i++){
			cout << i <<endl;
		}
	}
	else{
		for(int i=A;i<=A+K - 1;i++){
			cout << i <<endl;
		}
		for(int i=B - K +1;i<=B;i++){
			cout << i <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
count = 0
for i in range(N):
    Ai = list(map(int, input().split()))
    temp = C
    for j in range(M):
        temp = temp + Ai[j]*B[j]
    if temp > 0:
        count = count + 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    char x = a[0] - 32, y = b[0] - 32, z = c[0] - 32;
    cout << x << y << z;
    return 0;
}

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

m_1 = (a + [0]).each_slice(2).map {|o, e| o - e }.inject(:+)

ans = a.inject([m_1]) do |memo, item|
  memo << (item - memo.last/2)*2
end
ans.pop

puts ans.join(' ')


Measured memory_bytes: 14188
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

const ll MOD = 1e9 + 7;

int main() {
  int H, W, K;
  while (cin >> H >> W >> K) {
    vector<ll> p(W);
    p[0] = 1;
    p[1] = 2;
    for (int i = 2; i < W; i++) p[i] = (p[i - 1] + p[i - 2]) % MOD;
    vector<ll> dp(W);
    dp[0] = 1;
    for (int i = 0; i < H; i++) {
      vector<ll> ndp(W, 0);
      for (int j = 0; j < W; j++) {
        int a = j;
        int b = W - 1 - a;
        ndp[j] += dp[j] * p[max(0, a - 1)] % MOD * p[max(0, b - 1)] % MOD;
        ndp[j] %= MOD;
        if (j > 0) {
          ndp[j - 1] += dp[j] * p[max(0, a - 2)] % MOD * p[max(0, b - 1)] % MOD;
          ndp[j - 1] %= MOD;
        }
        if (j + 1 < W) {
          ndp[j + 1] += dp[j] * p[max(0, a - 1)] % MOD * p[max(0, b - 2)] % MOD;
          ndp[j + 1] %= MOD;
        }
      }
      dp = ndp;
    }
    cout << dp[K - 1] << endl;
  }
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  if (s[0] == '9' || s[1] == '9') cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
const int INF = (1<<30);
const int MX = 25;
bool vis[MX][MX];
int cnt[MX][MX];
int dx[]={+1,-1,+0,+0};
int dy[]={+0,-0,+1,-1};
vector<string> v;
int row,col;
int mx=0;

void bfs(PII source){

    int i;
    queue<PII> q;
    q.push(source);
    vis[source.first][source.second]=1;

    while(!q.empty()){

        PII nd = q.front();
        q.pop();
        for(i=0; i<4; i++){
            int x = nd.first + dx[i];
            int y = nd.second + dy[i];
            if(x>=0 && x<row && y>=0 && y<col && v[x][y]=='.' && !vis[x][y]){
                q.push({x,y});
                vis[x][y]=1;
                cnt[x][y]=cnt[nd.first][nd.second]+1;
            }
        }

    }
}

void fnd(){

    int i,j;
     for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            //cout<<cnt[i][j]<<" ";
            mx = max(cnt[i][j],mx);
        }
        //cout<<"\n";
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int i,j;
    cin>>row>>col;

    for(i=0; i<row; i++){
        string str;
        cin>>str;
        v.push_back(str);
    }

    for(i=0; i<row; i++){
        for(j=0; j<col; j++){
            if(v[i][j]=='#') continue;
            memset(vis,0,sizeof(vis));
            memset(cnt,0,sizeof(cnt));
            //cout<<i<<" "<<j<<"\n";
            bfs({i,j});
            fnd();
        }
    }

    cout<<mx<<"\n";
    return 0;
}





Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

# Hを1段ずつ減らしていく.
# 値が正の区間 (left, right) が一つ見つかるごとに答えは1増える.

ans = 0
while sum(H) > 0:
    left = right = 0
    prev = 0
    segment = []
    for i, h in enumerate(H):
        if h == 0 and prev != 0: # H = {..., 0, *(left), *, ..., *, 0(right), ...} (*: 正数)
            right = i
            segment.append((left, right))
        elif h != 0 and prev == 0:
            left = i
            if i == N-1: # H = {..., 0, *(left)} (*: 正数)
                right = i + 1
                segment.append((left, right))
        elif h != 0 and i == N-1: #(prev != 0) H = {..., 0, *(left), ..., *, *} (*: 正数)
            right = i + 1
            segment.append((left, right))
        prev = h
    ans += len(segment)
    #  Hの値が正のところを1段減らす.
    for l, r in segment:
        for i in range(l, r):
            H[i] -= 1
print(ans)

Measured memory_bytes: 3064
Program ABC120A

integer a,b,k,i,j,c

read(*,*) a,b,k

if (a>=b) then
 i=b
 else
 i=a
end if

c=0

do j=i,1,-1
 if (mod(a,j)==0.and.mod(b,j)==0) then
  c=c+1
  if (c==k) then
   go to 10
  end if
 end if
end do

10 write(*,*) j

stop
end

Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
#define RALL(v) std::rbegin(v), std::rend(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Aug 15 22:15:43 JST 2020
 **/

template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; }

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

template <class Dist, class Key, class Delta>  // Delta: Key, (Key, Dist -> void) -> void
std::map<Key, Dist> dijkstra(Key s, Delta delta) {
    std::map<Key, Dist> dist;
    using P = std::pair<Dist, Key>;
    std::priority_queue<P, std::vector<P>, std::greater<P>> q;
    q.push({dist[s] = Dist(), s});
    while (!q.empty()) {
        std::pair<Dist, Key> p = q.top();
        q.pop();
        if (dist[p.second] < p.first) continue;
        delta(p.second, [&](Key to, Dist d) -> void {
            if (dist.count(to) && dist[to] <= p.first + d) return;
            q.push({dist[to] = p.first + d, to});
        });
    }
    return dist;
}

bool is_palindrome(const std::string& s) {
    REP(i, s.size()) {
        if (s[i] != s[s.size() - 1 - i]) return false;
    }
    return true;
}
const Int INF = 1e18;
const std::string dummy = "01";
signed main() {
    Int n;
    std::cin >> n;
    auto ss = make_vec<std::string>(2, n, "");
    std::vector<Int> c(n);
    REP(i, n) std::cin >> ss[0][i] >> c[i], ss[1][i] = std::string(RALL(ss[0][i]));
    using Key = std::pair<std::string, bool>;
    auto delta = [&](Key from, auto update) -> void {
        REP(i, n) {
            std::string s = from.first == dummy ? "" : from.first;
            std::string t = ss[!from.second][i];
            bool nxt_b = from.second ^ (s.size() < t.size());
            if (s > t) std::swap(s, t);
            if (s != t.substr(0, s.size())) continue;
            std::string nxt_s = t.substr(s.size(), t.size() - s.size());
            update(Key{nxt_s, nxt_b}, c[i]);
        }
    };
    Key s = {dummy, 0};
    auto res = dijkstra<Int>(s, delta);
    Int ans = INF;
    for (auto& p : res) {
        if (is_palindrome(p.first.first)) chmin(ans, p.second);
    }
    std::cout << (ans == INF ? -1 : ans) << std::endl;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main() {
	unsigned long n;
	unsigned long long ans = 0;
	unsigned long long a[1000001];
	unsigned long long b[1000001];
	cin >> n;
	for (unsigned long i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for (unsigned long i = n; i >= 1; i--) {
		if (a[i] % b[i] == 0);
		else {
			ans += b[i] - (a[i] % b[i]);
		}
	a[i - 1] += ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6784
#include <stdio.h>

#define more(a,b) ((a)>(b))?(a):(b)

int main(void)
{
  int A, B;
  int max;

  scanf("%d %d",&A,&B);
  max = more((A+B),(A-B));
  max = more(max,(A*B));

  printf("%d\n",max);

  return 0;
}



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

#define rep(i, N) for(int i = 0;i < N;i++)
#define int long long

using namespace std;


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

	N = N % K;

	if (N < K / 2.0) cout << N << endl;
	else cout << K - N << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using lint = long long;

void solve() {
    lint n;
    std::cin >> n;

    lint ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vector<int> xy;
vector<double> xbc;

int main() {
    cin >> N;
    xy.resize(N, 0);
    xbc.resize(N, 0.0);
    rep(i, N) {
        string s, t;
        cin >> s >> t;
        if (t == "JPY") {
            xy[i] = stoi(s);
        }
        else {
            xbc[i] = stod(s);
        }
    }

    ll ans1 = 0;
    double ans2 = 0.0;
    rep(i, N) {
        ans1 += xy[i];
        ans2 += 380000.0 * xbc[i];
    }

    printf("%f\n", ans1 + ans2);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using itn = int;
const ll MOD = 1000000007;

int main() {

    int s;
    cin >> s;

    vector<int> num(4);
    num[0] = s / 1000;
    num[1] = s % 1000 / 100;
    num[2] = s % 100 / 10;
    num[3] = s % 10;

    vector<char> op(3);

    for (int bit = 0; bit < (1 << 3); bit++) {

        int sum = num[0];
        
        for (int i = 0; i < 3; i++) {
            if (bit & (1 << i)) {
                op[i] = '+';
                sum += num[i+1];
            } else {
                op[i] = '-';
                sum -= num[i+1];
            }
        }
        if (sum == 7) {
            break;
        }
    }

    printf("%d%c%d%c%d%c%d=7", num[0], op[0],num[1], op[1], num[2], op[2], num[3]);
    
    return 0;
}

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

ll ans (ll x) {
  // 悔しみの舞
  if (x == -1 || x == 0) return 0;
  if (x % 2 == 1) return (x / 2 + 1) % 2;
  return ((x / 2) % 2) ^ x;
}

int main () {
  ll a, b;
  cin >> a >> b;
  cout << ( ans(b) ^ ans(a - 1) ) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string s, t; cin >> s >> t;
  rep(i,t.size()) cout << s[i] << t[i];
  if (s.size()-t.size()==1){
    cout << s[s.size()-1] << endl;
  }
  

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int f[44];
void fib(int n){
  int i;
  f[0]=f[1]=1;
  for(i=2;i<=n;i++)f[i]=f[i-1]+f[i-2];
}

int main(){
  int n;
  scanf("%d",&n);
  fib(n);
  printf("%d\n",f[n]);
  return 0;
}



Measured memory_bytes: 2108
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var a, b, c, d, e int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &a, &b, &c, &d, &e)

	switch {
	case a == 0:
		fmt.Println(1)
	case b == 0:
		fmt.Println(2)
	case c == 0:
		fmt.Println(3)
	case d == 0:
		fmt.Println(4)
	default:
		fmt.Println(5)
	}
}


Measured memory_bytes: 1824
# -*- coding: utf-8 -*-
n = int(input())

coin_list = [1]

i=1
while 6**i <= 10**5:
    coin_list.append(6**i)
    i+=1

i=1
while 9**i <= 10**5:
    coin_list.append(9**i)
    i+=1

#j番目までのコインでi円を作る時の最小回数#jは0始まり
dp = [[10**5 for i in range(n+1)] for j in range(len(coin_list))]
dp[0] = [i for i in range(n+1)]

for i in range(n+1):
    for j,coin in enumerate(coin_list):
        if j==0:
            continue
        if coin <= i:
            dp[j][i] = min(dp[j-1][i],dp[j][i-coin]+1)
        else:
            dp[j][i] = dp[j-1][i]
print(dp[-1][n])

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


  int main() {
  int A, B;
  cin >> A >> B;
	int tmp;
	int reverse = 0;
	int remain;
	int count = 0;
	for(int i = A; i <= B; i++){
		tmp = i;
		while(tmp != 0){
			remain = tmp % 10;
			reverse = reverse * 10 + remain;
			tmp /= 10;
		}
		if(reverse == i){
			count++;
		}
		reverse = 0;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = min(a)+min(b)

for i in range(M):
    c =list(map(int,input().split()))
    s = a[c[0]-1]+b[c[1]-1]-c[2]
    ans = min(s,ans)

print(ans)

Measured memory_bytes: 18736
#include <iostream>
#include <queue>

int main(){
	int m,n;
	
	while(std::cin >> n >> m){
		//n,mがゼロで終了
		if(n == 0 && m == 0){
			break;
		}
		
		int sum_cost = 0;
		std::priority_queue<int> vegetable;
		for(int i = 0; i < n; ++i){
			int cost;
			std::cin >> cost;
			vegetable.push(cost);
		}
		
		for(int i = 1; i <= n; ++i){
			if(i % m){
				sum_cost += vegetable.top();
				vegetable.pop();
			}
			else
				vegetable.pop();
		}
		
		std::cout << sum_cost << std::endl;
	}
	
	return 0;
}
		

Measured memory_bytes: 1228
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;

int main() {
	string s; cin >> s;
	ll ans = s.size() / 2;
	for (auto a : s) {
		if (a == 'p') ans -= 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto H = s[0];
    auto W = s[1];
    auto A = H.iota.map!(_ => readln.chomp).array;
    auto B = H.iota.map!(_ => readln.chomp).array;
    H.iota.map!(i => W.iota.map!(j => A[i][j] != B[i][j]).sum).sum.writeln;
}



Measured memory_bytes: 10580
d = {}
d["AC"] = 0
d["WA"] = 0
d["TLE"] = 0
d["RE"] = 0

N = int(input())
for _ in range(N):
    d[input()] += 1

for s in ["AC", "WA", "TLE", "RE"]:
    print(s + " x " + str(d[s]))

Measured memory_bytes: 9060
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int len_a, len_b;
 
  cin >> len_a;
  vector<int> vecA(len_a);
  for (int i = 0; i < len_a; i++) {
    cin >> vecA[i];
  }
 
  cin >> len_b;
  vector<int> vecB(len_b);
  for (int i = 0; i < len_b; i++) {
    cin >> vecB[i];
  }
 
  int len_min = min(len_a, len_b);
  for (int i = 0; i < len_min; i++) {
    if (vecB[i] > vecA[i]) {
      cout << 1 << endl;
      return 0;  // end
    } else if (vecB[i] < vecA[i]) {
      cout << 0 << endl;
      return 0;  // end
    } else {
      continue;
    }
  }
 
  if (len_b > len_a) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
 
  return 0;
}


Measured memory_bytes: 3108
def pali (s):
    if(1):
        start=0
        end=len(s)-1
        while(start<end):
            if(s[start]!=s[end]):
                return 0
            start+=1
            end-=1
        return 1
s=input()
n=len(s)
s1=s[:(n-1)//2]
s2=s[(n+3)//2-1:]
if(pali(s)==1 and (pali(s1)==1 and pali(s2)==1)):
    print ('Yes')
else:
    print ('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
 
int main() {
  ll x,y;
  cin>>x>>y;
  rep(z,x+1){
    if(2*x+2*z==y){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int main(){
	while(1){
		int x,y,s;
		cin>>x>>y>>s;

		if(x==0&&y==0&&s==0)
			break;

		int tmax=-1;

		for(int a=1;a<s-1;a++){
			int ax=a*(100+x)/100;
			int ay=a*(100+y)/100;

			for(int b=1;b<s-1;b++){
				int bx=b*(100+x)/100;
				int by=b*(100+y)/100;

				if(ax+bx==s){
					tmax=max(tmax,ay+by);
				}
				else if(ax+bx>s){
					break;
				}
			}
		}
	
		cout<<tmax<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2988
n,k=(int(i) for i in input().split())
r,s,p=(int(i) for i in input().split())
dic={'r':r,'s':s,'p':p}
wazap={'r':'p','s':'r','p':'s'}
rail=input()
l=[[] for i in range(k)]
ans=0
for i in range(len(rail)):
  l[i%k].append(wazap[rail[i]])
for i in range(k):
  flag=0
  ans+=dic[l[i][0]]
  for j in range(len(l[i])-1):
    if l[i][j+1]==l[i][j]:
      if flag==1:
        ans+=dic[l[i][j+1]]
        flag=0
      else:
        flag=1
    else:
      ans+=dic[l[i][j+1]]
      flag=0
print(ans)
        

Measured memory_bytes: 50176
#include<stdio.h>
#define abs(opr) ((opr)<0?-(opr):(opr))

int main(void){
    long long x,k,d;
    scanf("%lld %lld %lld",&x,&k,&d);
    long long distc = x / d; 
    if(abs(distc) >= k)
        printf("%lld",abs(((abs(distc) - k) * (distc / abs(distc)))*d + x % d));
    else printf("%lld",abs(k%2==abs(distc%2)?x%d:d-abs(x%d)));
}

Measured memory_bytes: 1724
#include <cstdio>
#include<complex>

using namespace std;
typedef complex<double> P;
 
int main() {
  int n;
  double ax, ay, bx, by, cx, cy, dx, dy;
  scanf("%d", &n);
  while(n--) {
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&ax, &ay, &bx, &by, &cx, &cy, &dx, &dy);
    P k = P(bx - ax, by - ay) * P(dx - cx, cy - dy);
    if(k.imag() == 0) {
      printf("2\n");
    } else if(k.real() == 0) {
      printf("1\n");
    } else {
      printf("0\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2760
#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;
  cin >> n;
  char s;
  char last = ' ';
  char last2 = ' ';
  int ans = 0;
  rep(i,n) {
    cin >> s;
    // cout << last2 << last << s<< endl;
    if(last=='B' && last2=='A' && s =='C'){
      ans ++;
    }
    last2=last;
    last=s;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char c;
    cin>>c;
    if(c>='a'&&c<='z')
    {
        cout<<'a'<<endl;
    }
    else
    {
        cout<<'A'<<endl;
    }
    return 0;
}



Measured memory_bytes: 3628
#include <stdio.h>

  int main(){
    int a,ac=0,wa=0,tle=0,re=0;
    char huruf[10];
    scanf("%d",&a);
    for(int i=0;i<a;i++){
      scanf("%s",huruf);
      if(huruf[0] == 'A'){
        ac++;
      }else if(huruf[0]=='W'){
        wa++;
      }else if(huruf[0]=='T'){
        tle++;
      }else if(huruf[0]=='R'){
        re++;
      }
    }
    printf("AC x %d\n",ac);
    printf("WA x %d\n",wa);
    printf("TLE x %d\n",tle);
    printf("RE x %d",re);
  return 0;
  }


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
int a[10][10];
int main()
{
    int n;
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
            scanf("%d", &a[i][j]);
    scanf("%d", &n);
    int x;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &x);
        for (int i = 1; i <= 3; i++)
            for (int j = 1; j <= 3; j++)
            {
                if (x == a[i][j])
                    a[i][j] = -1;
            }
    }
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++)
        {
            if (a[i][j] == -1 && a[i + 1][j] == -1 && a[i + 2][j] == -1)
            {
                printf("Yes\n");
                return 0;
            }
            if (a[i][j] == -1 && a[i][1 + j] == -1 && a[i][2 + j] == -1)
            {
                printf("Yes\n");
                return 0;
            }
            if (a[i][j] == -1 && a[i + 1][j + 1] == -1 && a[i + 2][j + 2] == -1)
            {
                printf("Yes\n");
                return 0;
            }
            if (j == 3 && a[i][j] == -1 && a[i + 1][j - 1] == -1 && a[i + 2][j - 2] == -1)
            {
                printf("Yes\n");
                return 0;
            }
        }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		long mod = 1000000007;
		while(sc.hasNext()){
			char [] c = sc.next().toCharArray();
			int [] data = new int[26];
			
			for(int i = 0; i < c.length; i++){
				data[c[i] - 'a']++;
			}
			
			boolean flg = true;
			for(int i = 0;i <data.length; i++){
				if(data[i] % 2 != 0){
					flg = false;
					break;
				}
			}
			
			System.out.println(flg ? "Yes" : "No");
		}

	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

long long int nC2(long long int n){
    if(n>=0){
        return n*(n-1)/2;
    }
    else{
        return 0;
    }
}

int main() {
    int N;
    cin >> N;
    vector<string> vec(N);
    for(int i=0; i<N; i++){
        string c;
        cin >> c;
        sort(c.begin(), c.end());
        vec[i] = c;
    }
    sort(vec.begin(), vec.end());

    

    vector<int> ve;

    int count=1;
    for(int i=1; i<N; i++){
        if(vec[i]!=vec[i-1]){
            ve.push_back(count);
            count =1;
        }
        else{
            count++;
        }
    }
    ve.push_back(count);

    long long int ans=0;
    for(int i=0; i<ve.size(); i++){
        ans += nC2(ve[i]);
    }

    cout << ans << endl;

}


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

#define ll long long int

int main()
{
	ll A,B,C;
	cin>>A>>B>>C;
	if(A==B && B==5 && C==7) cout<<"YES";
	else if(A==C && C==5 && B==7) cout<<"YES";
	else if(B==C && C==5 && A==7) cout<<"YES";
	else cout<<"NO";
	
	
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep (i, n) cin >> a[i];
  unordered_set<int> s(all(a));
  cout << (a.size() == s.size() ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 8832
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000000000LL
#define MOD 1000000007

long long fun(long long n, long long b) {
	long long sum = 0;

	while (n) {
		sum += n % b;
		n /= b;
	}

	return sum;
}

int main() {
	long long n, s, b = 2, ans = INF;;

	cin >> n >> s;

	if (n == 1) {
		if (s == 1) {
			cout << 2;
		}
		else {
			cout << -1;
		}
		return 0;
	}

	while (b * b <= n) {
		if (fun(n,b) == s) {
			ans = min(ans, b);
		}
		b++;
	}

	b = 1;

	while (b * b <= n - s) {
		if ((n - s) % b == 0) {
			if (fun(n, (n - s) / b + 1) == s) {
				ans = min(ans, (n - s) / b + 1);
			}
		}
		b++;
	}

	if (fun(n, n) == s) {
		ans = min(ans, n);
	}
	else if (fun(n, n + 1) ==  s) {
		ans = min(ans, n + 1);
	}

	if (ans != INF) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[3010][3010] = {};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll sum[3010] = {};
    rep(i,1,N+1){
        dp[0][N-i] = 1;
    }
    rep(i,0,N) sum[i+1] = sum[i] + dp[0][i];

    rep(i,1,N){
        rep(j,0,N-i){
            if(S[i-1] == '<'){
                dp[i][j] += (sum[N] - sum[j+1] + MOD) % MOD;
                dp[i][j] %= MOD;
            }else{
                dp[i][j] += (sum[j+1] - sum[0] + MOD) % MOD;
                dp[i][j] %= MOD;
            }
        }
        sum[0] = 0;
        rep(j,0,N){
            sum[j+1] = sum[j] + dp[i][j];
            sum[j+1] %= MOD;
        }
    }
    ll ans = 0;
    rep(i,0,N) (ans += dp[N-1][i]) %= MOD;
    print(ans);

    

}

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

typedef struct {
	int no;
	int num;
} place_t;

int comp(const void* x,const void* y) {
	place_t* a=(place_t*)x;
	place_t* b=(place_t*)y;
	if(a->num<b->num)return 1;
	if(a->num>b->num)return -1;
	if(a->no>b->no)return 1;
	if(a->no<b->no)return -1;
	return 0;
}

int main(void) {
	place_t place[100];
	int i,j,n,m;
	int one;
	while(1) {
		scanf("%d %d",&n,&m);
		if(n==0 && m==0)break;
		for(i=0;i<100;i++) {
			place[i].no=i;
			place[i].num=0;
		}
		for(i=0;i<n;i++) {
			for(j=0;j<m;j++) {
				scanf("%d",&one);
				if(one)place[j].num++;
			}
		}
		qsort(place,m,sizeof(place_t),comp);
		for(i=0;i<m-1;i++) {
			printf("%d ",place[i].no+1);
		}
		printf("%d\n",place[m-1].no+1);
	}
	return 0;
}

Measured memory_bytes: 428
def warshall_floyd(d,N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k]+d[k][j])
    return d

# N:頂点, M:辺
N, M = map(int, input().split())

d = [[float('inf') for i in range(N)] for i in range(N)]

edges = []
for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c
    edges.append([a,b,c])

for i in range(N):
    d[i][i] = 0

warshall_floyd(d,N)
cnt = 0
for edge in edges:
    if d[edge[0]][edge[1]] != edge[2]:
        cnt += 1

print(cnt)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int val=n/i;
        cnt+=val;
        if(n%i==0)
            cnt--;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, c;
    cin >> n >> c;
    vector<vector<int>> stc(c+1, vector<int>(2 * 1e5 + 1));
    for(int i = 0; i < n; i++)
    {
        int s, t, c;
        cin >> s >> t >> c;
        s *= 2;
        s -= 1;
        t *= 2;
        for(int j = s; j <= t; j++)
        {
            stc[c][j]++;
        }
    }
    int ans = 0;
    for(int i = 0; i <= 2 * 1e5 + 1; i++)
    {
        int tmp = 0;
        for(int j = 1; j <= c; j++)
        {
            if(stc[j][i] != 0) tmp++;
        }
        
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 26608
road = []

for i in range(3):
	a, b = map(int, input().split())
	road.append(a)
	road.append(b)

if road.count(1) >= 3:
	print('NO')
elif road.count(2) >= 3:
	print('NO')
elif road.count(3) >= 3:
	print('NO')
elif road.count(4) >= 3:
	print('NO')
else:
	print('YES')

Measured memory_bytes: 3060
# include <iostream>
# include <cstdio>
using namespace std;
const int N = 4e3 + 12;
int a[N],b[N],black[N][N],white[N][N],n,bpos[N],wpos[N],dp[N][N];
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n << 1;i++)
	{
		char ch[2];
		scanf("%s %d",ch,&a[i]);b[i] = ch[0];
		if(b[i] == 'B')bpos[a[i]] = i;
		else wpos[a[i]] = i;
    }
    for(int i = 1;i <= n << 1;i++)
     for(int j = 0;j <= n;j++)
     {
     	black[i][j] = black[i - 1][j] + (a[i - 1] > j && b[i - 1] == 'B'); 
     	white[i][j] = white[i - 1][j] + (a[i - 1] > j && b[i - 1] == 'W');
     }
     for(int i = 0;i <= n;i++) 
      for(int j = 0;j <= n;j++)
      {
      	if(!i && !j)continue;
      	int x = bpos[i],y = wpos[j];
      	dp[i][j] = 0x3f3f3f3f;
      	if(i)dp[i][j] = min(dp[i][j],dp[i - 1][j] + black[x][i - 1] + white[x][j]);
      	if(j)dp[i][j] = min(dp[i][j],dp[i][j - 1] + black[y][i] + white[y][j - 1]);
      }
      printf("%d\n",dp[n][n]);
}

Measured memory_bytes: 159616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author RiaD
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class TaskA {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		in >> s;
		auto pos = s.find('C');
		if (pos != string::npos && s.find('F', pos) != string::npos) {
			out << "Yes\n";
		} else {
			out << "No\n";
		}
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	TaskA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	in.tie(0);
	out << std::fixed;
	out.precision(20);
	return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        a = dp[j-w]+v
        if dp[j] < a:
            dp[j] = a

print(dp[W])

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

int main()
{
  int a,b,c,d;

  cin >> a >> b >> c >> d;

  if (b < c || d < a){
    cout << 0;
  }else{
    int s[4];
    s[0] = a;
    s[1] = b;
    s[2] = c;
    s[3] = d;
    sort(s,s+4);
    cout << s[2] - s[1];
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		var A = new List<long>(N);
		for(int i = 0; i < N; i++)
			A.Add(GetLong());
		A.Sort();

		long ans = A[N - 1] - A[0];
		int usedLeft = 0;
		int usedRight = N - 1;
		int nextLeft = 1;
		int nextRight = N - 2;
		while(nextRight >= nextLeft)
		{
			bool useLeft = false;
			bool addLeft = false;
			long tmp = long.MinValue;

			if(Math.Abs(A[usedLeft] - A[nextLeft]) > tmp)
			{
				tmp = Math.Abs(A[usedLeft] - A[nextLeft]);
				useLeft = true;
				addLeft = true;
			}

			if(Math.Abs(A[usedLeft] - A[nextRight]) > tmp)
			{
				tmp = Math.Abs(A[usedLeft] - A[nextRight]);
				useLeft = false;
				addLeft = true;
			}

			if(Math.Abs(A[usedRight] - A[nextLeft]) > tmp)
			{
				tmp = Math.Abs(A[usedRight] - A[nextLeft]);
				useLeft = true;
				addLeft = false;
			}

			if(Math.Abs(A[usedRight] - A[nextRight]) > tmp)
			{
				tmp = Math.Abs(A[usedRight] - A[nextRight]);
				useLeft = false;
				addLeft = false;
			}

			ans += tmp;

			if(addLeft)
				usedLeft = useLeft ? nextLeft : nextRight;
			else
				usedRight = useLeft ? nextLeft : nextRight;

			if(useLeft)
				nextLeft++;
			else
				nextRight--;				
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

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

  // 言及していない場合は-1
  vector<vector<int>> g(n, vector<int>(n, -1));
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      x--; // 0-indexed
      g.at(i).at(x) = y;
    }
  }

  // bit全探索
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    vector<int> d(n);
    // j人目の人が「1:正直者」か「0:不親切な人」か
    for (int j = 0; j < n; j++) {
      d.at(j) = ((i >> j) & 1);
    }

    bool ok = true;
    for (int j = 0; j < n; j++) {
      // j番目の人が「0:不親切な人」の場合はスキップ
      if (d.at(j) == 0) { continue; }
      // j番目の人が「1:正直者」の場合は、証言に矛盾がないか確認
      for (int k = 0; k < (int) g.at(j).size(); k++) {
        // k番目の人について証言していない場合は、スキップ
        if (g.at(j).at(k) == -1) { continue; }
        // k番目の人について証言と仮定が一致しない場合は、フラグを false にする
        if (g.at(j).at(k) != d.at(k)) { ok = false; }
      }
    }

    // 証言と矛盾が無ければ「1:正直者」の数をカウント
    // 最大の正直車の数を更新する
    if (ok) {
      ans = max(ans, __builtin_popcount(i));
    }
  }

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


Measured memory_bytes: 3600
n, q = [int(i) for i in input().split()]
s = input()
l =[]
r =[]
for i in range(q):
    l1, r1 = [int(i) for i in input().split()]
    l.append(l1)
    r.append(r1)

Sum = [0]
for i in range(len(s)):
    if s[i-1]=="A" and s[i]=="C":
        Sum.append(Sum[i]+1)
    else:
        Sum.append(Sum[i])

#print(Sum)
for i in range(q):
    print(Sum[r[i]]-Sum[l[i]])


Measured memory_bytes: 14228
#include <iostream>

using namespace std;

int main() {
  long long a, b, k;
  cin >> a >> b >> k;
  long long a2 = (a - k < 0) ? 0 : a - k;
  long long b2 = (a - k < 0) ? ((b - k + a < 0) ? 0 : (b - k + a)) : b;
  cout << a2 << " " << b2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

using ll = long long;
using namespace std;

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

    REP(i, N + 1) {
        REP(j, N - i + 1) {
            int k = N - i - j;
            if (k < 0)continue;
            if (i * 10000 + j * 5000 + k * 1000 == Y) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256