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

string getString(vector<string> vec)
{
    string result = "";
    for (int i = 0; i < vec.size(); i++)
    {
        result += vec[i] + ", ";
    }
    return result;
}

int main()
{
    vector<string> ans;

    while (1)
    {
        string in1;
        cin >> in1;
        if (in1 == ".")
        {
            break;
        }
        string in2;
        cin >> in2;

        vector<string> T1, T2;
        vector<string> U1, U2;

        bool InQuote = false;
        for (int i = 0; i < in1.size(); i++)
        {
            if (InQuote)
            {
                T1.push_back("");
                while (in1[i] != '"' && i < in1.size())
                {
                    T1[T1.size() - 1] += in1[i];
                    i++;
                }
                InQuote = false;
            }
            else
            {
                T2.push_back("");
                while (in1[i] != '"' && i < in1.size())
                {
                    T2[T2.size() - 1] += in1[i];
                    i++;
                }
                InQuote = true;
            }
        }
        InQuote = false;
        for (int i = 0; i < in2.size(); i++)
        {
            if (InQuote)
            {
                U1.push_back("");
                while (in2[i] != '"' && i < in2.size())
                {
                    U1[U1.size() - 1] += in2[i];
                    i++;
                }
                InQuote = false;
            }
            else
            {
                U2.push_back("");
                while (in2[i] != '"' && i < in2.size())
                {
                    U2[U2.size() - 1] += in2[i];
                    i++;
                }
                InQuote = true;
            }
        }

        // ans.push_back(getString(T1));
        // ans.push_back(getString(T2));
        // ans.push_back(getString(U1));
        // ans.push_back(getString(U2));

        if (T1.size() != U1.size() || T2.size() != U2.size())
        {
            ans.push_back("DIFFERENT");
        }
        else
        {
            bool ok = true;
            for (int i = 0; i < T2.size(); i++)
            {
                if (T2[i] != U2[i])
                {
                    ans.push_back("DIFFERENT");
                    ok = false;
                    break;
                }
            }
            if (ok)
            {
                int NumMiss = 0;
                for (int i = 0; i < T1.size(); i++)
                {
                    NumMiss += (T1[i] != U1[i] ? 1 : 0);
                }
                if (NumMiss >= 2)
                {
                    ans.push_back("DIFFERENT");
                }
                else if (NumMiss == 1)
                {
                    ans.push_back("CLOSE");
                }
                else if (NumMiss == 0)
                {
                    ans.push_back("IDENTICAL");
                }
            }
        }
    }

    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
}


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

using namespace std;

int main()
{
    int n;
    long long int prod=1;
    cin>>n;
    long long int a[100005];
    for(int i=0; i<n; i++)
        scanf("%lld", &a[i]);

    for(int i=0; i<n; i++)
        if(a[i]==0)
        {
            cout<<0;
            return 0;
        }

    for(int i=0; i<n; i++)
    {
        if((a[i])<=(1000000000000000000/prod))
            prod*=a[i];
        else
        {
            cout<<-1;
            return 0;
        }
    }

    printf("%lld",prod);

    return 0;
}



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

int main()
{
    int A, B;
    cin >> A >> B;

    if (A > 9 || B > 9) {
        cout << -1 << endl;
    } else {
        cout << A * B << endl; 
    }
}

Measured memory_bytes: 256
n,c=map(int,input().split())
x=list(map(int,input().split()))
x=[x[i]-c for i in range(n)]
ans=x[0]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
for t in x:
    ans=gcd(ans,t)
print(abs(ans))

Measured memory_bytes: 14252
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(void);
void dfs_visit(int);

int color[MAX],M[MAX][MAX],n;
int d[MAX],f[MAX];
int time;

int main(){
  int u,k,v;
  int i,j;

  scanf("%d",&n);

  for (i = 0;i < n;i++){
    scanf("%d %d",&u,&k);

    u--;
    
    for (j = 0;j < k;j++){
      scanf("%d",&v);

      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  for (i = 0;i < n;i++){
    printf("%d %d %d\n",i + 1,d[i],f[i]);
  }
  return 0;
}

void dfs(void){
  int i;

  for (i = 0;i < n;i++)
    color[i] = WHITE;

  for (i = 0;i < n;i++)
    if (color[i] == WHITE)
      dfs_visit(i);
}

void dfs_visit(int u){
  int v;
  
  color[u] = GRAY;
  d[u] = ++time;

  for (v = 0;v < n;v++){
    if (M[u][v] && color[v] == WHITE)
      dfs_visit(v);
  }

  color[u] = BLACK;
  f[u] = ++time;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c<=0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a<=0){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int A, B, K;
    cin >> A >> B >> K;
    int X = max(A, B) + 1;
    for(int k = 0; k < K; k++) {
        do {
            X--;
        } while (X >= 1 && (A % X != 0 || B % X != 0));
    }
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long int ll;
constexpr int kN = int(2E5 + 10);

ll x[kN], y[kN];

int main() {
	int n, ans = 0;
	ll d;
	scanf("%d%lld", &n, &d);
	d *= d;
	for (int i = 1; i <= n; i++) scanf("%lld%lld", &x[i], &y[i]);
	for (int i = 1; i <= n; i++) if (x[i] * x[i] + y[i] * y[i] <= d) ans++;
	printf("%d\n", ans);
	
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define rl "\n"
#define ll long long
#define x first
#define y second
using namespace std;
vector<vector<int>> rd;
vector<bool> visited;
void dfs(int i)
{
	visited[i]=true;
	rep(j,0,rd[i].size())
	{
		if(!visited[rd[i][j]])
		{
			dfs(rd[i][j]);
		}
	}
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n,m;cin>>n>>m;
    rd.resize(n);
    visited.resize(n);
    while(m--)
   	{
   		int a,b;cin>>a>>b;
   		rd[a-1].pb(b-1);
   		rd[b-1].pb(a-1);
   	}
   	int ans=0;
   	dfs(0);
   	rep(i,1,n)
   	{
   		if(!visited[i])
   		{
   			dfs(i);
   			ans++;
   		}
   	}
   	cout<<ans;
}


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

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

    int ca, cb, cc;
    ca = cb = cc = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;

        ca += (p <= a);
        cb += (p > a && p <= b);
        cc += (p > b);
    }

    cout << min({ca, cb, cc}) << endl;

    return 0;
}


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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	int n;
	cin >> n;
	vector<pp> v;
	v.resize(n);
	for(int i = 0; i < n; i++){
		cin >> v[i].first >> v[i].second;
	}
	map<pp,ll> m;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i == j)continue;
			pp d = pp(v[i].first - v[j].first, v[i].second - v[j].second);
			m[d]++;
		}
	}
	ll maxi = 0;
	for(auto it : m){
		maxi = max(maxi,it.second);
	}
	cout << n - maxi << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int dp[100003];
int main(void){
   int N;
   cin>>N;
   for(int i=0;i<N;i++){
       int x;
       cin>>x;
       x++;
       dp[x]++;
       dp[x-1]++;
       dp[x+1]++;
   }
   int ans=0;
    for(int i=0;i<100003;i++){
        ans=max(dp[i],ans);
    }
    cout<<ans;
}


Measured memory_bytes: 768
def countave(n , a):
    ans = 100000000000000

    for i in range(2 , 4):
        kei = 0
        forans = 0
        #偶数+
        if i % 2 == 0:
            fast = 1
        else:
            fast = -1
        for w in range(n):
            if fast < 0 and kei + int(a[w]) >= 0:
                forans += abs(kei + int(a[w])) + 1
                kei = -1
                fast = 1
            elif fast > 0 and kei + int(a[w]) <= 0:
                forans += abs(kei + int(a[w])) + 1
                kei = 1
                fast = -1
            else:
                kei += int(a[w])
                fast *= -1
        ans = min(ans , forans)

    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(countave(n , a))

if __name__ == '__main__':
    main()


Measured memory_bytes: 63216
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp

res = Array.new(n, 0)
ans = 0
points = { r: p, s: r, p: s }
(0..n-1).each do |i|
  if i-k >= 0 && t[i] == t[i-k] && res[i-k] == 1
  else
    ans += points[t[i].to_sym]
    res[i] = 1
  end
end
puts ans

Measured memory_bytes: 3836
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
const ll mid=6400;
bool dp[85][85][13000];//dp[x][y][score];
struct data{
  int x,y,score;
};
int main(){
  int h,w;
  cin>>h>>w;
  vector<vector<int>> a(h,vector<int>(w)),b(h,vector<int>(w));
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>b[i][j];
  queue<data> q;
  q.push({0,0,a[0][0]-b[0][0]});
  q.push({0,0,b[0][0]-a[0][0]});
  dp[0][0][a[0][0]-b[0][0]+mid]=1;
  dp[0][0][b[0][0]-a[0][0]+mid]=1;
  while(!q.empty()){
    data d=q.front();
    q.pop();
    for(int i=0;i<2;i++){
      data next;
      next.x=d.x+i;
      next.y=d.y+(1^i);
      if(next.x>=h||next.y>=w)continue;
      if(!dp[next.x][next.y][a[next.x][next.y]-b[next.x][next.y]+d.score+mid]){
        dp[next.x][next.y][a[next.x][next.y]-b[next.x][next.y]+d.score+mid]=1;
        next.score=a[next.x][next.y]-b[next.x][next.y]+d.score;
        q.push(next);
      }
      if(!dp[next.x][next.y][b[next.x][next.y]-a[next.x][next.y]+d.score+mid]){
        dp[next.x][next.y][b[next.x][next.y]-a[next.x][next.y]+d.score+mid]=1;
         next.score=b[next.x][next.y]-a[next.x][next.y]+d.score;
        q.push(next);
      }
    }
  }
  ll ans=inf;
  for(ll i=0;i<13000;i++)if(dp[h-1][w-1][i])chmin(ans,abs(i-mid));
  cout<<ans<<endl;
}

Measured memory_bytes: 93136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int n;
    cin >> n;
    if(n >= 65 && n <= 90){
        cout << 1 << endl;
    }else if( n >= 97 && n <= 122){
        cout << 2 << endl;
    }else {
        cout << 0 << endl;
    }
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3112
#ABC146.B
N = int(input())
S = list(input())
alp = [chr(i)for i in range(65,91)]
L=[]
for i in range(len(S)):
    for m in range(len(alp)):
        if S[i]==alp[m]:
            if m + N <=25:
                L.append(alp[m+N])
            else:
                L.append(alp[m+N-26])
print(''.join(L))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int Max(int x,int y){
	return x>y?x:y;
}
int solve(int x,int y){
	if(x%y==0) return x/y;
	int v=x/y+1;
	int delta=Max((x%y)/v,1);
	return solve(x-delta*v,y);
}
int main(){
//	freopen("D.in","r",stdin);
	int ans=0,n;
	scanf("%d",&n);
	int x,y;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		ans^=solve(x,y);
	}
	if(ans)
		printf("Takahashi\n");
	else
		printf("Aoki\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
vector<int> a;
vector<bool> isprime;
map<ll,int> prime_factorize(ll n) {
    map<ll, int> ret;
    for (int i = 2; i*i <= n; ++i) {
        while(n%i==0){
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}
void sieve(ll n) {
    if ((size_t)(n + 1) > isprime.size()) {
        isprime.resize(n + 1, true);
    }
    isprime[0] = false;
    isprime[1] = false;
    for (ll i = 2; i*i <= n; ++i) {
        if (isprime[i]) {
            for (ll j = 2; i*j <= n; ++j) {
                isprime[i*j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll,int> mp=prime_factorize(n);
    cout << n <<":";
    for (auto p = mp.begin(); p != mp.end(); ++p) {
        while (p->second--) {
            cout << " " << p->first;
        }
    }
    
    cout << endl;
    return 0;
}



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

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

using namespace std;

typedef long long ll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector <int> ans;
  while (not arr.empty()) {
    int pos = -1;
    for (int i = sz(arr) - 1; i >= 0; i--) {
      if (arr[i] - 1 == i) {
        pos = i;
        break;
      }
    }
    if (pos == -1) {
      cout << -1 << endl;
      return (0);
    }
    vector <int> tmp;
    for (int i = 0; i < sz(arr); i++) {
      if (i == pos) continue;
      tmp.push_back(arr[i]);
    }
    ans.push_back(pos + 1);
    arr = tmp;
  }
  reverse(all(ans));
  for (int elem: ans) cout << elem << '\n';
  return (0);
}


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

int main()
{
    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;

    for (int i = l; i <= r; i++)
    {
        if (i % d == 0)
        {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>
 
int main()
{
	char s[30];
	int a[26]={0};
//	scanf("%s",s);
    fgets(s,30,stdin);
	int n=strlen(s);
	for(int i=0;i<n;i++)
		a[s[i]-'a']++;
	int dif=0;
	for(int i=0;i<26;i++)
		if(a[i]>1){
			dif=1;	break;
		}	
	if(dif==0)
		printf("yes");
	else
		printf("no");
	return 0; 
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstddef>
#include <cinttypes>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <array>
#include <valarray>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <tuple>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

const double EPS = 1e-10;
const int64_t INF = 1e9;

int main()
{
	int zoro[1000];
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		if (a == b) {
			zoro[i] = 1;
		} else zoro[i] = 0;
	}

	for (int i = 0; i < N-2; ++i) {
		if (zoro[i] + zoro[i+1] + zoro[i+2] == 3) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 3156
N = list(map(int, input().split()))[-1]
A = sorted(list(map(int, input().split())), reverse=True)[:N]
B = sorted(list(map(int, input().split())), reverse=True)[:N]
C = sorted(list(map(int, input().split())), reverse=True)[:N]

first = [i+j for i in A for j in B]
first = sorted(first, reverse=True)[:N]
second = [i+j for i in first for j in C]
result = sorted(second, reverse=True)[:N]

[print(i) for i in result]

Measured memory_bytes: 185544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> P(N);
    vector<tuple<string, int, int>> x(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> S[i] >> P[i];
        x[i] = make_tuple(S[i], -P[i], i);
    }
    sort(x.begin(), x.end());
    for ( int i = 0; i < N; i++ ) {
        cout << get<2>(x[i]) + 1 << '\n';
    }
    return 0;
}

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

using namespace std;

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	long long ans=0;

	for(long long i=1;i<=n;i+=2){
		long long cnt=0;
		for(long long j=1;j<=i;j++){
			if(i%j==0) cnt++;
		}
		if(cnt==8) ans++;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

std::random_device seed_gen;
std::mt19937 engine(seed_gen());
constexpr int prob = 26;
const double TL = 1.970;
// const double TL = 0.100;

vector<ll> c,l;
vector<vector<int>> s;
int d;

ll score(vector<int> &t) {
    ll sat = 0;
    rep (i, prob) l[i] = -1;
    rep (dy, d) {
        int k = t[dy];
        sat += s[dy][k];
        l[k] = dy;
        rep (i, 26) sat -= c[i] * (dy - l[i]);
    }
    return sat;
    // return (ll)-1e18 - 1;
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    clock_t start = clock(), end;
    cin >> d;
    c.resize(prob); l.resize(prob);
    s.resize(d); rep (i, s.size()) s[i].resize(prob);
    rep (i, c.size()) cin >> c[i];
    rep (i, s.size()) { rep (j, s[0].size()) { cin >> s[i][j]; }}

    vector<int> t(d), tmp;
    vector<int> sum(prob + 1);
    rep (i, prob) sum[i + 1] = sum[i] + c[i];
    rep (i, prob) l[i] = -1;
    rep (i, d) {
        int k = -1, x = -1;
        rep (j, prob) if (chmax(x, s[i][j] + (int)c[j] * (i - (int)l[j]))) k = j;
        t[i] = k;
        l[k] = i;
    }
    tmp = t;
    ll max_score = -(ll)1e18;
    int count = 1, k;
    while (true) {
        // write here
        
        do {
            k = engine() % d;
            tmp[k] = engine() % prob;
        } while (tmp[k] == t[k]);
        if (chmax(max_score, score(tmp))) t = tmp;
        // ll sc = score(tmp);
        // if (max_score > sc) t = tmp;
        // else {}

        if (count % 100 == 0) {
            end = clock();
            if (static_cast<double>(end - start) / CLOCKS_PER_SEC > TL) break;
        }
        count++;
    }
    
    rep (i, d) cout << t[i] + 1 << "\n";
    eprintf("count: %d\n", count);
    eprintf("max_score: %d\n", max_score);
    return 0;
}

Measured memory_bytes: 3744
<?php
$inputs = explode(' ', trim(fgets(STDIN)));
$K = $inputs[0];
$S = $inputs[1];
$ans = 0;
for($x = 0; $x <= $K; $x++){
	for($y = 0; $y <= $K; $y++){
		$z = $S - $x - $y;
		if(0 <= $z && $z <= $K) $ans++;
	}
}
echo $ans;
?>

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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<ll> a(N), b(N);

  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int i = 0; i < N; i++){
    cin >> b[i];
  }
  ll ans = 0;
  for(int i = 0; i < N; i++){
    if(a[i] - b[i] >= 0){
      ans += a[i] - b[i];
    }
  }
  cout << ans << endl;
}


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

typedef long long int ll;

int main () {
    int a, b; cin >> a >> b;
    int ans = -1;
    for (int i = 1; i <= 1100; i++) {
        int hatchi = (int)(((double)i) * 1.08);
        int zyu = (int)(((double)i) * 1.1);
        if (a == (hatchi - i) && b == (zyu - i)) {
            ans = i; break;
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

N, K = map(int, input().split())
t, d = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

# おいしさについて貪欲に寿司を食べたときの満足ポイントを求める
# その後、種類ボーナスを1個ずつ増やしたときの満足ポイントをそれぞれ求め、
# それらの最大値を求める
S = sorted(zip(d, t), reverse=True)
q = []
v = set()
s = 0
for D, T in S[:K]:
    s += D
    if T in v:
        heappush(q, D)
    else:
        v.add(T)
s += len(v)**2
opt = s
for D, T in S[K:]:
    if T not in v and q:
        z = heappop(q)
        s += D + 2 * len(v) + 1 - z
        v.add(T)
        opt = max(opt, s)
ans = opt

print(ans)


Measured memory_bytes: 58456
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <bitset>  // std::bitset<N>
#include <sstream> //stringstream
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
//ここから書き始める
int main(){
    int judge=0; //0ならNo 1ならYes
    int n ; cin >> n ;
    vector<ll> A(n);
    rep(i,n){
        cin>>A[i];
    }
    SORT(A);//３種類を超えたらポツダム
    vector<ll> B(1);
    B[0]=A[0];
    map<ll,ll> M;
    M[A[0]]++; 
    rep(i,n-1){
        M[A[i + 1]]++;
        if(A[i+1]!=A[i]){
            B.push_back(A[i+1]);
        }
    }
  //  che(B.size(),"Bnodekasa");
    if(n%3!=0){
        if(B.size()==1&&B[0]!=0) judge = 0;
        else if(B.size()==1&&B[0]==0) judge = 1;
        else judge = 0;
    }
    else if(B.size()>3) judge = 0;
    else if(B.size()==3){//3種類の時、全部n/3回ならok
        //binは0じゃないとだめ
        ll bin = B[0]^B[1]^B[2];
        if(bin == 0 && M[B[0]] == n / 3 && M[B[1]] == n/3 && M[B[2]] == n/3){
            judge = 1;
        }
    }
    else if(B.size()==2){//2種類の時、B[1]がn/3 *2 
        if(M[B[0]]==n/3) judge = 1;
    }
    else if(B.size()==1){
   //     che(B[0],"B[0]");
        if(B[0]==0) judge = 1;
    }
    if(judge)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 6260
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
int main() {
  map<string, int> mp;
  int n;
  string s;
  cin >> n;
  rep(i,n)
  {
    cin >> s;
    mp[s]++;
  }
  int cnt = 0;
  for (auto itr : mp) {
    cnt++;
  }
  cout << cnt;
}


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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define endl "\n"
ll mod = 1000000007;

ll MOD(ll a) {
	if (a < 0)
		a = a + mod;
	return (a%mod);
}

ll My_Pow(ll a, ll n) {
	if (n == 0)
		return 1;
	else if (n == 1)
		return a;
	else if (n&1) {
		ll ans = MOD(My_Pow(a, (n-1)/2));
		ans = MOD(ans*ans);
		ans = MOD(MOD(ans)*MOD(a));
		return ans;
	}
	else {
		ll ans = MOD(My_Pow(a, n/2));
		ans = MOD(ans*ans);
		return ans;
	}
}

void testCase() {
	ll m, n;
	cin >> m >> n;
	cout << My_Pow(m, n) << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim],B[lim],C[lim];
// map<lld,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc(n);
    ans = 0;
    rep(i,1,n) {
        countA = 0;
        rep(j,1,i) countA += (i % j == 0);
        // Error2(i, countA);
        ans += (i%2 == 1 and countA == 8);
    }
    prL(ans);
    return 0;
}

Measured memory_bytes: 256
H, W = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
M = 6401

def honya(y, d):
  t = (1 << d + 1) - 1
  t = y & t
  k = 0
  for i in range(d):
    k += t & 1
    t >>= 1
    k <<= 1
  return k

D = [[0] * W for _ in range(H)]
for i in range(H):
  for j in range(W):
    D[i][j] = abs(B[i][j] - A[i][j])

DP = [[0] * W for _ in range(H)]

def nasu(x, y, d):
  t = (1 << (d + 1)) - 1 & y
  return (x | (y << d) | (y >> d) | honya(y, d)) & mask
  

mask = (1 << M) - 1
DP[0][0] = 1 << D[0][0]
for i in range(H):
  for j in range(W):
    if i + 1 < H:
      DP[i + 1][j] = nasu(DP[i + 1][j], DP[i][j], D[i + 1][j])
    if j + 1 < W:
      DP[i][j + 1] = nasu(DP[i][j + 1], DP[i][j], D[i][j + 1])

t = DP[-1][-1]
for i in range(M):
  if t & 1:
    print(i)
    break
  t >>= 1



Measured memory_bytes: 52828
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
int a,b,si,ti,ti2;

int sw(int S,int i,int j){
  int I=(S>>i&1);
  int J=(S>>j&1);
  S-=(I<<i);
  S+=(J<<i);
  S-=(J<<j);
  S+=(I<<j);
  return S;
}

int d[(1<<16)];
int bfs(){
  for(int i=0;i<(1<<16);i++)d[i]=-1;
  queue<int> Q;
  Q.push(si);
  d[si]=0;
  while(!Q.empty()){
    int S=Q.front();Q.pop();
    if(S==ti||S==ti2){
      return d[S];
    }
    for(int i=0;i+1<N;i++){
      int to=sw(S,i,i+1);
      if(d[to]==-1){
	d[to]=d[S]+1;
	Q.push(to);
      }
    }
  }
}

int main(){
  cin>>N>>M;
  si=ti=ti2=0;
  for(int i=0;i<N;i++){
    cin>>a;
    si=si*2+a;
  }
  for(int i=0;i<M;i++){
    cin>>a;
    b=i%2;
    for(int j=0;j<a;j++){
      ti=ti*2+b;
      ti2=ti2*2+1-b;
    }
  }
  cout<<bfs()<<endl;
  return 0;
}

Measured memory_bytes: 1476
from collections import Counter
N, K =map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
takahashi = [0]*N
for i in range(N):     
    if i < K:
        if T[i] == 'r':
            takahashi[i] = 'p'
        elif T[i] == 's':
            takahashi[i] = 'r'
        elif T[i] == 'p':
            takahashi[i] = 's'
            
    if i >= K:
        if T[i] == 'r' and takahashi[i-K] != 'p':
            takahashi[i] = 'p'
        elif T[i] == 's' and takahashi[i-K] != 'r':
            takahashi[i] = 'r'
        elif T[i] == 'p' and takahashi[i-K] != 's':
            takahashi[i] = 's'

c = Counter(takahashi)
print(R*c['r'] + S*c['s'] + P*c['p'])

Measured memory_bytes: 5176
#include <stdio.h>
#include <string.h>
int main (){

	char A [100], B [100], C [100];
	A [100]= 'a' - 'z';
	B [100]= 'a' - 'z';
	C [100]= 'a' - 'z';
	
	scanf ("%s %s %s", &A, &B, &C);

	if (A [strlen (A) - 1 ] == B[0] && B [strlen (B) - 1] == C[0]) {
		printf ("YES\n");
		
	}
	else {
		printf ("NO\n");
	}	
	return 0;
}

Measured memory_bytes: 1592
H, W, K = map(int, input().split())
lis = []
for _ in range(H):
    A = list(input())
    lis.append(A)
    
ans = 0
for paint_h in range(2**H):
    for paint_w in range(2**W):
       cnt=0
       for i in range(H):
           for j in range(W):
               if (paint_h >> i)&1 ==0 and (paint_w >> j)&1 ==0:
                   if lis[i][j] == '#':
                       cnt += 1
       if cnt == K:
           ans += 1
print(ans)

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

int main() {
  int x, s1, s2, s3;
  cin >> x;
  s1 = x / 100;
  s2 = (x % 100) / 10;
  s3 = (x % 100) % 10;
  
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
int main(){
  int x1,x2,y1,y2;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  printf("%d %d %d %d\n",x2+y1-y2,y2+x2-x1,x1+y1-y2,y1+x2-x1);
  return 0;
}


Measured memory_bytes: 128
# ABC 164 E 草案
import sys
sys.setrecursionlimit(10**6)

n,m,s= map(int, input().split())
g= [list(map(int, input().split())) for i in range(m)]
# 両替所
c= [list(map(int, input().split())) for i in range(n)]

x=2501
# 作るグラフ (点,所有銀貨,必要時間)
gg=[[[] for i in range(x)] for i in range(n)]
for i in range(n):
    for j in range(x-1):
        # 金貨を銀貨に交換
        y=j+c[i][0]
        if y>=x-1:
            y=x-1
        gg[i][j].append((i,y,c[i][1]))


for i in range(1,x):
    for u,v,a,b in g:
        u-=1
        v-=1
        # 銀貨足りる時移動できる
        if i-a>=0:
            gg[v][i].append((u,i-a,b))
            gg[u][i].append((v,i-a,b))





#ダイクストラ法
from heapq import heappush, heappop

def dijkstra(edges, size, source,gold):
    # edge=探索するグラフ
    # size=グラフの点の数
    # source=スタート点
    distance = [[float('inf')  for i in range(x)] for i in range(n)]
    distance[source][gold] = 0
    visited = [[False  for i in range(x)] for i in range(n)]
    pq = []
    heappush(pq, (0, source,gold))
    while pq:
        dist_v, u,v = heappop(pq)
        visited[u][v] = True
        for u,v, weight in edges[u][v]:
            if not visited[u][v]:
                new_dist = dist_v + weight
                if distance[u][v] > new_dist:
                    distance[u][v] = new_dist
                    heappush(pq, (new_dist, u,v))
    return distance
s=min(2500,s)
ans=dijkstra(gg,n,0,s)

for i in range(1,n):
    print(min(ans[i]))

Measured memory_bytes: 172156
N = int(input())
xu = [list(map(str,input().split())) for i in range(N)]
sum = 0
for j in range(N):
	if xu[j][1] == 'JPY':
		sum += float(xu[j][0])
	else:
		sum += float(xu[j][0])*380000
print(sum)

Measured memory_bytes: 9108
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

struct Edge {
	int to, cost;
	Edge(const int a, const int b) {
		to = a, cost = b;
		return;
	}
};

struct Node {
	int index;
	long long score;
	Node(const int ind, const long long  int sco= 0) {
		index = ind;
		score = sco;
		return;
	}
	bool operator < (const Node&n)const {
		return score > n.score;
	}
};

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

	cin >> N >> M >> K;
	vector<vector<Edge>>edge(N);
	vector<vector<int>>rev_edge(N);
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> H;
		L--;
		R--;
		H -= K;
		edge[L].push_back(Edge(R, H));
		rev_edge[R].push_back(L);
	}
	vector<int>dis(N, MOD);
	dis.back() = 0;
	queue<int>Q;
	Q.push(N - 1);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : rev_edge[cn]) {
			if (dis[i] > dis[cn] + 1) {
				dis[i] = dis[cn] + 1;
				Q.push(i);
			}
		}
	}
	vector<long long int>ret(N, -MOD);
	vector<int>used(N);
	ret[0] = 0;
	priority_queue<Node>PQ;
	PQ.push(Node(0));
	while (!PQ.empty()) {
		auto box = PQ.top();
		int cn = box.index;
		int c = box.score;
		used[cn] ++;
		PQ.pop();
		if (ret[cn] > c)continue;
		if (ret[cn] < c&&ret[cn] != -MOD) {
			cout << -1 << endl;
			return 0;
		}
		for (auto i : edge[cn]) {
			if (dis[i.to] == MOD)continue;
			if (ret[i.to] < c + i.cost&&used[i.to]>=N) {
				cout << -1 << endl;
				return 0;
			}
			if (ret[i.to] < c + i.cost) {
				ret[i.to] = c + i.cost;
				PQ.push(Node(i.to, ret[i.to]));
			}
		}
	}
	cout << max(0LL,ret.back()) << endl;
}



Measured memory_bytes: 10732
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct S015 {
  long operator()(long a, long b, long x) {
    return b / x - a / x + (a % x == 0 ? 1 : 0);
  }
};

struct Solver {
  long a, b, x;
  Solver() {
    S002 r;
    r >= a >= b >= x;
  }
  void solve() {
    S015 s;
    long res = s(a, b, x);
    printf("%ld\n", res);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

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

int main() {
	int table[101][10001];
	int N, W;
	cin >> N >> W;

	int v[1000];
	int w[1000];
	for (int i = 1; i <= N; i++)
	{
		cin >> v[i] >> w[i];
	}

	int res = -1;
	for (int i = 0; i < W; i++) 
		table[0][i] = 0;
	for (int i = 0; i < N; i++) 
		table[i][0] = 0;
	
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			if (0 <= j - w[i]) {
				table[i][j] = max(table[i - 1][j], table[i - 1][j - w[i]] + v[i]);
			}
			else table[i][j] = table[i - 1][j];
			res = max(res, table[i][j]);
		}
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 7024
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;
double eps = 1e-11;

int main() {
    int N, K;
    cin >> N >> K;
    int a[N];
    int num = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] == 1) {
            num = i;
        }
    }
    ll ans = 0;
    ans += (N - 1 + (K - 2)) / (K - 1);
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
    public static void main(String[]args){

        Scanner sc = new Scanner(System.in);
        int A=sc.nextInt();
        int B=sc.nextInt();
        
        int price;
        
        if(A>=13) {
        	price=B;
        }
        else if(A<=12&&A>=6) {
        	price=B/2;
        }
        else {
        	price=0;
        }
        
        System.out.print(price);
        sc.close();
    }
}

Measured memory_bytes: 23124
N, M = map(int, input().split())
A = list()
B = list()
shop = []

for n in range(N):
  a,b = map(int, input().split())
  shop.append({'price' : a, 'zaiko' : b})

shop.sort(key=lambda x: (x['price'], -1*x['zaiko']))

ret = 0
cnt = 0
for s in shop:
  for i in range(s['zaiko']):
    cnt += 1
    ret += s['price']
    if M <= cnt:
      break
  if M <= cnt:
    break

print(ret)


Measured memory_bytes: 51076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define esp 1e-7
using namespace std;
long long read(){
    long long x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n;
char s1[100],s2[100];
long long dp[100],len[100],num;

int main(){
	n=read();
	scanf("%s%s",s1+1,s2+1);
	num=0;
	for (int i=1;i<=n;i++){
		if (s1[i]==s2[i]){
			len[++num]=1;
		}
		else {
			i++;
			len[++num]=2;
		}
	}
	if (len[1]==1)	dp[1]=3;
	else			dp[1]=6;
	for (int i=2;i<=num;i++){
		if (len[i]==1){
			if (len[i-1]==1){
				dp[i]=dp[i-1]*2;
			}
			else{
				dp[i]=dp[i-1];
			}
		}
		else{
			if (len[i-1]==1){
				dp[i]=dp[i-1]*2;
			}
			else{
				dp[i]=dp[i-1]*3;
			}
		}
	}
	cout<<(dp[num])%1000000007<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {
	
	//MOD、階乗・MODの逆元・階乗の逆元のテーブル
	static int MAX_FAC = 510000;
	static int MOD = 1000000007;
	static long[] fac = new long[MAX_FAC];
	static long[] finv = new long[MAX_FAC];
	static long[] inv = new long[MAX_FAC];
	
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		long N = in.nextLong();
		long M = in.nextLong();
		long ans = 1;
		
		//初期化
		initComb();
		
		long m = M;
		for (int i = 2; i * i <= m; i++) {
			if (m % i == 0) {
				int count = 0;
				while (m % i == 0) {
					m /= i;
					count++;
				}
				//System.out.println(i + " ^ " + count);
				//N-1+count C count
				ans = (ans * comb((int)N-1+count, count)) % MOD;
			}
		}
		if(m > 1){
			//System.out.println(n + " ^ " + 1);
			ans = (ans * N) % MOD;
		}
		
		System.out.println(ans);
	}
	
	//テーブルの初期化
	public static void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < MAX_FAC; ++i) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - (MOD / i) * inv[(int) (MOD % i)] % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}
	
	//nCk % MOD
	public static long comb(int n, int k){
		return fac[n] * finv[k] % MOD * finv[n - k] % MOD;
	}
}



Measured memory_bytes: 36180
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

using namespace std;

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

  cout<<r*r<<endl;
  return 0;
}



Measured memory_bytes: 256
from collections import defaultdict
def gcd(a,b):
    if a==0:
        return b
    return gcd(b%a,a)
N=int(int(input()))
ans=0
Hash=defaultdict(lambda:0)
for i in range(1,N+1):
    for j in range(1,N+1):
        x=gcd(i,j)
        Hash[x]+=1
for i in range(1,N+1):
    for j,t in Hash.items():
        x=gcd(j,i)
        ans+=t*x
print(ans)


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

#define pb push_back
#define fi first
#define se second


using namespace std;


vector<int> v;

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

	for(int i = 0; i<n; i++)
	{
		cin>>t;
		v.pb(t);
	}

	bool hav1 = false;
	for(auto &i : v)
	{
		if(i==1)
			hav1 = true;			
	}

	if(!hav1)
	{
		cout<<-1<<endl;
		return 0;
	}

	int atu = 1;
	for(auto &i : v)
	{
		if(i==atu)
			atu++;
	}

	cout<<n-atu+1<<endl;


	return 0;
}


Measured memory_bytes: 4292
#include <iostream>
#include <string>

using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	int min=t.length();
	for(int i=0;i<s.length()-t.length()+1;i++){
		int count=0;
		for(int j=0;j<t.length();j++){
			// cout << s[i+j] << " " << t[j] << endl;
			if(s[i+j]==t[j]){
				count++;
			}
			// cout << count <<endl;
		}
		if(min>t.length()-count){
			min=t.length()-count;
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int c[300];
int cnt[99];
int main(){
	char s[99];
	scanf("%s",s);
	rep(i,0,4)c[s[i]]++;
	rep(i,0,256)cnt[c[i]]++;
	puts(cnt[2]!=2?"No":"Yes");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<deque>
using namespace std;
bool is_gone[121212];
vector<int>edge[121212];
int main() {
	int n, m, i, j; scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		int s, e; scanf("%d%d", &s, &e);
		edge[s].push_back(e); edge[e].push_back(s);
	}
	deque<int>Q;
	for (i = 1; i <= n; i++)if (edge[i].size()) {
		Q.push_back(i);
		is_gone[i] = 1;
		break;
	}
	while (1) {
		int now = Q.back();
		for (i = 0; i < edge[now].size(); i++) {
			if (is_gone[edge[now][i]])continue;
			is_gone[edge[now][i]] = 1;
			Q.push_back(edge[now][i]);
			break;
		}
		if (i==edge[now].size())break;
	}
	while (1) {
		int now = Q.front();
		for (i = 0; i < edge[now].size(); i++) {
			if (is_gone[edge[now][i]])continue;
			is_gone[edge[now][i]] = 1;
			Q.push_front(edge[now][i]);
			break;
		}
		if (i==edge[now].size())break;
	}
	printf("%d\n", Q.size());
	for (i = 0; i < Q.size(); i++)printf("%d ", Q[i]);
	return 0;
}

Measured memory_bytes: 7296