akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>
#include <numeric>
using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

const ll MOD = 1000000007;
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// xを素因数分解
map <ll, ll> primeFactorization(ll x){
    map <ll, ll> ret;
    for(ll i = 2; i * i <= x; i++){
        while(x % i == 0){
            ret[i] ++;
            x /= i;
        }
    }
    if(x != 1) ret[x] = 1;

    return ret;
}

map <ll, ll> primeDiv( map<ll, ll> x, map<ll, ll> y){
    for(auto it = y.begin(); it != y.end() ; ++it){
        x[ it->first ] -= it->second;
    }
    return x;
}

ll reproduct(map<ll, ll> x, ll MOD){

    ll L = 1;
    for( auto it = x.begin(); it != x.end(); it++ ){
        for(int i = 0; i < it->second; i++){
            L *= it->first;
            L %= MOD;
        }
    }
    return L;
}

// a ÷ b mod. MOD を計算してみる
int main() {

    ll n;
    cin >> n;
 
    vector<ll> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
 
    map<ll, ll> LCM;
    vector< map<ll, ll> > lcm(n);
    for(int i = 0; i < n; i++){
        lcm[i] = primeFactorization(v[i]);
        for( auto it = lcm[i].begin(); it != lcm[i].end(); ++it ){
            LCM[ it->first ] = max( LCM[ it->first ],   it->second );
        }
    }

    ll ans = 0;
    ll L = reproduct( LCM, MOD );
    for(int i = 0; i < n; i++){
        ans += L * modinv( v[i], MOD );
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3968
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	int N;
	char a[10005];
	cin>>N>>a;
	for(int i=0;i<strlen(a);i++)
	{
		a[i]+=N;
		if(a[i]>'Z')
			a[i]-=26;
	}
	cout<<a;
} 

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        t: u32,
        tt: [u32;n]
    }
    let mut res = t;
    for i in 1..n {
        res += std::cmp::min(tt[i] - tt[i-1], t);
    }
    println!("{}", res);
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 085 C / Link: http://abc085.contest.atcoder.jp/tasks/abc085_c  ----- */


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

	LL N, Y; cin >> N >> Y;
	using tp = tuple<int, int, int>;
	tp ans=tp(-1,-1,-1);
	FOR(i, 0, N + 1) {
		FOR(j, 0, N + 1) {
			LL sen = Y - 10000LL * i - 5000 * j;
			LL k = sen / 1000;
			if (sen >= 0 && sen % 1000 == 0 && i+j+k==N) {
				ans = tp(i, j, sen / 1000);
			}
		}
	}

	int a, b, c; tie(a, b, c) = ans;
	cout << a << " " << b << " " << c << endl;
	
	return 0;
}


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

int main(){
  int N;
  int p[100], order[100];
  int a,b,c,d;
  vector<int> v;

  cin >> N;
  for( int i=0;i<N;i++ ) p[i]=0;
  for( int i=0,len=N*(N-1)/2;i<len;i++ ){
    cin >>a >> b >> c >> d;
    //    cout << a<<b<<c<<d<<endl;
    a--; b--;
    if( c==d ){ // テつ暗δクテつづつォテつ陛つェテつづつッ
      p[a]++; p[b]++;
    }else if( c>d )
      p[a]+=3;
    else 
      p[b]+=3;
  }
  /*
  for( int i=0;i<N;i++ )
    cout << "p "<<p[i] << endl;    
  */
  for( int i=1;i<=N; ){ // テつ湘つつ暗δ甘つεつ凝つーテつプ
    //    cout << "No."<<i<<endl;
    v.clear();
    int max = -1;
    for( int j=0;j<N;j++ ){
      if( p[j]>max ){
	max=p[j];
	//	cout << " max="<<j<<endl;
	v.clear();
	v.push_back( j );
      } else if( p[j]==max ){
	v.push_back( j );
      }
    }
    for( int j=0;j<v.size();j++ ){
      order[v[j]] = i; p[v[j]] = -10;
    }
    i+=v.size();
  }
  for( int i=0;i<N;i++ )
    cout << order[i] << endl;
  

  return 0;
}

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

int main() {
  int d;
  cin >> d;
  vector<long long> c(26);
  for(int i = 0; i < 26; i++) cin >> c.at(i);
  vector<vector<long long>> s(d, vector<long long> (26));
  for(int i = 0; i < d; i++){
    for(int j = 0; j < 26; j++) cin >> s.at(i).at(j);
  }
  
  vector<int> ans(d), last(26);
  long long score = 0;
  for(int day = 0; day < d; day++){
    long long ma = -pow(10, 9), choice;
    for(int i = 0; i < 26; i++){
      long long sum = 0;
      sum += s.at(day).at(i);
      for(int j = 0; j < 26; j++){
        if(i == j) continue;
        sum -= c.at(j) * (day - last.at(j));
      }
      if(ma < sum) ma = sum, choice = i;
    }
    score += ma;
    last.at(choice) = day;
    ans.at(day) = choice + 1;
  }
  
  for(auto now : ans) cout << now << endl;
}

Measured memory_bytes: 3724
N = gets.to_i
A = gets.chomp.split.map(&:to_i)

MAX = 10 ** 18

m = 1

A.each do |a|
  if a == 0
    puts 0
    exit
  end
end

A.each do |a|
  m *= a
  if m > MAX
    puts '-1'
    exit
  end
end

puts m


Measured memory_bytes: 23384
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

n = list(get_input())
maxi = 0
nums = [0 for i in range(101)]

for j in range(len(n)):
    k = int(n[j])
    nums[int(n[j])] += 1
    maxi = max(maxi, nums[k])

for i in range(101):
    if nums[i] == maxi:
        print(i)


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

const int mod = 998244353;

struct Data{
    int L, R;
};

int main(){
    int N, K;
    cin >> N >> K;
    Data data[K];
    for (int i = 0; i < K; ++i){
        cin >> data[i].L >> data[i].R;
    }

    ll dp[N + 1];
    for (int i = 0; i < N + 1; ++i){
        dp[i] = 0;
    } 
    dp[1] = 1;
    for (int i = 2; i < N + 1; ++i){
        for (int j = 0; j < K; ++j){
            if (data[j].L <= i){
                int num;
                num = dp[i - data[j].L] - dp[max(0, i - data[j].R - 1)];
                dp[i] = (dp[i] + num) % mod;
            }
        }
        dp[i] = (dp[i] + dp[i - 1]) % mod;
    }

    cout << (dp[N] - dp[N - 1] + mod) % mod << endl;
}

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

int main(void) {
    int x,y,z;
    cin >> x;
    cin >> y;
    cin >> z;
    if(x > y){
        int temp = x;
        x = y;
        y = temp;
    }
    if(y > z){
        int temp = y;
        y = z;
        z = temp;
    }
    if(x > y){
        int temp = x;
        x = y;
        y = temp;
    }
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 3072
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
    n: usize,
    a: [usize; n],
    }
    let mut ans = 0;
    let mut t = 1;
    for i in a{
        if i == t {
            t += 1;
        } else {
            ans += 1;
        }
    }
    if t == 1 {
        println!("-1");
        return
    }
    println!("{}", ans)
}


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

int main(){
	int n,a;
	cin>>n;
	stack<int> A;
	for(int i=0;i<n;i++){
		cin>>a;
		A.push(a);
	}
	for(int i=0;i<n;i++){
		int fuga = A.top();
		if(i<n-1)
			cout<<fuga<<" ";
		else
			cout<<fuga;
		A.pop();
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  string S; cin >> S;
  int ans = 0, v = 0;
  REP(i, 3) {
    if (S[i] == 'R') {
      ++v;
      ans = max(ans, v);
    } else {
      v = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3564
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, H, W = (int(i) for i in input().split())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    ans = 0
    for a, b in AB:
        ans += min(a//H, b//W)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, Q;
	string S;
	long long AC[100002] = {0};

	
	cin >> N >> Q;
	cin >> S;
	const char* s = S.c_str();
	// N = strlen(s)
	AC[0] = 0;
	for(int i=0; i < N - 1; i++){
		if(strncmp(s+i, "AC", 2) == 0){
			AC[i + 1] = AC[i];
			AC[i + 2] = AC[i + 1] + 1;
			if(i != N - 2)
				i++;
		}
		else{
			AC[i + 1] = AC[i];
			if(i == N - 2){
				AC[N] = AC[N - 1];
				break;
			}
		}
	}
	if(strncmp(s+N-2, "AC", 2) != 0){
		AC[N] = AC[N-1];
	}

	for(int i = 1; i <= Q; i++){
		int l, r;
		cin >> l >> r;
		long long ans;
		ans = AC[r] - AC[l - 1];
		if(AC[l] != AC[l - 1]){
			ans--;
		}
		cout << ans << endl ;
	}
	return 0;
}

Measured memory_bytes: 1872
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String a = scan.next();
    String b = scan.next();
    for (int j = 0; j<a.length();j++){
      if (a.charAt(j)!=b.charAt(j)){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 35756
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;

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

  while(N > 0) {
    int n = N % 10;
    if(n == 9) {
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

void inputData(vector<string>& data_set) {
	string buffer;
	while(getline(std::cin,buffer))
		data_set.push_back(buffer);
}

vector<string> splitString(const string& str, const string& separator = " ") {
	vector<string> ret;

	std::size_t bp, ep;
	bp = ep = 0;
	while((ep = str.find_first_of(separator, bp)) != string::npos){
		if(bp != ep){
			ret.push_back(string(str.begin() + bp, str.begin() + ep));
		}
		bp = ep + 1;
	}

	if(bp <= str.size() - 1){
		ret.push_back(string(str.begin() + bp, str.end()));
	}

	return ret;
}

template <class T>
T convertStringToNumber(const string& str) {
	stringstream ss;
	T ret;

	ss << str;
	ss >> ret;

	return ret;
}

vector<int> addDigits(const vector<string>& str_set) {
	vector<int> data_set(str_set.size());

	auto countDigits = [](const int num) -> int {
		int n = num, i;
		for(i = 0; n > 0; n/=10,++i);
		return i;
	};

	for(int i = 0; i < str_set.size(); ++i) {
		vector<string> temp = splitString(str_set[i], " ");
		data_set[i] = countDigits(convertStringToNumber<int>(temp[0])
									+ convertStringToNumber<int>(temp[1]));
	}

	return data_set;
}


void doAllProcess() {
	vector<string> buffer;

	inputData(buffer);

	auto ret = addDigits(buffer);

	for(auto&& e : ret)
		std::cout << e << std::endl;
}



int main() {
	doAllProcess();


	return 0;
}


Measured memory_bytes: 3172
def ma():
    return map(int,input().split())
y="Yes"
t="No"
n,m,x=ma()
CA=[list(ma()) for _ in range(n)]

ans=10**9
for i in range(2**n):
    temp=0
    dp=[0]*m
    base=0
    
    while i>>base:
        if (i>>base)&1==1:
            #print(t,i)
            temp+=CA[base][0]
            for j in range(m):
                dp[j]+=CA[base][j+1]
        base+=1
    
    for j in range(m):
        if dp[j]<x:
            break
    else:
        ans=min(ans,temp)
if ans==10**9:
    print(-1)
else:
    print(ans)   

Measured memory_bytes: 9220
W, H, N = map(int, input().split())
l = 0
r = W
b = 0
t = H
for i in range(N):
    L = [int(i) for i in input().split()]
    if L[2] == 1:
        l = max(l, L[0])
    elif L[2] == 2:
        r = min(r, L[0])
    elif L[2] == 3:
        b = max(b, L[1])
    else:
        t = min(t, L[1])
if l < r and b < t:
    print((r-l)*(t-b))
else:
    print(0)


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

int maxa = 1000000;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, i, j;
    cin >> n;
    vi a(n); cin >> a;
    vi cnt(maxa+1, 0);
    for(auto x : a) cnt[x] += 1;
    int ans = 0;
    int lm = min(maxa , *max_element(all(a)));
    for(i=0;i<=maxa;i++){
        if(cnt[i] > 0){
            if(cnt[i] == 1) ans++;
            for(j = 2*i; j<=lm; j+=i){
                cnt[j] = 0;
            }
            cnt[i] = 0;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7912
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;break;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;break;
		}
	}
	return 0;
} 

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <string.h>

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

Measured memory_bytes: 1160
import collections

n = int(input())
a = [collections.deque(int(s) - 1 for s in input().split()) for _ in range(n)]

day = 0
players = set(range(n))
while any(v for v in a):
    nxt_players = set()
    for player in players:
        if len(a[player]) == 0 or player in nxt_players:
            continue
        
        other = a[player][0]
        if len(a[other]) == 0 or other in nxt_players:
            continue
        
        if player == a[other][0]:
            a[player].popleft()
            a[other].popleft()
            nxt_players.add(player)
            nxt_players.add(other)

    if nxt_players:
        day += 1
        players = nxt_players
    else:
        print(-1)
        exit()

print(day)

Measured memory_bytes: 36084
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    int cur = 0;
    for (int j = 0; j < n; j++) {
      if ((1 << j) & i) {
        cur += v[j];
        cur -= c[j];
      }
    }
    ans = max(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  char a;
  cin >> a;
  if (a == 'A') {
    cout << "T" << endl;
  } else if (a == 'T') {
    cout << "A" << endl;
  } else if (a == 'G') {
    cout << "C" << endl;
  } else {
    cout << "G" << endl;
  }
}


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

int main() {
  int n, m;
  cin >> n >> m;
  priority_queue<ll>q;
  rep(i,n) {
    ll a;
    cin >> a;
    q.push(a);
  }
  rep(i,m){
    ll a = q.top();q.pop();
    q.push(a/2);
  }
  ll sum = 0;
  rep(i,n){
    sum += q.top();q.pop();
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int N,M,L;
double a[105][105],b[105][105],t[105][105],P,T,V;

long double f(int x)
{
	long double r=1;
	for(;x;)r*=x--;
	return r;
}

int main()
{
	scanf("%d%d%d",&N,&M,&L);
	for(int i=0;i<N;i++)
	{
		scanf("%lf%lf%lf",&P,&T,&V);
		for(int j=0;j<=M;j++)
		{
			t[i][j]=L/V+T*j;
			a[i][j]=pow(P/100,j)*pow(1-P/100,M-j)*f(M)/f(j)/f(M-j);
			b[i][j+1]=b[i][j]+a[i][j];
		}
	}
	for(int i=0;i<N;i++)
	{
		double n=0;
		for(int j=0;j<=M;j++)
		{
			double c=a[i][j];
			for(int k=0;k<N;k++)
				if(i!=k)
				{
					int x=upper_bound(t[k],t[k]+M+1,t[i][j]+1e-9)-t[k];
					c*=1-b[k][x];
				}
			n+=c;
		}
		printf("%.8f\n",n);
	}
	return 0;
}

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

int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a2 < a1){
        swap(a1,a2);
    }
    if(a3 < a2){
        swap(a2,a3);
    }
    if(a2 < a1){
        swap(a1,a2);    
    }    
    cout << a1 << " " << a2 << " " << a3 << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 2000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
typedef pair<int, int>pii;
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll dp[150][410][410];
ll rui[410][410];
int a[400], b[400];
int dat[400][400];
bool xa[400][400], xb[400][400];
vector<pii>vec[400];
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &a[i]), a[i]--;
	for (int i = 0; i < num; i++)scanf("%d", &b[i]), b[i]--;
	for (int i = 0; i < num; i++)
	{
		bool f[400];
		fill(f, f + 400, false);
		int cnt = i + 1;
		for (int j = 0; j <= i; j++)f[a[j]] = true;
		for (int j = 0; j < num; j++)
		{
			if (!f[b[j]])cnt++;
			dat[i][j] = cnt;
		}
	}
	if (a[0] == b[0])
	{
		printf("0\n");
		return 0;
	}
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < num; j++)
		{
			xa[i][j + 1] = (a[j] == i) || xa[i][j];
			xb[i][j + 1] = (b[j] == i) || xb[i][j];
		}
	}
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)vec[dat[i][j]].push_back(make_pair(i, j));
	invinit();
	dp[1][1][1] = 1;
	for (int i = 1; i < num / 3; i++)
	{
		for (int j = 0; j <= num; j++)for (int k = 0; k <= num; k++)rui[j][k] = 0;
		for (int r = 2; r <= num; r++)
		{
			for (int t = 0; t < vec[r - 2].size(); t++)
			{
				int x = vec[r - 2][t].first, y = vec[r - 2][t].second;
				if (i * 3 >= r - 2)rui[x + 1][y + 1] = (rui[x + 1][y] + rui[x][y + 1] - rui[x][y] + dp[i][x + 1][y + 1] * kai[i * 3 - (r - 2)] + mod) % mod;
				else rui[x + 1][y + 1] = (rui[x + 1][y] + rui[x][y + 1] - rui[x][y] + mod) % mod;
			}
			for (int t = 0; t < vec[r - 1].size(); t++)
			{
				int x = vec[r - 1][t].first, y = vec[r - 1][t].second;
				rui[x + 1][y + 1] = (rui[x + 1][y] + rui[x][y + 1] - rui[x][y] + mod) % mod;
			}
			for (int t = 0; t < vec[r].size(); t++)
			{
				int x = vec[r][t].first, y = vec[r][t].second;
				rui[x + 1][y + 1] = (rui[x + 1][y] + rui[x][y + 1] - rui[x][y] + mod) % mod;
			}
			for (int t = 0; t < vec[r].size(); t++)
			{
				int x = vec[r][t].first, y = vec[r][t].second;
				if ((!xa[b[y]][x + 1]) && (!xb[a[x]][y + 1]))
				{
					if (i * 3 + 2 >= r)dp[i + 1][x + 1][y + 1] = rui[x][y] * invkai[i * 3 + 2 - r] % mod;
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < num; j++)
		{
			ll t = dp[num / 3][i + 1][j + 1];
			for (int k = 1; k <= num - dat[i][j]; k++)t = t*k%mod;
			ans = (ans + t) % mod;
		}
	}
	for (int i = 0; i < num / 3; i++)ans = ans*(i * 3 + 1)*(i * 3 + 2) % mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 182656
#include<bits/stdc++.h>
#define LL long long
#define inf 0x3fffffffffffffff
using namespace std;

int n;

int main()
{
    cin>>n;
    int ans=1;
    for (int i=2;i<=n;i++)
    {
        int x=i*i;
        for (;x<=n;x*=i)
            if (x<=n) ans=max(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head
 
void solve(){
    int n, d;
    cin >> n >> d;
    vector<vector<int>> a(n);
    int t;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < d; j++){
            cin >> t;
            a[i].push_back(t);
        }
    }

    double distance;
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            distance = 0;
            for (int k = 0; k < d; k++){
                distance += pow((a[i][k] - a[j][k]), 2);
            }
            distance = sqrt(distance);
            if (distance - (int) distance == 0.0) ans++;
        }
    }
    cout << ans << '\n';
}

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

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

Measured memory_bytes: 3672
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=100100;
int i,j,k,n,m,ch,ff,x,y,Fg,En,cnt;
ll ans;
int nm[3],c[N],h[N];
struct edge { int s,n,v;} E[N<<1];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].v=1;
	E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].v=2;
	E[En].n=h[y];h[y]=En;
}
void dfs(int x) {
	nm[c[x]]++;
	for (int k=h[x];k;k=E[k].n) {
		cnt++;
		int nt=(c[x]+E[k].v)%3;
		if (c[E[k].s]==-1) {
			c[E[k].s]=nt;
			dfs(E[k].s);
		}
		else {
			if (c[E[k].s]!=nt) Fg=1;
		}
	}
}
int main() {
	R(n);R(m);
	for (i=1;i<=m;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	memset(c,-1,sizeof c);
	for (i=1;i<=n;i++) if (c[i]==-1) {
		nm[0]=nm[1]=nm[2]=0;
		cnt=0;
		c[i]=0;
		Fg=0;
		dfs(i);
		cnt/=2;
		if (Fg) {
			int t=nm[0]+nm[1]+nm[2];
			ans+=(ll) t*t;
		}
		else {
			if (!nm[0] || !nm[1] || !nm[2]) ans+=cnt;
			else ans+=(ll) nm[0]*nm[1]+(ll) nm[1]*nm[2]+(ll) nm[2]*nm[0];
		}
	}
	printf("%lld\n",ans);
}

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

int main(){
int H,W;
  cin>>H>>W;
  vector<string>a(H);
  for(int i=0; i<H; i++){
    cin>>a[i];}
  
  vector<bool>row(H, false), col(W, false);
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
    if(a[i][j]=='#'){
      row[i]=true;   // 1つでも＃があるi行はtrueにされる
      col[j]=true; } // 1つでも＃があるj列はtrueにされる
   }
  }
  
  for(int i=0; i<H; i++){
   if(row[i]){  // そのi行内に1つでも＃がある
     for(int j=0; j<W; j++){
      if(col[j]){cout<<a[i][j];} // そのj列内に1つでも＃がある
     }   // 1つだけ.があっても、それを含む行列に＃が1つでもあれば
    cout<<endl;  // 出力されるしくみ
   }
  }
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int s = int.Parse(input[0]);
            int w = int.Parse(input[1]);

            if(w>=s)
            {
                Console.WriteLine("unsafe");
            }
            else
            {
                Console.WriteLine("safe");
            }

        }
    }
}

Measured memory_bytes: 17840
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int H, W, cnt = 0;
    char s[55][55];

    cin >> H >> W;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (s[i][j] == '#' && s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j-1] != '#' && s[i][j+1] != '#') cnt++;
        }
    }

    if (cnt == 0) cout << "Yes" << endl;
    else cout <<  "No" << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
b=list(map(int,input().split()))
a=list(map(int,input().split()))
ans=0
for i in range(n):
  m=min(b[i],a[i])
  ans+=m
  a[i]-=m
  b[i]-=m
  m=min(b[i+1],a[i])
  ans+=m
  a[i]-=m
  b[i+1]-=m
print(ans)


Measured memory_bytes: 18476
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b=map(int,input().split())
print(min(str(a)*b,str(b)*a))


Measured memory_bytes: 38256
from functools import reduce

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def gcd_list(numbers):
    return reduce(gcd, numbers)
    

n,x = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ls = [abs(i-x) for i in xs]


print(gcd_list(ls))

Measured memory_bytes: 14748
import math

X = int(input())
ans = 1
flg = False
for i in range(X, 0, -1):
    if flg:
        break
    for j in range(2, int(math.sqrt(i)) + 1):
        temp = i
        while True:
            if temp % j != 0:
                break
            elif temp / j == 1:
                print(i)
                flg = True
            temp = temp // j
        if flg:
            break
if not flg:
    print(1)


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

long long f[110][100100];

void readint(int &x){
	char c;
	while(!isdigit(c=getchar()));
	x=c^48;
	while(isdigit(c=getchar())) x=(x<<3)+(x<<1)+(c^48);
}

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	
	int N,W;
	readint(N);
	readint(W);
	
	for(int i=1;i<=N;i++){
		int w,v;
		readint(w);
		readint(v);
		for(int j=1;j<=W;j++){
			f[i][j]=f[i-1][j];
			if(j>=w) f[i][j]=max(f[i][j],f[i-1][j-w]+v);
		}
	}
	return cout<<f[N][W]<<endl,0;
}

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N) {
    cin >> H[i];
  }
  int h = H[0];
  int ans = 0;
  REP(i, N) {
    if(H[i] >= h) {
      ans++;
    }
    h = max(h, H[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007

int main()
{
	fast;
	int n,m,k,ans=0;
	cin>>n>>m;
	vector<vector<int>> v(m);
	for(int i=0;i<m;i++)
	{
		cin>>k;
        v[i].resize(k);
		for(int j=0;j<k;j++)
        {
            cin>>v[i][j];
            --v[i][j];
        }
	}
	vector<int> p(m);
    for(int i=0;i<m;i++)
        cin>>p[i];
    for(int i=0;i<(1<<n);i++)
    {
    	bool flag=true;
    	for(int j=0;j<m;j++)
    	{
            int cnt=0;
    		for(auto it: v[j])
    		{
    			if((i>>it)&1)
    				cnt++;
    		}
            cnt%=2;
    		if(cnt!=p[j])
    			flag=false;
    	}
    	if(flag)
    		ans++;
    }
    cout<<ans<<"\n";
	return 0;
}


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

template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}

int main(){
  int n;cin>>n;
  long long ans = 1;
  for(int i = 0; n > i; i++){
    long long t;cin>>t;
    ans = lcm(ans,t);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

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


    int n,m;cin>>n>>m;
        vec s(m);
        vec c(m);    
    rep(i,m){
        cin>>s[i]>>c[i];
    }
    rep(i,m) --s[i];

    for(int i=0;i<=pow(10,n);i++){
        bool ans = true;        
        string num = to_string(i);             
        if(num.size()!=n) continue;
        rep(j,m){
            if(num[s[j]]-'0'!= c[j]){
                ans=false;
            }
        }

        if(ans){
            cout<<i<<endl;
            return 0;
    }

    }

    cout<<"-1"<<endl;
    return 0;
}

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

namespace abc041
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            int s;
            int i;
            n = int.Parse(Console.ReadLine());
            s = 0;
            for (i = 1; i <=n;i++)
            {
                s = s + i;
            }
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


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

#define ll long long

int h, w;

int main(){
	scanf("%d%d", &h, &w);
	ll ans = LLONG_MAX;
	if(h % 3 == 0 || w % 3 == 0) return printf("0\n"), 0;
	
	ans = std::min(h, w);
	
	for(int i = 1; i < h; ++ i){
		ll a1 = 1ll * w * i, a2 = 1ll * w / 2 * (h - i), a3 = 1ll * (w - w / 2) * (h - i);
		ans = std::min(ans, std::max(a1, std::max(a2, a3)) - std::min(a1, std::min(a2, a3)));
	}
	
	for(int i = 1; i < w; ++ i){
		ll a1 = 1ll * h * i, a2 = 1ll * h / 2 * (w - i), a3 = 1ll * (h - h / 2) * (w - i);
		ans = std::min(ans, std::max(a1, std::max(a2, a3)) - std::min(a1, std::min(a2, a3)));
	}
	
	printf("%I64d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

struct VectorItem
{
  int64_t A, B, C;
  VectorItem(int64_t A = 0, int64_t B = 0, int64_t C = 0) : A(A), B(B), C(C) {}
  bool operator<(const VectorItem &item) const { return C < item.C; }
  bool operator>(const VectorItem &item) const { return C > item.C; }
};

int main(int argc, char **argv)
{
  uint64_t N;
  std::cin >> N;
  
  std::vector<VectorItem> v(N);
  N_TIMES(n, N) {
    int64_t A, B;
    std::cin >> A >> B;
    
    v[n] = VectorItem(A, B, A + B);
  }
  
  std::sort(v.begin(), v.end(), std::greater<VectorItem>());
  
  int64_t takahashi = 0, aoki = 0;
  N_TIMES(n, N) {
    if (n % 2 == 0) {
      takahashi += v[n].A;
    } else {
      aoki += v[n].B;
    }
  }
  
  std::cout << (takahashi - aoki) << std::endl;
  
  return 0;
}

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


int main() {
  int k;
  string s;
  cin >> k >> s;
  int ss = s.size();
  if(ss <= k) cout << s << endl;
  else {
    rep(i, k) cout << s[i];
    cout << "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

int main() {
	int n,ans,max,p;
	max = 0;
  ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p;
		if (p > max)max = p;
		ans += p;

	}
	ans -= max / 2;

	cout << ans << endl;
		
	
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;
int main() {
	int N;
	int a[100001];
	cin >> N;
	vector<int>v(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		v[i] = a[i];
	}
	sort(v.begin(), v.end());
	ll sum = 0;
	int count = 1;
	for (int i =0; i < N-1; ++i) {
		if (v[i] == v[i + 1]) {
			count++;
		}
		else {
			if (v[i] > count) {
				sum += count;
			}
			else if (v[i] < count) {
				sum += count - v[i];
			}
			count = 1;
		}
	}
	if (v[N - 1] < count) {
		sum += count - v[N-1];
	}
	else if (v[N - 1] > count) {
		sum += count;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
const main = (input) => {
  const change = (answer) => {
    const temp = parseInt(answer, 10);
    if (temp === 0) {
      return 0;
    } else {
      return 1000 - temp;
    }
  };

  const N = input.trim().split("");
  if (N.length <= 3) {
    console.log(change(N.join("")));
  } else {
    let answer = "";
    let cnt = 0;

    while (cnt < 3) {
      answer = N.pop() + answer;
      cnt++;
    }

    console.log(change(answer));
  }
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29656
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
s=str(input())
l=len(s)

ans=100000000000
for i in range(l-2):
    k=""
    for j in range(3):
        k+=s[i+j]
    d=int(k)
    ans=min(ans,abs(753-d))
print(ans)

    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
LL n, x, as;
LL work(LL a, LL b) {
	if(a > b) swap(a, b);
	if(a == 0) return 0;
	return work(a, b % a) + b / a * 2 * a - a * (b % a == 0);
}
int main() {
	cin >> n >> x;
	as += n;
	as += work(x, n - x);
	cout << as << endl;
	return 0;
}


Measured memory_bytes: 256
open Str

type btree = Node of node | Nil and
     node = {k : int; l : btree; r : btree}

let preorder f tr =
  let rec iter = function
      Nil -> ()
    | Node n -> f n.k; iter n.l; iter n.r
  in iter tr; print_newline ()
  
let inorder f tr =
  let rec iter = function
      Nil -> ()
    | Node n -> iter n.l; f n.k; iter n.r
  in iter tr; print_newline ()

let insert k tr =
  let rec iter = function
      Nil -> Node {k = k; l = Nil; r = Nil}
    | Node n -> if n.k = k then Node n
                else if n.k < k then Node {n with r = iter n.r}
                else Node {n with l = iter n.l}
  in iter tr

let find k tr =
  let rec iter = function
      Nil -> "no"
    | Node n -> if n.k = k then "yes"
                else if n.k < k then iter n.r
                else iter n.l
  in iter tr

let rec min_key tr =
  let rec iter = function
      Nil -> failwith "min_key"
    | Node n -> if n.l = Nil then n.k
                else iter n.l
  in iter tr
               
let rec delete k tr =
  let rec iter = function
      Nil -> Nil
    | Node n -> if n.k < k then Node {n with r = iter n.r}
                else if n.k > k then Node {n with l = iter n.l}
                else match n.l, n.r with
                       Nil, Nil -> Nil
                     | Nil, _ -> n.r
                     | _, Nil -> n.l
                     | _, _ -> let v = min_key n.r in
                               let nr = delete v n.r in
                               Node {n with k = v; r = nr}
  in iter tr

let read_list () =
  split (regexp " +") (read_line ())

let () =
  let n = read_int () in
  let rec read tr x =
    if x = 0 then ()
    else match read_list () with
           "print" :: _ -> begin
             inorder (fun i -> print_string @@ " " ^ (string_of_int i)) tr;
             preorder (fun i -> print_string @@ " " ^ (string_of_int i)) tr;
             read tr (x-1)
           end
         | "insert" :: ns :: _ -> read (insert (int_of_string ns) tr) (x-1)
         | "find" :: ns :: _ -> begin
             find (int_of_string ns) tr |> print_endline;
             read tr (x-1)
           end
         | "delete" :: ns :: _ -> read (delete (int_of_string ns) tr) (x-1)
         | _ -> failwith "read"
  in
  read Nil n

Measured memory_bytes: 37348
#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, t;
	cin >> n >> t;
	vi a(n); cin >> a;
	int ans = 0;
	int tmp = 0;
	for (auto i : a)
	{
		if (tmp < i)
		{
			ans += t;
		}
		else
		{
			ans += t - (tmp - i);
		}
		tmp = i + t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<double,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,0,1,1,1,-1,-1,-1};
int dy[]={1,-1,1,0,-1,1,0,-1};


 
int main(){
    LL n,k;
    while(cin >> n >> k){
        if(!n&&!k) break;
        LL t = 9, sum = 1, d = 0, c = 1;
        for (int i = 0; i < 10; i++) {
            if(sum + t * (i + 1) >= n){
                d = i + 1;
                break;
            }
            sum += t * (i + 1);
            t *= 10;
            c = c * 10;
        }
        LL l = 0, r = t + 1;
        while(r - l > 1){
            LL m = (r + l) / 2;
            if(sum + d * m <= n){
                l = m;
            }
            else{
                r = m;
            }
        }
        sum += d * l;
        LL p = c + l;
        string ans = "";
        for (int i = 0; i <= k; i++) {
            ans += to_string(p+i);
        }
        for (int i = n-sum; i < n-sum+k; i++) {
            cout << ans[i];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3216
#include <iostream>

using namespace std;
int CARD_NUM = 13;
int CARD_TOTAL_NUM = 13 * 4;
char const CARD_TYPES[] = {'S','H','C','D'};

void output(int card){
	int cardtype = card / CARD_NUM;
	int cardnum = (card % CARD_NUM) + 1;
	cout << CARD_TYPES[cardtype] << " " << cardnum << "\n";
}
int input(){
	char cardtype;
	int cardnum;
	cin >> cardtype >> cardnum;
	for(int i = 0; i < 4; i++){
		if(CARD_TYPES[i] == cardtype) {
			return i * CARD_NUM + cardnum - 1;	
		}
	}
	return 0;//??±???
}
int main(int argc, char *argv[]){
	int isExistCard[CARD_TOTAL_NUM];
	for(int i = 0; i < CARD_TOTAL_NUM; i++){
		isExistCard[i] = false;	
	}
	int existNum;
	cin >> existNum;
	for(int i = 0; i < existNum; i++){
		int card = input();
		isExistCard[card] = true;	
	}
	for(int i = 0; i < CARD_TOTAL_NUM; i++){
		if (!isExistCard[i]){
			output(i);
		}
	}
	return 0;
}

Measured memory_bytes: 3084
import sys
from collections import deque

n = int(input())
nex = [[] for _ in range(n)]
d = [[1000]*n for _ in range(n)]
for i in range(n):
    ni = list(sys.stdin.readline().rstrip())
    for j in range(n):
        if ni[j] == '1':
            nex[i].append(j)
            d[i][j] = 1
        elif i == j:
            d[i][j] =0
        else:
            d[i][j] = 1000000

maxi = 0
maxii = 0
vr = [set() for _ in range(n)]
nexcache = deque()
di = 1
dil = [-1] * n
dil[0] = 0
vr[0].add(0)
for i in range(len(nex[0])):
        vr[nex[0][i]].add(1)
        vr[nex[0][i]].add(-1)
        nexcache.append(nex[0][i])
        maxi = 1
        maxii = nex[0][i]
        dil[nex[0][i]] = 1
error = False
while len(nexcache) > 0:
    nnx = []
    for ne in nexcache:
        couho = set()
        for i in vr[ne]:
            couho.add(i+1)
            couho.add(i-1)
        for i in nex[ne]:
            if dil[i] == -1:
                vr[i] = vr[i].union(couho)
                nnx.append(i)
                dil[i] = di+1
                if maxi < di+1:
                    maxi = di+1
                    maxii = i
            else:
                if dil[i] != di-1 and dil[i] != di+1:
                    error = True
                    break
        if error:
            break
    di+=1
    nexcache = nnx

if error:
    print(-1)
    exit()

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

result = 0
for i in range(n):
    for j in range(i):
        if d[i][j] > result:
            result = d[i][j]

print(result+1)


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

int main() {
	int a,b,c,x;
  	int cnt;
  	int i,j,k;

  	cin >> a >> b >> c;
  	cin >> x;
  	
  	cnt=0;
  	for (i=0;i<=a;++i)
    {
    	for (j=0;j<=b;++j)
        {
          	for (k=0;k<=c;++k)
            {
              	if (i*500+j*100+k*50 == x)
                  	++cnt;
            }
        }
    }

  	cout << cnt << endl;
}


Measured memory_bytes: 256