akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int A[3]; std::cin >> A[0] >> A[1] >> A[2];
 
  int ans = 1e9;
  for(int i=0; i<3; i++) {
    for(int j=0; j<3; j++) {
      for(int k=0; k<3; k++) {
        if ( i == j || j == k || k == i ) continue;
        ans = std::min(ans, std::abs(A[i]-A[j])+std::abs(A[j]-A[k]));
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int a,b,k;

  cin >> a >> b >> k;

  int n = min(a,b);

  int cnt = 0;
  int ans = 0;

  for(int i = min(a,b); i > 0; i--)
  {
    if(a % i == 0 && b % i == 0)
      cnt++;
    
    if(cnt == k)
    {
      ans = i;
      break;
    }
  }

  cout << ans;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
k = gets.to_i

len = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

p len[k-1]

Measured memory_bytes: 1788
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n,a,b = I()

if (n == 1) and (a == b):
    print(1)
    sys.exit()

if (n == 1) or (a > b):
    print(0)
    sys.exit()

if (n == 2) or (a == b):
    print(1)
    sys.exit()

print((n-2)*(b-a)+1)




"""
n = k()
s = v()

def check(n):
    if 

#コマンドの種類
comand = ["A","B","X","Y"]
p = list(itertools.permutations(comand,2))
for i in range(len(p)):
    p[i] = "".join(p[i])

for i in 
"""

Measured memory_bytes: 10340
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n, t, a = 90;
	char c;
	double x = 0.0, y = 0.0;
	while (cin >> n >> c >> t, n || t)
	{
		x += n * cos((double)a*3.14159265/180);
		y += n * sin((double)a*3.14159265/180);
		a -= t;
	}
	cout << (int)x << endl << (int)y << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
char s[100010];
int main(void)
{
     int n,m,k;
     scanf("%s",s);
     for(int i=0;i<strlen(s);i++)
     {
          if(i%2==0)
               printf("%c",s[i]);
     }
     printf("\n");
     return 0;
}


Measured memory_bytes: 384
import Control.Applicative
import Data.List
main = do
  numbers <- (map read . words) <$> getLine
  let sortedNumbers = quickSort numbers :: [Int]
  putStrLn $ intercalate " " $ map show sortedNumbers

quickSort [] = []
quickSort (n:xs) = quickSort lt ++ [n] ++ quickSort gteq
  where
    lt = [x | x <- xs, x < n]
    gteq = [x | x <- xs, x >= n]

Measured memory_bytes: 3552
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void solve() {
  vector<int> v;
  int n;
  cin >> n;
  v.resize(n+1);
  for(int i = 0; i < v.size(); i++) cin >> v[i];
  sort(v.begin(), v.end());
  int ret = 0;
  for(int i = 1; i < v.size(); i++) {
    ret = __gcd(ret, v[i] - v[i-1]);
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
int bin[7];

void decToBinary(int num) {
    fill(bin, bin+7, 0);
    int i = 6;
    while (num > 0) {
        bin[i] = num % 2;
        num /= 2;
        i--;
    }
    for (i = 0; i < 7; i++) printf("%d", bin[i]);
    printf("\n");
}


int main()
{
    int nums[10] = {63, 6, 91, 79, 102, 109, 125, 39, 127, 111};
    int n, curr, prev, change;
    for (; ;) {
        scanf("%d", &n);
        if (n == -1) break;
        scanf("%d", &prev);
        decToBinary(nums[prev]);
        for (int i = 1; i < n; i++) {
            scanf("%d", &curr);
            change = nums[prev] ^ nums[curr];
            decToBinary(change);
            prev = curr;
        }
    }
    return 0;
}



Measured memory_bytes: 2696
#include <stdio.h>

int main(void){

  int a,b,c,d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  while (1) {
    c -= b;
    if (c <= 0) {
      printf("Yes\n");
      break;
    }
    a -= d;
    if (a <= 0) {
      printf("No\n");
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    if(n < 1200) cout << "ABC" << endl;
    else if(n < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    
    int x, i;


    for(i=1; i<=10000; i++){
        scanf("%d", &x);
        if(x==0)
            break;
        else  
            printf("Case %d: %d\n", i, x);
    }
    
    return 0;
    
}
        


Measured memory_bytes: 2024
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 2e5+7;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
//ll cnm[maxn][maxn];
//void getCnm(){
//    cnm[0][0] = 1;
//    for(int i = 1;i < maxn;i++){
//        for(int j = 0;j <= i;j++){
//            cnm[i][j] = cnm[i-1][j];
//            if(j)cnm[i][j] += cnm[i-1][j-1];
//            cnm[i][j] %= (modn-1);
//        }
//    }
//}
//ll f[maxn],invF[maxn];
//void getF(){
//    f[0] = invF[0] = 1;
//    for(int i = 1;i < maxn;i++)f[i] = f[i-1]*i % modn;
//    invF[maxn-1] = qpow(f[maxn-1],modn-2);
//    for(int i = maxn-2;i >= 1;i--)invF[i] = invF[i+1]*(i+1) % modn;
//}
ll a[maxn];
int main(){
    int n;
    scanf("%d",&n);
    ll big = 0,small = 1e18;
    for(int i = 1;i <= n;i++)scanf("%lld",&a[i]),big = max(big,a[i]),small = min(small,a[i]);
    printf("%lld\n",big-small);
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  int L = S.size();
  string res = "AC";
  if (S[0] != 'A') res = "WA";
  int cnt = 0;
  for (int i = 1; i < L; ++i) {
    if (isupper(S[i])) {
      if (i == 1 || i == L - 1 || S[i] != 'C') res = "WA";
      cnt++;
    }
  }
  if (cnt != 1) res = "WA";
  cout << res << endl;
}

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

int main(){
    while(true){
        int a,b;
        string op;
        int ans;
        cin >> a >> op >> b;

        if(op=="?") break;
        else if (op=="+") ans=a+b;
        else if(op=="-") ans=a-b;
        else if(op=="/") ans=a/b;
        else ans=a*b;
        
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
import sys
input = sys.stdin.readline

m, d = map(int, input().split())
ans = 0
for i in range(1, m + 1):
	for j in range(1, d + 1):
		d1 = j // 10
		d2 = j % 10
		if d1 * d2 == i and d1 >= 2 and d2 >= 2:
			#print(d1, d2)
			ans += 1
print(ans)

Measured memory_bytes: 38896
import sys
import heapq
import bisect
import itertools

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def LI_(): return([int(x)-1 for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    N = I()
    A = IR(N)

    i = 0
    odd_start = [A[i] for i in range(0,N,2)]
    A.sort()
    even_end = [A[i] for i in range(1,N,2)]

    count_list = odd_start + even_end
    count_list.sort()

    ans = 0

    for i in range(len(count_list)-1):
        if count_list[i] == count_list[i+1]:
            ans += 1
    return(ans)
    

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 47964
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const double EPS = 1E-10;

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


int dfs(int v, std::vector<std::vector<int>>& G, std::vector<int>& d){
    int ret(v), a;
    for(int u: G[v]){
        if(d[u] != INF) continue;
        d[u] = d[v] + 1;
        a = dfs(u, G, d);
        if(d[a] > d[ret]) ret = a;
    }
    return ret;
}


int main(){
    int N; std::cin >> N;
    std::string s;
    //cnt0: B...A, cnt1 B..., cnt ...A
    int cnt0(0), cnt1(0), cnt2(0);
    int ans(0);
    for(int a(0); a < N; ++a){
        std::cin >> s;
        int n(s.length());
        for(int i(0), i_len(n-1); i < i_len; ++i){
            if(s[i] == 'A' && s[i+1] == 'B') ++ans;
        }
        if(s[0] == 'B'){
            if(s[n-1] == 'A') ++cnt0;
            else ++cnt1;
        }else if(s[n-1] == 'A') ++cnt2;
    }
    ans += std::min(cnt1, cnt2);
    if(cnt0){
        ans += cnt0;
        if(!(cnt1 + cnt2)) --ans;
    }
    std::cout << ans << std::endl;
    return 0;
}


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


bool inside(int i, int j, int h, int w) {
	return (i >= 0 && i < h && j >= 0 && j < w);
	}

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
	int n;
	cin>>n;
	int count4 = 0, countEven = 0;
	vector<int> arr(n);
	for(int i = 0; i < n; i++) {
		cin>>arr[i];
		if(arr[i] % 4 == 0)
			count4++;
		else if(arr[i] % 2 == 0)
			countEven++;
	}
	int sum = count4 + countEven/2;
	if(sum >= n/2)
		cout<<"Yes";
	else 
		cout<<"No";

	return 0;		
}


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

deque<int> Era(int n) {
    deque<int> arr(n+1,1);
    deque<int> prime;
    arr[0]=0;
    arr[1]=1;
    for (int i=2;i*i<n;i++) {
        if (arr[i]==1) {
            for (int j=i*i;j<n;j+=i) {
                arr[j]=0;
            }
        }
    }
    for (int k=2;k<=n;k++) {
        if (arr[k]==1) {
            prime.emplace_back(k);
        }
    }
    return prime;
}


int main(void){
    std::deque<int> prime=Era(60000);
    int ans[50001]={0};
    int size=prime.size();
    for (int i=0;i<size;i++) {
        for (int j=i;j<size;j++) {
            if (prime[i]+prime[j]>50000) {
                continue;
            }
            ans[prime[i]+prime[j]]++;
        }
    }
    int n;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            cout<<ans[n]<<endl;
        }
    }
}



Measured memory_bytes: 3404
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;
signed main() {
  int N;
  while (cin >> N, N) {
    char last = ' ';
    int ans = 0;
    for (int i = 0; i < N; i++) {
      string s; cin >> s;
      if (last == s[1]) {
        ans++;
      } else {
        last = s[1];
      }
    }
    cout << ans << endl;
  }
}




Measured memory_bytes: 3120
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    int d = 110;
    while (k--) {
        --d;
        while (a % d || b % d)
            --d;
    }

    cout << d << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

void minDist(const vector<string>& plane, char wall, int y0, int x0, vector<vector<int> >& dist)
{
    int dy[] = {0, 0, -1, 1};
    int dx[] = {-1, 1, 0, 0};

    int h = plane.size();
    int w = plane[0].size();
    dist.assign(h, vector<int>(w, -1));

    queue<pair<int, int> > q;
    q.push(make_pair(y0, x0));
    dist[y0][x0] = 0;
    int n = 1;
    while(!q.empty()){
        queue<pair<int, int> > q1;
        while(!q.empty()){
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            for(int i=0; i<4; ++i){
                int y1 = y + dy[i];
                int x1 = x + dx[i];
                if(0 <= y1 && y1 < h && 0 <= x1 && x1 < w && plane[y1][x1] != wall && dist[y1][x1] == -1){
                    q1.push(make_pair(y1, x1));
                    dist[y1][x1] = n;
                }
            }
        }
        ++ n;
        q = q1;
    }
}

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

    int sy, sx;
    vector<string> t(h, string(w, ' '));
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            cin >> t[y][x];
            if(t[y][x] == 'D'){
                sy = y;
                sx = x;
            }
        }
    }
    vector<vector<int> > dist;
    minDist(t, '#', sy, sx, dist);

    vector<int> r(d+2);
    for(int i=1; i<=d; ++i)
        cin >> r[i];
    r[0] = -1;
    r[d+1] = INT_MAX;

    vector<int> ax(n), ay(n), s(n);
    for(int i=0; i<n; ++i)
        cin >> ax[i] >> ay[i] >> s[i];

    bool ok = false;
    bool ng = false;
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            if(t[y][x] == '#')
                continue;

            bool isTreasure = true;
            for(int i=0; i<n; ++i){
                int squareSize = max(abs(y - ay[i]), abs(x - ax[i]));
                if(!(r[s[i]] < squareSize && squareSize <= r[s[i]+1]))
                    isTreasure = false;
            }
            if(isTreasure){
                if(dist[y][x] != -1)
                    ok = true;
                else
                    ng = true;
            }
        }
    }

    if(ok){
        if(ng)
            cout << "Unknown" << endl;
        else
            cout << "Yes" << endl;
    }
    else{
        if(ng)
            cout << "No" << endl;
        else
            cout << "Broken" << endl;
    }

    return 0;
}

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

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

	if(N==0){
		break;
	}

	int cnt0=0;
	int cnt1=0;

	for(int i=0;i<N;i++){
		int k;
		cin>>k;

		if(k==0){
			cnt0++;
		}
		else if(k==1){
			cnt1++;
		}
 	}

	if(cnt0+cnt1==N){
		cout<<"NA"<<endl;
	}
	else{
		cout<<N-cnt0+1<<endl;
	}
 }
return 0;
}

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

struct Unionfind{
    vector<int> data;
    Unionfind(int size):data(size, -1) {}
    bool unite(int x, int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x!=y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return (data[x] < 0) ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,m; cin >> n >> m;
    vector<int> a(m),b(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    if(m%2!=0){
        cout << -1 << endl;
        return 0;
    }
    vector<int> Tr[n];
    vector<int> deg(n,0);
    Unionfind uni(n);
    vector<P> ans;
    rep(i,m){
        if(uni.same(a[i],b[i])){
            //a[i]->b[i];
            ans.pb({a[i],b[i]});
            deg[a[i]]++;
        }else{
            uni.unite(a[i],b[i]);
            Tr[a[i]].pb(b[i]);
            Tr[b[i]].pb(a[i]);
        }
    }
    queue<int> q;
    vector<bool> vis(n,false);
    vector<int> dep(n,0);
    //
    int mxm=0;
    q.push(0);
    vis[0]=true;
    while(q.size()){
        int fr=q.front(); q.pop();
        for(int u:Tr[fr]){
            if(vis[u]) continue;
            q.push(u); vis[u]=true;
            dep[u]=dep[fr]+1;
            chmax(mxm,dep[u]);
        }
    }
    //
    vector<int> dp[mxm+1];
    rep(i,n){
        dp[dep[i]].pb(i);
    }
    for(int i=mxm;i>=0;i--){
        for(int u:dp[i]){
            for(int v:Tr[u]){
                if(dep[u]<dep[v])continue;
                if(deg[u]%2==1){
                    deg[u]++;
                    ans.pb({u,v});
                }else{
                    deg[v]++;
                    ans.pb({v,u});
                }
            }
        }
    }
    rep(i,n){
        if(deg[i]%2==1){
            cout << -1 << endl;
            return 0;
        }
    }
    for(P res:ans){
        cout << res.fi+1 << " " << res.se+1 << endl;
    }
}



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

int main(){
    int n;
    cin >> n;
    vector<int> v(n),c(n),a(n,0);
    for(int i=0;i<n;i++)
    {
        cin >> v[i];
    }
    for(int i=0;i<n;i++)
    {
        cin >> c[i];
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(v[i]>c[i])
        {
            a[i]=v[i]-c[i];
        }
        ans+=a[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double x = sc.nextDouble(); 
 
        double v = a * a * b;
        double theta = 0.0;
        double rad = 0.0;
        if(x <= v / 2){
            rad = Math.atan((a * b*b) / (2 * x));
            theta = Math.toDegrees(rad);
        }
        if(x > v / 2){
            rad = Math.atan((2*v - 2*x) / (a*a*a));
            theta = Math.toDegrees(rad);
        }

        System.out.println(theta);
    }
}

Measured memory_bytes: 24532
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::num::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn is_prime(x:usize) -> bool{
    let mut prime = true;
    for i in 2..(x as f64).sqrt()as usize + 1{
       if x % i == 0{
           prime = false;
           break;
       }
    }
    prime
}
fn main(){
    let mut x:usize = read();
    let mut flag = false;
    while flag == false{
        flag = is_prime(x);
        if !flag {
            x += 1;
        }
    }
println!("{}",x);
}

Measured memory_bytes: 2144
x1, y1, x2, y2 = map(int, input().split())
X2=x2-x1
Y2=y2-y1
x3=X2-Y2+x1
y3=X2+Y2+y1
x4=-Y2+x1
y4=X2+y1
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N;
  ll numR, numG, numB;
  cin >> N;
  string S;
  cin >> S;
  ll ans = 0;
  numR = numG = numB = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'R') {
      ++numR;
    } else if (S[i] == 'G') {
      ++numG;
    } else {
      ++numB;
    }
  }
  ans = numR * numG * numB;
  for (int i = 0; i < N-2; ++i) {
    for (int j = i+1; j < N-1; ++j) {
      int k = i + 2 * (j-i);
      // printf("%d %d %d\n", i, j, k);
      if (k >= N) {
        break;
      }
      // printf("%d %d %d\n", i, j, k);
      /*
      if (S[i] == S[j]) {
        continue;
      }*/
      if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
        --ans;
        // printf("%d %d %d\n", i, j, k);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int main(){
	string s;
	cin>>s;
	ll cnt[26]={};
	for(char c:s) cnt[c-'a']++;
	ll ans = 1;
	rep(i,26) rep(j,i) ans += cnt[i]*cnt[j];
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

int main(){
  char C;
  cin >> C;
  cout<< char(C+1) <<endl;
}


Measured memory_bytes: 256
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  k <- getl toInt
  solve n <$> replicateM k (getl $ wrds toInt) >>= mapM_ print

solve :: Int -> [[Int]] -> [Int]
solve n = map f
  where
    f [x,y] = g (x-1) (y-1)
    g x y
      | x + y > n - 1 = g (n - y - 1) (n - x - 1)
      | x - y < 0 = g y x
      | otherwise = y `mod` 3 + 1

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    REP(i, k) {
        if (a >= b) b *= 2;
        else if (b >= c) c *= 2;
        else c *= 2;
    }
    if (a < b and b < c) cout << "Yes" << endl; else cout << "No" << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    map<ll, ll> ac;
    REP(i, n) {
        ll a; cin >> a;
        ac[a]++;
    }
    ll maxa = (*(--ac.end())).first;
    if ((maxa % 2 == 1 && ac[(maxa+1)/2] != 2) || (maxa % 2 == 0 && ac[maxa/2] != 1)) cout << "Impossible\n";
    else {
        ll prev = -1;
        for (P<ll, ll> acc: ac) {
            if ((maxa%2==0 && acc.first < maxa/2) || (maxa%2==1 && acc.first < (maxa+1)/2)) {
                cout << "Impossible\n"; return 0;
            }
            if (prev == -1) {
                prev = acc.first;
                continue;
            }
            if (acc.first != prev+1 || acc.second < 2) {
                cout << "Impossible\n"; return 0;
            }
            prev = acc.first;
        }
        cout << "Possible\n";
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int n, m, k;
  cin >> n >> m >> k;
  REP(i, n+1) {
    REP(j, m+1) {
      // cout << i << " " << j << " " << i*m << " " << j*n << " " << i*j << " " << i*m + j*n - i*j << endl;
      if(i*m + j*n - i*j*2 == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    // cout << endl;
  }
  cout << "No" << endl;

  return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
#define PI (acos(-1))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

#define MAXN 1123456
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
typedef vector<vi> vvi;

// Either globally or in a single class:
static char buf[450 << 20];
void* operator new(size_t s) {
	static size_t i = sizeof buf;
	assert(s < i);
	return (void*)&buf[i -= s];
}
void operator delete(void*) {}

struct Tree {
	typedef int T;
	static constexpr T unit = INT_MIN;
	T f(T a, T b) { return max(a, b); } // (any associative fn)
	vector<T> s; int n;
	Tree(int n = 0, T def = unit) : s(2*n, def), n(n) {}
	void update(int pos, T val) {
		for (s[pos += n] = val; pos /= 2;)
			s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
	}
	T query(int b, int e) { // query [b, e)
		T ra = unit, rb = unit;
		for (b += n, e += n; b < e; b /= 2, e /= 2) {
			if (b % 2) ra = f(ra, s[b++]);
			if (e % 2) rb = f(s[--e], rb);
		}
		return f(ra, rb);
	}
};

ll n, k;

bool stay(vi &a) {
  for (int i = 0; i + k <= sz(a); ++i) {
    bool sorted = true;
    for (int j = i+1; j < i+k; ++j) {
      //cerr << j <<" ";
      if (a[j] < a[j-1]) {
        sorted=false;
        i=j-1;
        break;
      }
    }
    //cerr<<endl;
    if(sorted) return true;
  }
  return false;
}

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

  cin >> n >> k;
  vi a(n);
  rep(i,0,n) cin >> a[i];

  int extra = stay(a);
  int extra1=0;
  rep(i,1,k-1) {
    if (a[i]<a[i-1])extra1=1;
  }
  ll ans = extra+extra1;

  vi inv(n);
  rep(i,1,n) inv[i] = inv[i-1] + (a[i] < a[i-1]);

  Tree tr(n), mintr(n);
  rep(i,0,n) tr.update(i, a[i]);
  rep(i,0,n) mintr.update(i, -a[i]);

  rep(i, k-1, n) {
    if (i==k-1 && extra1) continue;
    int mx = tr.query(i-k+1, i);
    int mn = -mintr.query(i-k+1, i);
    if (mx > a[i] || (i>=k && a[i-k] > mn && (!extra || inv[i]-inv[i-k+1]))) ++ans;
    //cerr << i << " " << ans << endl;
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 8448
#include<iostream>
#include<string>
int main() {
	int a,b,c,d;
 
	std::cin >> a>>b>>c>>d;
 
	if ((a + b) == (c + d)) {
		std::cout << "Balanced" << std::endl;
	}
	else {
		if (a + b > c + d) {
			std::cout << "Left" << std::endl;
		}
		else {
			std::cout << "Right" << std::endl;
		}
	}
	
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    REP(i,N){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    static int n;
    static int[] A;
    static boolean res;
    public static void main(String[] args){
        Scanner a = new Scanner(System.in);
        n = a.nextInt();
        A = new int[n];
        for(int i=0; i<n; i++){
            A[i] = a.nextInt();
        }
        int q = a.nextInt();
        int[] m = new int[q];
        for(int i=0; i<q; i++){
            m[i] = a.nextInt();
        }
        for(int i=0; i<q; i++){
            boolean x = sub(0,m[i]);
            if(x){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
    }
    public static boolean sub(int i, int m){
        if(m == 0){
            return true;
        }
        if(i >= n){
            return false;
        }
        res = sub(i+1, m) || sub(i+1, m-A[i]);
        return res;
    }
}


Measured memory_bytes: 26844
/*input
3 10
1 4
4 1
2 5
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    let ticket: [i32; 4] = [6000, 4000, 3000, 2000];
    let mut v: Vec<i32>;
    for _ in 0..4 {
        v = read_line()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        println!("{}", ticket[(v[0] - 1) as usize] * v[1]);
    }
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin>>n;
	string s; cin>>s;
	vector<char> v;
	for(int i=0;i<s.length();++i)
	{
		int x=s[i]-'A';
		x=(x+n)%26;
		char c=(char)(65+x);
		v.push_back(c);
	}
	for(int i=0;i<v.size();++i)cout<<v[i];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<unistd.h>
#define PI 3.14159265359


using namespace std;
int main()
{

    int W,H;
    while(1){
        cin >> H >> W;

        if(H==0 && W==0) break;
        
        for(int i=0; i<H;i++){
            if(i==0 || i == H-1){
                for(int j=0;j<W;j++){
                    cout << "#";
                }
            }
            else{
                for(int j=0;j<W;j++){
                    if(j==0 || j == W-1) cout << "#";
                    else cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;

    }

    return 0;
}



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

int main() {

  int H,W;
  cin >> H >> W;
  vector<int> num(26);
  for(int i = 0;i < H;i++) {
    for(int j = 0;j < W;j++) {
      char ch;
      cin >> ch;
      num.at(ch-'a')++;
    }
  }

  bool exist_odd = false;
  for(int i = 0;i < 26;i++) {
    if(exist_odd && num.at(i)%2 != 0) {
      cout << "No" << endl;
      return 0;
    }
    if(num.at(i)% 2 != 0) exist_odd = true;
  }
  
  int sum = 0;
    for(int i = 0;i < 26;i++) {
      sum += num.at(i) / 4;
  }

  if(H%2 == 0 && W%2 == 0) {
    for(int i = 0;i < 26;i++) {
      if(num.at(i)%4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }else if(H % 2 == 0 && W % 2 != 0) {
    if(sum*4 < H*(W-1) || exist_odd) cout << "No" << endl;
    else cout << "Yes" << endl;
  }else if(H % 2 != 0 && W % 2 == 0) {
    if(sum*4 < W*(H-1) || exist_odd) cout << "No" << endl;
    else cout << "Yes" << endl;
  }else{
    if(sum*4 < (H-1)*(W-1)) cout << "No" << endl;
    else cout << "Yes" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int a, b, c, ans;
  scanf("%lld %lld %lld", &a, &b, &c);

  if(a*c <= b){
    ans = c;
  }else{
    ans = b/a;
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
  int n,m; cin >> n >> m;
  double sum = 0;
  vector<double> a(n);
  rep(i,n) {cin >> a.at(i); sum+=a.at(i);}

  double flg =  sum / (4*m);  // 以下はダメ
  rep(i,n){
    if(a.at(i) >= flg) m--;
  }
  if(m<=0) printf("Yes");
  else printf("No");
}

Measured memory_bytes: 256
import java.util.Scanner;

//https://onlinejudge.u-aizu.ac.jp/problems/1147
public class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	while (true) {

	  int n = sc.nextInt();
	  if (n == 0) {
		break;
	  }
	  int min = 1001, max = 0, sum = 0;
	  for (int i = 0; i < n; i++) {
		int s = sc.nextInt();
		if (min > s) {
		  min = s;
		}
		if (max < s) {
		  max = s;
		}
		sum += s;
	  }
	  System.out.println((sum - max - min) / (n - 2));
	}
  }
}


Measured memory_bytes: 29104
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
 
using namespace std;
typedef long long LL;
 
 
int main() {
 
	string a,b,c;
	
	cin >> a >> b;
 
	for (int i=0; i < a.size(); i++) {
		c += a.substr(i, 1);
		c += b.substr(i, 1);
	}
 
	cout << c;
	
	//int abc;
	//cin >> abc ;
}

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

int main(){
  long long N,P;
  cin >> N >> P;
  if (N==1){
    cout << P << endl;
    return 0;
  }
  long long ans=1;
  for (long long i=2;pow(i,N)<=P;i++){
    long long cnt=0;
    while(P%i==0){
      P=P/i;
      cnt++;
    }
    ans*=pow(i,cnt/N);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
string ans3[3]={
"aa.",
"..a",
"..a"};
string ans4[4]={
"agbb",
"agcc",
"ddfh",
"eefh"};
string ans5[5]={
"bbccb",
"caa.b",
"c..ac",
"b..ac",
"bccbb"
};
string ans7[7]{
"aabbc..",
"b...caa",
"b.abb..",
"cca.a..",
".b..abb",
".b...gh",
"..tt.gh"
};
char ans[1005][1005];
void solve(int x,int y){
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)ans[i][j]='.';
	int now=1;
	for(int i=0;i<x;i++){
		for(int a=0;a<4;a++){
			for(int b=0;b<4;b++){
				ans[now+a][now+b]=ans4[a][b];
			}
		}
		now+=4;
	}
	for(int i=0;i<y;i++){
		for(int a=0;a<5;a++){
			for(int b=0;b<5;b++){
				ans[now+a][now+b]=ans5[a][b];
			}
		}
		now+=5;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			putchar(ans[i][j]);
		}
		putchar('\n');
	}
}
int main(){
	cin>>n;
	for(int i=0;i*4<=n;i++){
		if((n-i*4)%5==0){
			solve(i,(n-i*4)/5);
			return 0;
		}
	}
	if(n==2){
		cout<<-1<<endl;
	}else if(n==3){
		for(int i=0;i<3;i++)cout<<ans3[i]<<endl;
	}else if(n==4){
		for(int i=0;i<4;i++)cout<<ans4[i]<<endl;
	}else if(n==5){
		for(int i=0;i<5;i++)cout<<ans5[i]<<endl;
	}else if(n==6){
		for(int i=0;i<6;i++){
			cout<<ans3[i%3]<<ans3[i%3]<<endl;
		}
	}else if(n==7){
		for(int i=0;i<7;i++)cout<<ans7[i]<<endl;
	}else if(n==11){
		string e4="....",e7=".......";
		for(int i=0;i<7;i++){
			cout<<ans7[i]<<e4<<endl;
		}
		for(int i=0;i<4;i++){
			cout<<e7<<ans4[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2176
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
import heapq
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 998244353
def mint(lis):
    return list(map(int, lis))

def bifind(arr_sorted, x):
    idx = bisect_left(arr_sorted, x)
    if idx == len(arr_sorted):
        return False
    if arr_sorted[idx] == x:
        return True
    else:
        return False
def getyaku(n):
    ret = []
    for i in range(1, int(math.sqrt(n) + 1)):
        if n % i == 0:
            ret.append(i)
            ret.append(n // i)

    return ret

def main():
    n, m = getList()
    ans = 0
    for yaku in getyaku(m):
        if m // yaku >= n:
            if ans < yaku:
                ans = yaku
    print(ans)

if __name__ == "__main__":
    main()



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

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

		while(true){
			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			int[] array = new int[N];
			
			for(int i = 0; i < N; i++){
				array[i] = i + 1;
			}
			
			int count = 0;
			for(int i = 2; i < N; i++){
				int sum = 0;
				for(int j = 0; j < i; j++){
					sum += array[j];
				}
				
				
				
				for(int j = 0; j < (N - i + 1); j++){
					/*
					for(int k = j; k < j + i; k++){
						System.out.print(array[k] + " ");
					}
					System.out.println();
					System.out.println(sum);
					*/
					
					if(sum >= N){
						if(sum == N){
							count++;
						}
						break;
					}
					
					sum -= array[j];
					sum += array[j + i];
				}
			}
			
			System.out.println(count);
		}
		
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  int cnt = 0;
  int ans = 100000;

  for(int i=0;i<=S.size()-T.size();i++){
    cnt = 0;
    for(int j=0;j<T.size();j++){
      if(S.at(i+j)!=T.at(j)){
        cnt ++;
      }
    }
    if(cnt <= ans){
      ans = cnt;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
const int MAX = 3;
int main(){

    ll a;
    ll b;
    ll n;

    cin >> n >> a >> b;

    ll c1;
    ll c2;
    ll c;

    if(a == 0){
        c = 0;
        cout << c << endl;
    }else{
        ll t =  n/(a + b);
        c1 = a * t;
        c2 = n % (a + b);
        if(c2 == 0LL){
            cout << c1 + c2 << endl;

        }else if(c2 <= a){
            cout << c1 + c2 << endl;

        }else if(c2 > a){
            cout << c1 + a << endl;


        }

        
    }

    return 0;
}

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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

ll to5(ll a){
	return a*a*a*a*a;
}

int main(){
	ll x;
	scanf("%lld", &x);
	set<ll> s;

	//a^5 - 1 = 10^9
	map<ll, ll> sq5;
	for(ll a = -1000; a <= 1000; a++){
		sq5[to5(a)] = a;
		s.insert(to5(a));
	}

	for(ll b = -1000; b <= 1000; b++){
		if(s.count(to5(b)+x)){
			cout << sq5[to5(b)+x] << " " << b << endl;
			return 0;
		}
	}

	return 0;
}



Measured memory_bytes: 3844