akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>a[i];
    //dp[i][j]はi番目まででj個の分け合い方
    vector<vector<ll>> dp(N, vector<ll>(K+1, 0));
    for(ll i=0;i<=a[0];++i)dp[0][i]=1;
    for(ll i=1;i<N;++i){
        dp[i][0]=1;
        for(ll j=1;j<=K;++j){
            dp[i][j]=dp[i][j-1]+dp[i-1][j];
            if(j-a[i]-1>=0)dp[i][j]-=dp[i-1][j-a[i]-1];
            dp[i][j]=(dp[i][j]+MOD)%MOD;
        }
    }
    prt(dp[N-1][K])

    return 0;
}


Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];
    sort(s,s+n);
    vector<string> v;
    v.push_back(s[0]);
    for(int i=1;i<n;i++)
    {
        if(s[i]!=s[i-1])
            v.push_back(s[i]);
    }
    cout<<v.size();
    return 0;
}


Measured memory_bytes: 17812
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Ruined Square
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }

  Pt<T> rot90() { return Pt<T>(-y, x); }
};

typedef Pt<int> pt;

/* global variables */

/* subroutines */

/* main */

int main() {
  pt p0, p1;
  scanf("%d%d%d%d", &p0.x, &p0.y, &p1.x, &p1.y);

  pt v(p1 - p0);

  v = v.rot90();
  pt p2(p1 + v);
  v = v.rot90();
  pt p3(p2 + v);

  printf("%d %d %d %d\n", p2.x, p2.y, p3.x, p3.y);
  return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Mon Feb  4 14:11:22 2019
//
package main

import "fmt"

func main() {

	var m [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scan(&m[i][j])
		}
	}

	b1, b2, b3 := m[0][0], m[0][1], m[0][2]
	a21, a22, a23 := m[1][0]-b1, m[1][1]-b2, m[1][2]-b3
	a31, a32, a33 := m[2][0]-b1, m[2][1]-b2, m[2][2]-b3

	if a21 != a22 || a22 != a23 || a31 != a32 || a32 != a33 {
		fmt.Println("No")
		return
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main()
{
    int a;
    long long x=0,y=0,mi=0,sum=0;
    int s[200005];
    cin>>a;
    for(int i=0;i<a;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<a;i++)
    {
        sum+=s[i];
        mi+=abs(s[i]);
    }
    for(int i=0;i<a-1;i++)
    {
        x+=s[i];
        y=sum-x;
       if(x-y<0)
       {
           if(mi>y-x) mi = y-x;
       }
       if(x-y>=0)
       {
           if(mi>x-y) mi = x-y;
       }
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    
    //変数の宣言
    int a, b, c;
    
    //h変数の入力
    cin >> a >> b >> c;
    
    //if：条件を与え判定する➡　判定は成立する or 成立しない
    if(a < b && b < c) {
        cout << "Yes" << endl;
    }
    //else：if文が成立しないとき条件
    else {
        cout << "No" << endl;
    }
    
    return 0;
    
}


/*******************if文とは************************

if(条件式){
    条件が成立するとき通過できる所
}
else {
    条件を成立してない所が通過できる所
}


※条件式とは
    不等号を使用する
        ・AよりBの方が大きい　➡　A < B
        ・AよりBの方が小さい　➡　A > B
        ・AよりBの方がi以上　➡　A <= B
        ・AよりBの方がi以下　➡　A >= B
        ・AとBは等しい　➡　A == B 
        ・AとBは等しくない　➡　A != B
        ・A以外の値　➡　!A
        
    
********************************************************/


















Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 4; i++) {
    cout << s[i] << flush;
  }
  cout << " " << flush;
  for (int i = 4; i < s.size(); i++) {
    cout << s[i] << flush;
  }
  cout << endl;
  return 0;
}

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

int x[100000], n;

ll c(bool s){
	ll z = 0, an = 0;
	f(i, 0, n){
		z += x[i];
		if (s)an += max(0ll, 1ll - z), z = max(z, 1ll);
		else an += max(0ll, z + 1ll), z = min(z, -1ll);
		s = !s;
	}
	return an;
}

int main(){
	scanf("%d", &n);
	f(i, 0, n)scanf("%d", x + i);
	ll an = min(c(false), c(true));
	printf("%lld\n", an);
}

Measured memory_bytes: 640
num = int(input())
statements = input().split()
count = 0

for j in range(num):
    for i in range(num-1):
        statements[i] = int(statements[i])
        statements[i+1] = int(statements[i+1])
        if statements[i] > statements[i+1]:
            temp = statements[i] 
            statements[i] = statements[i+1]
            statements[i+1] = temp
            count += 1

print(*statements)
print(count)


Measured memory_bytes: 5608
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
 
using namespace std;
 
struct Point{
    bool operator<(const struct Point &arg) const{
        if(y != arg.y)return y < arg.y;
        return x < arg.x;
    };
    double x,y;
};
 
//true?????????
bool calcGaiseki(Point left,Point base, Point right){
    double gaiseki = (left.x-base.x)*(right.y - base.y)-(left.y-base.y)*(right.x-base.x);
    if(gaiseki < -0.00000001)return false;
    else{
        return true;
    }
}
 
int main(){
 
    vector<Point> V,UP,DOWN;
 
    int n;
    double x,y;
 
    scanf("%d",&n);
 
    for(int i = 0; i < n; i++){
        scanf("%lf %lf",&x,&y);
        V.push_back(Point());
        V[i].x = x;
        V[i].y = y;
    }
 
    sort(V.begin(),V.end());
 
    UP.push_back(V[0]);
    UP.push_back(V[1]);
 
    DOWN.push_back(V[V.size()-1]);
    DOWN.push_back(V[V.size()-2]);
 
    for(int i = 2; i < V.size(); i++){
        while(UP.size() > 1 && calcGaiseki(UP[UP.size()-2],UP[UP.size()-1],V[i]) == false)UP.pop_back();
        UP.push_back(V[i]);
    }
 
    for(int i = V.size()-3; i >= 0; i--){
        while(DOWN.size() > 1 && calcGaiseki(DOWN[DOWN.size()-2],DOWN[DOWN.size()-1],V[i]) == false){
            DOWN.pop_back();
        }
        DOWN.push_back(V[i]);
    }
 
    printf("%d\n",UP.size()+DOWN.size()-2);
    for(int i = DOWN.size()-1; i >= 1;i--)printf("%.0lf %.0lf\n",DOWN[i].x,DOWN[i].y);
    for(int i = UP.size()-1; i >= 1 ;i--)printf("%.0lf %.0lf\n",UP[i].x,UP[i].y);
 
}


Measured memory_bytes: 6576
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int N,k,a[100010];

int f(int x){
    int ret = 0;
    REP(i,N) ret += x^a[i];
    return ret;
}
int scanning(int l, int r){
    cerr << "scan : " << l << " " << r << endl;

    if( l >= r) return 0;
    int big = 0;
    while(r >= (1LL << big)) big++;
    big--;
    while((l>>big) == (r>>big) && big > 0) big--;

    int sug = l;
    while(big){
        big--;
        int a = sug;
        int b = sug | (1LL << big);
        if(f(a) < f(b)) sug = b;
    }
    return f(sug);
}

int solve(int l, int r){
    cerr << "solve: " << l << " " << r << endl;
    if(l >= r) return 0;
    
    int big = 0;
    while(r >= (1LL << big)) big++;
    big--;
    
    while((l>>big) == (r>>big) && big > 0) big--;
    int mid = l | (1LL << big);
    return max(scanning(l, mid), solve(mid, r));
}

signed main(){
    I(N); I(k);
    REP(i,N) I(a[i]);
    cout << solve(0,k+1) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lld unsigned long long int
#define MAX 2005
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
using namespace std;

int n, x, y, xx, yy, difx, dify, d;
char c[MAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> x;
    if(n<x)cout<<0;
    else cout<<10;
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans,C[2003][2003],mo=1e9+7;
int main() {
	scanf("%d %d",&n,&k);
	C[0][0]=1;
	for(int i=1; i<=2000; i++) {
		C[i][0]=1;
		for(int j=1; j<=i; j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
	}//k-1  i-1
	for(int i=1; i<=k; i++)printf("%lld\n",C[n-k+1][i]*C[k-1][i-1]%mo);
	return 0;
}

Measured memory_bytes: 30080
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, H):

    for i in range(1, N):
        if H[i-1] - H[i] > 1:
            return 'No'

    for i in range(N-1):
        if H[i] < H[i+1]:
            H[i+1] -= 1
    
    for i in range(1, N):
        if H[i-1] > H[i]:
            return 'No'
    
    return "Yes"


def slv2(N, H):

    for i in range(1, N):
        if H[i-1] - H[i] > 1:
            return 'No'

    for i in range(2, N):
        if H[i-2] > H[i-1] > H[i]:
            return 'No'

    return "Yes"


def main():
    N = read_int()
    H = read_int_n()
    print(slv(N, H))

    # N = 5
    # for _ in range(10):
    #     H = [random.randint(1, 3) for _ in range(N)]
    #     H_ = H[:]
    #     if slv(N, H[:]) != slv2(N, H[:]):
    #         print(H_, slv(N, H[:]), slv2(N, H[:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16640
def cmb(n,r):
  r=min(r,n-r)
  if r<0 or n<=0:
    return 0
  return A[n]*B[r]*B[n-r]%mod
mod=10**9+7
A=[1,1]
B=[1,1]
for i in range(2,7*10**5):
  A.append(A[-1]*i%mod)
  B.append(B[-1]*pow(i,mod-2,mod)%mod)
x,y=map(int,input().split())
if (x+y)%3==0:
  a=(x+y)//3
  b=x-a
  print(cmb(a,b))
else:
  print(0)

Measured memory_bytes: 115820
// AOJ 1135 "Ohgas' Fortune" (ICPC国内予選 2005 Problem A)
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int max = 0;
            int init = sc.nextInt();
            int year = sc.nextInt();
            int n = sc.nextInt();
            for (int j = 0; j < n; j++) {
                int method = sc.nextInt();
                double rate = sc.nextDouble();
                int cost = sc.nextInt();
                if (method == 0) {
                    max = Math.max(max, simpleInterest(init, year, rate, cost));
                } else if (method == 1) {
                    max = Math.max(max, compoundInterest(init, year, rate, cost));
                } else {
                    System.err.println("想定していない運用方法が入力されました。");
                    System.exit(1);
                }
            }
            System.out.println(max);
        }
    }
    
    public static int simpleInterest(int init, int year, double rate, int cost) {
        int sumInterest = 0;
        int money = init;
        
        for (int i = 1; i <= year; i++) {
            sumInterest += money * rate;
            money -= cost;
        }
        return money + sumInterest;
    }
    
    public static int compoundInterest(int init, int year, double rate, int cost) {
        int money = init;
        for (int i = 1; i <= year; i++) {
            money += money * rate - cost;
        }
        return money;
    }
}

Measured memory_bytes: 41980
[k,n] = list(map(int, input().split()))
 
li = list(map(int, input().split()))
 
distances = []
for i in range(n):
    if i == 0:
        distances.append(li[n-1] - li[i])
    else:
        distances.append(k - (li[i] - li[i-1]))
 
print(min(distances))

Measured memory_bytes: 86732
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		if(s.charAt(0)==s.charAt(1) && s.charAt(0)==s.charAt(2)) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		
	}	
}


Measured memory_bytes: 21844
#include <utility>
#include <vector>
#include <string>
#include <iostream>
#include <set>

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB(c) push_back(c)
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
    int n; cin >>  n;
    int x = 0, y = 0, t = 0;
    int xx, yy, tt;
    REP(i,n) {
        cin >> tt >> xx >> yy;
        int dis = abs(x - xx) + abs(y -yy);
        int dt = tt - t;
        if ((dt < dis) || (dt%2 != dis % 2)) {
            cout << "No" << endl;
            return 0;
        }
        t = tt, x = xx, y = yy;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
vector<ll> a={100,101,102,103,104,105};
ll x;
cin>>x;
vector<int> ans(x+1,0);
ans[0]=1;
for(int i=0;i<6;i++){
for(int j=0;j<=x;j++){
   if(j+a[i]<=x&&ans[j]==1)ans[a[i]+j]=1;
}
}
cout<<ans[x]<<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

bool check(string s1,string s2){
    int l=0,r=0;
    int cnt=0;
    while(l<s1.size() || r<s2.size())
    {
        //if(s1.size()==l || s2.size()==r)return false;
        if(s1[l]!=s2[r])return false;
        if(s1[l]=='"')
        {
            l++;
            string ss="";
            while(s1[l]!='"')
            {
                ss+=s1[l];
                l++;
            }
            r++;
            string ss2="";
            while(s2[r]!='"')
            {
                ss2+=s2[r];
                r++;
            }
            l++;
            r++;
            if(ss!=ss2)
            {
                cnt++;
            }
        }
        else
        {
            l++;
            r++;
        }
    }
    return (l==s1.size() && r==s2.size() && cnt<=1);
}

int main()
{
    while(1){
        string s1,s2;
        cin >> s1;
        if(s1==".")break;
        cin >> s2;
        if(s1==s2){
            printf("IDENTICAL\n");
        }else{
            printf("%s\n",check(s1,s2)?"CLOSE":"DIFFERENT");
        }
    }
    return 0;
}



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

#import
#import math
#import numpy as np
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [0] * (W + 1)

for w, v in wv:
    for i in range(W, 0, -1):
        if i - w < 0:
            break

        dp[i] = max(dp[i], dp[i - w] + v)
            
print(dp[W])


Measured memory_bytes: 68136
import bisect
N = int(input())
L = [int(i) for i in input().split()]
L.sort(reverse=True)
ans = 0
P = []
for i in range(N-1):
    for j in range(i+1,N):
        P.append(L[i]+L[j])
P.sort()
now = 0
ans = 0
for i in range(N-2):
    now += N - (i + 1)
    index = bisect.bisect_left(P,L[i]+0.1)
    ans += (len(P) - index)-now
print(ans)


Measured memory_bytes: 88256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
  
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge{
    int to, cost;
};

int main(){
    int n;
    cin >> n;
    ll as, bs;
    ll a[20010], b[20010];
    REP(i, n){
        cin >> a[i];
    }
    REP(i, n){
        cin >> b[i];
    }
    bs = 0;
    ll flag = 0;
    REP(i, n){
        if(a[i] <= b[i]){
            flag += (b[i] - a[i]) / 2;
        }else{
            bs += a[i] - b[i];
        }
    }
    if(flag >= bs){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

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

	int n,m,X,Y;
	cin >> n >> m >> X >> Y;
	int x[n]; int y[m];
	for(int i=0; i<n; i++) cin >> x[i];
	for(int i=0; i<m; i++) cin >> y[i];
	sort(x, x+n); sort(y, y+m);
	int maxX = x[n-1]; int minY = y[0];
	if(X <= maxX and maxX < minY and minY <= Y) cout << "No War";
	else cout << "War";
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1000000007;
const ll INF = 99999999;


int main() {
	int n, m, a[50]{};
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		a[s - 1]++; a[t-1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    int x;
    cin >> x;
    if (x < 600) {
        cout << 8;
    } else if (x < 800) {
        cout << 7;
    } else if (x < 1000) {
        cout << 6;
    } else if (x < 1200) {
        cout << 5;
    } else if (x < 1400) {
        cout << 4;
    } else if (x < 1600) {
        cout << 3;
    } else if (x < 1800) {
        cout << 2;
    } else if (x < 2000) {
        cout << 1;
    }
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3648
#include<complex>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e5+7;
int n,m,tot;
long long a[N],f[N],c[N];
long long qread()
{
	long long x=0;
	char ch=getchar();
	while(ch<'0' || ch>'9')ch=getchar();
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int main()
{
	scanf("%d%d",&n,&m);
	a[++tot]=n;
	long long x;
	for(int i=1;i<=m;i++)
	{
		x=qread();
		while(tot && x<=a[tot])tot--;
		a[++tot]=x;
	}
	f[tot]=1;
	for(int i=tot-1;i;i--)
	{
		f[i]+=a[i+1]/a[i]*f[i+1];
		long long tmp=a[i+1]%a[i],t;
		while(tmp)
		{
			t=upper_bound(a+1,a+tot+1,tmp)-a-1;
			if(t)f[t]+=tmp/a[t]*f[i+1],tmp%=a[t];
			else c[tmp]+=f[i+1],tmp=0;
		}
	}
	c[a[1]]+=f[1];
	for(int i=n-1;i;i--)
		c[i]+=c[i+1];
	for(int i=1;i<=n;i++)
		printf("%lld\n",c[i]);
	return 0;
}

Measured memory_bytes: 3968
N = int(input())

hyaku = N // 100
resi = N - (100 * hyaku)
ju = resi // 10
iti = resi % 10

n = hyaku * ju * iti

if not hyaku == 7:
  if not ju == 7:
    if not iti == 7:
      print('No')
    else:
      print('Yes')
  else:
    print('Yes')
else:
  print('Yes')

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
long long  GCD(long long a,long long b){
	if(b==0) return a;
  else return GCD(b,a%b);
}

long long  LCM(long long a,long long b){
	long long g = GCD(a,b);
  	return a/g*b;
}
 
int main(){
  int n;
  cin >> n;
  long long ans=1;
 
  for(int i=0; i<n; i++){
   long long T;
   cin >> T;
   ans=LCM(ans,T);
  }

 
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
ll dp[111][111][5555];
int main() {
    int n,a;
    cin>>n>>a;
    vector<int> x(n);
    rep(i,n){
        cin>>x[i];
    }
    dp[0][0][0]=1;
//    for(int i=0;i<n;i++){
//        for(int j=0;j<n;j++){
//         for(int k=0;k<=5000;k++){
//             dp[i+1][j][k]+=dp[i][j][k];
//             if(k>=x[i]){
//                 dp[i+1][j+1][k]+=dp[i][j][k-x[i]];
//             }
//         }
//        }
//    }

    for(int i=0;i<n;i++){
        for(int j=0;j<=i+1;j++){
            for(int k=0;k<=5000;k++){
                dp[i+1][j][k]+=dp[i][j][k];
                if(k>=x[i]){
                    dp[i+1][j+1][k]+=dp[i][j][k-x[i]];
                }
            }
        }
    }




    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][i*a];
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 162048
s = int(input())
a = [s]
for i in range(1, 11000):
    if a[i - 1] % 2 == 0:
        tmp = a[i - 1] // 2

        if a.count(tmp) == 1:
            print(i + 1)
            break
        else:
            a.append(tmp)
    else:
        tmp = 3 * a[i - 1] + 1

        if a.count(tmp) == 1:
            print(i + 1)
            break
        else:
            a.append(tmp)


Measured memory_bytes: 3060
n,k=[int(i) for i in input().split()]
d=[i for i in input().split()]
num=[i for i in range(1,10) if (i in d)==False]
def check(number):
    s=str(number)
    result=True
    for i in range(len(s)):
        if s[i] in d:
            result=False
    return result
if check(n):
    print(n)
else:
    while True:
        if check(n+num[0]):
            print(n+num[0])
            break
        else:
            n+=num[0]

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}


//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let a:Vec<u32> = (0..3).map(|_| read()).collect();

    println!("{}",
        if a[0] == a[1] && a[1] == a[2] {"Yes"}
        else {"No"}
    );
    
}


Measured memory_bytes: 4352
# さっきWAして答えみて再度アタック
# （ちなみに問題自体憶えてないけど昔やったことあってそんときゃACしてたので退化してるね 向いてないね やめたほうがいいね）
n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
par = [i for i in range(n)]


def root(x):
    # while x != par[x]:
    #     par[x] = root(par[x])
    # return par[x]
    # なぜか上記の書き方が駄目だった
    if x == par[x]:
        return x
    y = root(par[x])
    par[x] = y
    return y


def union(a, b):
    if a > b:
        a, b = b, a
    ra, rb = root(a), root(b)
    if ra != rb:
        par[ra] = rb


for _ in range(m):
    x, y = map(lambda x: int(x) - 1, input().split())
    union(x, y)

ans = 0
for i in range(n):
    ra, rb = root(i), root(p[i])
    if ra == rb:
        ans += 1
print(ans)


Measured memory_bytes: 13812
import bisect
N,M=map(int,input().split())
divd=[]
i=1
while i*i<=M:
    if M%i==0:
        divd.append(i)
        if i!=M//i:
            divd.append(M//i)
    i+=1
divd.sort()
k=bisect.bisect_left(divd,N)
print(M//divd[k])


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

void swap(int &a, int &b)
{
	int x = a;
	a = b;
	b = x;
}

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	swap(A, B);
	swap(A, C);
	cout << A << " " << B << " " << C << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  ll ans = 0;
  REP(i,a+1) {
    REP(j,b+1) {
      int diff = x - (500*i + 100*j);
      if (diff < 0) continue;
      if (diff % 50 == 0 && diff / 50 <= c) ans++;
    }
  }
  COUT(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


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

        String str = sc.next();
        int count = -1;

        if(str.matches(".*R{3}.*")){
            count = 3;
        }
        else if(str.matches(".*R{2}.*")){
            count = 2;
        }
        else if(str.matches(".*R{1}.*")){
            count = 1;
        }
        else{
            count = 0;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35616
#include <iostream>
using namespace std;
int main()
{
    int n,d,x,c=0,b=0;
    cin>>n>>d>>x;
    int a[n];
    for (int i=0;i<n;i++) cin>>a[i];
    for (int i=0;i<n;i++)
    {
        c=0;
        for (int j=0;j<=d;j++)
        {
            if (1+a[i]*j<=d) c++;
        }
        b=b+c;
    }
    cout<<x+b<<endl;
    system ("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug cerr << "-- " << __LINE__ << " --" << endl
#define MOD 1000000007
typedef long long int ll;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
template <typename T> string to_string(const vector<T> &xs) {string s="["; for(int i=0;i<xs.size();i++) s += (i>0 ? " " : "") + to_string(xs[i]); return s + "]";}
ll nextLL(){ll x; scanf("%lld", &x); return x;}
int nextInt(){int x; scanf("%ld", &x); return x;}


ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
ll gcd(ll a, ll b) { ll x, y; return extgcd(a, b, x, y);}

class llm{
	ll n;
public:
	llm(){n = 0;}
	llm(ll n){this->n = (n >= 0) ? (n % MOD) : (MOD - 1 - (-n-1 % MOD));}
	operator ll() const {return n;}
	llm operator+(const llm &y) const{ return llm((ll)*this + (ll)y);}
	llm operator+=(const llm &y) { *this = *this + y; return *this;}
	llm operator-(const llm &y) const{ return llm((ll)*this - (ll)y);}
	llm operator-=(const llm &y) { *this = *this - y; return *this;}
	llm operator-() const{ return llm(0) - *this;}
	llm operator*(const llm &y) const{ return llm((ll)*this * (ll)y);}
	llm operator*=(const llm &y) { *this = *this * y; return *this;}
	llm operator/(const llm &y) const{ return *this * y.inv();}
	llm operator/=(const llm &y) { *this = *this / y; return *this;}
	llm inv() const{
		ll x, y;
		if (extgcd(n, MOD, x, y) == 1) return llm(x);
  		return llm(0); // unsolvable
	}
	friend istream& operator >> (istream& os, llm& x);
	friend ostream& operator << (ostream& os, const llm& x);
};
istream& operator >> (istream& is, llm& x){ll n; is >> n; x = llm(n); return is;}
ostream& operator << (ostream& os, const llm& x){os << (ll)x; return os;}

template<typename T> T comb(ll n, ll k){
	T ret = 1;
	for(ll i=1;i<=k;i++) ret = ret * T(n - k + i) / T(i);
	return ret;
}

ll N, M;
vector<ll> cost;
vector<vector<ll>> skill;
vector<ll> effect;

vector<ll> dp;

int main(void){
	cin >> N >> M;
	skill = vector<vector<ll>>(M);
	for(int i=0;i<M;i++){
		ll a, b;
		cin >> a >> b;
		cost.pb(a);
		for(int j=0;j<b;j++){
			skill[i].pb(nextLL() - 1);			
		}
		ll sum = 0;
		for(auto s : skill[i]) sum |= (1LL<<s);
		effect.pb(sum);
	}

	dp = vector<ll>(1LL<<N, LLONG_MAX/2);
	dp[0] = 0;
	for(int i=0;i<M;i++){
		for(int j=0;j<(1LL<<N);j++){
			// state j で effect[i] を使うと state p に
			ll p = j | effect[i];
			dp[p] = min(dp[p], dp[j] + cost[i]);
		}
	}

	ll ans = dp[(1LL<<N) - 1];
	if (ans >= LLONG_MAX / 2) ans = -1;
	cout << ans << endl;

    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

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;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, K, ans = 0;
    cin >> h >> w >> K;
    vector<int> bh(h), bw(w);
    vector<vector<char>> c(h, vector<char>(w));
    rep(i, h) rep(j, w) { cin >> c[i][j]; }
    rep(i, 1 << h) rep(j, 1 << w) {
        int num = 0;
        auto tmp = c;
        rep(k, h) if (i & (1 << k)) { rep(l, w) tmp[k][l] = '.'; }
        rep(k, w) if (j & (1 << k)) { rep(l, h) tmp[l][k] = '.'; }
        rep(k, h) rep(l, w) if (tmp[k][l] == '#') num++;
        if (num == K) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		int count = 0;
		while(true){
			for(int i=0;i<n;i++){
				if(count == 0){
					a[i] = scanner.nextInt();
				}
				if(a[i] % 2 != 0){
					System.out.println(count);
					return;
				}else{
					a[i] /= 2;
				}
			}
			count++;
		}
	}

}


Measured memory_bytes: 23892
n = int(input())
arr = {}

for i in range(n):
    s = input()
    if not s in arr:
        arr[s] = 1
    else:
        arr[s] += 1

max_count = max(arr.values())
dic = [key[0] for key in arr.items() if key[1] == max_count]

out_sort = sorted(dic)
print("\n".join(out_sort))

Measured memory_bytes: 35672
import bisect

N=int(input())
A=[int(i) for i in input().split()]
A.sort()
B=[int(i) for i in input().split()]
B.sort()
C=[-int(i) for i in input().split()]
C.sort()
ans=0
for b in B:
    a=bisect.bisect_left(A,b)
    c=bisect.bisect_left(C,-b)
    # print(a,c)
    ans+=a*c
print(ans)

Measured memory_bytes: 23232
import heapq

def main():
    N, M, S = map(int, input().split())
    AB = [[] for _ in range(N)]
    maxA = 0
    for _ in range(M):
        u, v, a, b = map(int, input().split())
        AB[u - 1].append((a, b, v - 1))
        AB[v - 1].append((a, b, u - 1))
        maxA = max(maxA, a)
    for i in range(N):
        AB[i].sort()

    CD = [tuple(map(int, input().split())) for _ in range(N)]
    maxS = N * maxA
    cur = [(0, 0, S)]  # (time, station, silver)
    T = [-1] * N
    tc = N
    P = [-1] * N
    while tc:
        t, u, s = heapq.heappop(cur)
        if s <= P[u]:
            continue
        P[u] = s
        if T[u] == -1:
            T[u] = t
            tc -= 1
        for a, b, v in AB[u]:
            if s < a:
                break
            heapq.heappush(cur, (t + b, v, s - a))
        if s != maxS:
            c, d = CD[u]
            min_a = AB[u][0][0]
            k = max(1, (min_a - s + c  - 1) // c)
            heapq.heappush(cur, (t + k * d, u, min(s + k * c, maxS)))
    print('\n'.join(map(str, T[1:])))

main()


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

int main(){
  string S;
  cin >> S;
  int maru=0, batsu=0;
  for (auto k: S){
    if (k=='0') maru++;
    else batsu++;
  }
  cout << min(maru, batsu)*2 << endl;
}


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

int main() {
  int h,w,n,c = 0;
  cin >> h >> w >> n;
  vector<int>a(n);
  vector<int>str(h*w);
  for(int i = 0;i < n;i++) cin >> a[i];
  for(int i = 0;i < n;i++){
    for(int j = 0;j < a[i];j++){
      str[c] = i+1;
      c++;
    }
  }
  for(int i = 0;i < h;i++){
    vector<int>ans(w);
    for(int j=0;j < w;j++){
      ans[j] = str[w*i+j];
    }
    if(i%2 == 1) reverse(ans.begin(),ans.end());
    for(int j = 0;j < w;j++){
      cout << ans[j];
      if(j != w-1) cout << " ";
      else cout << "" << endl;
    }
  }
}

Measured memory_bytes: 384
n=int(input())
s=str(input())
r,g,b=0,0,0
ans=0
for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
    else:
        b += 1
for i in range(0,n):
    if s[i]=='R':
        ans += b*g
        r -= 1
    elif s[i]=='G':
        ans += r*b
        g -= 1
    else:
        ans += r*g
        b -= 1
for i in range(1,n):
    for j in range(n):
        l,mid,r=j,j+i,j+i+i
        if r<n:
            d={}
            d[s[l]]=1
            d[s[mid]]=1
            d[s[r]]=1
            if len(d)==3:
                ans -= 1
print(ans)

Measured memory_bytes: 68512
#include <iostream>
#include <cstdio>
using namespace std;
int ask(int x)
{
    printf("%d\n",x);
    fflush(stdout);
    char c[10];
    scanf(" %s",c);
    if (c[0]=='V') return 0;
    if (c[0]=='M') return 1;
    return 2;
}
int main()
{
    int n,i;
    scanf("%d",&n);
    int x=ask(0);
    if (x==0) return 0;
    int l=1,r=n-1,m;
    while (l<=r)
    {
        m=(l+r)/2;
        int y=ask(m);
        if (y==0) return 0;
        if ((y==x) ^ ((m-l+1)%2==1))
        {
            l=m+1;
            x=y;
        }
        else
            r=m-1;
    }
    return 0;
}


Measured memory_bytes: 852
x = int(input())

digit = 0
for i in range(x):
    x = i + 1

    if x % 3 == 0 and x % 5 == 0:
        continue
    elif x % 3 == 0 and x % 5 != 0:
        continue
    elif x % 3 != 0 and x % 5 == 0:
        continue
    else:
        digit += x



print(digit)

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

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

    int sx, sy;
    cin >> sx >> sy;

    int tx, ty;
    cin >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;
    // trueなら右
    bool b1 = dx > 0;
    // trueなら上
    bool b2 = dy > 0;
    if(!b1) dx = -dx;
    if(!b2) dy = -dy;

    string s1 = "";
    string s2 = "";
    for(int i = 0; i < dx; ++i){
        if(b1){
            s1 += 'R';
            s2 += 'L';
        }
        else {
            s1 += 'L';
            s2 += 'R';
        }
    }
    string s3 = "";
    string s4 = "";
    for(int i = 0; i < dy; ++i){
        if(b2){
            s3 += 'U';
            s4 += 'D';
        }
        else {
            s3 += 'D';
            s4 += 'U';
        }
    }
    string s5 = (b2 ? "D" : "U");
    s5 += s1;
    s5 += (b1 ? 'R' : 'L');
    s5 += (b2 ? 'U' : 'D');
    s5 += s3;
    s5 += (b1 ? 'L' : 'R');
    string s6 = "";
    for(size_t i = 0; i < s5.size(); ++i){
        if(s5[i] == 'L')
            s6 += 'R';
        if(s5[i] == 'R')
            s6 += 'L';
        if(s5[i] == 'U')
            s6 += 'D';
        if(s5[i] == 'D')
            s6 += 'U';
    }

    cout << s1 + s3 + s2 + s4 + s5 + s6 << endl;

    return 0;
};

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
#include <vector> 
using namespace std; 
inline int gi() {
    register int data = 0, w = 1;
    register char ch = 0;
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 1e5 + 5; 
int N, M, a[MAX_N], b[MAX_N], p[MAX_N]; 
int pa[MAX_N]; 
int getf(int x) { while (x != pa[x]) x = pa[x] = pa[pa[x]]; return x; } 
vector<int> G[MAX_N]; 
long long f[MAX_N], sum[MAX_N];
bool vis[MAX_N]; 
int main () { 
	N = gi(), M = gi();
	for (int i = 1; i <= N; i++) { 
		a[i] = gi(), b[i] = gi(); 
		a[i] = max(a[i] - b[i], 0);
		p[i] = i, pa[i] = i; 
	} 
	sort(&p[1], &p[N + 1], [](const int &l, const int &r) { return a[l] < a[r]; } ); 
	for (int i = 1; i <= M; i++) { 
		int u = gi(), v = gi(); 
		G[u].push_back(v), G[v].push_back(u); 
	} 
	for (int i = 1; i <= N; i++) { 
		vector<int> son;
		int x = p[i]; 
		vis[x] = 1, sum[x] = b[x]; 
		for (auto v : G[x]) {
			if (!vis[v] || getf(x) == getf(v)) continue; 
			son.push_back(getf(v)); 
			sum[x] += sum[getf(v)]; 
			pa[getf(v)] = getf(x); 
		} 
		f[x] = sum[x] + a[x]; 
		for (auto v : son) f[x] = min(f[x], sum[x] - sum[v] + max(1ll * a[x], f[v])); 
	} 
	printf("%lld\n", f[p[N]]); 
    return 0; 
} 

Measured memory_bytes: 9468
#include<bits/stdc++.h>
#define mod 1000000007
#define f first
#define s second

using namespace std;

/*int gcd(int a,int b){
	if(b == 0)
		return a;
	return gcd(b,a%b);
}*/

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a;
    int b;
    cin>>a>>b;

    int cnt =0;
    int power = 1;
    while(power < b){
    	power+=a;
    	cnt++;
    	power-=1;
    }
    cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()

    ans = n
    for a in xrange(1,n):
        b = n-a
        ans = min(ans, sum(map(int, list(str(a)+str(b)))))

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 6036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n; string s; cin >> n >> s;
    int ans = 0;
    for(int i = 1;i < n;i++){
        string x = s.substr(0,i);sort(x.begin(),x.end());
        string y = s.substr(i,s.length());sort(y.begin(),y.end());
        x.erase(unique(x.begin(),x.end()),x.end());
        y.erase(unique(y.begin(),y.end()),y.end());
        int cnt = 0;
        for(int j = 0;j < x.length();j++){
            if(y.find(x[j]) != string::npos){
                cnt++;
            }
        }
        ans = max(ans,cnt);
    }
    cout << ans;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll x=0;
	for(int i=1;i<=n;i++){
		if(i%2==0){
			x-=a[i];
		}
		else{
			x+=a[i];
		}
	}
	x/=2;
	ll ans=2*x;
	for(int i=1;i<=n;i++){
		cout << ans << " ";
		ans=2*a[i]-ans;
	}
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	string s,t;cin>>s>>t;
	cout<<t<<s<<endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        List<int> NAB = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToList();
        int N = NAB[0], A = NAB[1], B = NAB[2];

        int sum = 0;
        for (int i = 1, j = 1, dsum = 0; i <= N; i++, j = i, dsum = 0)
        {
            while (j != 0)
            {
                dsum += j % 10;
                j /= 10;
            }
            if (A <= dsum && dsum <= B)
                sum += i;
        }

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13268
N = gets.to_i
count = 0
res = 0

for i in  1..N do
  if i % 2 == 1
    for j in  1..i do
      if i % j == 0
        count += 1
      end
    end
  end
  if count == 8
    res += 1
  end
  count = 0
end

p res

Measured memory_bytes: 1788
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<long,long>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long POWL(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

int main(){
    vector<ll> ans(100001);
    vector<ll> kyoyou(100001,2);
	ll n;
    cin >> n;
    vector<ll> a(n+1);
    for(ll i=0;i<n+1;i++){
        cin >> a[i];
    }
    if(n==0&&a[0]==1){
        cout <<1;
        return 0;
        }
    if(a[0]!=0){
        cout << -1 << endl;
        return 0;
    }

    
    for(ll i=1;i<n+1;i++){
        if(a[i]>kyoyou[i]){
            cout <<-1 << endl;
            return 0;
        }else{
            kyoyou[i+1]=(kyoyou[i]-a[i])*2;
            if(kyoyou[i+1]>4.61*1e18){
                kyoyou[i+1]=4.61*1e18;
            }
        }
    }
    
    for(ll i=n;i>0;i--){
        ans[i]=a[i];
        if(i!=n){
            if(ans[i+1]>kyoyou[i]-a[i]){
                ans[i]= kyoyou[i];
            }else{
                ans[i]+=ans[i+1];
            }
        }
    }
    ll answer=1;
    for(ll i=1;i<=n;i++){
        answer+=ans[i];
    }
    cout << answer << endl;
}

Measured memory_bytes: 5636