akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////



ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}
#define MAX_N (ll)1E6+5///変更！！！！！！！
vector<ll>prime;
bool is_prime[MAX_N+1];
void precal(){
    rep(i,0,MAX_N)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    rep(i,2,MAX_N){
        if(is_prime[i]){
            prime.pb(i);
            for(ll j=2*i;j<=MAX_N;j+=i)is_prime[j]=false;
        }
    }
}
vector<l_l> fact(ll n){
    vector<l_l>v;
    for(ll p:prime){
        if(p*p>n)break;
        ll c=0;
        while(n%p==0){
            n/=p;
            c++;
        }
        if(c)v.pb(l_l(p,c));//pという素因数がc個入っている
    }
    if(n!=1){
        ll vsize=v.size();
        if(vsize>=1&&v[vsize-1].first==n)v[vsize-1].second++;
        else v.pb(l_l(n,1));
    }
    if(v.size()==0){
        v.pb(l_l(1,1));
    }
    return v;
}
/////////////////////////////////////////////////////
int main(){fastio
    precal();
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ma[MAX_N];memset(ma,0,sizeof(ma));
    rep(i,0,n-1){
        if(a[i]==1)continue;
        vector<l_l>v=fact(a[i]);
        for(auto x:v){
            Max(ma[x.first],x.second);
        }
    }
    /*
    rep(i,0,20){
        cout<<i<<":"<<ma[i]<<endl;
    }*/
    ll gcd=1;
    rep(i,2,MAX_N-1){
        gcd=mod(gcd*po(i,ma[i]));
    }
    ll b[n];
    rep(i,0,n-1){
        b[i]=gcd*bunbo(a[i]);
    }
    ll ans=0;
    rep(i,0,n-1)Add(ans,b[i]);
    cout<<ans<<endl;
    
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int A[n]={};
    for (int i=0;i<n;i++){
        cin >> A[i];
    }
    
    for (int j=0;j<n;j++){
        int v,k;
        v = A[j];
        
        k = j-1;
        while(k>=0 && A[k]>v){
            A[k+1] = A[k];
            A[k] = v;
            k -=1;
        }
        
        for (int l=0;l<n;l++){
            if(l<n-1) cout << A[l] << " ";
            else cout << A[l] <<endl;
        }    
        
    }
    return 0;
}


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

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(const 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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef pair<int, int> pi;

vector<int> v;
int dp[100005][2];
int n;

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    const ll INF = 1e16;
    cin>>n;

    ll A[n];
    for (int i=0;i<n;++i) cin>>A[i];
    vector<vector<ll> > dp(n+1, vector<ll> (2));

    dp[1][0] = A[0];
    dp[1][1] = -A[0];
    for (int i=2;i<=n;++i){
        for (int j=0;j<2;++j){
            if (j==0){
                dp[i][j] = max(dp[i-1][0] + A[i-1], dp[i-1][1] - A[i-1]);
            }
            else {
                dp[i][j] = max(dp[i-1][0] - A[i-1], dp[i-1][1] + A[i-1]);
            }
        }
    }
    cout<<dp[n][0]<<endl;

    return 0;
}

Measured memory_bytes: 6528
//Space Coconut Grab
#include<bits/stdc++.h>
using namespace std;

#define INF 10000000
typedef long long ll;

//x^t
ll mypow(ll x, ll t){
  return (ll)pow((double)x, (double)t);
}

ll ans[1000001];

int main(){
  for(ll i=0; i<=1000000; i++)ans[i]=INF;
  for(ll z=0; mypow(z, 3)<=1000000; z++){
    ll tmp;
    for(ll y=0; (tmp=mypow(z,3)+mypow(y,2))<=1000000; y++)
      if(ans[tmp]>y+z)
        ans[tmp]=y+z;
  }
  while(true){
    ll e;
    cin>>e;
    if(e==0)break;
    ll mn=INF;
    for(int i=0; i<=e; i++)
      if(mn>ans[i]+(e-i))mn=ans[i]+(e-i);
    cout<<mn<<endl;
  }
  return 0;
}

Measured memory_bytes: 9032
#include <iostream>
#include <cstdio>
using namespace std;
 
int main() 
{
  int a,b;
  cin >> a >> b;
  int d,r;
  double f;
  d = a/b;
  r = a % b;
  double c,e;
  c = (double)a;
  e = (double)b;
  f = c / e;
  cout << d << " " << r << " ";
  printf("%lf\n",f);
  return 0;
}


Measured memory_bytes: 3236
#include <stdio.h>
#include <string.h>
                                                                                                
  
int main(void){
                                                                                                
   
    char a[11];

    char b[11];

    char c[11];
   
      
    scanf("%s %s %s", a, b, c );
   

    if( a[ strlen(a) - 1 ] == b[0] && b[ strlen(b) - 1 ] == c[0] ){

        printf("YES\n");

        return 0;

        }
   

    printf("NO\n");


    return 0;
                                                          
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    int N;
    string c;
    cin >> N >> c;

    int ans = 0;
    int l = 0, r = 0;
    for (int i = N-1; i >= 0; --i) {
        if (c[i] == 'R') {
            r = i;
            break;
        }
    }
    for (int i = 0; i < N; ++i) {
        if (c[i] == 'W') {
            if (i < r) {
                ans++;
                swap(c[i], c[r]);
                while (r >= 0) {
                    if (c[r] == 'R') {
                        break;
                    }
                    r--;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define yabs(x) ((x<0)?(-(x)):(x)) 

typedef long long LL;
using namespace std;

int D;
LL ppow[20];

void Init() {
	scanf("%d",&D);
	ppow[0]=1ll;
	for (int i=1;i<=18;++i) ppow[i]=ppow[i-1]*10ll;
}

int Dfs(int now,int len,LL D) {
	if (yabs(D)>=ppow[len-now]) return 0;
	if (len-now-1<now) return D==0;
	if (len-now-1==now) return (D==0)*10;
	int ret=0,mx,mn;
	for (int i=-9;i<=9;++i) {
		if (!now) mx=min(9,9-i),mn=max(1,-i);	
		else mx=min(9,9-i),mn=max(0,-i);
		if (mx>=mn)
			ret+=(mx-mn+1)*Dfs(now+1,len,D-i*(ppow[len-now-1]-ppow[now]));
	}
	return ret;
}

void Solve() {
	LL ans=0;
	for (int i=0;i<=18;++i) ans+=Dfs(0,i,D);
	printf("%lld\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
       
        while (true) {
            String[] data = sc.nextLine().split(" ");
            int n = Integer.parseInt(data[0]);
            int x = Integer.parseInt(data[1]);
            if (n == 0 && x == 0)
                break;
            int count = 0;
            for (int i = 1; i <= n - 2; i++) {
                for (int j = i + 1; j <= n - 1; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if ((i + j + k) == x)
                            count++;
                    }
                }
            }
            System.out.println(count);
 
        }
    }
 
}

Measured memory_bytes: 26500
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>

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

std::vector<std::pair<long long, int>> prime_factor(long long n) {
    // nの素因数分解。計算量はO(sqrt(n))なので、long longも入り得る。
    // intにおさまらない素数を入れた場合を考えて、keyはlong longにしておく。戻り値はintで十分と思われる。
    std::vector<std::pair<long long, int>> res;
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int num = 0;
            while(n % i == 0) {
                num++;
                n = n / i;
            }
            res.push_back(std::pair<long long, int>({i, num}));
        }
    }
    if (n != 1) {
        res.push_back(std::pair<long long, int>({n, 1}));
    }
    return res;
}

std::vector<int> prime_sieve(int n) {
    // n以下の素数を返す。
    // 計算時間はO(n)程度なので、long long型は入らない。
    std::vector<int> ret;
    std::vector<bool> prime_flag;
    prime_flag.resize(n+1, true);
    prime_flag[0] = false;
    prime_flag[1] = false;
    for (int i = 2; i <= n; i++) {
        if (prime_flag[i]) {
            ret.push_back(i);
            for (int j = i * 2; j <= n; j += i) {
                prime_flag[j] = false;
            }
        }
    }
    return ret;
}

const int MAX_N = 10050;
int N;
long long a[MAX_N];
long long tmp[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = N; 0 <= i; i--) {
        std::cin >> a[i];
    }

    std::set<long long> ret;

    int g = abs(a[N]);
    for (int i = 0; i <= N - 1; i++) {
        g = gcd(g, abs(a[i]));
    }

    if (g != 1) {
        auto fac = prime_factor(g);
        for (auto pair : fac) {
            ret.insert(pair.first);
        }
    }

    auto cand = prime_sieve(N);

    for (int p : cand) {
        for (int i = 0; i <= N; i++) {
            tmp[i] = a[i] % p;
        }
        for (int i = p; i <= N; i++) {
            int r = i % (p - 1);
            if (r == 0) {
                r = p - 1;
            }
            tmp[r] += tmp[i];
        }
        bool is_ok = true;
        for (int i = 0; i <= p - 1; i++) {
            if (abs(tmp[i]) % p != 0) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            ret.insert(p);
        }
    }

    for (auto itr = ret.begin(); itr != ret.end(); ++itr) {
        std::cout << (*itr) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 384
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

H = INT()
W = INT()
N = INT()

print(-(-N//max(H, W)))

Measured memory_bytes: 5144
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

void solve()
{

  int n,w;
  cin>>n>>w;
  vll a(n+1),b(n+1);

  rep(i,n)
  {
    cin>>a[i+1]>>b[i+1];
  }

  ll dp[n+1][w+1];
  rep(i,n+1)
  {
    rep(j,w+1)
    {
      dp[i][j]=0;
    }
  }

  loop(i,1,n)
  {
    loop(j,1,w)
    {
      if(j<a[i])
        dp[i][j]=dp[i-1][j];
      else
        dp[i][j]=max(b[i]+dp[i-1][j-a[i]],dp[i-1][j]);
    }
  }

  cout<<dp[n][w]<<endl;

} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

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

  return 0;
}


Measured memory_bytes: 82376
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define BUF_SIZE 30

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

#define VERTEXES_MAX 200000
#define LPOOL_MAX (VERTEXES_MAX*3+50)

struct list {
    struct list *next;
    int dst;
    uint64_t point;
};


struct list lpool[LPOOL_MAX];
int lpos = 0;

struct list *create_graph(int vs) {
    struct list *graph = &lpool[lpos];
    lpos += vs;
    int i;
    // initialization
    for(i = 0; i < vs; i++) {
        graph[i].next = &graph[i];
        graph[i].dst = i;
        graph[i].point = 0;
    }
    return graph;
}

void add_list(struct list *head, int v) {
    struct list *elem = &lpool[lpos++];
    elem->next = head->next;
    elem->dst = v;
    head->next = elem;
}

// Tree DP
void dfs(struct list *graph, int this, int parent, uint64_t point) {
    struct list *head = &graph[this];
    head->point += point;
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
        int dst = elem->dst;
        if(dst == parent) continue;
        dfs(graph, elem->dst, this, head->point);
    }
}

int main(void) {
    int vs, qs;
    get_int2(&vs, &qs);
    int es = vs - 1;
    struct list *graph = create_graph(vs);
    int i;
    for(i = 0; i < es; i++) {
        int v1, v2;
        get_int2(&v1, &v2);
        // 1-indexed -> 0-indexed
        v1--; v2--;
        add_list(&graph[v1], v2);
        add_list(&graph[v2], v1);
    }
    for(i = 0; i < qs; i++) {
        int v; int p;
        get_int2(&v, &p);
        // 1-indexed -> 0-indexed
        v--;
        graph[v].point += p;
    }
    dfs(graph, 0, -1, 0);
    for(i = 0; i < vs; i++) {
        printf("%llu%c", graph[i].point, (i==(vs-1))?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 25728
N, K = map(int, input().split())
li = []
ansli = []
for i in range(K):
    d = int(input())
    li.extend(list(map(int, input().split())))
for i in range(1, N+1):
    if i not in li:
        ansli.append(i)
print(len(ansli))

Measured memory_bytes: 9208
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;

const int MAX_N = 2019;
char grid[MAX_N][MAX_N];
int height, width, length_from[MAX_N][MAX_N], leftmost_obstacle[MAX_N][MAX_N], rightmost_obstacle[MAX_N][MAX_N], up_obstacle[MAX_N][MAX_N], down_obstacle[MAX_N][MAX_N];

int outside_grid(int h, int w)
{
    return (h < 1 || h > height || w < 1 || w > width);
}

int main()
{
    scanf("%d %d", &height, &width);

    for(int i = 1; i <= height; i++)
            scanf("%s", grid[i] + 1);

    memset(up_obstacle, 0, sizeof(up_obstacle));
    memset(leftmost_obstacle, 0, sizeof(leftmost_obstacle));

    for(int h = 1; h <= height; h++)
    {
        for(int w = 1; w <= width; w++)
        {  // cout << grid[h][w];
            leftmost_obstacle[h][w] = (grid[h][w] == '#' ? 0 : leftmost_obstacle[h][w - 1] + 1);

            up_obstacle[h][w] = (grid[h][w] == '#' ? 0 : up_obstacle[h - 1][w] + 1);
        }//cout << endl;
    }

    memset(rightmost_obstacle, 0, sizeof(rightmost_obstacle));
    memset(down_obstacle, 0, sizeof(down_obstacle));

    for(int h = height; h >= 1; h--)
    {
        for(int w = width; w >= 1; w--)
        {
            rightmost_obstacle[h][w] = (grid[h][w] == '#' ? 0 : rightmost_obstacle[h][w + 1] + 1);

            down_obstacle[h][w] = (grid[h][w] == '#' ? 0 : down_obstacle[h + 1][w] + 1);
        }
    }

    int answer = 0;
    for(int  h = 1; h <= height; h++)
    {
        for(int w = 1; w <= width; w++)
        {
            if(grid[h][w] == '#')
                continue;

            //cout << "h = " << h << " w = " << w << "L = " << leftmost_obstacle[h][w] << " R = " << rightmost_obstacle[h][w] << endl;
            answer = max(answer, leftmost_obstacle[h][w] + up_obstacle[h][w] + rightmost_obstacle[h][w] + down_obstacle[h][w] - 3);
        }
    }

    printf("%d\n", answer);
    return 0;
}


Measured memory_bytes: 71552
#include <stdio.h>
int main(){
  char s[4];
  char t[4];
  scanf("%s",s);
  scanf("%s",t);
  int cnt = 0;
  for(int i=0;i<3;i++){
    if(s[i] == t[i]){
      cnt++;
    }
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=[list(map(int,input().split())) for i in range(M)]
d = 0
e = 0
aa=sorted(a)
bb=sorted(b)

e=aa[0]+bb[0]

for i in range(M):
	d=a[c[i][0]-1]+b[c[i][1]-1]-c[i][2]
	if d<e:
		e=d

print(e)

Measured memory_bytes: 40488
import java.io.*;
import java.util.*;

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private void solve(Scanner sc, PrintWriter out) {
    int N = sc.nextInt();
    long[] count = new long[2];
    for (int i = 0; i < N; ++i) {
      int T = sc.nextInt();
      int A = sc.nextInt();

      if (i == 0) {
        count[0] = T;
        count[1] = A;
        continue;
      }

      long n = Math.max((count[0] + T - 1) / T, (count[1] + A - 1) / A);
      count[0] = T * n;
      count[1] = A * n;
    }

    out.println((count[0] + count[1]));
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 13472
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        a: usize,
        b: usize,
    }

    for i in 0..h {
        if i < b {
            for j in 0..w {
                if j < a {
                    print!("0");
                } else {
                    print!("1");
                }
            }
        } else {
            for j in 0..w {
                if j < a {
                    print!("1");
                } else {
                    print!("0");
                }
            }
        }
        println!();
    }
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  int n;
  while (scanf("%d", &n) != EOF)
  {
    int d[n][2];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < 2; j++)
        scanf("%d", &d[i][j]);

    bool can = false;
    for (int i = 2; i < n; i++)
    {
      bool yes = true;
      for (int j = 0; j < 3; j++)
        if (d[i - j][0] != d[i - j][1])
          yes = false;
      can |= yes;
    }
    printf("%s\n", can ? "Yes" : "No");
  }
  return 0;
}

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

int main(void){
  int N;
  string S;
  cin >> N >> S;
  
  int sum = 0;
  int ans = 0;
  for(int i=0; i<N; i++){
    if(S[i] == 'I'){
      sum++;
    }else{
      sum--;
    }
    if(sum > ans)
      ans = sum;
  }
  cout << ans << endl;
  return 0;
}


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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int X,Y; cin >> X >> Y;
    int x,y;

    if((Y-2*X)%2){
        cout << "No" << en;
        return;
    }

    y = (Y-2*X)/2;

    if(y<0){
        cout << "No" << en;
        return;
    }

    x = X-y;
    if(x<0){
        cout << "No" << en;
        return;
    }

    cout << "Yes" << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 x, y; cin >> x >> y;
        if(x < y) { swap(x, y); }
        _i64 r = x % y;
        while(r != 0) { x = y; y = r; r = x % y; }
        cout << y << endl;
    }
    return 0;
}


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

int main() {
    string O,E;
    cin >> O >> E;
    if(O.size() == E.size()) {
        for(int i = 0; i < O.size(); i++) {
            cout << O[i] << E[i];
        }
        cout << endl;
    }
    else {
        for(int i = 0; i < E.size(); i++) {
            cout << O[i] << E[i];
        }
        cout << O[O.size()-1] << endl;
    }
}

Measured memory_bytes: 256
<?php
  while (true) {
    $height_width = explode(" ", trim(fgets(STDIN)));
    $h = $height_width[0];
    $w = $height_width[1];
    if ($h == 0 && $w == 0) {
      break;
    }

    for($i = 0; $i < $h; $i++){
      for($j = 0; $j < $w; $j++){
        if ($i == 0 || $i == $h -1) {
          echo '#';
        } elseif ($j ==0 || $j == $w - 1) {
          echo '#';
        } else {
          echo '.';
        }
      }
      echo PHP_EOL;
    }
    echo PHP_EOL;
  }

Measured memory_bytes: 15352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TOPSIC
{
    partial class Program
    {
        static void Main(string[] args)
        {
          string[] AB = Console.ReadLine().Split(' ');
            int A = int.Parse(AB[0]);
            int B = int.Parse(AB[1]);


            double ansA = A / 0.08;
            double ansB = B / 0.1;

            double ansA1 = (A + 1) / 0.08;
            double ansB1 = (B + 1) / 0.1;

            for (int i = (int)Math.Ceiling(ansA); i < (int)Math.Ceiling(ansA1); i++)
            {
                for (int j = (int)Math.Ceiling(ansB); j < (int)Math.Ceiling(ansB1); j++)
                {
                    if (i == j)
                    {
                        Console.WriteLine(i);
                        return;
                    }
                }
            }

            Console.WriteLine("-1");


        }
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main(){
    int s;
    cin >> s;
    int h = (int)s/3600;
    int m = (int)s%3600/60;
    s = (int)s%3600%60;

    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

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

int main() {
  string S,T;
  int N;
  cin >> S >> T;
  
  if(S.length()+1 == T.length() && S == T.substr(0,S.length())){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3576
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using pii = std::pair<int, int>;
using namespace std;

ll gcd(ll a, ll b) { return a < b ? gcd(b, a) : b == 0 ? a : gcd(b, a % b); }

int main() {
  ll N;
  cin >> N;
  vec<ll> A(N);

  REP(i, N) { cin >> A[i]; }

  vec<ll> L(N + 1);
  L[0] = 0;
  for (ll i = 0; i < N; i++) {
    L[i + 1] = gcd(L[i], A[i]);
  }
  vec<ll> R(N + 1);
  R[N] = 0;
  for (ll i = N; i >= 1; i--) {
    R[i - 1] = gcd(R[i], A[i - 1]);
  }

  ll answer = -1;
  for (int i = 0; i < N; i++) {
    answer = max(answer, gcd(L[i], R[i + 1]));
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int p;
int dp[101][101][101];
int cost[101][101];
int x[101],y[101];


int main(void){
	scanf("%d%d",&n,&p);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	for(int i=0;i<n;i++){
		int prev=0;
		for(int j=i;j<n;j++){
			int nx=max(0,x[j]-prev);
			int newcost=max(y[j]-nx,0);
			prev=newcost;
			cost[i][j+1]=newcost;
		}
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				dp[i][j][k]=-1;
			}
		}
	}
	dp[0][0][0]=p;
	int res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<=i;k++){
				if(dp[i][j][k]>=0.0){
					dp[i+1][j][i+1]=max(dp[i+1][j][i+1],dp[i][j][k]);
					int val=x[i]-cost[k][i];
					if(val-y[i]>=0){
						dp[i+1][j+1][i+1]=max(dp[i+1][j+1][i+1],dp[i][j][k]);
						res=max(res,j+1);
						//printf("%d %d %d %f\n",i+1,j+1,i+1,dp[i+1][j+1][i+1]);
					}else if(dp[i][j][k]-cost[k][i+1]>=0){
						dp[i+1][j+1][k]=max(dp[i+1][j+1][k],dp[i][j][k]-cost[k][i+1]);
						res=max(res,j+1);
						//printf("%d %d %d %f %f\n",i+1,j+1,k,dp[i+1][j+1][k],cost[k][i+1]);
					}
				}
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 7204
#include <stdio.h>

int check_abc(int a, int b, int c, int A, int B, int C) {
    if(a<=A && b<=B && c<=C) {
        return 1;
    } else {
        return 0;
    }
}

int main() {
    int X, A, B, C, a, b, c;
    scanf("%d %d %d %d", &A, &B, &C, &X);

    a = X/500;
    b = (X - 500*a)/100;
    c = (X - 500*a - 100*b)/50;


    int i, j, k, ans=0, count=0;

    for(i=a; i>=0; i--) {
        // if(i>A) {
        //     continue;
        // }

        count += 1;
        ans += check_abc(i, b, c, A, B, C);
        // printf("%d %d %d\n", i, b, c);

        k = c;

        for(j=b-1; j>=0; j--) {
            k += 2;

            // if(j>B) {
            //     continue;
            // }
            // if(k>C) {
            //     break;
            // }

            ans += check_abc(i, j, k, A, B, C);
            // printf("%d %d %d\n", i, j, k);
            count += 1;
        }

        b += 5;
    }

    // printf("%d %d\n", ans, count);
    printf("%d\n", ans);

    return 0;
}

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

using namespace std;
typedef long long ll;


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

    int flag =0;

    int half;
    half=S.length()/2;

    for (int i=0;i<half;i++){
        if(S[i]!=S[S.length()-1-i]){
            flag=1;
        }
    }

    for (int i=0;i<(half/2);i++){
        if(S[i]!=S[half-1-i]){
            flag=1;
        }
        if(S[half+1+i]!=S[S.length()-1-i]){
            flag=1;
        }
    }

    if(flag==0){
        cout << "Yes"<< endl;
    }else {
        cout << "No"<< endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,m;
signed main()
{
	n=read(),m=read();
	if (m==1) cout<<0;else cout<<n-m;
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int s = h1 * 60 + m1;
    int t = h2 * 60 + m2;
    print(max((t - k) - s, 0));
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,W;
ll w[200];
ll v[200];
ll a,b,c;

typedef pair<int,ll> P;

map<P,ll> m;

ll ans(int i ,ll j) {
	if(m.find(P(i,j)) != m.end()) {
		return m[P(i,j)];
	}
	if(i >= n) {
		return m[P(i,j)] = 0;
	}

	if(j + w[i] > W) {
		return m[P(i,j)] = ans(i + 1,j);
	}

	return m[P(i,j)] = max(ans(i + 1,j),ans(i + 1,j + w[i]) + v[i]);
}


int main(){
	cin >> n >> W;
	REP(i,n) {
		cin >> w[i] >> v[i];
	}

	cout << ans(0,0) << endl;
	return 0;
}


Measured memory_bytes: 6400
n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(m)]
arr=sorted(arr,key=lambda x:x[0])
arr=sorted(arr,key=lambda x:x[1])
cnt=0
pos=0
for i in range(m):
  if arr[i][0]<pos:
    continue
  else:
    cnt+=1
    pos=arr[i][1]
print(cnt)

Measured memory_bytes: 29932
#include <bits/stdc++.h>
using namespace std;
#define maxn 100009
vector <int> ed[maxn];
int fi[maxn]={0};
int du[maxn]={0};
int n,m,tt=1;
void dfs(int x,int fa) {
    int a,b,c,i,j;
    fi[x]=tt++;
    for(a=0;a<ed[x].size();a++) 
    if(ed[x][a]!=fa) {
        if(fi[ed[x][a]]&&fi[ed[x][a]]<fi[x]) {printf("%d %d\n",x,ed[x][a]);du[x]^=1;continue;}
        else if(!fi[ed[x][a]]) dfs(ed[x][a],x);
    }
    if(x==1) return;
    if(du[x]) {printf("%d %d\n",x,fa);du[x]^=1;}
    else {printf("%d %d\n",fa,x);du[fa]^=1;}
}
int main(){
    scanf("%d%d",&n,&m);
    if(m%2) {printf("-1\n");return 0;}
    int a,b,c,i,j;
    for(a=1;a<=m;a++) {
        scanf("%d%d",&i,&j);
        ed[i].push_back(j);
      	ed[j].push_back(i);
    }
    dfs(1,0);
    return 0;
} 


Measured memory_bytes: 13952
#include <stdio.h>

int n, a, b, c, d;

int main(){
  int i;
  long long min0, max0, min1, max1;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);

  for(i=0;i<n;i++){
    min0 = (long long) (n-1-i) * c;
    max0 = (long long) (n-1-i) * d;
    min1 = (long long) i * c;
    max1 = (long long) i * d;
    if(b >= a + min0 - max1 && b <= a + max0 - min1){
      puts("YES");
      return 0;
    }
  }

  puts("NO");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <string> 
using namespace std;
const int mod = 1e9 + 7;
const int mid = 2*1e5;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(long long i = 0;i < n;i++)


int B[200000];
int  ans=1;
struct node
{
  vector <int> num;
};
node fe[300000];
int dfs(int num,int kazu){
  int count=1;
  if(B[num]!=0)  return 0;
  B[num]=kazu;
  for(int a:fe[num].num){
    count+=dfs(a,kazu);
  }
  return count;
}
int main()
{
  long long N,M;
  cin>>N>>M;
  REP(i,M){
    int a,b;
    cin>>a>>b;
    fe[a].num.push_back(b);
    fe[b].num.push_back(a);
  }
  REP(i,M){
    ans=max(ans,dfs(i+1,i+1));
    
  }
  cout<<ans;
  return 0;
}




Measured memory_bytes: 26852
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        if (Character.isUpperCase(n.charAt(0))) {
            System.out.println("A");
        } else {
            System.out.println("a");
        }
    }
}

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

#define ll long long

int main()
{

	string ss;
	cin >> ss;

	string s1 = ss.substr(0, ss.size() / 2);
	string s2 = ss.substr(ss.size() / 2, ss.size());
	//cout<<s1<<" "<<s2;
	if (s1 >= "01" && s1 <= "12" && s2 >= "01" && s2 <= "12") cout << "AMBIGUOUS";
	else if (s1 >= "01" && s1 <= "12" && s2 > "12") cout << "MMYY";
	else if (s1 > "12" && s2 >= "01" && s2 <= "12") cout << "YYMM";
	else if (s1 >= "01" && s1 <= "12" && s2 == "00") cout << "MMYY";
	else if (s2 >= "01" && s2 <= "12" && s1 == "00") cout << "YYMM";
	else if (s1 == "00" && s2 > "12" || s2 == "00" && s1 > "12") cout << "NA";
	else cout<<"NA";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;

    int cnt =0;
    for(int i=1;i<=n;i++)
 {
     int x;
     cin>>x;
     if(i%2!=0&&x%2!=0)
        cnt++;
 }
    cout<<cnt<<endl;

}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define N 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isprim(int x){
	for(int j=2;j*j<=x;j++){
		if(x%j==0){
			return 0;
		}
	}
	return (x!=1);
}

/*
 _____________              __                ___        ___       __________________________     ____        ____
|             |            /\ \              |   |      |   |     |                          |    \   \      /   /
|   __________|           / /\ \             |   |      |   |     |     _____      _____     |     \   \    /   /
|  |                     / /  \ \            |   |      |   |     |    |     |    |     |    |      \   \  /   /
|  |                    / /    \ \           |   |      |   |     |    |     |    |     |    |       \   \/   /
|  |______             / /      \ \          |   |______|   |     |    |     |    |     |    |        \      /
|         |           / /        \ \         |              |     |    |     |    |     |    |         \    /
|   ______|          / /          \ \        |    ______    |     |    |     |    |     |    |          |  |
|  |                / /============\ \       |   |      |   |     |    |     |    |     |    |          |  |
|  |               / /==============\ \      |   |      |   |     |    |     |    |     |    |          |  |
|  |              / /                \ \     |   |      |   |     |    |     |    |     |    |          |  |
|  |             / /                  \ \    |   |      |   |     |    |     |    |     |    |          |  |
|__|            /_/                    \_\   |___|      |___|     |____|     |____|     |____|          |__|

							<<<<<<<<<<< NEVER GIVE UP !! >>>>>>>>>>>
							<<<<<<<< YOU CAN DO IT IF YOU WANT !! >>>>>>>>
							<<<<<<<<< BELIEVE IN YOURSELF !! >>>>>>>>>
*/

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("stand.in","r",stdin);
	//freopen("stand.out","w",stdout);
	AIA();
	ll a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a);
	return 0;
}

Measured memory_bytes: 3692
K = int(input())
A, B = map(int, input().split())
A_B = []
index = 0

for i in range(0, B - A + 1):
    A_B.append(i+A)

for i in range(0, len(A_B)):
    if A_B[i] % K == 0:
        index = 1
        break

if index == 1:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9192
n, m, x = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
ans = 10 ** 7

for bit in range(2**n):
    tmp = [0] * m
    cost = 0
    for i in range(n):
        if (bit >> i) & 1:
            cost += arr[i][0]
            for j in range(m):
                tmp[j] += arr[i][j+1]
    for tmp_ in tmp:
        if tmp_ < x:
            break
    else:
        ans = min(ans, cost)

print(ans if ans < 10**7 else -1)


Measured memory_bytes: 9216
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    rep(k, 1, N + 1) {
        ll now = k;
        while (now <= N) {
            ans += now;
            now += k;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	int ans = c * 60 + d - (a * 60 + b) - e;

	cout << ans;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,input,k;
  cin>>n;
  cin>>k;
  vector<int> h;
  for(int i=0;i<n;i++){
    cin>>input;
    h.push_back(input);
  }
int dp[n];
for(int i=0;i<n;i++)
dp[i]=1000000000;
dp[1]=abs(h[1]-h[0]);
dp[0]=0;
for(int j=2;j<n;j++){
for(int i=1;i<=k&&(j-i)>=0;i++){
dp[j]=min(dp[j],dp[j-i]+abs(h[j]-h[j-i]));
}
}
cout<<dp[n-1];
  return 0;
}

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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  
  if(N*A<B)
    cout<<N*A<<endl;
  else if(N*A>B)
    cout<<B<<endl;
  else
    cout<<B<<endl;
  
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

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

    vector<int> v(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
    }
    int m;
    cin >> m;

    for(int i= 0 ; i < m ; i++){
        int a, b;
        cin >> a >> b;

        cout << sum + b + - v[a - 1] << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
cards = [2,3,4,5,6,7,8,9,10,11,12,13,1]
alice,bob = gets.split.map(&:to_i)
case
  when cards.index(alice) > cards.index(bob)
     puts "Alice"
  when cards.index(alice) < cards.index(bob)
     puts "Bob"
  when cards.index(alice) == cards.index(bob)
     puts "Draw"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>i) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;

int dfs(auto &G, auto &v, auto &dp, auto &visited)
{
  if (visited.at(v))
  {
    if (dp.at(v) == -1) return -1;
    else return dp.at(v);
  }
  visited.at(v) = true;
  if (G.at(v).empty()) return dp.at(v) = 1;
  REPx(x, G.at(v))
  {
    int res = dfs(G, x, dp, visited);
    if (res == -1) return -1;
    dp.at(v) = max(dp.at(v), res + 1);
  }
  return dp.at(v);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  VVI A(N, VI(N-1));
  REP(i, N)
  {
    REP(j, N-1)
    {
      int a;
      cin >> a;
      A.at(i).at(j) = a - 1;
    }
  }
  VVI enID(N, VI(N));
  int V = 0;
  REP(i, N-1)
  {
    REP2(j, i+1, N)
    {
      enID[i][j] = V;
      enID[j][i] = V++;
    }
  }
  VVI G(V, VI());
  REP(i, N)
  {
    REP(j, N-1)
    {
      A.at(i).at(j) = enID.at(i).at(A.at(i).at(j));
      if (j == 0) continue;
      else G.at(A.at(i).at(j-1)).push_back(A.at(i).at(j));
    }
  }
  VI dp(V, -1);
  int ans = 0;
  VB visited(V, false);
  REP(i, V)
  {
    int res = dfs(G, i, dp, visited);
    if (res == -1)
    {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 37632
def main():
    ABCD = list(map(int, input().split()))

    A = ABCD[0]
    B = ABCD[1]
    C = ABCD[2]
    D = ABCD[3]

    Takahashi = True

    while True:
        C = C - B
        if C <= 0:
            Takahashi = True
            break

        A = A - D
        if A <= 0:
            Takahashi = False
            break

    if Takahashi:
        print("Yes")
    else:
        print("No")




if __name__ == '__main__':
    main()



Measured memory_bytes: 9188
#include "bits/stdc++.h"

using namespace std;

long long power(long long x, long long n, long long M) {
    if (!n) return 1;
    if (n % 2 == 0) {
        long long t = power(x, n / 2, M);
        return t * t % M;
    }
    return x * power(x, n - 1, M) % M;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long x, y;
    cin >> x >> y;
    long long res = 0;
    long long i = 0;
    while (x * power(2, i, LLONG_MAX) <= y) {
        res++;
        i++;
    }
    cout << res << "\n";
    return 0;
}


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

int main(){
  int n,q;
  cin >> n;
  map<int,int> A;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    A[a]+=1;
  }
  long sum = 0;
  for(auto x : A) {
    sum += x.first*x.second;
  }

  cin >> q;
  for (int i = 0; i < q; ++i) {
    int b,c;
    cin >> b >> c;

    sum += A[b]*(c-b);
    A[c] += A[b];
    A.erase(b);

    cout <<sum << endl;
  }
  return 0;
}

Measured memory_bytes: 6096
import sys
input = sys.stdin.readline

T=[int(input().strip()) for x in range(5)]
mini=0
nonmini=[]
for t in T:
  if mini==0:
    mini=t
  elif t%10!=0 and t%10<mini%10:
    nonmini.append(mini)
    mini=t
  else:
    nonmini.append(t)

T=0
for t in nonmini:
  T+=t
  if T%10!=0:
    T+=10-T%10

print(T+mini)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int ans = 0;

        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            while (value % 2 == 0) {
                value /= 2;
                ans++;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 34076