akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int m;
    cin>>m;
    cout<<48-m<<endl;
    return 0;
}


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

template <class T>
struct sparse {
    int n, logn;
    vector<vector<T>> st;
    function<T(T, T)> func = [&](T a, T b) { return min(a, b); };

    sparse(vector<T> a) {
        n = a.size();
        logn = 32 - __builtin_clz(n);
        st.resize(logn);
        st[0] = a;
        for (int j = 1; j < logn; j++) {
            st[j].resize(n - (1 << j) + 1);
            for (int i = 0; i <= n - (1 << j); i++) {
                st[j][i] = func(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);
            }
        }
    }

    T get(int from, int to) const {
        int lg = 32 - __builtin_clz(to - from + 1) - 1;
        return func(st[lg][from], st[lg][to - (1 << lg) + 1]);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n), rev(n + 1), fr(n + 1);
    vector<vector<int>> s(2, vector<int>(n, 1e9)), ch(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        rev[p[i]] = i;
        s[i & 1][i] = p[i];
    }
    vector<sparse<int>> st = {sparse<int>(s[0]), sparse<int>(s[1])};
    function<int(int, int)> solve = [&](int a, int b) {  // [a, b)
        if (a == b) {
            return -1;
        }
        int dep = a & 1;
        int mn = st[dep].get(a, b - 1);
        int pos = rev[mn];
        int mo = st[dep ^ 1].get(pos + 1, b - 1);
        int pot = rev[mo];
        fr[mn] = mo;
        ch[mn].emplace_back(solve(a, pos));
        ch[mn].emplace_back(solve(pos + 1, pot));
        ch[mn].emplace_back(solve(pot + 1, b));
        return mn;
    };
    int root = solve(0, n);
    debug(root);
    vector<int> q;
    priority_queue<int, vector<int>, greater<int>> pq;
    pq.push(root);
    while (!pq.empty()) {
        int v = pq.top();
        pq.pop();
        q.emplace_back(v);
        for (int i : ch[v]) {
            if (i > 0) pq.push(i);
        }
    }
    for (int i : q) {
        cout << i << " " << fr[i] << " ";
    }
    cout << endl;
    return 0;
}

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

int64_t gcd(int m, int n) {
  if (n == 0) {
    return m;
  }
  else {
    return gcd(n, m%n);
  }
}

int main() {
  int N;
  int64_t X;
  cin >> N >> X;
  vector<int64_t> x(N), d(N); // d means diameter
  for (int i=0; i<N; i++) {
    cin >> x.at(i);
    d.at(i) = abs(X-x.at(i));
  }
  int64_t answer;
  if (N == 1) {
    answer = d.at(0);
  }
  else {
    answer = gcd(d.at(0), d.at(1));
    for (int i=0; i<N-2; i++) {
      answer = gcd(answer, d.at(i+2));
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 1792
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = input().rstrip()

    if (N[0] == '7') | (N[1] == '7') | (N[2] == '7'):
        print('Yes')
    else:
        print('No')



main()


Measured memory_bytes: 9096
M=1000003
o=->a,n{n<1?1:(n%2>0?a:1)*o[a,n/2]**2%M}
*f=1
1.upto(M){|i|f<<f[i-1]*i%M}
gets
$<.map{|s|x,d,n=s.split.map &:to_i
t=x*o[d,M-2]%M
p d<1?o[x,n]:M<t+n||t<1?0:f[t+n-1]*o[f[t-1],M-2]*o[d,n]%M}

Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L
const int mod=1000000007,MAX=200005,INF=1<<30;

	int n;
  	ll w,weight[110],value[110];
  
  	ll dp[110][100100]={0};

int main() {
  cin>>n>>w;
  rep(i,n){
  	cin>>weight[i]>>value[i];
  }
  
  for(int i=0;i<n;i++){
  	for(int sum_w=0;sum_w<=w;sum_w++){
    	if(sum_w-weight[i]>=0){
        	chmax(dp[i+1][sum_w],dp[i][sum_w-weight[i]]+value[i]);
        }
      
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }

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

}

Measured memory_bytes: 81688
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	int n;
	cin >> n;
	vector <int> p(n + 1);
	for (int i = 2; i <= n; i++) {
		int t = i;
		for (int j = 2; j <= i; j++) {
			int c = 0;
			if (t % j == 0) {
				while(t % j == 0) {
					t /= j;
					c++; 
				}
				p[j] += c;
			}
		}
	}
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = (ans * (p[i] + 1)) % MOD;
	}
	cout << ans;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		String S = sc.next();
		int K = sc.nextInt();
		SortedSet<String> strings = new TreeSet<>();
		for (int i = 0; i < S.length(); i++) {
			for (int j = 1; j <= K && i + j <= S.length(); j++) {
				strings.add(S.substring(i, i + j));
			}
		}
		String ans = null;
		while (K > 0) {
			K--;
			strings.remove(ans = strings.first());
		}
		System.out.println(ans);
	}
}


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

int main ()

{
    int k;
    string s;
    cin >> k;
    cin >> s;
    if (s.size()>k)
    {
        s = s.substr (0,k)+"...";
    }
    cout << s << endl;
    return 0;

}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x,n;
	cin >> x >> n;
	set<int> s;
	for(int i = 0;i<n;i++){
	    int temp;
	    cin >> temp;
	    s.insert(temp);
	}
	for(int i = 0;i<=100;i++){
	    int temp = x-i;
	    if(s.find(temp)==s.end()){
	        cout << temp << "\n";
	        break;
	    }
	    temp = x+i;
	    if(s.find(temp)==s.end()){
	        cout << temp << "\n";
	        break;
	    }
	}
	return 0;
}


Measured memory_bytes: 3600
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		String s = sc.next();
		boolean[] ans = new boolean[1000];
		for (int i = 0; i < 1000; i++) {
			int first = s.indexOf(Integer.toString(i / 100));
			if (first == -1) {
				continue;
			}
			int second = s.indexOf(Integer.toString(i % 100 / 10), first + 1);
			if (second == -1) {
				continue;
			}
			int third = s.indexOf(Integer.toString(i % 100 % 10), second + 1);
			if (third == -1) {
				continue;
			}
			ans[i] = true;
		}
		int sum = 0;
		for (int i = 0; i < 1000; i++) {
			if (ans[i]) {
				sum++;
			}
		}
		System.out.println(sum);
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

const int maxn = 310;
int n, K, P, f[maxn][maxn], s[maxn][maxn], C[maxn][maxn];

int main() {
    scanf("%d %d %d", &n, &K, &P);
    for (int i = 0; i <= n; i++) {
        for (int j = C[i][0] = 1; j <= i; j++) {
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % P;
        }
    }
    for (int i = 0; i <= K; i++) {
        f[1][i] = 1, s[1][i] = K - i + 1;
    }
    for (int i = 2; i <= n + 1; i++) {
        for (int j = 1; j < i; j++) {
            for (int k = 0; k <= K; k++) {
                f[i][k] = (f[i][k] + 1LL * f[i - j][k] * s[j][k + 1] % P * C[i - 2][j - 1]) % P;
            }
        }
        for (int j = K; j; j--) s[i][j] = (s[i][j + 1] + f[i][j]) % P;
    }
    printf("%d\n", f[n + 1][0]);
    return 0;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
h = list(map(int, input().split()))
false_set = set()
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] == h[b]:
        false_set.add(a)
        false_set.add(b)
    elif h[a] < h[b]:
        false_set.add(a)
    else:
        false_set.add(b)
print(n-len(false_set))

Measured memory_bytes: 20112
import datetime
S = input()

def YYMM(S):
	try:
		datetime.datetime.strptime(S,"%y%m")
		return True
	except ValueError:
		return False

def MMYY(S):
	try:
		datetime.datetime.strptime(S,"%m%y")
		return True
	except ValueError:
		return False

YM = YYMM(S)
MY = MMYY(S)

if YM and MY:
	print("AMBIGUOUS")
elif YM:
	print("YYMM")
elif MY:
	print("MMYY")
else:
	print("NA")

Measured memory_bytes: 4464
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    cout << r * r << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

using namespace std;
int main() {

	ll s;
	cin >> s;
	ll ans = 0;
	
	ll goC = s / 500;

	s -= goC * 500;

	ll g = s / 5;


	cout << goC * 1000 + g * 5 << endl;

}

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

class biconnected {
private:
  void dfs(int u, int p, int &tm) {
    bool flag = false;
    ord.at(u) = low.at(u) = tm++, st.push(u);
    for (int v : G.at(u)) {
      if (ord.at(v) < 0) {
        dfs(v, u, tm);
        low.at(u) = min(low.at(u), low.at(v));
      } else if (v != p) {
        low.at(u) = min(low.at(u), ord.at(v));
      } else{
        if (flag) low.at(u) = min(low.at(u), ord.at(v));
        else flag = true;
      }
    }
    if (ord.at(u) == low.at(u)) {
      if (p >= 0) bridge.emplace_back(u, p);
      while(true) {
        const int v = st.top();
        st.pop();
        cmp.at(v) = kind;
        if (v == u) break;
      }
      kind++;
    }
  }
public:
  const int V;
  int kind;
  vector<vector<int>> G, tree;
  vector<pair<int, int>> bridge;
  vector<int> ord, low, cmp;
  stack<int> st;
  biconnected(int node_size) : V(node_size), kind(0), G(V), ord(V, -1), low(V), cmp(V) {}
  void add(const int u, const int v) {
    G.at(u).push_back(v), G.at(v).push_back(u);
  }
  int detect_bridge() {
  int tm = 0;
  for (int i = 0; i < V; i++) {
    if (ord.at(i) < 0) dfs(i, -1, tm);
  }
  for (int i = 0; i < V; i++) cmp.at(i) = kind - 1 - cmp.at(i);
  return kind;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  biconnected B(N);
  while (M--) {
    int a, b;
    cin >> a >> b;
    B.add(--a, --b);
  }
  cout << B.detect_bridge() - 1 << "\n";
}

Measured memory_bytes: 256
program worlds_tale
  implicit none
  integer              :: n, m, x, y
  integer, allocatable :: xi(:), yi(:)
  integer              :: inf, sup
  read(*,*) n, m, x, y
  allocate(xi(n),yi(m))
  read(*,*) xi(:)
  read(*,*) yi(:)
  sup = maxval(xi)
  inf = minval(yi)
  if (min(inf,y)-max(sup,x) .ge. 1) then
     write(*,'(a)') "No War"
  else
     write(*,'(a)') "War"
  end if
  deallocate(xi,yi)
  stop
end program worlds_tale

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int n;
    cin >> n;
    map<string, ll> a;
    while(n--){
        string s;
        cin >> s;
        sort(all(s));
        a[s]++;
    }
    ll sol=0;
    for(auto& x: a){
        sol+=((x.second-1)*(x.second))/2;
    }
    cout << sol;
}

Measured memory_bytes: 11136
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
 
    def to_sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= (i & -i)
        return s
 
    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += (i & -i)
 
    def get(self, i, j):
        return self.to_sum(j)-self.to_sum(i-1)

N,K = map(int,input().split());MOD = 998244353
S = []
for i in range(K):
  temp = list(map(int,input().split()))
  S.append(temp)
#print(S)
Tree = BIT(N) #1index
Tree.add(1,1) #最初
for i in range(1,N+1):
  for l,r in S:
    #print(i-r,i-l)
    if i-r >= 1:
      temp = Tree.get(i-r,i-l)
    elif i-l >= 1:
      temp = Tree.get(1,i-l)
    else:
      temp = 0
    Tree.add(i,temp%MOD)
ans = Tree.get(N,N)%MOD
print(ans)



Measured memory_bytes: 70632
package main

import (
	"fmt"
)

func main() {
	var b string
	fmt.Scan(&b)

	switch b {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	default:
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

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

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

const double PI = acos(-1.0);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,M;
    cin>>N>>M;
    priority_queue<ll> pq;
    rep(i,N){
        int a;
        cin>>a;
        pq.push(a);
    }
    while(M--){
        int x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }
    ll ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

    int N, M;
    cin >> N >> M;

    int a = M * 1900 + (N - M) * 100;
    cout << a * pow(2, M) << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int n;
    cin>>n;
    vector<int64_t> a(n);
    map<int,int> p;
    rep(i,n){
        cin>>a[i];
        p[a[i]]++;
    }
    int64_t sum = 0;
    for(auto c:p){
        int64_t ball = c.first;
        int64_t cnt = c.second;
        sum += cnt*(cnt-1)/2;
    }
    //cout<<sum<<endl;
    rep(i,n){
        int64_t ans = sum;
        if(p.count(a[i])){//まあ絶対ある
            int64_t ball = p[a[i]];
            //cout<<"ball:"<<ball<<"  ";
            ans -= ball*(ball-1)/2;
            ans += (ball-1)*(ball-2)/2;
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL K,A,B;

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


Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

bool comp(pair<string, int>& a, pair<string, int>& b){
	if(a.fi < b.fi)return true;
	else if(a.fi > b.fi)return false;
	else return a.se > b.se;
}

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<pair<string, int>> v, u;
	forn(i, n){
		string s;int sc;
		cin >> s >> sc;
		v.pb({s, sc});
	}
	u = v;
	sort(all(u), comp);
	forn(i, n){
		auto z = find(all(v), u[i]) - v.begin();
		cout << z + 1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

typedef long long ll;

int main()
{
    ll N, T;
    cin >> N >> T;
    vector<ll> t(N+1);
    t[0]=0;
    for(int i=0; i<N; i++){
        cin >> t[i+1];
    }
    ll now=0, ans=0;
    for(int i=1; i<N+1; i++){
        ans+=min(t[i]-t[i-1], T);
    }
    ans+=T;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll X;
    cin >> X;
    ll ans = X / 500 * 1000 + (X%500)/5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100];
	string s, t;
	char u;
	int i, j, k;
	bool flag = true;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		x[i] = 0;
		}
	for (i = 0; i < m; i++) {
		cin >> l;
		for (j = 0; j < l; j++) {
			cin >> a;
			x[a - 1]++;
		}
	}
	b = 0;
	for (i = 0; i < n; i++) {
		if (x[i] == 0)b++;
	}
	cout << b << endl;
		
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N

int main(){
	FIO;
    int k; cin >> k;
    string s;
    cin >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0,k) << "..." << endl;
	return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmpint(const void *x, const void *y) { return *(int *)x - *(int *)y; }
int main() {
	char s[200001], t[200001];
	int Scnt[26] = {0}, Tcnt[26] = {0};
	scanf("%s%s", s, t);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		Scnt[s[i] - 'a']++;
	}
	for (int i = 0; i < len; i++) {
		Tcnt[t[i] - 'a']++;
	}
	qsort(Scnt, 26, sizeof(int), cmpint);
	qsort(Tcnt, 26, sizeof(int), cmpint);
	for (int i = 0; i < 26; i++) {
		if (Scnt[i] != Tcnt[i]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 2e5+5;

int n,a[N];
multiset<int>m;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>a[i];
        m.insert(a[i]);
    }

    for(int i=1;i<=n;i++){
        m.erase(m.find(a[i]));
        auto it=m.end();
        it--;
        cout<<*it<<"\n";
        m.insert(a[i]);
    }

    return 0;
}



Measured memory_bytes: 11776
import java.util.*;
 
class Main{
 
    void solve(){
        Scanner sc = new Scanner(System.in);
         
         
        long[][][] dp = new long[1001][101][10];
        for(int i=0; i<=100; i++) dp[i][i][1] = 1;
           
        for(int i=2; i<=9; i++){
            for(int j=0; j<=100; j++){
                for(int k=j; k<=1000; k++){
                    for(int l=0; l<j; l++){
                        dp[k][j][i] += dp[k-j][l][i-1];
                    }
                }
            }
        }
         
 
        while(true){
            int n = sc.nextInt();
            int s = sc.nextInt();
            if(n==0 && s==0) break;
 
            long cnt = 0;
            for(int i=0; i<=100; i++) cnt += dp[s][i][n];
             
            System.out.println(cnt);
        }
    }
     
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 31640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <map>
using namespace std;

typedef long long ll;
const ll inf = 1e15;

int main() {
    ll n,k,q;
    cin>>n>>k>>q;
    vector<ll> v(n,0);
    for (ll i = 0; i < q; i++) {
        ll p; cin>>p; p--;
        v[p]++;
    }
    for (ll i = 0; i < n; i++) {
        if (k - q + v[i] > 0) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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



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

  int ans = 0;
  rep(i, 7) {
    if((int)pow(2, i) <= n) ans = (int)pow(2, i);
  }
  cout << ans << endl;

  return 0;
}

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

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    cout<<setprecision(10)<<fixed;

    ll n,k,x,m=0;
    cin>>n>>k;
    ll s[n+1];
    s[0] = 0;

    for(int i=1;i<=n;i++)
    {
        cin>>x;
        s[i]=(x+1+s[i-1]);
        //cout<<s[i]<<" ";
    }

    for(int i=k;i<=n;i++)
        m = max(m,s[i]-s[i-k]);

    cout<<(m/2.0)<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
const int mod=1e9+7;
long long f[4000010],inv[4000010],dp[2010][2010];
int n,K;
int ADD(int x)
{
	return (x>=mod)?x-mod:x;
}
long long calc(long long a,long long b,long long mod)
{
	long long ans=1,t=a;
	for (;b;b>>=1)
	{
		if (b&1) ans=ans*t%mod;
		t=t*t%mod;
	}
	return ans;
}
long long C(int n,int m)
{
	return f[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	scanf("%d%d",&n,&K);
	if (K==1)
	{
		printf("1\n");
		return 0;
	}
	f[0]=1;
	for (int i=1;i<=n*K;i++) f[i]=f[i-1]*i%mod;
	inv[n*K]=calc(f[n*K],mod-2,mod);
	inv[0]=1;
	for (int i=n*K-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
	dp[0][0]=1;
	for (int i=0;i<=n;i++)
		for (int j=0;j<=i;j++)
		{
			if (i!=0) dp[i][j]=dp[i-1][j];
			if (j!=0) dp[i][j]=ADD(dp[i][j]+dp[i][j-1]*C(n*K-i-(j-1)*(K-1)-1,K-2)%mod);
		}
	printf("%lld\n",dp[n][n]*f[n]%mod);
	return 0;
}

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

using namespace std;

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

    if (n.at(0) == n.at(1) && n.at(1) == n.at(2)) {
        cout << "Yes" << endl;
        return 0;
    } else if (n.at(1) == n.at(2) && n.at(2) == n.at(3)) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, K;
	cin >> N >> K;
	int key;
	for (int i = 0; i < N; ++i) {
		int a;
		cin >> a;
		if (a == 1) {
			key = i;
		}
	}
	if ((N - 1) % (K - 1) == 0) {
		cout << (N - 1) / (K - 1) << endl;
	}
	else {
		cout << (N - 1) / (K - 1) + 1 << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N;
	int i;
	int a = 0, b = 0, ab = 0, ba = 0;
	int kitaeri;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		char s[16];
		int j;
		if (scanf("%15s", s) != 1) return 1;
		if (s[0] == 'B') b++;
		for (j = 0; s[j] != '\0'; j++) {
			if (s[j] == 'A' && s[j + 1] == 'B') ab++;
			if (s[j] == 'A' && s[j + 1] == '\0') {
				a++;
				if (s[0] == 'B') ba++;
			}
		}
	}
	kitaeri = a <= b ? a : b;
	printf("%d\n", ab + (a == ba && b == ba && ba > 0 ? kitaeri - 1 : kitaeri));
	return 0;
}


Measured memory_bytes: 1708
import sys
d={' ':'101',"'":'000000',',':'000011','-':'10010001','.':'010001','?':'000001','A':'100101','B':'10011010','C':'0101','D':'0001','E':'110',
'F':'01001','G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100','M':'10011001','N':'10011110','O':'00101','P':'111',
'Q':'10011111','R':'1000','S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010','Y':'10010011','Z':'10010000'}
for e in sys.stdin:
 a=''.join(d[c]for c in e[:-1])
 a+='0'*(-len(a)%5)
 print(''.join("ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"[int(a[i:i+5],2)]for i in range(0,len(a),5)))


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

int main() {
  int N; cin >> N;
  vector<int> A(N + 2);
  rep(i, 1, N + 1) cin >> A[i];
  int tot = 0;
  rep(i, 0, N + 1) tot += abs(A[i] - A[i+1]);
  rep(i, 1, N + 1) {
    int el = abs(A[i] - A[i-1]) + abs(A[i] - A[i+1]);
    int ad = abs(A[i-1] - A[i+1]);
    cout << tot - el + ad << "\n";
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  LL n;
  cin >> n;
  bool flag = false;
  REP(i, n) {
    int a;
    cin >> a;
    if(a%2) flag = true;
  }
  cout << (flag?"first":"second") << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String InStr = scan.nextLine();
		String[] AryStr = InStr.split(" ");

		int A = Integer.parseInt(AryStr[0]);
		int B = Integer.parseInt(AryStr[1]);
		int T = Integer.parseInt(AryStr[2]);
		int X;

		X = T / A;

		System.out.println(B * X);

		scan.close();
	}
}


Measured memory_bytes: 21716
from decimal import *
import sys

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

N = int(input())

A = [Decimal(input()) for i in range(N)]

nanachi = [[0, 0] for i in range(N)]

eprint(A)

def is_integer(n: Decimal):
  return n == n.to_integral_value()

for i, a in enumerate(A):
  t = 0
  while not is_integer(a):
    a *= 10
    t += 1
  nanachi[i][0] = -t
  nanachi[i][1] = -t
  while a % 2 == 0:
    a = a / 2
    nanachi[i][0] += 1
  while a % 5 == 0:
    a = a / 5
    nanachi[i][1] += 1

eprint(nanachi)

tmp = min(map(min, nanachi))

for i in range(N):
  nanachi[i][0] -= tmp
  nanachi[i][1] -= tmp

eprint(nanachi)

aaa = [[0] * 200 for i in range(200)]

for a in nanachi:
  aaa[a[0]][a[1]] += 1

acc = [[0] * 201 for i in range(201)]

for i in reversed(range(0, 200)):
  for k in reversed(range(0, 200)):
    acc[i][k] = acc[i+1][k] + acc[i][k+1] - acc[i+1][k+1] + aaa[i][k]

res = 0

for a in nanachi:
  i = max(0, - (a[0] + 2*tmp))
  k = max(0, - (a[1] + 2*tmp))
  res += acc[i][k]
  if a[0] >= -tmp and a[1] >= -tmp:
    res -= 1

res = res // 2

print(res)

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

int main() {
	int a, b;
	cin >> a >> b;
	if ((a * b) % 2 == 0) puts("Even");
	else puts("Odd");
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<ll, ll> P;

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

vector<vector<ll>> graph;
vector<vector<ll>> dist;
const ll LARGE = (ll)1e15;

bool is_prime(ll value) {
	if (value == 1) return true;
	if (value == 2) return true;
	if (value % 2 == 0) return false;
	for (ll i = 3; i * i <= value; i+=2) {
		if (value % i == 0) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	ll a, b;
	cin >> a >> b;
	ll m = min(a, b);
	set<ll> divs;
	for (ll i = 1; i * i <= m; i++) {
		if (a % i == 0 && b % i == 0) {
			divs.insert(i);
		}
		ll t = m / i;
		if (a % t == 0 && b % t == 0) {
			divs.insert(t);
		}
	}
	set<ll> ps;
	for (auto e : divs) {
		if (is_prime(e)) {
			ps.insert(e);
		}
	}
	cout << ps.size() << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int MAX_N = 12;
typedef pair<int,char> P;

// 入力
int n;
string s[MAX_N];
// f[c] := 文字 c の係数.
int f[256] = {0};
// m[c] := 文字 c に割り当てた数字 (0-9のどれか, まだ割り当てられていないときは -1 )
int m[256] = {0};
// max_digit := 最大の桁数
int max_digit;
// 登場する文字
vector<char> vc;
// is_head[c] := 文字 c が先頭で数字 0 を割り当てることができない.
bool is_head[256];
// used[i] := 数字 i を使ったかどうか.
bool used[10];
// 解
int ans;
// 上限と下限
int low, high;

int pow10(int x){
	int a = 1;
	for(int i=0 ; i < x ; i++ ) a *= 10;
	return a;
}

void init(){
	// 初期化.
	vc.clear();
	for(int i=0 ; i < 10 ; i++ ){
		used[i] = false;
	}
	for(char c = 'A' ; c <= 'Z' ; c++ ){
		f[c] = 0;
		m[c] = -1;
	}
	int a = s[0].size();
	for(int i=1 ; i < n-1 ; i++ ){
		a = max( a , (int)s[i].size() );
	}
	max_digit = max( a , (int)s[n-1].size() );
	// 文字列を逆にする.
	for(int i=0 ; i < n ; i++ ){
		reverse( s[i].begin() , s[i].end() );
	}
	
	// 各文字の係数をまとめておく.
	int h[256] = {0};
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j < max_digit ; j++ ){
			if( s[i].size() <= j ) continue;
			
			h[ s[i][j] ] = 1;
			if( i == n-1 ){
				f[ s[i][j] ] -= pow10(j);
			}else{
				f[ s[i][j] ] += pow10(j);
			}
		}
	}
	// 登場する文字のチェック.
	for(char c = 'A' ; c <= 'Z' ; c++ ){
		if( h[c] ) vc.push_back( c );
	}
	// 係数の小さい順に文字の並び替え
	vector<P> v;
	for(int i=0 ; i < vc.size() ; i++ ){
		char c = vc[i];
		v.push_back( P(f[c],c) );
	}
	sort(v.begin(),v.end());
	// 上限と下限の計算
	int p=9;
	high = low = 0;
	for(int i=0 ; i < v.size() && v[i].first < 0 ; i++ ){
		high -= v[i].first * p--;
	}
	p=9;
	for(int i=v.size()-1 ; i >= 0 && v[i].first >= 0 ; i-- ){
		low -= v[i].first * p--;
	}
	
	// 逆にした文字列を元に戻す.
	for(int i=0 ; i < n ; i++ ){
		reverse( s[i].begin() , s[i].end() );
	}
}

void solve(int pos, int k, int sum ){
	if( pos == k ){
		if( sum == 0 ){
			ans++;
		}
		return ;
	}
	if( sum < low || high < sum ) return;
	
	// c := 今割り当てようとしている文字
	char c = vc[pos];
	for(int i=0 ; i < 10 ; i++ ){
		if( used[i] ) continue;
		if( i == 0 && is_head[c] ) continue;
		
		used[i] = true;
		m[c] = i;
		solve( pos+1 , k , sum + m[c] * f[c] );
		used[i] = false;
		m[c] = -1;
	}
}

int main(){
	while( cin >> n , n ){
		// 初期化
		for(char c = 'A' ; c <= 'Z' ; c++ ) is_head[c] = false;
		// 入力.
		for(int i=0 ; i < n ; i++ ){
			cin >> s[i];
			if( s[i].size() >= 2 ){
				is_head[ s[i][0] ] = true;
			}
		}
		
		// 前処理.
		init();
		// 解く.
		ans = 0;
		solve( 0 , vc.size() , 0 );
		// 解を出力.
		cout << ans << endl;
	}
}

Measured memory_bytes: 932
STDIN.read.split("\n").map(&:chomp).map(&:to_i).each do |n|
  count = 0
  10.times do |a|
    10.times do |b|
      10.times do |c|
        10.times do |d|
          count += 1 if a + b + c + d == n
        end
      end
    end
  end

  puts count
end

Measured memory_bytes: 8628
#include <cstdio>
typedef long long ll;
inline int rd(){
    int x=0,p=1;
    char a=getchar();
    while((a<48||a>57)&&a!='-')a=getchar();
    if(a=='-')p=-p,a=getchar();
    while(a>47&&a<58)x=(x<<1)+(x<<3)+(a&15),a=getchar();
    return x*p;
}
const int N=1000002;
char c;
int main(){
	scanf("%c",&c);
	if(c=='z')putchar(97);
	else putchar(c+1);
	puts("");
    return 0;
}

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

typedef long long ll;
int T, A, B, C, D;
ll N;
map<ll, ll> M;

int _abs(int x) {
	return x < 0 ? -x : x;
}

ll solve(ll N) {
	if (N <= 1) return D * N;
	if (M.count(N)) return M[N];
	ll &res = M[N] = 1e18 / (double)N > D ? D * N : 1e18;
	rep(i, -1, 1) if (N + i >= 0 && (N + i) % 2 == 0) res = min(res, solve((N + i) / 2) + 1ll * abs(i) * D + A);
	rep(i, -2, 2) if (N + i >= 0 && (N + i) % 3 == 0) res = min(res, solve((N + i) / 3) + 1ll * abs(i) * D + B);
	rep(i, -4, 4) if (N + i >= 0 && (N + i) % 5 == 0) res = min(res, solve((N + i) / 5) + 1ll * abs(i) * D + C);
	return res;
}

int main() {
	scanf("%d", &T);
	while (T --> 0) {
		scanf("%lld %d %d %d %d", &N, &A, &B, &C, &D);
		map<ll, ll>().swap(M);
		printf("%lld\n", solve(N));
	}
	return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ans[2];
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N, M;
  cin >> N >> M;

  vec< int > x(N), y(M);
  REP(i, N) { cin >> x[i]; }
  REP(i, M) { cin >> y[i]; }

  REPS(i, N - 1) {
    ans[0] += i * (N - i) * (x[i] - x[i - 1]);
    ans[0] %= MOD;
  }

  REPS(i, M - 1) {
    ans[1] += i * (M - i) * (y[i] - y[i - 1]);
    ans[1] %= MOD;
  }
  print((ans[0] * ans[1]) % MOD);
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    ll a[N];
    REP(i, N) cin >> a[i];
    ll cul[N+1] = {};
    REP(i, N){
        cul[i+1] = cul[i]+a[i];
    }
    ll mi = LLONG_MAX/3;
    for(int i=1;i<N;i++){
        mi = min(abs(2*cul[i] - cul[N]), mi);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int A, B;
  cin >> A >> B;
  
  if( A <= 0 && B >= 0 ){
    cout << "Zero" << endl;
    return 0;
  }
  
  if( A > 0 && B > 0 ){
    cout << "Positive" << endl;
    return 0;
  }
  
  if( A < 0 && B < 0 ){
    if( (abs(A-B)+1) % 2 == 0 ) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
    
    
    
}




Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,s,count=0;
    scanf("%d",&n);
    while(n>0)
    {
        s=n%10;
        if(s==7){
            count++;
          break;
        }
        n/=10;
    }
    if (count>0)
    printf("Yes\n");
    else
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1600
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n;cin>>n;
    while(n>=0){
        if(n%7==0){
            cout<<"Yes"<<endl;return 0;
        }else n-=4;
    }
    cout<<"No"<<endl;return 0;
}

Measured memory_bytes: 256
def main():
    S,T = map(str, input().split())
    A,B = map(int, input().split())
    U = str(input())
    if(U == S):
        res = str(A-1) + " " + str(B)
    elif(U == T):
        res = str(A) + " " + str(B-1)
    else:
        res = str(A) + " " + str(B)
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001



int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N+1,0);
	for(int i=1;i<=N;i++)cin>>A[i];
	
	int ok = 200001;
	int ng = 0;
	
	while(ok-ng>1){
		int mid = (ok+ng)/2;
		bool f = true;
		vector<pair<int,int>> now;
		for(int i=1;i<A.size();i++){
			if(A[i]>A[i-1]){
				now.emplace_back(0,A[i]-A[i-1]);
			}
			else{
				int t = A[i-1]-A[i];
				while(t!=0){
					if(now.back().second>t){
						now.back().second-=t;
						t=0;
						break;
					}
					else{
						t -= now.back().second;
						now.pop_back();
					}
				}
					
				long long S = 0;
				while(now.size()!=0&&now.back().first==mid-1){
					S += now.back().second;
					now.pop_back();
				}
				if(now.size()==0){
					f = false;
					break;
				}
				if(now.back().second!=1){
					now.back().second--;
					now.emplace_back(now.back().first,1);
				}
				now.back().first++;
				if(S!=0)now.emplace_back(0,S);
			
			
			}
			
		}
		
		
		
		
		if(f)ok = mid;
		else ng = mid;
	}
	
	cout<<ok<<endl;
	
	return 0;
}

Measured memory_bytes: 4692
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
 */

var re = /\s+|$/;
reader.on('close', () => {
    var l = lines[0].trim().split(re).map(Number);
    var n = l[0];
    
    aux(n);
});

function aux(n)
{
  var s='';
  for (var i=1; i<=n; i++){
    var x = i;
    if ( x % 3 == 0 ){
      s += " " + i.toString();
    } else {
      while (x > 0) {
	if ( x % 10 == 3 ){
	  s += " " + i.toString();
	  break;
	}
	x = Math.floor(x/10);
      }
    }

  }
  console.log(s);
}


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



int main(void)
{
    set<int> s;
    int n;
    cin >> n;

    for(int i = 0; i < n; i++)
    {
        int d;
        cin >> d;
        s.insert(d);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <utility>
using namespace std;

#define endl '\n'
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
typedef pair<int, int> ii;
typedef long long LL;
typedef long double LD;


int main(int argc, char *argv[]){
    int n;
    set<pair<int,int> > s;
    while(cin>>n){
        s.clear();
        for(int i=1;i<=n;i++){
            int f;
            cin>>f;
            s.insert(make_pair(i,f));
        }
        int res = 0;
        for(set<pair<int,int> >::iterator it = s.begin();it!=s.end();it++){
            pair<int,int> p;
            p.first = it->second; p.second = it->first;
            if(s.find(p)!=s.end()) res ++;
        }
        cout<<res/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 4992