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

int main() {
  long long int N, T = 1, A = 1;
  cin >> N;
  for (long long int i = 0; i < N; i++) {
    long long int t, a;
    cin >> t >> a;
    long long int n = max((T + t - 1) / t, (A + a - 1) / a);
    T = n * t;
    A = n * a;
  }
  cout << T + A << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

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

    n += max(0ll, (m - 2 * n) / 2) / 2;
    m -= max(0ll, (m - 2 * n) / 2);

    cout << min(n, m / 2) << endl;

    return 0;
}

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

int main() {

  /*
  min → nilai terkecil dari array
  max → nilai terbesar dari array
  freqMin → berapa kali min muncul
  freqMax → berapa kali max muncul


  kalo min == max ?
    freqMin == n-1 → yes
    freqMin*2 <= → yes
    else → no

  kalo max == min+1 ?
    freqMin <= min dan max <= freqMin + freqMax/2 → yes
    else → no

  else → no
  */

  int n, num[100005];
  cin >> n;

  int mx = 0, mn = INT_MAX;
  for(int i=0; i<n; i++){
    cin >> num[i];
    mx = max(mx, num[i]);
    mn = min(mn, num[i]);
  }

  int freqMin = 0, freqMax = 0;
  for(int i=0; i<n; i++){
    if(num[i] == mx) freqMax++;
    if(num[i] == mn) freqMin++;
  }

  if(mn == mx){
    if(mn == n-1 || mn*2 <= n) cout << "Yes";
    else cout << "No";
  }
  else if(mn+1 == mx){
    if(freqMin <= mn && mx <= freqMin+freqMax/2) cout << "Yes";
    else cout << "No";
  }
  else cout << "No";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3956
import java.util.Scanner;
import java.util.Arrays;

public class Main { //HDL-style Disjoint Set
	static int N; // int_maxsize > 10000 (constrain)
	static int Q; // int_maxsize > 110000 (worstcase = 10000initial set  + 100000 new set)
	static boolean Com; //com only have two kind;
	static int V1;
	static int V2;
	static int[] S;
	static Scanner scanner;
	public static void main(String[] args){
		scanner = new Scanner(System.in);
		N = scanner.nextInt();
		N = 100000;
		S = new int[N];
		reset();
		Q = scanner.nextInt();
		FSM();
	}
	//end of main
	private static void reset(){
		Com = false;
		V1 = 0;
		V2 = 0;
		for(int i = 0; i<N; i++){
			S[i]=i;
		}
	}
	//end of reset
	private static void FSM(){
		while(Q>0){
			fetch();
			dispatch();
			Q--;
		}
	}
	//end of FSM
	private static void fetch(){
		Com = (scanner.nextInt() > 0)?true:false;
		V1 = scanner.nextInt();
		V2 = scanner.nextInt();
	}
	//end of feteh
	private static void dispatch(){
		if(Com){
			same();
		}else {
			unite();
		}
	}
	//end of dispatch
	private static void unite(){
		if(S[V1] == S[V2]){
			return;
		}else{
			merge();
		}
	}
	//end of unite
	private static void same(){
		if(S[V1] == S[V2]){
			System.out.println(1);
		}else{
			System.out.println(0);
		}
	}
	//end of same
	private static void merge(){
		V1 = S[V1];// use variable 1 to store the set code of V1
		V2 = S[V2];// use variable 2 to store the set code of V2
		for(int i = 0; i< N;i++)
		{
			if(S[i] == V1){
				S[i] = V2;
			}else{
				continue;
			}
		}
	}
}	



Measured memory_bytes: 101076
#include <stdio.h>
#include <string.h>

int main() {
	char day_W[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	char S[4];
	scanf("%s",S);
	int i;
	for (i = 0; i < 7; i++) {
		if (strcmp(S, &day_W[i][0]) == 0) break;
	}
	printf("%d\n", 7 - i);
	return 0;
}

Measured memory_bytes: 128
import math
a,b,c=map(float,input().split())
C=math.sin(math.radians(c))
D=math.cos(math.radians(c))

S=(1/2)*a*b*C
k=a**2+b**2-2*a*b*D
L=k**(1/2)+a+b
h=2*S/a

print('{:.8f}'.format(S))
print('{:.8f}'.format(L))
print('{:.8f}'.format(h))


Measured memory_bytes: 5700
/*
    Author : DemonStar
*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define loop(i, n) for(ll i = 0; i < n; i++)
#define pl pair<ll, ll>
#define vl vector<ll>
#define endl '\n'
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};


template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t) {
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t) {
    for (auto &i : t) os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &t : v) is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v) {
    for (pair<T1, T2> &t : v) is >> t.first >> t.second;
    return is;
}

const ll mod = 1e9 + 7;

int main()
{

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

    ll n;
    cin >> n;
    n %= 10;
    if (n == 2 or n == 4 or n == 5 or n == 7 or n == 9)
        cout << "hon" << endl;
    else if (n == 3)
        cout << "bon" << endl;
    else cout << "pon" << endl;

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif

    return 0;
}

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

int main(){
    int n,k,now=0,ans=0; cin>>n >>k;
    vector<int> spe(200000,0);
    
    for(int i=0;i<n;i++){
        int a; cin>>a;
        a--;
        spe[a]++;
    }
    
    for(int i=0;i<200000;i++)if(spe[i]>0)now++;
    
    sort(spe.begin(),spe.end());
    
    int i=0;
    while(now>k&&i<200000){
        if(spe[i]>0){
            ans+=spe[i];
            now--;
        }
        i++;
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main(){
	/*input*/
	string s;	cin >> s;
	/*calculation*/
	int n = s.size();
	vector<int>ans(n);
	for(int i = 0; i < 2; i++){
		int cnt = 0;
		for(int j = 0; j < n; j++){
			if(s[j] == 'R')cnt++;
			else{
				ans[j] += cnt/2;
				ans[j - 1] += (cnt + 1)/2;
				cnt = 0;
			}
		}
		reverse(ans.begin(), ans.end());
		reverse(s.begin(), s.end());
		for(int j = 0; j < n; j++){
			switch(s[j]){
				case 'L':
				s[j] = 'R';
				break;
				case 'R':
				s[j] = 'L';
				break;
			}
		}
	}
	/*output*/
	for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

const int N=1e5+9;

ll k,p[N];
int n,m,a[N],ans[N],tmp[N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&p[i]);
	for(int i=1;i<n;i++)
		a[i]=ans[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1,v;i<=m;i++)
	{
		scanf("%d",&v);
		swap(a[v-1],a[v]);
	}

	while(k)
	{
		if(k&1)
			for(int i=1;i<n;i++)
				ans[i]=a[ans[i]];
		for(int i=1;i<n;i++)
			tmp[i]=a[a[i]];
		for(int i=1;i<n;i++)
			a[i]=tmp[i];
		k>>=1;
	}

	ll x=p[1];
	for(int i=1;i<=n;i++)
	{
		printf("%lld.0\n",x);
		x+=p[ans[i]+1]-p[ans[i]];
	}

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() 
{

  fast();
  
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    ll n,m;
    cin >> n >> m;
    multiset<ll,greater <ll>>sets;
    ll x;
    f(i,0,n)
    {
      cin >> x;
      sets.add(x);
    }   
     multiset<ll>::iterator ms_iterator; 
    while(m)
    {
      

       
        ll q=*sets.begin();
       
        ms_iterator = sets.begin();
        sets.add(q/2);
        sets.erase(ms_iterator);
       

        
        m--;
    }
    ll s=0;
    while(sets.size())
    {
      
      
       s+=*sets.begin();
      ms_iterator = sets.begin();
      sets.erase(ms_iterator);
    }
    cout<<s;

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 4992
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int sumsum = 0;
		for(int i = 1; i <= n; i++){
			String num = Integer.toString(i);

			int sum = 0;
			for(int j = 0; j < num.length(); j++){
				sum += num.charAt(j) - '0';
			}

			if(sum >= a && sum <= b){
				sumsum += i;
			}
		}
		System.out.println(sumsum);

	}
}


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

const ll INF = 1e18;

map<long long, int> prime_factor(long long n){
    map< long long, int> ret;

    for(long long i = 2; i * i <= n; i++){
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }

    if( n != 1) ret[n] = 1;
    return ret;
}

int main(){
    ll A, B; cin >> A >> B;
    map<ll,int> MP = prime_factor(__gcd(A, B));

    int cnt = 1;
    for(auto e: MP){
        cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

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

void solve() {
    int n,m;
    cin >> n >> m;
    memset(s, '.', sizeof s);
    for (int i = 1; i <= n; i++) {
        cin >> (s[i]+1);
    }
    bool valid = true;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i][j]=='.') continue;
            bool adj = false;
            for (int k = 0; k < 4; k++) {
                adj |= s[i+dx[k]][j+dy[k]] == '#';
            }
            valid &= adj;
        }
    }
    cout << (valid? "Yes":"No");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
double xa,xb,xc,xd,ya,yb,yc,yd,ta,tb,tc,td;
int main(){
	int i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd;
		ta = xa - xb;
		tb = ya - yb;
		tc = xc - xd;
		td = yc - yd;
		if(tc/td == ta/tb) cout << "YES" << endl;
		else if(ta == -tc && tb == -td) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    N = int(input())
    l = [[0] * 10 for _ in range(10)]
    for i in range(1,N + 1):
        i = str(i)
        t = i[0]
        b = i[-1]
        if t == 0 or b == 0:
            continue
        l[int(t)][int(b)] += 1
    r = 0
    for i in range(1, 10):
        for j in range(1, 10):
            r += l[i][j] * l[j][i]
    return r

print(main())


Measured memory_bytes: 40460
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int solve(string &in){
  int ret=0;
  rep(i,in.size()/2){
    char a=in[i],b=in[in.size()-1-i];
    if (isalpha(a) || isalpha(b)){
      if (a!=b)ret++;
    }else if (a=='(' && b==')' || a==')' && b == '(');
    else ret++;
  }
  if (in.size()%2 == 1 && !isalpha(in[in.size()/2] ))ret++;
  return ret;
}

main(){
  string in;
  while(getline(cin,in)){
    cout << solve(in) << endl;
  }
  return false;
}

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

int main() {
	string S;
	cin >> S;
	int memo = 0;
	int r = (S.size() + 1) / 2;
	int l = r - 1;
	char c = S[l];
	if (1 == S.size() % 2) {
		memo++;
		l--;
	}

	while ((c == S[r]) && (c == S[l])) {
		memo += 2;
		l--;
		r++;
		if (l < 0) {
			break;
		}
	}
	cout << (S.size() + memo) / 2 << endl;
	return 0;
}

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

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

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

  if("ABC" == s) cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=2e5+10;
char ch[M];
int dp[M][2],fr[M][2];
void dg(int x,int o){
	if (!x) return;
	dg(x-1,fr[x][o]);
	cout<<(o ? 'P' : 'D');
}
int n;
int main(){
	scanf("%s",ch+1); 
	n=strlen(ch+1);
	dp[0][0]=0;
	dp[0][1]=-1e9;
	F(i,1,n){
		F(j,0,1) dp[i][j]=-1e9; 
		if (ch[i]=='D'){
			if (dp[i-1][1]+2>dp[i-1][0]+1) fr[i][0]=1;
			else fr[i][0]=0;
			dp[i][0]=max(dp[i-1][1]+2,dp[i-1][0]+1);
		}
		if (ch[i]=='P'){
			if (dp[i-1][1]>dp[i-1][0]) fr[i][1]=1;
			else fr[i][1]=0;
			dp[i][1]=max(dp[i-1][1],dp[i-1][0]);		
		}
		if (ch[i]=='?'){
			if (dp[i-1][1]+2>dp[i-1][0]+1) fr[i][0]=1;
			else fr[i][0]=0;
			dp[i][0]=max(dp[i-1][1]+2,dp[i-1][0]+1);
			if (dp[i-1][1]>dp[i-1][0]) fr[i][1]=1;
			else fr[i][1]=0;
			dp[i][1]=max(dp[i-1][1],dp[i-1][0]);			
		}
	}
	if (dp[n][0]>dp[n][1]) dg(n,0);
	else dg(n,1);
	return 0;
}




Measured memory_bytes: 13332
import sys
lines = [l.rstrip() for l in sys.stdin.readlines()]
n = int(lines[0])
l = [int(e) for e in lines[1].split(" ")]

min = n
c = 0
for e in l:
    if e < min:
        min = e
    if min >= e:
        c += 1

print(c)


Measured memory_bytes: 26008
#include<iostream>
#include<string.h>
using namespace std;
char str1[10005],str2[10005];
int dp[10005][10005],p[10005][10005];//p[i][j]记录转移的方法,便于回溯
int main()
{
    cin>>str1+1>>str2+1;//从1地址开始
    int maxLength = 0;
    int tip1,tip2;
    for(int i=0;i<=strlen(str1);i++)
    dp[i][0] = 0;
    for(int j=0;j<=strlen(str2);j++)
    dp[0][j] = 0;
    for(int i=1;i<=strlen(str1+1);i++)
    for(int j=1;j<=strlen(str2+1);j++)
    {
        if(str1[i] == str2[j])
        {
            p[i][j] = 1;
            dp[i][j] = dp[i-1][j-1] + 1;
            if(maxLength < dp[i][j])
            {
                maxLength = dp[i][j];//更新最长公共子串长度
                tip1 = i;//记录最大公共子串结尾序号
                tip2 = j;
            }
        }
        else
        {
            if (dp[i-1][j] >= dp[i][j-1])
            {
                p[i][j] = 2;
                dp[i][j] = dp[i-1][j];
            }
            else{
                p[i][j] = 3;
                dp[i][j] = dp[i][j-1];
            }
        }
    }
    string s="";
    while(maxLength!=0)
    {
        if(p[tip1][tip2]==1)
        { 
            s = str1[tip1] + s;
            tip1--;
            tip2--;
            maxLength--;
        }
        if(p[tip1][tip2]==2)
        { 
            tip1--;
        }
        if(p[tip1][tip2]==3)
        { 
            tip2--;
        }
    }
    cout<<s;
}

Measured memory_bytes: 238592
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long r = sc.nextInt();
            long d = sc.nextInt();
            long x = sc.nextInt();

            for (int i = 0; i < 10; i++) {
                x = r * x - d;
                System.out.println(x);
            }
        }
    }
}

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

ll extended_euclidian(ll a, ll b) {
  if(b == 1) return a-1;
  if(a == 1) return b-1;
  ll s=a, t=b, x=1, y=0, u=0, v=1, k;
  while(t) {
    k = s / t;
    s -= k * t;
    swap(s, t);
    x -= k * u;
    swap(x, u);
    y -= k * v;
    swap(y, v);
  }
  if(x>0) return a*x-1;
  else return b*y-1;
}

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

  ll n;
  cin >> n;

  if(n == 1) {
    cout << 1 << newl;
    return 0;
  }

  ll root = sqrt(n);
  vl is_prime(root+10, 1);
  is_prime[0] = 0;
  is_prime[1] = 0;

  ll N = 2*n;
  vl p, r;

  rep2(i, 2, root+10) {
    if(!is_prime[i]) continue;
    for(ll j=i; i*j<=root; j++) is_prime[i*j] = 0;

    if(N%i == 0) {
      p.push_back(i);
      r.push_back(0);
      while(N%i == 0) {
        N /= i;
        r.back()++;
      }
    }
  }

  if(N>1) {
    p.push_back(N);
    r.push_back(1);
  }

  if(n==N) {
    cout << n-1 << newl;
    return 0;
  }
  
  ll ans = 2*n-1, ps = p.size();
  vl P(ps);
  rep(i, ps) P[i] = pow(p[i], r[i]);

  rep(i, 1 << (ps-1)) {
    vb choose(ps, 0);
    rep(j, ps-1) if(i & (1 << j)) choose[j]=1;
    ll a=1, b=1;
    rep(j, ps) {
      if(choose[j]) a *= P[j];
      else b *= P[j];
    }

    chmin(ans, extended_euclidian(a, b));
  }
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 249380
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define INF 2000

int main() {
	ll n, buf, ma, mi;
	ma = 0;
	mi = INF;
	vl a;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		cin >> buf;
		a.push_back(buf);
		ma = max(ma, buf);
		mi = min(mi, buf);
	}
	cout << ma - mi << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b%a == 0)
            System.out.println(a+b);
        else
            System.out.println(b-a);

    }
}


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

using namespace std;
using ll = long long;

template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


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

    string s;
    cin>>s;

    int ans = 0;
    for (int i = 0; i < n-1; i++) {
        if(s[i]==s[i+1])ans++;
    }
    
    ans += 2*k;
    ans = min(ans, n-1);

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n;
  rd(n);
  auto a = readln.split.to!(long[]);
  {
    bool ok = true;
    foreach (i; 1 .. n)
      ok &= a[i - 1] <= a[i];
    if (ok) {
      writeln(0);
      return;
    }
  }

  import std.math : abs;

  int arg_abs_max = 0;
  foreach (i; 1 .. n) {
    if (abs(a[arg_abs_max]) < abs(a[i])) {
      arg_abs_max = i;
    }
  }
  struct T {
    int y, x;
    string toString() {
      return format("%d %d", x, y);
    }
  }

  T[] ans;
  foreach (i; 0 .. n) {
    if (i != arg_abs_max) {
      ans ~= T(i + 1, arg_abs_max + 1);
      a[i] += a[arg_abs_max];
    }
  }
  if (a[arg_abs_max] >= 0) {
    foreach (i; 1 .. n) {
      ans ~= T(i + 1, i);
      a[i] += a[i - 1];
    }
  } else {
    foreach_reverse (i; 1 .. n) {
      ans ~= T(i, i + 1);
      a[i - 1] += a[i];
    }
  }
  import std.exception : enforce;

  enforce(ans.length <= n * 2);
  foreach (i; 1 .. n)
    enforce(a[i - 1] <= a[i]);
  writeln(ans.length);
  writefln("%(%s\n%)", ans);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(k<s.length()){
    cout<<s.substr(0,k)<<"...";
  }
  else{
    cout<<s;
  }
  return 0;
}
    

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

int buka[200005];

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

  int n;cin>>n;
  for(int i=0;i<n-1;i++){
    int t;
    cin>>t;
    buka[t]++;
  }
  for(int i=1;i<=n;i++){
    cout<<buka[i]<<endl;
  }

  return 0;
}


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

int main() {
  vector<int>a(3);
  cin>>a[0]>>a[1]>>a[2];
  
  int k; cin>>k;
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  for(int i=0;i<k;i++){
    a[0]*=2;
  }
  
  int sum=0;
  
 for(int i=0;i<3;i++){
   sum+=a[i];
 }
  cout<<sum<<endl;
  
}


Measured memory_bytes: 256
#include <math.h>
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
    double a,b,c;
    cin >> a >> b >> c;
    if(pow(a,2.0)+pow(b,2.0)==pow(c,2.0)||
            pow(c,2.0)+pow(b,2.0)==pow(a,2.0)||pow(a,2.0)+pow(c,2.0)==pow(b,2.0)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    }
}

Measured memory_bytes: 1220
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;
int b,w;
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
#define N 200100
int fac[N+1];
int inv[N+1];
signed main(){
    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }
    cin >> b >> w;
    int noB = 0;
    int noW = 0;
    for(int i = 1;i <= b+w;i++){
        cout << (1-noB+noW+MOD)%MOD*inv[2]%MOD << endl;
        int lostB = 0;
        int lostW = 0;
        if(i-b >= 0){
            lostB = fac[i-1]*inv[b-1]%MOD*inv[i-b]%MOD*bitpow(inv[2],i)%MOD;
        }
        if(i-w >= 0){
            lostW = fac[i-1]*inv[w-1]%MOD*inv[i-w]%MOD*bitpow(inv[2],i)%MOD;
        }
        noB = (lostB+noB)%MOD;
        noW = (lostW+noW)%MOD;
    }
    
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://exawizards2019.contest.atcoder.jp/tasks/exawizards2019_a

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    bool flag = false;

    rep1(i,10)
        rep1(j,10)
            if (i * j == n) {
                flag = true;
            }
            
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
    
}

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;

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

int main() {
    int N;
    cin >> N;
    ll T, ans = 1;
    rep(i, N) {
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
    
    int r;

    cin >> r;

    string ans;

    if(r < 1200){
        ans = "ABC";
    }
    else if(r < 2800){
        ans = "ARC";
    }
    else{
        ans = "AGC";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}

using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  
  long long n;
  long long a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  bool flag = false;
  for(long long i=0;i<n;i++){
    if(i*c-(n-1-i)*d<=(b-a) && (b-a)<=i*d-(n-1-i)*c){
      flag = true;
      break;
    }
  }
  if(flag){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
main(){
	int a=100000,i,n; 
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
	a=a*1.05;
	a=a+999;
	a=a/1000;
	a=a*1000;	
	}
	
	printf("%d\n",a);
	
	return 0;
}

Measured memory_bytes: 592
from math import atan, pi

a, b, x = map(int, input().split())

if x <= a * a * b / 2:
  print(atan(0.5 * a * b * b / x) * 180 / pi)
  
else:
  print(atan(2 * b / a - 2 * x / a ** 3) * 180 / pi)

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

int main() {
  string s, t; cin >> s >> t;
  int sz = s.size();
  for (int i=0; i<sz; ++i) {
    bool possible = true;
    for (int j=0; j<sz; ++j) {
      if (s[(i+j)%sz] != t[j]) {
        possible = false;
        break;
      }
    }
    if (possible) {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


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 k, t;
  cin >> k >> t;
  vector<int> a(t);
  rep(i,t) cin >> a[i];
  int maxA = *max_element(a.begin(), a.end());
  int ans = max(0, maxA-1-(k-maxA));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353,INF=1e18;



int main() {
    int N,M;
    cin>>N>>M;
    vector<int> H(N);
    rep(i,N)cin>>H.at(i);
    vector<vector<int>> g(N,vector<int>(0));
    rep(i,M){
        int A,B;
        cin>>A>>B;
        --A;--B;
        g.at(A).pb(B);
        g.at(B).pb(A);
    }
    int count=0;
    rep(i,N){
        bool j=true;
        for(int x:g.at(i)){
            if(H.at(x)>=H.at(i))j=false;
        }
        if(j)count++;
    }
    cout<<count<<endl;
}


Measured memory_bytes: 8800
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	// your code goes here
	int S;
	cin>>S;
	int h=S/3600,m=(S-h*3600)/60,s=S%60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int H,W;
char c[51][51];
int dfs(int i,int j)
{
  if (i<0||i>=H||j<0||j>=W) return 0;
  if (c[i][j]=='.') return 0;
  c[i][j]='.';
  return 1+dfs(i,j+1)+dfs(i,j-1)+dfs(i+1,j)+dfs(i-1,j);
} 
int main()
{
  cin>>H>>W;
  for (int i=0;i<H;i++)
    cin>>c[i];
  for (int i=0;i<H;i++)
    for (int j=0;j<W;j++)
      if (dfs(i,j)==1)
      {
        puts("No");
        return 0;
      }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

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

	int p[N];
	int i;
    
    int tmp;
    for(i=0;i<N;i++){
    	cin >> p[i];
    }

	for(i=0;i<N;i++){
		if(p[i] != i+1){
			p[p[i]-1] = p[i];
			p[i] = i+1;
            break;
		}
	}

    int j;
    j=0;
    for(i=0;i<N;i++){
		if(p[i] != i+1){
          j=-1;
		}
    }

  if(j==-1){
    cout << "NO" << endl;
  }
  else{
  	cout << "YES" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
S=input()
N=len(S)
A=[0]*(N+1)
B=[0]*(N+1)
for i in range(N):
	if S[i]=="<":
		A[i+1]=A[i]+1
	elif S[i]==">":
		A[i+1]=0
for i in range(N):
	if S[N-i-1]==">":
		B[N-i-1]=B[N-i]+1
	elif S[N-i-1]=="<":
		B[N-i-1]=0
ans=0
for i in range(len(A)):
	ans+=(max(A[i],B[i]))
print(ans)

Measured memory_bytes: 27316
#include <iostream>

using namespace std;

int main(){
    
    int luca_count = 0;
    
    cin >> luca_count;
    
    unsigned long result = 0;
    unsigned long one_back = 1;
    unsigned long two_back = 2;
    
    unsigned long save = 0;
    
    if(luca_count == 0){
        
        result = two_back;
        
    }else if(luca_count == 1){
        
        result = one_back;
        
    }else{
     
     for(int i = 1;i < luca_count;i++){
         
         save = two_back + one_back;
         two_back = one_back;
         one_back = save;
         
     }
     
     result = save;
        
    }
    
    cout << result << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int A,B,K,i,count;
	scanf("%d %d %d",&A,&B,&K);
	
	for(count=0,i=100;;i--){
		if(A%i==0&&B%i==0) count++;
		if(count==K){
			printf("%d",i);
			return 0;
		}
	}
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define INF (1e9)

int N, M;

int main() {
    cin >> N >> M;

    vs A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vs B(N);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }

    for (int i = 0; i <= N - M; i++) {
        for (int j = 0; j <= N - M; j++) {
            bool f = true;
            for (int x = 0; x < M; x++) {
                for (int y = 0; y < M; y++) {
                    if (A[x + i][y + j] != B[x][y])
                        f = false;
                }
            }
            if (f) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#include<math.h>
#include<string.h>
#define ll long long
#define db double
#define max(a, b) a>b?a:b
#define min(a, b) a<b?a:b
#define sz 500000005


int main()
{
    char ch;
    scanf("%c", &ch);
    if(ch >= 'A' and ch <= 'Z')
        puts("A");
    else
        puts("a");
    return 0;
}


Measured memory_bytes: 1588
#include <iostream>

using namespace std;

void swap(int *a,int *b){
    int tmp = *b;
    *b = *a;
    *a = tmp;
}

int main(){
    int n;
    int ns[100];

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

    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(ns[i]<ns[j])swap(&ns[i],&ns[j]);
        }
        int init = 1;
        for(int k=0;k<n;k++){
            if(init)init =0;
            else cout << " ";
            cout << ns[k];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F1 first
#define S2 second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    int N;
    cin >> N;
    cout << ((N == 0)? 1 : 0) << endl;
    #ifdef DBG
    //PrintArr(A, N);
    #endif

    //cout.setf(ios::fixed, ios::floatfield);
    //cout.precision(4);
    //M_PI;
    //cout << "Case #" << t << ": " << N << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    //cin >> T;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(void){
  int N;
  cin >>N;
  vector<int> data(N);
  rep(i,N){
  cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  int A = 0, B = 0;
  rep(i,N){
    if(i % 2 == 0){
      A += data.at(i);
    } else {
      B += data.at(i);
    }
  }
  cout << A - B << endl;
  return 0;
}



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

int main()
{
	//?????°?????????
	string in;
	string out[100] = {};
	int kai;
	int mai;
	int count = 0;

	//?????£?????????
	while (1)
	{
		cin >> in;
		if (in == "-")
		{
			break;
		}
		cin >> kai;
		for (int i1 = 0; i1 < kai; i1++)
		{
			cin >> mai;
			for (int i2 = 0; i2 < mai; i2++)
			{
				in += in[0];
				in.erase(0,1);
			}
		}
		out[count] = in;
		count++;
	}

	//????????¨???
	for (int i3 = 0; i3 < count; i3++)
	{
		cout << out[i3] << endl;
	}
	return 0;
}

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

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

#define ll long long int
#define ull unsigned long long int
#define MAX 1000000007
#define MOD 998244353

#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST ll t;cin>>t;while(t--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define pi acos(-1.0)
vector<ll> adj[100001];
bool vis[100001];
ll power(ll a,ll b){
    ll ans=1;
    while(b){
        if(b&1) ans=ans*a;
        b/=2;
        a=a*a;
    }
    return(ans);
}
ll pre[100001];
ll level[100001];
void bfs(ll node){
    memset(level,0,sizeof level);
    level[node]=1;
    queue<ll> q;
    q.push(node);
    while(!q.empty()){
        ll p=q.front();
        q.pop();

        for(ll i=0;i<adj[p].size();i++){
            if(!vis[adj[p][i]]){
                q.push(adj[p][i]);
                pre[adj[p][i]]=p;
                level[adj[p][i]]=level[p]+1;
                vis[adj[p][i]]=true;
            }
        }
    }
}
int main(){
    IO
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(vis,false,sizeof vis);
    memset(pre,0,sizeof pre);

    bfs(1);
    for(ll i=2;i<=n;i++){
        if(!vis[i]) {cout<<"No";return(0);}
    }
    cout<<"Yes"<<"\n";
    for(ll i=2;i<=n;i++)
        cout<<pre[i]<<"\n";
    return(0);
}


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

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

int main() {
  ll a, b;
  cin >> a >> b;

  ll gcd_v = gcd(a, b);
  ll ans = 1;

  for (ll i = 2; i*i <= gcd_v; i++) {
    ll tmp = gcd_v;
    while (gcd_v % i == 0) {
      gcd_v /= i;
    }
    if (tmp > gcd_v) ans++; 
  }
  if (gcd_v > 1) ans++;

   cout << ans << endl;

  return 0;
}


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 int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<P> v;
    rep(i,n){
        int t;
        ll d;
        cin >> t >> d;
        v.emplace_back(d, t-1);
    }
    sort(v.begin(), v.end(), greater<>());
    ll sum = 0, type = 0;
    vector<int> cnt(n, 0);
    rep(i,k){
        sum += v[i].first;
        if(cnt[v[i].second]++ == 0) ++type;
    }
    ll ans = sum + type * type;
    for(int i = k, j = k-1; i < n; ++i){
        if(cnt[v[i].second] > 0) continue;
        ++cnt[v[i].second];
        sum += v[i].first;
        ++type;
        while(j >= 0){
            if(cnt[v[j].second] > 1){
                --cnt[v[j].second];
                sum -= v[j].first;
                chmax(ans, sum + type * type);
                --j;
                break;
            }
            --j;
        }
        if(j < 0) break;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

int main() {
  string S,T;cin>>S>>T;
  int N;N=S.size();
  REP(i,N) {
    if (S.substr(i)+S.substr(0,i)==T) {
      OUT("Yes");
      return 0;
    }
  }
  OUT("No");

  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
   long long x,a,b,c,d,e,j=0;
   cin >>  x;
   a=x/100;
  for(long long i=a; i > 0; i--){
    b=i/1000000;
    c=x-100*i;
    d=(i-(b*1000000))*5;
    if(c<=d){
        j=1;
        break;
    }
  }
  cout << j << endl;
}

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

int par[10010];
int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}
bool same(int x, int y) {
    return find(x) == find(y);
}
void unit(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px != py) par[py] = px;
}

struct edge {
    int s;
    int t;
    int w;
};
bool operator<(edge e1, edge e2) {return e1.w < e2.w;}
bool operator>(edge e1, edge e2) {return e1.w > e2.w;}

int main() {
    int V, E;
    cin >> V >> E;

    priority_queue<edge, vector<edge>, greater<edge>> que;
    int si, ti, wi;
    rep(i, E) {
        cin >> si >> ti >> wi;
        que.push({si, ti, wi});
    }

    rep(i, V) par[i] = i;

    int ans = 0;
    while (!que.empty()) {
        edge e = que.top();
        que.pop();
        if (!same(e.s, e.t)) {
            ans += e.w;
            unit(e.s, e.t);
        }
    }

    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 4588
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  string t="AC";
  int i,count=0,count_2=0;
  if(s.at(0)!='A'){
    t="WA";
  }
  for(i=1;i<s.size();i++){
    if(s.at(i)<='z' && s.at(i)>='a'){
      count++;
    }
  }
  for(i=2;i<s.size()-1;i++){
    if(s.at(i)=='C'){
      count_2++;
    }
  }
  if(count!=s.size()-2 || count_2!=1){
    t="WA";
  }
  cout << t;
}

Measured memory_bytes: 256
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int a[100000];
int main() {
    int i;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d",&a[i]);
    sort(a,a+N,greater<int>());

    for (i = 0; i < N; i++) {
        if (a[i] < i+1) break;
    }
    int p = i-1;
    int d1 = a[p]-(p+1);
    for (i = p+1; i < N; i++) {
        if (a[i] < p+1) break;
    }
    int d2 = i-p-1;
    if (!(d1 & 1) && !(d2 & 1)) printf("Second\n");
    else printf("First\n");

    return 0;
}



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

int dp[100005];

int main() {
  int n;
  int h[100005];
  cin >> n;
  for (int i = 1; i <= n; ++i )cin >> h[i];
  
  dp[0] = 1e9;
  for ( int i = 2; i <= n; ++i ) {
    dp[i] = min ( dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]) );
  }

  cout<<dp[n]<<"\n";
  return 0;
}

Measured memory_bytes: 4348