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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print( pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;


int main(void){

   // READ_IN;

   ll k;
   cin >> k;
   ll n;
   cin >> n;

   vector<llu>a(n);

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

   sort(a.begin(),a.end());

   llu ans1 = k-a[n-1]+a[0];


  // trace(ans1);
   //trace(ans2);

   llu sum = ans1;

   for(int i=0;i<n-1;i++){
        sum=max(a[i+1]-a[i],sum);
   }

   //trace(sum);


   cout << k-sum << endl;


    return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        float x1, y1, x2, y2, x3, y3, x4, y4;
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        if(((y1-y2)/(x1-x2))==((y3-y4)/(x3-x4)))
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[500010];
int cant,snum,si,cou;
bool par = true;

int main()
{
	int n;cin >> n;
	
	REP(a,n)
	{
		int tmp;
		cin >> tmp;
		
		if(!par)
		{
			printf("No\n");
			continue;
		}
		
		if(tmp > 500000)
		{
			printf("Yes\n");
			cou++;
			continue;
		}
		
		if(tmp <= cant || tmp <= si)
		{
			printf("No\n");
			continue;
		}
		
		mp[tmp]++;
		
		bool ok = true;
		bool tmpp = true;
		int ssi = 0,ssnum = 0;
		for(ll i=si+1,k=2,num=snum;i<500001;i++)
		{
			k -= mp[i];num+=mp[i];
			if(k < 0)
			{
				ok = false;
				break;
			}
			if(k == 0)
			{
				tmpp = false;
			}
			if(k == 1 && num < cou)
			{
				ssi = max(si,(int)i);
				ssnum = num;
			}
			if(k > 500000)
			{
				break;
			}
			k *= 2;
		}
		if(ok)
		{
			printf("Yes\n");
			cou++;
			par &= tmpp;
			si = max(si,ssi);
			snum = max(snum,ssnum);
		}
		else
		{
			printf("No\n");
			mp[tmp]--;
			cant = max(cant,tmp);
		}
		//cout << si << ' ' << snum << endl;
	}
			
			
	
	
	return 0;
}

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1e6 + 100;
const int INF = 1e9;

int U[N] , V[N] , C[N];
int n , m;


vpii G[N];

int dis[N];


int main(){
	fio; cout<<fixed<<setprecision(25);	
	cin >> n >> m;

	map<pii , int> exist;
	int idx = n+1 , u , v , c;
	for(int i = 1;i <= m;++i){
		cin >> u >> v >> c;
		if(exist.find(mp(u , c)) == exist.end()){
			exist[mp(u , c)] = idx++;
		}
		if(exist.find(mp(v , c)) == exist.end()){
			exist[mp(v , c)] = idx++;
		}
		G[u].pb(mp(exist[mp(u , c)] , 1));
		G[exist[mp(u , c)]].pb(mp(u , 0));
		G[v].pb(mp(exist[mp(v , c)] , 1));
		G[exist[mp(v , c)]].pb(mp(v , 0));
		G[exist[mp(u , c)]].pb(mp(exist[mp(v , c)] , 0));
		G[exist[mp(v , c)]].pb(mp(exist[mp(u , c)] , 0));
	}
	for(int i =1 ;i < idx ; ++i){
		dis[i] = INF;
	}
	deque<pii> Q;
	// priority_queue<pair<pii, int> , vector<pair<pii,int> > , greater<pair<pii,int> > >Q;
	// Q.push(mp(mp(0 , -1) , 1));
	Q.pb(mp(0 , 1));
	dis[1] = 0;
	//it.F is distance
	//it.S is vertex
	while(Q.size() > 0){
		auto it = Q.front();
		// trace(it);
		if(it.S == n){
			cout << it.F << endl;
			return 0;
		}
		Q.pop_front();
		for(auto e : G[it.S]){
			int w = e.S + it.F;
			if(dis[e.F] > w){
				dis[e.F] = w;
				if(e.S == 1){
					Q.pb(mp(dis[e.F] , e.F));
				}
				else{
					Q.push_front(mp(dis[e.F] , e.F));
				}
			}
		}
	} 	
	cout << -1 << endl;








	return 0;
}


Measured memory_bytes: 72960
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int m = scanner.nextInt();
        final int d = scanner.nextInt();

        int result = 0;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= d; j++) {
                if (j % 10 >= 2 && j / 10 >= 2) {
                    if ((j % 10) * (j / 10) == i) {
                        result++;
                    }
                }
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
int n,state;
long long num[100010];
long long totalsum=0,ans=LLONG_MAX,cou;

int main()
{
	int i,j;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&num[i]);
	}
		//first is +
		state = 1;
		if(num[0] <= 0)
		{
			totalsum = 1;
			cou = -num[0]+1;
		}
		else
		{
			totalsum = num[0];
			cou = 0;
		}
		for(i=1;i<n;i++)
		{
			totalsum += num[i];
			state *= -1;
			
			if(state == 1)
			{
				if(totalsum <= 0)
				{
					cou += -totalsum+1;
					totalsum = 1;
				}
			}
			else if(state == -1)
			{
				if(totalsum >= 0)
				{
					cou += (totalsum)+1;
					totalsum = -1;
				}
			}
		}
		if(cou < ans) ans = cou;
		
		//first is -
		state = -1;
		if(num[0] >= 0)
		{
			totalsum = -1;
			cou = num[0]+1;
		}
		else
		{
			totalsum = num[0];
			cou = 0;
		}
		for(i=1;i<n;i++)
		{
			totalsum += num[i];
			state *= -1;
			
			if(state == 1)
			{
				if(totalsum <= 0)
				{
					cou += -totalsum+1;
					totalsum = 1;
				}
			}
			else if(state == -1)
			{
				if(totalsum >= 0)
				{
					cou += (totalsum)+1;
					totalsum = -1;
				}
			}
		}
		if(cou < ans) ans = cou;

	printf("%lld\n",ans);
}

Measured memory_bytes: 4476
n,m=map(int,input().split())

ans=0
if 2*n<=m:
    ans+=n
    n=0
    m-=2*ans
elif 1<=n and 2<=m:
    ans+=m//2
    n-=m
    m-=(m//2)*2
   

ans+=m//4

print(ans)


Measured memory_bytes: 2940
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define PREP(it,array) for(vector<P>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)

#define MP       make_pair
#define PB       push_back
#define ALL(x)   (x).begin(),(x).end()

const int INF = 1<<29;
const double EPS = 1e-9;
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef long long LL;
typedef pair<int,int> P;


int m;
int card[100+1];
int g;
int memo[1001][101];

int solve(int n, int u){
  if( n == 0 )
    return 1;
  if( n<0 || u>100 ) return 0;

  if( memo[n][u] != -1 )
    return memo[n][u];

  int res=0;
  REP(i,card[u]+1){
    res += solve( n-u*i, u+1 );
  }

  return memo[n][u] = res;
}


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);

  while( cin>>m, m ){
    REP(i,1001)
      fill( memo[i], memo[i]+101, -1 );
    memset( card,0,sizeof(card) );
    REP(_t,m){
      int a,b;
      cin >>a>>b;
      card[a] = b;
    }

    cin >> g;
    REP(_t,g){
      int n;
      cin >> n;
      cout << solve(n, 0) << endl;
    } 
  }

  return 0;
}

Measured memory_bytes: 1560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>

using namespace std;

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

int main(){
	int n;
	vector<int>a(3);
	rep(i, 3)
		cin >> a[i];
	sort(a.begin(), a.end());

	cout << abs(a[0] -a[1]) + abs(a[1]- a[2]);


}

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

int main(){
    ll s, w;
    cin >> s >> w;

    if(s<=w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" <<endl;
    }

    return 0;
}

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


class B
{
    static int[,] m=new int[101,101];
    static int[] p=new int[101];
    public static void Main() {
        int n = int.Parse(System.Console.ReadLine());
        for(int i = 1; i <= n; i++) {
            string[] input = Console.ReadLine().Split(' ');
            p[i - 1] = int.Parse(input[0]);
            p[i] = int.Parse(input[1]);
        }
        matrixChainOrder(n);
        Console.WriteLine(m[1, n]);
    }
    static void matrixChainOrder(int n) {
        int j;
        for(int l = 2; l <= n; l++) {
            for(int i = 1; i <= n - l + 1; i++) {
                j = i + l - 1;
                m[i, j] = int.MaxValue;
                for(int k = i; k < j; k++) {
                    m[i, j] = Math.Min(m[i, j], m[i, k] + m[k + 1, j] + p[i - 1] * p[k] * p[j]);
                }
            }
        }
    }
}


Measured memory_bytes: 18060
from collections import deque
n,q = map(int,input().split())
d = deque([[] for _ in range(n)])
for _ in range(q):
    t = input().split()
    if t[0] == "0":
        d[int(t[1])].append(t[2])
    elif t[0] == "1":
        if len(d[int(t[1])]) != 0:
            print(d[int(t[1])][-1])
    else:
        if len(d[int(t[1])]) != 0:
            d[int(t[1])].pop()
        




Measured memory_bytes: 20224
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, ans;
  cin >> a >> b;
  if ((a + b) % 2 == 0) ans = (a + b) / 2;
  else ans = (a + b) / 2 + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int A,B,C,D;
cin>>A>>B>>C>>D;
int turn=0;
while(A>0 && C>0){
if(turn%2==0){
    C-=B;
}
else{
    A-=D;
}
turn+=1;
}
if(A>0){
    cout<<"Yes"<<"\n";
}
else{
    cout<<"No"<<"\n";
}
return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(void){
  int day[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int m,d;
  scanf("%d %d", &m, &d);
  
  if(d == day[m-1])
    printf("1");
  else
    printf("0");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	while(1)
	{
		int n; cin >> n ;
		if(!n) break;
		int money=1000-n; int cnt=0;
		while(money>=500) {cnt++,money-=500;}
		while(money>=100) {cnt++,money-=100;}
		while(money>=50) {cnt++,money-=50;}
		while(money>=10) {cnt++,money-=10;}
		while(money>=5) {cnt++,money-=5;}
		while(money>=1) {cnt++,money-=1;}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	long long int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	} else {
		vector<long long int> d;
		d.push_back(a);
		d.push_back(b);
		d.push_back(c);
		sort(d.begin(), d.end(), greater<long long int>());
		cout << d[1]*d[2] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
	double r;
	cin >> r;
	cout << 2* r * 3.1415 << endl;
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define vec vector
#define fi first
#define se second
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
#define bit(x) (1ll<<(x))

void mainsolve(){
	
	string s,t;
	cin >> s >> t;

	cout << t+s << endl;
	
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

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

//The Number of the Real Roots of a Cubic Equation
public class Main{

	int a, b, c, d;
	double EPS = 1e-8;
	List<Double> ans;
	
	double f(double x){
		return a*x*x*x + b*x*x + c*x + d;
	}
	double df(double x){
		return 3*a*x*x + 2*b*x + c;
	}
	void bs(double L, double R, boolean up){
		if(f(L)==0){
			ans.add(L); return;
		}
		if(f(R)==0){
			ans.add(R); return;
		}
		if(L <= 0 && 0 <= R && f(0)==0)return;
//		if(up && (0 < f(L) || f(R) < 0))return;
//		if(!up && (f(L) < 0 || 0 < f(R)))return;
		while(R-L > 1e-12){
			double M = (L+R)/2;
			if(0 < f(M)){
				if(up)R=M;
				else L=M;
			}
			else if(f(M) < 0){
				if(up)L=M;
				else R=M;
			}
			else{
				ans.add(M); return;
			}
		}
		if(Math.abs(f(L)) < EPS)ans.add(L);
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int INF = 1000000;
		while(T--!=0){
			a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt();
			int D = b*b-3*a*c, rm = 0, rp = 0;
			ans = new ArrayList<Double>();
			if(0 <= D){
				double x0 = (-b-Math.sqrt(D))/3/a, x1 = (-b+Math.sqrt(D))/3/a;
				if(x1 < x0){
					double tmp = x1;
					x1 = x0;
					x0 = tmp;
				}
				bs(-INF, x0, 0 < df((x0-INF)/2));
				bs(x0, x1, 0 < df((x0+x1)/2));
				bs(x1, INF, 0 < df((x1+INF)/2));
			}
			else{
				bs(-INF, INF, 0 < df(0));
			}
			for(double d:ans){
				if(Math.abs(d) == 0)continue;
				if(0 < d)rp++;
				else rm++;
			}
			System.out.println(rp+" "+rm);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;
int gcd(int a, int b)
{
   if (b < a)
      return gcd(b, a);
   if (b % a == 0)
      return a;
   return gcd(b % a, a);
}

bool isPrime[1000001];
int cnt[100000];
vector<ll> primes;
map<ll, int> p2i;
int main()
{
   int N;
   cin >> N;
   vector<int> A(N);
   memset(isPrime, true, sizeof(isPrime));
   for (int i = 2; i < 1000001; i++)
   {
      if (isPrime[i])
      {
         primes.emplace_back(i);
         for (int j = i + i; j < 1000001; j += i)
         {
            isPrime[j] = false;
         }
      }
   }
   for (int i = 0; i < (int)primes.size(); i++)
   {
      p2i[primes[i]] = i;
   }
   int setwise;
   for (int i = 0; i < N; i++)
   {
      cin >> A[i];
      if (i == 0)
         setwise = A[0];
      else
         setwise = gcd(setwise, A[i]);
   }
   sort(A.begin(), A.end());
   if (setwise != 1)
   {
      cout << "not coprime" << endl;
      return 0;
   }
   bool ok = true;
   memset(cnt, 0, sizeof(cnt));
   for (int i = 0; ok && i < N; i++)
   {
      for (int pi = 0; primes[pi] * primes[pi] <= A[i]; pi++)
      {
         int p = primes[pi];
         if (A[i] % p == 0)
         {
            cnt[pi]++;
            if (cnt[pi] >= 2)
            {
               ok = false;
            }
            while (A[i] % p == 0)
               A[i] /= p;
         }
      }
      if (A[i] != 1)
      {
         int pi = p2i[A[i]];
         cnt[pi]++;
         if (cnt[pi] >= 2)
         {
            ok = false;
         }
      }
   }
   if (ok)
   {
      cout << "pairwise coprime" << endl;
   }
   else
   {
      cout << "setwise coprime" << endl;
   }

   return 0;
}


Measured memory_bytes: 13844
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] top = sc.next().toCharArray();
		int price = 700;
		for (int i=0; i<3; i++){
			if (top[i]=='o'){
				price+=100;
			}
		}
		System.out.println(price);

	}

}

Measured memory_bytes: 35588
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[2]) cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll x, y, f[2000006] = {1}, g[2000006] = {};
    for (int i = 1; i <= 2000000; i++) f[i] = f[i - 1] * i % mod;
    g[2000000] = 407182070;
    for (int i = 1999999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    cin >> x >> y;
    if ((x + y) % 3) {
        cout << 0;
    } else if (x > y) {
        if (y + y < x) cout << 0;
        else {
            ll n = 0, m = 0, k = (x + y) / 3;
            for (int i = 0; i <= k; i++) {
                if (i + i + k - i == x && i + k - i + k - i == y) {
                    n = i;
                    m = k - i;
                    break;
                }
            }
            cout << f[k] * g[n] % mod * g[m] % mod;
        }
    } else {
        if (x + x < y) cout << 0;
        else {
            ll n = 0, m = 0, k = (x + y) / 3;
            for (int i = 0; i <= k; i++) {
                if (i + i + k - i == x && i + k - i + k - i == y) {
                    n = i;
                    m = k - i;
                    break;
                }
            }
            cout << f[k] * g[n] % mod * g[m] % mod;
        }
    }
}


Measured memory_bytes: 34904
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count=0;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++)
    cin >> p.at(i);
  for (int j=0; j<N;j++){
    if(p.at(j) == j+1)
      continue;
    else
      count++;
  }
  if (count >= 3)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
x = 0
total = 0


for i in range(n-1):
    if a[i] >= a[i+1]:
        x = a[i] - a[i+1]
        total += x
        a[i+1] = a[i]
        i = i+1
    else:
        total += 0

print(total)

Measured memory_bytes: 32240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  int sum = 0;
  int maxl = 0;
  rep(i, n) {
    cin >> l[i];
    sum += l[i];
    maxl = max(maxl, l[i]);
  }
  sum -= maxl;
  if (maxl < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return list(map(proc, rl().split()))
    else:
        return rl().split()

def main():
    n, a, b = srl(int)
    print(min(n*a, b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n,d;
    scanf("%d%d",&n,&d);
    int X[n][d];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            scanf("%d",&X[i][j]);
        }
    }
    int count = 0;
    for(int i = 0;i < n;i++){
        for(int j = i;j < n;j++){
            int sum = 0;
            if(i != j){
                for(int k = 0;k < d;k++){
                    sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                double ans = sqrt((double)sum);
                if ((int)ans * (int)ans == sum){
                    count++;
                }
            }
        }
    }

    printf("%d",count);
}

Measured memory_bytes: 128
H, W, N = map(int, input().split())

Dic = {}
for i in range(N):
    a, b = map(int, input().split())
    for j in range(3):
        for k in range(3):
            if 1 <= a-j <= H-2 and 1 <= b-k <= W-2:
                if (a-j, b-k) in Dic:
                    Dic[(a-j, b-k)] += 1
                else:
                    Dic[(a-j, b-k)] = 1

Painted = [0 for _ in range(10)]
colered = 0
for i in Dic:
    Painted[Dic[i]] += 1
    colered += 1
Painted[0] = (H-2) * (W-2) - colered

for i in Painted:
    print(i)

Measured memory_bytes: 166500
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s; cin >> s;
	int n,a,cnt;
	cnt=0;
	n=a=s.size();
	
	for (int i=0;i<n;i++){
		if(s.at(i)=='0'){
			cnt+=1;
		}

	}
		a=n-cnt;

	
	
cout << 2*min(cnt,a) << endl;
	
}

Measured memory_bytes: 512
#include <stdio.h>
int main(){
  int n,i,x;
 
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if((x%3)==0) printf(" %d",i);
    else{
      while(1){
    if((x%10)==3){
      printf(" %d",i);
      break;
    }
    if((x/=10)==0) break;
      }
    }
  }
  printf("\n");
 
  return 0;
}


Measured memory_bytes: 2104
h,w=map(int,input().split())
maze=[]
for i in range(h):
  x=list(input())
  if x.count('#')!=0:
    maze.append(x)
  else:
    h-=1
    
ans=['' for i in range(h)]
  
for i in range(w):
  cnt=0
  for j in range(h):
    if maze[j][i]=='#':
      cnt+=1
  if cnt!=0:
    for k in range(h):
      ans[k]+=maze[k][i]
  else:
    w-=1
      
for i in range(h):
  print(ans[i])
    
  


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

static const int MAX = 200000;

int main(void)
{
	int n,i, minv, maxv;
	static int R[MAX];

	cin >> n;
	for (i = 0; i < n; i++)
		cin >> R[i];

	minv = R[0];
	maxv = R[1] - R[0];
	for (i = 2; i < n; i++){
		if (R[i - 1] < minv)
			minv = R[i - 1];
		if (R[i] - minv > maxv){
			maxv = R[i] - minv;
		}
	}
	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 1940
# AGC014B - Unplanned Queries
from collections import Counter


def main():
    N, _, *A = map(int, open(0).read().split())
    T = Counter(A).values()
    flg = all(i % 2 == 0 for i in T)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

Measured memory_bytes: 25964
#
# abc133 b
#
import sys
from io import StringIO
import unittest
from math import sqrt


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 2
1 2
5 5
-2 8"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 4
-3 7 8 2
-12 1 10 2
-2 8 9 3"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 1
1
2
3
4
5"""
        output = """10"""
        self.assertIO(input, output)


def resolve():
    N, D = map(int, input().split())
    X = [list(map(int, input().split())) for _ in range(N)]

    ans = 0
    for i, x1 in enumerate(X):
        for x2 in X[i+1:]:
            tmp = 0
            for j in range(D):
                tmp += (x2[j]-x1[j])**2
            tmp = sqrt(tmp)
            if tmp.is_integer() == True:
                ans += 1

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16284
import collections

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
bcs=[list(map(int,input().split())) for i in range(Q)]
total=sum(A)
c=collections.Counter(A)
ans=[0 for i in range(Q)]


for i in range(Q):
    B=bcs[i][0]
    C=bcs[i][1]
    if c[B]!=0:
        total+=c[B]*(C-B)
        ans[i]=total
        c[C]+=c[B]
        c[B]=0
    else:
        ans[i]=total
for i in range(Q):
    print(ans[i])


Measured memory_bytes: 37372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> ps(n);
  for (int i = 0; i < n; i++) {
    cin >> ps.at(i); 
  }
  int count = 0;
  for (int i = 1; i < n - 1; i++) {
    if (ps.at(i) > ps.at(i - 1) && ps.at(i) < ps.at(i + 1) || ps.at(i) > ps.at(i + 1) && ps.at(i) < ps.at(i - 1)) { count++; }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int x;
	cin >> x;
	int ans = 1;
	rep(i, 2, sqrt(x)) {
		int a = i;
		while (a*i <= x) {
			a *= i;
		}
		ans = max(ans, a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N;
  cin >> N;
  ll A[N];
  ll Num[N+10] = {0};
  for (int i = 1; i < N; ++i) {
    cin >> A[i];
    ++Num[A[i]-1];
  }
  for (int i = 0; i < N; ++i) {
    printf("%lld\n", Num[i]);
  }
}


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

int main(){
  int A,B;
  cin>>A>>B;
  if(A==B){
    cout<<"Draw"<<endl;
  }else if(B==1){
    cout<<"Bob"<<endl;
  }else if(A==1){
    cout<<"Alice"<<endl;
  }else if(A>B){
    cout<<"Alice"<<endl;
  }else if(A<B){
    cout<<"Bob"<<endl;
  }
  return 0;
}


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

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, m, x;
   cin >> n >> m >> x;
   vector<int> a;
   for(int i = 0;i < m;i++) {
      int x;
      cin >> x;
      a.push_back(x);
   }
   int right, left;
   right = 0;
   left = 0;


   for(int i = 0;i < a.size();i++) {
      if(x>a[i]) {
         right+=1;
      } else {
         left+=1;
      }
   }
   cout << min(right, left) << endl;
   
   return 0;
}



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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, ll K) {
    if (N % K == 0) cout << 0 << endl;
    else cout << 1 << endl;
}


void main_(istream &cin) {
    ll N;
    ll K;
    cin >> N;
    cin >> K;
    solve(N, K);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
#python3

class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.length = [1 for _ in range(n)] 

    def makeSet(self, n):
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.length = [1 for _ in range(n)]

    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parents[x] = y
            self.length[y] += self.length[x]
        else:
            self.parents[y] = x
            self.length[x] += self.length[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def getLength(self, x):
        x = self.find(x)
        return self.length[x]        

    def isSameGroup(self, x, y):
        return self.find(x) == self.find(y)

def main():

    n, m, k = map(int, input().split())
    uf = UnionFind(n)

    to = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(lambda x: int(x)-1, input().split())
        to[a].append(b)
        to[b].append(a)
        uf.unite(a, b)

    block = [[] for _ in range(n)]
    block_count = [0 for _ in range(n)]
    for _ in range(k):
        c, d = map(lambda x: int(x)-1, input().split())
        block[c].append(d)
        block[d].append(c)
        if uf.isSameGroup(c, d):
            block_count[c] += 1 
            block_count[d] += 1
   #同じグループ内にいるときのみブロックを引く 
    for i in range(n):
        ans = uf.getLength(i) - len(to[i]) - block_count[i] - 1
        print(ans, end=' ')
main()

Measured memory_bytes: 43584
/*
      author  : nishi5451
      created : 14.08.2020 17:26:24
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    for(int i=a; i<=b; i++){
        if( (i%10==i/10000) && ((i%100)/10 == (i%10000)/1000))
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)



int main(){
    int r;
    cin >> r;
    string ans;
    if(r < 1200) ans = "ABC";
    else if(r < 2800) ans = "ARC";
    else ans = "AGC";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
    char str[200];
    int s=1;
    scanf("%s",str);
    for(int i=0;str[i]!='\0';i++)
    {
        if((i+1)%2==0)
        {
            if(str[i]!='D'&&str[i]!='U'&&str[i]!='L')
            {
                s=0;
                break;
            }
        }
        else
        {
            if(str[i]!='R'&&str[i]!='U'&&str[i]!='D')
            {
                s=0;
                break;
            }
        }
    }
    if(s==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  bool f=false;
   
   
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1])) f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
 
  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
   
  cout << (f?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3100
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

point = 0
mod = 10**9+7

from itertools import accumulate

li = list(accumulate(a))

for i,j in enumerate(a):
    point += j*(li[-1]-li[i])%mod

print(point%mod)

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

int main()
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    long long s = 0;
    if(k>a)
    {
        s = s + a;
        k-=a;
        if(k>b)
        {
            k-=b;
            if(k!=0)
            {
                s = s - k;
            }
        }
        
    }
    else
    {
        s = k;
    }
    cout<<s;
    
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
typedef long long LL;
int main() {
	std::string a;
	std::cin >> a;
	if (a[0] == a[1] && a[1] == a[2]) { std::cout << "Yes" << std::endl; }
	else if(a[1] == a[2] && a[3] == a[2]) { std::cout << "Yes" << std::endl; }
	else { std::cout << "No" << std::endl;}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 1004
#define mod 998244353
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
    ll n,i;
    in(n);
    set<string>ss;
    string s;
    nfl(i,n){
        cin>>s;
        ss.insert(s);
    }
    cout<<ss.size()<<"\n";
}
int main(){
    clock_t t1=clock();
    gear_change;
    ll test=1;
    // in(test);
    while(test--){
        solve();
    }
    clock_t t2=clock();
    cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}    

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

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

int32_t main(){
  DESYNC;
  int a,b;
  cin >> a >> b;
  if(a >= 13) cout << b << endl;
  else if(a > 5) cout << b/2 << endl;
  else cout << 0 << endl;
}



Measured memory_bytes: 256
def main():
    N, W = (int(i) for i in input().split())
    VW = [[int(i) for i in input().split()] for j in range(N)]
    dp = [[0]*(W+1) for _ in range(N+1)]

    for i in range(N):
        for j in range(W+1):
            if 0 <= j - VW[i][0]:
                dp[i+1][j] = max(dp[i][j], dp[i][j - VW[i][0]] + VW[i][1])
            else:
                dp[i+1][j] = dp[i][j]

    print(dp[N][W])


if __name__ == '__main__':
    main()


Measured memory_bytes: 147028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  string A,B,C ;
  cin >> A >> B >> C ;
  int i = 0  , j = -1  , k = -1 ;
  int a = 0  , b = 0  , c = 0  ; 
  int n = 0 ;
  //cout << A{4] << endl;
  while(1){
    if( n == 0 ){
      a = 1 ;
      n = 1 ;
    }
    if ( a && A[i] == 'a' ){
      i++ ;
      a = 1 ,b = 0 , c = 0 ;
      //cout << "Aは" << i << "枚目" << "次はAの番" << endl;
      if( i == A.size()){
      	cout << 'A' << endl;
      	return 0 ;
      }
    }
    else if ( a && A[i] == 'b' ){
      j++ ;
      a = 0 ,b = 1 , c = 0 ;
      //cout << "Aは" << i << "枚目" << "次はBの番" << endl;
    }
    else if ( a && A[i] == 'c' ){
      k++ ;
      a = 0 ,b = 0 , c = 1 ;
      //cout << "Aは" << i << "枚目" << "次はCの番" << endl;
    }
    else if ( b && B[j] == 'a' ){
      i++ ;
      a = 1 ,b = 0 , c = 0 ;
      //cout << "Bは" << j << "枚目" << "次はAの番" << endl;
    }
    else if ( b && B[j] == 'b' ){
      j++ ;
      a = 0 ,b = 1 , c = 0 ;
      //cout << "Bは" << j << "枚目" << "次はBの番" << endl;
      if( j == B.size() ){
        cout << 'B' << endl;
        return 0 ;
      }
    }
    else if ( b && B[j] == 'c' ){
      k++ ;
      a = 0 ,b = 0 , c = 1 ;
      //cout << "Bは" << j << "枚目" << "次はCの番" << endl;
    }
    else if ( c && C[k] == 'a' ){
      i++ ;
      a = 1 ,b = 0 , c = 0 ;
      //cout << "Cは" << k << "枚目" << "次はAの番" << endl;
    }
    else if ( c && C[k] == 'b' ){
      j++ ;
      a = 0 ,b = 1 , c = 0 ;
      //cout << "Cは" << k << "枚目" << "次はBの番" << endl;
    }
    else if(c && C[k] == 'c' ){
      k++ ;
      a = 0 ,b = 0 , c = 1 ;
      //cout << "Cは" << k << "枚目" << "次はCの番" << endl;
      if ( k == C.size() ){ 
      	cout << 'C' << endl;
        return 0 ;
      }
    }
    if( i == A.size() ){
        cout << 'A' << endl;
        return 0 ;
    }
    else if( j == B.size() ){
        cout << 'B' << endl;
        return 0 ;
    }
    else if ( k == C.size() ){ 
      	cout << 'C' << endl;
        return 0 ;
    }
    else continue ; 
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
inline long long read()
{
	long long x=0;
	char ch=getchar();
	while(ch>='0'&&ch<='9')
	{x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x;
}
long long a,b,c;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	a=a%500;
	if(a<=b)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from fractions import gcd
import sys
sys.setrecursionlimit(10 ** 7)


def solve(N: int, A: "List[int]"):
    L, R = [0], [0]
    for i in range(N - 1):
        L.append(gcd(L[i], A[i]))
        R.append(gcd(R[i], A[-i - 1]))
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(L[i], R[N - i - 1]))
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95004
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define maxn 100005
int main(){__
	string alpha = "abcdefghijklmnopqrstuvwxyz";
	lli n;
	cin >> n;
	string ans="";
	if(n == 0){
		cout << "a\n";
		return 0;
	}
	while(true){
		n--;
		char c = alpha[n%26];
		ans+=c;
		n/=26;
		if(n == 0) break;
	}
	reverse(all(ans));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int[] a;
        int n;
        int sum = 0, count = 0;
        int aini = 7;

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];

        a[0] = aini;

        for (int i = 1; i < a.length; i++) {
            a[i] = a[i-1] + 5;
            for (int j = 2; j < a[i]; j++) {
                if (a[i] % j == 0) {
                    a[i] += 5;
                    j = 2;
                }
            }
        }

        for (int x: a) {
            System.out.print(x + " ");
            sum += x;
        }
        System.out.println();

    }
}


Measured memory_bytes: 20692
a, b, c, d = map(int, input().split())

t_hp = a
a_hp = c
while a_hp > 0 or t_hp > 0:
    a_hp -= b
    t_hp -= d
    if a_hp <= 0:
         print("Yes")
         exit()
    elif t_hp <= 0:
         print("No")
         exit()

Measured memory_bytes: 9164
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	buttons := make([]int, n)
	for i := range buttons {
		fmt.Scan(&buttons[i])
		buttons[i]--
	}
	
	target := 0
	cnt := 1
	for i := 0; i < n; i++ {
		if buttons[target] == 1 {
			fmt.Println(cnt)
			return
		} else {
			target = buttons[target]
			cnt++
		}
	}
	fmt.Println(-1)
}

Measured memory_bytes: 6316
#include<stdio.h>

int main(){
  long N,A,B;
  scanf("%ld%ld%ld",&N,&A,&B);

  if (B>=A&&N>=(B-A))
  {
    printf("%ld",(B-A)*(N-2)+1);
  }else{
    puts("0");
  }

  return 0;
}

Measured memory_bytes: 1680
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#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;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(void) {
    LL A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    LL c1 = A * X + B * Y;
    LL c2 = C * (X * 2) + B * (max((LL)0, Y-X));
    LL c3 = C * (Y * 2) + A * (max((LL)0, X-Y));
    
    cout << min(c1,min(c2,c3)) << endl;

    return 0;
}

Measured memory_bytes: 256