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

using namespace std;

int main(){
    long int n, x;
    cin >> n >> x;

    long int ans = 0;
    for(long int i = n; i > 0; i--){
        if (pow(2, i + 2) - 3 > 2 * x - 1) {
            if (x == 1) {
                cout << ans << '\n'; 
                return 0;
            }else{
                x = x - 1;
            }
        }else if (pow(2, i + 2) - 3 == 2 * x - 1){
            ans += pow(2, i);
            cout << ans << '\n';
            return 0;
        }else{
            if (x == pow(2, i + 2) - 3) {
                ans += pow(2, i + 1) - 1;
                cout << ans << '\n';
                return 0;
            }else{
                ans += pow(2, i);
                x = x - pow(2, i + 1) + 3 - 2;
                // cout << "ans = " << ans << '\n';
                // cout << "x = " << x << '\n';
            }
        }
    }
    ans++;
    cout << ans << "\n";
}

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

int main(){
    int N,A[100]={},c = 0,n,l;

    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> l;
        A[i] = l;
    }
    for (int i =0; i < n; i++){
        int minj = i;
        for ( int j = i; j < n; j++){
            if (A[j] < A[minj]){
                minj = j;
            }
        }
        int a = A[i];
        A[i] = A[minj];
        A[minj] = a;
        if (A[i] != A[minj]){
            c += 1;
        }
    }
    for (int i = 0; i < n; i++){
        if (i == n-1){
            cout << A[i] << '\n';
        }
        else{
            cout << A[i] << " ";
        }
    }
    cout << c << '\n';
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ll n;
	cin >> n;
	ll count = 0, pos = 0, chal = 0, cop, p;
	bool sev, fiv, thr, wr;
	while ( chal <= n ){
		pos++;
		sev = fiv = thr = false;
		wr = false;
		chal = 0;
		cop = pos;
		p = 1;
		while ( cop > 0 ){
			if ( cop % 4 == 1 ){
				thr = true;
				chal += p * 3;
			}else if ( cop % 4 == 2 ){
				fiv = true;
				chal += p * 5;
			}else if ( cop % 4 == 3){
				sev = true;
				chal += p * 7;
			}else{
				wr = true;
			}
			cop /= 4;
			p *= 10;
		}
		if ( !wr && sev && fiv && thr && chal <= n ){
			count++;
		}
	}
	cout << count << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
     
    public class Main{
          public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
                int k = sc.nextInt();
                int a = sc.nextInt();
                int b = sc.nextInt();
                for(; a <= b+1; a++){
                  if(a % k == 0){
                    System.out.println("OK");
                    break;
                  } else if(a == b){
                    System.out.println("NG");
                    break;
                  }
                }
              }
    }

Measured memory_bytes: 35820
#include <iostream>

using namespace std;

int main(void){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout << x2+y1-y2 << " " << y2+x2-x1 << " " 
         << x1+y1-y2 << " " << y1+x2-x1 << endl;
    return 0;
}


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

n = int(input())
x = [list(input().split()) for _ in range(n)]

for i in range(n):
    x[i][1] = int(x[i][1])

X = []
for i in range(len(x)):
    X.append(int(x[i][1]))
    
xx = sorted(x)
flag = True
temp = xx[0][0]
l = []
ans = []
l.append(xx[0][1])
for i in range(1, n):
    if temp == xx[i][0]:
        l.append(xx[i][1])
        flag = True
    else:
        flag = False
        l.sort(reverse=True)
        for j in l:
            ans.append(j)

        l = []
        temp = xx[i][0]
        l.append(xx[i][1])

if flag:
    l.sort(reverse=True)
    for j in l:
        ans.append(j)
    
ans = [int(a) for a in ans]

if len(ans) != len(X):
    ans.append(xx[i][1])
for j in range(n):
    print(X.index(ans[j]) + 1)



Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

search :: [Int] -> Int -> Int -> Int
search (x:xs) n i | x == n = i
                  | otherwise = search xs n (i+1)

main = do
  xs <- getIntList
  print $ search xs 0 1


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
bool solve(){
  string s,t;
  cin>>s>>t;
  rep(i,0,s.length()){
    if(s[i]!=t[i]) return false;
  }
  return true;
}
int main(){
    optimizeIO();
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t a; string b; cin>>a>>b;
	int c=0;
	for(int i=0;i<b.size();++i){
		if(b.at(i)=='.')continue;
		c*=10;
		c+=b.at(i)-'0';
	}
	cout<<a*c/100<<"\n"s;
}

Measured memory_bytes: 3588
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
   int m;
   int l;
  
   cin >> n >> m >> l;
  
   if(n*m>l){
     cout << l << endl;
   }else{
     cout << n*m << endl;
   }
   
   
  return 0;
}

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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
	string S;
	cin >> S;
	reverse(S.begin(), S.end());

	const int N = S.length();
	vector<int> mod13(N);
	
	int x = 1;
	for (int i = 0; i < N; ++i) {
		mod13[i] = x;
		x = (x * 10) % 13;
	}
	
	vector<long long> dp(13);
	if (S[0] == '?') {
		for (int d = '0'; d <= '9'; ++d) {
			int x = (d - '0') * mod13[0];
			dp[x % 13] += 1;
		}
	}
	else {
		int x = (S[0] - '0') * mod13[0];
		dp[x % 13] += 1;
	}

	for (int i = 1; i < N; ++i) {
		vector<long long> v(13, 0);
		if (S[i] == '?') {
			for (int d = '0'; d <= '9'; ++d) {
				int x = (d - '0') * mod13[i];
				for (int k = 0; k < 13; ++k) {
					v[(k + x) % 13] = (v[(k + x) % 13 ] + dp[k]) % MOD;
				}
			}
		}
		else {
			int x = (S[i] - '0') * mod13[i];
			for (int k = 0; k < 13; ++k) {
				v[(k + x) % 13] = (v[(k + x) % 13] + dp[k]) % MOD;
			}
		}
		dp = move(v);
	}

	auto ans = dp[5] % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 896
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

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

int main() {
	int h, w, d;
	scanf("%d%d%d", &h, &w, &d);
	int res[h][w];
	forn(i, h) {
		forn(j, w) {
			res[i][j] = ((i + j) / d % 2) * 2 + ((i - j + w) / d % 2);
			putchar("RYGB"[res[i][j]]);
		}
		puts("");
	}
	// forn(i, h) 
	// 	forn(j, w) 
	// 		forn(i1, h) 
	// 			forn(j1, w) 
	// 				if (abs(i - i1) + abs(j - j1) == d)
	// 					assert(res[i][j] != res[i1][j1]);
}


Measured memory_bytes: 1408
N = int(input())
a = list(map(int,input().split()))

baclet = [False] * 9
baclet[8] = 0

for val in a:
    if val < 400:
        baclet[0] = True
    elif val >= 400 and val < 800: 
        baclet[1] = True
    elif val >= 800 and val < 1200: 
        baclet[2] = True
    elif val >= 1200 and val < 1600: 
        baclet[3] = True
    elif val >= 1600 and val < 2000: 
        baclet[4] = True
    elif val >= 2000 and val < 2400: 
        baclet[5] = True
    elif val >= 2400 and val < 2800: 
        baclet[6] = True
    elif val >= 2800 and val < 3200: 
        baclet[7] = True
    elif val >= 3200: 
        baclet[8] += 1

if baclet[:-1].count(True) > 0:
    print(baclet[:-1].count(True),end=" ")
elif baclet[8] > 0:
    print(1,end=" ")

print(baclet[:-1].count(True) + baclet[8])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b)
  	cout << c << endl;
  else if(a == c)
  	cout << b << endl;
  else
    cout << a << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    int cnt[5] = {};
    REP(i, 0, N) {
        string s; cin >> s;
        if (s[0] == 'M') cnt[0]++;
        if (s[0] == 'A') cnt[1]++;
        if (s[0] == 'R') cnt[2]++;
        if (s[0] == 'C') cnt[3]++;
        if (s[0] == 'H') cnt[4]++;
    }

    ll ans = 0;
    for (int bit = 0; bit < (1 << 5); bit++) {
        vector<int> bits;
        REP(i, 0, 5) {
            if (bit & (1 << i)) bits.push_back(i);
        }

        if (bits.size() != 3) continue;

        ll comb = 1;
        for (auto i : bits) comb *= cnt[i];

        ans += comb;
    }

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

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

public class Main implements Runnable{
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	int res;

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int n = fs.nextInt();
		int x = fs.nextInt();
		boolean[] bad = new boolean[10];
		for(int i = 0; i < x; i++) bad[fs.nextInt()] = true;

		res = Integer.MAX_VALUE;
		find("", n, bad);
		out.println(res);
		out.close();
	}

	void find(String s, int n, boolean[] bad) {
		if(s.length() > 0) {
			int parse = Integer.parseInt(s);
			if(parse >= n) {
				res = Math.min(res, parse);
				return;
			}
		}
		for(int i = 0; i < bad.length; i++) if(!bad[i]) {
			if(i == 0 && s.length() > 0) {
				find(s + "" + i, n, bad);
			}
			else if(i > 0) {
				find(s + "" + i, n, bad);
			}
		}
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}

	}

}

Measured memory_bytes: 31044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n; cin>>n;
    if(n%2==0) cout<<n<<endl;
    else cout<<2*n<<endl;
    return 0;
}


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

const int SIZE = 50030;
bool isprime[SIZE + 1] = {0};
vector<int> prime;
void make_prime(){
    isprime[1] = true;
    isprime[0] = true;
    for(int i = 2; i <= SIZE; i++){
        if(isprime[i]) continue;
        for(int j = i * 2; j <= SIZE; j += i) isprime[j] = true;
        prime.push_back(i);
    }
}

int main(){
    make_prime();
    int n;
    while(cin >>n){
        int min, max;
        for(min = n - 1; isprime[min] != false; min--) ;
        for(max = n + 1; isprime[max] != false; max++) ;
        cout <<min <<" " <<max <<endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
int main()
{
    double a,b;
    std::cin >> a >> b;
    if(a > b)
    {
        std::cout << "GREATER" << std::endl;
    }
    else if(a < b)
    {
        std::cout << "LESS" << std::endl;
    }
    else
    {
        std::cout << "EQUAL" << std::endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int x, a;
    cin >> x >> a;
    if(x < a) ppp(0);
    else ppp(10);

    return 0;
}


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

char str[3][10];

int len(char*);

int main(void){
    for(int i=0;i<3;i++){
        scanf("%s", str[i]);
        if(len(str[i])<1 || len(str[i])>10){
            printf("Error\n");
            return 0;
        }
        printf("%c", toupper(str[i][0]));

    }
    printf("\n");
    return 0;


}



int len(char arr[]){
    char* p = arr;
    int count=0;
    char end = '\0';
    while(strcmp(p,&end)){
        count++;
        p++;
    }
    return count;
}


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


tmp = 10 ** 18
best_h = -1

for i,h in enumerate(H):
  _tmp = T - h * 0.006
  diff_tmp = abs(tmp - A)
  diff__tmp = abs(_tmp - A)
  
  if diff__tmp < diff_tmp:
    best_h = i + 1
    tmp = _tmp


print(best_h)

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int a[3];
string S;

int main(){
	cin >> S;
	for(auto z : S){
		if(z=='a') ++a[0];
		else if(z=='b') ++a[1];
		else ++a[2];
	}
	sort(a,a+3);
	cout << (a[2]-a[0]<2?"YES":"NO") << endl;
	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-

def f(N,k):
    if not N:
        return 0
    N = str(int(N))
    a = (len(N)-1)
    na = int(N[0])
    if k == 1:
        return str(9*a+na)
    if k == 2:
        return str(9**2*a*(a-1)//2 + (na-1)*int(f('9'*a,1)) + int(f(N[1:],1)))
    if k == 3:
        return str(9**3*a*(a-1)*(a-2)//6 + (na-1)*int(f('9'*a,2)) + int(f(N[1:],2)))

def solve():
    N = input()
    K = int(input())
    return f(N,K)
    
if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3064
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]

pmz = 0
ans = 1

for i in range(N-1):
    diff = A[i+1] - A[i]
    if pmz * diff < 0:
      pmz = 0
      ans +=1
    elif pmz == 0:
      pmz = diff
    
print(ans)

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

bool isPrime(int x) {
    if (x <= 1) return false;
    for (int i = 2; i * i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}


int main()
{

    int x;
    cin >> x;

    while(!isPrime(x)) x++;

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
	int SpreadSheet[100][100];
	int SumOfRow[100];
	int SumOfColumn[100];
	int row,column;
	scanf("%d %d",&row,&column);
	for(int i=0;i<row;i++){
		SumOfRow[i] = 0;
		for(int j=0;j<column;j++){
			scanf("%d",&SpreadSheet[i][j]);
			printf("%d ",SpreadSheet[i][j]);
			SumOfRow[i] += SpreadSheet[i][j];
		}
		printf("%d\n",SumOfRow[i]);
	}
	for(int j=0;j<column;j++){
		SumOfColumn[j] = 0;
		for(int i=0;i<row;i++){
			SumOfColumn[j] += SpreadSheet[i][j];
		}
	}
	int SumOfAll = 0;
	for(int i=0;i<row;i++){
		SumOfAll += SumOfRow[i];
	}
	for(int j=0;j<column;j++){
		printf("%d ",SumOfColumn[j]);
	}
	printf("%d\n",SumOfAll);
	return 0;
}

Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
#define N 1111116

int n,m,ans;
pair<int,int> a[N];
priority_queue<int,vector<int>,greater<int> > ql,qr;

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++)
		a[i].first=read(),a[i].second=read();
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		if (a[i].first==(int)ql.size()) 
		ql.push(a[i].second),qr.push(ql.top()),ql.pop();
		else ql.push(a[i].second),ans++;
	for (int i=ql.size()+1;i<=m;i++)
		if (!qr.empty()&&qr.top()<=i) qr.pop(),ans++;
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
#define fore_(i, s, e) for(long long i = s; i > e; i--)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef long long ll;
ll b,w,r;
string s;
int main() {
  FIN;cin>>s;
  fore_(i,s.size()-1,-1){
    if(s[i]-'W'){b++;r+=w;}else {w++;}
  }
  cout<<r<<endl;
  return 0;
}

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


int check(string str) 
{ 
	// Compute sum of digits 
	int n = str.length(); 
	int digitSum = 0; 
	for (int i=0; i<n; i++) 
		digitSum += (str[i]-'0'); 

	return (digitSum % 9 == 0); 
} 

int main() 
{ 
	string str;cin>>str;
	check(str)? cout << "Yes" : cout << "No "; 
	return 0; 
} 


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

void solve() 
{
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll ans=max({a*c,a*d,b*c,b*d});
    cout<<ans<<endl;
}

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

Measured memory_bytes: 3648
N, M, X = map(int, input().split())
#N=参考書の冊数, 縦,M＝学びたいアルゴリズムの数, 横,X＝目標の理解度
S = [ input().split() for _ in range(N)]
mintotal = 10 ** 9

for i in range(2 ** N):
    alg = [0 for _ in range(M)]
    #bag = []
    total = 0
    #print("pattern {}:".format(i),  end="")
    for j in range(N):
        if ((i >> j) & 1):
            #bag.append(S[j])
            for k in range(M):
                alg[k] += int(S[j][k + 1])
            total += int(S[j][0])
    #print(alg, bag)

    for l in range(M):
        #print(alg[l])
        if alg[l] < X:
            break
    else:
        mintotal = min(mintotal, total)

if mintotal == 10 ** 9:
    print(-1)
else:
    print(mintotal)


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

ll solve() {
    ll A;
    double B;
    cin >> A >> B;
    ll b100 = (ll)(B * 100 + 0.5);
    ll ans = A*b100/100;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#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 bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int r,g,b,n; cin>>r>>g>>b>>n;
    ll ans = 0;
    rep(i,n/r+1){
        int x = n;
        x -= i*r;
        rep(j,x/g+1){
            int y = x;
            y -= j*g;
            if(y % b == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define FOR(i,a,b)  for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n)    FOR(i,0,n)
#define ALL(a)      a.begin(),a.end()
#define vi          vector<int>
#define vvi         vector<vi>
#define P           pair<int,int>
#define vP          vector<P>
#define vvP         vector<vP>

int main(){
    int n;cin>>n;
    vi num(n);
    REP(i,n){
        cin>>num[i];
    }
    sort(ALL(num));
    int res=0;
    int before=-1;
    REP(i,n){
        if(before!=num[i]){
            res++;
        }
        before=num[i];
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int a,b,c,d; cin >> a >> b >> c >>d;
    cout << c-d+b << " " <<  d+c-a <<  " " << a-d+b << " " << b+c-a << endl; 

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
#define N 100100
using namespace std;
string s, t;
int dp[3005][3005];
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> s >> t;
int sl = s.length();
int tl = t.length();
for (int i = 1; i <=sl; i++){
    for (int j = 1; j <= tl; j++) {
         if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
         }
         else if (dp[i-1][j] > dp[i][j-1] ) {
                dp[i][j]  = dp[i-1][j];
          }
          else{
             dp[i][j] = dp[i][j-1];
          }
    }
}
int x = sl, y = tl;

string res = "";
while (x and y ){
    if (s[x-1] == t[y-1]) {
        res+=s[x-1];
        x--;
        y--;
    }
    else if (dp[x-1][y] >= dp[x][y-1]){
        x--;
    }
    else {
        y--;
    }
}
reverse (res.begin() , res.end());
cout << res;
}



Measured memory_bytes: 35456
using System;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nAndk = Console.ReadLine().Split(" ");
            string[] line = Console.ReadLine().Split(" ");
            int kosuu = int.Parse(nAndk[0]);
            int dokomade = int.Parse(nAndk[1]);
            int[] amount = new int[kosuu];

            int answer = 0;
            for (var i = 0 ; i < kosuu; i++)
            {
                amount[i] = int.Parse(line[i]);
            }
            Array.Sort(amount);
            for(var i = 0; i < dokomade; i++)
            {
                answer = answer + amount[i];
            }
            
            Console.WriteLine(answer);

            
        }
    }
}


Measured memory_bytes: 27876
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

bool is_prime(int64_t n) {
    if (n == 2) {
        return true;
    } else if (n % 2 == 0) {
        return false;
    }

    for (int64_t i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    int32_t N, count = 0;

    cin >> N;

    for (int32_t i = 0; i < N; i++) {
        int64_t n;
        cin >> n;

        if (is_prime(n)) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3092
from collections import deque
from sys import stdin, stdout

input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N = int(input())

    ans = '' if N else '0'
    while N:
        if N % 2:
            N -= 1
            ans = '1' + ans
        else:
            ans = '0' + ans
        N //= -2
    write(ans + '\n')

main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

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

	int n, a, b;
	cin >> n >> a >> b;

	if(abs(a - b) % 2 == 0) cout << "Alice" << endl;
	else cout << "Borys" << endl;

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 2000003;
const int MOD = 1000000007;

        signed main() {
    cout<<fixed<<setprecision(15);
    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)cin>>s[i];
    for(int i=0;i<w+2;i++)cout<<'#';
    cout<<endl;
    for(int i=0;i<h;i++){
            cout<<'#'<<s[i]<<'#'<<endl;
    }
     for(int i=0;i<w+2;i++)cout<<'#';
    cout<<endl;
    
      }

        


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

int main() {
    set<ll> a;
    int q;
    cin >> q;
    rep(i, q) {
        int command;
        ll x;
        cin >> command >> x;

        if (command == 0) {
            a.insert(x);
            cout << a.size() << endl;
        } else if (command == 1) {
            cout << (a.find(x) != a.end()) << endl;
        } else {
            a.erase(x);
//            cout << a.size() << endl;
        }

    }

}



Measured memory_bytes: 12472
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}


//Variables Declaration
int N , W ;
vector<pair<ll,ll>> vect;

ll dp[110][MAXN];
ll solve(int n , int w){
	if(dp[n][w] >= 0 ) return dp[n][w];
	if(n>=N) return 0;
	if(w== 0 ) return 0;
	if(w-vect[n].first <0) return solve(n+1,w);

	ll sol = 0;
	//debug(n);  debugg(w);
	sol = max( solve(n+1,w) + 0 , solve(n+1,w-vect[n].first) + vect[n].second );

	return dp[n][w] = sol ;

}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	memset(dp,-1,sizeof(dp));

 	cin >> N >> W;
 	vect.resize(N);
 	for(auto &x : vect){
 		cin >> x.first >> x.second;
 	}

 	cout << solve(0,W) << endl;





	return 0;
}


Measured memory_bytes: 86272
N = int(input())
p = list(map(int,input().split()))
q = sorted(p)
A = [0 for _ in range(N)]
for i in range(N):
    A[i] = 0 if p[i]==q[i] else 1
x = sum(A)
if x==2 or x==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#pragma GCC                   target ("avx2")
#pragma GCC                   optimize("Ofast")
#pragma GCC                   optimization ("O3")
#pragma GCC                   optimization ("unroll-loops")
#pragma GCC                   target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod                   1000000007
#define INF                   1000000000000000000
#define int                   long long
#define PI                    3.14159265359
#define Author                std::ios_base::sync_with_stdio(0);
#define ABHISHEK_SHARMA       cout.tie(0);
#define IIIT_ALLAHABAD        cin.tie(0);
#define all(v)                v.begin(),v.end()
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
 
clock_t time_p=clock();
 
void abhishhh1(){
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(double)(time_p)/(1.0*CLOCKS_PER_SEC)<<"\n";
}
 
void solve() {
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int t=60*c+d;
    double hangle=(t/2.0);
    hangle=hangle-(int)(hangle/360)*360;
    double mangle=(6.0*t);
    double angle=max(hangle,mangle)-min(mangle,hangle);
    double ans=sqrt(a*a*1.0+b*b*1.0-2.0*a*b*cos((angle*PI)/180.0));
    printf("%.10lf", ans);
    
}
 
signed main(){
    //file reader-writer
#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif
    //Booster
    Author
    ABHISHEK_SHARMA
    IIIT_ALLAHABAD
    //Driver Code here
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    abhishhh1();
}

Measured memory_bytes: 4252
#include<iostream>
using namespace std;
int main() {
	int sum = 0;
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		int a; cin >> a;
		if (a % 2 == 1)sum++;
	}
	if (sum % 2 == 1)cout << "NO\n"; else cout << "YES\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>
#define N 1003

using namespace std;

struct edge{
	int to, nxt;
}e[N * N * 3];

int n, cnt;
int ins[N * N], mp[N][N], fir[N * N], t[N * N];

queue < int > Q;

int id(int ,int);
void add(int ,int);

int main(){
	scanf("%d", &n); int ans = 0;
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j < n; ++j)
			scanf("%d", mp[i] + j);
	for(int i = 1; i <= n; ++i)
		for(int j = 2; j < n; ++j)
			add(id(i, mp[i][j - 1]), id(i, mp[i][j]));
	for(int i = 1; i <= n * n; ++i){
		if(!ins[i]) Q.push(i);
		t[i] = 1;
	}
	while(!Q.empty()){
		int u = Q.front(); Q.pop(); ans = max(ans, t[u]);
		for(int i = fir[u]; i; i = e[i].nxt){
			int v = e[i].to;
			--ins[v];
			if(!ins[v])
				Q.push(v), t[v] = t[u] + 1;
		}
	}
	for(int i = 1; i <= n; ++i) 
		if(ins[i]) ans = -1;
	cout << ans << endl;
	return 0;
}

int id(int x,int y){
	if(x > y) swap(x, y);
	return (x - 1) * n + y;
}

void add(int u,int v){
	e[++cnt] = (edge){v, fir[u]}; fir[u] = cnt; ++ins[v];
	return ;
}

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



int main() 
{ 
int n;
cin >> n;
if(n<1000) cout << 1000-n;
else if(n>=1000&&n%1000==0) cout << 0;
else if(n>1000&&n%1000!=0)
{
     int k = ((n=n%1000)/1000)+1;
     cout << (1000*k)-n;
}

     return 0; 
     
}

Measured memory_bytes: 3564
#include "stdio.h"
 
int tryit(int my[10], int* jikanntai, int F[100][10], int P[100][11], int* max, int mise_max)
{
	int mise_ind = 0;
	int dou_num = 0;
	int i, j;
	int temp_p = 0;
 
	if(*jikanntai>=9)
	{
		for(i=0; i<mise_max; i++)
		{
			dou_num = 0;
			for(j=0; j<10; j++)
			{
				if(my[j] == F[i][j] &&  F[i][j] == 1)
				{
					dou_num += 1;
				}
			}
			temp_p += P[i][dou_num];
		}
 
		if((temp_p > *max)&&(my[0]!=0||my[1]!=0||my[2]!=0||my[3]!=0||my[4]!=0||my[5]!=0||my[6]!=0||my[7]!=0||my[8]!=0||my[9]!=0))
		{
			*max = temp_p;
		}
 
		return 0;
	}
 
	*jikanntai = *jikanntai + 1;
	my[*jikanntai] = 0;
	tryit(my, jikanntai, F, P, max, mise_max);
 
	my[*jikanntai] = 1;
	tryit(my, jikanntai, F, P, max, mise_max);
 
	*jikanntai = *jikanntai - 1;
	return 0;
}
 
int main(void){
	int i, j;
	int my[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	int max = -2147483647;
	int jikanntai = 0;
 
	int N;
	int F[100][10];
	int P[100][11];
	scanf("%d", &N);
	for(i=0;i<N;i++)
	{
		for(j=0;j<10;j++)
		{
			scanf("%d", &F[i][j]);
		}
	}
 
	for(i=0;i<N;i++)
	{
		for(j=0;j<11;j++)
		{
			scanf("%d", &P[i][j]);
		}
	}
 
	jikanntai = -1;
	tryit(my, &jikanntai, F, P, &max, N);
 
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 256
S = input()
Q = int(input())


flip = 0
head = ""
for _ in range(Q):
    q = input()
    if q == '1':
        flip += 1
    else:
        _, f, c = q.split(' ')
        if f == '1' and (flip % 2) == 0:
            # S = c + S
            head = head + c
        elif f == '1' and (flip % 2) != 0:
            S = S + c
        elif f != '1' and (flip % 2) == 0:
            S = S + c
        else:
            # S = c + S
            head = head + c

if (flip % 2) == 0:
    head = head[::-1]
    S = head + S
else:
    S = S[::-1]
    S = S + head

print(S)


Measured memory_bytes: 4316
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val s = scn.next().toCharArray()
	var pre = mutableListOf<Char>()
	var suf = mutableListOf<Char>()
	val nq = scn.nextInt()
	var rev = false
	repeat(nq){
		val t = scn.nextInt()
		when(t){
			1 -> rev = !rev
			2 -> {
				val f = scn.nextInt()==2
				val c = scn.next().toCharArray()[0]
				if (f==rev) pre.add(c)
				else suf.add(c)
			}
		}
	}
	if (rev){
		val tmp = suf
		suf = pre
		pre = tmp.asReversed()
		s.reverse()
	}else pre.reverse()
	val ans = buildString {
		append(pre.toCharArray())
		append(s)
		append(suf.toCharArray())
	}
	print(ans)
}


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

using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> h(n, 0);

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

    int counter = 0;
    while (1){
        int sum = accumulate(h.begin(), h.end(), 0);
        if (sum == 0) break;

        bool leftflag = false;

        for (int i = 0; i < h.size(); i++){
            if (h[i] != 0){
                h[i]--;
                leftflag = true;
                if (i == h.size() - 1) counter++;
            }

            else{
                if (leftflag){
                    counter++;
                    leftflag = false;
                }
            }
        }
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    // 一回の提出で必ず1900M+100(N-M)
    // 全部通るまで提出する回数の期待値は1/(1/2)^M=2^M
    cout << (1900 * M + 100 * (N - M)) * (1 << M) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int H, W;
    
    while (1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0){
        break;
    }
    int i,j;
    
    for(i=1; i <= H ; i++){
      for(j=1; j <= W; j++){
          
    if(i==1 || j==W)  
    putchar('#');
    else if(j==1 || j==W)
    putchar('#');
    else
    putchar('#');
     }
    putchar('\n');
    }
    putchar('\n');
    }
    
    return 0;
    
}


Measured memory_bytes: 2104
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int D,T,S;cin>>D>>T>>S;
    if(S*T>=D) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
    string s;
    cin >> s;
    rep(i, 12){
        cout << s[i];
        if(i == 3)
        cout << " ";
    }
    cout << endl;
}

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

class Dice{
public:
    long r[6];
    Dice(){};
    void roll(long a, long b, long c, long d){
        swap(r[a], r[b]);
        swap(r[b], r[c]);
        swap(r[c], r[d]);
    }
    void spinW(){roll(0, 2, 5, 3);}
    void spinN(){roll(0, 1, 5, 4);}
};

int main() {
    bool ans = 0;
    int n;
    cin >> n;
    vector<Dice> D(n);
    for (int i = 0; i < n ; i++) {
        for (int j = 0; j < 6; j++) cin >> D[i].r[j];
    }
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1 ; j < n ; j++) {
            char SWS[8]={"NNNWNNN"};
            for (int k = 0; k < 8; k++){
                if (D[i].r[1] == D[j].r[1]) break;
                if (SWS[k] == 'W') D[j].spinW();
                else D[j].spinN();
            }
            for (int k = 0; k < 4; k++){
                if (D[i].r[0] == D[j].r[0]){
                    if (D[i].r[1] == D[j].r[1] && D[i].r[2] == D[j].r[2] && D[i].r[3]==D[j].r[3] && D[i].r[4] == D[j].r[4] && D[i].r[5] == D[j].r[5])
                        ans = 1;
                }
                D[j].spinW();
            }
        }
    }

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

    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    string S;
    cin >> N;
    cin >> S;
    ll ans = 1;
    REP(i, N - 1)
    {
        if (S[i] != S[i + 1]) ans++;
    }

    cout << ans << endl;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(n+2);
    for(int i=0; i<m; i++){
        int l, r;
        cin >> l >> r;
        v[l]++;
        v[r+1]--;
    }
    for(int i=0; i<n; i++) v[i+1] += v[i];
    int ans = 0;
    for(int i=0; i<v.size(); i++) ans += (v[i] == m);
    cout << ans << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
import bisect

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word

def solve(N: int):
    tokens = iterate_tokens()
    colors_top = []
    for i in range(N):
        new = int(next(tokens))
        if colors_top:
            b = bisect.bisect_right(colors_top, -new)
            if b == len(colors_top):
                colors_top.append(-new)
            else:
                colors_top[b] = -new
        else:
            colors_top.append(-new)
    print(len(colors_top))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

int main() {
  long long N; cin >>N;
  long long kotae= LLONG_MAX;
  long long siraberu=1;
  while(siraberu){
    if(siraberu*siraberu>N)break;
    siraberu++;
  }
  long long i=1;
  long long j=N;
  for(i=1;i<siraberu;i++){
    if(N%i==0){
      j=N/i;
      kotae=min(kotae,i+j-2);
    }
  }
  cout <<kotae<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long T = sc.nextLong();
        long ans = T;
        long[] t = new long[N];
        for(int i=0;i<N;i++) t[i]=sc.nextLong();
        long end = T;
        for(int i=1;i<N;i++){
            if(t[i]>=end){
                ans+=T;
            }
            else{
                ans += T-(end-t[i]);
            }
            end = t[i]+T;
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 65548
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cassert>
#include<vector>
#include<deque>
using namespace std;
typedef pair<int,int> P;
int n,m,cnt;
int mincost[110][110];
bool visited[110][110];
int dx[2][6] = {{-1,+0,1,0,-1,-1},{+0,+1,1,1,0,-1}};
int dy[2][6] = {{-1,-1,0,1,+1,+0},{-1,-1,0,1,1,+0}};
bool f;
 
void dfs(int x,int y,int cost)
{
  //if(!f)
  //cout << "xy = "  << x << "," << y << " cost = " << cost << endl;
  for(int i=0;i<6;i++)
    {
      int nx = x + dx[y%2][i];
      int ny = y + dy[y%2][i];
      if(!(0 <= nx && nx < m && 0 <= ny && ny < n))
    continue;
      //if(!f)cout << "mincost["<<ny<<"]["<<nx<<"] = " << mincost[ny][nx] << " = cost + 1  = " << cost + 1  << endl;
      if(mincost[ny][nx] > cost+1)
    {
      if(!visited[ny][nx])
        cnt++;
      visited[ny][nx] = true;
      mincost[ny][nx] = cost + 1;
      dfs(nx,ny,cost+1);
    }
    }
}
 
int main()
{
  while(true)
    {
      cin >> m;
      if(!m) break;
      cin >> n;
      for(int i=0;i<n;i++) 
    for(int j=0;j<m;j++)
      mincost[i][j] = (1<<29);  
      f = true;
      int s,t,mex = 0;
      scanf("%d",&s);
      for(int i=0;i<s;i++)
    {
      int x,y;
      scanf("%d %d",&x,&y);
      x--,y--;
      mincost[y][x] = 0;
      dfs(x,y,0);
    }
      f = false;
      scanf("%d",&t);
      for(int i=0;i<t;i++)
    {   
      int pre_mincost[n][m];
      for(int j=0;j<n;j++)
        for(int k=0;k<m;k++)
          pre_mincost[j][k] = mincost[j][k],visited[j][k] = false;
      int p,q;
      scanf("%d %d",&p,&q);
 
      cnt = 1,p--,q--;
      mincost[q][p] = 0,visited[q][p] = true;
       
      dfs(p,q,0);
       
      mex = max(mex,cnt);
      for(int j=0;j<n;j++)
        for(int k=0;k<m;k++)
          mincost[j][k] = pre_mincost[j][k];
    }
      cout << mex << endl;
    }
  return 0;
}

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

using namespace std;

int main(void)
{
    string S;
    cin >> S;
    int sum = 0;
    for(int i=0; i<4; i++){
        if(S[i] == '+'){
            sum++;
        }else{
            sum --;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

long long a[50], b[50], c[50], d[50], e[10];
long long n, m, q, res = 0;

void check()
{
    //for (int i = 0; i < n; i++)
    //{
    //    std::cout << e[i] << " ";
    //}
    long long t = 0;
    for (int i = 0; i < q; i++)
    {
        if (e[b[i] - 1] - e[a[i] - 1] == c[i])
        {
            t += d[i];
        }
    }
    //std::cout << t << " F \n";
    if (t > res)
        res = t;
}

void dequy(long long k, long long max)
{
    if (k == n)
    {
        check();
        return;
    }
    for (int i = max; i <= m; i++)
    {
        e[k] = i;
        dequy(k + 1, i);
    }
}

int main()
{
    std::cin >> n >> m >> q;
    for (long long i = 0; i < q; i++)
    {
        std::cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dequy(0, 1);
    std::cout << res;
}

Measured memory_bytes: 3632
def main():
  n, m = map(int, input().split())
  
  dp = [0]*(2**n)
  len_dp = len(dp)

  key_list = dict()
  sub = 1
  for i in range(n):
    key_list[i+1] = sub
    sub *= 2

  for _ in range(m):
    a, b = map(int, input().split())
    c = [int(x) for x in input().split()]
    key = 0
    for value in c:
      key += key_list[value]
    for i in range(len_dp-1, -1, -1):
      if i == 0 or dp[i]:
        if dp[i|key]:
          dp[i|key] = min([dp[i]+a, dp[i|key]])
        else:
          dp[i|key] = dp[i]+a

  print(dp[len_dp-1] if dp[len_dp-1] else -1)

if __name__ == "__main__":
  main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))
    m = 1000
    k = 0

    for i in range(N-1):
        if A[i+1] - A[i] <= 0:
            continue
        
        k += m // A[i]
        m -= k * A[i]
        m += k * A[i+1]
        k = 0

    print(m)

main()

Measured memory_bytes: 9176