akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string s;
vector<int> vec;
int ans;

signed main() {
	cin >> s;
	int k = 1, cnt = 0;
	vec.push_back(0);
	for (int i = (int)s.size() - 1; i >= 0; i--) {
		int x = s[i] - '0';
		cnt = (cnt + x * k) % 2019;
		vec.push_back(cnt);
		k *= 10;
		k %= 2019;
	}
	sort(all(vec));
	cnt = 1;
	for (int i = 1; i < (int)vec.size(); i++) {
		if (vec[i - 1] == vec[i])cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 5480
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

ll func(ll x , ll y) {
    ll ans = 1;
    while(y > 0) {
        if (y % 2 == 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        y /= 2;
    }
    return ans;
}

int main()
{
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    unsyncIO;
    int n;
    cin >> n;
    ll ans;
    ans = func(10, n) - (func(9, n) * 2 - func(8, n));
    ans = ans % MOD;
    if(ans < 0)
        ans += MOD;
    cout << ans << endl;
    return 0;
}

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

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

    std::string cand;
    for (int i = 0; i < 10; i++) {
        cand += "hi";
        if (s == cand) {
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
H, W = map(int,input().split())
A = ""
for _ in range(H):
  A += input()

cA = Counter(A)

if H % 2 == 1 and W % 2 == 1:
  one = 1
  two = H // 2 + W // 2
  four = (H // 2) * (W // 2)
else:
  one = 0
  two = (H * (W % 2) + W * (H % 2)) // 2
  four = (H // 2) * (W // 2)

# print(one, two, four)

vals =[val for val in cA.values()]

# print(vals)

# one
while one > 0:
  for i in range(len(vals)):
    _, m = divmod(vals[i], 4)
    if m == 1 or m == 3:
      vals[i] -= 1
      break # 
  one -= 1

# print(vals)    

# two
if two > 0:
  for i in range(len(vals)):
    _, m = divmod(vals[i], 4)
    if two > 0 and m == 2:
      vals[i] -= 2
      two -= 1
          
# print(vals)

# four
while four > 0:
  for i in range(len(vals)):
    _, m = divmod(vals[i], 4)
    if vals[i] != 0 and m == 0:
      vals[i] -= 4
      break
  four -= 1

# print(vals)      
# print(one, two, four)

# two
while two > 0:
  for i in range(len(vals)):
    _, m = divmod(vals[i], 2)
    if vals[i] != 0 and m == 0:
      vals[i] -= 2
      break
  two -= 1

# print(vals)      
# print(one, two, four)
  
if all([val == 0 for val in vals]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3316
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int amount = 0;

        if(x <= y){
            for(int i = 0; i <= y; i++){
                int tmp = b * i + 2 * c * (y - i) + Math.min(a, 2 * c) * Math.max(0, x - y + i);
                if(amount == 0){
                    amount = tmp;
                }else{
                    amount = Math.min(amount, tmp);
                }
            }
        }else{
            for(int i = 0; i <= x; i++){
                int tmp = a * i + 2 * c * (x - i) + Math.min(b, 2 * c) * Math.max(0, y - x + i);
                if(amount == 0){
                    amount = tmp;
                }else{
                    amount = Math.min(amount, tmp);
                }
            }
        } 

        System.out.println(amount);
	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {

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

        int my = 1000;
        int mm = 1;
        int md = 1;
        int hito = scanner.nextInt();
        for (int poi = 0; poi < hito; poi++){
            int y = scanner.nextInt();
            int m = scanner.nextInt();
            int d = scanner.nextInt();

            int days = 0;
            for (int year = y + 1; year < my; ++year) {
                if (year % 3 == 0) {
                    days = days + 200;
                } else {
                    days = days + 195;
                }
            }

            int tep = d;
            for (int month = 1; month < m; ++month) {
                if (y % 3 == 0 || month % 2 == 1) {
                    tep += 20;
                } else {
                    tep += 19;
                }
            }

            if (y % 3 == 0) {
                days += 200 - tep;
            } else {
                days += 195 - tep;
            }

            System.out.println(days + 1);
        }
    }
}





Measured memory_bytes: 26516
#include<stdio.h>
#include<stdlib.h>
long gcd(long a,long b){return b?gcd(b,a%b):a;}
const long mod=1e9+7;
struct X{long A,B;int f;};
struct X A[2<<17];
long long O=mod-1;
int cmp(const void *a,const void *b){
    struct X *aa=(struct X *)a;
    struct X *bb=(struct X *)b;
    long dA=aa->A-bb->A,dB=aa->B-bb->B;
    return dA?dA<0?-1:1:dB?dB<0?-1:1:0;
}


int main()
{
    int N;long a,b;
    int sz=0;
    scanf("%d",&N);
    ////输入并实现a，b的标准化
    for(int i=0;i<N;i++){
        scanf("%ld %ld",&a,&b);
            int f=0;
        if(!a&&!b) O++;
        else{
              long g=gcd(a,b);
              a=a/g;b=b/g;
            if(a<0){
                a=-a;
                b=-b;
            }
            if(a==0){
                a=1;
                b=0;
                f=1;
            }
            else if(b<0){
                long t;
                t=a;
                a=-b;
                b=t;
                f=1;
            }
            A[sz].A=a;
            A[sz].B=b;
            A[sz].f=f;
            sz++;
        }
    }
    //实现排序
    qsort(A,sz,sizeof(struct X),cmp);
    //实现计算；
    long ans=1;
    for(int i=0;i<sz;){
        int c[2]={1,1};
        int j=i;
        while(i<sz&&A[i].A==A[j].A&&A[i].B==A[j].B){
            c[A[i].f]=c[A[i].f]*2%mod;
            i++;
        }
        ans=ans*(c[0]+c[1]-1)%mod;
    }
    printf("%d",(ans+O)%mod);
}

Measured memory_bytes: 10652
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

string s;
int main(int argc, char const *argv[]) {
  cin >> s;
  char begin = *s.begin();
  char end = *(s.end() - sizeof(char) * 1);
  size_t mean = s.size() - 2;
  cout << begin << mean << end << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    U, D, L, R = "U", "D", "L", "R"
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy
    print(R * dx + U * dy
          + L * dx + D * dy
          + D * 1
          + R * (dx + 1) + U * (dy + 1)
          + L
          + U
          + L * (dx + 1) + D * (dy + 1)
          + R)
    return


main()


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int N,M; scanf("%d%d",&N,&M);//N,Mを入力
  int A[110]; for(int i = 1;i <= N;i++){scanf("%d",&A[i]);}//Aの配列を作る
  long int SUM = 0; for(int i = 1;i <= N;i++){SUM += A[i];}//得票数の合計を求める

  //"得票数に4Mを掛けた値がSUM以上になる商品の数"がM以上ならYes
  int cnt = 0; for(int i = 1;i <= N;i++){if(A[i]*4*M >= SUM){cnt += 1;}}//選べる商品の数を求める

  if(cnt >= M){printf("Yes");}
  else{printf("No");}

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define RANGE 10010
#define MAX 2000001
using namespace std;

void Counting_Sort(int A[], int B[], int k, int n)
{
	int C[RANGE];
	for (int i = 0;i <= k;i++)
	{
		C[i] = 0;
	}
	for (int i = 1;i <= n;i++)
	{
		C[A[i]]++;
	}
	for (int i = 1;i <= k;i++)
	{
		C[i] += C[i-1];
	}
	for (int i = n;i >= 1;i--)
	{
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}
}

int main ()
{
	int n, A[MAX], B[MAX];
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		cin >> A[i];
	}
	
	Counting_Sort(A, B, RANGE, n);
	
	
	cout << B[1];
	for (int i = 2;i <= n;i++)
	{
		cout << " " << B[i];
	}
	cout << endl;
	return 0;
 } 


Measured memory_bytes: 18712
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long int li;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef pair<double, double> dd;
typedef unsigned int ui;
typedef vector<ii> vii;
typedef vector<ff> vff;
typedef set<int> si;
typedef set<lli> slli;
typedef vector<lli> vlli;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long int ulli;
#define MOD 1000000007
#define INF (unsigned)(~0)>>1
typedef pair<int, ii> iii;
void arr_int(int* given_arr, int n){
  for(int i=0;i<n;i++)
    scanf("%d", &given_arr[i]);
  return;
}
void solve();
int main(int argc, char const *argv[]){
  solve();
  return 0;
}
void solve(){
  int a[3][3];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      scanf("%d", &a[i][j]);
  int N;
  scanf("%d", &N);
  int temp;
  bool done = false;
  for(int i=0;i<N;i++){
    scanf("%d", &temp);
    for(int i=0;i<3 && !done;i++)
      for(int j=0;j<3 && !done;j++){
        if(a[i][j] == temp){
          a[i][j] = -1;
          if(a[(i+1)%3][j] == -1 && a[(i+2)%3][j] == -1){
            printf("%s\n", "Yes");
            done = true;
          }
          else if(i==j && a[(i+1)%3][(i+1)%3] == -1 && a[(i+2)%3][(i+2)%3]==-1){
            printf("%s\n", "Yes");
            done = true;
          }
          else if(a[i][(j+1)%3] == -1 && a[i][(j+2)%3] == -1){
            printf("%s\n", "Yes");
            done = true;
          }
          else if(i+j==2 && a[(i+1)%3][2 - ((i+1)%3)] == -1 && a[(i+2)%3][2-((i+2)%3)]==-1){
            printf("%s\n", "Yes");
            done = true;
          }
        }
      }
  }
  if(!done)
    printf("%s\n", "No");
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#define MAX 100000
int partition(int,int);

using namespace std;
int S[MAX];
int n;

int main(){
  int i;
  int q;
  cin >> n;

  for(i = 0; i < n; i++){
    cin >> S[i];
  }
  q = partition(0,n-1);
  for(i = 0; i < n; i++){
    if(0 < i){
      cout << " ";
    }
    if(i == q){
      cout << "[";
    }
    cout << S[i];
    if(i == q){
      cout << "]";
    }
  }
  cout << endl;
  return 0;
}//end main func

int partition(int p,int r){
  int i,j,x;
  int tmp;
  x = S[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(S[j] <= x){
      i++;
      tmp = S[i];
      S[i] = S[j];
      S[j] = tmp;
    }
  }
  tmp = S[i+1];
  S[i+1] = S[r];
  S[r] = tmp;
  return i+1;
}// end partition func

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

int main() {
	int N, Xt, tsum;
	string Xs;
	vector<string> s(N, "");
    vector<int> t(N, 0);
	cin >> N;
    
    for (int i = 0; i < N; i++) {
    	cin >> s.at(i);
    	cin >> t.at(i);
    }
    
    cin >> Xs;
  
	for (int i = 0; i < N; i++) {
    	if (s.at(i) == Xs) {
        	Xt = i + 1;
        }
    }
    
    for (int i = Xt; i < N; i++) {
    	tsum += t.at(i);
    }
    
    cout << tsum << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int divisor(long long n) {
    ll mn=inf;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
             ll ans=0;
             ll a=n/i;
             while(a>0){
               ans++;
               a/=10;
             }
             mn=min(mn,ans);
               
        }
    }
    
   
      
    return mn;
}

int main() {
  ll n;
  cin>>n;
  cout<<divisor(n)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,i,f[44];
  scanf("%d",&a);
  for(i=2;i<a+1;i++)f[i]=-1;
  f[0]=1;
  f[1]=1;
  for(i=2;i<a+1;i++)f[i] = f[i-2]+f[i-1];
  printf("%d\n",f[a]);
  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

long long gcd(long long x, long long y) {
  if (y == 0) { return x; }
  else {
    return gcd(y, x%y);
  }
}

int main() {
  long long a, b; cin >> a >> b;
  cout << a/gcd(a, b)*b << endl;
  return 0;
}

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

int main()
{
	int n,s=0,s1=0,i;
	cin>>n;
	int a[n+1];
	for(i=1;i<=n;i++)  cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n;i+=2)
	{
		s+=a[i];
	}
	for(i=2;i<=n;i+=2)
	{
		s1+=a[i];
	}
	cout<<fabs(s-s1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
const int max_n = 1e6;
pair<ll, ll> p[max_n];
void solve(){
  ll sum = 0;
  for(int i=0 ; i<n ; i++){
    ll k = min(p[i].second, m);
    sum += k * p[i].first;
    m -= k;
    if(m == 0) break;
  }
  cout << sum << endl;
}
int main(){
  cin >> n >> m;
  for(int i=0 ; i<n ; i++){
    cin >> p[i].first >> p[i].second;
  }
  sort(p, p+n);
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cmath>
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int A,B,X,sum=0;;
  cin>>A>>B>>X;
  if(X%500!=0) X=X+500-(X%500);
  //cout<<X<<endl;
  if(A>2*B){
    sum=B*(X/500);
  }
  else if(A<B){
    if(X%1000==0) sum=A*(X/1000);
    else if(X>500)sum=A*(X/1000)+B;
    else sum=A;
  }
  else{
    if(X%1000==0) sum=A*(X/1000);
    else sum=A*(X/1000)+B;
  }
  cout<<sum<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF+7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    string s, t;
    cin >> N >> s >> t;
    REP(i, s.size()) {
        auto sbuf = s.substr(i);
        auto tbuf = t.substr(0, sbuf.size());
        if (sbuf == tbuf) {
            auto ss = s.substr(0, i);
            //cerr << ss << " " << t << endl;
            cout << ss.size() + t.size() << endl;
            return 0;
        }
    }
    cout << s.size() + t.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int p[100005];
int lpath[100005];
vector<int> adj[100005];

void dfs(int f, int par) {
	p[f] = par;
	lpath[f] = 0;
	for (auto it : adj[f]) {
		if (it != par) {
			dfs(it, f);
			lpath[f] = max(lpath[f], lpath[it] + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int u, v;
	cin >> u >> v;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(v, -1);
	int gap = 0;
	int f = u;
	while (f != v) {
		gap++;
		f = p[f];
	}
	f = u;
	int ans = 0;
	int pre = 0;
	while (gap > 0) {
		int gans = pre+lpath[f] + (gap / 2);
		ans = max(ans, gans);
		f = p[f];
		gap -= 2;
		pre++;
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100
#define INF 1<<30
typedef pair<int, int> P;
P r[MAX_N], b[MAX_N];
bool rused[MAX_N], bused[MAX_N];
int N;
int main(void){
	int cnt = 0;
	fill(rused, rused+N, false);
	fill(bused, bused+N, false);
	cin >> N;
	for(int i=0; i<N; i++) cin >> r[i].first >> r[i].second;
	for(int i=0; i<N; i++) cin >> b[i].first >> b[i].second;
	sort(r, r+N, [](auto& x, auto& y){
		return x.first > y.first;
	});
	for(int i=0; i<N; i++){
		int jpair = -1;
		int min_d = INF;
		for(int j=0; j<N; j++){
			int dx = b[j].first - r[i].first;
			int dy = b[j].second - r[i].second;
			if(dx > 0 && dy > 0 && !rused[i] && !bused[j]){
				if(min_d > dy){
					jpair = j;
					min_d = dy;
				}
			}
		}
		if(jpair != -1 && min_d != INF){
			rused[i] = true;
			bused[jpair] = true;
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
    int n; cin >> n;
    map<int, int> cnt;
    while (n --) {
        int a_i; cin >> a_i;
        cnt[a_i] += 1;
    }
    int result = 0;
    for (auto it : cnt) {
        int x, cnt_x; tie(x, cnt_x) = it;
        result += x <= cnt_x ? cnt_x - x : cnt_x;
    }
    cout << result << endl;
    return 0;
}


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

#define lp_ui(k,n) for(ui i = (k); i < (n); ++i)
#define lp_ul(k,n) for(ul i = (k); i < (n); ++i)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

using namespace std;

ull solve(void)
{
	ui N{}, D{};
	cin >> N >> D;

	ull cnt{1};
	for(ui i = D + 1; i + D < N;)
	{
		i = i + 2 * D + 1;
		++cnt;
	}

	return cnt;
}

int main(void)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(0);

	auto ans = solve();
	cout << ans << endl;

	return 0;
}


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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if(a == 0){
    cout << 1;
  }
   if(b == 0){
    cout << 2;
  }
   if(c == 0){
    cout << 3;
  }
   if(d == 0){
    cout << 4;
  }
   if(e == 0){
    cout << 5;
  }
  return 0;
}

Measured memory_bytes: 3632
//未証明
#include <iostream>
#include <string>
using namespace std;

string s;

bool check(int kaisu) {
	for (char c = 'a'; c <= 'z'; c++) {
		bool ok = true;
		for (int i = 0; i < (int)s.length() - kaisu; i++) {
			bool flag = false;
			for (int j = 0; j <= kaisu; j++) {
				if (s[i + j] == c) {
					flag = true;
					break;
				}
			}
			if (!flag) { ok = false; break; }
		}
		if (ok) return true;
	}
	return false;
}

signed main() {
	cin >> s;
	
	for (int i = 0; i < (int)s.length(); i++) {
		if (check(i)) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}
int main() {
  
  int A,B,C;
  cin>>A>>B>>C;
  
  if((A<C&&C<B)||(B<C&&C<A)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

void Main() {
  int n;
  cin >> n;

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

  long long c[n];
  c[0] = a[0];
  for (int i = 1; i < n; i++) {
    c[i] = a[i] + c[i - 1];
  }

  long long ans = 9999999999999999;
  long long f = 0, b = 2;
  for (int i = 1; i < n - 2; i++) {
    long long p = c[f], q = c[i] - c[f];
    for (int j = f + 1; j < i; j++) {
      if (abs(p - q) > abs(c[j] - (c[i] - c[j]))) {
        p = c[j];
        q = c[i] - c[j];
        f = j;
      } else {
        break;
      }
    }

    long long r = c[b] - c[i], s = c[n - 1] - c[b];
    for (int j = b + 1; j < n; j++) {
      if (abs(r - s) > abs((c[j] - c[i]) - (c[n - 1] - c[j]))) {
        r = c[j] - c[i];
        s = c[n - 1] - c[j];
        b = j;
      } else {
        break;
      }
    }

    long long ma = max(max(max(p, q), r), s);
    long long mi = min(min(min(p, q), r), s);
    ans = min(ans, ma - mi);

  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 2560
#import <stdio.h>
int main(){
    int p=0;
    int q=0;
    int r=0;
    int s=0;
    char c;
    while((c=getchar())!=EOF){
        if (c=='N') p++;
        else if (c=='S') q++;
        else if (c=='E') r++;
        else if (c=='W') s++;
        else break;
    }
    puts((p==0&&q>0)||(p>0&&q==0)||(r==0&&s>0)||(r>0&&s==0) ? "No" : "Yes");
}


Measured memory_bytes: 7628
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;

public class Main{
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        int ans = 0;
        long q = 2;
        long e = 1;
        long div;
        int loops = 43;

        if(N == 1){
            System.out.println(0);
            return;
        }

        while(true){
            div = (long) Math.pow(q, e);
            if(N % div == 0){
                N /= div;
                ans++;
                e++;
            }else{
                while(N % q == 0){
                    N /= q;
                }
                q++;
                if(q * q > N){
                    break;
                }
                e = 1;
            }
        }
        if(N != 1){
            ans++;
        }

        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long ll;

#ifdef RED
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = (int)1e6 + 5;
const int inf = (int)1e9 + 7;

int n, m;
int dp[N];
vector <int> g[N];

int dfs(int v) {
  if (dp[v]) {
    return dp[v];
  }if ((int)g[v].size() == 0) {
    return 0;
  }
  for (auto to : g[v]) {
    dp[v] = max(dp[v], dfs(to) + 1);
  }
  return dp[v];
}

int main() {
#ifdef RED
  freopen("a.in", "r", stdin);
#endif
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
  }
  int ans = -inf;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, dfs(i));
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 29312
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i=0;i<N;i++) {
        cin >> a.at(i);
    }
    int button =1;
    bool judge = false;
    int count =0;
    
    for (int i=0;i<N;i++) {
        button = a.at(button-1);
        count++;
        if(button==2) {
            cout << count << endl;
            judge = true;
            break;
        }
        
    }
    if(judge == false) {
        cout << -1 << endl;
    }
    
    
   }

 

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

int solve(int n, int a[]){
	int dp[n+1];
	dp[0]=0; dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	
	for(int i=3; i<=n; i++){
		dp[i]=min(abs(a[i]-a[i-1]) + dp[i-1], abs(a[i] -a[i-2]) +dp[i-2]);
	}
	
	return dp[n];
}

int main() {
	int n;
	cin>>n;
	int a[n+1];
	a[0]=0;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	int ans=solve(n,a);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import sys

class paiza_fmt_input:
    def __init__(self):
        self.cur = 0
        self.all_input = []

    def input_all(self):
        for line in sys.stdin:
            self.all_input.append(line)

    def get_one_line_with_split(self):
        input_cur = self.all_input[self.cur]
        self.cur += 1
        splitted_input = input_cur.split()
        return splitted_input

def get_bit_list(num):
    bit_list = []
    for i in range(64):
        if (num >> i) & 1:
            bit_list.append(i)
    return bit_list



def solve(inputs):
    line1_input = list(map(int, inputs.get_one_line_with_split()))
    path_num = line1_input[0]
    bit_list = get_bit_list(path_num)
    # print(bit_list)

    max_bit = bit_list[-1]
    # print(max_bit)

    dags = []
    for i in range(max_bit):
        dags.append([i+1, i+2, 0])
        dags.append([i+1, i+2, pow(2, i)])
    # print(dags)

    end_node_no = bit_list[-1] + 1
    bit_list.pop()
    ofs_num_cur = pow(2, max_bit)
    while True:
        if not bit_list:
            break
        bit = bit_list.pop()

        dags.append([bit+1, end_node_no, ofs_num_cur])
        ofs_num_cur += pow(2, bit)
    # print(dags)

    # output
    print(end_node_no, len(dags))
    for dag in dags:
        print(*dag)





inputs = paiza_fmt_input()
inputs.input_all()
solve(inputs)


Measured memory_bytes: 3064
#include <stdio.h>

int A[5000000],B[5000000];
int n;

void c_sort(int k){
  int C[5000000];
  int i,j;
  
  for(i = 0;i <= k;i++)C[i] = 0;
  for(j = 1;j <= n;j++)C[A[j]]++;
  for(i = 1;i <= k;i++)C[i] += C[i-1];
  for(j = n;j >= 1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

int main(){
  int i,max = 0;
  
  scanf("%d",&n);
  for(i = 1;i <= n;i++){
    scanf("%d",&A[i]);
    if(A[i] > max)max = A[i];
  }
  
  c_sort(max);

  for(i = 1;i < n;i++)printf("%d ",B[i]);
  printf("%d\n",B[i]);

  return 0;
}



Measured memory_bytes: 17432
#include<iostream>
#include<algorithm>
#include<cstring>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;

#define int long long

#ifdef lioraju
	#define ndbg(x) 
#else
	#define ndbg(x) x
#endif

const int mxsz = 1e5 + 5;

vector<int> AE[mxsz];

int dp[mxsz];
bool vis[mxsz];

int d(int p)
{
	if (vis[p]) return dp[p];
	
	vis[p] = 1;
	int mxn = 0;
	for (int x: AE[p])
		mxn = max(mxn, d(x)+1);
	
	return dp[p] = mxn;
}

signed main()
{
	ndbg( ios::sync_with_stdio(0); cin.tie(0); );
	int n, m; cin>>n>>m;
	for (int i=0, a, b;i<m;i++)
		cin>>a>>b, --a, --b, AE[a].push_back(b);
	
	int mxn = 0;
	for (int i=0;i<n;i++) mxn = max(mxn, d(i));
	cout<<mxn<<'\n';
}

Measured memory_bytes: 8704
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 256
N, A = map(int, input().split())
x = list(map(int, input().split()))

X = max(x)
if X < A:
    X = A
    
y = []
for i in x:
    y += [i-A]

dp = [[-1] * (2*N*X+1) for _ in range(N+1)]

def check(j, t):
    if dp[j][t] != -1:
        return dp[j][t]
    if  j == 0 and t == N * X:
        dp[j][t] = 1
        return 1
    if j >= 1 and (t-y[j-1] < 0 or t-y[j-1] > 2 * N * X):
        dp[j][t] = check(j-1, t)
        return dp[j][t]
    if j >= 1 and 0 <= t-y[j-1] and t-y[j-1] <= 2*N*X:
        dp[j][t] = check(j-1, t) + check(j-1, t- y[j-1])
        return dp[j][t]
    dp[j][t] = 0
    return 0

print (check(N, N*X)-1)


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  ll n;cin>>n;
  string a,b,c;cin>>a>>b>>c;

  ll ans=0;
  rep(i,0,n){
    if(a[i]==b[i]&&b[i]==c[i])ans+=0;
    else if(a[i]!=b[i]&&b[i]!=c[i]&&c[i]!=a[i])ans+=2;
    else ans++;
  }

  out(ans);

  return 0;
}


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

ans = 0
for row in range(N):
    tmp = C
    for col in range(M):
        tmp += A[row][col]*B[col]
    if tmp > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int n,a,i;
  int cnt[10001]={};

  cin>>n;

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

  for(i=0;i<10001;i++){
    while(cnt[i]>1){
      printf("%d ",i);
      cnt[i]--;
      n--;
    }
    if(cnt[i]){
      printf("%d",i);
      if(n==1){
        printf("\n");
        return 0;
      }
      else{
        printf(" ");
        n--;
      }
    }
  }

	return 0;
}


Measured memory_bytes: 3256
N = gets.to_i
S = gets.chomp.split('')

r_list = []
g_list = []
b_list = []
S.each_with_index do |s,i|
  if s == 'R'
    r_list.push(i)
  elsif s == 'G'
    g_list.push(i)
  elsif s == 'B'
    b_list.push(i)
  else
    raise
  end
end
result = r_list.size * g_list.size * b_list.size
1.upto(N/2) do |n|
  (N - (2 * n)).times do |i|
    if S[i] != S[i+n]
      if S[i+2*n] != S[i] && S[i+2*n] != S[i+n]
        result -= 1
      end
    end
  end
end
# 1r_list.each do |r|
# 1  g_list.each do |g|
# 1    b_list.each do |b|
# 1      rgb = [r,g,b].sort
# 1      next if rgb[1] - rgb[0] == rgb[2] - rgb[1]
# 1      result += 1
# 1    end
# 1  end
# 1end

puts result



Measured memory_bytes: 14596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int l,n;cin>>l>>n;
	int sum=0;
	rep(i,n){
		int x,w;cin>>x>>w;
		sum+=x*w;
	}
	if(sum==0)cout<<0<<endl;
	else{
	int hu=(sum<0)?1:(-1);
	printf("1\n%d %d\n",hu,abs(sum));
	}
	return 0;
}

Measured memory_bytes: 1196
n, m = map(int, input().split())
count = [1 for i in range(n + 1)]
count[0] = 0
flag = [False for i in range(n + 1)]
flag[1] = True
for i in range(m):
    x, y = map(int, input().split())
    if flag[x] == True:
        flag[y] = True
    count[x] -= 1
    count[y] += 1
    if count[x] == 0:
        flag[x] = False
print(sum(flag))

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

using namespace std;

int main(){
	int k;
	cin >> k;
	long long ans = 0;
	for(int i=1;i<=k;++i){
		for(int j=1;j<=k;++j){
			for(int l=1;l<=k;++l){
				ans+=__gcd(i,__gcd(j,l));
			}
		}
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3576
use std::io::{self, BufRead};

pub fn lower_bound(vec: &[(usize, usize, i32)], val: i32) -> usize {
  let mut lo = 0;
  let mut hi = vec.len();
  while hi - lo > 0 {
    let p = (hi + lo) / 2;
    if vec[p].2 < val {
      lo = p + 1;
    } else {
      hi = p;
    }
  }
  return lo;
}

pub fn upper_bound(vec: &[(usize, usize, i32)], val: i32) -> usize {
  let mut lo = 0;
  let mut hi = vec.len();
  while hi - lo > 0 {
    let p = (hi + lo) / 2;
    if vec[p].2 > val {
      hi = p;
    } else {
      lo = p + 1;
    }
  }
  return lo;
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
  let mut xs: Vec<(usize, usize, i32)> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).enumerate().map(|(i, h)| (i, h, i as i32 - h as i32)).collect();
  xs.sort_by(|a, b| (a.2).cmp(&(b.2)));
  let mut ans = 0;
  for i in 0..n {
    let d = (xs[i].0 + xs[i].1) as i32;
    let lo = lower_bound(&xs, d);
    let hi = upper_bound(&xs, d);
    ans += hi - lo;
  }
  println!("{}", ans);
}

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using  namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	int ar[n];
	int dp[n];
	for(int i=0;i<n;i++)
		cin>>ar[i];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=abs(ar[i]-ar[i-1])+dp[i-1];
		for(int j=2;j<=k;j++){
			if(i-j>=0)
				dp[i]=min(dp[i],abs(ar[i]-ar[i-j])+dp[i-j]);
			else
				break;
		}
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, D = LI()
XY = []
ans = 0
for i in range(N):
    x, y = LI()
    if x ** 2 + y ** 2 <= D ** 2:
        ans += 1
print(ans)




Measured memory_bytes: 10872
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 0; i < n; i++){
        ans *= (i+1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#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>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long 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 pair<long, long> PLL;
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(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

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

const double EPS = 1e-9;
const double INF = 1e9;


int pari(string str){
	int i,j;
	for(i=0,j=SZ(str)-1;i<j;i++,j--)if(str[i]!=str[j])return 0;
	return 1;
}
int main(){
	string str;
	long sum=0;
	while(cin>>str)sum+=pari(str);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

int main(){
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
    for(int i = 0;i < s.size();i++){
        for(int j = 0;j < t.size();j++){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j]+1;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    string res = "";
    int i = s.size();
    int j = t.size();
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            res = s[i-1]+res;
            i--, j--;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 35584
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer>list = new ArrayList<>();
		for(int i = 0;i<n;i++){
			int a = sc.nextInt();
			list.add(a);
		}Collections.sort(list);
		int al =0;
		int bo = 0;
		for(int i =0;i<n;i++){
			al+=(i+1)%2*list.get(n-1-i);
			bo+=(i)%2*list.get(n-1-i);
		}System.out.println(al-bo);
	}
}

Measured memory_bytes: 23764
n = []
n = input().split()
n_1 = int(n[0])
x = int(n[1])
t = int(n[2])
 
if(n_1%x==0):
  count,mod = divmod(n_1,x)
else:
  count,mod = divmod(n_1,x)
  count = count + 1
 
print(count*t)

Measured memory_bytes: 9116
open Scanf

let ($) f g = f g

let factorize n =
  let s = sqrt $ float_of_int n in
  let n = ref n in
  let i = ref 2 in
  let xs = ref [] in
  while float_of_int !i <= s do
    while !n mod !i = 0 do
      xs := !i::!xs;
      n := !n / !i
    done;
    i := !i + 1
  done;
  if float_of_int !n > s then xs := !n::!xs;
  !xs

let rec gcd a b = 
  if b = 0 then a
    else gcd b (a mod b) 

let lcm a b =
  a * (b / gcd a b)

let multi_lcm xs =
  let result = List.fold_left (fun a x ->
    match a with
    | None -> Some x
    | Some r -> Some (lcm r x)
  ) None xs
  in
  match result with
  | None -> failwith "Something wrong"
  | Some r -> r

let _ =
  let n = scanf "%d\n" (fun x -> x) in
  let rec loop i xs =
    if i >= n then xs
    else (
      let v = scanf "%d\n" (fun x -> x) in
      if List.mem v xs then loop (i + 1) xs
      else loop (i + 1) $ v::xs
    ) in
  let xs = loop 0 [] in
  print_int $ multi_lcm xs



Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	s := nextMega()

	rank := 0
	sum := 0
	for i := 0; i < n; i++ {
		ok := false
		if s[i] == 'a' && sum < a+b {
			sum++
			ok = true
		} else if s[i] == 'b' {
			rank++
			if sum < a+b && rank <= b {
				sum++
				ok = true
			}
		}
		if ok {
			puts("Yes")
		} else {
			puts("No")
		}
	}
	wt.Flush()
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
int a[1252][1252];
int enemy[1252];
int head[1252];
int tim[1252];

int main(){
    scanf("%d",&n);
    REP(i,n)REP(j,n-1)scanf("%d",&a[i][j]),a[i][j]--;
    int ans = 0;
    queue<int> Q;
    REP(i,n)enemy[i] = a[i][0];
    REP(i,n)if(enemy[enemy[i]]==i){
        Q.push(i);
    }
    int cnt = 0;
    while(Q.size()){
        int p = Q.front(); Q.pop();
        if(enemy[enemy[p]]!=p)continue;
        cnt++;
        int q = enemy[p];
        int t = max(tim[p], tim[q])+1;
        CHMAX(ans, t);
        tim[p] = tim[q] = t;
        head[p]++; head[q]++;
        if(head[p] != n-1){
            enemy[p] = a[p][head[p]];
            if(enemy[enemy[p]]==p){
                Q.push(p);
            }
        }
        if(head[q] != n-1){
            enemy[q] = a[q][head[q]];
            if(enemy[enemy[q]]==q){
                Q.push(q);
            }
        }
    }
    if(cnt != n*(n-1)/2){
        puts("-1");
    }else{
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 6400
<?php

$rooms     = array_fill_keys(range(1, 10), 0);
$floors    = array_fill_keys(range(1, 3), $rooms);
$buildings = array_fill_keys(range(1, 4), $floors);

fscanf(STDIN, '%d', $n);

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%d %d %d %d', $b, $f, $r, $v);

    $buildings[$b][$f][$r] += $v;
}

foreach ($buildings as $floors) {
    $floor = array();
    foreach ($floors as $rooms) {
        $floor[] = sprintf(' %s%s', implode(' ', $rooms), PHP_EOL);
    }
    $tenant[] = implode('', $floor);
}

echo implode(str_repeat('#', 20) . "\n", $tenant);

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

int main()
{
	double i, max = 0, min = 0;
	bool flag = true;

	while (cin >> i){
		if(flag){
			max = i;
			min = i;
			flag = false;
		}
		else{
			if (i < min)
				min = i;
			if (i > max)
				max = i;
		}
	}
	cout << max - min << endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double x;   cin >> x;
        ans += 1/x;
    }
    cout << fixed << setprecision(12) << 1/ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    ll n, a, b, k, mn = INF;

    cin >> n;

    for(a = 1; a <= sqrt(n); a++){
        if(n % a == 0){
            b = n / a;
            k = 0;
            for(; b != 0; b /= 10){
                k++;
            }
            mn = min(mn, k);
        }
    }

    cout << mn << endl;
}

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

#define ll long long
#define MOD 1000000007
#define MAX 1000000



int main(){
    int a;
    for(int i=1;i<=5;i++){
        cin>>a;
        if(a==0){
            cout<<i<<endl;
        }
    }
}


Measured memory_bytes: 3516
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
N = int(input())
a = list(map(int, input().split()))

def sol(N,a):
    nex = 1
    con = 0

    if  not 1 in a:
        return -1
    for i in range(N):
        if nex == a[i]:
            nex +=1
        else:
            con +=1
    return con
        
print(sol(N,a))

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int K = 1e5+5;
int arr[105];
int dp[K];
int n, k;

int dfs(int remain){
    if(dp[remain] != -1) return dp[remain];
    bool res = 0;
    for(int i = 0; i < n; ++i){
        if(remain >= arr[i]) res |= (dfs(remain-arr[i]) == 0);
    }
    return dp[remain] = res;
}

void solve(){
    cin >> n >> k;
    for(int i = 0; i < n; ++i) cin >> arr[i];
    memset(dp, -1, sizeof dp);

    cout << (dfs(k)==1 ? "First": "Second") << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 8672
import bisect
ALP = 'abcdefghijklmnopqrstuvwxyz'

S = input()
K = int(input())

N = len(S)
substr = []
for i in range(N):
    for j in range(i, min(i + 5, N)):
        tmp_substr = S[i:j+1]

        if tmp_substr in substr:
            continue

        if len(substr) <= 4:
            substr.append(tmp_substr)
            substr.sort()
        else:
            substr.append(tmp_substr)
            substr.sort()
            del substr[-1]

print(substr[K-1])

Measured memory_bytes: 3188