akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define N_MAX 100

int main() {
    char b[10];
    cin >> b;

    if (b[0] == 'A') {
        cout << 'T' << endl;
    }
    else if (b[0] == 'T') {
        cout << 'A' << endl;
    }
    else if (b[0] == 'C') {
        cout << 'G' << endl;
    }
    else {
        cout << 'C' << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

from operator import itemgetter

AB.sort(key = itemgetter(1))

cost = 0

ans = 'Yes'
for a,b in AB:
    cost += a
    if cost > b:
        ans = 'No'
        break
print(ans)

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;
ll t;

ll ans = 0;

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &t);

  ll last;
  scanf("%lld", &last);

  for (int i = 1; i < n; ++i) {
    ll cur;
    scanf("%lld", &cur);
    ans += min(cur - last, t);
    last = cur;
  }

  ans += t;

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v)          ((v).begin()), ((v).end())
#define pb push_back
#define Compiler_Beso ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define clr(v,d)        memset(v, d, sizeof(v))
#define endl '\n'
typedef long long ll;


ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }


enum dir       { DOWN = 0, UP, RIGHT, LEFT, DOWN_RIGHT, DOWN_LEFT, UP_RIGHT, UP_LEFT };
int  dir_r[] = { 1, -1, 0, 0, 1, 1, -1, -1 };
int  dir_c[] = { 0, 0, 1, -1, 1, -1, 1, -1 };

int main()
{
    Compiler_Beso
    
    
    ll n;
    cin>>n;
    cout<<lcm(2,n);
    
    
    
    
    
    return 0;
}







Measured memory_bytes: 256
a,b=map(int,input().split())
store=[list(map(int,input().split())) for x in range(a)]
store.sort()
price=0
for x in store:
    if b>x[1]:
        b-=x[1]
        price+=x[1]*x[0]
    else:
        price+=b*x[0]
        break
print(price)


Measured memory_bytes: 27756
def p(b):
    for i in range(0,len(b)):
        if i==len(b)-1:
            print(b[i])
        else:
            print(b[i],' ',end="")

n=int(input())
a=[int(i) for i in input().split()]
b=[None]*n
if n%2==1:
    m=int(n/2)
    b[m]=a[0]
    s=1
    t=1
    while s+m<n:
        b[m+s]=a[t]
        t+=1
        b[m-s]=a[t]
        t+=1
        s+=1
    p(b)
else:
    m=int(n/2)
    b[m]=a[0]
    s=1
    t=1
    while s+m<=n:
        b[m-s]=a[t]
        t+=1
        if m-s==0:
            break
        b[m+s]=a[t]
        t+=1
        s+=1
    p(b)


Measured memory_bytes: 25748
x=gets.chomp.split(" ")
n=x[0].to_i
m=x[1].to_i
e=x[2].to_i

$N=n
$V=n+m
$G=Array.new($V).map{Array.new(0,0)}
$match=Array.new($V,-1);
$used=Array.new($V,false)

def add_edge(u,v)
    $G[u].push(v)
    $G[v].push(u)
end

def dfs(v)
    $used[v]=true
    for i in 0..$G[v].size-1
        u=$G[v][i]
        w=$match[u]
        if w<0 || !$used[w]&&dfs(w)==true
            $match[v]=u
            $match[u]=v
            return true
        end
    end
    return false 
end

def bipartite_matching()
    res=0
    $match.fill(-1,0..$V-1)
    for v in 0..$N-1
        if $match[v]<0
            $used.fill(false,0..$V-1)
            if dfs(v)==true
                res+=1
            end
        end
    end
    return res
end

for i in 1..e
    x=gets.chomp.split(" ")
    u=x[0].to_i
    v=x[1].to_i+n
    add_edge(u,v)
end
puts bipartite_matching()


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= k;
    }
    vector<ll> sum(n+1);
    for(int i = 0; i < n; i++) sum[i+1] = sum[i] + a[i];
    vector<ll> b(n+1);
    for(int i = 0; i <= n; i++) {
        b[i] = (sum[i]-i+100000*k) % k;
    }
    map<ll, int> mp;
    queue<int> q;
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
        ans += mp[b[i]];
        mp[b[i]]++;
        q.push(b[i]);
        while(q.size()>=k) {
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 17536
n = int(input())
from collections import defaultdict as dd
dic = dd(lambda: 0)

counter = 0
for i in range(n):
  s = input()
  s_s = sorted(s)
  s_s_s = "".join(s_s)
  counter += dic[s_s_s]
  dic[s_s_s] += 1

print(counter)

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

using namespace std;

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

char s[25][25];
int dist[25][25];
bool flag[25][25];
int h, w;

int solve(int x, int y) {
    int mx = 0;
    memset(flag, 0, sizeof(flag));
    flag[x][y] = 1;
    dist[x][y] = 0;
    queue <pair<int, int> > que;
    que.push(make_pair(x, y));

    while(que.size()) {
        pair <int, int> now = que.front();
        mx = max(mx, dist[now.first][now.second]);
        que.pop();

        for (int i = 0; i < 4; i++) {
            int nx = now.first + dx[i];
            int ny = now.second + dy[i];

            if (nx < 0 || nx >= h || ny < 0 || ny >= w || flag[nx][ny] || s[nx][ny] == '#') continue;
            dist[nx][ny] = dist[now.first][now.second] + 1;
            flag[nx][ny] = 1;
            que.push(make_pair(nx, ny));
        }
    }
    return mx;
}

int main() {
    scanf("%d%d", &h, &w);

    for (int i = 0; i < h; i++) scanf("%s", s[i]);

    int res = 0;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') continue;
            res = max(res, solve(i, j));
        }
    }

    printf("%d\n", res);
}


Measured memory_bytes: 3740
#include <iostream>
#include <map>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

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

	while (N!=0) {
		int max_w = 0;
		int max_h = 0;
		int min_w = 0;
		int min_h = 0;
		int n,d;
		std::map< int, std::vector<int> > coor;
		std::vector<int> temp(2);
		temp[0] = 0;
		temp[1] = 0;
		coor[0] = temp;
		for (int i = 1; i < N; i++) {
			cin >> n; 
			cin >> d; 
			if (d == 0) {
				temp[0] = coor[n][0] - 1;
				temp[1] = coor[n][1];
				if (temp[0] < min_w) {
					min_w = temp[0];
				}
				coor[i] = temp;
			}
			if (d == 1) {
				temp[0] = coor[n][0];
				temp[1] = coor[n][1] - 1;
				if (temp[1] < min_h) {
					min_h = temp[1];
				}
				coor[i] = temp;
			}
			if (d == 2) {
				temp[0] = coor[n][0] + 1;
				temp[1] = coor[n][1];
				if (temp[0] > max_w) {
					max_w = temp[0];
				}
				coor[i] = temp;
			}
			if (d == 3) {
				temp[0] = coor[n][0];
				temp[1] = coor[n][1] + 1;
				if (temp[1] > max_h) {
					max_h = temp[1];
				}
				coor[i] = temp;
			}
		}

		cout << max_w-min_w+1 << " " << max_h-min_h+1 << endl;
		cin >> N;
	}

	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    // グラフ
    vector<int> d(N);
    for(int i = 1; i <= N; ++i) {
        for(int j = 1 + i; j <= N; ++j) {
            ll tmp = min(j - i, abs(X - i) + abs(Y - j) + 1);
            d[tmp]++;
        }
    }
    
    for(int i = 1; i < N; ++i) {
        cout << d[i] << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
int seq[200005];
std::vector<int> combine(std::vector<int> &a, std::vector<int> &b)
{
	std::vector<int> res;
	for (int i = 0; i < a.size(); i++)
	{
		if (i & 1)
			res.push_back(b[i]);
		res.push_back(a[i]);
		if (i & 1 ^ 1)
			res.push_back(b[i]);
	}
	return res;
}
int main()
{
	// freopen("AGC031-C.in", "r", stdin);
	int n, s, t, len = 0;
	scanf("%d%d%d", &n, &s, &t);
	t ^= s;
	for (int i = 0; i < n; i++)
	{
		if (t & (1 << i))
			seq[len++] = i;
	}
	if (len & 1 ^ 1)
	{
		puts("NO");
		return 0;
	}
	std::vector<int> vec = {0, 1 << seq[0]};
	for (int i = 1; i < len; i += 2)
	{
		auto vec_00 = vec, vec_01 = vec, vec_11 = vec, vec_10 = vec;
		for (int &x : vec_01)
			x ^= 1 << seq[i];
		for (int &x : vec_11)
			x ^= (1 << seq[i]) ^ (1 << seq[i + 1]);
		for (int &x : vec_10)
			x ^= 1 << seq[i + 1];
		vec = combine(vec_00, vec_01);
		std::reverse(vec_10.begin(), vec_10.end());
		vec.insert(vec.end(), vec_10.begin(), vec_10.end());
		vec.insert(vec.end(), vec_11.begin(), vec_11.end());
	}
	for (int i = 0; i < n; i++)
	{
		if (!(t & (1 << i)))
		{
			auto vec_1 = vec;
			for (int &x : vec_1)
				x ^= 1 << i;
			vec = combine(vec, vec_1);
		}
	}
	puts("YES");
	for (int i = 0; i < 1 << n; i++)
		printf("%d%c", vec[i] ^ s, " \n"[i + 1 == 1 << n]);
	return 0;
}


Measured memory_bytes: 1904
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<vector<ll>> a(200, vector<ll>(200));
	string s[n];
	pair<int, int> t[n];
	rep(i, n) {
		cin >> s[i];
		ll p = 0, q = 0;
		for (auto c : s[i]) {
			if (c == '.') {
				q++;
			} else {
				p = p * 10 + (c - '0');
				if (q) q++;
			}
		}
		int u = 0, v = 0;
		while (p % 2 == 0) {
			u++;
			p /= 2;
		}
		while (p % 5 == 0) {
			v++;
			p /= 5;
		}
		if (q) q--;
		a[q - u + 100][q - v + 100]++;
		t[i] = {u - q, v - q};
	}
	rep(i, 200) rep(j, 199) a[i][j + 1] += a[i][j];
	rep(i, 199) rep(j, 200) a[i + 1][j] += a[i][j];
	ll ans = 0;
	rep(i, n) {
		ans += a[t[i].first + 100][t[i].second + 100];
		if (t[i].first >= 0 and t[i].second >= 0) ans--;
	}
	cout << ans / 2 << endl;
	return 0;
}

Measured memory_bytes: 11572
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define inin(x) int x; cin>>x;
#define ll long long

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

vector<int> d, c;
int n, m;
int memo[1001][1001];
long long dp(int now, int day)
{
	if (memo[now][day] != -1)return memo[now][day];
	if (now == n)return 0;
	if (day == m)return INT_MAX;
	long long ans = 0;
	ans = min(dp(now + 1, day + 1) + d[now] * c[day], dp(now, day + 1));
	return memo[now][day] = ans;
}

int main()
{
	cin >> n >> m;
	memset(memo, -1, sizeof memo);
	rep(i, n)
	{
		inin(x)d.push_back(x);
	}

	rep(i, m)
	{
		inin(x)c.push_back(x);
	}

	cout << dp(0, 0) << endl;



}

Measured memory_bytes: 5200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll,ll> pll;
const int INF = 1000000000;
const int maxN = 1010;
const int MOD = 100003;

int **c;
int **s;
int u[maxN];
char a[maxN];
char b[maxN];
int main()
{
	scanf("%s",a);
	int len = strlen(a);
	int flag = 0;
	int p = 0;   //仍旧有不同的
	for(int i=0;i<len;i++)
	{
		u[a[i]]++;
	}
	for(int i=0;i<len-1;i++)
	{
		if(a[i] != a[i+1])
			p = 1;
	}
	if(!p)
	{
		printf("0\n");
		return 0;
	}
	int cnt = INF;
	for(int i=97;i<=122;i++)
	{
		if(u[i] != 0)
			flag = i;
		else
			continue;
		for(int j=0;j<len;j++)
			b[j] = a[j];
		int N = len-1;
		int ans = 0;
		while(1)
		{
			ans++;
			p=0;
			for(int i=0;i<N;i++)
			{
				if(b[i+1] == flag)
					b[i] = flag;
			}
			N--;
			for(int i=0;i<N;i++)
			{
				if(b[i]!=b[i+1])
					p=1;
			}
			if(p==0)
				break;
		}
		cnt = min(cnt,ans);
	}
	printf("%d\n",cnt);
	return 0;
} 


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Long> a = new ArrayList<>();
    ArrayList<Long> b = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      a.add(sc.nextLong());
      b.add(sc.nextLong());
    }
    List<Long> sortedA = a.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
    List<Long> sortedB = b.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
    if (n % 2 == 0) {
      double minD = ((double) (sortedA.get(n / 2 - 1) + sortedA.get(n / 2))) / 2;
      double maxD = ((double) (sortedB.get(n / 2 - 1) + sortedB.get(n / 2))) / 2;
      System.out.println((long) (2 * (maxD - minD) + 1));
    } else {
      long minD = sortedA.get((n + 1) / 2 - 1);
      long maxD = sortedB.get((n + 1) / 2 - 1);
      System.out.println(maxD - minD + 1);
    }
  }
}


Measured memory_bytes: 66964
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	vector<int>vec(3);
	rep(i, 0, 3)cin >> vec[i];
	sort(all(vec));
	int ans = vec[2] - vec[1];
	vec[0] += ans;
	ans += (vec[2] - vec[0]) / 2;
	if ((vec[2] - vec[0]) % 2 == 1) {
		ans += 2;
	}
	cout << ans << "\n";

	return 0;
}

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

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


	ll n;
	cin >> n;
	ll sum1 = 0, sum2 = 0;
	for (ll i = 1; i <= n; i++) {
		sum1 += (i * (i + 1)) / 2;
	}
	//cout << sum1 << endl;
	for (ll i = 0; i < n - 1; i++) {
		ll a, b;
		cin >> a >> b;
		ll u = min(a, b), v = max(a, b);
		sum2 += u * (n - v + 1);
	}
	//cout << sum2 << endl;
	ll ans = (sum1 - sum2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2199&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int N,M;
ll solve(){
    vector<ll> C(M),x(N);
    for(auto& in:C) cin >> in;
    for(auto& in:x) cin >> in;
    vector<vector<ll>> dp(N+1,vector<ll>(256,LINF));
    dp[0][128] = 0;
    for(int i = 0; i < N;i++){
        for(int j = 0; j < 256;j++){
            if(dp[i][j] == LINF) continue;
            for(int k = 0; k < M;k++){
                ll y = j + C[k];
                y = max(0LL,y); y = min(255LL,y);
                dp[i+1][y] = min(dp[i+1][y],dp[i][j] + (ll)pow(y-x[i],2));
            }
        }
    }
    return *min_element(dp[N].begin(),dp[N].end());
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> N >> M,N|M){
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 43964
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define for1(i, m, n) for (int i = m; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int tmp = i;
        if (tmp % 3 == 0) {
            cout << " " << tmp;
        } else {
            while(tmp != 0) {
                if (tmp % 10 == 3 ){
                    cout << " " << i;
                    break;
                } else {
                    tmp /= 10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3160
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  scanf("%d",&n);
  for  (int i = 1 ; i <= 9; i++ )
    for  (int j = 1 ; j <= 9; j++ )
        if ( i*j == n ) return cout <<"Yes" , 0;
    cout <<"No";
return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
  int d,n; cin >> d >> n;
  if(d == 0){
     if(n == 100)print(101);
     else print(n);
  }
  if(d == 1){
     if(n == 100)print(10100);
     else print(n * 100);
  }
  if(d == 2){
     if(n == 100)print(1010000);
     else print(n * 10000);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int N, K;
    int min=1000000001;
    
    cin >> N >> K;
    
    int h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h,h+N);
    for(int i=0;i<N-K+1;i++){
        if(h[i+K-1]-h[i]<min){
            min = h[i+K-1] - h[i];
        }
    }
    
    cout << min << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  long long p = 1, mod = 1000000007;
  for(int i = 1; i <= n; i++){
    p *= i;
    p %= mod;
  }
  cout << p << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;cin>>a>>b;
    if(a==1&&b==1){
        cout<<2<<" "<<2<<endl;
        cout<<"##"<<endl;
        cout<<".."<<endl;
        return 0;
    }
    char c[100][100];
    rep(i,0,100)rep(j,0,100)c[i][j]='?';
    int v=max(a,b);
    int w=min(a,b);
    int now=0;
    int jud=0;
    for(int i=0;i<100;i+=4){
        for(int j=0;j<100;j+=4){
            now++;
            if(now==v){
                jud=1;
                break;
            }
            for(int k=i;k<i+4;k++){
                for(int l=j;l<j+4;l++){
                    if(k%4==3||l%4==3)c[k][l]='#';
                    else c[k][l]='.';
                }
            }
            if(now<w)c[i+1][j+1]='#';
        }
        if(jud==1)break;
    }
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++)if(c[i][j]=='?')c[i][j]='.';
    }
    if(b>a){
        rep(i,0,100){
            rep(j,0,100){
            if(c[i][j]=='.')c[i][j]='#';
            else c[i][j]='.';
        }
        }
    }
    cout<<100<<" "<<100<<endl;
    rep(i,0,100){
        rep(j,0,100)cout<<c[i][j];
        cout<<endl;
    }
}


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


int main(){
	  ll l,r;
		cin>>l>>r;
    ll ans=2019,mod=2019;
    if(l+mod<=r) cout<<0<<endl;
    else if(l%mod>=r%mod) cout<<0<<endl;
    else {
      for(int j=l%mod;j<r%mod;j++){
      for(int i=j+1;i<=r%mod;i++){
        if((j*i)%mod<ans) ans=(j*i)%mod;
      }
      }

    cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll x=0,y=0,w=0,z=0;
  w(t)
  {
    string s;
    cin>>s;
    if(s=="AC")
    x++;
    if(s=="WA")
    y++;
    if(s=="TLE")
    w++;
    if(s=="RE")
    z++;
  }
  cout<<"AC x "<<x<<kk;
    cout<<"WA x "<<y<<kk;
    cout<<"TLE x "<<w<<kk;
    cout<<"RE x "<<z<<kk;
  return 0;
}

Measured memory_bytes: 3656
dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

INF = 10**9
dst = [[INF]*W for _ in range(H)]
dst[sh][sw] = 0

from collections import deque
dq = deque([(sh, sw)])
while dq:
    h, w = dq.popleft()

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] < dst[nh][nw]:
            dst[nh][nw] = dst[h][w]
            dq.appendleft((nh, nw))

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] + 1 < dst[nh][nw]:
            dst[nh][nw] = dst[h][w] + 1
            dq.append((nh, nw))

print(-1 if dst[eh][ew]==INF else dst[eh][ew])


Measured memory_bytes: 88764
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   int n,m;
   cin>> n >> m;
   vector<int> wa(n,0);
   vector<bool> isac(n,true);

   rep(i,m)
   {
      int foo;string hoge;
      cin >> foo >> hoge;
      if(hoge=="AC")isac[foo-1]=false;
      if(isac[foo-1]&&hoge=="WA")wa[foo-1]++;
   }
   int ans=0,anss=0;
   rep(i,n)
   {
      if(isac[i]==false)ans+=wa[i];
      if(isac[i]==false)anss++;
   }
   cout<<anss<<' '<<ans<<endl;
   return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<map>
using namespace std;
int n,k;
vector<int> v[2005];
typedef pair<int,int> P;
int solve(int x){
  int s=0;
  queue<P> q;
  P p;
  q.push(P(x,0));
  bool used[2005]={};
  while(!q.empty()){
    p=q.front();q.pop();
    x=p.first;
    if(used[x]) continue;
    used[x]=true;
    if(p.second>k/2) s++;
    for(int i=0;i<v[x].size();i++) q.push(P(v[x][i],p.second+1));
  }
  return s;
}
int calc(int x,int y){
  int s=0;
  queue<P> q;
  P p;
  q.push(P(x,0));
  q.push(P(y,0));
  bool used[2005]={};
  while(!q.empty()){
    p=q.front();q.pop();
    x=p.first;
    if(used[x]) continue;
    used[x]=true;
    if(p.second>(k-1)/2) s++;
    for(int i=0;i<v[x].size();i++) q.push(P(v[x][i],p.second+1));
  }
  return s;
}
int main(){
  cin >> n >> k;
  int i,j,a,b;
  bool p[2005]={};
  for(i=0;i<n-1;i++){
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    p[b]=false;
  }
  int ans=n;
  if(k%2==0){
    for(i=1;i<=n;i++){
      ans=min(ans,solve(i));
      //cout << solve(i) << endl;
    }
  }else{
    for(i=1;i<=n;i++){
      for(j=0;j<v[i].size();j++){
	ans=min(ans,calc(i,v[i][j]));
	//cout << solve(i) << endl;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int N,flag=0;
    scanf("%d",&N);
    for(int i=0;i<3;i++){
        if(N%10==7){
            flag++;
            printf("Yes");
            break;
        }
        N = N/10;
    }
    if(flag==0){
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1704
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
/*----------------------------------------------------------------------------------*/

ll dp[110][100010];

int main() {
    int N; cin >> N;
    int W; cin >> W;
    vector<int> w(N), v(N);
    rep(i,N) cin >> w[i] >> v[i];

    memset(dp, 0, sizeof(dp));

    rep(i,N) rep(j,W+1) {
        if (j+w[i]<=W) chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
        chmax(dp[i+1][j], dp[i][j]);
    }

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

    return 0;
}


Measured memory_bytes: 86144
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#N = int(input())
L = list(map(int, input().split()))
K = int(input())
L.sort(reverse=True)

sum = L[0]
for _ in range(K) :
  sum *= 2
sum += L[1]
sum += L[2]

print (sum)

Measured memory_bytes: 38384
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
         
        int d = a / b;
        int r = a % b;
        double f = 1.0 * a / b;
         
        System.out.printf("%d %d %f",a/b,a%b,(double)a/b);
    }
}

Measured memory_bytes: 17364
import sys
from operator import itemgetter
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())
    ab_list = [tuple(map(int, input().split())) for _ in range(m)]
    ab_list.sort(key = itemgetter(1))
    del_max = -10
    ans = 0
    for ab in ab_list:
        if ab[0] - 1 > del_max:
            ans += 1
            del_max = ab[1] - 2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 56924
n,k = list(map(int,input().split()))
ans=0
s1=0
s2=0

for i in range(k-1):
    s1+=i
    s2+=n-i
#print(s1,s2)

for i in range(k,n+2):
    s1+=i-1
    s2+=n-i+1
    ans += s2-s1+1
    #print(s1,s2, ans)
    ans = ans%(10**9+7)
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int n,m; ll k;
char f[2005][1005];
int main(){
	scanf("%d%d",&n,&m); cin>>k;
	if(k<=1){ puts("1"); return 0;}
	for(int i=0;i<n;i++) scanf("%s",&f[i]);
	bool tate=0,yoko=0;
	for(int i=0;i<n;i++){
		if(f[i][0]=='#' && f[i][m-1]=='#'){
			yoko = 1;
		}
	}
	for(int i=0;i<m;i++){
		if(f[0][i]=='#' && f[n-1][i]=='#'){
			tate = 1;
		}
	}
	if(yoko&&tate){
		puts("1"); return 0;
	}//cout<<"N"<<endl;
	if(!yoko&&!tate){
		ll ans = 0;
		for(int i=0;i<n;i++) for(int j=0;j<m;j++) ans+=f[i][j]=='#';
		cout<<modpow(ans,k-1)<<endl; return 0;
	}
	if(yoko){
		ll val = 0,c = 0,val2 = 0;
		for(int i=0;i<n;i++){
			if(f[i][0]=='#'&&f[i][m-1]=='#') val2++;
			for(int j=0;j<m-1;j++){
				if(f[i][j]=='#' && f[i][j+1]=='#'){
					val++;
				}
			}
			for(int j=0;j<m;j++) c+=f[i][j]=='#';
		}
		ll ans = modpow(c,k-1);
		ll x = val2 * modpow(c,k-2)%mod;
		ll y = val2 * modpow(c,mod-2) % mod;
		//x+...x*y^(k-2)
		ll z;
		if(y==1) z = k-1;
		else z = (modpow(y,k-1)-1)*modpow(y-1,mod-2)%mod;
		z = z*val%mod*modpow(val2,mod-2)%mod;
		cout<<(ans-x*z%mod+mod)%mod<<endl;
	}
	else{
		ll val = 0,c = 0,val2 = 0;
		for(int j=0;j<m;j++){
			if(f[0][j]=='#'&&f[n-1][j]=='#') val2++;
			for(int i=0;i<n-1;i++){
				if(f[i][j]=='#' && f[i+1][j]=='#'){
					val++;
				}
			}
			for(int i=0;i<n;i++) c+=f[i][j]=='#';
		}
		ll ans = modpow(c,k-1);
		ll x = val2 * modpow(c,k-2)%mod;
		ll y = val2 * modpow(c,mod-2) % mod;
		//x+...x*y^(k-2)
		ll z;
		if(y==1) z = k-1;
		else z = (modpow(y,k-1)-1)*modpow(y-1,mod-2)%mod;
		z = z*val%mod*modpow(val2,mod-2)%mod;
		cout<<(ans-x*z%mod+mod)%mod<<endl;
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;

  if (a + b - n >= 0)
    cout << min(a, b) << ' ' << a + b - n << endl;
  else
    cout << min(a, b) << ' ' << 0 << endl;

  return 0;
}


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

using namespace std ;
#define pi 3.1415926535897932384626433832795
int main ()  { 
	
ios_base::sync_with_stdio(false) ; 
cin.tie(NULL) ; 
cout.tie(NULL) ;

int n ; 
cin >> n ; 
int arr[300000] ;  
for( int i = 1;  i < n ; i++ )  {
	int x; 
	cin >> x; 
	arr[x]++ ; 
}

for( int i = 1 ; i <= n ; i++ ) 
	cout << arr[i] << endl; 


}


Measured memory_bytes: 4428
numsArray = Array.new
numsArray[0] = 0
i = 1
 
loop {
    numsArray[i] = gets.to_i
    if numsArray[i] == 0
        break
    end
     
    i += 1
}
 
i -= 1
caseNumber = 1
 
i.times do
    print "Case ", caseNumber, ": ", numsArray[caseNumber], "\n"
    caseNumber += 1
end

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 100000 + 200;
bool dp[MAX_N];


int main2() {
  CLR(dp, 0);
  int X = nextInt();

  dp[0] = true;

  for (int i = 0; i <= 5; i++) {
    int a = 100 + i;
    for (int x = 0; x <= X; x++) {
      if (dp[x]) {
        dp[x + a] = true;
      }
    }
  }

  cout << (dp[X]?1:0) << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int n,x,t;cin>>n>>x>>t;
    cout<<(n+x-1)/x*t<<endl;
}

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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define INF 1e9

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 2e5+2;
const int M = 1e9+7;

int main()
{
    _upgrade;
    ll x;
    cin>>x;

    for(ll i = 1; i<=200; ++i)
        for(ll p = -200; p < i; ++p)
        if(pow(i, 5) - pow(p, 5) == x)
        {
            cout<<i<<" "<<p;
            return 0;
        }
}


Measured memory_bytes: 4076
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, ans = 1;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(all(a));
	rep(i,n-1){
		if(a[i+1]>a[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
# Initialize

MIN = N
lb = 0
rw = 0
for i in range(N):
	rw += 1 if S[i] == "." else 0

for i in range(N):
	MIN = min(lb+rw,MIN)
	lb += 1 if S[i] == "#" else 0
	rw -= 1 if S[i] == "." else 0
# Finalize
MIN = min(lb,MIN)
print(MIN)



Measured memory_bytes: 3500
#include <cstdio>

using namespace std;

const int N = 1e5 + 500;

int n, a[N], b[N], p[N];

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= n;i++){
		scanf("%d", p + i);	
		a[p[i]] = 2 * i;
		b[p[i]] = n + 1 - i;
	}
	for(int i = 1;i <= n;i++)
		a[i] = (n + 1) * i;
	for(int i = 1;i <= n;i++)
		b[p[i]] = (n + 1) * (n + 1) - (a[p[i]] + n + 1 - i);
	for(int i = 1;i <= n;i++)
		printf("%d ", a[i]); 
	printf("\n");
	for(int i = 1;i <= n;i++)
		printf("%d ", b[i]); 
	printf("\n");
	
}

Measured memory_bytes: 768
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
void printString(long long int n) 
{ 
    char str[100000]; // To store result (Excel column name) 
    long long int i = 0; // To store current index in str which is result 
  
    while (n > 0) { 
        // Find remainder 
        long long int rem = n % 26; 
  
        // If remainder is 0, then a 'Z' must be there in output 
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else // If remainder is non-zero 
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    // Reverse the string and print result 
    reverse(str, str + strlen(str)); 
    cout << str << endl; 
  
    return; 
} 
int main(){
  long long int n;
  cin>>n;
  printString(n);
  
}

Measured memory_bytes: 3644
#include <stdio.h>
int main(void){
    char a[4];
    int i;
    scanf("%s",a);
    
    for(i=0;i<3;i++){
    if(a[i]=='1'){
        a[i]=a[i]+8;
    }else if(a[i]=='9'){
        a[i]=a[i]-8;
    }
    }
   printf("%s",a);

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
using namespace std;

int iszero(int a[], int n)
{
    for (int i = 1; i < n; i++)
    {
        if(a[i] != 0)
        {
            return i;
        }
    }
    return -1;
}

int main()
{
    int n;
    cin >> n;
    int h[n+2];
    h[0] = 0;
    h[n+1] = 0;
    for (int i = 1; i < n+1; i++)
    {
        cin >> h[i];
    }
    int tmp;
    int ans = 0;
    while((tmp = iszero(h,n+2)) != -1)
    {
        tmp--;
        for (int i = tmp+1; i < n+2; i++)
        {
            if(h[i] == 0)
            {
                for (int k = tmp+1; k <= i-1; k++)
                {
                    h[k]--;
                }
                if(i-tmp > 1) ans++;
                tmp = i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define N 3020
#define MOD 998244353
using namespace std;

int a[N];
int f[N];

int main(void)
{
    int n, s;
    int i, j, o;

    scanf("%d %d", &n, &s);
    for(i = 1; i <= n; i ++)
        scanf("%d", &a[i]);

    f[0] = 1;
    for(i = 1, o = 0; i <= n; i ++)
    {
        for(j = s; j >= a[i]; j --)
            f[j] = (f[j] + f[j - a[i]]) % MOD;
        f[0] = (f[0] + 1) % MOD;
        o = (o + f[s]) % MOD;
        // memset(g, 0, sizeof(int) * (s + 1));
        // for(j)
    }
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3005, MOD = 1e9 + 7;

int n, m, r[N], rightend[N], cnt1[N], f[N][N];
string s;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> m >> s;
  int curl, curr;
  cin >> curl >> curr;
  for (int i = 2, nxl, nxr; i <= m; ++i) {
    cin >> nxl >> nxr;
    if (nxl == curl) curr = max(curr, nxr);
    else if (nxr > curr) {
      r[curl] = curr;
      curl = nxl;
      curr = nxr;
    }
  }
  r[curl] = curr;
  for (int i = 1; i <= n; ++i) {
    cnt1[i] = cnt1[i - 1] + (s[i - 1] == '1');
    rightend[i] = max(rightend[i - 1], r[i - 1]);
    r[i] = max({rightend[i], r[i], i});
  }
  f[0][0] = 1;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (f[i][j] == 0) continue;
      int one = j + ((rightend[i] < r[i]) ? (cnt1[r[i]] - cnt1[rightend[i]]) : 0);
      if (one) (f[i + 1][one - 1] += f[i][j]) %= MOD;
      if (r[i] - i + 1 > one) (f[i + 1][one] += f[i][j]) %= MOD;
    }
  }
  cout << f[n + 1][0];
  return 0;
}

Measured memory_bytes: 33920
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
int N;
string input[10];
string dp[1 << 10][10];
int cover[10][10];

string solve(const vector<string>& names) {
	int n = names.size();
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) continue;
			cover[i][j] = 0;
			for (int k = min(names[i].size(), names[j].size()); k > 0; --k) {
				if (names[i].substr(names[i].size() - k) == names[j].substr(0, k)) {
					cover[i][j] = k;
					break;
				}
			}
		}
	}
	for (int i = 0; i < (1 << n); ++i) {
		fill(&dp[i][0], &dp[i][n], string());
	}
	for (int i = 0; i < n; ++i) {
		dp[1 << i][i] = names[i];
	}
	for (int i = 1; i < (1 << n); ++i) {
		for (int j = 0; j < n; ++j) {
			if (dp[i][j].empty()) continue;
			for (int k = 0; k < n; ++k) {
				if (i & (1 << k)) continue;
				string& cur = dp[i|(1<<k)][k];
				string next = dp[i][j] + names[k].substr(cover[j][k]);
				if (cur.empty()
					 	|| cur.size() > next.size()
					 	|| cur.size() == next.size() && cur > next) {
					cur = next;
				}
			}
		}
	}
	string ret = "";
	for (int i = 0; i < 100; ++i) ret += "z";
	for (int i = 0; i < n; ++i) {
		string& cur = dp[(1 << n) - 1][i];
		if (ret.size() > cur.size() || ret.size() == cur.size() && ret > cur) ret = cur;
	}
	return ret;
}

int main() {
	while (true) {
		cin >> N;
		if (N == 0) break;
		for (int i = 0; i < N; ++i) {
			cin >> input[i];
		}
		vector<string> names;
		for (int i = 0; i < N; ++i) {
			bool contains = false;
			for (int j = 0; j < N; ++j) {
				if (j == i) continue;
				if (input[i].size() < input[j].size() && input[j].find(input[i]) != string::npos) {
					contains = true;
					break;
				}
			}
			if (!contains) names.push_back(input[i]);
		}
		cout << solve(names) << endl;
	}
}

Measured memory_bytes: 1696
long long i,j,e,t,w=1ll<<50,u,x[1<<17],y[1<<17];int main(n){scanf("%d%lld%lld",&n,&e,&t);for(x[n]=2*e;i<n;){scanf("%lld",&x[i]);x[i++]*=2;}for(i=0;i<n;){for(;j<i&&t<x[i]-x[j];){u=y[j]+x[i]-x[j++];w=w<u?w:u;}u=x[i]-x[j];u=y[j]+(u<t?t:u);y[i+1]=w<u?w:u;w+=(x[i+1]-x[i++]);}printf("%lld\n",y[n]+e);return 0;}

Measured memory_bytes: 1792
def dfs(i,s,res):
    if i==3:
        if res == 7:
            print(s+"=7")
            exit()
        return
 
    dfs(i+1,s+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,s+'-'+S[i+1],res-int(S[i+1]))
 
S=input()
dfs(0,S[0],int(S[0]))

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1e5+10;
ll X[maxn];
ll n,a,b;
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i=1;i<=n;i++)
        scanf("%lld",&X[i]);
    ll ans=0;
    for(int i=2;i<=n;i++)
    {
        ans+=min((X[i]-X[i-1])*a,b);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoderBeginnerContest.ABC117
{
    class A
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var input = s.Split(' ');
            var T = int.Parse(input[0]);
            var X = int.Parse(input[1]);
            Console.WriteLine((((double)T) / ((double)X)).ToString());
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N>>M;
  vector<int> X(M*2);
  for (int i=0; i< 2*M; i++){
    cin>> X.at(i);
  }
  for (int j=0; j<N; j++){
    int a=0;
    for (int i=0; i< 2*M; i++){
      if (X.at(i) == j+1)
        a++;
    }
  cout << a << endl;
  }
}
   

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

int main(){
	int N;
	cin >> N;
	string s;
	cin >> s;
	int r = 0;
	int b = 0;
	for (int i = 0; i < N; i++){
		if (s[i] == 'R'){
			r++;
		}
		else{
			b++;
		}
	}
	if (r > b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;


}

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

const int MOD = (int)1e9+7;

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  int ans=A.at(0);
  for(int i=0;i<N;i++){
    ans=gcd(ans,A.at(i));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto nh = readln.chomp.split.to!(int[]);
  auto n = nh[0];
  auto h = nh[1];
  auto b = new int[](n);
  int amax;
  foreach (i; 0..n) {
    auto ab = readln.chomp.split.to!(int[]);
    b[i] = ab[1];
    amax = max(ab[0], amax);
  }
  int bsum;
  int cnt;
  b = b.sort!("b < a").array;

  foreach (i; 0..n) {
    if (b[i] > amax) {
      bsum += b[i];
      cnt++;
      if (bsum >= h) {
        break;
      }
    }
  }
  h -= bsum;
  if (h < 0) {
    h = 0;
  }
  cnt += h / amax;
  if (h % amax) {
    cnt++;
  }
  cnt.writeln;
}


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

int a[]{ 4,6,9,11 };
int f(int x) {
	if (x == 2)return 0;
	if (find(a, a + 4, x) != a + 4)return 1;
	return 2;
}
int main() {
	int x, y; scanf("%d%d", &x, &y);
	puts(f(x) == f(y) ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	ll N;
	vector<ll>V;
	cin >> N;
	V.push_back(2);
	V.push_back(1);
	if(N==1){
		cout << "1" << endl;
	}
	else{
		for(int i=1;i<N;i++){
			ll t;
			t=V[i-1]+V[i];
			V.push_back(t);
		}
		cout << *(V.end()-1) << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main(){
    int N=0;
    scanf("%d",&N);
    char str[N+1];
    scanf("%s",str);
    long count = 0;
    long b=0;
    for(int i = 0;i < N;i++) if(str[i] == 'B') b++;
    for(int i = 0;i < N;i++){
        for(int k = i+1;k < N;k++){
            if((str[i] == 'R' && str[k] == 'G') || (str[i] == 'G' && str[k] == 'R')){
                if( (2*k-i)<N && str[2*k-i]=='B' )count--;//RGB,GRB
                if( str[(i+k)/2]=='B' && (i+k)%2==0 )count--;//RBG,GBR
                if( (2*i-k)>=0 && str[(2*i-k)]=='B' )count--;//BRG,BGR
                count+=b;
            }
        }
    }
    printf("%ld\n",count);
    return 0;
}

Measured memory_bytes: 1728