akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = 1e9;

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for(int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];

    vector<vector<int>> dp(N+1, vector<int>(3, -INF));
    dp[0][0] = dp[0][1] = dp[0][2] = 0;

    for(int i = 0; i < N; i++) {
        dp[i+1][0] = max({dp[i+1][0], dp[i][1] + b[i], dp[i][2] + c[i]});
        dp[i+1][1] = max({dp[i+1][1], dp[i][0] + a[i], dp[i][2] + c[i]});
        dp[i+1][2] = max({dp[i+1][2], dp[i][0] + a[i], dp[i][1] + b[i]});
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;

    return 0;
}

Measured memory_bytes: 6912
#include <cstdio>
#include <cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<cmath>
#include <map>
#include <algorithm>
using namespace std;
map<string, string>mp;
vector<vector<int> >G;

const int INF=0x3f3f3f3f;
const int maxn=1100;
int maps[maxn][maxn];
int n, m;


int main()
{
    while(scanf("%d", &n), n)
    {
        m=0;
        memset(maps, INF, sizeof(maps));
        for(int i=0; i<n; i++)
        {
            int u, v, w;
            scanf("%d %d %d", &u, &v, &w);
            m=max(m, max(u, v));
            maps[u][v]=maps[v][u]=w;
        }

        for(int k=0; k<=m; k++)
        {
            for(int i=0; i<=m; i++)
            {
                for(int j=0; j<=m; j++)
                    maps[i][j]=min(maps[i][j], maps[i][k]+maps[k][j]);
            }
        }

        int sum=INF, index;
        for(int i=0; i<=m; i++)
        {
            int ans=0;

            for(int j=0; j<=m; j++)
                if(i!=j)
                    ans+=maps[i][j];
            if(sum>ans)
            {
                sum=ans;
                index=i;
            }
        }
        printf("%d %d\n", index, sum);
    }
    return 0;
}

Measured memory_bytes: 5920
N, M  = list(map(int,input().split()))

gaku = []
for i in range(N):
	gaku.append(tuple(map(int,input().split())))

cp = []
for i in range(M):
	cp.append(tuple(map(int,input().split())))

def dis(x,y,a,b):
	return(abs(x-a)+abs(y-b))

res = []

for x,y in (gaku):
	c = 1
	mind = float("inf")
	minc = 0
	for a,b in (cp):
		if dis(x,y,a,b) < mind:
			minc = c
			mind = dis(x,y,a,b)
		c+=1
	res.append(minc)


for i in res:
	print(i)

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

    int math (int n){
        
        int ans =0;
        while (0<n){
          ans+= n%10;
          n/=10;
        }
        return ans;
    }
int main(){
    int n;
    cin >>n;
    int min = 10e5;
    for (int i=1;i<=n/2;i++){
        int a ,b,add;
        b =i;
        a=n-b;
        add =math(b)+ math(a);
        if(min>add) min =add;
    }
    cout << min;
}    


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

void main() {
    const N = readln.chomp.to!long;
    const as = readln.split.to!(long[]);

    long cnt;
    long ss, xs;
    long r;
    foreach (l; 0..N) {
        while (r < N && ss + as[r] == (xs ^ as[r])) {
            ss += as[r];
            xs ^= as[r];
            r++;
        }
        cnt += r-l;
        ss -= as[l];
        xs ^= as[l];
    }
    writeln(cnt);
}



Measured memory_bytes: 11432
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<P> V(N);
    rep(i,0,N){
        cin >> V[i].first >> V[i].second;
    }
    sort(V.begin(), V.end());
    ll sum = 0;
    rep(i,0,N){
        ll num = min(M, V[i].second);
        sum += num * V[i].first;
        if(M < V[i].second)M = 0;
        else M -= V[i].second;
    }
    cout << sum << endl;
}

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

int main() {
    int n, q;
    string s;
    cin >> n >> s >> q;
    set<int> alpha[26];
    for (int i = 0; i < n; i++) {
        alpha[s[i] - 'a'].insert(i);
    }
    while (q--) {
        int type;
        cin >> type;
        if (type == 1) {
            int i;
            char c;
            cin >> i >> c;
            i--;
            alpha[s[i] - 'a'].erase(i);
            s[i] = c;
            alpha[c - 'a'].insert(i);
        } else {
            int l, r;
            cin >> l >> r;
            l--;
            r--;
            int ans = 0;
            rep(k, 26) {
                if (alpha[k].lower_bound(l) == alpha[k].end()) continue;
                if (*alpha[k].lower_bound(l) <= r) ans++;
            }
            cout << ans << endl;
        }
    }
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

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

    set<char> chars;
    rep(0, s.size()) chars.insert(s[i]);

    cout << (chars.size() == 2 ? "Yes" : "No") << endl;

    return 0;
}


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

typedef long long ll;

using namespace std;

ll MAX = 1e9+1;
void solve() {
    int n, w;

    cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    for (int i = 0; i < n; i++) {
        cin >> weight[i] >> value[i];
    }

    vector<ll> dp(1e5+1, MAX); // dp[v] ~ lowest weight that can get value v
    dp[0] = 0;
    
    for (int i = 1; i <= n; i++) {
        for (int v = 1e5; v >= value[i-1]; v--) {
            ll new_weight = dp[v-value[i-1]] + weight[i-1];
            if (new_weight <= w) 
                dp[v] = min(dp[v], new_weight);
        }
    }

    //for (int i = 0; i < 15; i++) 
    //    cout << dp[i] << " ";
    //cout << endl;

    for (int v = 1e5; v >= 0; v--) {
        if (dp[v] != MAX) {
            cout << v << endl;
            return;
        }
    }
}


int main() {
    solve();
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int a, b; cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for i in range(3)]
d = [[0] * 3 for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
def bingo(l1, l2):
    global d
    for i in l2:
        for j in range(3):
            for k in range(3):
                if l1[j][k] == i:
                    d[j][k] = 1
    for i in range(3):
        if d[i][0] == 1 and d[i][1] == 1 and d[i][2] == 1:
            return "Yes"
        elif d[0][i] == 1 and d[1][i] == 1 and d[2][i] == 1:
            return "Yes"
    if d[0][0] == 1 and d[1][1] == 1 and d[2][2]:
        return "Yes"
    elif d[2][0] == 1 and d[1][1] == 1 and d[0][2]:
        return "Yes"
    else:
        return "No"
print(bingo(a,b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    string s_r = s;
    reverse(all(s_r));
    if (s == s_r) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

      double a = Double.parseDouble(sc.next());
      double b = Double.parseDouble(sc.next());
      double x = Double.parseDouble(sc.next());

      double ans = 0;

      double halfVol = a*a*b/2;

      if(x>halfVol){ //1
        double kk = 2*(a*a*b-x)/(a*a*a);
        ans = Math.atan(kk);
        ans = Math.toDegrees(ans);
      }
      else if(x==halfVol){ //2
        ans = 45;
      }
      else if(x<halfVol){ //3
        double kk = a*b*b/2/x;
        ans = Math.atan(kk);
        ans = Math.toDegrees(ans);
      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,cc,n) for (int i = cc; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmin(x,y) x = min(x,y)

const int INF = 1001001001;
int dp[1000005][2];

int main() {
  int N;
  cin >> N;
  
  vector<int> B(N-1);
  rep(i,0,N-1) cin >> B.at(i);
  
  int ans = B.at(0);

  rep(i,1,N-1) ans += min(B.at(i-1),B.at(i));
  ans += B.at(N-2);
  
  cout << ans << endl;
}

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

int main() {
    int n, b, f, r, v;
    cin >> n;

    int rooms[4][3][10];

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                rooms[i][j][k] = 0;
            }
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        
        rooms[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 10; k++) {
                cout << ' ' << rooms[i][j][k];
            }
            cout << endl;
        }
        if (i != 3) cout << "####################" << endl;
    }
}



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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

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

	if(a <= 5){
		cout << 0 << endl;
	}
	else if(6 <= a && a <= 12){
		cout << b/2 << endl;
	}
	else{
		cout << b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#define INF 1000000000//INF=∞
using namespace std;
typedef pair<int, int> P;//firstは最短距離,secondは頂点番号

const int MAX_M = 100;

struct edge {
  int to, cost;
  //edge() : to(0), cost(0) {}
  //edge(int to, int cost) : to(to), cost(cost) {}
};
int V;//頂点の数

vector<vector<edge> > time_graph(MAX_M); //頂点間の距離情報(隣接リスト)
vector<vector<edge> > cost_graph(MAX_M);

vector<vector<int> > time_ds(MAX_M);
vector<vector<int> > cost_ds(MAX_M);

int dijkstra_time(int s, int g){
  if (!time_ds[s].empty()) return time_ds[s][g];
  
  priority_queue<P, vector<P>, greater<P> > que;
  vector<int> d(V, INF);//最短距離を記録する配列(∞で初期化しておく)
  d[s] = 0;//頂点sから頂点sへの最短距離は0で確定
  que.push(P(0, s));//距離0,頂点sからスタート

  while(!que.empty()){
    /*処理1*/
    //キューの中で最も頂点sからの距離が近い頂点vとその距離cを取得
    P p = que.top();
    que.pop();
    int v = p.second, c = p.first;

    /*処理2*/
    //頂点vの最短距離がすでに確定していたらcontenue
    if(d[v] < c)
      continue;

    /*処理3*/
    //頂点vの最短距離が既に確定していなければ頂点vへの最短経路はcで確定
      d[v]=c;

    /*処理4*/
    //頂点vから移動しうる頂点とその距離をキューに入れる
    for(int i = 0; i < time_graph[v].size(); i++){
      //頂点vはG[v].size()個の行き先を持つ
      edge e = time_graph[v][i];
      if(d[e.to] > d[v] + e.cost){
        que.push(P(d[v] + e.cost, e.to));
      }
    }
  }
  time_ds[s] = d;
  return d[g];//頂点gへの最短距離を返す
}


int dijkstra_cost(int s, int g){
  if (!cost_ds[s].empty()) return cost_ds[s][g];
  
  priority_queue<P, vector<P>, greater<P> > que;
  vector<int> d(V, INF);//最短距離を記録する配列(∞で初期化しておく)
  d[s] = 0;//頂点sから頂点sへの最短距離は0で確定
  que.push(P(0, s));//距離0,頂点sからスタート

  while(!que.empty()){
    P p = que.top();
    que.pop();
    int v = p.second, c = p.first;

    if(d[v] < c)
      continue;

      d[v]=c;

    for(int i = 0; i < cost_graph[v].size(); i++){
      edge e = cost_graph[v][i];
      if(d[e.to] > d[v] + e.cost){
        que.push(P(d[v] + e.cost, e.to));
      }
    }
  }

  cost_ds[s] = d;
  return d[g];//頂点gへの最短距離を返す
}


int main() {
  int n, m;
  while (cin >> n >> m, n || m) {
    V = m;

    for (int i = 0; i < MAX_M; i++) {
      time_graph[i].clear();
      time_ds[i].clear();
      cost_graph[i].clear();
      cost_ds[i].clear();
    }

    for (int i = 0; i < n; i++) {
      int a, b, time, cost;
      cin >> a >> b >> time >> cost;
      a--; b--; // 0-indexedにする
      edge e1,e2,e3,e4;
      e1.to = e3.to = b; e1.cost = e2.cost = time;
      e2.to = e4.to = a; e3.cost = e4.cost = cost;
      time_graph[a].push_back(e1);
      time_graph[b].push_back(e2);
      cost_graph[a].push_back(e3);
      cost_graph[b].push_back(e4);
    }

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      int p, q, r;
      cin >> p >> q >> r;
      p--; q--;
      if (p > q) swap(p, q);
      if (r == 0)
        cout << dijkstra_time(p, q) << endl;
      else
        cout << dijkstra_cost(p, q) << endl;
    }
  }
}

Measured memory_bytes: 1188
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a == b&&b == c)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
from itertools import cycle

while True:
    (H, W) = [int(i) for i in input().split(' ')]
    if (H == W == 0):
        break

    it1 = cycle(['#', '.'])
    it2 = cycle(['.', '#'])

    str1 = ''
    str2 = ''

    for i in range(W):
        str1 += next(it1)
        str2 += next(it2)

    for i in range(H):
        if ((i % 2) == 0):
            print(str1)
        else:
            print(str2)

    print()

Measured memory_bytes: 7720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){

  int n;
  cin >> n;
  int sushi[3]={0,0,0};
  int a;
  rep(i,n){
    cin >> a;
    if(a!=0) sushi[a-1]++;
  }
  double dp[n+2][n+2][n+2];
  rep(i,n+2) rep(j,n+2) rep(k,n+2) dp[i][j][k]=0;
  rep(c3,n+1) rep(c2,n+1) rep(c1,n+1) {
    double sm = c1 + c2 + c3;
    if (sm == 0) continue;
    dp[c1][c2][c3] = ((double) n)/ sm;
    if (c1) dp[c1][c2][c3] += dp[c1 - 1][c2][c3] * c1 / sm;
    if (c2) dp[c1][c2][c3] += dp[c1 + 1][c2 - 1][c3] * c2 / sm;
    if (c3) dp[c1][c2][c3] += dp[c1][c2 + 1][c3 - 1] * c3 / sm;
    //    cout << c1 << " " << c2 << " " << c3 << " " << dp[c1][c2][c3] << endl;
  }
  cout << fixed << setprecision(10) << dp[sushi[0]][sushi[1]][sushi[2]] << endl;
    
    
  return 0;

}


Measured memory_bytes: 215424
n = int(input())
a = list(map(int,input().split()))
dict = {}
sumcon = 0
for i in a:
  if i not in dict:
    dict[i] = 1
  else:
    dict[i] += 1
    
for i in dict:
  sumcon += (dict[i]*(dict[i]-1))//2
  
for j in a:
  print(sumcon + 1 - dict[j])

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

typedef long long ll;

ll n, p;

int main()
{
    cin >> n >> p;
    if (n == 1) cout << p << endl;
    else {
        ll res = 1;
        for (ll i = 2; i * i <= p; i++)
            if (p % i == 0) {
                int cnt = 0;
                while (p % i == 0) {
                    cnt++;
                    p /= i;
                }
                cnt /= n;
                while (cnt--) res *= i;
            }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    for (int i = min(a,b); i >= 1; i--) {
        if (a%i == 0 && b%i == 0){
            k--;
            if(k == 0) {
                cout << i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 998244353;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


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


int pw(int a, int b) {
	if (!b)
		return 1;
	int res = pw(a, b / 2);
	res = res * res % MOD;
	if (b & 1)
		res = res * a % MOD;
	return res;
}

int f[MX];
int f1[MX];

int C(int n, int k) {
	if (k < 0 || k > n)
		return 0;
	return f[n] * f1[n - k] % MOD * f1[k] % MOD;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   	
    f[0] = 1;
    fi(1, MX)
    	f[i] = f[i - 1] * i % MOD;
    f1[MX - 1] = pw(f[MX - 1], MOD - 2);
    fi1(MX - 1, 0)
    	f1[i] = f1[i + 1] * (i + 1) % MOD;

   	int n, m, k;
   	cin >> n >> m >> k;
   	int res = 0;
   	fi(0, k + 1) {
   		res += m * C(n - 1, i) % MOD * pw(m - 1, n - 1 - i) % MOD; 
   	}
   	cout << res % MOD;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> 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() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  cin >> s;

  int ans = 0, res = 0;
  rep(i, 3) {
    if (s[i] == 'S') res = 0;
    else res++;
    chmax(ans, res);
  }
  cout << ans << '\n';

  
  return 0;
}

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

bool usedx[100009];
bool usedy[100009];

vector<int>v[100009];
bool used[100009];

int dfs(int now){
  if(used[now])return 0;
  used[now]=1;
  int res=1;
  r(i,v[now].size()){
    res += dfs(v[now][i]);
  }
  return res;
}

signed main(){
  int n,sum=0;
  cin>>n;
  int y[n],x[n];
  r(i,n){
    cin>>x[i]>>y[i];
    if(usedx[x[i]] || usedy[y[i]]){
      cout<<-1<<endl;
      return 0;
    }
    usedx[x[i]]=1;
    usedy[y[i]]=1;
    v[x[i]].push_back(y[i]);
    v[y[i]].push_back(x[i]);
    //if(x[i]==y[i])used[x]=1;
  }

  r(i,n){
    if(!used[i+1]){
      sum += dfs(i+1)-1;
    }
  }


  cout<<sum<<endl;
  
}



Measured memory_bytes: 12728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int ans = (n / 500) * 1000;
	n = n % 500;
	ans += (n / 5) * 5;
	cout << ans;
	return 0;
}

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


def main():
    from bisect import bisect_left
    from bisect import bisect_right

    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = list(map(int, input().split()))
    c = sorted(list(map(int, input().split())))
    ans = 0

    for bi in b:
        less = bisect_left(a, bi)
        greater = n - bisect_right(c, bi)
        ans += less * greater

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 23744
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};


signed main(){
  string s;
  int K;
  cin>>s>>K;

  vector<string>str;
  for(int k=1;k<=K;k++){
    for(int t=0;t+k<=s.size();t++){
      str.push_back(s.substr(t,k));
    }
  }
  sort(str.begin(),str.end());
  str.erase(unique(str.begin(),str.end()),str.end());
  auto itr=str.begin();
  itr+=K-1;
  cout<<(*itr)<<"\n";
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
void solve()
{
 int n;
 cin>>n;
 int arr[n][3];

 for(int i=0;i<n;i++)
 {
   for(int j=0;j<3;j++)
        cin>>arr[i][j];
 }
 vector<vector<int>> dp(n,vector<int>(3,0));

 for(int i=0;i<3;i++)
 {
    dp[0][i]=arr[0][i];
 }


  for(int i=1;i<n;i++)
  {
      for(int j=0;j<3;j++)
      {
         if(j==0)
          dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][2]);
         if(j==1)
            dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][2]);
         if(j==2)
            dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][1]);
      }
  }
/*for(int i=0;i<n;i++)
{
    for(int j=0;j<3;j++)
        cout<<dp[i][j]<<" ";
    cout<<"\n";
}*/
 cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

int main()
{
    int test;
  //  cin>>test;
  test=1;
  while(test--)
  {
    solve();
  }


    return 0;
}


Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
string s,t;
char c;
int n,a,f;
int main(){
	cin>>s>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a==1) swap(s,t);
		if(a==2)
		{
			cin>>f>>c;
			if(f==1) t.push_back(c);
			if(f==2) s.push_back(c);
		}
	}
	reverse(t.begin(),t.end());
	cout<<t+s<<endl;
	return 0;
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int cmod = 998244353;
const int N = 1e5 + 5;
const int inf = 1e18 + 2;


void solve(int Case) {
    int a , b , c , d ;
    int ans = 0 , ans2 = 0;
    cin >> a >> b >> c >> d ;
    ans = b * d ;
    ans2 = a * c ;
    int ans3 = a * d ;
    int ans4 = b * c ;
    cout << max({ans , ans2 , ans3 , ans4}) << '\n';
}
/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int Case = 1;
    while(testcase --) {
        solve(Case);
    }
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int partition(int a[],int p,int r){
  int x=a[r],j,i=p-1;
  for(j=p;j<r;j++){
    if(a[j]<=x){
      i=i+1;
      //cout<<x<<" :"<<i<<endl;
      swap(a[i],a[j]);
    }

  }
  swap(a[i+1],a[r]);
  return i+1;

}

int main(){
  int n,i,j;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)cin>>a[i];
  j=partition(a,0,n-1);
  for(i=0;i<j;i++)cout<<a[i]<<" ";
  cout<<"["<<a[i]<<"] ";
  for(i++;i<n-1;i++)cout<<a[i]<<" ";
  cout<<a[i]<<endl;

  return 0;
}



Measured memory_bytes: 3396
#include <stdio.h>
 
int main(){
  int r,c,a[101][101],i,j,sum=0;
  scanf("%d %d",&r,&c);
  for(i=0; i<101; i++){
    for(j=0; j<101; j++){
      a[i][j]=0;
    }
  }
  for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      a[r][j]+=a[i][j];
      a[i][c]+=a[i][j];
    }
  }//-----            
for(i=0; i<r; i++){
    for(j=0; j<c; j++){
      a[r][c]+=a[r][j];
      a[r][c]+=a[i][c];
    }
  }
  a[r][c]/=(r+c);
  for(i=0; i<=r; i++){
    for(j=0; j<=c; j++){
      if(j==c)printf("%d\n",a[i][j]);
      else printf("%d ",a[i][j]);
    }
  }
  return 0;
}


Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
#define int ll
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 200005
int n;
struct node{ ll x,y; }a[N];
const bool cmp(const node &x,const node &y){
	return x.y>y.y;
}
//#define local
signed main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	n=read(); ll ans=0,sum=0,tmp=0; bool flag=0;
	rep (i,1,n){
		a[i].x=read(),a[i].y=read();
		if (a[i].x!=a[i].y) flag=1;
		if (a[i].x<a[i].y){ ans+=a[i].y; tmp+=a[i].y-a[i].x; }
	}
	if (!flag){ puts("0"); exit(0); }
	sort(a+1,a+1+n,cmp);// cerr<<tmp<<endl;
	//cerr<<ans<<endl;
	rep (i,1,n) if (a[i].x>=a[i].y){
		if (a[i].x-a[i].y+1>tmp){
			continue;
		}
		//cerr<<a[i].x-a[i].y<<endl;
		tmp-=a[i].x-a[i].y; ans+=a[i].y;
		//cerr<<tmp<<' '<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}
// sample data:
/*
2
1 2
3 2

3
8 3
0 1
4 8


5
1 3
2 8
3 0
8 4
10 9


5
2 2
1 9
3 0
8 4
10 9

*/
 
// rest:
/*

*/

Measured memory_bytes: 512
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    map<char,bool>m;
    rep(i,s.size()){
        m[s[i]]=true;
    }
    if(m['N']!=m['S'])return no,0;
    if (m['W'] != m['E'])
        return no, 0;
    yes;
}


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

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
 int n;
 int m;
 cin >> n;
 vector<int> vec(n);
 for (int i = 0; i < n - 1; ++i){
	 cin >> m;
	 ++ vec[m-1];
 }
 for (int l = 0; l < n; ++l){
	 cout << vec[l] << '\n';
 }
} 

Measured memory_bytes: 3984
/*
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long double ld;

int main(){
    ld a,b;
    long long ans;
    cin >> a >> b;
    ans = floor(a*b);
    cout << setprecision(18) << ans << endl;
    //cout << (long long)a*b << endl;
    return 0;
}
*/

#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<numeric>

using namespace std;

int main() {
    unsigned long long ans=0;
 double buf=0;
 unsigned long long N;
 unsigned long long u, d;
 cin >> N;
 cin >> buf;
 u = (unsigned long long)buf;
 d = (unsigned long long)(buf * 1000) - u * 1000;
 u = N * u;
 d = (N * d) / 1000;
 ans = u + d;
 //cout << N << endl;
 //cout << u << endl;
 //cout << d << endl;
 cout << ans << endl;
}


Measured memory_bytes: 3696
#include <iostream>
using namespace std;
 
int total;
string S;
string T;
 
int main(){
  cin >> S >> T;
  total = 0;
  if(S[0] == T[0]){
    total++;
  }
  if(S[1] == T[1]){
    total++;
  }
  if(S[2] == T[2]){
    total++;
  }
  cout << total;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll n, d, a;
  cin >> n >> d >> a;

  vector<pair<ll, ll>> m;
  rep(i, n) {
    ll x, h;
    cin >> x >> h;
    m.emplace_back(x, h);
  }

  sort(ALL(m));

  ll ans = 0;

  ll damage = 0;
  deque<pair<ll, ll>> bomb;

  for (auto& p : m) {
    while (!bomb.empty() && p.first >= bomb.front().first) {
      damage += bomb.front().second;
      bomb.pop_front();
    }

    p.second -= damage;
    if (p.second > 0) {
      ll num = p.second / a;
      if (p.second % a != 0) num++;
      bomb.emplace_back(p.first + 2 * d + 1, -num * a);
      damage += num * a;
      ans += num;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n;
	cin >>n;
	int a[n+1];
	int b;
	for(int i = 0; i < n; i++){
		cin >>b;
		a[b]= i+1;
	}
	for(int i = 1 ; i <= n; i++)cout<<a[i]<<" ";
}
int main(){
	
	solve();
	
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	crap;
	ll l,r,d,i;
	cin >> l >> r >> d;
	ll count  =  0 ;
	for(i=l;i<=r;++i)
		if(i%d==0)
			count++ ;
	cout << count endl ;
	return 0;
}

/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int r, g, b;
    cin >> r >> g >> b;
    
    int ans = r*100 + g*10 + b;
    
    cout << (ans % 4 ? "NO" : "YES") << endl;
    
    return 0;
    
    
}


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

int main(){
    cin >> k;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int h = 1; h <= k; h++){
                ans += __gcd(__gcd(i, j), h);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
macro_rules! numin {
      () =>{
          {
            let mut input = String::new();
              std::io::stdin()
                  .read_line(&mut input)
                .expect("Failed to read line");
              input.trim().parse().unwrap()
        }
    };
}
fn main() {
    let n :i32 = numin!();
    // let n = 0;
    if n==0 { println!("{}",1) }
    else { println!("{}",0) }
}

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

struct Namori {
    vector<vector<int>> g;
    vector<int> deg;
    Namori(int n) : g(n), deg(n, 0) { }
    void add_edge(int u, int v) {
        g[u].emplace_back(v); deg[u]++;
        g[v].emplace_back(u); deg[v]++;
    }
    enum { ISPED, INCYCLE };
    vector<int> build() {
        int n = g.size();
        queue<int> que;
        vector<int> in_cycle(n, INCYCLE);
        for (int u = 0; u < n; u++) if (g[u].size() == 1) {
            que.push(u), in_cycle[u] = ISPED;
        }
        while (!que.empty()) {
            int u = que.front(); que.pop();
            for (int v: g[u]) if (in_cycle[v]) {
                if (--deg[v] <= 1) que.push(v), in_cycle[v] = ISPED;
            }
        }
        return in_cycle;
    }
};

int main() {
    int n; cin >> n;
    Namori namori(n);
    for (int i = 0; i < n; i++) {
        int u, v; cin >> u >> v; u--, v--;
        namori.add_edge(u, v);
    }
    vector<int> in_cycle = namori.build();
    int q; cin >> q;
    while (q--) {
        int a, b; cin >> a >> b; a--, b--;
        if (in_cycle[a] && in_cycle[b]) cout << 2 << endl;
        else cout << 1 << endl;
    }
    return 0;
}


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

void swap(int &a, int &b) {
    int temp;
    temp = a;
    a = b;
    b = temp;
    return;
}

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
def main():
    x = int(input())
    list1 = list(map(int, input().split(" ")))
    result = 1

    if 0 in list1:
        print(0)
        return 
    
    for i in list1:
        result *= i
        if result > 1000000000000000000:
            print("-1")
            exit()
    print(result)

main()

Measured memory_bytes: 21784
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  int i,j,k;
  string s,b;
  while((n+m+q)!=0){
    int table[1001][40]={{}};
    fill(table[0],table[1001],1);
    int onoff[40]={};
    
    for(i=0;i<q;i++){
      cin >> s >> b;
      for(j=0;j<n;j++){
	if(s[j]=='1') {
	  if(onoff[j]==0) onoff[j]=1;
	  else onoff[j]=0;
	}
      }
      int c=0,x;
      /*
      for(j=0;j<n;j++){
	c+=onoff[j];
	if(onoff[j]==1) x=j;
      }
      if(c==1){
	for(j=0;j<m;j++){
	  if(b[j]=='1'){
	    for(k=0;k<n;k++){
	      if(k!=x) table[j][k]=1;
	    }
	  }
	}
      }
      */
      for(j=0;j<m;j++){
	if(b[j]=='1'){
	  for(k=0;k<n;k++){
	    /*
	    if(table[j][k]==0){
	      if(onoff[k]==1)
		table[j][k]=1;
	    }
	    */
	    table[j][k]*=onoff[k];
	  }
	}else{
	  for(k=0;k<n;k++){
	    //cout << j << " " << k << endl;
	    if(onoff[k]==1)
	    table[j][k]=0;
	  }
	}
      }
      /*
      int ch[1001]={},id[40]={};
      for(j=0;j<m;j++){
	for(k=0;k<n;k++){
	  if(table[j][k]==1) ch[j]++;
	  if(table[j][k]==0) id[j]=k;
	}
      }
      for(j=0;j<m;j++){
	if(ch[j]+1==n){
	  //cout <<"a"<< endl;
	  for(k=0;k<m;k++){
	    if(ch[k]+1!=n){
	      table[k][id[j]]=1;
	    }
	  }
	}
      }
      */
      
    }

    for(j=0;j<m;j++){
      /*
	int c=0,id;
	for(k=0;k<n;k++){
	  if(table[j][k]==1) c++;
	  if(table[j][k]==0) id=k;
	}
	char buf;
	if(c+1==n){
	  if(id<10) buf=id+'0';
	  else buf='A'+id-10;
	}else{
	  buf='?';
	}
	cout << buf;
      */
      int c=0,id;
      for(k=0;k<n;k++){
	c+=table[j][k];
	if(table[j][k]==1) id=k;
      }
      char buf;
      if(c==1){
	if(id<10) buf=id+'0';
	else buf='A'+id-10;
      }else{
	buf='?';
      }
      cout << buf;
    }
    cout << endl;
    cin >> n >> m >> q;
  }
  return 0;
}

Measured memory_bytes: 1356
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

enum Event{
	None,
	Move_On,
	Get,
	Lose,
};

struct Info{
	void init(){
		value = 0;
		event = None;
	}
	Event event;
	int value;
};

int main(){

	int X,Y,Z,V[4],N,E,A,next_masu;
	Event event[4] = {None,Move_On,Get,Lose};
	double dp[51][5001];
	double ans;
	Info info[51];

	while(true){
		scanf("%d %d %d",&X,&Y,&Z);
		if(X == 0 && Y == 0 && Z == 0)break;

		for(int i = 0; i <= Y; i++)info[i].init();

		for(int i = 0; i < X; i++){
			scanf("%d",&V[i]);
		}

		for(int i = 0; i < Z; i++){
			scanf("%d %d %d",&N,&E,&A);
			info[N].event = event[E];
			info[N].value = A;
		}

		for(int i = 0; i <= Y; i++){
			for(int k = 0; k <= 5000; k++)dp[i][k] = 0.0;
		}

		dp[0][0] = 1.0;

		for(int masu = 0; masu <= Y-1; masu++){
			for(int score = 0; score <= 5000; score++){
				if(dp[masu][score] == 0.0)continue;

				for(int dice = 0; dice < X; dice++){

					if(masu + V[dice] > Y){
						next_masu = Y;
					}else{
						next_masu = masu + V[dice];
					}

					if(info[next_masu].event == None){

						dp[next_masu][score] += dp[masu][score]/(double)(X);

					}else if(info[next_masu].event == Move_On){

						if(next_masu + info[next_masu].value > Y){
							next_masu = Y;
						}else{
							next_masu = next_masu + info[next_masu].value;
						}
						dp[next_masu][score] += dp[masu][score]/(double)(X);

					}else if(info[next_masu].event == Get){

						dp[next_masu][score+info[next_masu].value] += dp[masu][score]/(double)(X);

					}else{ //info[next_masu].event == Lose

						if(score < info[next_masu].value){

							dp[next_masu][0] += dp[masu][score]/(double)(X);

						}else{

							dp[next_masu][score-info[next_masu].value] += dp[masu][score]/(double)(X);
						}
					}
				}
			}
		}

		ans = 0;

		for(int i = 0; i <= 5000; i++){
			ans += (double)i*dp[Y][i];
		}

		printf("%.0f\n",floor(ans));

	}

	return 0;
}

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

int main() {
    long long n,m;
    cin >> n >> m;
    long long c=1e9+7;
    long long ans=1;
    if(n==m){
        for(int i=1;i<=n;i++){
            ans=(ans*i)%c;
        }
        ans=(ans*ans)%c;
        ans=ans*2%c;
    }
    else if(abs(n-m)==1){
        if(n>m) swap(n,m);
        for(int i=1;i<=n;i++){
            ans=ans*i%c;
        }
        ans=ans*ans%c;
        ans=ans*m%c;
    }
    else ans=0;
    cout << ans << endl;
}

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

int main() {

long long t;
t = 1;
while(t--){
	long long a, b;
	cin >> a >> b;
	long long x = a * b;
	long long y = __gcd(a, b);
	cout << x / y;
}
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prob0007
{
    class Program
    {
        const int defMoney = 100000;

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int money = defMoney;
            for (int i = 0; i < n; i++)
            {
                money += (int)(money * 0.05);
                if (money % 1000 != 0)
                    money = (money / 1000 + 1) * 1000;
            }
            Console.WriteLine(money);
            
        }


    }
}

Measured memory_bytes: 5604
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

//
struct BIT{
	int N;
	ll *bit;
	void init(int n){
		N=n;
		bit=new ll[N+1];
		rep(i,N+1)bit[i]=0;
	}
	ll sum(int i){
		ll s=0;
		while(i){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}
	void add(int i,ll x){
		i++;
		while(i<=N){
			bit[i]+=x;
			i+=i&-i;
		}
	}
	void set(int i,ll x){
		ll pre=sum(i+1)-sum(i);
		add(i,x-pre);
	}
};
//

int N,Q,M;
int s[1000010];
int t[1000010];
multiset<int> lead;
multiset<int>::ite it;

vector<pi> merge(vector<pi> v){
	int n=sz(v);
	vector<pi> res;
	vector<pi> p;
	rep(i,n){
		p.pb(mp(v[i].fir,+1));
		p.pb(mp(v[i].sec,-1));
	}
	sort(p.begin(),p.end());
	int nest=0;
	rep(i,sz(p)){
		if(nest == 0){
			res.pb(mp(p[i].fir,-1));
		}
		nest += p[i].sec;
		if(nest == 0){
			res[sz(res)-1].sec = p[i].fir;
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	/*
	vector<pi> test;
	test.pb(mp(5,6));
	test.pb(mp(6,7));
	test.pb(mp(3,5));
	test.pb(mp(3,6));
	test=merge(test);
	rep(i,sz(test))cout<<test[i].fir<<" "<<test[i].sec<<endl;
	*/
	
	BIT B;
	B.init(1<<20);
	
	scanf("%d %d",&N,&Q);
	rep(i,N){
		scanf(" %d",s+i);
		t[i]=s[i];
	}
	
	sort(t,t+N);
	M = unique(t,t+N) - t;
	
	rep(i,N){
		int id = lower_bound(t,t+M,s[i])-t;
		B.add(id,1);
	}
	
	vector<pi> ranges;
	rep(_,Q){
		char c[8];
		int x;
		scanf(" %s %d",c,&x);
		if(c[0]=='A'){
			x--;
			lead.insert(s[x]);
		}
		if(c[0]=='R'){
			x--;
			lead.erase(lead.find(s[x]));
		}
		if(c[0]=='C'){
			int lo=-1,hi=INF;
			while(lo+1<hi){
				int mi=lo+hi>>1;
				
				ranges.clear();
				for(it=lead.begin();it!=lead.end();it++){
					ranges.pb(mp(*it-mi,*it+1));
				}
				//rep(i,sz(ranges))cout<<ranges[i].fir<<" "<<ranges[i].sec<<endl;
				ranges = merge(ranges);
				//rep(i,sz(ranges))cout<<ranges[i].fir<<" "<<ranges[i].sec<<endl;
				int sum=0;
				rep(i,sz(ranges)){
					int lb1 = lower_bound(t,t+M,ranges[i].sec)-t;
					int lb2 = lower_bound(t,t+M,ranges[i].fir)-t;
					sum += B.sum(lb1) - B.sum(lb2);
				}
				//if(hi-lo<5)cout<<mi<<": "<<sum<<endl;
				if(sum >= N-x) hi=mi;
				else lo=mi;
			}
			if(hi==INF)puts("NA");
			else printf("%d\n",hi);
		}
		//for(it=lead.begin();it!=lead.end();it++)cout<<*it<<" ";cout<<endl;
	}
}

Measured memory_bytes: 17272
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

ans=0
pre=-2
for i in range(N):
  ans+=B[A[i]-1]
  if pre+1==A[i]-1:
    ans+=C[A[i]-2]
  pre=A[i]-1

print(ans)

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

const int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  ll ten = 1, nine = 1, eight = 1;
  while(n--) {
    ten *= 10;
    ten %= mod;
    nine *= 9;
    nine %= mod;
    eight *= 8;
    eight %= mod;
  }
  ll ans = (ten-nine*2+eight) %mod;
  cout << (ans + mod) %mod << endl;
  return 0;
}

Measured memory_bytes: 3596
/*
	Author  : Phumipat C.
	School  : RYW
	Language: C++
*/
#include<bits/stdc++.h>
using namespace std;
vector<long long > g[100010],child;
long long dp[100010],l[100010],r[100010],sum[100010],ans[100010];
long long n,m;
void dfs(long long now,long long p){
    dp[now] = 1;
    for(auto x:g[now]){
        if(x == p)  continue;
        dfs(x,now);
        dp[now]*=dp[x];
        dp[now]%=m;
    }
    dp[now]++;
    dp[now]%=m;
    child.clear();
    child.push_back(0);
    for(auto x:g[now]){
        if(x == p)  continue;
        child.push_back(x);
    }
    l[0] = r[child.size()] = 1;
    for(long long i=1;i<child.size();i++)
        l[i] = (l[i-1]*dp[child[i]])%m;
    for(long long i=child.size()-1;i>0;i--)
        r[i] = (r[i+1]*dp[child[i]])%m;
    for(long long i=1;i<child.size();i++)
        sum[child[i]] = (l[i-1]*r[i+1])%m;
}
void dfs2(long long now,long long p){
    if(now == 1)    ans[now] = 1;
    else            ans[now] = ((ans[p]*sum[now])+1)%m;
    for(auto x:g[now]){
        if(x == p)  continue;
        dfs2(x,now);
    }
}
int main(){
    long long u,v;
    scanf("%lld %lld",&n,&m);
    for(long long i=1;i<n;i++){
        scanf("%lld %lld",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,0);
    dfs2(1,0);
    for(long long i=1;i<=n;i++)
        printf("%lld\n",ans[i]*(dp[i]-1+m)%m);
	return 0;
}

Measured memory_bytes: 17024
a,b,c,d=input().split()
a=int(a)
b=int(b)
c=int(c)
d=int(d)
count=0
while True:
    if count%2==0:
        c=c-b
    else:
        a=a-d
    if a<=0:
        print("No")
        break
    elif c <=0:
        print('Yes')
        break
    else:
        count+=1
       

Measured memory_bytes: 9184