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

int main() {
  int n;
  string s;
  cin >> n >> s;

  if (n % 2) {
    cout << "No" << endl;
    return 0;
  }

  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[i + (n / 2)]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

int main()
{
	int a, b; 
	scanf("%d %d", &a, &b);
	
	if(a > b)
	{
		printf("a > b\n", a, b);
	}
	if(a < b)
	{
		printf("a < b\n", a, b);
	}
	if(a == b)
	{
		printf("a == b\n", a, b);
	}
	
	
	return 0;
}


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

ans = [['0' for i in range(W)] for j in range(H)]

for i in range(H):
    S = input()
    for j,s in enumerate(S):
        if s == '#':
            ans[i][j] = '#'
            for a in range(-1,2):
                for b in range(-1,2):
                    if i+a >= 0 and j+b >= 0\
                        and i+a < H and j+b < W\
                        and ans[i+a][j+b] != '#':
                        ans[i+a][j+b] = str(int(ans[i+a][j+b])+1)

for i in range(H):
    print("".join(ans[i]))

Measured memory_bytes: 73996
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll X, A, B;
    cin >> X >> A >> B;
    if (X < B - A)
    {
        cout << "dangerous" << endl;
    }
    else if (A >= B)
    {
        cout << "delicious" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	snuke := 0
	for i := 0; i < K; i++ {
		snuke = nextSnuke(snuke)
		fmt.Println(snuke)
	}
}

func nextSnuke(n int) int {
	ret := -1
	tmp := math.MaxFloat64

	ds := make([]int, 15)
	org := digits(n + 1)
	for i := 0; i < len(org); i++ {
		ds[15-len(org)+i] = org[i]
	}
	for i := len(ds) - 1; i >= 0; i-- {
		if ds[i] != 9 {
			for j := i + 1; j < len(ds); j++ {
				ds[j] = 9
			}
			for {
				dec := digits2Dec(ds)
				e := eval(dec)
				if e < tmp {
					tmp = e
					ret = dec
				}
				if ds[i] == 9 {
					break
				}
				ds[i]++
			}
		}
	}
	return ret
}

func eval(n int) float64 {
	return float64(n) / float64(S(n))
}

func S(n int) int {
	ret := 0
	for _, d := range digits(n) {
		ret = ret + d
	}
	return ret
}

func digits2Dec(digits []int) int {
	ret := 0
	for i := 0; i < len(digits); i++ {
		ret = ret*10 + digits[i]
	}
	return ret
}

func digits(n int) []int {
	ret := make([]int, 0)
	for n > 0 {
		ret = append([]int{n % 10}, ret...)
		n = n / 10
	}
	return ret
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>                            
#define loop(i,b) for(int i = 0; i < (b); i++)     
#define loop2(i,h,b) for(int i = (h); i < (b); i++)
#define all(a) a.begin(),a.end()                   
using namespace std;                               
                                                   
int main(){                                        
  int A,B;                                         
  scanf("%d%d",&A,&B);                             
                                                   
  bool is_posible = false;                         
                                                   
  if(A % 3 == 0)                                   
    is_posible = true;                             
                                                   
  if(B % 3 == 0)                                   
    is_posible = true;                             
                                                   
  if((A + B) % 3 == 0)                             
    is_posible = true;                             
                                                   
  if(is_posible) printf("Possible\n");             
  else printf("Impossible\n");                     
                                                   
  return 0;                                        
}                                                  
                                                   

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int n;

    cin >> n;

    int a[100];

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

    int s=0;

    for (int i=0 ; i<n;i++){
        if ((a[i]%2 == 0) && (a[i]%3 != 0) && (a[i]%5 != 0))
            s=s+1;
    }

    if (s==0)
        cout << "APPROVED"<<endl;
    else 
        cout << "DENIED"<<endl;      

}

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

int main() {
    ll n;
    ll a[100001];
    ll b[100001];
    ll c[100001];
    
    ll m_num = 0;
    ll p_num = 0;
    
    
    ll m_sum = 0;
    ll s_sum[100002];
    
    s_sum[0] = 0;
    
    ll sum = 0;
    
    
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
        c[i] = a[i] - b[i];
        sum += c[i];
        if(c[i]<0){
            m_num++;
            m_sum += c[i];
        }
        if(c[i]>0){
            p_num++;
        }
    }
    if(sum<0){
        std::cout << -1 << std::endl;
        return 0;
    }
    
    sort(c,c+n,greater<>());
    
    for (int i = 0; i < p_num; i++) {
        s_sum[i+1] = s_sum[i]+c[i];
    }
    
    ll result = distance(s_sum,lower_bound(s_sum,s_sum+p_num+1,-m_sum));
    
    std::cout << result+m_num << std::endl;
    
    
}



Measured memory_bytes: 3072
#include <stdio.h>
#define N 2000000
#define INF (1<<30)

int A[N+1], n;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

void maxHeapify(int i){

  int l, r, largest, temp;

  l = left(i);
  r = right(i);
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(largest);
  }
  
}

int heapExtractMax(){

  int max;
  
  if(n < 1) printf("heap underflow\n");
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1);
  return max;
}

void heapIncreaseKey(int i, int key){

  int temp;

  if(key < A[i]) printf("new key is smaller than current key\n");
  A[i] = key;
  while(i > 1 && A[parent(i)] < A[i]){
    temp = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = temp;
    i = parent(i);
  }
}

void maxHeapInsert(int key){

  n++;
  A[n] = -INF;
  heapIncreaseKey(n, key);
}

int main(){

  int key;
  char str[8];

  while(1){
    scanf("%s", str);
    if(str[0] == 'e' && str[1] == 'n') break;
    if(str[0] == 'i'){
      scanf("%d", &key);
      maxHeapInsert(key);
    } else {
      printf("%d\n", heapExtractMax());
    }
  }
  
  return 0;
}

Measured memory_bytes: 4696
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int cmp(const void *a, const void *b){return *(int*)a - *(int*)b;}

int n, a[200200], b[200200];
ll ans;
main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d%d", &a[i], &b[i]);
    }
    qsort(a, n, 4, cmp);qsort(b, n, 4, cmp);
    if(n&1){
        ans = b[n/2] - a[n/2] + 1;
    }else {
        ans = b[n/2]+b[n/2-1] - a[n/2]-a[n/2-1] + 1;
    }
    printf("%lld\n", ans);
    return 0;
    return 0;
}

Measured memory_bytes: 4012
A, B, C, D, E, F = map(int,input().split())

ans_w = 0
ans_s = 0
max_ans = 0.0
for a in range(31):
    for b in range(31):
        w = 100 * (A * a + B * b)
        if w > F:
            break
        for c in range((w // 100 * E) // C + 1):
            for d in range(((w // 100 * E) - c) // D + 1):
                s = C * c + D * d
                if s > (w // 100 * E) or (w + s) > F:
                    break
                if w + s != 0:
                    n = (100 * s) / (w + s)
                    if n > max_ans:
                        max_ans = n
                        ans_w = w
                        ans_s = s

if ans_w == 0 and ans_s == 0:
    print(100 * A, 0)
else:
    print(ans_w + ans_s, ans_s)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

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

int n, c, k;
int t[100001];

int main(int argc, char **argv) {
	cin >> n >> c >> k;
	REP(i, n) cin >> t[i];
	sort(t, t + n);
	t[n] = t[n - 1] + k + 1;
	int res = 0, u = t[0] + k, p = 0;
	REP(i, n + 1) {
		while (t[i] > u) {
			++res;
			p = min(p + c, i);
			u = t[p] + k;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
S = list(input())

d = defaultdict(int)
for i in range(len(S)):
    d[S[i]] += 1

ans = 1
for k in d.keys():
    ans *= d[k]+1
    ans %= mod

print(ans-1)

Measured memory_bytes: 49392
#include <iostream>
//#include <bits/stdc++.h>
#include<iomanip>

using namespace std;
#define ll long long int 
#define tezz std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int main() {
            int n;
            cin>>n;
            int count=0;
            for(int i=1;i<=n;++i)
            {
                if(i&1) count++;        // 
                
            }
            
        //    double result = (double) count / n;
            
           // cout<<fixed<<setprecision(10)<<result;

            cout<<fixed<<setprecision(10)<<(double)((n/2)+(n%2))/n; 
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)

n = int(input())
ans = [-1]*(n+1)
data =[[] for i in range(n+1)]

for i in range(n-1):
    u,v,w = map(int,input().split())
    data[u].append([v,w])
    data[v].append([u,w])

ans[1] = 1
def color(i):
    for v, w in data[i]:
        if ans[v] == -1:
            if w % 2 == 0:
                ans[v] = ans[i]
            else:
                ans[v] = 1 - ans[i]
            color(v)
    return

color(1)
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 167072
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int a=N;
    int sum=0;
    int dig;
    while(N){
        dig=N%10;
        sum=sum+dig;
        N=N/10;
    }
   // cout<<N<<" "<<sum<<endl;
   // cout<<N%sum<<endl;
    if(a%sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;
int main(){

  int y,x;

  cin >> y >> x;

  int a[x*y];
  memset(a,0,x*y*sizeof(int));

  int b[x];
  memset(b,0,(x+1)*sizeof(int));


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

  for(int j=0;j<y;j++){
    int sum=0;
    for(int i=0;i<x;i++){
      cout << a[i+j*x] << " " ;
      sum += a[i+j*x];
      b[i] += a[i+j*x];
    }
    cout << sum << endl;
  }
  int sum = 0;
  for(int i=0;i<x;i++){
    cout << b[i] << " " ;
    sum += b[i];
  }
  cout << sum <<endl;

  
}




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

int main() {
  string S;
  cin >> S;
  int C = 0;
  int small = 0;
  
  for (int i = 2; i < S.size()-1; i++) {
    if (S.at(i) == 'C')
      C++;
  }
   for (int i = 1; i < S.size(); i++) {
    if  ( islower(S.at(i)) )
      small++;
   }
   if (S.at(0) == 'A' && 
             C == 1   && 
         small == S.size()-2)
    cout << "AC" << endl;
  else
    cout << "WA" << endl;    
}    

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main()
{
  int i,j,n,k=0,minj,min,temp;
  int A[N];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
  }

  i = 0;
  for(i = 0 ; i < n ; i++){
    minj = i;

    for(j = i ; j <= n-1 ; j++){
      if(A[j] < A[minj]) minj = j;
    }
    if(A[i] != A[minj]) {
      temp = A[minj];
      A[minj] = A[i];
      A[i] = temp;
      k+=1;
  }
  }

  for(i = 0 ; i < n-1 ; i++)
    printf("%d ",A[i]);

  printf("%d\n%d\n",A[i],k);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int X;
    cin >> X;
    int ans = 1;
    for (int i = 1; i <= ceil(sqrt(X)); i++)
    {
        for (int j = 2; j < 10; j++)
        {
            int tmp = pow(i, j);
            if ((tmp <= X) && (ans < tmp))
            {
                ans = tmp;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	string str;
	int answer;

	while(1){
		cin >> str;
		if(str == "0") break;
		answer = 0;

		while(1){
			answer += (int)str[0] - 48;
			str.erase(str.begin());
			if(str.empty()) break;
		}
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
s = input()

s1,s2,s3 = s[0:1],s[1:2],s[2:3]

i= 0 

if int(s1) == 1:
  i += 1
if int(s2) == 1:
  i += 1
if int(s3) == 1:
  i += 1
  
print(i)

Measured memory_bytes: 2940
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef gp_hash_table < int, int > fast;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test();

int main() {
    fast_io();
    cout << fixed << setprecision(15);
    test();
    return 0;
}

void test() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    s = '^' + s;
    bool vis[26] = {false};
    for (int i = 1; i <= n; ++i) {
        vis[s[i] - 'a'] = true;
    }
    for (auto &i: t) {
        if (!vis[i - 'a']) {
            cout << "-1\n";
            return;
        }
    }
    ll nxt[n + 2][26];
    for (int i = 0; i <= n + 1; ++i) {
        for (int j = 0; j < 26; ++j) {
            nxt[i][j] = -1;
        }
    }
    for (int i = n; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) {
            nxt[i][j] = nxt[i + 1][j];
            if (i and s[i] - 'a' == j) {
                nxt[i][j] = i;
            }
        }
    }
    ll ans = 0;
    int ptr = 1;
    for (int i = 0; i < m; ++i) {
        int pos = nxt[ptr][t[i] - 'a'];
        if (pos != -1) {
            ans += pos - ptr + 1;
            ptr = pos + 1;
        } else {
            pos = nxt[0][t[i] - 'a'];
            ans += pos + n - ptr + 1;
            ptr = pos + 1;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 20844
#include "vector"
#include "set"
#include "map"
#include "unordered_map"
#include "string"
#include "iostream"
#include "algorithm"
#include "queue"

using namespace std;

#define ll long long
#define INF 2e9
#define MOD 998244353

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;


template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& j: v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os <<j;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

vector<vi> g;
vi p;
vi h;
void dfs(int x, int prev) {
    p[x] = prev;
    h[x] = (prev == -1) ? 0 : h[prev] + 1;

    for (int y : g[x]) {
        if (y != prev) {
            dfs(y, x);
        }
    }
}

struct v {
    int a;
    int b;
    int c;
};

bool comp(const v& x, const v& y) {
    return x.c < y.c;
}

void solve() {
    string s;

    cin >> s;

    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

    if (0) {
        int tests;
        cin >> tests;
        while (tests--) {
            solve();
            cout << "\n";
        }
    } else {
        solve();
        cout << endl;
    }

    return 0;
}

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}
	vector<vector<int>> L(H, vector<int>(W));	
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			if ('#' != S[n][m]) {
				if (0 == m) {
					L[n][m] = 1;
				}
				else {
					L[n][m] = L[n][m - 1] + 1;
				}
				
			}
			else {
				L[n][m] = 0;
			}
		}
	}
	vector<vector<int>> R(H, vector<int>(W));	
	for (int n = 0; n < H; ++n) {
		for (int m = W - 1; m >= 0; --m) {
			if ('#' != S[n][m]) {
				if (W - 1 == m) {
					R[n][m] = 1;
				}
				else {
					R[n][m] = R[n][m +1 ] + 1;
				}

			}
			else {
				R[n][m] = 0;
			}
		}
	}
	vector<vector<int>> D(H, vector<int>(W));
	for (int n = H - 1; n >= 0; --n) {
		for (int m = 0; m < W; ++m) {
			if ('#' != S[n][m]) {
				if (H - 1 == n) {
					D[n][m] = 1;
				}
				else {
					D[n][m] = D[n + 1][m] + 1;
				}

			}
			else {
				D[n][m] = 0;
			}
		}
	}
	vector<vector<int>> U(H, vector<int>(W));	
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			if ('#' != S[n][m]) {
				if (0 == n) {
					U[n][m] = 1;
				}
				else {
					U[n][m] = U[n - 1][m] + 1;
				}

			}
			else {
				U[n][m] = 0;
			}
		}
	}
	int ans = 0;
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			if ('#' != S[n][m]) {
				ans = max(ans, L[n][m]+R[n][m]+D[n][m]+U[n][m] - 3);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 73716
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			long tt = 1;
			long aa = 1;
			for (int i = 0; i < n; i++) {
				long t = cin.Long();
				long a = cin.Long();

				long t1 = tt + (t - (tt % t == 0 ? t : tt % t));
				long a1 = t1 / t * a;
				{
					long mul = aa / a1;
					if (aa % a1 != 0) {
						mul++;
					}

					t1 *= mul;
					a1 *= mul;
				}

				long a2 = aa + (a - (aa % a == 0 ? a : aa % a));
				long t2 = a2 / a * t;
				{
					long mul = tt / t2;
					if (tt % t2 != 0) {
						mul++;
					}

					t2 *= mul;
					a2 *= mul;
				}

				if (t1 + a1 > t2 + a2) {
					tt = t2;
					aa = a2;
				} else {
					tt = t1;
					aa = a1;
				}
			}

			Console.WriteLine(tt + aa);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    string s,k="keyence"; cin>>s;
    ll n=s.size();
    bool ok=false;
    rep(i,n+1)for(int j=i;j<n+1;j++){
        string t = s.substr(0,i)+s.substr(j);
        if(t==k) ok=true;
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(((x%mod)+mod)%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator-() const noexcept {
    return modint(mod) - *this;
  }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator+(long long x){ return modint(*this) += modint(x); };
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator-(long long x){ return modint(*this) -= modint(x); };
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator*(long long x){ return modint(*this) *= modint(x); };
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint operator/(long long x){ return modint(*this) /= modint(x); };
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
T power(T x, long long k){
  T ret(1);
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}

int main(){
  constexpr long long mod = 1e9 + 7;
  using mint = modint<mod>;
  long long N;
  mint A, B, C;
  cin >> N >> A >> B >> C;
  A /= 100;
  B /= 100;
  C /= 100;
  vector<mint> F(2*N);
  F[0] = mint(1);
  for(long long i = 1; i < 2*N; ++i){
    F[i] = F[i-1]*i;
  }
  auto comb = [&](long long n, long long k){
                return F[n]/F[n-k]/F[k];
              };
  mint ans(0);
  for(long long i = 0; i < N; ++i){
    mint t = power(A,N)*power(B,i)*comb(N+i-1,i) + power(B,N)*power(A,i)*comb(N+i-1,i);
    t *= mint(i+N)*(C*power(-C+1,i+N)-power(-C+1,i+N)+1)/(C-1)/power(-C+1,i+N) - mint(i+N);
    ans -= t;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
"""
ある整数 x が、素因数分解によって x = p^n × q^m × ... (p, q, ...は素数) と表せる時、
x の約数の個数は(n + 1) × (m + 1) × ... となります。
"""

"""nを素因数分解"""
"""2以上の整数n => return [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):  
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr
  
from collections import defaultdict
N = int(input())
MOD = 10**9+7
primes = defaultdict(int)
# N!をループしそれぞれの素因数を取得
for i in range(2, N+1):
  for k, v in factorization(i):
    primes[k] += v

ans = 1  
for k, v in primes.items():
  ans = ans * (v+1)%MOD
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N;
    cin >> N;
    vector<ll> kisuu(N/2 + 1);
    vector<ll> V(N),gusuu(N/2);

    for(ll i = 0;i < N;i++)
        cin >> V.at(i);
    
    for(ll i = 0;i < N;i++){
        if(i % 2 == 0){
            kisuu.at(i/2) = V.at(i);
        }else{
            gusuu.at(i/2) = V.at(i);
        }
        
    }

    if(N % 2 == 0){
        reverse(gusuu.begin(),gusuu.end());
        for(ll i = 0;i < gusuu.size();i++)
            cout << gusuu.at(i) << " ";
        for(ll i = 0;i < kisuu.size() -1;i++)
            cout << kisuu.at(i) << " ";

        cout << endl;
    }else{
        reverse(kisuu.begin(),kisuu.end());
        for(ll i = 0;i < kisuu.size();i++)
            cout << kisuu.at(i) << " ";
        for(ll i = 0;i < gusuu.size();i++)
            cout << gusuu.at(i) << " ";

        cout << endl;

    }
}

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

inline long long read(){
    long long s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9'){
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}

long long a, b, c, d, ans;

int main(){
    a = read(), b = read(), c = read(), d = read();
    ans = -0x7f7f7f7f7f7f7f7f;
    ans = max(ans, a * c);
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    if ((a <= 0 && b >= 0) || (c <= 0 && d >= 0))
        ans = max(ans, (long long)0);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = (1'000'000'000 + 7);
int h, w, k;
int popcnt(int n)
{
    int ret = 0;
    while (n != 0)
    {
        ret += (n & 1);
        n >>= 1;
    }
    return ret;
}
int calc(vector<string> &g, int split)
{
    int ret = 0;
    VI num(10, 0);
    bool isloop;
    rep(j, w)
    {
        //cerr << j << " " << split << endl;
        int mnum = -1;
        int cur = 0;
        rep(i, h)
        {
            if (g[i][j] == '1')
                num[cur]++;
            mnum = max(mnum, num[cur]);
            if (((split >> i) & 1) == 1)
            {
                cur++;
            }
        }
        if (mnum > k)
        {
            if (isloop)
            {
                return IINF;
            }
            //cerr << "split" << j << endl;
            ret++;
            rep(i, 10) num[i] = 0;
            j--;
            isloop = true;
        }
        else
        {

            isloop = false;
        }
    }
    //cerr << ret << endl;
    return ret;
}

int main()
{
    cin >> h >> w >> k;
    vector<string> g(h);
    rep(i, h) cin >> g[i];
    int ans = IINF;
    rep(split, (1 << (h - 1)))
    {
        ans = min(ans, popcnt(split) + calc(g, split));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a=input()
b=[]
c=0
for i in range(len(a)):
  c=a[i]
  b.append(c)
c=int(a)
def s(b):
  cc=1
  for i in range(len(b)):
    if b[i]=="+":
      cc=i
  for i in range(cc,len(b)):
    if b[i-1]!="+" and b[i]!="+":
      ba=b[:i]
      bb=b[i:]
      bc=ba+["+"]+bb
      cc="".join(bc)
      cc=cc.split("+")
      for i in range(len(cc)):
        cc[i]=int(cc[i])
      global c
      c+=sum(cc)
      s(bc)
      
s(b)
print(c)
  
      
      

Measured memory_bytes: 3064
n = int(input())
s = input()
int_s = [int(i) for i in s]
pc = s.count('1')

def f(x):
    bi = bin(x)
    pc = bi.count('1')
    cnt = 1
    while True:
        if x == 0:
            break
        x = x % pc
        bi = bin(x)
        pc = bi.count('1')
        cnt += 1
    return cnt

num_pl = 0
for i in range(n):
    num_pl = (num_pl*2) % (pc+1)
    num_pl += int_s[i]

num_mi = 0
for i in range(n):
    if pc-1 <= 0:
        continue
    num_mi = (num_mi*2) % (pc-1)
    num_mi += int_s[i]

ans = [0]*n
pc_pl, pc_mi = pc+1, pc-1
r_pl, r_mi = 1, 1
for i in range(n-1, -1, -1):
    if int_s[i] == 0:
        num = num_pl
        num = (num+r_pl) % pc_pl
    else:
        num = num_mi
        if pc_mi <= 0:
            continue
        num = (num-r_mi+pc_mi) % pc_mi

    ans[i] = f(num)
    r_pl = (r_pl*2) % pc_pl
    if pc_mi <= 0:
        continue
    r_mi = (r_mi*2) % pc_mi
     
print(*ans, sep='\n')

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    llint n;
    cin >> n;

    vector<llint> a(n);
    vector<llint> b(n);
    vector<llint> c(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
    }
    for(int in=0;in<n;in++) {
        cin >> b.at(in);
    }
    for(int in=0;in<n;in++) {
        cin >> c.at(in);
    }

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

    llint ans=0;
    for(int ib=0;ib<n;ib++) {
        auto ia = lower_bound(a.begin(), a.end(), b.at(ib));
        auto ic = lower_bound(c.begin(), c.end(), b.at(ib)+1);
        ans += (ia-a.begin())*(n-(ic-c.begin()));
    }
    cout << ans << endl;
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int Alice = 0, Bob = 0;
  for (int i = 0; i < N; i++) {
   if (i % 2 == 0) {
     Alice += vec.at(i);
   }
   if (i % 2 == 1) {
     Bob += vec.at(i);
   }
  }
  
  cout << Alice - Bob << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

char albt[26] = {'a','b','c','d','e','f','g','h','i','j','k','l',
                 'm','n','o','p','q','r','s','t','u','v','w','x',
                 'y','z'};

//vector<ll> g[202020];
//fill(score, score+202020, 0);
//vector<ll> v;

int main(){
  ll n,m;
  cin >> n >> m;
  
  ll A[n][3];
  ll x,y,z;
  for (int i=0;i<n;i++){
    cin >> x >> y >> z;
    A[i][0] = x; A[i][1] = y; A[i][2] = z; 
  }
  
  int ar[] = {1, -1};
  ll max = 0;
  for(int i : ar) {
    for(int j : ar) {
      for(int k : ar) {
        //cout << i << " " << j << " " << k << endl;
        vl vec;
        ll tmp_max = 0;
        for (int l=0;l<n;l++){
          vec.push_back(i*A[l][0] + j*A[l][1] + k*A[l][2]);
        }
        sort(vec.begin(), vec.end(), greater<ll>());
        for (int l=0;l<m;l++){
          tmp_max += vec[l];
        }
        if (tmp_max > max) max = tmp_max;
      }
    }
  }
        
  cout << max << endl;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    q = II()
    bc = [MII() for _ in range(q)]
    sumv = sum(aa)
    numbers = [0]*(10**5+1)
    for a in aa:
        numbers[a] += 1

    for b,c in bc:
        numb = numbers[b]
        sumv += numb*(c-b)
        print(sumv)
        numbers[b] = 0
        numbers[c] += numb

if __name__ == '__main__':
    main()

Measured memory_bytes: 32092
N = int(input())
A = [[]]
for _ in range(2):
	A.append(list(map(int, input().split())))

current_sum = A[1][0] + sum(A[2])
ans = current_sum
for i in range(1, N):
	current_sum += A[1][i] - A[2][i-1]
	ans = max(ans, current_sum)

print(ans)

Measured memory_bytes: 3064
H, W = map(int, input().split())
s = [input() for i in range(H)]
dy, dx = [1, 0, -1, 0], [0, 1, 0, -1]
for i in range(H):
    for j in range(W):
        if s[i][j] == '.': continue
        f = 1
        for d1, d2 in zip(dy, dx):
            ni, nj = i + d1, j + d2
            if 0 <= ni < H and 0 <= nj < W and s[ni][nj] == '#':
                f = 0
                break
        if f:
            print('No')
            quit()
print('Yes')

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

int main(){
  int sum;
  while(std::cin >> sum, sum){
    for (int i = 0; i < 9; i++) {
      int tmp;
      std::cin >> tmp;
      sum -= tmp;
    }
    std::cout << sum << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define len(x) (int)(x).size()
#define rep(i,x) for(int i=0;i<x;++i)

typedef long long ll;
typedef long double ld;

using namespace std;

signed main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s;cin >> s;
    rep(i , len(s))cout << 'x';
    return 0;
}


Measured memory_bytes: 256
# 英小文字からなる文字列 s が与えられます。
# 前から数えて奇数文字目だけ抜き出して作った文字列を出力してください。
# ただし、文字列の先頭の文字を1文字目とします。
# 前から数えて奇数文字目だけ抜き出して作った文字列を出力せよ。
a_s = gets.chomp.split("")

odd_a_s = []
a_s.each_index do |idx|
  next if idx%2 != 0
  odd_a_s << a_s[idx]
end

puts "#{odd_a_s.join}"

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

using namespace std;
char s[100500];

int main()
{
    int n , k;
    cin >> n >> k;

    scanf("%s",s+1);

    int res = 0;
    for(int i=2;i<=n;i++){
        if(s[i]!=s[i-1]){
            res ++;
        }
    }

    while(k && res>1){
        k--;
        res -= 2;
    }

    cout <<  n - 1 - max(0,res-k);


    return 0;
}


Measured memory_bytes: 384
a,b,c,d=map(int, input().split())
print(b*d if a>=0 and d>=0 else d*a if a>=0 and d<=0 else b*d if b>=0 and a<=0 and c>=0
     else max(b*d, c*a) if a<=0 and b>=0 and c<=0 and d>=0 else c*a if a<=0 and b>=0 and d<=0
     else b*c if b<=0 and c>=0 else c*a )

Measured memory_bytes: 9056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int x; cin >>x;
    vector<int> divisi;

    for(int i = 1; i*i <= x; i++){
        if(x % i == 0){
            divisi.push_back(i);
            divisi.push_back(x / i);
        }
    }
    sort(ALL(divisi));

    for(int a = 0; pow(a,5) <= x; a++){
        REP(k,divisi.size()){
            int b = divisi[k] - a;
            if(b >= 0 && pow(a,5) + pow(b,5) == x){
                cout << a << " " << -b << endl;
                return 0;
                if(pow(a,5) + pow(b,5) > x) break;
            }
        }
    }
    //int a = 0;
    bool flag = false;
    for(int a = 0; pow(a,4) <= x ; a++){
        //cout << a << endl;
        REP(k, divisi.size()){
            int b = a - divisi[k];
            if(pow(a,4) + pow(b,4) > x) break;
            if(b >= 0){
                //cout << a << " " << b << endl;
                if(pow(a,5) - pow(b,5) == x){
                    cout << a << " " << b << endl;
                    flag = true;
                    break;
                    //return 0;
                }
                else continue;
            }
            if(flag) break;
        }
        if(flag) break;
    }
    //cout << "bad" << endl;
    return 0;
}

Measured memory_bytes: 4080
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;
  vt<int> a(n);
  rep(i,n)
    std::cin >> a[i];

  std::queue<int> num;
  num.push(a[0]);
  sort(a.begin(),a.end());
  int mini = 0;

  while(mini != num.front()){
    mini = num.front();
    rep(i,n){
      if(a[i] == mini)
        continue;
      else {
        a[i] %= mini;
        if(a[i] < num.front() && a[i] != 0){
          num.pop();
          num.push(a[i]);
        }
      }
    }
    sort(a.begin(),a.end());
  }

  std::cout << mini << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  cout << (100*n+1800*m)*(ll)pow(2, m) << newl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; (i * i) <= n; i++) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while((n % i) == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p;
    cin >> n >> p;
    vector<pair<ll, int>> f = factorize(p);
    ll ans = 1;
    for (auto x : f) {
        rep(i, x.second / n) {
            ans *= x.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N, T = map(int, raw_input().split())
ans = 0
time = map(int, raw_input().split())

ans = 0
tmp = 0
start = time[0]
end = T
for t in time[1:]:
    if end < t:
        ans = ans + (end - start)
        start = t
        end = T + start
    else:
        end = t + T

end = time[N-1] + T
ans = ans + (end - start)

print ans

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

dp = [[-1 for i in range(W+1)] for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    v, w = map(int, input().split())
    for j in range(W):
        if dp[i][j] >= 0:
            try:
                dp[i+1][j] = max(dp[i][j], dp[i+1][j])
                dp[i+1][j+w] = max(dp[i][j]+v, dp[i][j+w])
            except IndexError:
                pass
print(max(dp[-1]))

Measured memory_bytes: 24264
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

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

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modInv(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modInv(fact(k)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  ll i,j,cnt=0;
  char c;
  cin>>c;
  cout<<(char)(c+1)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#define __max(a,b) (((a) > (b)) ? (a) : (b))

int main() {
	int a, b, x, y, z;

	scanf("%d %d", &a, &b);

	x = a + b;
	y = a - b;
	z = a * b;

	printf("%d\n", __max(__max(x, y), z));

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...


ll n;
void test_case(){
	cin>>n;
	string ans;
	while(n){
		--n;
		int x = n%26;
		ans += 'a'+ x;
		n/=26;
	}
	reverse(all(ans));
	cout<<ans;
}







int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main() {
    std::ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if ((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
"""
import math
N = int(input())
A = list(map(int, input().split()))
g = math.gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = math.gcd(g, a)
print(g)
"""
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
N = int(input())
A = list(map(int, input().split()))
g = gcd(A[0], A[1])
for a in A:
    if g == 1:
        break
    g = gcd(g, a)
print(g)

Measured memory_bytes: 15020