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

struct city{
	int p, y, wz;
	string id;
};

bool cmp(const city &x, const city &y)
{
	if(x.p < y.p || x.p==y.p && x.y<y.y) return true;
		else return false;
}

bool cmp1(const city &x, const city &y)
{
	return x.wz < y.wz;
}

string create(int p, int id){
	string sp;
	int num = 0;
	while(p){
		sp = char(p % 10 + 48) + sp;
		p /= 10;
		num++;
	}
	for(int i = 1; i <= 6 - num; i++)
		sp = '0' + sp;
	string sid;
	num = 0;
	while(id){
		sid = char(id % 10 + 48) + sid;
		id /= 10;
		num++;
	}
	for(int i = 1; i <= 6 - num; i++)
		sid = '0' + sid;
	return sp+sid;
}

int n,m;
city cc[100005];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		cin >> cc[i].p >> cc[i].y;	
		cc[i].wz = i;
	}
	sort(cc+1,cc+m+1,cmp);
	int id = 0;
	for(int i = 1; i <= m; i++){
		if (cc[i].p==cc[i-1].p){
			id++;
			cc[i].id = create(cc[i].p, id);
		}else{
			id = 1;
			cc[i].id = create(cc[i].p,id);
		}
	}
	sort(cc+1, cc+1+m, cmp1);
	for(int i = 1; i <= m; i++)
		cout << cc[i].id << "\n";
	return 0;
}

Measured memory_bytes: 8576
N = int(input())
d = []
ans = 'No'
for i in range(N):
    d.append(list(map(int,input().split())))
for i in range(N-2):
    if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1]and d[i+2][0]==d[i+2][1]:
        ans = 'Yes'
print(ans)
            
        

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int max = -1;
        int min = -1;

        for (int i = 0; i < num; i++) {
            int tmp = in.nextInt();
            max = max < 0 ? tmp
                    : max < tmp ? tmp
                    : max;
            min = min < 0 ? tmp
                    : min > tmp ? tmp
                    : min;
        }
        int ans = max - min;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define pa pair<int,int>
using namespace std;
vector<pa>G[200004];
int n,cnt;
int ans[200004];
void dfs(int x,int fa,int une){
    int nowcnt=0;
    for(int i=0;i<G[x].size();i++){
        int to=G[x][i].first;
        if(to==fa)continue;
        nowcnt++;
        if(une==nowcnt)nowcnt++;
        cnt=max(nowcnt,cnt);
        ans[G[x][i].second]=nowcnt;
        dfs(to , x , nowcnt);
    }
}
int main(){
    scanf("%d",&n);
    memset(ans,0,sizeof(ans));
    for(int i=1;i<n;i++){
        int a,b;scanf("%d%d",&a,&b);
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    cnt=0;
    dfs(1,0,0);
    printf("%d\n",cnt);
    for(int i=1;i<n;i++){
        printf("%d\n",ans[i]);
    }
    return 0;
}


Measured memory_bytes: 12160
# based on editorial

h, w, k = gets.split.map(&:to_i)
field = h.times.map { gets.chomp }

answer = 0

0.upto((1 << h) - 1) do |i|
  0.upto((1 << w) - 1) do |j|
    black = 0
    0.upto(h - 1) do |y|
      0.upto(w - 1) do |x|
        black += 1 if field[y][x] == '#' && i & (1 << y) == 0 && j & (1 << x) == 0
      end
    end
    answer += 1 if black == k
  end
end
puts answer


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


int main(){
  int k;
  string s;
  cin >> k;
  cin >> s;
  if(s.size()<=k){
    cout << s << endl;
  }else{
    for(int i=0;i<k;++i){
      cout << s[i];
    }
    cout << "...";
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3596
a,b,h,m = map(float,input().split())

bb=float(6*m)
aa=float(0.5*(h*60+m))
c=aa-bb
d=bb-aa
if c<0:
    s=d
else:
    s=c
cc=360.0-s
if cc<s:
    s=cc
import math

e = math.sqrt(a*a+b*b-2*a*b*(math.cos(math.radians(s))))
print(e)


Measured memory_bytes: 9388
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void){
   string S;
   int sum=0;
   int s=0;

   cin >> S;

   for(int i=0;i<S.length();i++){
       int tmp = (int)(S[S.length() - i -1] - '0');
       sum += tmp;
       s += tmp * pow(10, i);
   }
   if(s % sum == 0){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll N;
vector<ll> A;

void solve(){
  ll res = 0;
  ll ok = 1;
  rep(i, N){
    if(A[i] <= ok){
      ok = max(ok, A[i] + 1);
    }else{
      res += (A[i] - 1) / ok;
      ok = max(ok, 2LL);
    }
  }
  cout << res << endl;
}

int main(){
  cin >> N;
  A.resize(N);
  rep(i, N) cin >> A[i];
  solve();
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   
   ll k,n;
   cin >> k >> n;
   vector <ll> a,v;
   for(ll i=0;i<n;i++){
       ll tmp;
       cin >> tmp;
       a.push_back(tmp);
   }
   a.push_back(a[0] + k);

   for(ll i=0;i<n;i++){
       v.push_back(a[i+1] - a[i]);
   }
   sort(v.begin(), v.end());
//   for(ll i=0;i<n;i++){
//       cout << v[i] << endl;
//   }
   cout << k - v[n-1] << endl;

}

Measured memory_bytes: 4848
#include<iostream>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
int x,a,b,r,y;
cin>>x>>a>>b;
y=x-a;
r=y%b;
cout<<r;
return 0;  
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  string s;
  while(getline(cin,s),s!=".")
  {
    stack<char> t;
    bool judge=true;
    rep(i,s.size())
    {
      if(s[i]=='('||s[i]=='[') t.push(s[i]);
      else if((s[i]==')'||s[i]==']'))
      {
        if(t.empty())
        {
          judge=false;
          break;
        }
        else if(s[i]==')'&&t.top()=='(') t.pop();
        else if(s[i]==']'&&t.top()=='[') t.pop();
        else 
        {
          judge=false;
          break;
        }
      } 
    }
    if(!t.empty()) judge=false;
    if(judge) print("yes");
    else print("no");

  }

  return 0;
}


Measured memory_bytes: 3136
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 
p = int(readline())
if p % 2 == 1:
    print(0)
else:
    p //= 2
    ans = 0
    while p:
        p //= 5
        ans += p
    print(ans)

Measured memory_bytes: 3060
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	string a,b,c;
	cin>>a>>b>>c;
	if((a[(int)a.length()-1]==b[0])&&(b[(int)b.length()-1]==c[0])) cout<<"YES";
	else cout<<"NO";
}//1 0 2 3 1
//1 1 3 6 7

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

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

const int MOD=1000000007; //10^9+7

int main() {
    int N;
    cin>>N;
    vector<pii> p(N);
    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        p[i]=make_pair(x,y);
    }
    //道の数はN*(N-1)/2 経路数はN! 1つの道が使われる回数は(N-1)!*2
    double total=0.0;
    for(int i=0;i<N-1;i++){
        for(int j=i;j<N;j++){
            double dx=p[i].first-p[j].first;
            double dy=p[i].second-p[j].second;
            total+=sqrt(dx*dx+dy*dy);
        }
    }
    cout<<setprecision(10)<<total*2/N<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define MAX 1000000

int main(void){
  int n,t;
  int menu[30],flg[MAX+1],prime[MAX+1];
  int i,j,min=MAX+1;
  for(i=0;i<=MAX;i++) prime[i]=0;
  for(i=3;i<=MAX;i+=2) prime[i]=1;
  prime[2]=1;
  for(i=3;i*i<=MAX;i+=2){
    if(!prime[i]) continue;
    else for(j=2*i;j<=MAX;j+=i) prime[j]=0;
  }

  while(scanf("%d %d",&n,&t) && (n || t)){
    for(i=0;i<n;i++){
      scanf("%d",&menu[i]);
      if(min>menu[i]) min=menu[i];
    }
    memset(flg,0,sizeof(flg));
    for(j=menu[0];j<=t;j+=menu[0]) flg[j]=1;
    flg[0]=1;
    for(i=1;i<n;i++){
      for(j=menu[i];j<=t;j++){
	if(flg[j] || flg[j-menu[i]]) flg[j]=1;
      }
    }
    for(i=t;i>=min;i--){
      if(prime[i] && flg[i]){
	printf("%d\n",i);
	break;
      }
    }
    if(i<min) puts("NA");
  }
  return 0;
}

  

Measured memory_bytes: 8432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll n , m , l ;

ll w=100000000000;
struct edge {
    ll to;
    ll cost;
    edge() {}
    edge(ll to, ll cost) : to(to), cost(cost) {};
};
vector<ll> dijkstra(ll s, vector<vector<edge>> &g)
{
  //pair.first=距離,pair.second=点
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
  vector<ll> dist(g.size(), INF);
  dist[s] = 0;
  q.push({0, s});

  while (!q.empty())
  {
    pair<ll, ll> p = q.top();
    q.pop();
    ll v = p.second;
    if (dist[v] < p.first)
      continue;
    rep(i, g[v].size())
    {
      edge e = g[v][i];
      ll dd;
      if(e.cost>l)continue;
      if(dist[v]%w+e.cost>l)dd=(dist[v]/w)*w+w+e.cost;
      else dd=dist[v]+e.cost;
      if (dist[e.to] > dd)
      {
        dist[e.to] = dd;
        q.push({dist[e.to], e.to});
      }
    }
  }
  return dist;
}
int main()
{
cin >> n >> m >> l ;
vector<vector<edge>> g(n);
rep(i,m){
  ll a , b , c ;
  cin >> a >> b >> c ;
  g[a-1].emplace_back(b-1,c);
  g[b-1].emplace_back(a-1,c);
}
ll q ;
cin >> q ;
vector<vector<ll>> v(n);
rep(i,n)v[i]=dijkstra(i, g);
rep(i,q){
  ll s , t ;
  cin >> s >> t ;
  cout <<(( (v[s-1][t-1]/w)>100000 ) ? -1 : (v[s-1][t-1]/w) )<< endl;
  
}

return 0;
}

Measured memory_bytes: 3584
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)

for i in range(n):
  if x[i] <= y[(n//2) - 1]:
    print(y[(n//2)])
  elif x[i] >= y[(n//2)]:
    print(y[(n//2) - 1])

Measured memory_bytes: 25556
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

int main () {
  int N;
  cin >> N;
  int sum = 0;
  for (auto i = 1; i <= N; i++) {
    sum += i;
    if (sum >= N) {
      int exclude = sum - N;
      for (auto j = 1; j <= i; j++) {
        if (j == exclude) continue;          
        cout << j << endl;
      }
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int gcd(int, int);
int main(){
  int x,y;
  scanf("%d%d", &x, &y);
  printf("%d\n",gcd(x, y));
    return 0;
}
int gcd(int x, int y){
  int r;
  if(x < y){
    r = x;
    x = y;
    y = r;
  }

  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for(int i = 1; i < n-1; i++){
        if((p[i-1] < p[i]) && (p[i] < p[i+1])) ans++;
        else if((p[i-1] > p[i]) && (p[i] > p[i+1])) ans++;
    }
    // for(int i = 1; i < n-1; i++){
    //     cout << p[i-1];
    //     cout << p[i];
    //     cout << p[i+1];
    //     if((p[i-1] < p[i]) && (p[i] < p[i+1])) printf(" True\n");
    //     else if((p[i-1] > p[i]) && (p[i] > p[i+1])) printf(" True\n");
    // }
    cout << ans << endl;
    return 0;
};

Measured memory_bytes: 384
#include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
    double r ;
    cin >> r ;
    const double PI=3.14159265358979323846;

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

 


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a==c&&b==c){
    cout<<1<<endl;
  }else if(a==b||b==c||c==a){
    cout<<2<<endl;
  }else{
    cout<<3<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedLists     #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}

import           Control.Monad
--import           Control.Monad.Loops
import           Data.IORef
import           Data.Maybe
import qualified Data.Text     as T
import qualified Data.Text.IO  as T
import           GHC.Base
import           System.IO

import qualified Data.Array    as A
import qualified Data.IntMap   as I
import           Data.List
import qualified Data.Map      as M
import qualified Data.Set      as S
import qualified Data.Vector   as V

-- for Text
(+.+) = T.append
(!.!) = T.index

-- for Vector
count :: (a -> Bool) -> V.Vector a -> Int
count p = V.length . V.filter p

-- for IO
readT :: Read a => T.Text -> a
readT = read . T.unpack

getLineSpc :: Read a => IO [a]
getLineSpc = do
  t <- T.getLine
  let xs = map readT $ T.split (== ' ') t
  return xs

getLineSpcVec :: Read a => IO (V.Vector a)
getLineSpcVec = do
  t <- T.getLine
  let xs = V.fromList $ map readT $ T.split (== ' ') t
  return xs

-- main
main :: IO ()
main = coins

coins :: IO ()
coins = do
  a :: Int <- readLn -- 500
  b :: Int <- readLn -- 100
  c :: Int <- readLn -- 50
  x :: Int <- readLn
  let ansList = [ (a', b', c')
                | a' <- [0..a]
                , b' <- [0..b]
                , c' <- [0..c]
                , 500 * a' + 100 * b' + 50 * c' == x
                ]
  print $ length ansList
  return ()

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    for(int i=s.size()-t.size()+1;i>=0;i--){
    //rep(i,0,s.size()-t.size()+1){
        bool ok=true;
        rep(j,i,t.size()+i){
            //cout<<s[j];
            if(!(s[j]=='?'||s[j]==t[j-i]))ok=false;
        }
        //cout<<endl;
        if(ok){
            rep(j,0,s.size()){
                if(i<=j&&j<=i+t.size()-1){
                    cout<<t[j-i];
                }else {
                    if(s[j]=='?')cout<<"a";
                    else cout<<s[j];
                }
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<"UNRESTORABLE";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    // 11:07-
    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            int N = sc.nextInt();
            int[] vs = new int[N];
            int[] cs = new int[N];
            for (int i = 0; i < N; i++) vs[i] = sc.nextInt();
            for (int i = 0; i < N; i++) cs[i] = sc.nextInt();

            long ret = 0L;
            for (int i = 0; i < vs.length; i++) {
                int delta = vs[i] - cs[i];
                if (delta > 0) ret += delta;
            }

            out.println(ret);
        }
    }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long int
#define REP(i,a,b)  for(i=a;i<=b;i++)
#define REPr(i,a,b) for(i=b;i>=a;i--)
#define pi 3.14159265358979323846
#define pb push_back
#define umap(x,y) unordered_map<x,y>
#define f first
#define s second
using namespace std;

//intialization for a tree
vector<int> adj[100005];
bool visited[100005]={false};

void solve(){
    string s,t; cin>>s>>t;
    int i;
    int counter=0;
    REP(i,0,t.size()-1) if(s[i]!=t[i])  counter++;
    cout<<counter<<endl;
}

int main(){
    int t;
    t=1;

    while(t--){
        solve();
    }
}

Measured memory_bytes: 6276
#include<iostream>
#include<map>
#include<string>
using namespace std;

int main() {
  map<string,int> a;
  int n;
  string s;

  cin >> n;
  for ( int i = 0; i < n; i++) {
    cin >> s;
    if ( a.count(s) == 0 ) {
      a[s] = 1;
    }
  }

  if ( a["Y"] == 1 ) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }

  return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();
		int a[] = new int[N];

		long sum = 0;

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt()-1;
			sum += a[i];
		}
		System.out.println(sum);
	}
}


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

int main(){
    long long n, l;
    cin >> n >> l;

    long long n_sum = n*l + n*(n-1)/2;

    long long min_delta = 1e12;
    long long minv;

    for(long long i = 0; i < n; i++){
        long long sum = n_sum - (l+i);
        if(min_delta > abs(n_sum - sum)){
            min_delta = abs(n_sum - sum);
            minv = sum;
        }
    }
    cout << minv << endl;
    return 0;
}

Measured memory_bytes: 3600
#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>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

//m^n
mint f(int m, int n) {
	if (0 == n) {
		return 1;
	}
	mint x = f(m, n / 2);
	x *= x;
	if (1 == n % 2) {
		x *= (mint)m;
	}
	return x;
}
// nCa
mint choose(int n, int a) {
	mint x = 1;
	mint y = 1;
	for (int m = 0; m < a; ++m) {
		x *= (mint)(n - m);
		y *= (mint)(a - m);
	}
	return x / y;
}

int main() {
	int r1,c1,r2,c2;
	cin >>r1 >> c1>> r2>>c2;
	mint ans = 0;
	ans += choose(r2 + c2 + 2,c2 + 1) -1;
	ans -= choose(c2 + r1 - 1 + 2,c2 + 1)-1;
	ans -= choose(c1 + r2 -1 + 2,r2 + 1)-1;
	ans += choose(c1+r1-2 + 2,c1-1 + 1)-1;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s1,s2;
    cin>>s1>>s2;
    int res=0;
    FOR(i,0,s1.size()){
        if(s1[i] != s2[i]) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3764
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a= 2*x - y/2;
		int b= y/2 - x;
		if (a+b == x && 2*a+4*b == y && a >= 0 && b>=0){
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
		return;
	}

}


Measured memory_bytes: 35752
#include <iostream>
using namespace std;
#define INF 100000000

int main(){
    int h,n;
    cin >> h >> n;
    int atc[n],mp[n];
    int maxatc = 0;
    for(int i = 0;i<n;i++){
        cin >> atc[i] >> mp[i];
        maxatc = max(maxatc,atc[i]);
    }
    int m = h+maxatc+1;
    int dp[m][n+1];
    int ans = INF;
    for(int i = 0;i<m;i++){
        dp[i][0] = INF;
    }
    for(int j = 0;j<n+1;j++){
        dp[0][j] = 0;
    }
    for(int i = 1;i<m;i++){
        for(int j = 0;j<n;j++){
            if(atc[j]>i){
                dp[i][j+1] = dp[i][j];
            }else{
                dp[i][j+1] = min(dp[i][j],dp[i-atc[j]][j+1]+mp[j]);
            }
        }
        if(i>=h)ans = min(ans,dp[i][n]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 44032
fn main(){
    let nxt: Vec<usize> = read_vec();
    let ans: usize = (nxt[0] + nxt[1] - 1) / nxt[1] * nxt[2];
    println!("{}", ans)
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 110, M = 1010;

int n, m;
int w[N], v[N];
map<int, int> f[2];

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i ++ ) cin >> w[i] >> v[i];
	
	int t = 0;
	f[t][0] = 0;
	for (int i = 1; i <= n; i ++ )
	{
		t ^= 1;
		for (auto u : f[t ^ 1])
		{
			f[t][u.F] = max(f[t][u.F], u.S);
			if (w[i] + u.F <= m)
				f[t][u.F + w[i]] = max(f[t][u.F + w[i]], u.S + v[i]);
		}
	}
	
	int res = 0;
	for (auto u : f[t]) res = max(res, u.S);
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l;
int main() {
           cin>>n;
           a=100;
           while(a<n) {
                      a+=(a/100);
                      k++;
           }
           cout<<k;
}

Measured memory_bytes: 3592
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD =998244353;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<LL>>g;
vector<edge>edges;
vector<Pll>v;
map<Pll, Pll>ma;
set<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
int main() {
	cin >> n;
	cin >> str;
	LL x = 0, y = 0, z = 0;
	ans = 1;
	for (int i = 1; i <= n; i++)
		ans *= i, ans %= MOD;
	rep(i, n * 3) {
		if (str[i] == 'R') {
			a[0] = x;
			a[1] = max(y, z);
			a[2] = min(y, z);
			x++;
		}
		if (str[i] == 'G') {
			a[0] = y;
			a[1] = max(x, z);
			a[2] = min(x, z);
			y++;
		}
		if (str[i] == 'B') {
			a[0] = z;
			a[1] = max(y, x);
			a[2] = min(y, x);
			z++;
		}
		if (a[0] >= a[1]) {}
		else if (a[0] >= a[2]) {
			ans *= a[1] - a[0];
		}
		else {
			ans *= a[2] - a[0];
		}
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <queue>

using namespace std;

#define ll long long

int main(){

    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<int>> a(n, vector<int>(m));
    vector<vector<int>> b(m, vector<int>(l));
    vector<vector<ll>> c(n, vector<ll>(l));

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){
            cin >> b[i][j];
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            for(int k=0; k<m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }    

    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            cout << c[i][j];
            if(j != l-1) cout << " ";
        }
        cout << endl;
    }


    return  0;
}

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

int main()
{
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) puts("Yes");
    else    puts("No");
    return  0;
}


Measured memory_bytes: 256
N = int(input())
red = [list(map(int,input().split())) for i in range(N)]
# yについて降順にソート
red = sorted(red,key=lambda x:(-x[1]))
blue = [list(map(int,input().split())) for i in range(N)]
# xについて昇順にソート
blue = sorted(blue,key=lambda x:(x[0]))
cnt = 0
pair = []
for i in range(N):
    b_x = blue[i][0]
    b_y = blue[i][1]
    for j in range(N):
        index = 0
        for e in red:
            a_x = e[0]
            a_y = e[1]
            if b_x > a_x and b_y > a_y:
                cnt += 1
                pair.append([blue[i],e])
                del red[index]
                break
            index += 1
        else:
            continue
        break
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
// #define scanf " %s codekaze quiz"

using namespace std;
int main()
{   
    long x;
    cin>>x;
    long ans=0;
    int fives = x/500;
    int twos = (x%500)/5;
    ans+=(fives*1000);
    ans+=(twos*5);
    cout<< ans;
   
    return 0;
}

Measured memory_bytes: 256
#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 all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;
 
int main( void ){
	
	int h, w;
	cin >> h >> w;
	char s[ 60 ][ 60 ];
	rep( i, 60 ){
		rep( j, 60 ){
			s[ i ][ j ] = '.';
		}
	}
	
	FOR( i, 1, h + 1 ){
		FOR( j, 1, w + 1 ){
			cin >> s[ i ][ j ];
		}
	}
	
	bool ok = true;
	FOR( i, 1, h + 1 ){
		FOR( j, 1, w + 1 ){
			if( s[ i ][ j ] == '#' ){
				if( s[ i - 1 ][ j ] == '#' or s[ i + 1 ][ j ] == '#' or s[ i ][ j - 1 ] == '#' or s[ i ][ j + 1 ] == '#' ){
				}else{
					ok = false;
				}
			}
		}
	}
	
	if( ok == true ){
		cout << "Yes" <<endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    S = input()
    T = input()

    res = 0

    for i in range(len(S)):
        if S[i] != T[i]:
            res +=1
    
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10656
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;


int main() {
	
	int index = 0;

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx = y2 - y1; 
	int dy = x2 - x1;

	cout << x2 - dx << " " << y2 + dy << " " << x1 - dx << " " << y1 + dy << endl;
		
}


Measured memory_bytes: 256
import sys

N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    E[a-1].append((b-1, c))
    E[b-1].append((a-1, c))

Q, K = map(int, input().split())
dist = [0] * N
sys.setrecursionlimit(2 * N)
def rec(v, pred, d):
    dist[v] = d
    for u, c in E[v]:
        if u == pred:
            continue
        rec(u, v, d + c)
rec(K-1, -1, 0)
ans = [0] * Q
for i in range(Q):
    x, y = map(int, input().split())
    ans[i] = dist[x-1] + dist[y-1]

[print(a) for a in ans]

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);

int main() {  // TODO
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];

  sort(A.begin(), A.end());
  int bigA = A[n - 1];
  vector<bool> at(bigA + 1, true);
  rep(i, A.size()) {
    if (i > 0 && A[i - 1] == A[i]) {
      at[A[i]] = false;
    }
    if (at[A[i]]) {
      int j = A[i];
      int ji = 2;
      while (j * ji <= bigA) {
        at[j * ji] = false;
        ji++;
      }
    }
  }
  int ans = 0;
  rep(i, A.size()) {
    if (at[A[i]]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 999999999
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;
typedef pair<int, int> P;

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

long int euclidean_gcd(long int a, long int b) {
    while(1) {
        if(a < b) swap(a, b);
        if(!b) break;
        a %= b;
    }
    return a;
}

int main()  {
    long int N, X;
    cin >> N >> X;
    long int x[100005];
    long int minimum;
    rep(i, N) {
        cin >> x[i];
        x[i] = abs(X - x[i]);
    }
    minimum = x[0];

    rep(i, N - 1) {
        minimum = min(minimum, euclidean_gcd(x[i], x[i + 1]));
    }

    cout << minimum << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    char input[100];
    scanf("%s", input);
    char reset[100];
    int id = 0;
    for(int i = 0; input[i] != '\0'; i++){
        if(input[i] == '0'){
            reset[id] = '0';
            id++;
        }
        if(input[i] == '1'){
            reset[id] = '1';
            id++;
        }
        if(input[i] == 'B'){
            if(id > 0){
                id--;
                reset[id] = '\0';
            }
        }
    }
    reset[id] ='\0';
    printf("%s\n", reset);
    return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
map<ll,ll> factorizee(ll n) {
  map<ll,ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        mp[n]++;
    }
    return mp;
}
int main()
{
       ll a,b;
       cin>>a>>b;
       a = __gcd(a,b);
       map<ll,ll> mp = factorizee(a);
       cout<<mp.size()+1<<endl;
}


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

using namespace std;

#define MOD 1000000007
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626

typedef long long ll;

void solve()
{
    
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    int n;
    cin>>n;
    ll a[n+1];
    for(int i=1; i<=n; i++)cin>>a[i];
    ll curr=1000;
    ll stocks=0;

    for(int i=1; i<=n-1; i++)
    {
        if(a[i+1]>a[i])
        {
            curr+=(stocks*a[i]);
            stocks=0;
            stocks=(curr/a[i]);
            curr-=(stocks*a[i]);
        }
        else
        {
            curr+=(stocks*a[i]);
            stocks=0;
        }
    }
    if(stocks>0)curr+=(stocks*a[n]);

    cout<<curr;
    
    return 0;
}

Measured memory_bytes: 3632
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect::<Vec<usize>>();
    let mut p = vec![0; n];
    for i in 0..n {
        p[a[i] - 1] = i + 1;
    }
    println!(
        "{}",
        p.iter()
            .map(|v| v.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    );
}

Measured memory_bytes: 13052
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int d[10][10];
int V = 10;
void warshall_floyd() {
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0;j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
// d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF、ただしd[i][i]=0とする) // 頂点数

int main(){
	int h,w;cin>>h>>w;
	for(int i = 0; i <= 9; i++) {
		for(int j = 0; j <= 9; j++) {
			cin >> d[i][j];
		}
	}
	warshall_floyd();
	ll ans = 0;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			int x;cin>>x;
			if(x != -1){
				ans += d[x][1];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque, defaultdict
N, M = map(int, input().split())
G = defaultdict(list)
for _ in range(M):
    p, q, c = map(int, input().split())
    G[(p-1, c-1)].append((p-1, -1))
    G[(q-1, c-1)].append((q-1, -1))
    G[(p-1, -1)].append((p-1, c-1))
    G[(q-1, -1)].append((q-1, c-1))
    G[(p-1, c-1)].append((q-1, c-1))
    G[(q-1, c-1)].append((p-1, c-1))


dist = defaultdict(lambda :-1)
que = deque([(0, -1)])
dist[(0, -1)] = 0
while que:
    v = que.pop()
    d = dist[v]
    for nv in G[v]:
        if dist[nv]<0:
            if nv[1] == -1:
                dist[nv] = d+1
                que.appendleft(nv)
            else:
                dist[nv] = d
                que.append(nv)
print(dist[(N-1, -1)])





Measured memory_bytes: 196472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <stack>
#include <queue>
#include <set>

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

typedef long long ll;
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES";
    else cout << "NO";
    return 0;
}

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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int H, W, sh, sw, gh, gw;
  cin >> H >> W >> sh >> sw >> gh >> gw;
  sh--, sw--, gh--, gw--;
  int st = 0, go = 0;
  vector<vector<pair<int, char>>> S(H, vector<pair<int, char>>(W));
  for (int i = 0, id = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      if (i == sh && j == sw) st = id;
      if (i == gh && j == gw) go = id;
      S.at(i).at(j) = {id++, c};
    }
  }
  
  vector<int> mh(4), mw(4);
  mh = {-1, 0, 1, 0};
  mw = {0, 1, 0, -1};

  Dijkstra<long> D(H * W);
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      for (int i = h - 2; i <= h + 2; i++) {
        for (int j = w - 2; j <= w + 2; j++) {
          if (i < 0 || i >= H || j < 0 || j >= W) continue;
          if (S.at(i).at(j).second == '.') D.add(S.at(h).at(w).first, S.at(i).at(j).first, 1);
        }
      }
      for (int i = 0; i < 4; i++) {
        int nh = h + mh.at(i);
        int nw = w + mw.at(i);
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (S.at(nh).at(nw).second == '.') D.add(S.at(h).at(w).first, S.at(nh).at(nw).first, 0);
      }
    }
  }

  D.solve(st);

  if (D.dist.at(go) == LONG_MAX) return cout << -1 << "\n", 0;
  cout << D.dist.at(go) << "\n";
}

Measured memory_bytes: 368556
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int n, k, v[101];

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	
	int ans = 0;
	for(int i = 0; i <= min(k, n); i++){
		for(int j = 0; j+i <= min(k,n); j++){
			int cnt = 0;
			vector<int> have;
			for(int d = 0; d < i; d++){
				have.push_back(v[d]);
				cnt += v[d];
			}
			for(int d = n-1; d >= n-j; d--){
				have.push_back(v[d]);
				cnt += v[d];
			}
			sort(have.begin(),have.end());
			for(int d = 0; d < k-i-j; d++){
				if(i+j <= d) break;
				if(have[d] < 0){
					cnt -= have[d];
				}
			}
			ans = max(ans, cnt);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 1000

int initialize();
int isEmpty();
int isFull();
void push(int);
int pop();

int top;
int S[100];

int main(){
  int x;
  char s[100];
  int a,b;
  while(scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
      
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b - a);

    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
      
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[top]);
  return 0;
}

int initialize(){
  top = 0;
}

int isEmpty(){
  if(top == 0) return 1;
  else return 0;
  
}

int isFull(){
  if(top >= MAX - 1) return 1;
  else return 0;

    }

void push(int x){
  if (isFull() == 1) printf("??¨?????????????????????????????????\n");
  else{
    top++;
    S[top] = x;
	     }
}
int pop(){
  if (isEmpty() == 1)printf("?????¢???????????¨?????????\n");
  else{
    top--;
    return S[top+1];
	      }
}

Measured memory_bytes: 548