akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define NIL -1
#define MAX 100000

typedef struct{
  int p,l,r;
}Node;

Node T[MAX];

int n;

int depth(int a){
  
  int num=0,s=T[a].p;
  
  while(s!=NIL){
    num++;
    s=T[s].p;
  }
  return num;
}

int main(){

  int i,j,x,d,c,l;

  scanf("%d",&n);
  
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0;i<n;i++){
    scanf("%d %d",&x,&d);
    for(j=0;j<d;j++){
      scanf("%d", &c);
      if(j==0) T[x].l=c;
      else T[l].r =c;
      l=c;
      T[c].p=x;
    }
  }
  for(i=0;i<n;i++){
  printf("node %d: parent = %d, depth = %d, ", i, T[i].p,depth(i));

  if(T[i].p==NIL) printf("root, ");
  else if(T[i].l!=NIL) printf("internal node, ");
  else printf("leaf, ");

  printf("["); 

  for(j=0, c=T[i].l; c!=NIL; j++, c=T[c].r){
    if(j==0) printf("%d", c);
    else printf(", %d", c);
  }
  printf("]\n");
  }
  return 0;
}
  

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    char a[105];
	gets(a);
    bool b=0;
    for(int i=0;a[i];i++)
	{
        if(a[i]=='C')
            b=1;
        if(a[i]=='F'&&b==1)
		{
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_H = 55, MAX_W = 55;
const int INF = 1000100100;

int color[MAX_H][MAX_W], c[MAX_H][MAX_W];
int w, h;


void init(){
    rep(i,MAX_H){
        rep(j,MAX_W){
            color[i][j] = INF;
            c[i][j] = 0;
        }
    }
}

void dfs(int hi, int wi, int col){
    if(color[hi][wi] == INF) color[hi][wi] = col;

    for(int i=-1; i<=1; i++){   // 高さ
        for(int j=-1; j<=1; j++){   // 幅
            int nh = hi+i, nw = wi+j;
            if(nh<0 || nw<0 || nh>=h || nw>=w) continue;
            if(c[nh][nw] == 1 && color[nh][nw] == INF) dfs(nh, nw, col);
        }
    }
}

int main()
{
    while(true){
        cin >> w >> h;
        if(w == 0 && h == 0) break;

        init();

        rep(i,h){
            rep(j,w){
                cin >> c[i][j];
            }
        }

        int col = 0;
        rep(i,h){
            rep(j,w){
                if(color[i][j] == INF && c[i][j] == 1){
                    dfs(i, j, col);
                    ++col;
                }
            }
        }
        set<int> s;
        rep(i,h){
            rep(j,w){
                if(color[i][j] != INF) s.insert(color[i][j]);
            }
        }
        cout << s.size() << endl;
    }
}


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

int main() {
    int a, b, q; cin >> a >> b >> q;
    vector<long long> v(a), w(b);
    for (int i = 0; i < a; i++) cin >> v[i];
    for (int i = 0; i < b; i++) cin >> w[i];
    while (q--) {
        long long x; cin >> x;
        long long v1, v2, w1, w2;
        if (v[a-1] < x) {
            v1 = abs(v[a-1]-x); v2 = 1e15;
        } else {
            int i = lower_bound(v.begin(), v.end(), x) - v.begin();
            if (i == 0) {
                v1 = 1e15; v2 = abs(v[0]-x);
            }
            else {
                v1 = abs(v[i-1]-x); v2 = abs(v[i]-x);
            }
        }
        if (w[b-1] < x) {
            w1 = abs(w[b-1]-x); w2 = 1e15;
        } else {
            int i = lower_bound(w.begin(), w.end(), x) - w.begin();
            if (i == 0) {
                w1 = 1e15; w2 = abs(w[0]-x);
            }
            else {
                w1 = abs(w[i-1]-x); w2 = abs(w[i]-x);
            }
        }
        long long ans = 1e15;
        ans = min({ans, v1*2+w2, v1+w2*2, w1*2+v2, w1+v2*2, max(v1, w1), max(v2, w2)});
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 2944
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	X := readInt()
	D := 0
	count := 0
	for i := 0; i < N && D <= X; i++ {
		count++
		L := readInt()
		D += L
	}
	if D <= X {
		count++
	}
	println(count)
}

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


Measured memory_bytes: 640
#include <cstdint>
#include <cstdio>
using namespace std;
inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline uint_fast32_t read(){
  uint_fast32_t a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
uint_fast32_t h[100001];
int main(){
  uint_fast32_t n=read(),a=read(),b=read(),i;a-=b;
  double a_=1.0/a;
  for(i=0;i<n;++i)h[i]=read();
  uint_fast32_t left=0,right=1000000000;
  int_fast64_t temp,cnt=0,mid;
  while (right>left+1) {
    mid=(right+left)>>1;
    cnt=0;
    for(i=0;i<n;++i){
      temp=h[i]-b*mid+a-1;
      if(temp>0)cnt+=temp*a_;
    }
    if(cnt<=mid)right=mid;
    else left=mid;
  }
  printf("%u\n",right);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
#define watch(x) cout << "["<<(#x) << " is " << (x) << "]" << endl
void watchVecI(vector<int>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}
void watchVecS(vector<string>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}
void watchVecC(vector<char>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i];
	}
	cout << endl;
}
long double binets(double n){
	long double first = (1+sqrt(5.0))/2.0;
	long double second = (1-sqrt(5.0))/2.0;
	long double third = pow(first,n)-pow(second,n);
	return (third/sqrt(5.0));
}


void solve(){
  char a;
  cin >> a;
  if(a<=90){
    cout << 'A' << endl;
  }
  else{
    cout << 'a' << endl;
  }
}

int main(){
//	freopen("I_P.txt", "r", stdin);
    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }
	return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll n;
    cin >> n;
    vector<ll> bits;
    ll f = n;
    while(n >= 0) {
        ll rem = n % 10;
        n = n / 10;
        bits.push_back(rem);
        if (n == 0) {
            break;
        }
    }
    ll sum = 0;
    for (ll i = 0;i < bits.size();i++) {
        sum += bits[i];
    }
    if (f % sum == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string t;
    cin >> t;
    for(int i=0;i<t.size();i++){
        if(t.at(i)=='?'){
            t.at(i)='D';
        }
    }
    cout<<t<<endl;
}
    



Measured memory_bytes: 3752
//
// Created by yamunaku on 2020/08/09.
//

#include <bits/stdc++.h>

using namespace std;

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

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

int main(){
    //CFS;
    int n;
    cin >> n;
    mtl num(101, vl(101, 0));
    rep(i, n){
        long double d;
        cin >> d;
        int two = 0, five = 0;
        rep(t, 9){
            d *= 10;
            two--, five--;
        }
        CST(10);
        ll dd = (ll)round(d);
        while(dd % 2 == 0){
            dd /= 2;
            two++;
        }
        while(dd % 5 == 0){
            dd /= 5;
            five++;
        }
        num[two + 50][five + 50]++;
    }
    ll ans = 0, ans2 = 0;
    rep(i, 101){
        rep(j, 101){
            if(i + i >= 100 && j + j >= 100){
                ans2 += num[i][j] * (num[i][j] - 1) / 2;
            }
            rep(k, 101){
                rep(l, 101){
                    if(i == k && j == l) continue;
                    if(i + k >= 100 && j + l >= 100){
                        ans += num[i][j] * num[k][l];
                    }
                }
            }
        }
    }
    cout << ans/2 + ans2 << endl;
    return 0;
}

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

using namespace std;

int main(void){
  int N,i,count=1;
  unsigned long long int ans=0;
  cin >> N;
  string S[N];
  for(i=0;i<N;i++){
    cin >> S[i];
  }
  for(i=0;i<N;i++){
    sort(S[i].begin(),S[i].end());
  }
  sort(S,S+N);
  for(i=0;i<N-1;i++){
    if(S[i]==S[i+1]){
      ans+=count;
      count++;
    }
    else{
      count=1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

int to_int(int c){
    if(0 <= c && c <= 9) return (c+48);
    else return -1;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    string S;cin >> S;
    ll ans = 0;
    REP(i,1000){
        string T;
        if(i < 10){
            T = "00" + to_string(i);
        }
        else if(i < 100){
            T = "0" + to_string(i);
        }
        else T = to_string(i);
        int j = 0;
        REP(k,S.size()){
            if(T[j] == S[k]){
                j++;
                if(j == 3){ans++;break;}
            }
        }
    }
    cout << ans << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for (int i = 1; i <= n; i++) {
    double tmp = 1.0 / n;
    int now = i;
    while (now < k) {
      now *= 2;
      tmp /= 2;
    }
    ans += tmp;
  }
  printf("%.12f\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define chmax(x,y) x = max(x, y)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(b < 0) {
        if(d < 0) cout << a * c << endl;
        else if(c < 0) cout << a * c << endl;
        else cout << b * c << endl;
    }
    else if(a < 0) {
        if(d < 0) cout << a * c << endl;
        else if(c < 0) cout << max(a * c, b * d) << endl;
        else cout << b * d << endl;
    }
    else {
        if(d < 0) cout << a * d << endl;
        else if(c < 0) cout << b * d << endl;
        else cout << b * d << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};

int main() {
	int a,b;
  cin>>a>>b;
	if(b%a==0)cout<<a+b;
	else cout<<b-a;
	return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task1 solver = new Task1();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task1 {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {
			String s = sc.next();
			out.println(s.indexOf('a') >= 0 && s.indexOf('b') >= 0 && s.indexOf('c') >= 0 ? "Yes" : "No");
		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

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

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

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

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

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

	}
}



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

int N,M,K;
int E[100],A[100];
int v[4];

double dp[51][5000];
void solve(){


    dp[0][0]=1.0;
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i;j--){
            for(int k=0;k<=i*100;k++){
                for(int l=0;l<M;l++){
                    int toval=k;
                    int topos=min(N,j+v[l]);
                    if(E[topos]==1)topos=min(N,topos+A[topos]);
                    else if(E[topos]==2)toval+=A[topos];
                    else if(E[topos]==3)toval=max(0,toval-A[topos]);
                    dp[topos][toval]+=dp[j][k]/M;
                }
                dp[j][k]=0;
            }

        }
    }

    double sum=0;
    for(int i=0;i<5000;i++)sum+=dp[N][i]*i;
    cout<<(int)sum<<endl;
}

bool input(){
    memset(dp,0,sizeof(dp));
    memset(E,0,sizeof(E));
    memset(A,0,sizeof(A));

    cin>>M>>N>>K;
    if(M==0&&N==0&&K==0)return false;
    for(int i=0;i<M;i++)cin>>v[i];
    for(int i=0;i<K;i++){
        int n,e,a;
        cin>>n>>e>>a;
        E[n]=e;
        A[n]=a;
    }
    return true;
}

int main(){
    while(input())solve();
    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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

signed main()
{   
  gearup;
  int h,w,k;cin>>h>>w>>k;
  vvs c(h,vs(w));
  //入力
  int num = 1;
  rep(i,h)rep(j,w){
    char ch;
    cin>>ch;
    if(ch == '#')c[i][j] = to_string(num++);
    else c[i][j] = ch;
  }
  
  //左からみぎに
  rep(i,h)rep(j,w-1)if(c[i][j+1] == ".")c[i][j+1] = c[i][j];
  //みぎから左
  rep(i,h)for(int j=w-1;j>0;j--)if(c[i][j-1] == ".")c[i][j-1] = c[i][j];
  //上から下に.があれば上の文字で置き換える
  rep(i,h-1)rep(j,w)if(c[i+1][j] == ".")c[i+1][j]=c[i][j];
  //下から上に
  for(int i=h-1;i>0;i--)rep(j,w)if(c[i-1][j] == ".")c[i-1][j]=c[i][j];
  //出力
  rep(i,h){
    rep(j,w){
      if(j)cout << " ";
      cout << c[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  if (a+b > c+d) cout << "Left" << endl;
  else if (a+b == c+d) cout << "Balanced" << endl;
  else cout << "Right" << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll n;
vll a;
vi G[5005];

int num[5005];
ll dp[5005][5005][2]; // vで条件を満たすようにi辺取り除いたときvの連結成分の和の最小値(j=1なら全ての成分が正である)
ll sub[5005][2];

void dfs(int v, int p){
  vi child;
  for(auto &nv: G[v]){
    if(nv==p) continue;
    dfs(nv,v);
    child.push_back(nv);
  }
  
  dp[v][0][(a[v]>0)]=a[v];
  
  for(auto &nv: child){
    for(int i=0; i<=num[v]; i++){
      for(int j=0; j<=num[nv]; j++){
        rep(k1,2) rep(k2,2){
          ll v1=dp[v][i][k1], v2=dp[nv][j][k2];
          if(max(v1,v2)==LINF) continue;
          chmin(sub[i+j][k1&k2], v1+v2);
          if(k2==1 || v2<0) chmin(sub[i+j+1][k1], v1);
        }
      }
    }
    num[v]+=num[nv]+1;
    for(int i=0; i<=num[v]; i++) for(int j=0; j<2; j++){
      dp[v][i][j]=sub[i][j];
      sub[i][j]=LINF;
    }
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  cin>>n;
  a.resize(n);
  rep(i,n) cin>>a[i];
  rep(i,n-1){
    ll a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  rep(i,n+1) rep(j,n+1) rep(k,2) dp[i][j][k]=LINF;
  rep(i,n+1) rep(j,2) sub[i][j]=LINF;
  dfs(0,-1);
  
  ll ans=LINF;
  // rep(i,n) cout<<dp[0][i][0]<<' ';
  // cout<<endl;
  // rep(i,n) cout<<dp[0][i][1]<<' ';
  // cout<<endl;
  
  rep(i,n){
    if(dp[0][i][0]<0 || dp[0][i][1]!=LINF){
      ans=i;
      break;
    }
  }
  
  cout<<ans<<endl;
  
}

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

int main()
{
	int W, H, x, y, r;
	do
	{
		cin >> W >> H >> x >> y >> r;
	} while (x < -100 || y < -100 || x > 100 || y > 100 ||  W <= 0 || H <= 0 || r <= 0 || W > 100 || H > 100 || r > 100);
	if (r <= x && r <= y && x <= W - r && y <= H - r)
		cout << "Yes" << endl;
	else if (x < r || y < r || W - r < x || H - r < y)
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
    #define lint long long
    #define st first
    #define nd second
    #define INF 0x3f3f3f3f
     
    using namespace std;
     
     
    int main(){
    	ios_base::sync_with_stdio(false);
    	cin.tie(NULL); cout.tie(NULL);
    	char x; cin>>x;
    	if('a'<=x && x <='z')
    		cout<<"a\n";
    	else if('A'<=x && x <='Z')
    		cout<<"A\n";
    	
    	return 0;	
    }

Measured memory_bytes: 3616
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int N = ReadLineParseInt();
        long[] TA = ReadLine().Split(' ').Select(long.Parse).ToArray();
        long T = TA[0];
        long A = TA[1];
        for(int i = 1; i < N; i++)
        {
            TA = ReadLine().Split(' ').Select(long.Parse).ToArray();


            long minMulti = Max((T - 1) / TA[0] + 1, (A - 1) / TA[1] + 1);
            T = TA[0] * minMulti;
            A = TA[1] * minMulti;
        }
        WriteLine(T + A);
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n)cin >> a.at(i);
  int ans=0;

  for(int i=0;i<n;i+=2){
    if(a.at(i)%2==1)ans++;
  }
  cout << ans << endl;
}


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

int main()
{
    long long X, Y;
    cin >> X >> Y;

    if (abs(X - Y) <= 1)
    {
        cout << "Brown" << endl;
    }
    else
    {
        cout << "Alice" << endl;
    }

    // vector<vector<bool>> dp(X + Y + 1, vector<bool>(X + Y + 1, false));
    // dp[0][0] = false;
    // dp[1][0] = false;
    // dp[0][1] = false;
    // dp[1][1] = false;
    // dp[2][0] = true;
    // dp[0][2] = true;
    // for (long long distance = 3; distance <= X + Y; distance++)
    // {
    //     for (long long x = 0; x <= distance; x++)
    //     {
    //         long long y = distance - x;
    //         for (long long i = 1; 2 * i <= x; i++)
    //         {
    //             if (!dp[x - 2 * i][y + i])
    //             {
    //                 dp[x][y] = true;
    //                 break;
    //             }
    //         }
    //         for (long long i = 1; 2 * i <= y; i++)
    //         {
    //             if (!dp[x + i][y - 2 * i])
    //             {
    //                 dp[x][y] = true;
    //                 break;
    //             }
    //         }
    //     }
    // }
    // for (auto a : dp)
    // {
    //     for (auto b : a)
    //     {
    //         cout << b << " ";
    //     }
    //     cout << endl;
    // }
    // if (dp[X][Y])
    // {
    //     cout << "Alice" << endl;
    // }
    // else
    // {
    //     cout << "Brown" << endl;
    // }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    string n;
    cin>>n;
    int sz = n.size() - 1;
    if(n[sz]=='2' || n[sz]=='4' || n[sz]=='5' || n[sz]=='7' || n[sz]=='9'){
        cout<<"hon";
    }
    else if(n[sz]=='0' || n[sz]=='1' || n[sz]=='6' || n[sz]=='8'){
        cout<<"pon";
    }
    else{
        cout<<"bon";
    }
    return 0;
}

Measured memory_bytes: 3036
s = input()
ans, sum = 0, 0
for i in range(len(s)):
    cur = s[i]
    if (cur == 'A' or cur == 'T' or cur == 'G' or cur == 'C'):
        sum += 1
    else: sum = 0
    ans = max(ans, sum)
print(ans)


Measured memory_bytes: 2940
N, M = map(int, input().split())
V = []
INF = float("inf")
dp = [INF]*(1<<N)
dp[0] = 0
for i in range(M):
  a,b = map(int, input().split())
  c = list(map(int, input().split()))
  k = 0
  for j in range(b):
    k += 1<<(c[j]-1)
  V.append((a,k))
  dp[k] = min(dp[k],a)

for i in range(1<<N):
  for a,k in V:
    dp[i|k] = min(dp[i|k],dp[i]+dp[k])  
print(dp[-1] if dp[-1] != INF else -1)

Measured memory_bytes: 46552
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(N, M);
  vector<vector<int>> G(N);
  FOR(i, M) {
    GI2(a, b);
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  stack<pair<int, unordered_set<int>>> s;
  s.push(pair<int, unordered_set<int>>(0, unordered_set<int>()));
  int ans = 0;
  while (!s.empty()) {
    pair<int, unordered_set<int>> p = s.top();
    s.pop();
    p.second.insert(p.first);
    if (p.second.size() == N) {
      ans++;
      continue;
    }
    for (int v : G[p.first]) {
      if (!p.second.count(v)) {
        unordered_set<int> u = p.second;
        s.push(pair<int, unordered_set<int>>(v, u));
      }
    }
  }
  print(ans);
  return 0;
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> X(M);
  vector<int> S(M-1);
  rep(i,M){
    cin>>X.at(i);
  }
  sort(X.begin(),X.end());
  rep(i,M-1){
    S.at(i)=X.at(i+1)-X.at(i);
  }
  sort(S.begin(),S.end(),greater<int>());
  int ans = 0;
  rep(i,M-1){
    if(i>N-2){
      ans+=S.at(i);
    }
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  std::vector<ll> a(n),b;

  rep(i,0,n){
    ll temp;
    std::cin>>temp;
    a[i]=temp;
    if(i%2)b.push_back(temp);
  }

  std::sort(all(a));
  std::sort(all(b));

  ll ans=0;

  for(ll i=0;i<a.size();i+=2){ 
    if(std::binary_search(all(b),a[i]))ans++;
  }

  std::cout<<ans;



  return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

class Main{

public static void larger(int a, int b, int c){
if ((a < b) && (b < c)){
System.out.println("Yes");
}else {
System.out.println("No");
}
}
	
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int p = scanner.nextInt();
int q = scanner.nextInt();
int w = scanner.nextInt();
larger(p, q, w);

}
}



Measured memory_bytes: 26288
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, h, w;
	cin>>n>>h>>w;
	int res = 0;
	for(int i = 0; i < n; ++i){
		int a, b;
		cin>>a>>b;
		if(h <= a && w <= b)res++;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
<?php


[$N] = fscanf(STDIN, "%d");

$n = 0;
while($N--){
    [$A, $B] = fscanf(STDIN, "%d%d");
    if($A == $B){
        $n++;
        if($n == 3){
            echo "Yes";
            exit;
        }
    }else{
        $n = 0;
    }

}
echo "No";


Measured memory_bytes: 16200
#coding: utf-8

n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
d = [0 for i in range(4)]
for i in range(n):
    temp1 = abs(x[i] - y[i])
    d[0] += temp1
    d[1] += temp1 ** 2
    d[2] += temp1 ** 3
    d[3] = max(d[3], temp1)
d[1] **= (1/2)
d[2] **= (1/3)
for i in d:
    print(i)


Measured memory_bytes: 5648
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
acc = [0]

for ai in a:
    acc.append(acc[-1]+ai)

ans = 10**18

for i in range(1, N):
    ans = min(ans, abs(acc[i]-(acc[N]-acc[i])))

print(ans)

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

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

    int ans = N % 10;
    if(ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9){
        cout << "hon" << endl;
    }else if(ans == 0 || ans == 1 || ans == 6 || ans == 8){
        cout << "pon" << endl;
    }else{
        cout << "bon" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;

//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;

template <typename T>
T Prim(WeightedGraph<T> &g)
{
    T res = 0;
    vector<bool> used(g.size(), false);
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> que;
    que.emplace(0, 0);
    while (que.empty() != true)
    {
        auto p = que.top();
        que.pop();
        if (used[p.second] == true)
            continue;
        used[p.second] = true;
        res += p.first;
        for (auto &e : g[p.second])
        {
            que.emplace(e.cost, e.to);
        }
    }
    return res;
}

int N;

int main()
{
    cin >> N;
    vector<ll> X(N), Y(N);
    vector<pair<pair<ll, ll>, int>> x, y;
    WeightedGraph<ll> G(N);
    for (int i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i];
        x.emplace_back(make_pair(X[i], Y[i]), i);
        y.emplace_back(make_pair(Y[i], X[i]), i);
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int i = 0; i + 1 < N; i++)
    {
        ll a = x[i].first.first, b = x[i].first.second;
        ll na = x[i + 1].first.first, nb = x[i + 1].first.second;
        a--, b--, na--, nb--;
        int p1 = x[i].second, p2 = x[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - na), abs(b - nb)));
        G[p2].emplace_back(p1, min(abs(a - na), abs(b - nb)));
    }

    for (int i = 0; i + 1 < N; i++)
    {
        ll a = y[i].first.first, b = y[i].first.second;
        ll na = y[i + 1].first.first, nb = y[i + 1].first.second;
        a--, b--, na--, nb--;
        int p1 = y[i].second, p2 = y[i + 1].second;
        G[p1].emplace_back(p2, min(abs(a - na), abs(b - nb)));
        G[p2].emplace_back(p1, min(abs(a - na), abs(b - nb)));
    }
    cout << Prim(G) << endl;
}

Measured memory_bytes: 25636
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ul N,A,B,i,x,y,n;
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
inline void solve(){
  IN(N);
  A=1;B=1;
  REP(i,N){
    IN2(x,y);
    n=max(ceil(A,x),ceil(B,y));
    A=n*x;
    B=n*y;
  }
  OUT(A+B);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a[1000000],b[1000000],c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i] >> b[i];
           ans+=b[i]-a[i]+1;
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 2304
n=int(input())
A=list(map(int,input().split()))
B=A

while len(B)>1:
  C=[i for i in range(len(B))]
  C.remove(B.index(min(B)))
  d=min(B)

  for i in C:
    B[i]=B[i]%d
  while 0 in B:
    B.remove(0)
print(B[0])

Measured memory_bytes: 15020
import collections
mod = 10**9+7
fac = [1]
caf = [1]
n=int(input())

def pow(n,p):
    res=1
    while p >0:
        if p%2==0:
            n = n**2 % mod
            p //= 2
        else:
            res = res * n % mod
            p -= 1
    return res % mod

for i in range(1,n+2):
    fac.append((fac[i-1]*i)%mod)
    caf.append(pow(fac[i],mod-2)%mod)

def ncr(n,r):
    if n < r: return 0
    return fac[n]*caf[r]*caf[n-r]

def main():
    global n
    a=list(map(int,input().split()))

    ca= collections.Counter(a)
    tyo= ca.most_common()[0][0]
    kaburi=[i for i, x in enumerate(a) if x == tyo]

    for i in range(1,n+2):
        print((ncr(n+1,i)-ncr(n+1-(kaburi[1]-kaburi[0]+1),i-1))%mod)

main()


Measured memory_bytes: 81624
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
n,W = ma()
wm=3*(n-1)
dp=[[[0]*(wm+1) for j in range(n+1)] for j in range(n+1) ] #dp[i][j][w] iまで見てj個使った時に重さwとなる場合のmaxのv
wv=[]
for i in range(n):
    w,v=ma()
    if i==0:
        wv.append((0,v))
        w0=w
    else:
        wv.append((w-w0,v))

for i in range(n):
    w,v = wv[i]
    for j in range(1,i+2):
        #print(i,j)
        for ww in range(wm+1):
            dp[i][j][ww]=dp[i-1][j][ww]
            if ww-w>=0:
                dp[i][j][ww]=max(dp[i-1][j-1][ww-w]+v,dp[i][j][ww])
ans=0
for j in range(n+1):
    for w in range(wm+1):
        if j*w0 + w<=W:
            ans=max(ans,dp[n-1][j][w])
print(ans)
# print(wv)
# for i in range(n):
#     print(dp[i])
#     print()


Measured memory_bytes: 96956
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    foreach (c; S)
        write("x");
    writeln();
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, ctr = 0;
   string s;
   cin >> n >> s;
   FOR(i, 0, n - 2)
   {
      if (s.substr(i, 3) == "ABC")
         ctr++;
   }
   cout << ctr << endl;
   return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ss := make([]string, n)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	cs := map[string]int{"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
	for _, s := range ss {
		cs[s]++
	}

	for _, k := range []string{"AC", "WA", "TLE", "RE"} {
		fmt.Println(k, "x", cs[k])
	}
}


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

int main(void)
{
	string s;
	cin >> s;
	int a_i = -1, z_i = -1;
	for (int i = 0; i < s.size(); i++) {
		if (a_i == -1 && s[i] == 'A')
			a_i = i;
		if (s[i] == 'Z')
			z_i = i;
	}

	cout << z_i-a_i+1 << endl;

	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> dp(N);
    vector<int> h(N);
    for (int i=0;i<N;i++){
        cin >> h.at(i);
    }
    if(N<=K){
        cout << abs(h.at(0) - h.at(N-1));
        return 0;
    }
    for (int i=1;i<K;i++){
        dp.at(i) = abs(h.at(0) - h.at(i));
    }
    for (int i=K;i<N;i++){
        int min_dp = abs(h.at(i) - h.at(i-1)) + dp.at(i-1);
        for(int j=1;j<K+1;j++){
            int tmp = abs(h.at(i) - h.at(i-j)) + dp.at(i-j);
            if(tmp < min_dp){
                min_dp = tmp;
            }
        }
        dp.at(i) = min_dp;
    }
    cout << dp.at(N-1);
    return 0;
}


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


def solve(X: int):
    a = X // 500
    print(a * 1000 + ((X - (500 * a)) // 5) * 5)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main() {
	long long n, k;
	cin >> n >> k;
	if (n % k == 0) { cout << "0"; return 0; }
	n = n % k;
	cout<< min(abs(n - k), n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int D, N;
  cin >> D >> N;
  if(N!=100){
    if(D == 0){
      cout << N << endl;
    }else if(D == 1){
      cout << N*100 << endl;
    }else{
      cout << N*10000 << endl;
    }
  }else{
    if(D == 0){
      cout << N+1 << endl;
    }else if(D == 1){
      cout << (N+1)*100 << endl;
    }else{
      cout << (N+1)*10000 << endl;
    }
  }
}

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

int keta(int a){
    int cnt = 0;
    
    while(a){
        a /= 10;
        cnt++;
    }
    return cnt;
}

int main(void){
    long long n;
    cin >> n;
    
    int ans = 12;
    
    for (int i = 1; i <= pow(10, 5); i++){
        if (n % i != 0) continue;
        
        int b = n / i;
        
        int temp = max(keta(i), keta(b));
        
        ans = min(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256