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

using namespace std;


int main()
{
   int N, K;
   string S;

    int count0, count1;
    bool flag0, flag1;
    vector<int>vec;
    int sum = 0, max = INT_MIN;


    flag0 = flag1 = false;

    count0 = count1 = 0;

   cin >> N >> K;
   cin >> S;
    if (S[0] != '1') {
      vec.push_back(0);
    }

    //create vec
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') {
            flag1 = true;
            if (flag1 == true) {
                count1++;
            }
            
            if (flag0)
                vec.push_back(count0);
            flag0 = false;
            
            count0 = 0;
            if (i == N-1)
                vec.push_back(count1);
        } else if (S[i] == '0') {
            flag0 = true;
            if (flag0 == true) {
                count0++;
            }
            
            if (flag1)
                vec.push_back(count1);
            flag1 = false;
            count1 = 0;
           if (i == N-1)
                vec.push_back(count0);
        }
    }
    /*
    for (auto x : vec) {
        cout << x;
    }
    cout << endl;
    */
   if ((int)vec.size() % 2 == 0) {
       vec.push_back(0);
   }
   if (((int)vec.size()-2)/2 < K) {
       cout << N << endl;
       return 0;
   }
    for (int i = 0; i+(2*K+1) <= (int)vec.size(); i += 2) {
        sum = 0;
        for (int j = i; j < i+2*K+1; j++) {
            sum += vec[j];
        }
       // cout << "Sum" << i << " " << sum << endl;
        if (sum > max) {
            max = sum;
        }
       }
   
   // cout << vec.size() << endl;
   cout << max << endl;
    return 0;   
}

Measured memory_bytes: 1020
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String s = sc.next();
      	int c = 0;
      	for(int i = 0; i < s.length(); i++){
        	if(s.charAt(i)=='1') c++;
        }
      	System.out.println(c);
    }
}

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

int main(){
  int H1 , M1 , H2 , M2 , K ;
  cin >> H1 >> M1 >> H2 >> M2 >> K ;
  int a = (H2-H1)*60+M2-M1 ;
  
  cout << a-K << endl;
}

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

public class DateSetSort
{
    //0?????\????????§??°????????????????????????????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int i = 0;
        int k;
        string[] unit_num;
        List<string> list = new List<string>(); //??\???????????????????????????????????????????????????
        int[] sort_set = new int[2];  //???????????????????????????????????????????????????
        /*---??£?¨???¨---*/

        /*[0 0]?????\????????§???????????????????????????*/
        while (true){

            list.Add((Console.ReadLine()));
            if (list[i] == "0 0"){
                break;
            }
            i++;
        }

        /*????????????????????????x??¨y??????????????¨???*/
        for (k = 0; k < i; k++) {
            /*2?????????????????????????????§??????*/
            unit_num = list[k].Split(' ');
            sort_set[0] = int.Parse(unit_num[0]);
            sort_set[1] = int.Parse(unit_num[1]);

            /*??????????????????????????????????????????*/
            Array.Sort(sort_set);

            Console.WriteLine("{0} {1}", sort_set[0], sort_set[1]);
        }
    }
}

Measured memory_bytes: 9748
from collections import Counter
n, k = map(int, input().split())
d = Counter([])
for i in range(n):
    a, b = map(int, input().split())
    d[a] += b
ans = 1
cnt = 0
while cnt < k:
    cnt += d[ans]
    ans += 1

print(ans - 1)

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

					#define pb push_back
					#define cend(s) return cout << s, 0;
					using namespace std;
					typedef long long ll;

					int main()
					{
						int a, b, c, k;
						cin >> a >> b >> c >> k;
						while(a >= b && k)
							k--, b *= 2;
						while(k)
							k--, c *= 2;
						if(a < b && b < c)
							cend("Yes")
						else cend("No");	
					}

Measured memory_bytes: 3592
n = int(input())
l = list(map(int, input().split()))
ans = 1
for i in l:
  if i == 0:
    ans = 0

for i in l:
  ans *= i
  if ans > 1e18 or ans == 0:
    break
if ans > 1e18:    
  print(-1)
else:
  print(ans)

Measured memory_bytes: 21568
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    //答えは、2^M*(1800M+100N)
    double answer =0;
    answer = Math.pow(2,M)*(1800*M+100*N);
    System.out.println((int)answer);
    
  }
  

  
}

Measured memory_bytes: 21972
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;cin>>N;
  vint a(N);
  int mia=INF,mxa=-INF;
  repeat(i,N){
    cin>>a[i];
    mia=min(mia,a[i]);
    mxa=max(mxa,a[i]);
  }
  int ans = INF;
  for(int j=mia;j<=mxa;j++){
    int sum=0;
    repeat(i,N){
      sum += (a[i]-j)*(a[i]-j);
    }
    ans = min(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <stdexcept>
#include <utility>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; i++)
#define rep1(i,h) for(int i = 0; i <= h; i++)
#define rep2(i,n,h) for(int i = n; i < h; i++)
#define rep3(l,n,h) for(int l = n; i <= h; i++)
using namespace std;



int main() {
    int n;
    cin >> n;
for (int i = 1; i < 50000 ;i++ ) {
    int j =i * 1.08;
    if ( j == n) {
        cout << i << endl;
        return 0;
    }
}
cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
/*Obada*/
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    int r , area1 , area2 , E;
    cin >> r ;

    area1 = (r*r) * 3 ;
    area2 = 3 ;

    E = area1/area2 ;

    if (r >= 1 && r <= 100 )

        cout << E ;


    return 0 ;

}


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

#define INF (1<<21)

int n,vis[10001];
vector<pair<int, int> > adj[10001];

void dijkstra(){
    int i,j,k,v;
    priority_queue<pair<int,int> > PQ;
    int d[10001];
    for( i = 0; i < n; i++ ){
        d[i] = INF;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    while(!PQ.empty()){
        pair<int,int> f = PQ.top();
        PQ.pop();
        int u = f.second;
        vis[u] = 1;
        if( d[u] < f.first*(-1) ) continue;
        for( j = 0; j < adj[u].size(); j++ ){
            v = adj[u][j].first;
            if(vis[v]) continue;
            if( d[v]>d[u]+adj[u][j].second ){
                d[v] = d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
            }
        }
    }
    for( i = 0; i < n; i++ ){
        cout << i << " " << (d[i]==INF?-1:d[i]) <<endl;
    }
}

int main(){
    int i,j,k,u,v,du,c;
    cin >> n;
    for( i = 0; i < n; i++ ){
        cin >> u >> du;
        for( j = 0; j < du; j++ ){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
}



Measured memory_bytes: 7984
#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 tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ull randlong(ull a,ull b){return uniform_int_distribution<unsigned long long>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
//ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
//ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

//ll fmul(ll a, ll b, ll mod){ll res=0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
//ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
//inline bool rabbin_miller(ll x){if(x%2==0) return false;for(int i=0;i<5;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

ll A,B,res=1;

ull fmul(ull a, ull b, ull mod){
	ull res = 0;
	while(a){
		if(a&1) res = (res+b)%mod;
		a>>=1;
		b = (b<<1)%mod;
	}
	return res;
}

ull fpow(ull b, ull exp, ull mod){
	ull res = 1;
	while(exp){
		if(exp&1) res = fmul(res,b,mod);
		b = fmul(b,b,mod);
		exp>>=1;
	}
	return res;
}

inline bool prim(ull x){
	if(x == 2 || x == 3) return true;
//	if(x%2 == 0) return false;
	for(int i=0; i<30; i++){
		ull rd = randlong(2,x-2);
		if(fpow(rd,x-1,x) != 1)
			return false;
	}
	return true;
}

//inline bool prim(ull x){
//	if(x == 2) return true;
//	ull lim = sqrt(x);
//	while(lim*lim < x) lim++;
//	while(lim*lim > x) lim--;
//	for(ull k=2; k<=lim; k++){
//		if(x%k == 0) return false;
//	}
//	return true;
//}

int main(){
	scanf("%lld %lld",&A,&B);
	ll gg = __gcd(A,B);
	ll lim = sqrt(gg);
	while(lim*lim < gg) lim++;
	while(lim*lim > gg) lim--;
	for(ll i=2; i<=lim; i++){
		if(gg%i == 0){
			if(prim(i))
				res++;
			if(i*i != gg && prim(gg/i))
				res++;
		}
	}
	if(prim(gg) && gg != 1) res++;
	printf("%lld\n",res);
}

Measured memory_bytes: 256
def nextsunday():
  S = input()
  if S == 'SUN':
    print('{}'.format(7))
  if S == 'MON':
    print('{}'.format(6))
  if S == 'TUE':
    print('{}'.format(5))
  if S == 'WED':
    print('{}'.format(4))
  if S == 'THU':
    print('{}'.format(3))
  if S == 'FRI':
    print('{}'.format(2))
  if S == 'SAT':
    print('{}'.format(1))

nextsunday()

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

using namespace std;
long long MAXN = 2*(1e5)+1;
/*
long double pi = 3.1415926536;

long long mod = 1e9+7;

bool secgreat(pair<int, int> a, pair<int, int> b){
    return a.second<b.second;
}


long long fact(long long n){
    n%=mod;
    if(n==0){
        return 1;
    }
    else if(n == 1){
        return 1;
    }
    else{
        return ((n%mod)*(fact(n-1)%mod))%mod;
    }
}

long long power(long long n, long long pow){
    n%=mod;
    long long res = 1;
    while(pow){
        if(pow%2){
            res = ((res%mod)*(n%mod))%mod;
        }
        pow/=2;
        n= ((n%mod)*(n%mod))%mod;
    }
    res%=mod;
    return res;

}

long long inversemod(long long n){
    return power(n, mod-2)%mod;
}
*/
/*
struct node{
    long long key;
    node* left;
    node* right;
};

struct node* newnode(long long item){
    struct node* temp = new struct node;
    temp->key = item;
    temp->left = NULL;
    temp->right = NULL;
    return temp;
};

struct node* insert(struct node* root, long long key){
    if(root == NULL){
        return newnode(key);
    }

    if (key<root->key){
        root->left = insert(root->left, key);
    }
    else if(key>root->key){
        root->right = insert(root->right, key);
    }
};
*/
/*
string binary(int a){
    string s;
    int x = 9;
    while(x>0){
        s.push_back(48+a%2);
        a/=2;
        x--;
    }
    reverse(s.begin(), s.end());

    return s;
}

int strtoi(string s){
    int n = s.length();
    int i;
    int sum = 0;
    for(i = 0; i<n; i++){
        sum+=pow(2, i)*s[i];
    }
    return sum;
}
*/
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int i;
    int s = 0;
    int c = 0;
    for(i = 0; i<n; i++){
        int x, y;
        cin>>x>>y;
        if(x == y){
            s++;
        }
        else{
            s = 0;
        }
        if(s >= 3){
            c = 1;
        }
    }
    if(c ==1){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

}

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


int main()
{
    long A[3][3];
    for(long i=0; i<3; i++){
        for(long j=0; j<3; j++){
            std::cin >> A[i][j];
        }
    }
    long N;
std::cin >> N;
    std::vector<long> b;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        b.push_back(temp);
    }

    long R[3][3]={};
    for(long i=0; i<N; i++){
        for(long j=0; j<3; j++){
            for(long k=0; k<3; k++){
                if(b[i]==A[j][k]){
                    R[j][k]=1;
                }
            }
        }
    }

    bool result=0;
    long score=0;
    for(long i=0; i<3; i++){
        for(long j=0; j<3; j++){
            if(R[i][j]==1){
                score++;
            }
        }
        if(score==3){
            result=1;
        }
        score=0;
    }

    for(long i=0; i<3; i++){
        for(long j=0; j<3; j++){
            if(R[j][i]==1){
                score++;
            }
        }
        if(score==3){
            result=1;
        }
        score=0;
    }

    if(R[0][0]==1 && R[1][1]==1 && R[2][2]==1){
        result=1;
    }
    if(R[2][0]==1 && R[1][1]==1 && R[0][2]==1){
        result=1;
    }
    if(result==1){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; i++)

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

int main()
{

  int K;
  cin >> K;

  int total = 0;

  for (int i = 1; i <= K; i++)
  {
    for (int j = 1; j <= K; j++)
    {
      for (int k = 1; k <= K; k++)
      {
        total += gcd(gcd(i,j), k);
      }
    }
  }

  cout << total << endl;

  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using pii = std::pair<int,int>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 1e9 + 19;
const ll INFL = 1e18 + 19;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
//_____________________　following sorce code_________________________//
int n,m,k;
string S;
vll cost(1 << 16);
int a,b,c;
int h,w;
vi v;
vll u;

bool check(){
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n);
  v = vi(n);
  rep(i,n)IN(v[i]);
  vi res;
  int lo = 1;
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  rep(i,n-1){
    if(v[i] == v[i+1]){
      res.pb(lo);
      lo = 1;
    }
    else {
      lo++;
    }
  }
  res.pb(lo);
  ll ans = 0;
  ll sum = 0;
  queue<int> q;
  for(auto c : res){
    //dump(c);
    if(sz(q) >= 3){
      sum -= q.front();q.pop();
      q.push(c);
      sum += c;
      chmax(ans, sum);
    }
    else {
      q.push(c);
      sum += c;
      ans += c;
    }
  }
  cout << ans << endl;
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 4036
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, k;
	cin >> n >> k;
	set<int> st;
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int a;
			cin >> a;
			st.insert(a);
		}
	}
	cout << n - st.size() << '\n';
}

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

int dp[100000];
int main(){
    int N,K;cin>>N>>K;
    vector<int> a(N);
    for(int i=0;i<N;i++)cin>>a.at(i);
    for(int i=1;i<N;i++){
        int minnow=1000000001;
        for(int j=1;j<=K;j++){
            if(i-j<0)continue;
            minnow=min(minnow,dp[i-j]+abs(a.at(i)-a.at(i-j)));
        }
        dp[i]=minnow;
    }
        

    cout<<dp[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  cout << A * B / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
import collections
import sys

l = collections.deque(sys.stdin.readlines())
l.pop()
s = ""
while l:
    a = 0
    b = 0
    for i in range(int(l.popleft())):
        x,y = map(int, l.popleft().split())
        if x > y:
            a = a + x + y
        elif x < y:
            b = b + x + y
        else:
            a = a+x
            b = b+y
    s += str(a) + " " + str(b) + "\n"

print(s,end="")

Measured memory_bytes: 8816
module primeMod
        implicit none
        
        contains
        function isPrime( x ) result( flag )
          implicit none
          integer(16),intent(in) :: x
          logical :: flag
          integer(16) :: n,i
          
          flag = .false.
          if(x==1) return
          if(x==2)then
            flag = .true.
            return
          end if
          
          n = int( sqrt(real(x))) + 1
          
          if( mod(x,2)==0 ) return
          do i = 3,n,2
            if( mod(x,i)==0 )then
              RETURN
            end if
          end do
          
          flag = .true.
        end function
      end module
      
      PROGRAM piyo
      use primeMod
      IMPLICIT NONE
      integer(16) :: x
      integer(16) :: counter
      
      read*,x
      counter = x
      do while( .true. )
        if( isPrime(counter) ) exit
        counter = counter + 1
      end do
      
      print*,counter
      
      
      
      END PROGRAM

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
const int MAXH = 101;
const int MAXW = 101;
const int MAXA = 11;
const int INF = 1<<28;
const int di[] = {0,1,0,-1};
const int dj[] = {1,0,-1,0};
const int P[] = {1,0,3,2};
const int Q[] = {3,2,1,0};
int H, W, A;
char G[MAXH][MAXW];
int vis[MAXH][MAXW][4][MAXA][MAXA];

struct State {
  int i, j, d, a, b;
};
 
int bfs(int si, int sj, int gi, int gj) {
  queue<State> que;
  memset(vis, 0, sizeof(vis));
  vis[si][sj][1][A][A] = true;
  que.push((State){si, sj, 1, A, A});
  while(que.size()) {
    const State s = que.front();
    que.pop();
    do {
      State t = s;
      t.i += di[t.d];
      t.j += dj[t.d];
      if(t.i < 0 || t.i >= H) break;
      if(t.j < 0 || t.j >= W) break;
      if(G[t.i][t.j] == '#' || (G[t.i][t.j] == 'S' && t.d == 3)) break;
      if(vis[t.i][t.j][t.d][t.a][t.b]) break;
      vis[t.i][t.j][t.d][t.a][t.b] = true;
      que.push(t);
    } while(0);
    do {
      State t = s;
      if(G[t.i][t.j] == 'S') break;
      t.d = P[t.d];
      if(--t.a < 0) break;

      t.i += di[t.d];
      t.j += dj[t.d];
      if(t.i < 0 || t.i >= H) break;
      if(t.j < 0 || t.j >= W) break;
      if(G[t.i][t.j] == '#' || (G[t.i][t.j] == 'S' && t.d == 3)) break;

      if(vis[t.i][t.j][t.d][t.a][t.b]) break;
      vis[t.i][t.j][t.d][t.a][t.b] = true;
      que.push(t);
    } while(0);
    do {
      State t = s;
      if(G[t.i][t.j] == 'S') break;
      t.d = Q[t.d]; 
      if(--t.b < 0) break;

      t.i += di[t.d];
      t.j += dj[t.d];
      if(t.i < 0 || t.i >= H) break;
      if(t.j < 0 || t.j >= W) break;
      if(G[t.i][t.j] == '#' || (G[t.i][t.j] == 'S' && t.d == 3)) break;

      if(vis[t.i][t.j][t.d][t.a][t.b]) break;
      vis[t.i][t.j][t.d][t.a][t.b] = true;
      que.push(t);
    } while(0);
  }
  int res = INF;
  for(int a = 0; a <= A; ++a) {
    for(int b = 0; b <= A; ++b) {
      for(int k = 0; k < 4; ++k) {
        if(vis[gi][gj][k][a][b]) {
          res = min(res, A*2 - (a+b));
        }
      }
    }
  }
  if(res == INF) return -1;
  return res;
}
 
int main() {
  cin >> H >> W >> A;
  int si, sj, gi, gj;
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      cin >> G[i][j];
      if(G[i][j] == 'S') {
        si = i; sj = j;
      }
      if(G[i][j] == 'G') {
        gi = i; gj = j;
      }
    }
  }
  cout << bfs(si, sj, gi, gj) << endl;
  return 0;
}

Measured memory_bytes: 20652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int a, b, c; cin >> a >> b >> c;
	int k, cnt = 0; cin >> k;
	while(a >= b) {
		b *= 2;
		cnt++;
	}
	while(b >= c) {
		c *= 2;
		cnt++;
	}
	if(cnt <= k) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}

Measured memory_bytes: 3628
# -*- coding:utf-8 -*-
import math
N, A, B = map(int, input().split())
if N != 1 and A <= B:
    '''
    n = math.factorial(B-A+N-2)
    a = math.factorial(N-2)
    b = math.factorial(B-A)
    print(n//(a*b))
    '''
    print((B-A)*(N-2)+1)
else:
    if A != B:
        print(0)
    else:
        print(1)

Measured memory_bytes: 3060
#include "stdio.h"
#include "iostream"
#include "vector"
#include "algorithm"
#include "iomanip"
#include "map"
#include "set"
#include "bitset"
#include "queue"
#include "string.h"
#include "math.h"
#include "numeric"

using namespace std;
using LL = long long;


int main() {
    int n;
    scanf("%d", &n);

    vector< int> a(n), b(n), c(n);
    for (int &e : a) scanf("%d", &e);
    for (int &e : b) scanf("%d", &e);

    vector< int> v(n);
    for (int i = 0; i < n; ++i) {
        v[i] = a[i] - b[i];
    }
    sort(v.begin(), v.end());

    int r = n - 1, res = 0;

    int val = 0;
    for (int i = 0; i < n; ++i) {
        if (v[i] >= 0) return !printf("%d\n", i + res);

        while (r > i and val < abs(v[i])) {
            val += v[r];
            r--;
            res ++;
        }

        if (val < abs(v[i])) return !printf("-1\n");
        val -= abs(v[i]);
    }
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, C, D[50][50], c[505][505];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> C;
    REPS(i, C) REPS(j, C) { cin >> D[i][j]; }
    REP(i, N) REP(j, N) { cin >> c[i][j]; }

    map<int, map<int, int> > cmap;
    REP(i, N) REP(j, N) { cmap[(i + j) % 3][c[i][j]]++; }

    int ans = INF;
    REPS(i, C) {
        REPS(j, C) {
            if (i == j) continue;
            REPS(k, C) {
                if (j == k || i == k) continue;

                int tmp = 0;
                REPS(t, C)
                tmp += cmap[0][t] * D[t][i];
                REPS(t, C)
                tmp += cmap[1][t] * D[t][j];
                REPS(t, C)
                tmp += cmap[2][t] * D[t][k];

                ans = min(ans, tmp);
            }
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<P> A(N);
    rep(i, N) {
        ll a;
        cin >> a;
        A[i] = make_pair(a, i);
    }
    sort(A.rbegin(), A.rend());
    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 0));
    rep(k, N) {
        P p = A[k];
        rep(i, k + 1) {
            ll j = k - i;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + p.first * abs(p.second - i));
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + p.first * abs(p.second - ((N - 1) - j)));
        }
    }
    ll ans = 0;
    rep(i, N) {
        rep(j, N) {
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 34620
p = 10**9 + 7

def modpow(a, n, p):
    if n == 1:
        ans = a % p
    else:
        if n % 2 == 0:
            ans = (modpow(a, n // 2, p) ** 2) % p
        else: # n % 2 == 1
            ans = (a * (modpow(a, n // 2, p) ** 2)) % p

    return ans

Fact = [[1, 1] for _ in range(10**5 + 1)]
for i in range(1, 10**5 + 1):
    Fact[i][0] = (Fact[i - 1][0] * i) % p
    Fact[i][1] = modpow(Fact[i][0], p - 2, p)

def C(a, b, p, Fact):
    if a < b:
        return 0
    else:
        ans = Fact[a][0] * Fact[b][1] * Fact[a - b][1] % p
        return ans

N, K = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])
 
maxS = 0
for i in range(N):
    maxS = (maxS + A[i] * C(i, K - 1, p, Fact)) % p

minS = 0
for i in range(N):
    minS = (minS + A[i] * C(N - i - 1, K - 1, p, Fact)) % p

ans = (maxS - minS) % p
 
print(ans)

Measured memory_bytes: 35296
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    int n, k; 
    cin >> n >> k;
    ll c = n/k;
    ll ans = c*c*c;

    if (k%2 == 0) {
        ll c = (n+k/2)/k;
        ans += c*c*c;
    }
    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 chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main(){
    int N;
    string s;
    map<string, int> m;
    map<string, int>::iterator it;
    cin >> N;
    int max = 0;
    rep(i,N){
        int j = 0;
        cin >> s;
        it = m.find(s);
        if(it == m.end()){
            j = 1;
        }else{
          j = it->second + 1;
          m.erase(s);
        }
        if(j > max){
            max = j;
        }
        m.insert(pair<string, int>(s, j));
    }

    it = m.begin();
     for (; it != m.end(); ++it)
    {
        if(it->second == max){
            cout << it->first << endl;
        }
    }
}

Measured memory_bytes: 25216
# ABC128B - Guidebook
n = int(input())
lst = [input().rstrip().split() for _ in range(n)]
city = sorted(set([i[0] for i in lst]))
ans = [[] for i in range(len(city))]
for i, l in enumerate(lst, start=1):
    idx = city.index(l[0])
    ans[idx] += [[i, l]]
for i in ans:
    for j in sorted(i, key=lambda x: int(x[1][1]), reverse=True):
        print(j[0])

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<ll> k(m);
    vector<vector<ll>> s(m);
    for(i = 0;i < m;++i){
        cin >> k.at(i);
        rep(j,k.at(i)){
            ll ss;
            cin >> ss;
            --ss;
            s.at(i).push_back(ss);
        }
    }
    vector<ll> p(m);
    for(i = 0;i < m;++i){
        cin >> p.at(i);
    }
    ll ans = 0;
    ll bit;
    for(bit = 0;bit < (1 << n);++bit){
        bool flag = true;
        for(i = 0;i < m;++i){
            ll tmp = 0;
            rep(j,k.at(i)){
                if(bit & (1 << s.at(i).at(j))){
                    ++tmp;
                }
            }
            if(tmp%2 != p.at(i)){
                flag = false;
                break;
            }
        }
        if(flag) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
//*3 or /2

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    vector<int>a(n);
    rep(i,0,n)cin>>a[i];
    ll ans = 0;
    rep(i,0,n){
        while(true){
            if(a[i]%2==0){
                a[i]/=2;
                ans++;
            }else{
                break;
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000;
int main() {   
    int h,w,d;
    cin>>h>>w>>d;
    int a[301][301]={};
    int x[100000]={};
    int y[100000]={};
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>a[j][i];
            x[a[j][i]]=j;
            y[a[j][i]]=i;
        }
    }
    int dp[100000]={};
    for(int i=1;i<=d;i++){
        for(int j=i;j<=h*w;j+=d){
            if(j==i){
                dp[j]=0;
                continue;
            }
            dp[j]=dp[j-d]+abs(x[j]-x[j-d])+abs(y[j]-y[j-d]);
        }
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        cout<<dp[r]-dp[l]<<endl;
    }
}

                           


Measured memory_bytes: 2688
/*
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){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n,p[300005];
void check(vector<int>&l,vector<int>&r){
//	for(auto v:l)cerr<<v<<" ";cerr<<endl;
//	for(auto v:r)cerr<<v<<" ";cerr<<endl;
	vector<int> L=l,R=r;
	sort(L.begin(),L.end());
	sort(R.begin(),R.end());
	if(L!=l||R!=r){
		puts("No");
		exit(0);
	}
	l.clear();r.clear();
}
void solve(int l,int r){
	if(l>r)return;
	if(l==r){
		if(p[l]!=l){
			puts("No");
			exit(0);
		}
		return;
	}
	vector<int>L,R;
	for(int i=l;i<=r;i+=2){
		if(p[i]>i)L.push_back(p[i]);
		else R.push_back(p[i]);
	}
	for(int i=l+1;i<=r-1;i+=2){
		if(p[i]!=i){
			puts("No");
			exit(0);
		}
	}
	if(*min_element(p+l,p+r+1)!=l||*max_element(p+l,p+r+1)!=r){
		puts("No");
		exit(0);
	}
	check(L,R);
}
bool del[300005];
int mp[300005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i];
	}
	for(int i=1;i<=n;i+=2){
		if(~p[i]&1){
			puts("No");
			return 0;
		}
	}
	for(int i=2;i<=n;i+=2){
		if(p[i]&1){
			puts("No");
			return 0;
		}
	}
	vector<int>occ;
	p[0]=0;p[n+1]=n+1;
	for(int i=1;i<=n+1;i++){
		if(p[i]==i&&p[i-1]==i-1){
			del[i]=del[i-1]=1;
		}
	}
	for(int i=1;i<=n;i++){
		if(!del[i]){
			mp[i]=occ.size();
			occ.push_back(p[i]);
		}
	}
	n=occ.size();
	for(int i=1;i<=n;i++)p[i]=mp[occ[i-1]]+1;
	for(int i=1;i<=n;i++)cerr<<p[i]<<" ";cerr<<endl;
	vector<int>opr;
	opr.push_back(0);
	for(int i=1;i<=n-1;i++){
		if(p[i]!=i&&p[i+1]!=i+1)opr.push_back(i);
		if(p[i-1]!=i-1&&p[i]!=i&&p[i+1]!=i+1){
			puts("No");return 0;
		}
	}
	opr.push_back(n);
	for(int i=1;i<opr.size();i++){
		int l=opr[i-1]+1,r=opr[i];
		solve(l,r);
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
	string s, t;
	cin>>s>>t;
	
	vector<int> g[26];
	for(int i=0;i<s.size();i++){
	    g[s[i]-'a'].push_back(i);
	}
	
	
	int count=0;
	int curr = -1;
	for(int i=0;i<t.size();i++){
	    if(g[t[i]-'a'].size()==0){
	        cout<<-1;
	        return 0;
	    }
	    vector<int>::iterator upper = upper_bound(g[t[i]-'a'].begin(),g[t[i]-'a'].end(),curr);
	    if(upper==g[t[i]-'a'].end()){
	        count++;
	        curr = g[t[i]-'a'][0];
	    }
	    else{
	        curr = *upper;
	    }
	}
	
	int ans = count*s.size()+curr+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1724
n = int(input())
if n % 2:
  print((n-1) * (n-1) // 2)
  for i in range(1,n):
    skip = n - i
    for j in range(i+1,n+1):
      if j != skip:
        print(i,j)
else:
  print((n-2) * n // 2)
  for i in range(1,n):
    skip =  n + 1 - i
    for j in range(i+1,n+1):
      if j != skip:
        print(i,j)
      

Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BDigits solver = new BDigits();
        solver.solve(1, in, out);
        out.close();
    }

    static class BDigits {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long n = in.nextLong(), k = in.nextLong(), ans = 0;
            while (n > 0) {
                n /= k;
                ans++;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define mper make_pair
#define PI 3.14159
#define F first
#define S second
#define ll int
//#define forik(i, a, b) for(ll i = a; i <= b; ++i)
#define vl vector<ll>
#define pll pair<ll, ll>
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll a, b;

int main() {

mal

ll type = -1;

cin >> a >> b;

if(a == 0 || b == 0) {type = 0;}
else if(a < 0 && b > 0) {type = 0;}
else if(a < 0 && b < 0) {

    if((abs(a - b) + 1) % 2 == 0) {type = 1;}
    else {type = 2;}

}

else {type = 1;}

if(!type) {cout << "Zero";}
else if(type == 1) {cout << "Positive";}
else if(type == 2) {cout << "Negative";}

return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    string s,t;
    int n,a,b,c,d;
    cin >> s >> t;
    cout << t << s << endl;

}


Measured memory_bytes: 888
import sys
import copy
input = sys.stdin.readline

N = int(input())

if N == 1:
    print('a')
    exit()
if N == 2:
    print('aa')
    print('ab')
    exit()

ans = ['aaa', 'aab', 'aba', 'abb', 'abc']
alph = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
length = 3

while length < N:
    ans2 = []
    for value in ans:
        for letter in alph:
            ans2.append(value + letter)
            if letter not in value:
                break
    length += 1
    ans = copy.deepcopy(sorted(ans2))

for value in ans:
    print(value)

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

int main(){
  int n,i;
  cin>>n;
  int d[n];
  for(i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d,d+n);
  int cnt=1;
  for(i=0;i<n-1;i++){
    if(d[i+1]-d[i]!=0)cnt++;
  }
  cout<<cnt;
}

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

int main(void) {
  int A, B;
  cin >> A >> B;
  
  if(A+B >= A-B && A+B >= A*B)
    cout << A+B << endl;
  else if(A-B >= A*B)
    cout << A-B << endl;
  else
    cout << A*B << endl;
  
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
S=[int(i) for i in input().split()]
q=int(input())
T=[int(i) for i in input().split()]

count=0

for i in range(q):
  k=n//2
  if n%2==1:
    l=(n+1)/2
  else:
    l=n/2
  while not((S[k-1] < T[i]) and (S[k] > T[i])):
    if l%2==1:
      l=(l+1)//2
    else:
      l=l//2
    if S[k] > T[i]:
      k= int(k-l)
      if k < 0:
        break
    elif S[k] < T[i]:
      k= int(k+l)
      if k > n-1:
        if S[n-1] == T[i]:
          count+=1
        break
    else:
      count+=1
      break
    #print(S[k])
print(count)


Measured memory_bytes: 16900
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int read();

vector<int> e[5003];
void add(int f, int t) { e[f].push_back(t), e[t].push_back(f); }
int f[5003][5003], g[5003], tmp[5003];
int n, sz[5003];

void dfs(int u, int fa) {
    f[u][sz[u] = 1] = 1;
    for (int i = 0, v; i < e[u].size(); ++i) {
        if ((v = e[u][i]) == fa) continue;
        dfs(v, u);
        for (int i = 1; i <= sz[u] + sz[v]; ++i) tmp[i] = 0;
        for (int i = 1; i <= sz[u]; ++i)
            for (int j = 0; j <= sz[v]; ++j)
                (tmp[i + j] += 1ll * f[u][i] * f[v][j] % mod) %= mod;
        for (int i = 1; i <= sz[u] + sz[v]; ++i) f[u][i] = tmp[i];
        sz[u] += sz[v];
    }
    for (int i = 2; i <= sz[u]; i += 2)
        (f[u][0] += mod - 1ll * f[u][i] * g[i] % mod) %= mod;
}

int main() {
    g[0] = 1, n = read();
    for (int i = 2; i <= n; i += 2) g[i] = 1ll * g[i - 2] * (i - 1) % mod;
    for (int i = 1; i < n; ++i) add(read(), read());
    dfs(1, 0);
    printf("%d\n", mod - f[1][0]);
    return 0;
}
const int _SIZE = 1 << 22;
char ibuf[_SIZE], *iS = ibuf, *iT = ibuf;
#define gc                                                         \
    (iS == iT ? iT = ((iS = ibuf) + fread(ibuf, 1, _SIZE, stdin)), \
     (iS == iT ? EOF : *iS++) : *iS++)
int read() {
    int x = 0, f = 1;
    char c = gc;
    while (!isdigit(c)) f = (c == '-') ? -1 : f, c = gc;
    while (isdigit(c)) x = x * 10 + c - '0', c = gc;
    return x * f;
}

Measured memory_bytes: 98304
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  vector<int> input(2);
  vector<int> output(N,0);
  int i,j;
for (i=0; i< M; i++){
  cin >> input.at(0) >> input.at(1);
    for (j=1; j<N+1; j++){
      if( input.at(0) == j){
        output.at(j-1) ++;}
        else if(input.at(1) == j){
        output.at(j-1) ++;}
  }
}
     for (i=0; i<N; i++){
       cout << output.at(i) << endl;}
    
}

Measured memory_bytes: 256
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))

re = 0
max_dif = 0
A_min = A[0]
for i in range(1, N):
    A_min = min(A_min, A[i-1])
    dif = A[i] - A_min
    if max_dif < dif:
        max_dif = dif
        re = 1
    elif dif == max_dif:
        re += 1

print(re)

Measured memory_bytes: 14244
k,n=map(int, input().split())
a_list=list(map(int, input().split()))

diff=[]
for i in range(len(a_list)-1):
    diff.append(a_list[i+1]-a_list[i])
diff.append(k-(a_list[n-1]-a_list[0]))
diff.sort(reverse=True)
print(k-diff[0])

Measured memory_bytes: 25840
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000],arr1[1000000],arr2[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k;
    cin>>n;
    for (i=1;i<=n;i++)
    {
    	cin>>arr[i];
	}
	for (i=1;i<=n;i++)
	{
		if (i>arr[i])
		{
			arr1[i-arr[i]]++;
		}
	}
	k=0;
	for (i=1;i<=n;i++)
	{
		if (i+arr[i]<=n)
		{
			k=k+arr1[i+arr[i]];
		}
	}
	cout<<k<<endl;
}

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main()
{ 
  int x,  y; cin >> x>> y;
  int t = (y/2)-x;
  int c = x - t;
  if(y%2==0 && t>=0 && c>=0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;


int main() {
  int N; cin >> N;
  if(N < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;

	return 0;
}



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

using namespace std;

int main() {
    int N,K; cin>>N>>K;
    vector<int> hn(N);
    for (int i=0;i<N;i++) cin>>hn[i];

    sort(hn.begin(), hn.end());

    int ans=INT_MAX;
    for (int i=0;i<N-K+1;i++) {
        ans = min(ans, hn[i+K-1] - hn[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
/*
         ██╗ ██████╗ ██╗███╗   ██╗    ██╗   ██╗███████╗
         ██║██╔═══██╗██║████╗  ██║    ██║   ██║██╔════╝
         ██║██║   ██║██║██╔██╗ ██║    ██║   ██║███████╗
    ██   ██║██║   ██║██║██║╚██╗██║    ██║   ██║╚════██║
    ╚█████╔╝╚██████╔╝██║██║ ╚████║    ╚██████╔╝███████║
     ╚════╝  ╚═════╝ ╚═╝╚═╝  ╚═══╝     ╚═════╝ ╚══════╝
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5e5 + 5;
const int inf = 0x3f3f3f3f;

int main() {
    string a[3];
    cin>>a[0]>>a[1]>>a[2];
    int op=0;
    while(1)
    {
        // cout<<(char)(op+'A')<<endl;
        if(a[op].empty()){
            cout<<(char)(op+'A');
            return 0;
        }
        else 
        {
            int c=a[op][0]-'a';
            reverse(a[op].begin(),a[op].end());
            a[op].pop_back();
            reverse(a[op].begin(),a[op].end());
            op=c;
        }
    }
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

S = input()

ctr = defaultdict(int)
ctr[0] = 1
cur = 0
n = len(S)
mod = 2019
for i in reversed(range(n)):
    cur = (cur + int(S[i]) * pow(10, n - i - 1, mod)) % mod
    ctr[cur] += 1

ans = 0
for v in ctr.values():
    ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 69060