akhauriyash/Code-Regression huggingface dataset:
l = list(map(int, input().split()))
count = 0
while True:
  l.sort()
  if l[0] == l[1] and l[1] == l[2]:
    break

  if l[0] < l[1] and l[1] == l[2]:
    l[0] += 2
    count += 1
  else:
    l[0] += 1
    l[1] += 1
    count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
 
#define MAX_N 100005
#define MAX_Q 100005
 
int N;
string S[MAX_N];
int Q;
int K[MAX_Q];
string P[MAX_Q];
 
void input()
{
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    cin >> S[i];
  }
  cin >> Q;
  for (size_t i = 0; i < Q; i++) {
    cin >> K[i] >> P[i];
  }
}
 
string SS = "";
 
class Node{
public:
  Node()
  {
    term = 0;
    for (size_t i = 0; i < 26; i++) {
      nextNode[i] = NULL;
    }
    memset(edgeCnt, 0, sizeof(edgeCnt));
  }
 
  void addString(const string &S, int pos, int _term)
  {
    if(pos < 0 || S.length() < pos){
      return;
    }
 
    if(S.length() == pos){
      term = _term;
      return;
    }
 
    if(nextNode[S[pos] - 'a'] == NULL){
      nextNode[S[pos] - 'a'] = new Node();
    }
 
    edgeCnt[S[pos] - 'a']++;
    nextNode[S[pos] - 'a']->addString(S, pos+1, _term);
 
  }
 
  Node* eraseEdge()
  {
    Node* ret = NULL;
    int cnt = 0;
    bool update = true;
 
    for (size_t i = 0; i < 26; i++) {
      if(nextNode[i] != NULL){
        cnt++; ret = nextNode[i];
        auto it = nextNode[i]->eraseEdge();
        if(it != NULL){
          update = false;
          delete(nextNode[i]);
          nextNode[i] = it;
        }
      }
    }
 
    if(cnt == 1 && term == 0 && update){
      return ret;
    }
    else{
      return NULL;
    }
 
  }
 
  int solve(const string &P, const string &S, int ret = 0, int pos = 0)
  {
    if(pos == S.length()){
      return ret + 1;
    }
 
    if(term > 0){
      ret++;
    }
 
    for (size_t i = 0; i < P.length(); i++) {
      if(P[i] == S[pos]){
        return nextNode[S[pos] - 'a']->solve(P, S, ret, pos+1);
      }
      else{
        ret += edgeCnt[P[i] - 'a'];
      }
    }
  }
 
  void debugPrint(string p = "")
  {
    if(term > 0){
      cout << p << endl;
    }
    for (size_t i = 0; i < 26; i++) {
      if(nextNode[i] != NULL){
        char c = 'a' + i;
        nextNode[i]->debugPrint(p + c);
      }
    }
  }
 
  bool updateS()
  {
    bool ret = false;
    if(term > 0){
      if(S[term-1] != SS){
        ret = true;
      }
      S[term-1] = SS;
    }
    for (size_t i = 0; i < 26; i++) {
      if(nextNode[i] != NULL){
        char c = 'a' + i;
        SS += c;
        ret |= nextNode[i]->updateS();
        SS.pop_back();
      }
    }
    return ret;
  }
 
  int term;
  Node* nextNode[26];
  int edgeCnt[26];
 
}Root;
 
int main()
{
  input();
 
  for (size_t i = 0; i < N; i++) {
    Root.addString(S[i], 0, i+1);
  }
 
  do{
    Root.eraseEdge();
  }while(Root.updateS());
 
  for (size_t q = 0; q < Q; q++) {
    //cerr << "*** " << S[K[q]-1] << endl;
    printf("%d\n", Root.solve(P[q], S[K[q]-1]));
  }
 
  return 0;
}

Measured memory_bytes: 156156
// Circle.c
// 半径 r の円の面積と円周の長さを求めるプログラムを作成して下さい。
// 【入力】
// １つの実数 r が与えられます。
// 【出力】
// 面積と円周の長さを１つの空白で区切って１行に出力して下さい。
// 出力は浮動小数点数とし、0.00001 以下の誤差を含んでもよいものとします。
// 【制約】
// 0 < r < 10,000
// 【例】
// 入力：2、出力：12.566371 12.566371
#include<stdio.h>
#include<math.h>

int main( void) {
  double r;
  double area, circumference;
  double PI = acos(-1);

  scanf( "%lf", &r);

  area = r * r * PI;
  circumference = 2 * r * PI;

  printf( "%.6lf %.6lf\n", area, circumference);

  return 0;
}



Measured memory_bytes: 2052
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

X, Y = MAP()

if X%Y == 0:
	print(-1)
else:
	print(X)

Measured memory_bytes: 10628
num = int(input())
ans = []
flag = True
for i in range(num):
  mochi = int(input())
  for j in range(len(ans)):
    if ans[j] == mochi:
      flag = False
      break
 
  if flag == True:
    ans.append(mochi)
  flag = True

print(len(ans))

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int A, B, C;
    io.read(A, B, C);
    vector<int> v(B, 0);
    int r = A % B;
    int x = r;
    string ans = "YES";
    while(true){
        if(x == C){
            break;
        }
        if(v[x]){
            ans = "NO";
            break;
        }
        v[x] = 1;
        x = (x + r) % B;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)
	printf("hon\n");
	else if(n==0||n==1||n==6||n==8)
	printf("pon\n");
	else
	printf("bon\n");
	return 0; 
} 

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> Asum(N);
    rep(i, N) cin >> A[i];
    ll sum=0;
    for(int i=N-1; i>=1; i--){
        sum = (sum + A[i]) % MOD;
        Asum[i] = sum;
    }
    ll ans=0;
    rep(i, N-1){
        ans = (ans + (A[i]*Asum[i+1])%MOD) % MOD;
    }
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll, ll> > drinks(n);
	for (int i = 0; i < n; ++i)
	{
		ll a, b;
		cin >> a >> b;
		drinks[i] = make_pair(a, b);
	}
	sort(drinks.begin(), drinks.end());
	ll ans, cnt;
	ans = 0;
	cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		if (cnt + drinks[i].second  >= m)
		{
			ans += drinks[i].first * (m - cnt);
			break;
		}
		else
		{
			ans += drinks[i].first * drinks[i].second;
			cnt += drinks[i].second;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int h, w;
		cin >> h >> w;
		if (!h)break;
		vector<string> v(h);
		REP(i, h)cin >> v[i];
		set<string> st;
		string ans = "";
		REP(i, h) {
			REP(j, w) {
				REP(k, 8) {
					int ni = i, nj = j;
					string s;
					s += v[i][j];
					REP(l, INF) {
						if (!st.insert(s).second) {
							if (ans.size() < s.size())ans = s;
							else if (ans.size() == s.size() && ans > s)ans = s;
						}
						ni = (ni + dx[k] + h) % h, nj = (nj + dy[k] + w) % w;
						if (ni == i&&nj == j)break;
						s += v[ni][nj];

					}
				}
			}
		}
		if (ans.size() <= 1)cout << 0 << endl;
		else cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 35576
class Coordinate(object):
    def __init__(self):
        self.path = [None, None, None, None]


class Maze(object):
    def __init__(self):
        self.a = [[Coordinate() for _ in [0]*5] for _ in [0]*5]

    def get_room(self, x, y):
        return self.a[y][x]

    def set_path(self, pos1, pos2):
        dir1, dir2 = (0, 2) if pos1[1] == pos2[1] else (1, 3)
        self.get_room(*pos1).path[dir1] = pos2
        self.get_room(*pos2).path[dir2] = pos1

    def solve(self):
        result, x, y, direction = "R", 1, 0, 0
        direction_sign = "RDLU"

        while not(x == 0 and y == 0):
            current = self.get_room(x, y)
            if current.path[(direction-1)%4]:
                direction = (direction-1)%4
            elif current.path[direction]:
                pass
            elif current.path[(direction+1)%4]:
                direction = (direction+1)%4
            else:
                direction = (direction+2)%4
            x, y = current.path[direction]
            result += direction_sign[direction]

        return result


maze = Maze()
for i in range(9):
    y = i//2
    dx, dy = (1, 0) if i%2 == 0 else (0, 1)
    for x, c in enumerate(input()):
        if c == "1":
            maze.set_path((x, y), (x+dx, y+dy))

print(maze.solve())


Measured memory_bytes: 5576
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int p = scan.nextInt();
	int odds = 0;
	int diff = 0;
        for(int i = 1; i <= n; i++){
            diff = scan.nextInt();    
	    diff = diff % 2;
	    odds += diff;
	}

	long combi = 1;
	if(odds != 0){
	    for(int j = 1; j <= n-1; j++){
		combi = 2 * combi;
	    }
	}else if(p == 1){
	    combi = 0;
	}else{
	    for(int j = 1; j<= n-odds; j++){
	        combi = 2 * combi;
	    }
	}
	System.out.print(combi);	
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
	int N;
	cin >> N;
	bool find = false;
	for (int i = N; !find && i > 0; --i) {
		int sn = sqrt(i);
		if (sn*sn == i) {
			cout << i << endl;
			find = true;
		}
	}
	return 0;
}


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

using namespace std ;
const int N =1e5 +5 ;

int dp[105][N] ;

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

    int n ,W ;
    cin >> n >>W;

    vector<pair<int,int>> b(n) ;
    for(int i = 0 ; i  < n ; ++i)
    {
        int w ,v ;
        cin >>w >> v ;
        b[i] = (make_pair(w,v)) ;
    }




    for(int i = 1 ; i <= n ; ++i)
    {
        for(int j = 1 ; j <= W ; ++j)
        {


            if (b[i-1].first <= j)
            {
                dp[i][j] = max(dp[i-1][j-b[i-1].first] + b[i-1].second , dp[i-1][j]) ;
            }
            else
            {
                dp[i][j] = max(dp[i-1][j] ,dp[i][j]) ;
            }
        }

    }

    cout << dp[n][W] << endl ;



}


Measured memory_bytes: 81792
#include<bits/stdc++.h>
 
using namespace std;
 
void load(void);
long long calc(void);
void output(void);
 
int N;
long long A[100000], res = 1;
 
int main(){
	load();
	output();
	return 0;
}
 
void load(void){
	int in;
	cin >> N;
	for(in = 0;in < N;in++){
		cin >> A[in];
	}
}
 
long long calc(void){
	int i;
	for(i = 0;i < N;i++){
        if(A[i] == 0){
        	return 0;
        }
    }
	for(i = 0;i < N;i++){
		if(A[i] > (long long)(1000000000000000000 / res)){
			return -1;
		}
        res = res * A[i];
	}
    return res;
}
 
void output(void){
	cout << calc() << endl;
}

Measured memory_bytes: 4404
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,k,ans=1000000000000;
  cin >> n >> k;
  n %= k;
  ans = n;
  ans = min(ans,abs(n-k));
  cout<< ans << endl;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
MOD=10**9+7
def inv(a):
  return pow(a,MOD-2,MOD)

def choose(n,r):
  if r==0 or r==n:
    return 1
  else:
    A=B=1
    ls_A=[1]
    ls_B=[1]
    for i in range(r):
      A=ls_A[i]*(n-i)%MOD
      ls_A.append(A)
      B=ls_B[i]*(i+1)%MOD
      ls_B.append(B)
    return ls_A[r]*inv(ls_B[r])%MOD

def pow_k(x,n):
    if n==0:
        return 1
    K=1
    while n>1:
        if n%2 != 0:
            K=K*x%MOD
            x=x**2%MOD
            n=(n-1)//2
        else:
            x=x**2%MOD
            n=n//2%MOD
    return K*x%MOD 

print((pow_k(2,n)-1-choose(n,a)-choose(n,b))%MOD)

Measured memory_bytes: 94064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	long long H;
	cin>>H;
    int count=0;
  	if(H==1){
      cout<<1<<endl;
      return 0;
    }
	while(true){
		H=H/2;
		count++;
		if(H==1) break;
    }
  //	cout<<count<<endl;
  	long long sum=0;
  	for(int i=0; i<=count; i++){
      	sum+=pow(2,i);
    }
  cout<<sum<<endl;
   
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
  long long sum=0;
  long long shou=LLONG_MAX;
  for(int i=0;i<n-k+1;i++){
    sum=h[i+k-1]-h[i];
    shou=min(shou,sum);
  }
  cout<<shou<<endl;
  return 0;
}

Measured memory_bytes: 640
import sys
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))
N = int(input())
B = [int(input()) for i in range(N)]
a1 = [0,0,0]
a2 = [0,0,0]
a3 = [0,0,0]
for b in B:
    if b in A1:
        a1[A1.index(b)] = 1
    elif b in A2:
        a2[A2.index(b)] = 1
    elif b in A3:
        a3[A3.index(b)] = 1

for i in range(3):
    if a1[i] == 1 and a2[i] == 1 and a3[i] == 1:
        print("Yes")
        sys.exit()
if a1[0] == 1 and a1[1] == 1 and a1[2] == 1:
    print("Yes")
    sys.exit()
elif a2[0] == 1 and a2[1] == 1 and a2[2] == 1:
    print("Yes")
    sys.exit()
elif a3[0] == 1 and a3[1] == 1 and a3[2] == 1:
    print("Yes")
    sys.exit()
elif a1[0] == 1 and a2[1] == 1 and a3[2] == 1:
    print("Yes")
    sys.exit()
elif a1[2] == 1 and a2[1] == 1 and a3[0] == 1:
    print("Yes")
    sys.exit()

print("No")

Measured memory_bytes: 3064
import sys
fastinput = sys.stdin.readline
from collections import deque
S = input()
Q = int(input())
ans = deque([S])
Reverse = False
for q in range(Q):
    query = fastinput().split()
    if query[0]=="1":
        Reverse = not Reverse
    elif (query[1]=="1") ^ Reverse:#左側にくっつく
        ans.appendleft(query[2])
    else:
        ans.append(query[2])
SS = "".join(list(ans))
if Reverse:
    SS = "".join(reversed(SS))
print(SS)


Measured memory_bytes: 7668
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
using namespace std;

// 插入此處

int main() {
    LL n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    if (n <= a) {
        printf("%lld\n", n);
    } else if (n <= a + b) {
        printf("%lld\n", a);
    } else {
        LL re = n % (a + b);
        LL times = n / (a + b);
        printf("%lld\n", times * a + (re <= a ? re : a));
    }
}


Measured memory_bytes: 128
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

vector<ll>v;
vector<ll>::iterator it;
map<ll,ll>mp;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        //cout << 2 << " ";  
        mp[2]++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            //cout << i << " ";  
            mp[i]++;
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2){ 
        mp[n]++; 
        //cout << n << " "; 
    } 
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n;
        cin>>n;
        primeFactors(n);
        ll ans=0;
        for(auto i:mp){
            ll sum=1;
            while(sum*(sum+1)/2<=i.second){
                sum++;
            }
            ans+=sum-1;
        }
        cout<<ans<<"\n";
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<tuple<int64_t,int64_t,int64_t>> D;
    rep(i,0,N){
        int64_t a,b; cin>>a>>b;
        D.emplace_back(a+b,a,b);
    }

    sort(ToEnd(D),greater<tuple<int64_t,int64_t,int64_t>>());

    int64_t ans=0,idx=0;
    for(auto d:D){
        int64_t s,a,b;
        tie(s,a,b)=d;

        if(idx%2) ans-=b;
        else ans+=a;
        idx++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4980
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>

#define MAX 100
#define INFTY 1<<30 // 2^30
#define N 100
#define N2 10000  // N * N
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(o) (o).begin(), (o).end()

/*
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/


using namespace std;

typedef long long llong;

int V, E, R, S[500010], T[500010], D[500010];
int C[100010];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  cin >> V >> E >> R; // V ???????????° E ????????°
  REP(i,E)
    cin >> S[i] >> T[i] >> D[i];
  REP(i,V)
    C[i] = INFTY;
  C[R] = 0;
  REP(j,V)
  {
    bool update = false;
    REP(i,E)
    {
      int s = S[i], t = T[i], d = D[i];
      if(C[s] < INFTY && C[s] + d < C[t])
      {
        C[t] = C[s] + d;
        update = true;
      }
    }
    if(!update) break;
  }
  REP(i,V)
  {
    if(C[i] == INFTY) cout << "INF" << endl;
    else cout << C[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 7412
#include<stdio.h>
#include<math.h>

int main(void){
int N,K,i,score;
double total;

scanf("%d %d",&N,&K);

double probability[N];

for(i=0;i<N;i++){

  score = i+1;
  int count=0;

  while(score<K){
    score = score*2;
    count++;
      }


probability[i] = pow(0.5,count)/(double)N;
}

for(i=0;i<N;i++){
  total = total + probability[i];
}
printf("%0.12f",total);
return(0);
}


Measured memory_bytes: 896
#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++)
typedef int64_t Int;

int main(){ 
  Int N, M;
  cin >> N >> M;
  
  if (N == M) cout << "Yes" << endl;
  if (N > M) cout << "No" << endl;

}


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

int main(){
	
	string taro, hanako;
	int x=0,y=0;
	
	int n;
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> taro >> hanako;
		if (taro > hanako) x+=3;
		else if(taro == hanako) x+=1, y+=1;
		else if(taro < hanako) y+=3;
	}
	cout << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

unsigned int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w; return(w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n + m - 1), b(n + m - 1);

	int maxn = 0;
	rep(i, n + m - 1) {
		cin >> a[i] >> b[i];
		maxn = max(maxn, max(a[i], b[i]));
	}
	vector<vector<int>> child(maxn + 1), parent(maxn+1);

	rep(i, n + m - 1) {
		child[a[i]].push_back(b[i]);
		parent[b[i]].push_back(a[i]);
	}

	vector<int> ans(maxn + 1);
	queue<int> q;

	FOR(i, 1, maxn + 1) {
		if (parent[i].empty()) {
			ans[i] = 0;
			q.push(i);
		}
	}

	while (q.size() > 0) {
		int x = q.front();
		q.pop();
		rep(i, child[x].size()) {
			int y = child[x][i];

			auto itr = parent[y].begin();
			while (itr != parent[y].end())
			{
				if ((*itr) == x)
				{
					itr = parent[y].erase(itr);
					if (parent[y].size() == 0) {
						ans[y] = x;
						q.push(y);
					}
				}
				else
				{
					itr++;
				}
			}
		}
	}
	FOR(i, 1, maxn + 1) {
		cout << ans[i] << endl;
	}

	return 0;
}





Measured memory_bytes: 12928
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  s <- getLine
  print $ case s of
    "SUN" -> 7
    "MON" -> 6
    "TUE" -> 5
    "WED" -> 4
    "THU" -> 3
    "FRI" -> 2
    "SAT" -> 1


Measured memory_bytes: 380
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import math

def my_round(x):
    xx = 1000*x
    f, i = math.modf(xx)
    #print(f,i)
    if f < 0.0 and f <= -0.5:
        i -= 1
    if f >= 0.0 and f >= 0.5:
        i += 1
    return i/1000 + 0

def main():
    for line in sys.stdin:
        a, b, c, d, e, f = map(float, line.split())

        det = a*e - b*d
        x = ( e*c - b*f) / det
        y = (-d*c + a*f) / det

        xr = my_round(x)
        yr = my_round(y)
        print("{:.3f} {:.3f}".format(xr, yr))

if __name__ == "__main__": main()

Measured memory_bytes: 7600
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <random>
#include <complex>
#include <random>
#include <functional>
 
using namespace std;

#define int long long

bool check(vector<int> v) {
    for (int i = 0; i + 1 < (int)v.size(); i++) {
        if (__builtin_popcount(v[i] ^ v[i + 1]) != 1) {
            return false;
        }
    }
    return true;
}

vector<int> genka(int n, int a, int b) {
    if (n == 1) {
        return {a, b};
    }
    assert(__builtin_popcount(a ^ b) & 1);
    int ca = (a >> (n - 1)) & 1;
    int cb = (b >> (n - 1)) & 1;
    if (ca != cb) {
        int wb = 0;
        if (ca)  {
            a ^= (1 << (n - 1));
            b ^= (1 << (n - 1));
            wb = 1;
        }
        for (int mid = 0; mid < (1 << (n - 1)); mid++) {
            if (__builtin_popcount(mid ^ a) % 2 == 0) continue;
            if (__builtin_popcount((1 << (n - 1)) ^ mid ^ b) % 2 == 0) continue;
            {
                vector<int> f = genka(n - 1, a, mid);
                vector<int> s = genka(n - 1, mid, b ^ (1 << (n - 1)));
                for (auto t : s) {
                    f.push_back(t ^ (1 << (n - 1)));
                }
                if (wb) {
                    for (auto &t : f) {
                        t ^= (1 << (n - 1));
                    }
                }
                return f;
            }
        }
    } else {
        int wb = 0;
        if (ca)  {
            a ^= (1 << (n - 1));
            b ^= (1 << (n - 1));
            wb = 1;
        }
        vector<int> f = genka(n - 1, a, b);
        {
            int i = 0; 
            int x = f[i];
            int y = f[i + 1];
            vector<int> s = genka(n - 1, x, y);
            vector<int> ans = {f[0]};
            for (auto t : s) {
                ans.push_back(t ^ (1 << (n - 1)));
            }
            for (int j = 1; j < (int)f.size(); j++) {
                ans.push_back(f[j]);
            }
            if (wb) {
                for (auto &t : ans) {
                    t ^= (1 << (n - 1));
                }
            }
            return ans;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b;
    cin >> n >> a >> b;
    int dt = a ^ b;
    if (!(__builtin_popcount(dt) & 1)) {
        cout << "NO\n";
        exit(0);
    } 
    cout << "YES\n";
    vector<int> ans = genka(n, a, b);
    for (auto t : ans) {
        cout << t << ' ';
    }
    cout << endl;
    // for (int i = 0; i < (1 << n); i++) {
    //     for (int j = 0; j < (1 << n); j++) {
    //         if (__builtin_popcount(i ^ j) & 1) genka(n, i, j);
    //     }
    // }
}


Measured memory_bytes: 2776
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll s[500005];
ll c[500005];
ll nmbr[500005];
int main()
{
    fastread;
    ll m,n,i,j,k,l;
    cin>>n>>m;
    for(i=1;i<=n;i++)
       nmbr[i]=-1;
    int flag=0;   
    for(i=1;i<=m;i++){
    	cin>>k>>l;
    	if(nmbr[k]!=-1&&nmbr[k]!=l){
    		flag=1;
    		break;
		}
		else if(k==1&&l==0&&n>1){
			flag=1;
			break;
		}
		else
		nmbr[k]=l;
	}
	if(flag==0){
		for(i=1;i<=n;i++){
			if(nmbr[i]==-1){
				if(i==1&&n>1)
				nmbr[i]=1;
				else
				nmbr[i]=0;
			}
		}
		for(i=1;i<=n;i++)
		cout<<nmbr[i];
	}
	else
	cout<<"-1";   
    return 0;
}

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

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

 int main() {
   int H, W;
   cin >> H >> W;
   vector<vector<char>> pict(H + 2, vector<char>(W + 2));

   rep(i, W + 2) {
     pict.at(0).at(i) = '.';
     pict.at(H + 1).at(i) = '.';
   }
   rep(i, H + 2) {
     pict.at(i).at(0) = '.';
     pict.at(i).at(W + 1) = '.';
   }
   for (int i = 1; i <= H; i++) {
     for (int j = 1; j <= W; j++) {
       cin >> pict.at(i).at(j);
     }
   }

   string ans = "Yes";
   for (int i = 1; i <= H; i++) {
     for (int j = 1; j <= W; j++) {
       if (pict.at(i).at(j) == '#' && pict.at(i - 1).at(j) == '.' && pict.at(i + 1).at(j) == '.' && pict.at(i).at(j - 1) == '.' && pict.at(i).at(j + 1) == '.') {
         ans = "No";
         break;
       }
     }
     if (ans == "No") break;
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void) {
	// 3のn乗 - 2の(偶数の数)乗 
	int n, a;
	cin >> n;
	int even_cnt = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a % 2 == 0) ++even_cnt;
	}
	int ans = pow(3, n) - pow(2, even_cnt);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

const int inf=1<<30;
int memo[1<<16][16], t[17][17], n;

#define min(x, y) ((x)<(y)?(x):(y))

int func(int S, int k)
{
    int i, j, res=memo[S][k];
    if (S==(1<<n)-1) return 0;
    if (res) return res;

    res=inf;
    for(i=0;i<n;++i) if (!(S&(1<<i))) {
        int minT=t[i+1][0];
        for(j=0;j<n;++j) if (S&(1<<j)) minT=min(minT, t[i+1][j+1]);
        res=min(res, func(S|(1<<i), i)+minT);
    }
    return memo[S][k]=res;
}

int main(void)
{
    while (scanf("%d", &n), n) {
        int i, j, res;
        for(i=1;i<=n;++i) for(j=0;j<=n;++j) scanf("%d", &t[i][j]);
        res=inf;
        memset(memo, 0, sizeof(memo));
        res=min(res, func(0, 0));
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 4704
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;





int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;
    cin>>k>>s;
    if(s.length() <= k){
        cout<<s<<endl;
    }
    else{
        cout<<s.substr(0,k)+"...";
    }




  






}

Measured memory_bytes: 3648
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+100;
const LL mod=1e9+7;
LL arr[N],ans[N];

LL fac[N],opp[N],op_fa[N];
void preWork(){
	
	fac[0]=fac[1]=1;
	opp[0]=opp[1]=1;
	op_fa[0]=op_fa[1]=1;
	for(int i=2;i<=1e5+100;i++){
		
		fac[i]=((LL)fac[i-1]*i)%mod;
		opp[i]=(LL)(mod-mod/i)*opp[mod%i]%mod;
		op_fa[i]=(LL)opp[i]*op_fa[i-1]%mod;
	}

}
LL C(LL n,LL m){
	if(n<m)return 0;   //
	int ans=(LL)fac[n]%mod*(LL)op_fa[n-m]%mod*(LL)op_fa[m]%mod;
	return ans%mod;
}
int mak[N];
int main(){
	
	int n;
	preWork();
	while(cin>>n){
		memset(mak,0,sizeof(mak));
		
		int x,pos1=1,pos2=1,tmp1,tmp2,tmp;
		for(int i=1;i<=n+1;i++){
			cin>>x;
			if(mak[x])tmp=n-i+mak[x];
			mak[x]=i;	
		}
		ans[1]=n;
		for(int i=1;i<=n+1;i++){
	
			ans[i]=((LL)C(n+1,i)-(LL)C(tmp,i-1)+mod)%mod;
			
			
		}
		for(int i=1;i<=n+1;i++){
			
			cout<<ans[i]<<endl;
		}
	}
	return 0;
}

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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  
  string s="NG";
  
  for(int i=a;i<=b;i++){
    if(i%k==0){
      s="OK";
      break;
    }
  }
  cout << s << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;
using tTree=__gnu_pbds::tree< ll , __gnu_pbds::null_type, less< ll >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  string s;
  cin>>s;
  char prev=-1;

  ll LPos;
  ll RPos;

  vector<ll> ans(s.size(),0);

  unordered_set<ll> unse;
  for( ll i=0;i<s.size();i++ ){
    auto c=s[i];
    if(prev=='R'&& c=='L')
    {
      LPos=i;
      RPos=i-1;
      unse.insert(i);
    }
    else if(prev=='L'&& c=='R'){
      
      for(auto x:unse){
        if( x%2 == LPos%2 ){
          ans[LPos]++;
        }
        else ans[RPos]++;
      }
      unse.clear();
      unse.insert(i);
    }
    else if(c=='R'){
      unse.insert(i);
    }
    else if(c=='L'){
      unse.insert(i);
    }

    prev=c;
  }

  if(!unse.empty()){
    for(auto x:unse){
        if( x%2 == LPos%2 ){
          ans[LPos]++;
        }
        else ans[RPos]++;
      }
    unse.clear();
  }

  for(auto x:ans){
    cout << x << " ";
  }
  cout << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

int H, W;
int a[30], num[10];

int main() {
    cin >> H >> W;
    bool ho = H % 2 == 1, wo = W % 2 == 1;
    REP(i, H) {
        string s;
        cin >> s;
        REP(j, W) a[s[j] - 'a']++;
    }
    int m = min(2, H) * min(W, 2);
    REP(c, 26) {
        while (a[c] > 0) {
            if (a[c] >= m)a[c] -= m, num[m]++;
            else if (a[c] >= 2) {
                a[c] -= 2, num[2]++;
            } else num[1]++, a[c]--;
        }
    }
    int v = (H / 2) * (W / 2);
    int x = (H / 2) * wo + (W / 2) * ho;
    if (ho && wo) {
        if (num[1] == 1) {
            if ((num[2] == x && num[4] == v) || (x == 2 * (num[4] - v))) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    } else {
        if (num[1] == 0) {
            if ((num[2] == x && num[4] == v) || (x == 2 * (num[4] - v))) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}



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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll H,ANS=0,X=1;
    cin>>H;
    while(H>=1){
        H/=2;
        ANS+=X;
        X*=2;
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  LLI R,G,B,N;
  while(cin >> R >> G >> B >> N){
    int ans = 0;
    
    FORE(r,0,3000){
      FORE(g,0,3000){
	int t = N-r*R-g*G;
	if(t >= 0 and t%B==0) ++ans;
      }
    }

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


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

int main()
{
    int n; cin>>n;
    vector<int> d(n); for(auto& e: d) cin>>e;
    sort(begin(d), end(d));

    int mink=d[n/2-1]+1;
    int maxk=d[n/2];
    cout<<maxk-mink+1<<endl;
}


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

int main()
{
    int N, D, X;
    int A[100];
    scanf("%d", &N);
    scanf("%d %d", &D, &X);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
    int S = 0;
    for (int i = 0; i < N; i++)
    {
        int day = 1;
        while (day <= D)
        {
            S++;
            day += A[i];
        }
    }
    S += X;
    printf("%d\n", S);
    return 0;
}

Measured memory_bytes: 256
#アルファベットリストの作成
count = {}
for i in range(26):
    count[chr(ord('a') + i)] = 0

#入力情報を記録
list = []
try:
    while True:
        inp = input().lower()
        if inp == "":
            break
        list += inp
except EOFError:
    pass

#入力情報の文字数をカウントする
for i in range(len(list)):
    for j in range(len(list[i])):
        if list[i][j] in count.keys():
            count[list[i][j]] += 1

for k, v in count.items():
    print(k,":",v)


Measured memory_bytes: 5580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}

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

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

    ll base = 1;
    rep(i, 1, 11)
        base *= i;
    
    map<string, ll> s_cnt;
    rep(i, 0, n)
    {
        string s;
        cin >> s;

        sort(s.begin(), s.end());
        s_cnt[s]++;
    }

    ll ans = 0;
    for (auto s_c: s_cnt)
    {
        ll cnt = s_c.second;

        if (cnt > 1)
        {
            ans += cnt * (cnt - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int g[2005][2005];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n,x,y;cin>>n>>x>>y;x--,y--;
  map<int, int> mp;

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int dist = j - i;
      dist = min(dist, abs(i-x) + 1 + abs(j-y));
      mp[dist]++;
    }
  }
  for(int i=1;i<=n-1;i++) {
    cout<<mp[i]<<endl;
  }

  return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const ll LINF = 1e18 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;
ll C;

ll rSum[MAX_N];
ll lSum[MAX_N];
ll lMax[MAX_N];

ll solve(vector< ll > x, vector< ll > v)
{
  // 原点から右方向に進んだ時の、摂取できるカロリーの累積和を求める
  REP(i, N) {
    if (i > 0) rSum[i] = rSum[i - 1] + v[i];
    else rSum[i] = v[i];
  }

  // 原点から左方向に進んだ時の、摂取できるカロリーと消費するカロリーの差の最大値を求める
  // mxは原点から左方向に進んだ時に得られる最大のカロリー
  ll mx = 0ll;
  RREP(i, N) {
    ll cal = C - x[i];
    if (i < N - 1) lSum[i] = lSum[i + 1] + v[i] - (x[i+1]-x[i]);
    else lSum[i] = v[i] - (C-x[i]);
    mx = max(mx, lSum[i]);
    lMax[i] = mx;
  }

  // 右に行く範囲を大きくしていって、最大値を求める
  ll res = 0ll;
  REP(ub, N) {
    ll sum = 0ll;

    // printf("ub = %d\n", ub);
    
    sum -= x[ub];
    // debug(sum);
    sum += rSum[ub];

    // 左に戻らずに出る場合
    res = max(res, sum);

    sum -= x[ub];
    // debug(sum);

    if (ub < N - 1) sum += lMax[ub + 1];

    // printf("sum = %ld\n", sum);
    // printf("res = %ld\n", res);
    res = max(res, sum);
  }
  // cout << endl;

  return res;
}

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

  cin >> N >> C;
  vector< ll > x(N);
  vector< ll > v(N);
  REP(i, N) {
    cin >> x[i] >> v[i];
  }

  ll ans = solve(x, v);

  reverse(ALL(x));
  REP(i, N) {
    x[i] = C - x[i];
  }
  reverse(ALL(v));

  ans = max(ans, solve(x, v));

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



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

typedef long long ll;
const int maxn = 503;
const int dxy[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int n, d[maxn * maxn], r[maxn * maxn], p[maxn * maxn], o[maxn * maxn];

std::queue<int> q;
void push(int u, int v) {
    if(d[u] <= v)
        return;
    d[u] = v;
    q.push(u);
}
void bfs(int s) {
    r[s] = 1;
    q.push(s);
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(int j = 0; j < 4; ++j) {
            int x = (u - 1) / n, y = (u - 1) % n;
            x += dxy[j][0];
            y += dxy[j][1];
            if(x < 0 || x >= n || y < 0 || y >= n)
                continue;
            int v = x * n + y + 1;
            int w = d[u] + (!r[u]);
            push(v, w);
        }
    }
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n * n; ++i) {
        scanf("%d", p + i);
        o[p[i]] = i;
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            d[i * n + j + 1] = std::min({i, j, n - i - 1, n - j - 1});
        }
    }
    ll ans = 0;
    for(int i = 1; i <= n * n; ++i) {
        ans += d[p[i]];
        bfs(p[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7684