akhauriyash/Code-Regression huggingface dataset:
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	string s, t;
	cin >> s >> t;
	ll lenS = s.length(), lenT = t.length();
	if(lenS < lenT){
		puts("UNRESTORABLE");
		return 0;
	}

	repr(i, lenS-lenT){
		string str = s.substr(i, lenT);
		bool flg = true;
		rep(j, lenT){
			if(str[j] != t[j] && str[j] != '?'){
				flg = false;
				break;
			}
		}
		if(flg){
			s.replace(i, lenT, t);
			rep(i, lenS){
				if(s[i] == '?') cout << 'a';
				else cout << s[i];
			}
			cout << endl;
			return 0;
		}
	}

	puts("UNRESTORABLE");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 998244353;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
const int biggg = 2000000000;
const long long bigggest = 1000000000000000000LL;
const double eps = .0000000001; 

int main ()
{
  prep();
  string s;
  cin >> s;
  deque<char> d;
  for (char i : s) d.push_front(i);
  int q;
  cin >> q;
  bool switchh = false;
  for (int i=0; i<q; i++){
      int w;
      cin >> w;
      if (w == 1) switchh = !switchh;
      else{
          int w2;
          cin >> w2;
          char c;
          cin >> c;
          if (((w2 == 1)+switchh)%2){
              d.push_back(c);
          }else{
              d.push_front(c);
          }
      }
  }
  if (!switchh){
      for (int i : d){
          cout << d.back();
          d.pop_back();
      }
  } else{
       for (int i : d){
           cout << d.front();
           d.pop_front();
       }
  }
 
  return 0;
}

Measured memory_bytes: 976
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    a,b,c,d= map(int, sys.stdin.readline().split(' '))
    f=1
    while(1):
        if(f):
            c-=b
            if(c<=0):
                break
        else:
            a-=d
            if(a<=0):
                break
        f=f^1
    if(a<=0):
        print("No")
    else:
        print("Yes")
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 9112
def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    tmp = 1
    ans = 0
    for i in a:
        if i == tmp:
            tmp += 1
        else:
            ans += 1

    if tmp == 1:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (int i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 10;
int n, d, x[nsz + 5][nsz + 5], ans;

bool inline is_sq(int a) {
    cont (i, 5e2) {
        if (i * i == a)  return 1;
    }
    return 0;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> d;
    cont (i, n) {
        cont (j, d) {
            cin >> x[i][j];
        }
    }
    cont (i, n) {
        circ (j, i + 1, n) {
            int cur = 0;
            cont (k, d) {
                cur += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if (is_sq(cur)) {
                ++ans;
            }
        }
    }
    cout << ans << endl;
}


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

static const int MAX = 10000;
static const int INFTY  = (1 << 20);

static const int WHITE = 0;
static const int GRAY  = 1;
static const int BLACK = 2;



int n;
vector<pair<int, int>> adj[MAX];
//グラフの隣接リスト表現(重み付き有向)　first:隣接頂点，second; コスト

void dijkstra(){
  priority_queue<pair<int, int>> PQ;  //各隣接頂点の始点からのコストのキュー
  int color[MAX]; //訪問状況
  int d[MAX];     //始点から各頂点までの最小コスト
  //初期化
  for(int i = 0; i < n; ++i){
    d[i] = INFTY;
    color[i]  = WHITE;
  }

  //始点のコストｄ[0]と，，priority_quwueに代入
  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;


  //最短経路の探索ループ

  while( !PQ.empty() ){
     //最小コストの頂点を取得し，確定
    pair<int, int> f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    //最小値を取り出し，それが最短でなければ無視
    if( d[u] < f.first*(-1) ) continue;

    for(int j = 0; j < adj[u].size(); ++j){
      int v = adj[u][j].first;
      if( color[v] == BLACK ) continue; //確定した頂点は飛ばす

      //最小コストを比較して，　更新
      if( d[v] > d[u] + adj[u][j].second ){
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v]* (-1), v));
        //priority_queueは大きい値を優先するため，−１をかける．
        color[v] = GRAY;
      }
    }
  }

  for( int i = 0; i < n; i++ ){
    cout << i << " "  << (d[i] == INFTY ? -1 : d[i]) << endl;
  }


}

int main(){
  //Input
  int k, u, v, c; //頂点uに隣接する頂点の数， 頂点, 頂点ｋに隣接する頂点, u>vのコスト
  cin >> n;

  REP(i,n){
    cin >> u >> k;
    REP(j,k){
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  //
  dijkstra();

  return 0;
}


Measured memory_bytes: 7996
#include <iostream>
using namespace std;
int main(void){
    int h1,h2,k1,k2,a,b,c,d;
    cin>>h1>>h2;
    cin>>k1>>k2;
    cin>>a>>b>>c>>d;
    int H,K;
    H=h1*a+h2*b+(h1/10)*c+(h2/20)*d;
    K=k1*a+k2*b+(k1/10)*c+(k2/20)*d;
    if(K==H)    cout<<"even";
    if(K>H) cout<<"kenjiro";
    if(K<H) cout<<"hiroshi";
    cout<<endl;
}



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

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

	int x = 1;
	while (true) {
		if (b - a == x) {
			break;
		}
		x++;
	}
	
	int y = 0;
	for (int i = 1; i <= x - 1; i++) y += i;

	cout << y - a << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 16/Feb/20 05:36:53 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	bool flag = 0;
	fr (i, 0, n) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 3 == 0 or x % 5 == 0)
				continue;
			else
				flag = 1;
		}
	}
	if (flag) {
		pr ("DENIED");
	} else {
		pr ("APPROVED");
	}

	return 0;
}

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

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

    for(int i=0;i<N;i++){
        int distance,num;
        for(int j=0;j<M;j++){
            int dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(j==0){
                distance=dis;
                num=j+1;
            }else if(distance>dis){
                distance=dis;
                num=j+1;
            }
        }
        cout<<num<<endl;

    }

    return 0;
}


Measured memory_bytes: 256
/* ***************************************
Author        :Scau.ion
Created Time  :2016/10/10 19:56:54 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=200010;

struct edge
{
    int val;
    bool ty;
    bool operator <(const edge &b)const
    {
        return val<b.val;
    }
}ed[maxn];

int main()
{
    int n[2];
    scanf("%d%d",&n[0],&n[1]);
    int nn=n[0]+n[1];
    for (int j=1;j<=n[0];++j)
    {
        scanf("%d",&ed[j].val);
        ed[j].ty=0;
    }
    for (int j=1;j<=n[1];++j)
    {
        scanf("%d",&ed[n[0]+j].val);
        ed[n[0]+j].ty=1;
    }
    sort(ed+1,ed+nn+1);
    LL ans=0;
    for (int j=1;j<=nn;++j)
    {
        ans+=1LL*ed[j].val*(n[!(ed[j].ty)]+1);
        --n[(ed[j].ty)];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
// https://atcoder.jp/contests/abc050/tasks/arc066_a

#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

ll N, A, cnt;
vector<int> c;

int main()
{
  cin >> N;

  REP(i, N)
  {
    c.push_back(0);
  }
  REP(i, N)
  {
    cin >> A;
    c[A]++;
  }

  cnt = 1;
  bool f = c[0] == N % 2;
  FOR(i, 1, N)
  {
    if (!f)
      break;
    else if (i % 2 != N % 2)
    {
      if (c[i] == 2)
        cnt = (cnt * 2) % (ll)(pow(10, 9) + 7);
      else
        f = false;
    }
    else if (c[i] != 0)
      f = false;
  }

  cout << (f ? cnt : 0) << '\n';

  return 0;
}


Measured memory_bytes: 892
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

from collections import Counter

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)
    L = Counter(it)
    ky = sorted(L.keys())
    n = len(ky)

    ans = 0
    for i in range(n-2):
        a = ky[i]
        ai = L[a]
        for j in range(i+1, n-1):
            b = ky[j]
            bi = L[b]
            ab = a + b
            for k in range(j+1, n):
                c = ky[k]
                ci = L[c]
                if ab <= c:
                    break
                ci = L[c]
                ans += ai * bi * ci
    print(ans)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 68348
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n = 1;
  long long x;

  cin >> x;
  
 
  if(x % 11 == 0){
    cout << (x / 11) * 2 << endl;
  }else if(x % 11 > 6){
    cout << (x / 11) * 2 + 2 << endl;
  }else if(x % 11 <= 6){
    cout << (x / 11) * 2 + 1 << endl;
  }
  return 0;
}

    


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

int main(){
	int k,n;
  	cin>>k>>n;
  	int arr[n]={};
  	for(int i=0;i<n;i++){
    	int d;
      	cin>>d;
      	arr[i]=d;
    }
  	int diff=0;
  	for(int i=1;i<n;i++){
    	int d = arr[i] - arr[i-1];
      	diff = max(diff,d);
    }
  	int last = k - arr[n-1] + arr[0];
  	diff = max(diff,last);
  	cout<<k-diff;
  	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


int main(){
    int N;
    cin >> N;
    vector<vector<int>> to(N, vector<int>()), cost(N, vector<int>()); // 隣接リスト。ある頂点につながっている頂点を保存

    rep(i, N-1) {
        int a, b, w;
        cin >> a >> b >> w;
        --a; --b;
        to[a].push_back(b); cost[a].push_back(w);
        to[b].push_back(a); cost[b].push_back(w);
    }
    
    vector<int> ans(N, -1);
    queue<int> q;
    ans[0] = 0; // 根に0を塗る。
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();

        rep(i, to[v].size()) {
            int u = to[v][i];
            int w = cost[v][i];
            if (ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }

    rep(i, N) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 11904
import sys
sys.setrecursionlimit(10**9)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

H, W = mi()
C = li2(10)
a = li2(H)
memo = [C[i][1] for i in range(10)]
flag = -1
'''
def dfs(column, m):
    if column == 1:
        global flag
        flag = max(m, flag)
    for i in range(10):
        if i!=column and C[column][i] < m:
            dfs(i, m-C[column][i])
    #return

for i in range(10):
    if i != 1:
        dfs(i, C[i][1])
        if flag != -1:
            memo[i] = C[i][1]-flag
        flag = -1
'''
flag = 10**9

def dfs(col, m):
    if col == 1:
        global flag
        flag = min(m, flag)
    for i in range(10):
        if i != col and m + C[col][i] < lim:
            dfs(i, m + C[col][i])

for i in range(10):
    if i != 1:
        flag = 10**9
        lim = C[i][1]
        dfs(i, 0)
        if flag != 10**9:
            memo[i] = flag

ans = 0
for i in range(H):
    for j in range(W):
        if abs(a[i][j]) != 1:
            ans += memo[a[i][j]]

print(ans)

Measured memory_bytes: 46044
#include<bits/stdc++.h>
using namespace std; 
int main(){
  string S;
  cin>>S;
  for(int i=2; i<S.size(); i+=2){
    int m = (S.size()-i)/2;
    string s1 = S.substr(0, m);
    string s2 = S.substr(m, m);
    if (s1 == s2) {
      cout << m * 2 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<" "<<x<<"\n";
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main() {
	cr7
	ll n;
	cin >> n;
	unordered_map<ll,ll> arr;
	arr[0]++;
	for(ll i=1;i < n;i++) {
		int a;
		cin >> a;
		arr[a]+=1;
	}
	for(ll i=0;i < n-1;i++){
	    cout<<arr[i+1]<<"\n";
	}
	cout<<"0\n";
}

Measured memory_bytes: 11492
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    if(b >= a * c){
        cout << c << endl;    
    }
    else{
        cout << b / a << endl;
    }


}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int x[500000];
int y[500000];
vector<int>bag[201][201];
int dx[]={1,1,1,0,0,0,-1,-1,-1};
int dy[]={1,0,-1,1,0,-1,1,0,-1};
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",x+i,y+i);
		x[i]+=10000;
		y[i]+=10000;
		bag[x[i]/100][y[i]/100].push_back(i);
	}
	int ret=999999999;
	if(a<=100){
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++)ret=min(ret,(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
		printf("%d\n",ret);
		return 0;
	}
	for(int i=0;i<a;i++){
		int R=x[i]/100;
		int W=y[i]/100;
		for(int j=0;j<9;j++){
			if(0<=R+dx[j]&&R+dx[j]<201&&0<=W+dy[j]&&W+dy[j]<201){
				for(int k=0;k<bag[R+dx[j]][W+dy[j]].size();k++){
					if(i!=bag[R+dx[j]][W+dy[j]][k])
					ret=min(ret,(x[i]-x[bag[R+dx[j]][W+dy[j]][k]])*(x[i]-x[bag[R+dx[j]][W+dy[j]][k]])+(y[i]-y[bag[R+dx[j]][W+dy[j]][k]])*(y[i]-y[bag[R+dx[j]][W+dy[j]][k]]));
				}
			}
		}
	}
	printf("%d\n",ret);
}

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

int main()
{
    char c[8][8];

    for( int i = 0; i < 8; i++ )
        for( int j = 0; j < 8; j++ )
            cin >> c[i][j];

    cout << 90 << endl;
    for( int j = 0; j < 8; j++ )
    {
        for( int i = 7; i >= 0; i-- )
            cout << c[i][j];
        cout << endl;
    }
    

    cout << 180 << endl;
    for( int i = 7; i >= 0; i-- )
    {
        for( int j = 7; j >= 0; j-- )
            cout << c[i][j];
        cout << endl;
    }

    cout << 270 << endl;
    for( int j = 7; j >= 0; j-- )
    {
        for( int i = 0; i < 8; i++ )
            cout << c[i][j];
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3016
# -*- coding: utf-8 -*-
"""
Created on Sat May  5 22:10:57 2018

@author: sakas
"""

a, b, c = map(int, input().split())
K = int(input())

if a>b and a>c:
    for i in range(K):
        a *= 2
    print(a+b+c)
elif b > a and b > c:
    for i in range(K):
        b *= 2
    print(a+b+c)
else:
    for i in range(K):
        c *= 2
    print(a+b+c)

Measured memory_bytes: 3064
N = int(input())
S = list(input())

for i, Si in enumerate(S):
    ord_ans = ord(Si) + N
    if ord_ans > ord('Z'):
        ord_ans = ord('A') + (ord_ans - ord('Z') - 1)
    S[i] = chr(ord_ans)

print(''.join(S))

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

int main()
{
    int mid,final,mk_up;
    while(cin>>mid>>final>>mk_up){
    
    if(mid==-1 && final==-1 && mk_up==-1) break;
    else if(mid==-1 || final==-1 || (mid+final<30)) cout<<"F"<<"\n";
    else if(mid+final>=80) cout<<"A"<<"\n";
    else if(mid+final>=65 && mid+final<80) cout<<"B"<<"\n";
    else if(mid+final>=50 && mid+final<65) cout<<"C"<<"\n";
    else {
         if(mk_up>=50) cout<<"C"<<"\n";
         else if(mid+final>=30 && mid+final<50) cout<<"D"<<"\n";

    }
    
    }
    return 0;
}


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

long long solve(vector<vector<long long>> &dp, vector<pair<long long, long long>> &v, long long i, long long w){
        if(w<0){
        return LLONG_MIN;
    }
    if (i == v.size()){
        return 0;
    }
    if(dp[w][i] != -1){
        return dp[w][i];
    }
    long long temp;
    temp = max(v[i].second + solve(dp, v, i+1, w-v[i].first), solve(dp, v, i+1, w));
    return dp[w][i] = temp;
}

int main(){
    long long n, w;
    cin>>n>>w;
    vector<pair<long long, long long>> v(n, pair<long long, long long> {0, 0});
    vector<vector<long long>> dp(w+1, vector<long long> (n, -1));
    for(long long i = 0; i < n; ++i){
        cin>>v[i].first>>v[i].second;
    }
    long long ans = solve(dp, v, 0, w);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 85264
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin>>N;
    ll a[N];
    bool t=false;
    rep(i,0,N) {
        cin>>a[i];
        if(a[i]%2==1) t=true;
    }
    if(t) cout <<"first"<<"\n";
    else cout << "second"<<"\n";
}

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

#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);


int main(){
  faster();
  ll n;
  cin >> n;
  vl x(n);
  rep(i,n) cin >> x[i];
  sort(all(x));
  ll _min=1e9;
  REP(i,x[0],x[n-1]+1){
    ll sum = 0;
    rep(j,n){
      sum += abs(x[j]-i)*abs(x[j]-i);
    }
    _min = min(_min , sum);
  }
  cout << _min ;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((a * 100 + b * 10 + c) % 4 == 0 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    buf = input()
    buflist = buf.split()
    A = int(buflist[0])
    B = int(buflist[1])
    if A >= 13:
        print(B)
    elif A >= 6:
        print(B // 2)
    else:
        print(0)

if __name__ == '__main__':
    main()


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


int n,m;
int c[300];
int p[300][3];

int f(int k){
	int dp[301]={};
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int b=0;
			for(int a=c[i];j+a<=m;a+=c[i]){
				b+=p[i][k];
				dp[j+a]=max(dp[j+a],dp[j]+b);
			}
		}
	}
	return *max_element(dp,dp+m+1);
}

int main(){
	while(cin>>n>>m&&n){
		for(int i=0;i<n;i++){
			string s;
			cin.ignore();
			getline(cin,s);
			cin>>c[i];
			for(int j=0;j<3;j++){
				cin>>p[i][j];
			}
		}
		cout<<max(max(f(0),f(1)),f(2))<<endl;
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans=0;
  rep(i,4){
    if(s[i]=='2')ans++;
  }
  cout << ans << endl;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int result = 0;
  if (K < A) {
    result += K;
    K = 0;
  }
  else {
    result += A;
    K -= A;
  }
  if (K < B) {
    K -= 0;
  }
  else {
    K -= B;
  }
  result -= K;
  cout << result << endl;
  return 0;
}


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

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int main(){
  int64_t n, a, b;
  cin >> n >> a >> b;
  int total = min(a * n, b);

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  int X;
  int Y;
 
  N >= 1;
  N <= 10000;
  A >= 0;
  A <= 1000;
 
  cin >> N >> A;
 
  X = N / 500;
  Y = N - 500 * X;
 
  if (A >= Y) {
  cout << "Yes" << endl;
  }
  else {
  cout << "No" << endl;
}
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

n = int(input())
a = list(map(int, input().split()))

g = 1
for i in a:
    g = lcm(g, i)

ans = 0
for i in a:
    ans += g // i

print(ans % mod)

Measured memory_bytes: 4084
n, k = map(int, input().split())
a = list(map(lambda s: int(s) - 1, input().split()))

cur = 0
while k > 0:
    if k % 2 == 1:
        cur = a[cur]
    next = [a[a[i]] for i in range(n)]
    a = next
    k //= 2
print(cur + 1)


Measured memory_bytes: 169908
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

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

int main(void){
  stack<int> st;
  int buf;
  while(cin>>buf){   
    if(buf==0){
      cout<<st.top()<<endl;
      st.pop();
    }else{
      st.push(buf);
    }

  }
}

Measured memory_bytes: 1200
N = int(input())
S1 = list(input())
S2 = list(input())
i = 0
ans = 1
lis = []
while i < N:
    if S1[i] == S2[i]:
        lis.append(0)
        if(i == 0):
            ans *= 3
        else:
            if lis[-2] == 0:
                ans *= 2
        i += 1
    else:
        lis.append(1)
        if(i == 0):
            ans *= 6
        else:
            if lis[-2] == 0:
                ans *= 2
            else:
                ans *= 3
        i += 2
    ans %= 10 ** 9 + 7
print(ans)

Measured memory_bytes: 61420
n = int(input())
s = [list(input()) for i in range(n)]
ans = sorted(list(set(s[0])))
numbers = [100 for i in range(len(ans))]
for i in range(n):
  for j in range(len(ans)):
    numbers[j] = min(numbers[j], s[i].count(ans[j]))
ret = ""
for i in range(len(ans)):
  ret += ans[i]*numbers[i]
print(ret)

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
  int f=0,s=0,t=0,m;
  while(scanf("%d",&m)!=EOF){
    if(m>f){
      t=s;
      s=f;
      f=m;
    }else if(m>s){
      t=s;
      s=m;
    }else if(m>t){
      t=m;
    }
  }
  printf("%d\n%d\n%d\n",f,s,t);
  return 0;
}

Measured memory_bytes: 1028
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static int mod = (int) (1e9+7);
	static long cf = 998244353;
    static final int MAX = (int) 1e6;
    public static List<Integer>[] edges;
    public static int[][] parent;
    public static int col = 20;
    public static long[] Bit;
    public static long[] fac,inv;
    public  static int[] prime; 
    public static long[] dp;
	public static FastReader sc = new FastReader();
	public static void main(String[] args) {
	//	Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		Pair[] a = new Pair[n];
		for(int i=0;i<n;++i) {
			a[i] = new Pair(sc.next(),sc.nextInt(),i+1);
		}
		Arrays.sort(a,new Comparator<Pair>() {

			@Override
			public int compare(Pair o1, Pair o2) {
			    if(!o1.s.equals(o2.s)) return o1.s.compareTo(o2.s);
				return o2.p-o1.p;
			}
			
		});
		for(int i=0;i<n;++i) out.println(a[i].id);
		out.close();
	}
	static class Pair{
		String s;
		int p;
		int id;
		Pair(String s,int p,int id){
			this.s = s;
			this.p = p;
			this.id = id;
		}
	}
	
	
}

Measured memory_bytes: 23380
n,k = map(int,input().split())
a = [int(i)-1 for i in input().split()]
seen = []
cnt = [-1]*n
now = 0
while cnt[now] == -1:
    cnt[now] = len(seen)
    seen.append(now)
    now = a[now]
loop = len(seen)-cnt[now]
toloop = cnt[now]
if k <= toloop:
    ans = seen[k] + 1
else:
    k = (k-toloop)%loop
    ans = seen[toloop+k] + 1
print(ans)

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

int main(){
  string str;
  cin >> str;
  if(str[0]=='7'||str[1]=='7'||str[2]=='7'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}
    


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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int count = 0;
    int N = S.size();
    for (int i = 0; i < N; i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            count++;
            ans = max(ans, count);
        } else {
            count = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
bool prime(long long num);
int main(){
int A,B,M;
cin >> A >> B >> M;
vector<int>a(A);
vector<int>b(B);
vector<int>x(M);
vector<int>y(M);
vector<int>c(M);
for(int i=0;i<A;i++){
    cin >> a[i];
}

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

for(int i=0;i<M;i++){
    cin >> x[i];
    cin >> y[i];
    cin >> c[i];
}

int price=10000000;
for(int i=0;i<M;i++){
    price=min(price,a[x[i]-1]+b[y[i]-1]-c[i]);}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
price=min(price,a[0]+b[0]);

cout << price << endl;
return 0;
}
//aaa

Measured memory_bytes: 2176
S = gets.chomp.to_s              # 文字列。chompを付けないと改行文字がついてくる
moji = ('a'..'z').to_a  #配列
ans = 0
while ans < 27 do
  if moji[ans] == S then
    ans = ans + 1
    break
  end
  ans = ans + 1
end

puts moji[ans]


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

lands=[False for _ in range(N-1)]
goal_land=[]

for _ in range(M):
    a,b = map(int,input().split())
    if a == 1 or b == 1:
        if a == 1:
            lands[b-1] = True
        else:
            lands[a-1] = True
    elif a == N or b == N:
        if a == N:
            goal_land.append(b-1)
        else:
            goal_land.append(a-1)

#print(lands)
#print(goal_land)

for i in goal_land:
    if lands[i]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

Measured memory_bytes: 14252
N,*abs=$<.read.split.map(&:to_i)

h = {}
abs.each_slice(2).with_index(1) do |(a,b),i|
    h[a] ||= []
    h[a] << [b,i]
    h[b] ||= []
    h[b] << [a,i]
end

arr = Array.new(N,0)

# p h

q = [[1,0,0]]
until q.empty?
    b,i,parent = q.shift
    # p [arr,q,[b,i,parent], arr[i]]
    next if arr[i] != 0
    arr[i] = parent

    n = 0
    h[b].each do |c,j|
        next if arr[j] != 0
        n += 1
        n += 1 if n == parent
        q << [c,j,n]
    end
end

arr.shift
puts arr.max, arr

Measured memory_bytes: 49496
#include<cstdio>
#include<algorithm>
using namespace std;

int arr[100005];
int main(){
    int n, x,cnt=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(!arr[x]){
            arr[x] = 1;
            cnt++;// 记录不重复的数字
        }
    }
    printf("%d\n",(n-cnt)&1?cnt-1:cnt);
    return 0;
}


Measured memory_bytes: 512
/*input
2
4
5 7 2
4 6 1
1 5 2
6 8 1
4
1 2 1
1 2 1
1 2 1
1 2 1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int a, b;
  cin >> a >> b;
  cout << max(0, a - 2 * b) << endl;

  return 0;
} 


Measured memory_bytes: 892
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> tower(1000);
    tower[0] = 0;
    for (int i = 1; i <= 999; i++) {
        tower[i] = tower[i-1] + i;
    }
    cout << tower[b-a] - b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;
void sort(double input[][2],int k){
    if(input[k][1] > input[k+1][1]){
        double num[2];
        num[0] = input[k][0];
        num[1] = input[k][1];
        input[k][0] = input[k+1][0];
        input[k][1] = input[k+1][1];
        input[k+1][0] = num[0];
        input[k+1][1] = num[1];
    }
}
int main(){
    double input[24][2];
    double ans[9][2];
    int a,b;
    a = b = 0;
    rep(i,24){
        cin >> input[i][0] >> input[i][1];
    }
    rep(i,3){
        range(j,i*8,i*8+7){
            range(k,i*8,i*8+7){
                sort(input, k);
            }
        }
    }
    rep(i,3){
        range(j,i*8,i*8+2){
            ans[a][0] = input[j][0];
            ans[a++][1] = input[j][1];
        }
        ans[6+i][0] = input[2+i*8][0];
        ans[6+i][1] = input[2+i*8][1];
    }
    range(i,6,8){
        range(j,6,8){
            sort(ans,j);
        }
    }
    rep(i,8){
        printf("%d ",(int)ans[i][0]);
        cout << setprecision(4) << showpoint << ans[i][1] << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> p(n), a(n, -1), lp(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
        g[p[i]].emplace_back(i);
    }
    function<void(int)> dfs = [&](int v) {
        if (lp[v] != 0) return;
        lp[v] = -1;
        for (int to : g[v]) {
            dfs(to);
            if (lp[to] != 2) {
                lp[v] = 1;
            }
        }
        if (g[v].empty() || lp[v] != 1) {
            lp[v] = 2;
        }
        return;
    };
    for (int i = 0; i < n; i++) {
        if (lp[i] == 0) {
            dfs(i);
        }
    }
    debug(lp);
    function<void(int)> calc = [&](int v) {
        a[v] = 0;
        set<int> st;
        for (int to : g[v]) {
            calc(to);
            st.emplace(a[to]);
        }
        while (st.count(a[v])) {
            a[v]++;
        }
        return;
    };
    for (int i = 0; i < n; i++) {
        if (lp[i] == 1) {
            for (int j : g[i]) {
                if (lp[j] == 2) {
                    calc(j);
                }
            }
        }
    }
    debug(a);
    vector<int> x;
    for (int i = 0; i < n; i++) {
        if (lp[i] == 1) {
            int v = i;
            while (p[v] != i) {
                x.emplace_back(v);
                v = p[v];
            }
            x.emplace_back(v);
            break;
        }
    }
    debug(x);
    vector<int> tmp1, tmp2;
    int lst;
    for (int i = 0; i < x.size(); i++) {
        int m = 0;
        set<int> st;
        for (int to : g[x[i]]) {
            st.emplace(a[to]);
        }
        while (st.count(m)) {
            m++;
        }
        if (i && m == tmp1.back()) {
            tmp1.emplace_back(m + 1);
        } else {
            tmp1.emplace_back(m);
        }
        if (!i) {
            tmp2.emplace_back(m + 1);
        } else {
            if (m == tmp2.back()) m++;
            tmp2.emplace_back(m);
        }
    }
    bool ok = false;
    int m = 0;
    set<int> st;
    for (int to : g[x[0]]) {
        st.emplace(a[to]);
    }
    while (st.count(m)) {
        m++;
    }
    ok = (tmp1[0] == (m + (m == tmp1.back())));
    ok |= (tmp2[0] == (m + (m == tmp2.back())));
    if (!ok) cout << "IM";
    cout << "POSSIBLE" << endl;
    return 0;
}

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

ll gcd(ll a , ll b) {
    while(b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    int ans = 1;
    long long sm = gcd(a, b);
    for(long long i = 2; i * i <= sm; i++) {
        int ok = 0;
        while(sm % i == 0) {
            ok = 1;
            sm /= i;
        }
        ans += ok;
    }
    if(sm != 1) {
        ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
Author: Sanskar Agarwal
Nick: sanskarag
Birla Institute Of Technology, Mesra
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define RF(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); i--)
#define INF 100009
#define mod 1000000007
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define test while(t--)solve();

void solve()
{
	ll n, k;
	cin >> n >> k;
	ll arr[n + 1];
	for (ll i = 1; i <= n; ++i)
		cin >> arr[i];
	ll dp[n + 1];
	dp[0] = 0;
	dp[1] = 0;
	for (ll i = 2; i <= n; ++i)
	{
		dp[i] = INT_MAX;
		ll j = max(i - k, 1LL);
		for (j; j < i; ++j)
		{
			ll temp = dp[j] + abs(arr[i] - arr[j]);
			dp[i] = min(dp[i], temp);
		}
	}
	cout << dp[n] << endl;
}

int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("../input.txt", "r", stdin);
// 	freopen("../output.txt", "w", stdout);
// #endif
	fast
	ll t;
	// cin >> t;
	t = 1;
	test
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}
int main(){
  int N;
  cin>>N;
  vector<int> V,C;
  V=input(N);
  C=input(N);
  int sum,ans = 0;
  for(int i =0;i<N;i++){
    sum=V.at(i)-C.at(i);
    if(sum>=0){
      ans+=sum;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if a[i]<=b[i]:
        ans += a[i]
        if a[i+1]<=(b[i]-a[i]):
            ans += a[i+1]
            a[i+1]=0
        else:
            ans += (b[i]-a[i])
            a[i+1] = a[i+1]-(b[i]-a[i])
    else:
        ans += b[i]
        a[i] = a[i]-b[i]

print(ans)

Measured memory_bytes: 82020
#include "bits/stdc++.h"
using namespace std;

int main(){
	string s;
	cin>>s;
	
	string ans="AKIHABARA";
	
	int flag=1;
	if(s.size()<5||s.size()>9)flag=0;
	int j=0;
	
	for(int i=0;i<s.size();i++){
		if(s[i]==ans[j]){
			j++;
		}else if(ans[j]=='A'){
			j++;
			if(s[i]==ans[j]){
				j++;
			}else{
				//cout<<i<<" "<<j<<endl;
				flag=0;
			}
		}else{
			//cout<<i<<" "<<j<<endl;
			flag=0;
		}
	}
	if(j<ans.size()-1)flag=0;
	
	if(flag){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=924844033;
int n,k,tot,dp[4010][2010][2],fac[2010],vis[2010][2];
bool ck[4010];
void init(){
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=1ll*fac[i-1]*i%mod;
	return;
}
void DP(){
	for(int i=1;i<=n;i++)
		for(int j=0;j<2;j++)
			if(!vis[i][j]){
				for(int a=i,b=j;a<=n;a+=k,b^=1){
					vis[a][b]=1;
					++tot;
				}
				ck[tot]=1;
			}
	dp[1][0][0]=1;
	for(int i=1;i<=tot;i++)
		for(int j=0;j<=n;j++){
			dp[i+1][j][0]=dp[i][j][0]+dp[i][j][1];
			if(dp[i+1][j][0]>=mod)
				dp[i+1][j][0]-=mod;
			if(!ck[i])
				dp[i+1][j+1][1]=dp[i][j][0];
		}
	return;
}
int get_ans(){
	int ret=0;
	for(int i=0;i<=n;i++)
		ret=(ret+(i&1?mod-1ll:1ll)*fac[n-i]%mod*(dp[tot][i][0]+dp[tot][i][1]))%mod;
	return ret;
}
int main(){
	scanf("%d%d",&n,&k);
	init();
	DP();
	printf("%d",get_ans());
	return 0;
}

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

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

    string s, t; cin>>s>>t;
    int n = s.size(), ans = 0;
    for(int i = 0; i<n; i++){
        if(s[i]!=t[i]) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n,m;
 cin>>n>>m;
 int p[m];
 string s[m];
 for(int i=0;i<m;i++)
 {
 	cin>>p[i]>>s[i];
 }
 int a[n+1]={0};
 int pen=0,cs=0;
 for(int i=0;i<m;i++)
 {
 	if(s[i]=="WA")
 	{
 		if(a[p[i]]>=0)
 		a[p[i]]++;
	 }
	 else{
	 	if(a[p[i]]>=0)
	 	{
		 cs++;
		 pen+=a[p[i]];
	 a[p[i]]=-1;
}
}
 }
 cout<<cs<<" "<<pen;
}

Measured memory_bytes: 7472
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;



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

	ll x, y;
	cin >> x >> y;

	ll ans = 0LL;

	while (x <= y) {
		x *= 2;
		ans++;
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 256
a = gets.chop.split("")
uniq_data =  a.sort.uniq

if uniq_data.length === 4
  print "Yes"
elsif uniq_data.length === 2
  if uniq_data[0] === "N" && uniq_data[1] === "S"
    print "Yes"
  elsif uniq_data[0] === "E" && uniq_data[1] === "W"
    print "Yes"
  else
    print "No"
  end
else
  print "No"
end




Measured memory_bytes: 1788
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

diff_min = float("inf")
ans = 0
for i in range(N):
  diff = abs(A - (T - H[i] * 0.006))
  if diff < diff_min:
    diff_min = diff
    ans = i + 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int INF = 1LL << 30;
int n, d, x;
int p[10][10];
int dp[100010];

void _main() {
    cin >> n >> d >> x;
    REP (i, d) REP (j, n) cin >> p[i][j];
    REP (i, 100010) dp[i] = -INF;
    REP (i, d - 1) {
        REP (j, x + 1) dp[j] = j;
        REP (j, n) FOR (k, p[i][j], x + 1) {
            dp[k] = max(dp[k], dp[k - p[i][j]] + p[i + 1][j]);
        }
        int tmp = 0;
        REP (j, x + 1) tmp = max(tmp, dp[j]);
        x = tmp;
    }
    cout << x << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<pair<string, int>> v;
    for(int i=0;i<n;++i){
        string s;
        int t;
        cin >> s >> t;
        v.emplace_back(s, t);
    }
    string x;
    cin >> x;
    int ans = 0;
    bool flag = false;
    for(int i=0;i<n;++i){
        if(flag)ans += v[i].second;
        if(v[i].first == x)flag = true;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
main = do
  whxyr_in <- (return . words) =<< getLine
  let w:h:x:y:r:[] = map (read::String->Int) whxyr_in
  if (x-r<0)||(x+r>w)||(y-r<0)||(y+r>h) then putStrLn "No" else putStrLn "Yes"



Measured memory_bytes: 3664