akhauriyash/Code-Regression huggingface dataset:
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second   
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
typedef long double ld ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef vector<int> vi;
typedef pair<int, int> pii; 
typedef vector<pii> vpii;
typedef pair<int , pii> piii ; 
typedef unsigned long long ull ;


bool solve()
{
    int n;
    cin >> n ;
    while(n){
        if(n%10 == 7) return true; 
        n /= 10; 
    }
    return false;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        cout << (solve()?"Yes":"No") ;
        cout << "\n" ;
    }
    return 0;
}


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

using namespace std;

int main() {
    string s1, s2, s3;
    int offset = 'A' - 'a';

    cin >> s1 >> s2 >> s3;
    cout << (char)(s1[0] + offset)
         << (char)(s2[0] + offset)
         << (char)(s3[0] + offset)
         << endl;

    return 0;
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N; cin >> N;
    vector<ll> v(5);
    rep(i, 5) cin >> v[i];

    ll mi = INF;
    rep(i, 5){
        mi = min(mi, v[i]);
    }

    cout << (ll)((N + mi -1)/mi + (ll)4) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))

b = [[0,0,0],[0,0,0],[0,0,0]]
for _ in range(int(input())):
  x = int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j] == x:
        b[i][j] = 1

ans = 'No'

for i in range(3):
  if sum(b[i]) == 3:
    ans = 'Yes'
    break

for i in range(3):
  if sum([b[j][i] for j in range(3)]) == 3:
    ans = 'Yes'
    break

if sum([b[i][i] for i in range(3)]) == 3:
  ans = 'Yes'

if sum([b[i][2-i] for i in range(3)]) == 3:
  ans = 'Yes'
  
print(ans)

Measured memory_bytes: 3064
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int t, a, b;
  cin >> t >> a >> b;
  if (t * a >= b)
  {
    cout << b << endl;
  }else{
    cout << t*a << endl;
  }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
class Main{
	public static void main(String[] args) throws IOException {
		int i,m;
		int[] n = new int[990];
		String[] str = new String[990];
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		str = in.readLine().split(" ");
		m = Integer.parseInt(str[0]);
		str = in.readLine().split(" ");
		for(i=0;i<m;i++){
			n[i] = Integer.parseInt(str[i]);
		}
		for(i=m-1;i>=0;i--){
			if(i!=m-1) System.out.print(" "); 
			System.out.print(n[i]);
		}
		System.out.println();
		System.out.flush();
	}
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int n = s.length();

    int ans = 0;
    rep(i, n)
    {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3772
import java.util.Scanner;


class Main {

	public static void main(String[] args) {   

		Scanner scanner = new Scanner(System.in);
		
		int n  = scanner.nextInt();
		double P1=0;
		double P2=0;
		double P3=0;
		double Pi=0;
		
		double[] x; 
		x = new double[n];//ベクトルx
		
		double[] y; 
		y = new double[n];//ベクトルy
		
           for(int i=0;i<n;i++){
        	   double X  = scanner.nextDouble();
			x[i]=X;
		}
           for(int i=0;i<n;i++){
        	   double Y  = scanner.nextDouble();
			y[i]=Y;
		}
           for(int i=0;i<n;i++){
        	   P1=P1+Math.abs(x[i]-y[i]);
        	   P2=P2+Math.pow(Math.abs(x[i]-y[i]),2);
        	   P3=P3+Math.pow(Math.abs(x[i]-y[i]),3);
        	   Pi=Math.max(Pi,Math.abs(x[i]-y[i]));
           }
           System.out.println(P1);
		   System.out.println(Math.sqrt(P2));
		   System.out.println(Math.cbrt(P3));
		   System.out.println(Pi);


		scanner.close();
	}
}



Measured memory_bytes: 28840
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
bool is_prime(long long n) {  //素数判定
  for(int64_t i = 2; i * i <= n; i++) {
    if(n % i == 0) return false;
  }
  return true;
}
int solve(){
  ll n,k;
  cin >> n >> k;
  vector<ll>h(n);
  rep(i,n)cin >> h[i];
  sort(all(h));
  reverse(all(h));
  ll ans = 0;
  rep(i,n){
    if(k > 0){k--;continue;}
    else ans += h[i];
  }
  cout << ans << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 1792
#include<cstdio>

int main() {
    int A, B;
    scanf("%d%d", &A, &B);
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        printf("Possible");
    }
    else {
        printf("Impossible");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int h,w;
    string board[110];
    vector<bool> goodx(110,false),goody(110,false);
    cin>>h>>w;
    for(int i=0;i<h;i++){    
            cin>>board[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(board[i][j]=='#'){
                goodx[i]=true;
                goody[j]=true;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(goodx[i]){
            for(int j=0;j<w;j++){
                if(goody[j]){
                    cout<<board[i][j];
                }
            }
        
    
    cout<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
N,M = (int(x) for x in input().split())
if N == 1:
    if M == 1:
        print('1')
    elif M == 2:
        print('0')
    else:
        print(M-2)
elif M == 1:
    if N == 2:
        print('0')
    else:
        print(N-2)
else:
    print((N-2)*(M-2))

Measured memory_bytes: 3064
<?php
 fscanf(STDIN,"%d %d",$a,$b);
 $pointsN = trim(fgets(STDIN));
 $arr1 = explode(" ", $pointsN);
 $arrN = str_split($arr1[0]);
 $arrN[$b-1] = strtolower($arrN[$b-1]);
 for($i=0; $i<$a; $i++){
   echo $arrN[$i];
 }
 ?>

Measured memory_bytes: 3828
from collections import deque
N, M = map(int, input().split())
road = [[] for _ in range(N+1)]
ans = [-1]*(N+1)
d = deque()
for i in range(M):
    A, B = map(int, input().split())
    road[A].append(B)
    road[B].append(A)
d.append(1)
while len(d) != 0:
    look = d.popleft()
    for i in road[look]:
        if ans[i] == -1:
            d.append(i)
            ans[i] = look

print("Yes")
for i in range(2, N+1):
    print(ans[i])


Measured memory_bytes: 34132
#include <iostream>

using namespace std;

int main()
{
	int m, f, b;

	cin >> m >> f >> b;

	if (m - b > 0) cout << 0 << endl;
	else if (b - m <= f) cout << b - m << endl;
	else cout << "NA" << endl;

	return 0;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    vector <pair<long long,long long>> pairs(n);
    for(int i = 0; i < n; i++){
        long long x,y;
        cin >> x >> y;
        pairs.at(i) = make_pair(x,y);
    }
    sort(pairs.begin(),pairs.end());
    unsigned long long sum = 0;
    for(int i = 0; i < n; i++){
        long long a,b;
        a = pairs.at(i).first, b = pairs.at(i).second;
        if(m-b >= 0){
            sum += a*b;
            m -= b;
        }else if(m-b < 0){
            sum += a*m;
            break;
        }
    }
    cout << sum << endl;
    return 0;
}


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

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

    long long sum = 1000;
    while (1)
    {
        if (n <= sum) break;
        sum += 1000;
    }

    cout << sum - n << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  int ans = 1;
  int dis = 0;
  int count = 1;
  rep(i,n-1){
    if(A[i] == A[i+1]){
      count++;
      if(i == n-2){
        dis += count-1;
      }
    }
    else{
      if(count % 2 == 0){
        dis += count-1;
      }
      ans++;
      count = 1;
    }
  }
  cout << ans - (dis%2) << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
   
   
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
   
   
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
   
def tree_find(top, k):
    x = top
    while x != None and k != x.key:
        if k < x.key:
            x = x.left
        else:
            x = x.right
    return x

def deleteNode(top, z):#(top, Node())
    if z.left == None or z.right == None:
        y = z
    else:
        y = getSuccessor(z)

    if y.left != None:
        x = y.left
    else:
        x = y.right

    if x != None:
        x.parent = y.parent

    if y.parent == None:
        top = x
    elif y == y.parent.left:
        y.parent.left = x
    else:
        y.parent.right = x

    if y != z:
        z.key = y.key
    return top

def getSuccessor(x):
    if x.right != None:
        return getMinimum(x.right)

    y = x.parent
    while y != None and x == y.right:
        x = y
        y = y.parent
    return y

def getMinimum(x):
    while x.left != None:
        x = x.left
    return x


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
   
   
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
   
   
n = int(stdin.readline())
   
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    elif cmd.startswith('f'):
        key = int(cmd[5:])
        if tree_find(top, key) != None:
            print('yes')
        else:
            print('no')
    elif cmd.startswith('d'):
        key = int(cmd[7:])
        top = deleteNode(top, tree_find(top, key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Measured memory_bytes: 171492
#include <iostream>
#include <vector>
#include <set>
using namespace std;

int main() {
    int i, j, n, res = 0;
    cin >> n;
    int a[n][n];

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

    vector<int> v;
    set<int> cons;
    v.push_back(0);
    cons.insert(0);
    while (v.size() != n) {
        int nearest_node = 9999999;
        int nearest_distance = 9999999;
        for (i=0; i<v.size(); i++) {
            for (j=0; j<n; j++) {
                if ((a[v[i]][j] != -1) && (a[v[i]][j] < nearest_distance) && (cons.count(j) == 0)) {
                    nearest_node = j;
                    nearest_distance = a[v[i]][j];
                }
            }
        }
        res += nearest_distance;
        v.push_back(nearest_node);
        cons.insert(nearest_node);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1256
def main():
    n,x,y=map(int,input().split())
    Ans=[0]*n
    for i in range(1,n):
        for j in range(i+1,n+1):
            Ans[min(abs(j-i),abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))]+=1
    for ans in Ans[1:]:
        print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 44528
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    long long a,b,c,k,m;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    m=max(max(a,b),c);
    while(k--)
        m=m*2;
    printf("%lld\n",m+a+b+c-max(max(a,b),c));
}



Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define R cin>>
#define C cout<<
const int INF = 1000000007;
typedef long long ll;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n,m;
  map<int,int>d;
  int tmp;
  cin >> n;
  rep(i,n){
    cin >> tmp;
    d[tmp]++;
  }
  bool can = true;
  cin >> m;
  rep(i,m){
    cin >> tmp;
    if(d[tmp] < 1)can = false;
    else d[tmp]--;
  }
  cout << (can ? "YES" : "NO") << endl; 
  return 0;
}

Measured memory_bytes: 9600
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string str;
    int K;
    cin >> K >> str;

    if (str.size() <= K) {
        cout << str << endl;
    } else {
        for (int i = 0; i < K; i++) {
            cout << str[i];
        }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(v) v.begin(),v.end()
#define mod 1000000007

int main(){
  ll n;
  cin >> n;
  ll p[110][11]={0},f[110][11]={0};
  rep(i,n)rep(j,10)cin >> f[i][j];
  rep(i,n)rep(j,11)cin >> p[i][j];
  bool flag=false;
  ll ans=-10000000000;

  //bit all tansaku
  for(ll i=1;i<(1<<10);i++){
    ll tmp=0;
    rep(j,n){
      ll count=0;
      rep(k,10){
        if(f[j][k]&&(i&(1<<k))){
          count++;
        }
      }
      tmp+=p[j][count];
    }
    ans=max(tmp,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <bits/stdtr1c++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;


/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/

/// Typedef
typedef long long           ll;
typedef unsigned long       ul;
typedef unsigned long long  ull;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<vi>          vvi;
typedef vector<ll>          vll;
typedef pair<int,int>       pii;
typedef pair<ll,ll>         pll;

#define pb                  push_back
#define ppb                 pop_back
#define MP                  make_pair
#define ff                  first
#define ss                  second
#define sf                  scanf
#define pf                  printf
#define loop(i, y)          for(int i=0; i<int(y); i++)
#define FOR(i, x, y)        for(int i=int(x); i<int(y); i++)
#define ROF(i, x, y)        for(int i=int(x); i>=int(y); i--)
#define all(c)              c.begin(), c.end()
#define sz(c)               int(c.size())
#define clr(x, y)           memset(x, y, sizeof(x))
#define si(x)               scanf("%d", &x)
#define sii(x, y)           scanf("%d %d", &x, &y)
#define siii(x, y, z)       scanf("%d %d %d", &x, &y, &z)
#define sl(x)               scanf("%lld", &x)
#define sll(x, y)           scanf("%lld %lld", &x, &y)
#define slll(x, y, z)       scanf("%lld %lld %lld", &x, &y, &z)
#define MAX                 10005
#define MOD                 1000000009
#define base                1000000007
#define eps                 1e-9
#define INF                 1llu<<61    // 2,305,843,009,213,693,952
#define inf                 1<<29       // 536,870,912
#define PI                  acos(-1.0)  // 3.1415926535897932
// #define INF              0x3f3f3f3f3f3f3f3f
// #define inf              0x3f3f3f3f

int ara[13][13],p[13];
int main(){
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n;
    si(n);
    double angle =180.0 - (360.0)/n;
    cout<<(angle*n)<<endl;
    #ifdef VAMP
       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
n = int(input())

x = list(map(int, input().split()))
xs = sorted(x)
left = xs[n // 2 - 1]
right = xs[n // 2]

for i in range(n):
    if x[i] <= left:
        print(right)
    else:
        print(left)


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

int main() {
int N;
  cin >> N;
  vector<int> h(N);
  rep(i, N)
    cin >> h.at(i);
  vector<int> pro(N, 0);
  rep(i, N){
  if(i == 0)
    continue;
    else if(i == 1){
    pro[i] = abs(h[0] - h[1]);
    }
    else if(i >= 2){
      pro[i] = min(pro[i-2]+abs(h[i-2]-h[i]), pro[i-1]+abs(h[i-1]-h[i]));
    }
  }
  cout << pro[N-1] << endl;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()

ans = INF

for h in range(1, H+1):
	S1 = h*W
	w = W//2
	S2 = (H-h)*w
	S3 = (H-h)*(W-w)
	ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))

	S2 = (H-h)//2*W
	S3 = H*W-S1-S2
	ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))

H, W = W, H

for h in range(1, H+1):
	S1 = h*W
	w = W//2
	S2 = (H-h)*w
	S3 = (H-h)*(W-w)
	ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))

	S2 = (H-h)//2*W
	S3 = H*W-S1-S2
	ans = min(ans, max(S1, S2, S3)-min(S1, S2, S3))

print(ans)


Measured memory_bytes: 3916
#include <iostream>

using namespace std;

int main()
{
    long long n,i,j,k;
    cin>>n;
    long long s[n+5]={0},z;
    for(i=1;i<=n;i++)
    {
        //if(i*i+j*j+k*k+i*j+i*k+j*k>n)
               // break;
        for(j=1;j<=n;j++)
        {
            //if(i*i+j*j+k*k+i*j+i*k+j*k>n)
                //break;
            for(k=1;k<=n;k++)
            {
                z=i*i+j*j+k*k+i*j+i*k+j*k;
                if(z<=n)
                {
                   /* if(i==j&&j==k&&i==k)
                    {
                        s[z]+=1;
                    }
                    else if(i==j||j==k||i==k)
                    {
                        s[z]+=3;
                    }
                    else if(i!=j&&j!=k&&i!=k)
                    {
                        s[z]+=6;
                    }*/
                    s[z]++;
                }
                else
                {
                    break;
                }
            }
        }
    }
    for(i=1;i<=n;i++)
        cout<<s[i]<<endl;
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S, T;
int A, B;
string U;
signed main() {
    cin >> S >> T >> A >> B >> U;
    if (S == U) { cout << A - 1 << " " << B << endl; }
    else { cout << A << " " << B - 1 << endl; }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;

int64 solve(const vector<int64>& a, int sign) {
  int n = a.size();
  int64 sum = 0, ret = 0;
  for (int i = 0; i < n; ++i) {
    int64 cur = sum + a[i];
    if (cur >= 0 && sign < 0) {
      sum -= cur + 1;
      ret += cur + 1;
    } else if (cur <= 0 && sign > 0) {
      sum += -cur + 1;
      ret += -cur + 1;
    }
    sign = -sign;
  }
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int64> sum(n);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    sum[i] = i > 0 ? sum[i - 1] + x : x;
  }
  int64 ret = 1LL << 60;
  ret = min(ret, solve(sum, 1));
  ret = min(ret, solve(sum, -1));
  printf("%lld\n", ret);
  return 0;
}


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

int main() {

    int N;
    int W;
    cin >> N >> W;
    long long w[N+1], v[N+1];
    w[0] = 0; v[0] = 0;
    for(int i=1; i<=N; i++)
        cin >> w[i] >> v[i];

    long long dp[N+1][W+1];
    for(int i=0; i<=N; i++) {
        for(int j=0; j<=W; j++) {
            if(i==0 || j==0) dp[i][j] = 0;
            else if(j < w[i]) dp[i][j] = dp[i-1][j];
            else {
                dp[i][j] = max(dp[i-1][j], v[i]+dp[i-1][j-w[i]]);
            }
        }
    }
    cout << dp[N][W];
    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;
int s[1010];
int g[1010];

int main(){
   int n;
   cin>>n;
   int ans=0;
   for(int i=0;i<n;i++){
      cin>>s[i]>>g[i];
      ans+=g[i]-s[i]+1;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
//ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main() {
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ll n, k; cin >> n >> k;
	vi cnt(111111);
	REP(i, n) {
		int a, b; cin >> a >> b;
		cnt[a] += b;
	}
	ll tmp = 0;
	REP(i, 111111) {
		tmp += cnt[i];
		if (tmp >= k) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T& chmin(T& a, const T& b) { return a = min(a, b); }
template<class T> T& chmax(T& a, const T& b) { return a = max(a, b); }
template<class T>
istream& operator>>(istream& is, vector<T>& v)
{
	for (auto& i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/



int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n);
	cin >> a;
	int t = 1; int cnt = 0;
	for (auto x : a) {
		if (x == t) {
			t++;
		}
		else {
			cnt++;
		}
	}
	cout << (cnt == n ? -1 : cnt) << endl;
	return 0;
}

Measured memory_bytes: 1024
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);
    	StringBuffer buf =new StringBuffer();
    	int m,f,r,u;
    	while(true){
    	    m = sc.nextInt();
    	    f = sc.nextInt();
    	    r = sc.nextInt();
    	    u = m+f;
    	    if(m==-1&&f==-1&&r==-1){
    	    	System.out.print(buf);
    	        break;
    	    }



    	    if(m==-1||f==-1){
    	            buf.append("F").append("\n");
    	    }else if(80<=u){
    	    	buf.append("A").append("\n");
    	    }else if(65<=u&&u<80){
    	    	buf.append("B").append("\n");
    	    }else if(50<=u&&u<65){
    	    	buf.append("C").append("\n");
    	    }else if(30<=u&&u<50){
    	         if(50<=r){
    	        	 buf.append("C").append("\n");
    	         }else{
    	        	 buf.append("D").append("\n");
    	         }
    	    }else{
    	    	buf.append("F").append("\n");
    	    }
    }
}
}

Measured memory_bytes: 26104
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
int ten[110]={},jun[110];
int main(){
	set<int> se;
	set<int>::iterator it;
	int N,Gn,a,b,c,d,las;
	cin>>N;
	Gn=N*(N-1)/2;
	for(int i=0;i<Gn;i++){
		cin>>a>>b>>c>>d;
		if(c>d){
			ten[a-1]+=3;
		}
		else if(c<d){
			ten[b-1]+=3;
		}
		else{
			ten[a-1]++;
			ten[b-1]++;
		}
	}
	for(int i=0;i<N;i++)jun[i]=1;
	for(int i=1;i<N;i++){
		for(int j=0;j<i;j++){
			if(ten[j]<ten[i]) jun[j]++;
			if(ten[j]>ten[i]) jun[i]++;
		}
	}
	for(int i=0;i<N;i++){
		cout<<jun[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
int main(){
  int N;
  cin>>N;
  vi num(N);
  rep(i,N)cin>>num[i];
  int ans =1;
  bool big = false;bool le=false;
  rep(i,N-1){
    if(!big&&!le){
      if(num[i]>num[i+1])le=true;
      if(num[i]<num[i+1])big=true;
    }
    if(big){
      if(num[i]>num[i+1]){
        ans++;
        big=false;
      }
      else continue;
    }
    if(le){
      if(num[i]<num[i+1]){
        ans++;
        le=false;
      }
      else continue;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque()

ok = True
for i in range(n):
  if ok:
    b.append(a[i])
    ok = False
  else:
    b.appendleft(a[i])
    ok = True

b = list(map(str, list(b)))
if ok:
  print(" ".join(b))
else:
  print(" ".join(b[::-1]))

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

using namespace std;

typedef long long ll;

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

    int cnt = 0;
    for (int i = 0; i < 1000; i++) {
        int c[3] = { i / 100, (i % 100) / 10, i % 10};
        int p = 0;
        for (int j = 0; j < N; j++) {
            if (S[j] == ('0' + c[p])) {
                p++;
            }
            if (p == 3) {
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;
/*
    map<string, bool> A1, A2, A3;
    A1[S.substr(N-1, 1)] = true;
    A1[S.substr(N-2, 1)] = true;
    A2[S.substr(N-2)] = true;
    for (int i = N - 3; i >= 0; i--) {
        for (auto const& e : A2) {
            string s = S.substr(i, 1);
            s += e.first;
            A3[s] = true;
        }

        for (auto const& e : A1) {
            string s = S.substr(i, 1);
            s += e.first;
            A2[s] = true;
        }

        A1[S.substr(i, 1)] = true;
    }
    
    cout << A3.size() << endl;
*/    
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int d[10][10];

int main(){
    int h, w;
    cin >> h >> w;

    const int INF = 1e9;
    rep(i, 10){
        rep(j, 10) if(i != j) d[i][j] = INF;
    }

    rep(i, 10){
        rep(j, 10) cin >> d[i][j];
    }

    rep(k, 10){
        rep(i, 10){
            rep(j, 10) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }

    int ans = 0;
    rep(i, h){
        rep(j, w) {
            int a;
            cin >> a;
            if(a != -1) ans += d[a][1];
        }
    }

    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

typedef long long LL;
template<typename T> using V = std::vector<T>;
template<typename T> using VV = std::vector<std::vector<T>>;
template<typename T> using VVV = std::vector<std::vector<std::vector<T>>>;

template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }

const int INF = 1L << 30;
const double EPS = 1e-9;
const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy4 = { 0, 1, 0, -1 }, dx4 = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };

using namespace std;

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
	LL MOD = 1000000000 + 7;

	string S;
	cin >> S;
	int N = S.size();

	vector<vector<LL>> dp(N + 10, vector<LL>(4, 0));
	dp[0][0] = 1;
	FOR(i, 0, N) {
        FOR(j, 0, 4) {
            if (S[i] != '?') {
                dp[i + 1][j] += dp[i][j];
            }
            else {
                dp[i + 1][j] += dp[i][j] * 3;
            }
            dp[i + 1][j] %= MOD;
        }

        if (S[i] == 'A' or S[i] == '?') {
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][1] %= MOD;
        }
        if (S[i] == 'B' or S[i] == '?') {
            dp[i + 1][2] += dp[i][1];
            dp[i + 1][2] %= MOD;
        }
        if (S[i] == 'C' or S[i] == '?') {
            dp[i + 1][3] += dp[i][2];
            dp[i + 1][3] %= MOD;
        }
	}

	print(dp[N][3]);


	return 0;
}

Measured memory_bytes: 7376
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var D = Sarray()[0];
            if (D == 25)
                WriteLine("Christmas");
            else if (D == 24)
                WriteLine("Christmas Eve");
            else if (D == 23)
                WriteLine("Christmas Eve Eve");
            else if (D == 22)
                WriteLine("Christmas Eve Eve Eve");
        }

        static long Mod = (long)1e9 + 7;
        private static int pl;

        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;

#define INT_MX 2147483647
#define INF ((int)1e9)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

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

void solve(){
    ll n, ipa, ipb, a, b, ka, kb;
    
    a = b = 1;
    cin >> n;
    while(n--){
        cin >> ipa >> ipb;
        ka = kb = 1;
        if(a > ipa){
            ka = a / ipa;
            if(ipa * ka < a)    ka++;
        }
        if(b > ipb){
            kb = b / ipb;
            if(ipb * kb < b)    kb++;
        }
        
        a = ipa * max(ka, kb);
        b = ipb * max(ka, kb);
    }
    cout << a + b << '\n';
    
}

int main(){
    IOS;
    
    solve();
}





Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	double w,h;
	int long long x,y;
	cin>>w>>h>>x>>y;
	printf("%f ",w*h/2);
	if(x==w/2&&y==h/2){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n;
    string t;
    cin >> t;
    n = t.size();
    rep(i,0,n-1){
        if(t[i]=='?') t[i]='D';
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3772
N , K = map(int,input().split())
hn = list(map(int,input().split()))
dp = [10 ** 10] * (N)
dp[0] = 0
#dp[1] = abs(hn[0]-hn[1])
for i in range(N):
    for j in range(1,K+1):
        if i + j < N:
            dp[i+j] = min(dp[i] + abs(hn[i+j]-hn[i]) ,dp[i+j])

print(dp[-1])

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

ll KMAX = 20000;

bool dp[81][81][20000] = {};

int main(){
  ll H, W; cin >> H >> W;
  ll dif[H][W];
  for(ll h = 0; h < H; h++){
    for(ll w = 0; w < W; w++){
      cin >> dif[h][w];
    }
  }
  for(ll h = 0; h < H; h++){
    for(ll w = 0; w < W; w++){
      ll a; cin >> a;
      dif[h][w] -= a;
      dif[h][w] *= (dif[h][w] < 0 ? -1 : 1);
    }
  }
  
  dp[0][0][ dif[0][0] ] = true;
  
  for(ll h = 0; h < H; h++){
    for(ll w = 0; w < W; w++){
      for(ll k = 0; k < KMAX - 100; k++){
        if(dp[h][w][k]){
          if(h != H-1){
            dp[h+1][w][k + dif[h+1][w]] = true;
            dp[h+1][w][abs(k - dif[h+1][w])] = true;
          }
          if(w != W-1){
            dp[h][w+1][k + dif[h][w+1]] = true;
            dp[h][w+1][abs(k - dif[h][w+1])] = true;
          }
        }
      }
    }
  }
  
  for(ll i = 0; i < KMAX; i++){
    if(dp[H-1][W-1][i]){
      cout << i << endl;
      break;
    }
  }
}

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


int main(){
    char S[4];
    cin >> S;

    bool answer = true;

    for(int i=0; i<3; i++){
        if(S[i] == S[i+1]){
            answer = false;
        } 
    }

    if(answer){
        cout << "Good";
    }
    else{
        cout << "Bad";
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
int main(){
while(true){
 int a;
 int b;
 std::cin >> a >> b;
 if(a==0 && b==0) { break; }
 if( a > b ){
  int t = static_cast<int&&>(a);
  a = static_cast<int&&>(b);
  b = static_cast<int&&>(t);
 }
 std::cout << a << " " << b << std::endl;
}
}

Measured memory_bytes: 3028
import java.util.*;

public class Main {
    public static int MOD = 998244353;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        long n = sc.nextLong();
        int x = sc.nextInt();
        int m = sc.nextInt();
        
        // ans:
        // array = {2,4,<16,256,471,620>}について、
        // 「i=0からスタートし、">"まで来たら"<"に戻る」ルールで、
        // 操作「今いるarray[i]の値を加算し、i++する」をn回したときの合計
        
        // array: a[i+1] = (a[i] * a[i]) % m
        
        // how: ρの形で考えて3パターンでそれぞれ集計する。
        
        Set<Integer> set = new HashSet<Integer>();
        List<Integer> list = new ArrayList<Integer>();
        set.add(x);
        list.add(x);
        int now = x;
        int last = 0;
        for (long i = 0; i < n; i++) {
            now = (int)((long)now * now % m);
            if (set.contains(now)) {
                last = now;
                break;
            } else {
                set.add(now);
                list.add(now);
            }
        }
        
        int loop_idx = 0;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == last) {
                loop_idx = i;
            }
        }
        
        long ans = 0;
        
        // [start, loop始点)
        for (int i = 0; i < loop_idx; i++) {
            ans += list.get(i);
        }
        n -= loop_idx;
        
        // [loop始点, loop終点] * 何周できるか
        long loop_sum = 0;
        for (int i = loop_idx; i < list.size(); i++) {
            loop_sum += list.get(i);
        }
        long len = list.size() - loop_idx;
        long block = n / len;
        ans += loop_sum * block;
        n %= len;
        
        // [loop始点, 残りの移動回数]
        for (int i = loop_idx; i < loop_idx + n; i++) {
            ans += list.get(i);
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 43240