akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[1002],b[1002],c[1002];
	while(cin>>a>>b>>c)
	{
		int la=strlen(a);
		int lb=strlen(b);
		int lc=strlen(c);
		int tmp=1;
		int a1=-1;
		int b1=-1;
		int c1=-1;
		while(true)
		{
			if(a1==la)
			{
				cout<<"A"<<endl;
				break;
			}
			if(b1==lb){
				cout<<"B"<<endl;
				break;
			}
			if(c1==lc){
				cout<<"C"<<endl;
				break;
			}
			 if(tmp==1)
            {
                a1++;
                tmp=a[a1]-'a'+1;
            }
            else if(tmp==2)
            {
                b1++;
                tmp=b[b1]-'a'+1;
            }
            else if(tmp==3)
            {
                c1++;
                tmp=c[c1]-'a'+1;
            }
		}
	}
	return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int n;
Tuple! (int, int) [] u;
Tuple! (int, int) [] v;
int [] a;
int [] girls;
bool [] w;

bool go (int k) {
  if (w[k]) {
    return false;
  }
  w[k] = true;
  foreach (i; 0 .. n) {
    if (u[k][0] < v[i][0] && u[k][1] < v[i][1]) {
      if (girls[i] < 0 || go (girls[i])) {
        girls[i] = k;
        return true;
      }
    }
  }
  return false;
}

void main() {
  readf (" %d", &n);
  u = new Tuple! (int, int) [n];
  v = new Tuple! (int, int) [n];
  foreach (i; 0 .. n) {
    int x, y;
    readf (" %d %d", &x, &y);
    u[i] = tuple (x, y);
  }
  foreach (i; 0 .. n) {
    int x, y;
    readf (" %d %d", &x, &y);
    v[i] = tuple (x, y);
  }
  girls = new int[n];
  foreach (i; 0 .. n) {
    girls[i] = -1;
  }
  int res = 0;
  foreach (i; 0 .. n) {
    w = new bool[n];
    if (go (i)) {
      res++;
    }
  }
  writeln (res);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int k, x;
    cin >> k >> x;
    
    rep (i, max(x-k+1, -1000000), min(x+k, 1000001))
        cout << i << " " << flush;
    
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define WRAP(y,x,h,w) (0<=y && y<h && 0<=x && x<w)

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	while (1) {
		if (cnt > 200) {
			cnt=-1;
			break;
		}
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
			break;
		}
		ll sum[3] = { 0 };
		sum[0]=b/2+c/2;
		sum[1] = a / 2 + c / 2;
		sum[2] = b / 2 + a / 2;
		a = sum[0];
		b = sum[1];
		c = sum[2];
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
def c_dubious_document(N, S):
    from collections import defaultdict, Counter
    # 各文字列の中に共通した文字はあるか？
    d = [None for _ in range(N)]  # i番は文字列Siに出現する文字の一覧と個数
    for i, s in enumerate(S):
        d[i] = Counter(s)

    common = defaultdict(str)  # 文字列の中で共通する文字の一覧と個数
    for c in range(ord('a'), ord('z') + 1):
        c = chr(c)
        low = float('inf')
        for i in range(N):
            low = min(low, d[i][c])
        if low != 0:
            common[c] = low
    common = sorted(common.items())  # キーでソート(いらないかも)

    ans = ''
    for c, v in common:
        ans += c * v
    return ans

N = int(input())
S = [input().strip() for _ in range(N)]
print(c_dubious_document(N, S))

Measured memory_bytes: 3444
S = list(input())
T = list(input())
s_element = list(set(S))
t_element = list(set(T))
s_count = [0]*(len(s_element))
t_count = [0]*(len(t_element))
for i in range(len(s_element)):
    s_count[i] = S.count(s_element[i])
for i in range(len(t_element)):
    t_count[i] = T.count(t_element[i])
x = sorted(s_count)
y = sorted(t_count)
print("Yes" if x==y else "No")

Measured memory_bytes: 6704
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  
print(-sum(a))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  
  vector<char> S(N);
  for(int i=0;i<N;i++){
    cin>>S.at(i);
  }
  
  int cnt=0;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C')
      cnt++;
  }

  cout<<cnt<<endl;
  
  return 0;
}

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

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

    vector<long int> a(N);
    for( int i = 0; i < N; ++i )
        cin >> a[i];

    vector<long int> even;
    even.push_back(2);
    for( int i = 0; ; ++i ){
        if( even[i]*2 < 10e9+1 )
            even.push_back(even[i]*2);
        else
            break;
    }

    int ans = 0;
    int len = (int)even.size();
    for( int i = 0; i < N; ++i ){
        for( int j = len-1; -1 < j; --j ){
            if( a[i]%even[j] == 0 ){
                ans += j + 1;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/



int a[3];
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int cnt=0;
	if(a[0]%2 and a[1]%2==0 or a[0]%2==0 and a[1]%2==1)
	{
		a[0]+=1;
		a[2]+=1;
		cnt++;
	}
	while(a[0]!=a[1])
	{
		a[0]+=2;
		cnt++;
	}
	while(a[0]!=a[2])
	{
		a[0]++;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int i,a,b,c,d,e;
	while(1){
	scanf("%d",&a);
	if(a==0) break;
	d=0; e=0;
	for(i=0;i<a;i++){
	scanf("%d %d",&b,&c);
	if(b==c){
	d+=b;
	e+=c;
	}
	else if(b>c){
	d+=b+c;
	}
	else if(b<c){
	e+=b+c;
	}
	}
	printf("%d %d\n",d,e);
	}
	return 0;
	}

Measured memory_bytes: 1028
import java.util.*;

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

        int K = sc.nextInt();

        if(K%2==0){
            System.out.println(K / 2 * K / 2);
        }
        else{
            System.out.println(K / 2 * (K / 2 + 1));
        }
    }
}

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

int main(){
    int64_t X;
    cin >> X;
    int A = X / 500;
    int B = (X - A * 500) / 5;
    cout << A * 1000 + B * 5 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
  int n,m,i,j,mx,sum,a,b;
  scanf("%d %d",&n,&m);
  sum=0;
  mx=0;
  for(i=0;i<m;i++)	{
    scanf("%d %d",&a,&b);
    if(a<n)	{
      sum+=n-a;
      mx=max(mx,n-a);
    }
  }
  printf("%d\n",sum-mx);
  return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>M>>L;
    mat dist(N, vec(N,INF)), num(N, vec(N,INF));
    ll C;
    rep(i,M){
        cin>>A>>B>>C;
        --A; --B;
        if(C <= L){
            dist[A][B] = dist[B][A] = C;
        }
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                if(dist[i][k] + dist[k][j] < min(dist[i][j], L + 1)){
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }
    rep(i,N) rep(j,N) if(dist[i][j] != INF) num[i][j] = 0;
    rep(k,N){
        rep(i,N){
            rep(j,N){
                if(num[i][k] + num[k][j] < num[i][j]){
                    num[i][j] = num[i][k] + num[k][j] + 1;
                }
            }
        }
    }
    cin>>Q;
    rep(i,Q){
        cin>>A>>B;
        --A; --B;
        cout<<(num[A][B] == INF ? -1 : num[A][B])<<endl;
    }
}

Measured memory_bytes: 1920
import sys

input = sys.stdin.readline

from collections import deque

H, W = map(int, input().split())
a = [input() for _ in range(H)]

dist = [[-1] * W for _ in range(H)]
dq = deque()

for r in range(H):
    for c in range(W):
        if a[r][c] == '#':
            dist[r][c] = 0
            dq.append((r, c))


def in_range(r, c):
    return 0 <= r < H and 0 <= c < W


dr_s = (0, 0, -1, 1)
dc_s = (-1, 1, 0, 0)

d = 0
while dq:
    r, c = dq.popleft()
    d = dist[r][c]
    for dr, dc in zip(dr_s, dc_s):
        nr = r + dr
        nc = c + dc
        if not in_range(nr, nc): continue
        if dist[nr][nc] != -1: continue
        dist[nr][nc] = d + 1
        dq.append((nr, nc))

print(d)


Measured memory_bytes: 89180
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int N = scan.nextInt();
		N = N % 10;
		
		switch(N) {
		
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;
		case 3:
			System.out.println("bon");
			break;
		}

	}

}


Measured memory_bytes: 35720
#include <iostream>

using namespace std;

int main(){
	int H, W;

	while(true){
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

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

int main(){
  int N,M;

  cin >> N >> M;
  vector<int> H(N);
  rep(i, N){
    int a;
    cin >> a;
    H[i] = a;
  }
  vector<vector<int>> g(N);
  rep(i, M){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  bool flag;
  rep(i, N){
    flag = true;
    for(int j = 0; j < g[i].size(); j++){
      if(H[i] <= H[g[i][j]]) flag = false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8804
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int sum[1 << 16];
int dp[1 << 16];

int x[16], y[16];

bool is_parallel(int a, int b, int c, int d) {
	return (y[b] - y[a])*(x[d] - x[c]) == (x[b] - x[a])*(y[d] - y[c]);
}
void solve() {
	int n; cin >> n;
	rep(i, n)cin >> x[i] >> y[i];

	rep(i, (1 << n)) {
		rep(j, n) {
			if (i&(1<<j))continue;
			Rep(k, j + 1, n) {
				if (i&(1<<k))continue;
				vector<bool> used(n);
				rep(l, n)if (i&(1 << l))used[l] = true;
				queue<int> q; q.push(i);
				int cnt = 0;
				rep(l, n) {
					if (used[l])continue;
					used[l] = true;
					vector<int> al = { l };
					Rep(m, l + 1, n) {
						if (used[m])continue;
						if (is_parallel(j, k, l, m)) {
							al.push_back(m); used[m] = true;
						}
					}
					cnt += al.size() / 2;
					if (al.size() >= 2) {
						int xsum = 0;
						rep(m, al.size()) {
							xsum ^= (1 << al[m]);
						}
						int len = q.size();
						rep(aa, len) {
							int id = q.front(); q.pop();
							if (al.size() % 2) {
								rep(m, al.size()) {
									int zsum = xsum ^ (1 << al[m]);
									q.push(id^zsum);
								}
							}
							else {
								q.push(id^xsum);
							}
						}
					}
				}
				while (!q.empty()) {
					int s = q.front(); q.pop();
					dp[s] = max(dp[s], dp[i] + cnt*(cnt-1)/2);
				}
			}
		}
	}
	int ans = 0;
	rep(i, (1 << n))ans = max(ans, dp[i]);
	cout << ans << endl;

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


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

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

    int power = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        power += a;
    }

    if (power >= H){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

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

using namespace std;
using ll = long long int;

int main() {
    static const double pi = 3.141592653589793;
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double rad =
        pi * 2 *
        ((double)h / 12.0 + ((double)m / 60.0) / 12.0 - (double)m / 60.0);

    double pow = (double)(a * a + b * b) - (double)(2 * a * b) * cos(rad);

    // cout << sqrt(pow) << endl;
    printf("%20.20Lf\n", sqrtl(pow));
}

Measured memory_bytes: 4160
<?php
fscanf(STDIN, '%d', $target);
$arr = array_fill(0, 1000001, 0);
$arr[1] = 7 % $target;
for ($i=2; $i <= $target; $i++) { 
    $arr[$i] = ($arr[$i-1]*10+7)%$target;
}
for ($i=1; $i <= $target; $i++) { 
    if ($arr[$i] == 0) {
        echo $i;
        exit;
    }
}
echo -1;

Measured memory_bytes: 47132
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  UnionFind uf(N);
  rep(i,0,M){
    cin >> A >> B >> C;
    uf.unite(A-1,B-1);
  }
  map<int,int>mp;
  rep(i,0,N)mp[uf.find(i)]++;
  Out(mp.size());
}


Measured memory_bytes: 5376
import java.io.*;
import java.util.*;

public class Main{
    PrintWriter out = new PrintWriter(System.out);
    long mod = 1000000000+7;
    static public void main(String[] args) throws Exception{
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ")
        Main main = new Main();
//        main.solve();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Long> a = new HashSet<>(n);
        long[] b = new long[n];
        for(int i=0;i<n;i++) {
            b[i] = sc.nextLong();
            a.add(b[i]);
        }
        long multi = LCM(a);
        long ans = 0;
        for(long w:b){
            ans = ans+multi*power(w,mod-2)%mod;
            ans %=mod;
        }
        return ans;
    }

    long power(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
    ArrayList<Integer> Primes(int upper){
        boolean[] rec = new boolean[upper+1];
        ArrayList<Integer> ans = new ArrayList<>(Math.max(upper/10,10));
        for(int i=2;i<=upper;i++){
            if(rec[i]) continue;
            ans.add(i);
            for(int j=i;j<=upper;j+=i){
                rec[j] = true;
            }
        }
        return ans;
    }
    long LCM(HashSet<Long> a){
        HashMap<Integer,Integer> rec = new HashMap<>(a.size());
        int maxi = -1;
        for(long w:a) maxi = Math.max(maxi,(int)w);
        ArrayList<Integer>[] pc = new ArrayList[maxi+1];
        for(int i=0;i<=maxi;i++) pc[i]=new ArrayList<Integer>();
        for(int i=2;i<=maxi;i++){
            if(pc[i].size()>0) continue;
            for(int j=2*i;j<=maxi;j+=i){
                pc[j].add(i);
            }
        }
        for(long w:a){
            // prime decomposition of w
            int now = (int)w;
            if(pc[now].size()==0) {
                rec.put(now,Math.max(1,rec.getOrDefault(now,0))); // w is a prime number
            }
            else{
                for(Integer p:pc[now]){
                    int back = now,cnt=0;
                    while(back%p==0){
                        cnt++;
                        back /= p;
                    }
                    if(rec.getOrDefault(p,0)<cnt) rec.put(p,cnt);
                }
            }
        }
        long ans = 1;
        for(int key:rec.keySet()){
            ans *= power(key,rec.get(key));
            ans %= mod;
        }
        return ans;
    }
}



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

main(){
    int n=0;
    cin >> n;
    for(int i=1,x=i; i<=n; ++i,x=i){
        if(x%3==0) cout << " " << i;
        else while(x) if(x%10==3){ cout << " " << i; break; }else x/=10;
    }
    cout << endl;
}


Measured memory_bytes: 3084
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] dArr = new Integer[n];

        for (int i = 0; i < n; i++) {
            dArr[i] = sc.nextInt();
        }

        // 降順に並べ替え
        Arrays.sort(dArr, Collections.reverseOrder());

        int count = 1;
        for (int i = 1; i < n; i++) {
            // 同じサイズだったら次へ
            if (dArr[i-1] == dArr[i]) continue;

            if (dArr[i-1] > dArr[i]) {
                count++;
            } else {
                // 降順にしているためないケース
                break;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23892
N = int(input())
t, x, y = 0, 0, 0
for _ in range(N):
	_t, _x, _y = map(int, input().split())
	d_xy = abs(x - _x) + abs(y - _y)
	d_t = _t - t
	if d_xy <= d_t and d_xy%2 == d_t%2:
		pass
	else:
		print("No")
		exit()
	t, x, y = _t, _x, _y
print("Yes")


Measured memory_bytes: 8996
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << n*800-(n/15)*200;
}

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

int main() {
int c[3][3];
for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
        cin >> c[i][j];
    }
}
string ans = "No";
if(c[1][0] - c[0][0] == c[1][1] - c[0][1] && c[1][1] - c[0][1] == c[1][2] - c[0][2]){
  if(c[2][0] - c[1][0] == c[2][1] - c[1][1] && c[2][1] - c[1][1] == c[2][2] - c[1][2]){
      ans = "Yes";
  }
}

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

Measured memory_bytes: 256
import sys

def solve(l, r):
  if r - l >= 2018:
    return 0

  ans = (l * r) % 2019
  for i in range(l, r+1):
    for j in range(l + 1, r+1):
      if i == j:
        continue

      # print(i, j)
      ans = min(ans, (i * j) % 2019)

  return ans


if __name__ == "__main__":
  l, r = map(int, sys.stdin.readline().rstrip().split(" "))
  print solve(l, r)

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

int main(){
  string S;
  cin>>S;
  int a=S.size(),z=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='A')
      a=min(a,i);
    else if(S[i]=='Z')
      z=i;
  }
  cout<<z-a+1<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  long long int i,j,k;
  long long int N,M;
  long long int space;
  long long int A,B,C,D;

  scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
  
  i=0;
  while(1){
    C = C-B;
    if( C<=0 ){
      printf("Yes\n");
      break;
    }    
    A = A-D;
    if( A<=0 ){
      printf("No\n");
      break;
    }
  }

  return 0; 
  
}

Measured memory_bytes: 1620
#include<iostream>

using namespace std;

int main() {

	long long int like[100000];
	for (int i = 0; i < 100000; i++) like[i] = 0;
	int N,ans=0;
	cin >> N;
	for (int i = 1; i <= N;i++) {
		cin >> like[i];
		if (like[like[i]] == i)ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long dp[101][300001];
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, w;
    cin >> n >> w;
    pair<long long, long long> items[100];
    for (int i = 0; i < n; i++) cin >> items[i].first >> items[i].second;

    dp[0][items[0].first] = items[0].second;
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j <= w; j++) {
            if (dp[i][j] == 0 && j != 0) continue;
            dp[i + 1][j + items[i + 1].first] =
                max(dp[i + 1][j + items[i + 1].first],
                    dp[i][j] + items[i + 1].second);
            dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
        }
    }
    long long ans = 0;
    for (int i = 0; i <= w; i++) ans = max(ans, dp[n - 1][i]);
    cout << ans << endl;
}


Measured memory_bytes: 231680
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println((H - h) * (W - w));
    }
}

Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl

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

 string s,t;
 cin>>s>>t;

 int n=s.length();

 if(t.substr(0,n)==s){
   cout<<"Yes"<<endl;
 }  
 else cout<<"No"<<endl;
  
  
     
  return 0;
}


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

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

	//桁数を求める
	int num = b, digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
		
	//aとbを結合
	if (digit == 1) c = b + a * 10;
	else if (digit== 2) c = b + a * 100;
	else c = b + a * 1000;

	//平方数かどうか
	for (int i = 1; i <= c; i++) {
		if (c == i * i) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])

    ret = 0
    for i in range(1, n+1):
        if not(i % 3 == 0 or i % 5 == 0):
            ret += i

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9180
var
	n,i,ans,now:Longint;
	L,R:Array[0..100000]of Longint;
	A:Array[1..100000]of Longint;
function gcd(a,b:Longint):Longint;
begin
	if b=0 then gcd:=a else gcd:=gcd(b,a mod b);
end;
begin
	read(n);
	for i:=1 to n do read(A[i]);
	for i:=1 to n do L[i]:=gcd(L[i-1],A[i]);
	for i:=n downto 1 do R[i-1]:=gcd(R[i],A[i]);
	for i:=1 to n do begin
		now:=gcd(L[i-1],R[i]);
		if ans<now then ans:=now;
	end;
	writeln(ans);
end.


Measured memory_bytes: 1280
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int D = Integer.parseInt(sc.next());
        var c = new int[27];
        for(int i = 1; i <= 26; i++){
            c[i] = Integer.parseInt(sc.next());
        }
        var s = new int[D+1][27];
        for(int d = 1; d <= D; d++){
            for(int i = 1; i <= 26; i++){
                s[d][i] = Integer.parseInt(sc.next());
            }
        }
    
        var last = new int[27];
        Arrays.fill(last, -1);
        var sb = new StringBuilder();
        for(int d = 1; d <= D; d++){
            int max = Integer.MIN_VALUE;
            int contest = 1;
            for(int i = 1; i <= 26; i++){
                int score = s[d][i];
                for(int j = 1; j <= 26; j++){
                    if(i == j) continue;
                    score -= c[i] * (d - last[i]);
                }
                if(score > max){
                    max = score;
                    contest = i;
                }
            }
            sb.append(contest).append(System.lineSeparator());
        }
        System.out.print(sb);
    }
}

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

int main() {
    
  int N,K;
  cin >> N;
  cin >> K;
  int sum=0;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(K-x<x){
      sum+=2*(K-x);
    }
    else{
      sum+=2*x;
    }
  }
  cout<< sum <<endl;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
ans = 0
L = []
for i in range(N//2+1):
    if i == 0:
        L.append(A[i])
    elif i % 2 == 0:
        L.append(A[i])
        ans += min(L[0],L[-2])
    else:
        L.insert(0,A[i])
        ans += min(L[1],L[-1])
if N % 2 == 1:
    ans += sum(A[1:N//2+1])
else:
    ans += sum(A[1:N//2])
print(ans)

Measured memory_bytes: 96888
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
 
typedef pair<int,int> P;
 
int n, d;
string t[202];
map<string, set<int> > idx;
 
vector<string> getV(string v){
  vector<string> res;
  string s = v;
 
  for(int a = 0; a < s.length() - 1; a++){
    swap(s[a], s[a + 1]);
    res.push_back(s);
    swap(s[a], s[a + 1]);
  }
 
  for(char ch = 'a'; ch <= 'z'; ch++){
    for(int j = 0; j < v.length(); j++){
      s = v;
      s[j] = ch;
      res.push_back(s);
      s[j] = v[j];
    }
 
    for(int j = 0; j < v.length() + 1; j++){
      s = v.substr(0, j) + ch + v.substr(j);
      res.push_back(s);
    }
  }
 
  for(int j = 0; j < v.length(); j++){
    s = v.substr(0, j) + v.substr(j + 1);
    res.push_back(s);
  }
 
  return res;
}
 
int main(){
  while(cin >> n, n){
    cin >> d;
 
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }
    sort(t, t + n);
 
    idx.clear();
 
    for(int i = 0; i < n; i++){
      vector<string> v = getV(t[i]);
 
      for(int j = 0; j < v.size(); j++){
        idx[v[j]].insert(i);
      }
    }
 
    set<P> ans;
 
    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        if(idx[t[j]].find(i) != idx[t[j]].end()){
          ans.insert(P(i, j));
        }
      }
    }
 
    if(d == 2){
      for(map<string,set<int> >::iterator iter = idx.begin(); iter != idx.end(); iter++){
        set<int> stt = iter->second;
        for(set<int>::iterator iter2 = stt.begin(); iter2 != stt.end(); iter2++){
          for(set<int>::iterator iter3 = stt.begin(); iter3 != stt.end(); iter3++){
            if(*iter2 < *iter3)
              ans.insert(P(*iter2, *iter3));
          }
        }
      }
    }
 
    for(set<P>::iterator iter = ans.begin(); iter != ans.end(); iter++){
      P p = *iter;
      cout << t[p.first] << "," << t[p.second] << endl;
    }
 
    cout << ans.size() << endl;
  }
}

Measured memory_bytes: 29304
# Print a Chessboard

end = 0
while end == 0:
    rectangle = [int(i) for i in input().rstrip().split()]
    height = rectangle[0]
    width = rectangle[1]
    if [height, width] == [0, 0]:
        end += 1
    else:
        for i in range(height):
            for j in range(width):
                sum = i + j
                if sum % 2 == 0:
                    print('#', end = "")
                elif sum % 2 == 1:
                    print('.', end = "")
            print()
        print()



Measured memory_bytes: 7008
package main

import (
    "fmt"
)

func main() {
    var a int64
    var b int64
    var k int64
  
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Scan(&k)
    
    if k - a < 0 {
        fmt.Printf("%d %d",a-k,b)
    } else {
        k = k -a
        if k - b < 0 {            
            fmt.Printf("%d %d",0,b-k)
        }else{
            fmt.Printf("%d %d",0,0)
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	
		ll int num,n;
		cin>>num>>n;
		ll int x;
		set<int> v;
		for(ll int i=0;i<n;i++)
		{
			cin>>x;
			v.insert(x);

		}
		int a,b;
		int s=0;
		while(1)
		{
			a=num-s;
			b=num+s;
			if(v.find(a)==v.end())
			{
				cout<<a<<endl;
				break;
			}
			
			
			
			if(v.find(b)==v.end())
			{
				cout<<b<<endl;
				break;
			}
			s++;
		}
		return 0;

	
}




Measured memory_bytes: 3680
import sys
sys.setrecursionlimit(10**7)

def dfs(v,p,d):
    dist[v]=d
    for nv in G[v]:
        if nv==p:
            continue
        dfs(nv,v,d+1)
def getSP(v):
    p=v
    if dist[v]==lim:
        return p
    for nv in G[v]:
        if dist[nv]<dist[v]:
            p=getSP(nv)
    return p
def depth(v,p,d):
    sdist[v]=d
    for nv in G[v]:
        if dist[nv]<dist[v]:
            continue
        depth(nv,v,d+1)
    
N,u,v=map(int,input().split())
u,v=u-1,v-1
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
dist=[-1]*N
dfs(v,-1,0)
lim=dist[u]-(dist[u]-1)//2
SP=getSP(u)
sdist=[-1]*N
depth(SP,-1,0)
D,tmp=-1,-1
for i in range(N):
    if sdist[i]>tmp:
        D=i
        tmp=sdist[i]
print(dist[D]-1)

Measured memory_bytes: 98348
#include <cstdio>

#define max(a, b) (a > b ? a : b)

int main() 
{
	const int MAX_N = 20;
	char operations[MAX_N];
	scanf("%s", operations);
	
	char answer[MAX_N];
	int end = 0;
	for(int i = 0; operations[i] != '\0'; i++)
	{
		if(operations[i] == 'B')
			end = max(0, end - 1);
		else
			answer[end++] = operations[i];
	}
	
	for(int i = 0; i < end; i++)
		printf("%c", answer[i]);
		
	return 0;
}

Measured memory_bytes: 128
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var X = Console.ReadLine().Split().Select(int.Parse).Last();
        Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).TakeWhile(x => 0 <= (X -= x)).Count() - (0 < X ? 1 : 0));
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;
typedef long long int64;

int64 MOD = 1000000007LL;

int64 Comb(int64 n, int64 k) {
  vector<int64> fac(n + 1);
  vector<int64> finv(n + 1);
  vector<int64> inv(n + 1);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= n; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i ) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
  int64 ans = fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
  return ans;
}

int main() {
  int64 N, M, K;
  cin >> N >> M >> K;

  int64 total = 0;
  for (int d = 1; d <= N - 1; ++d) {
    total += d * (N - d) * M % MOD * M % MOD;
    total %= MOD;
  }
  for (int d = 1; d <= M - 1; ++d) {
    total += d * (M - d) * N % MOD * N % MOD;
    total %= MOD;
  }
  total *= Comb(N * M - 2, K - 2);
  total %= MOD;

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-

# N, A, B, Xiの入力
n, a, b = map(int, input().split())
x = list(map(int, input().split()))

c = 0
for i in range(1, n):
    ea = (x[i] - x[i-1]) * a
    eb = b

    if ea >= eb:
        c += eb
    else:
        c += ea

print(c)


Measured memory_bytes: 14252
#C - こだわり者いろはちゃん 2
def checkDigit(n):
    d = []
    for i in range(9):
        if n%10 in D: return False
        n //= 10
        if n==0: return True

def solve(n):
    for i in range(N,1000000):
        if checkDigit(i): return i

N, K = [int(x) for x in input().split()]
D = [int(x) for x in input().split()]
#print(N,K,D)
print(solve(N))



Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main() {
  int n, sum = 0;
  cin >> n;
  vector<int> ws;
  for (int i = 0; i < n; ++i) {
    int v;
    cin >> v;
    sum += v;
    ws.push_back(v);
  }
  
  int csum = 0, least = 100000;
  for (int t = 0; t < n; ++t) {
    csum += ws[t];
    int diff = abs(csum - (sum - csum));
    if (diff < least)  least = diff;
  }
  cout << least << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> p(M), y(M);
	for (int i = 0; i < M; i++) {
		cin >> p[i] >> y[i];
		p[i]--;
	}
	vector<vector<int>> pre(N);
	for (int i = 0; i < M; i++)pre[p[i]].push_back(y[i]);
	for (int i = 0; i < N; i++)sort(pre[i].begin(), pre[i].end());
	for (int i = 0; i < M; i++) {
		printf("%06d", p[i] + 1);
		int id = lower_bound(pre[p[i]].begin(), pre[p[i]].end(), y[i]) - pre[p[i]].begin();
		printf("%06d", id + 1);
		cout << endl;
	}

}


Measured memory_bytes: 7808
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector< vector<int> > ice(90, vector<int>(90));

int m, n;

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

inline bool valid(int i, int j) {
	return 0 <= i && i < n && 0 <= j && j < m && ice[i][j] == 1;
}

int dfs(int i, int j, int count) {
	ice[i][j] = 0;
	int ret = count;
	for (int k=0; k<4; ++k) {
		if ( valid(i + dy[k], j + dx[k]) ) {
			ret = max(ret, dfs(i + dy[k], j + dx[k], count + 1));
		}
	}
	ice[i][j] = 1;
	return ret;
}

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

	while (cin >> m >> n && m && n) {
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				cin >> ice[i][j];
			}
		}
		int ans = 0;
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				if (ice[i][j] == 1) ans = max(ans, dfs(i, j, 1));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
#include <cmath>
#include <map>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
const int MaxN = 1e5 + 4;
typedef long long LL;
map<int,int>mp;
pair<int,int> PLL;
int main(){
	int n,k;
	cin>>n>>k;
	int t = 1e5+5;
	for(int i = 1; i <= n; i++){
		int x;
		cin>>x;
		k -= x;
		t = min(t,x);
	}
	cout<<n+k/t<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		int a = 60*60;
		int b = 60;
		int x,h,m,s;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		x = Integer.parseInt(str);
		h = x/a;
		m = (x%a)/b;
		s = (x%a)%b;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 17004
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 998244353;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  constexpr ll mxp = 4000;
  vector pm(mxp, vecll(mxp));
  FOR(i,1,mxp) {
    pm[i][0] = 1;
    FOR(j,1,mxp) {
      pm[i][j] = pm[i][j-1] * i % MOD;
    }
  }
  vector coeff11(mxp, vecll(mxp, 0));
  vector coeff12(mxp, vecll(mxp, 0));
  vector coeff21(mxp, vecll(mxp, 0));
  vector coeff22(mxp, vecll(mxp, 0));
  vector dp(c+1, vecll(d+1, 0));
  dp[a][b] = 1;
  FOR(i,a,c+1)FOR(j,b,d+1) {
    if (i == a && j == b) continue;
    //cerr<<i<<" "<<j<<" ";
    ll ii = i-1;
    ll jj = j-1;
    if (i > a && j > b) {
      // one top, one side
      dp[i][j] += ii * jj * dp[ii][jj] % MOD;
      dp[i][j] %= MOD;
      // multi top, one side
      if (i > a+1) {
        coeff11[i][j] += coeff11[i-1][j] * j % MOD + (i-2) * j * dp[i-2][j-1] % MOD;
        coeff11[i][j] %= MOD;
        coeff12[i][j] += coeff12[i-1][j] * jj % MOD + (i-2) * jj * dp[i-2][j-1] % MOD;
        coeff12[i][j] %= MOD;
        ll cf1 = coeff11[i][j];
        //cerr<<cf1<<" ";
        dp[i][j] += cf1;
        dp[i][j] %= MOD;
      }
      dp[i][j] += ii * dp[i-1][j-1] % MOD;
      dp[i][j] %= MOD;
      // one top, multi side
      if (j > b+1) {
        coeff21[i][j] += coeff21[i][j-1] * i % MOD + (j-2) * i * dp[i-1][j-2] % MOD;
        coeff21[i][j] %= MOD;
        coeff22[i][j] += coeff22[i][j-1] * ii % MOD + (j-2) * ii * dp[i-1][j-2] % MOD;
        coeff22[i][j] %= MOD;
        //cerr<<"("<<coeff21[i][j]<<" "<<coeff22[i][j]<<") ";
        ll cf2 = coeff21[i][j];
        //cerr<<cf2<<" ";
        dp[i][j] += cf2;
        dp[i][j] %= MOD;
      }
      dp[i][j] += jj * dp[i-1][j-1] % MOD;
      dp[i][j] %= MOD;
    }
    // no top, one side
    if (j == b) {
      dp[i][j] += dp[i-1][j] * j % MOD;
      dp[i][j] %= MOD;
      //cerr<<"01"<<" ";
    }
    // one top, no side
    if (i == a) {
      dp[i][j] += dp[i][j-1] * i % MOD;
      dp[i][j] %= MOD;
      //cerr<<"10"<<" ";
    }
    //cerr<<dp[i][j]<<endl;
  }
  cout<<dp[c][d]<<endl;
  return 0;
}


Measured memory_bytes: 699264
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


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

    return 0;
}


Measured memory_bytes: 3632
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print('C')
    elif m + f >= 30:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5596
#include <stdio.h> 
#include <iostream> 
using namespace std; 

int main(){
int X,A,B;
 
cin>>X>>A>>B;
if(B-A<=X){
     if(B-A>0){
cout<<"safe"<<endl;
}else{
cout<<"delicious"<<endl;
}
}else{
cout<<"dangerous"<<endl;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef vector<int>         vi;
typedef vector<ll>          vll;
 
#define ff                  first
#define sf                  scanf
#define pf                  printf
#define ss                  second
#define ppb                 pop_back
#define pb                  push_back
#define MP                  make_pair
#define MAXN                10000
#define MOD                 100000007
#define inf                 0x3f3f3f3f
#define PI                  (2.0*acos(0.0))
#define INF                 0x3f3f3f3f3f3f3f3f
#define rev(v)              reverse(all(v))
#define all(v)              v.begin(), v.end()
#define __lcm(x, y)         (x * y) / __gcd(x, y)
#define FOR(i, x, y)        for(int i = x; i < y; i++)
#define RFOR(i, x, y)       for(int i = x; i >= y; i--)
#define MEM(arr, val)       memset(arr, val, sizeof(arr));
#define unq(v)              (v).resize(unique(all(v)) - v.begin())
#define READ()              freopen("input.txt", "r", stdin)
#define WRITE()             freopen("output.txt", "w", stdout)
#define si(n)               scanf("%d", &n)
#define sl(n)               scanf("%lld", &n)
#define sii(a, b)           scanf("%d %d", &a, &b)
#define sll(a, b)           scanf("%lld %lld", &a, &b)
#define siii(a, b, c)       scanf("%d %d %d", &a, &b, &c)
#define slll(a, b, c)       scanf("%lld %lld %lld", &a, &b, &c)
#define siiii(a, b, c, d)   scanf("%d %d %d %d", &a, &b, &c, &d)
#define sllll(a, b, c, d)   scanf("%lld %lld %lld %lld", &a, &b, &c, &d)
#define vout(v)             for(int i = 0; i < v.size(); i++) {cout << v[i]; if(i < v.size() - 1) cout << ' '; else cout << endl;}
 
int main(){
        int n, k; sii(n, k);
        map<int, int> mp;
 
        FOR(i, 0, n){
            int x; si(x);
            mp[x]++;
        }
        int ans = n;
 
        while(true){
            int tmp = ans, flg = 0;
            while(tmp > 0){
                if(mp[tmp % 10]) flg = 1;
                tmp /= 10;
            }
            if(flg == 0) break;
            else ++ans;
        }
        cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3680
from collections import Counter

N = int(input())
S = Counter(map(int, input().split()))
Q = int(input())
T = Counter(map(int, input().split()))
ans = 0
if len(S) > len(T):
    for x, y in S.items():
        if x in T.keys():
            ans += min(y, T[x])
else:
    for x, y in T.items():
        if x in S.keys():
            ans += min(y, S[x])
print(ans)



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

typedef long long ll;
typedef complex<double> Vec;

ll N, M, P;
vector<vector<ll>> Out, In;
vector<tuple<ll, ll, ll>> Edges;
vector<bool> Seen, RSeen;
const ll INF = 1ll << 60;
vector<ll> Dist;

void dfs(int v) {
  if (Seen[v]) return;
  Seen[v] = true;
  for (ll w : Out[v]) dfs(w);
}
void rdfs(int v) {
  if (RSeen[v]) return;
  RSeen[v] = true;
  for (ll w : In[v]) rdfs(w);
}
bool valid(int v) { return Seen[v] && RSeen[v]; }
void clean() {
  Seen.resize(N);
  dfs(0);
  RSeen.resize(N);
  rdfs(N - 1);
  vector<tuple<ll, ll, ll>> new_edges;
  for (auto edge : Edges) {
    ll a, b, c;
    tie(a, b, c) = edge;
    if (valid(a) && valid(b)) new_edges.push_back(edge);
  }
  Edges = new_edges;
}
ll solve() {
  Dist.resize(N, -INF);
  Dist[0] = 0;
  for (ll cnt = 0; cnt <= N; ++cnt) {
    bool updated = false;
    for (auto edge : Edges) {
      ll a, b, c;
      tie(a, b, c) = edge;
      if (Dist[b] < Dist[a] + c) {
        Dist[b] = Dist[a] + c;
        updated = true;
      }
    }
    if (updated && cnt == N) {
      return -1;
    }
  }
  return max(0ll, Dist[N - 1]);
}
int main() {
  cin >> N >> M >> P;
  Out.resize(N);
  In.resize(N);
  for (ll i = 0; i < M; ++i) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    c -= P;
    Out[a].push_back(b);
    In[b].push_back(a);
    Edges.push_back(make_tuple(a, b, c));
  }
  clean();
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
using namespace std;
const int64_t INF=10000000000000000;

int main(){
	int number[3][3];
	bool ans[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>number[i][j];
			ans[i][j]=false;
		}
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int num;
		cin>>num;
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(number[j][k]==num){
					ans[j][k]=true;
				}
			}
		}
	}
	bool retval=false;
	for(int i=0;i<3;i++){
		if(ans[i][0]&&ans[i][1]&&ans[i][2]){
			retval=true;
		}
		if(ans[0][i]&&ans[1][i]&&ans[2][i]){
			retval=true;
		}
	}
	if(ans[0][0]&&ans[1][1]&&ans[2][2]){
		retval=true;

	}
	if(ans[2][0]&&ans[1][1]&&ans[0][2]){
		retval=true;
	}
	if(retval){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}


Measured memory_bytes: 256
a, b, c, x, y = list(map(int, input().split()))

a_sum = a * x
b_sum = b * y
c_sum = c * (x+y)
price = 0

if a_sum + b_sum > c_sum:
    num = min(x, y)
    price += num * c * 2
    x -= num
    y -= num
    if x > 0:
        if a < c * 2:
            price += a * x
        else:
            price += c * 2 * x
    if y > 0:
        if b < c * 2:
            price += b * y
        else:
            price += c * 2 * y
else:
    price += a*x + b*y
print(price)

Measured memory_bytes: 3064
#include<stdio.h>

int main()
{
    int H,W,i,j;
    scanf("%d %d",&H,&W);
    if( H == 0 && W == 0){
    	return 0;
    }
    while(!(H == 0 && W == 0)){
    	for(i=0; i<H; i++){
        	for(j=0; j<W ;j++){
            	printf("#");
        	}
        	printf("\n");
    	}
    	printf("\n");
    	scanf("%d %d",&H,&W);
    }
    return 0;
}

Measured memory_bytes: 572