akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int temp_data[50];

int fib(int n) {
	if (temp_data[n] != -1) return temp_data[n];
	if (n == 0) return 1;
	if (n == 1) return 1;
	int res = fib(n - 1) + fib(n - 2);
	temp_data[n] = res;
	return res;
}

int main() {
	for (int i = 0; i < 50; i++) temp_data[i] = -1;

	int n;
	cin >> n;
	cout << fib(n) << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N, K;
  long T=0;
  cin >> N >> K;
  
  vector<long> H(N);
  for(int i=0; i<N; i++)
    cin >> H.at(i);
  
  if(N < K)
    K = N;
  
  sort(H.begin(), H.end());
  
  for(int i=0; i<N-K; i++){
    T += H.at(i);
  }
  
  cout << T << endl;
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<double> x(N);
    vector<string> u(N);
    REP(i,N)cin >> x[i] >> u[i];
    double answer = 0;
    REP(i,N)answer += u[i] == "JPY" ? x[i] : x[i]*380000;
    cout << answer << "\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ppr, Vppr, greater<ppr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 4010;
const int SIZE3 = 305;
const int SIZE = SIZE1;
const LL p = 998244353;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
ut N, M, K, X, L, Y, H, W, Q, D, T;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], nums[SIZE], maps[SIZE2][SIZE2], answer = zero;
LL A[SIZE];
int R, C;
LL solve() {
	cin >> H >> W >> N;
	cin >> R >> C;
	string s, t;
	cin >> s >> t;
	reverse(ALL(s));
	reverse(ALL(t));
	int sR = 1, sC = 1, eR = H, eC = W;
	REP(i, N) {
		if (t[i] == 'D') sR = max(1LL, sR - 1);
		if (t[i] == 'U') eR = min(H, eR + 1);
		if (t[i] == 'R') sC = max(1LL, sC - 1);
		if (t[i] == 'L') eC = min(W, eC + 1);
		if (s[i] == 'U') sR++;
		if (s[i] == 'D') eR--;
		if (s[i] == 'L') sC++;
		if (s[i] == 'R') eC--;
		if (eC < sC or eR < sR) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (sR <= R and R <= eR and sC <= C and C <= eC) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}
signed main() {
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();
	//	cin >> N;
	return 0;
}


Measured memory_bytes: 12824
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int array[] = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        int search = 1;
        int broken = 0;
        for (int i = 0; i < n; i++) {
            if (array[i] == search) {
                search++;
                continue;
            }
            broken++;
        }

        if (broken == n) broken = -1;
        System.out.println(broken);
    }

}

Measured memory_bytes: 65572
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
for x in range(26):
    for y in range(15):
        if 4*x + 7*y == n:
            print('Yes')
            quit()
print('No')

Measured memory_bytes: 38384
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
 
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
  int A;
  cin>>A;
  cout<<(10000-A)%1000;
return 0;}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int train[100];
	int n;
	int data_no = 0;
	
	while (scanf("%d", &n) != EOF){
		if (!n){
			printf("%d\n", train[data_no]);
			train[data_no--] = 0;
		}
		else {
			train[++data_no] = n;
		}
	}
	
	return (0);
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int n;
  cin >> n;
  int p[20];
  REP(i, n)
  {
    cin >> p[i];
  }

  int count = 0;
  FOR(i, 1, n - 1)
  {
    if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]))
    {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
s = input()

n = len(s)
s_rev = s[::-1]

s_mae = s[:int((n-1)/2)]
s_mae_rev = s_mae[::-1]

s_usi = s[int((n+3)/2-1):]
s_usi_rev = s_usi[::-1]

if s == s_rev and s_mae == s_mae_rev and s_usi == s_usi_rev:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
from sys import exit
import math

def main():
  N = int(input())
  ran = int(math.sqrt(N))
  ans = N
  
  for i in range(1,ran+1):
    if N % i == 0:
      #print('L')
      if N / i + i <= ans + 1:
        ans = ((N / i) + i) -2
        #print(i)
  
  print(int(ans))
  
  
  
main()

Measured memory_bytes: 9144
// #include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::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...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 81;
#define endl '\n'
#define ld long double
//#define int ll
#define all(x)  (x).begin(),(x).end()
struct DSU{
  vector<int>par,sz;
  DSU(int n)
  {
    par.resize(n);
    sz = vector<int>(n,1);
    iota(par.begin(),par.end(),0);
  }
  int find(int x){
      if(x==par[x])
        return x;
      return par[x] = find(par[x]);
  }
  void unite(int a, int b){
      a = find(a);
      b = find(b);
      if(a==b)
        return ;
      if(sz[a]<sz[b])
        swap(a,b);
      par[b] = a;
      sz[a]+=sz[b];
      return ;
  }
};
int32_t main(){

  IOS


  int n, m;
  cin >> n >> m;
  DSU dsu(n);
  for(int i = 0;i<m;i++){
    int u, v;
    cin >> u >> v;
    u--, v--;
    dsu.unite(u, v);
  }
  int c = 0;
  for(int i = 0;i<n;i++){
    if(dsu.find(i)==i) c++;
  }
  cout << c - 1 << endl;




  

  
    
}



Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll h, w;
    cin >> h >> w;
    ll ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    VS s(h);
    rep(i, 0, h) cin >> s[i];

    const ll inf = 1e18;
    VVL d(h, VL(w, inf));
    
    ll di[20] = {2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, -1, -1, -1, -1, -2, -2, -2, -2, -2};
    ll dj[20] = {2, 1, 0, -1, -2, 2, 1, -1, -2, 2, -2, 2, 1, -2, -2, 2, 1, 0, -1, -2};

    auto chk = [&](ll i, ll j) {
        if(i < 0 || j < 0 || i >= h || j >= w) return false;
        else if(s[i][j] == '#') return false;
        else return true;
    };

    /* dijkstra's scope */{
        priority_queue<pair<ll,PL>, vector<pair<ll,PL>>, greater<pair<ll,PL>>> que;
        que.push({0, {ch, cw}});
        d[ch][cw] = 0;
        while(!que.empty()){
            auto q = que.top();
            que.pop();
            auto i = q.second.first;
            auto j = q.second.second;
            if(q.first > d[i][j]) continue;
            rep(k, 0, 4) {
                ll ni = i + d1[k];
                ll nj = j + d2[k];
                if(!chk(ni, nj)) continue;
                if(d[ni][nj] <= q.first) continue;
                d[ni][nj] = q.first;
                que.push({d[ni][nj], {ni, nj}});
            }
            rep(k, 0, 20) {
                ll ni = i + di[k];
                ll nj = j + dj[k];
                if(!chk(ni, nj)) continue;
                if(d[ni][nj] <= q.first + 1) continue;
                d[ni][nj] = q.first + 1;
                que.push({d[ni][nj], {ni, nj}});
            }
        }
    }

    if(d[dh][dw] == inf) cout << -1 << endl;
    else cout << d[dh][dw] << endl;
    return 0;
}

Measured memory_bytes: 13688
n = int(input())
w = list(map(int, input().split()))
res = 10 ** 9 + 7
for t in range(n - 1):
    u = sum(w[:t + 1])
    l = sum(w[t + 1:])
    dif = abs(u - l)
    if dif < res:
        res = dif
print(res)


Measured memory_bytes: 62812
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int n,q;

vector<int> cnt;
vector<vector<int> > to;
vector<bool> done;

void dfs(int id,int bef_cnt)
{
	done[id]=true;
	cnt[id]+=bef_cnt;

	for(int i=0;i<to[id].size();i++)
	{
		if(done[to[id][i]]!=true)
			dfs(to[id][i],cnt[id]);
	}
}


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

	cnt=vector<int>(n,0);
	to=vector<vector<int> >(n);
	done=vector<bool>(n,false);

	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}


	for(int i=0;i<q;i++)
	{
		int p,x;
		cin >> p >> x;
		p--;
		cnt[p]+=x;
	}


	dfs(0,0);


	for(int i=0;i<n;i++)
		cout << cnt[i] << (i==n-1 ? "":" ");
	cout << endl;




}


Measured memory_bytes: 23552
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
def resolve():
    N,K,S=pin()
    ans=[]
    bigint=pow(10,9)
    if S!=bigint:
        ans=[S]*K
        ans+=[bigint]*(N-K)
        
    else:
        ans=[bigint]*K+[1]*(N-K)
    return ans
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
if __name__=="__main__":print(*resolve())


Measured memory_bytes: 45396
#include <stdio.h>

int main(void){
    int n = 0,y = 0;
    int b = 0,r = 0,t = 0,ans = 0;
    double ri = 0,big = 0;
    double dummy = 0.0, base = 0.0;
    int i = 0, l = 1;
    while(1){
        scanf("%d", &n);    if( n == 0 )    break;
        scanf("%d", &y);
        l++;
        big = 0; 
        for(i = 1; i <= n; i++){
            scanf("%d %d %d", &b, &r, &t);
            if(t == 1){
                ri = 1.0 + y * r / 100.0;
            } else {
                dummy = 1.0 + (r / 100.0);
                base = dummy;
                for(int w = 2; w <= y; w++){
                    dummy = dummy * base;
                }
                ri = dummy;
            }
            if(ri >= big){
                big = ri;
                ans = b;
            }
        }  
        printf("%d\n", ans);                
    }
    return 0;
}


Measured memory_bytes: 1932
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
vector<vector<int>> vt;
vector<pair<int, int>> vt1;
int ch[701][701];
int n,m;
int de[701];
int gap[2],update;
int dp[701][701];
bool visited[701];
int func(int here, int x) {
	if (here == vt1.size()) {
		return x * (x - 1) / 2 + (n - x)*(n - x - 1) / 2;
	}
	int &ret = dp[here][x];
	if (ret != -1)return ret;
	ret = 1234567890;
	ret=min(ret,func(here + 1, x + vt1[here].first));
	ret = min(ret,func(here + 1,x+vt1[here].second ));
	return ret;
}
void dfs(int here,int par, int c)
{
	gap[c]++;
	de[here] = c;
	visited[here] = 1;
	for (int i = 0; i < vt[here].size(); i++) {
		int next = vt[here][i];
		if (next == par)continue;
		if (!visited[next])
			dfs(next,here, c ^ 1);
		else if (de[next] == de[here])
			update = 1;
	}
}
int main()
{
	memset(dp, -1, sizeof(dp));
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int q, w;
		scanf("%d %d", &q, &w);
		ch[q][w] = 1;
		ch[w][q] = 1;
	}
	vt.resize(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int y = i+1; y <= n; y++) {
			if (!ch[i][y]) {
				vt[i].push_back(y);
				vt[y].push_back(i);
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		if (visited[i])continue;
		dfs(i,0, 0);
		vt1.push_back({ gap[0],gap[1] });
		memset(gap, 0, sizeof(gap));
		if (update) {
			puts("-1");
			return 0;
		}
	}
	printf("%d\n", func(0, 0));
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> qu;
    loop(i,n){
        int a;
        cin >> a;
        qu.push(a);
    }
    loop(i,m){
        int a=qu.top();
        qu.pop();
        qu.push(a/2);
    }
    ll sum=0;
    loop(i,n){
        sum+=qu.top();
        qu.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
#include<stdio.h>

#define  MAX  100
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK =2;

int n,m[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int sum=0;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u=i;
	minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && m[u][v] != INFTY){
	if(d[v] > m[u][v]){
	  d[v] = m[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }

  for(i=0;i<n;i++){
    if(p[i] != -1)sum += m[i][p[i]];
  }

  return sum;
}

int main(){
  int i,j,e;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
    scanf("%d",&e);
    m[i][j] = (e == -1) ? INFTY: e;
    }
  }
printf("%d\n",prim());
return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
using namespace std;
int main()
{	
  int n;
  cin>>n;
  vector<int> v(n);
  for (int i=0;i<n;i++)
  {
    int a;
    cin>>a;
    v[i]=a;
  }
  vector<int> dp(n);
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);
  //dp[2]=min(abs(v[2]-v[0]),dp[1]+abs(v[2]-v[0]));
  for (int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 4056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		InputStreamReader in = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(in);
		StringBuilder sb = new StringBuilder(br.readLine());
		int q = Integer.parseInt(br.readLine());

		String A = new String();

		int orderFlg = 0;
		StringBuilder sb0 = new StringBuilder();
		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();

		A = sb.toString();

		for(int i = 0; i < q; i++) {

			String tmp = br.readLine();
			if(tmp.length() == 1) {
				orderFlg++;
			}else {
				String data = tmp.substring(tmp.length() -1);
				if(tmp.contains("1")) {
					if(orderFlg % 2 == 0) {
						sb1.insert(0,data);
					}else {
						sb2.append(data);
					}
				}else {
					if(orderFlg % 2 == 0) {
						sb2.append(data);
					}else {
						sb1.insert(0, data);
					}
				}

			}
		}
//		System.out.print("db1:"+ sb1 + "\n");
//		System.out.print("db2:"+ sb2 + "\n");

		sb0.append(sb1 + A + sb2);
		if((orderFlg > 0) && (orderFlg % 2 == 1)) {
			sb0.reverse();
		}
		System.out.print(sb0);

	}

}

Measured memory_bytes: 40288
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

const long long INF = MOD * 10000000LL;

int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long zero = 0;
    vector<long long> pos, neg;
    REP(i, N){
        if(A[i] > 0) pos.push_back(A[i]);
        else if(A[i] < 0) neg.push_back(A[i]);
        else zero++;
    }
    if(pos.size() + neg.size() < K){
        cout << 0 << endl;
        return 0;
    }
    if(pos.size() + neg.size() == K){
        if(neg.size()%2 && zero > 0){
            cout << 0 << endl;
            return 0;
        }
        long long prod = 1;
        for(auto x : pos){
            prod *= x;
            prod %= MOD;
        }
        for(auto x : neg){
            prod *= x;
            prod = (prod + INF) % MOD;
        }
        cout << (prod + INF) % MOD << endl;
        return 0;
    }
    if(pos.size() == 0){
        long long prod = 1;
        if(K%2){
            if(zero > 0){
                cout << 0 << endl;
                return 0;
            }
            sort(neg.begin(), neg.end(), greater<long long>());
            REP(i, K){
                prod *= neg[i];
                prod = (prod + INF) % MOD;
            }
        }else{
            sort(neg.begin(), neg.end());
            REP(i, K){
                prod *= neg[i];
                prod = (prod + INF) % MOD;
            }
        }
        cout << (prod + INF) % MOD << endl;
        return 0;
    }
    sort(pos.begin(), pos.end(), greater<long long>());
    sort(neg.begin(), neg.end());
    long long prod = 1;
    int p = 0;
    int n = 0;
    if(K%2){
        prod = pos[0];
        p++;
        K--;
    }
    while(K > 0){
        if(p+1 >= pos.size()){
            prod *= (neg[n] * neg[n+1]) % MOD;;
            prod %= MOD;
            K-=2;
            n+=2;
        }else if(n+1 >= neg.size()){
            prod *= (pos[p] * pos[p+1]) % MOD;
            prod %= MOD;
            K-=2;
            p+=2;
        }else{
            long long PP = (pos[p] * pos[p+1]);
            long long NN = (neg[n] * neg[n+1]);
            if(PP >= NN){
                prod *= PP % MOD;
                prod %= MOD;
                K-=2;
                p+=2;
            }else{
                prod *= NN % MOD;
                prod %= MOD;
                K-=2;
                n+=2;
            }
        }
        
    }
    cout << (prod + INF) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6928
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(a<=x&&x<=a+b)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


  int A[1000000],n;

int binarysearch(int key){
  int left=0;
  int right=n;
  int mid;

  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid])return 1;
    if(key>A[mid])left=mid+1;
    if(key<A[mid])right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarysearch(k))sum++;
  }
  printf("%d\n",sum);

  return 0;
}


  



Measured memory_bytes: 2108
n = int(input())
a = list(map(int, input().split()))

b = []
m = 0
for i in range(n):
    if a[i] < 0:
        m += 1
    b.append(abs(a[i]))

b.sort()
ans = sum(b)
if m % 2 == 1:
    ans -= b[0] * 2

print(ans)


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    init(x, y);
    vector<int> p;
    rep (i, n)
        p.pb(i);

    double sum = 0;
    int cnt = 0;
    do {
        cnt++;
        rep (i, p.size() - 1) {
            sum += sqrt((x[p[i]] - x[p[i + 1]]) * (x[p[i]] - x[p[i + 1]]) +
                        (y[p[i]] - y[p[i + 1]]) * (y[p[i]] - y[p[i + 1]]));
        }
    } while (next_permutation(all(p)));
    cout << setprecision(10) << sum / cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(void){
	char Week[7][4]={"thu","fri","sat","sun","mon","tue","wed"};
	int day=0;
	cin>>day;
	day%=7;
	cout<<Week[day]<<endl;
	return 0;
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A =nextInt();
		int B =nextInt();
		int X =nextInt();

		String ans ="YES";
		if(A>X){
			ans="NO";
		}
		if(A+B<X){
			ans="NO";

		}

		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include<stdio.h>
#define ARRAY_MAX 50
#define COUNT_RESET 0
#define RETURN 0
#define ARRAY_END -1
#define TEST_ABSENT -1
#define BORDER_A 80
#define BORDER_B 65
#define BORDER_C 50
#define BORDER_D 30

/* 構造体の定義 */
struct test_result{
    signed short ssW_D_mid;      /* 中間試験結果用変数 */
    signed short ssW_D_fin;      /* 期末試験結果用変数 */
    signed short ssW_D_re;       /* 再試験結果用変数 */
    unsigned char ubW_D_eval;    /* 評定用変数 */
};

/* 関数の宣言 */
unsigned char s_EVALUATE(struct test_result test);

int main(){
    struct test_result test[ARRAY_MAX];          /* 構造体の宣言 */
    unsigned short usW_C_i;                      /* ループ変数 */
    unsigned short usW_C_count = COUNT_RESET;    /* カウンタ変数 */

	/* 試験結果の入力 */
    for(usW_C_i = COUNT_RESET;usW_C_i < ARRAY_MAX;usW_C_i++){
    	/* 各個人の結果の入力 */
        scanf("%d %d %d", &test[usW_C_i].ssW_D_mid, &test[usW_C_i].ssW_D_fin, &test[usW_C_i].ssW_D_re);
    	/* 入力終了時の処理 */
        if(test[usW_C_i].ssW_D_mid == ARRAY_END && test[usW_C_i].ssW_D_fin == ARRAY_END && test[usW_C_i].ssW_D_re == ARRAY_END){
            break;
        }
    	/* 評定を代入 */
        test[usW_C_i].ubW_D_eval = s_EVALUATE(test[usW_C_i]);
    	/* カウンタをインクリメント */
        usW_C_count++;
    }

	/* 評定の出力 */
    for(usW_C_i = COUNT_RESET;usW_C_i < usW_C_count;usW_C_i++){
    	/* 各個人の評定の出力 */
        printf("%c\n", test[usW_C_i].ubW_D_eval);
    }

    return RETURN;
}

/* 関数名：評定計算 */
/* 概要：成績から評定を求める */
/* 引数：test型の構造体 */
/* 戻り値：評定 */
unsigned char s_EVALUATE(struct test_result test){
    signed short ssW_D_sum;        /* 中間期末合計点計算用の変数 */
    unsigned char ubW_D_result;    /* 評定用の変数 */

	/* 中間期末の合計点の計算 */
    ssW_D_sum = test.ssW_D_mid + test.ssW_D_fin;

	/* 評定の計算 */
    if(test.ssW_D_mid == TEST_ABSENT || test.ssW_D_fin == TEST_ABSENT){
    	/* 評定をＦに */
        ubW_D_result = 'F';
    }
    else if(ssW_D_sum >= BORDER_A){
    	/* 評定をＡに */
        ubW_D_result = 'A';
    }
    else if(ssW_D_sum >= BORDER_B){
    	/* 評定をＢに */
        ubW_D_result = 'B';
    }
    else if(ssW_D_sum >= BORDER_C){
    	/* 評定をＣに */
        ubW_D_result = 'C';
    }
    else if(ssW_D_sum >= BORDER_D){
    	/* 再試験の処理 */
        if(test.ssW_D_re >= BORDER_C){
    	/* 評定をＣに */
            ubW_D_result = 'C';
        }
        else{
        	/* 評定をＤに */
            ubW_D_result = 'D';
        }
    }
    else{
    	/* 評定をＦに */
        ubW_D_result = 'F';
    }

	/* 評定を返す */
    return ubW_D_result;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    ll N,A,B;
    cin >> N >> A >> B;
    if(A%2==B%2){
        cout << (B-A)/2 << endl;
    } else {
        ll to = min(A-1,N-B) + 1;
        ll diff = (B-A-1)/2;
        cout <<  to+diff << endl;
    }
}

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

int main() {
    int n;cin>>n;
    int a[n];int b[n];int c[n];
    int i,j,k;
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    int dp[3][n];
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    for(i=1;i<n;i++)
    {
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
    }
    cout<<max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1])<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 2688
import Data.List
import Data.Ord
import Data.Char
import Data.Ratio
import Data.Maybe

main = do
  [a,b] <- map (read::String->Integer) . lines <$> getContents
  putStrLn $ compare' a b

compare' a b | a<b = "LESS" | a==b = "EQUAL" | a>b = "GREATER"

Measured memory_bytes: 4104
A,B,Q,*I=`dd`.split.map &:to_i
s=[-F=1e15]+I[0,A]+[F]
t=[-F]+I[A,B]+[F]
eval"I[-Q,Q].map{|x|p s[s#{a='.bsearch_index{|y|y>x}-1,2].map{|'}s|t[t#{a}t|[(s-x).abs,(t-x).abs].min+(t-s).abs}.min}.min}"

Measured memory_bytes: 40192
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main { 
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	String gomi = sc.nextLine();
    	String[] eatingOrder = sc.nextLine().split(" ");
    	String[] satsfCount = sc.nextLine().split(" ");
    	String[] addiconlSatsf  = sc.nextLine().split(" ");
    	int[] intEaOrder = new int[eatingOrder.length];
    	int[] intSatsCount = new int[satsfCount.length];
    	
    	int tempPre = -1;
    	List additional = new ArrayList<Integer>(); 
    	int result = 0;
    	for(int i = 0;i<eatingOrder.length;i++) {
    		intEaOrder[i] = Integer.parseInt(eatingOrder[i]);
    		intSatsCount[i] = Integer.parseInt(satsfCount[i]);
    		if(tempPre+1 == intEaOrder[i]) {
    			additional.add(tempPre);
    		}
    		tempPre = intEaOrder[i];
    		result += intSatsCount[i];
    		
    	}
    	
    	for(int i = 0;i<additional.size();i++) {
    		int tmp = (int) additional.get(i);
    		result += Integer.parseInt(addiconlSatsf[tmp-1]);
    	
    	}
    	System.out.println(result);
    	
    	
    	
    	
    }
}

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

int main() {
	long S;
	cin >> S;
	int a;
	int out=1000;
	while(S>=100)
	{
	    a=S%1000;
	    if(out>abs(a - 753)) out=abs(a - 753);
	    S=S/10;
	}
	cout << out << endl;
	return 0;
}


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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input10.txt"); ofstream cout("output10.txt");

using namespace std;

ll  dp[2000][2000];

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

    dp[1][1] = 1;
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=m; j++)
        {
            char b;
            cin>>b;
            if(b == '.')
                dp[i][j] += dp[i-1][j] + dp[i][j - 1];
            dp[i][j] %= 1000000007;
        }
    }
    cout<<dp[n][m];
}


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

#define MAXN (100010)
#define MAXB (17)

int n, m;
int fa[MAXN], f[MAXN][MAXB], dep[MAXN], sz[MAXN];
bool isroot[MAXN];
std::vector<int> vec[MAXN];
std::vector<std::pair<int, int> > rest;

int getfather(int x){ return x == fa[x] ? x : fa[x] = getfather(fa[x]); }

void dfs(int u){
	sz[u] = 0;
	for(auto v : vec[u]){
		if(v == f[u][0]) continue;
		f[v][0] = u;
		dep[v] = dep[u] + 1;
		for(int i = 1; f[v][i] = f[f[v][i -1]][i - 1]; ++ i);
		dfs(v);
	}
}

int lca(int u, int v){
	if(dep[u] < dep[v]) std::swap(u, v);
	int delta = dep[u] - dep[v];
	for(int i = MAXB - 1; i + 1; -- i){
		if((delta >> i) & 1){
			u = f[u][i];
		}
	}
	if(u == v) return u;
	for(int i = MAXB - 1; i + 1; -- i){
		if(f[u][i] != f[v][i]){
			u = f[u][i];
			v = f[v][i];
		}
	}
	return f[u][0];
}

bool check(int u, int root){
	for(auto v : vec[u]){
		if(v == f[u][0]) continue;
		bool ret = check(v, root);
		if(!ret) return false;
		sz[u] += sz[v];
	}
	if(u != root && !(sz[u] & 1)) return false;
	return true;
}

int main(){
	memset(sz, -1, sizeof(sz));
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++ i) fa[i] = i;
	for(int i = 1; i <= m; ++ i){
		int u, v, fu, fv;
		scanf("%d%d", &u, &v);
		fu = getfather(u);
		fv = getfather(v);
		if(fu == fv){
			rest.push_back({u, v});
		}
		else{
			vec[u].push_back(v);
			vec[v].push_back(u);
			fa[fu] = fv;
		}
	}
	
	for(int i = 1; i <= n; ++ i){
		if(!~sz[i]){
			dfs(i);
			isroot[i] = true;
		}
	}
	
	for(auto p : rest){
		int u = p.first, v = p.second;
		sz[u] ++;
		sz[v] ++;
		sz[lca(u, v)] -= 2;
	}
	
	bool ans = true;
	for(int i = 1; i <= n; ++ i){
		if(isroot[i]){
			ans &= check(i, i);
		}
	}
	
	printf(ans ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 13312
#!/usr/bin/env python3
import sys
import math
from functools import reduce

def solve(K: int):
    K += 1
    ans = []
    for i in range(1, K):
        for j in range(1, K):
            for k in range(1, K):
                ans.append(gcd(i, gcd(j, k)))
    print(sum(ans))
    return

def gcd(x: int, y: int):
    """xとyの最大公約数を求める"""
    return gcd(y, x % y) if y else x
    
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

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

int main(void){
    int n, lim_t;
    cin >> n >> lim_t;
    int c, t;
    int min_cost = 3000;
    
    for (int i=0; i<n; i++) {
        cin >> c >> t;
        if (lim_t >= t) {
            if (min_cost > c) {
                min_cost = c;
            }
        }
    }
    
    if (min_cost > 1000) {
        cout << "TLE" << endl;
    } else {
        cout << min_cost << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define LL long long
#define N 200005
using namespace std;

char str[N];
LL num[26];

int main()
{
	while(~scanf("%s",str))
	{
		int len=strlen(str);
		memset(num,0,sizeof(num));
		for(int i=0;i<len;i++)
			num[str[i]-'a']++;
		LL ans=(LL)len*(len-1)/2+1;
		for(int i=0;i<26;i++)
			ans-=num[i]*(num[i]-1)/2;
		printf("%lld\n",ans);
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i, n) cin >> t[i];
  int m;
  cin >> m;
  vector<int> p(m), x(m);
  rep(i, m) cin >> p[i] >> x[i];
  
  rep(i, m){
    ll ans = 0;
    rep(j, n){
      if(p[i] - 1 == j) ans += x[i];
      else ans += t[j];
    }
    cout << ans << endl;
  }
}

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

int main() {
    long long A, B;
    cin >> A >> B;

    //AとBの最小公倍数を求める問題
    //AとBの大小をそろえる
    if (B > A) {
        long long swap = A;
        A = B;
        B = swap;
    }

    //ユークリッドの互除法
    long long GCD; //最大公約数
    long long remainder = A % B;
    long long initialB = B;
    if (remainder == 0) cout << A << endl;
    else {
        while (true) {
            long long swap = 0;
            swap = remainder;
            if (B % remainder == 0) {
                GCD = remainder;
                break;
            }
            else {
                remainder = B % remainder;
                B = swap;
            }
        }

        long long a = A/GCD;
        long long b = initialB/GCD;
        long long LCM; 
        LCM = a*b*GCD;

        cout << LCM << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
h s, d't skp th si tll i's svedclTabCtrl
 * ABC141 E
 * ABC145 D
 * ABC147 F
 * ABC174 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll x,k,d;
cin>>x>>k>>d;
if(x<0)
{
ll h=-x/d;
if(x%d!=0)
{
h++;
}
if(h>k)
{
cout<<abs(x+k*d)<<endl;
}
else
{
k-=h;
if(k%2==0)
{
cout<<abs(x+h*d)<<endl;
}
else
{
cout<<abs(x+(h-1)*d)<<endl;
}
}
}
else
{
x=-x;
ll h=-x/d;
if(x%d!=0)
{
h++;
}
if(h>k)
{
cout<<abs(x+k*d)<<endl;
}
else
{
k-=h;
if(k%2==0)
{
cout<<abs(x+h*d)<<endl;
}
else
{
cout<<abs(x+(h-1)*d)<<endl;
}
}
}
}

/*
 *||||

 */

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

int main() {
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3912
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Queue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;



public class Main{
	
	static int posx;
	static int posy;
	static int type;
	static int diff;
	static int INF = Integer.MAX_VALUE;
	static int[][] d;
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}



	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}


	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}


	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}


	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	 String s=sc.next();
	 
	 /*
	 while(s.contains("dreameraser")) {
	    
	    s=s.replace("dreameraser", "");
	 }*/
	 
	 
	 
	 while(s.contains("eraser")) {
		 s=s.replace("eraser","");
	 }
	 
	 while(s.contains("erase")) {
		 s=s.replace("erase","");
	 }
	 
	 while(s.contains("dreamer")) {
		 s=s.replace("dreamer", "");
	 }
	 
	 
	 
	
	 
	 while(s.contains("dream")) {
		 s=s.replace("dream", "");
	 }
	 
	 if(s.length()==0) {
		 System.out.println("YES");
	 }else {
		 System.out.println("NO");
	 }
	 
   
	 
	 
 }
	


}


Measured memory_bytes: 28836
function main() {
  var
  i, j, flag,
  primes = [2,3,5,7,11,13,17];
  for(i = 19;i < 80000; i += 2) {
    flag = true;
    for(j = 0; primes[j] < i*i; j++) {
      if(i % primes[j] == 0) {
        flag = false;
        break;
      }
    }
    if(flag) {
      primes.push(i);
    }
  }
  input.forEach(function(line) {
    if(line.trim() === '') return;
    var
    i,
    n = parseInt(line, 10);
    for(i = 0; n > primes[i]; i++) ;
    console.log('%d %d', primes[i-1], primes[i] === n ? primes[i+1] : primes[i]);
  });
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  
  vector<int> va(n);
  for (auto &a : va) {
  	cin >> a;
  }
  
  int ans = 0;
  for (auto &a : va) {
    while (a != 0 && a % 2== 0) {
      a /= 2;
      ans++;
    }
  }
  
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3664
def main():
    x = int(input())

    max_onigiri = x // 100
    mod100 = x % 100
    onigiri = mod100 // 5
    if mod100 % 5 != 0:
        onigiri += 1
    print(1 if onigiri <= max_onigiri else 0)


if __name__ == '__main__':
    main()


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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    vector<char> vec(N);
    vector<char> vec_rev(N);
    for (int i=0; i<N; i++) {
        vec[i] = S[i];
        vec_rev[N-1-i] = S[i];
    }

    int count = 0;
    if (N%2 == 0) {
        for (int i=0; i<N/2; i++) {
            if (vec[i]!=vec_rev[i]) {
                count++;
            }
        }
    }
    else {
        for (int i=0; i<N/2; i++) {
            if (vec[i]!=vec_rev[i]) {
                count++;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1LL << 30;

int main(void){
    string S,T; cin >> S >> T;
    
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i]) ans++;
    }
    
    cout << ans << "\n";
}


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

public class ABC {
    private static void Main(string[] args) {
        var n = ReadInt();
        if (n < 3) { Console.WriteLine("0"); return; }
        var l = ReadIntsAsArrayAsc();

        var count = 0;
        for (var i = 0; i < n - 2; i++) {
            for (var j = i + 1; j < n - 1; j++) {
                for (var k = j + 1; k < n; k++) {
                    if ((l[i] + l[j] > l[k]) && (l[i] != l[j]) && (l[j] != l[k]) && (l[i] != l[k])) {
                        count++;
                    }
                }
            }
        }
        Console.WriteLine(count);
    }

    private static int ReadInt() => int.Parse(Console.ReadLine().Trim());
    private static int[] ReadIntsAsArrayAsc() => Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
}

Measured memory_bytes: 28508
N=int(input())
A=[0]*10100
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      key=x**2+y**2+z**2+x*y+y*z+z*x
      if key<=10000:
        A[key-1]+=1
for i in range(N):
  print(A[i])

Measured memory_bytes: 9380
#include <cstdio>
#include <cstring>
using namespace std;
int length,flag;
char oID[10],nID[11];
int main ()
{
	scanf("%s%s",oID,nID);
	length=strlen(oID);
	for (int i=0;i<length;++i)
	{
		if (oID[i]!=nID[i])
		{
			flag=1;
			break;
		}
	}
	if (flag==0) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 1724
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <iterator>
#include <cmath>
#include <deque>
using namespace std;

int main()
{
    {
        if (fopen("input.txt", "r")) {
            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);
        }
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
    }
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (auto& c : s)
        c = (c - 'A' + n) % 26 + 'A';
    cout << s;
    return 0;
}

Measured memory_bytes: 256