akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll a,b; cin >> a >> b;
    ll c = __gcd(a,b);
    vector<bool> x(1000001,0);
    for(int i=2;i<1000001;i++){
        while(c%i==0){
            c/=i;
            x.at(i) = 1;
        }
    }
    ll ans = 0;
    rep(i,1000001) if(x.at(i)==1) ans++;
    cout << ans + (c!=1) + 1 << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  int ans = 0;
  rep(i, N) {
    if (i < K)
      ans += X;
    else
      ans += Y;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/**
题意:给定目标串S(由小写字母构成),统计取出S的字符组成的不同串的个数;
define ：不同串:
              1 ：不同位置的相同字符
              2 ：一个串不存在相同的字符
思路:统计每个小写字母的数量,考虑每个字母存在 取1个与不取 的情况，累乘即可
最后去除空的情况
*/
 
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
 
const ll mod = 1e9+7;
const int maxn = 1e5+7;
ll sum[27];
 
int main (){
    int n;cin>>n;
    string s;cin>>s;
    memset(sum,0,sizeof(sum));
    for(int i=0;i<n;i++) sum[s[i]-'a']++;
    ll ans=1;
    for(int i=0;i<=26;i++) ans=ans*(sum[i]+1)%mod;
    ans=(ans-1+mod)%mod;
    cout<<ans<<endl;
    return 0;
}
 
 

Measured memory_bytes: 3724
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n;
    while (cin >> n, n) {
        vector<vector<int>> stage_time(n, vector<int>(n + 1));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= n; j++) cin >> stage_time[i][j];
        }
        vector<int> dp(1 << n, INF);
        dp[0] = 0;
        for (int cur = 1; cur < (1 << n); cur++) {
            for (int i = 0; i < n; i++) {
                int prev = cur & ~(1 << i);
                int best = stage_time[i][0];
                for (int j = 0; j < n; j++) if (prev & (1 << j)) {
                    best = min(best, stage_time[i][j + 1]);
                }
                dp[cur] = min(dp[cur], dp[prev] + best);
            }
        }
        cout << dp[(1 << n) - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3404
import java.util.Arrays;
import java.util.Scanner;
class Main{
	   public static void main(String[] args){
	  Scanner scan =  new Scanner(System.in);
	   int a = scan.nextInt();
       int b = scan.nextInt();
       int c = scan.nextInt();
       int f=0;
       int z =0;
       double g =0;
       double d[] = new double[a];
       int e=1;
       double x = 0;
       double y=0;
       for(int i=0;i<a;i++){
    	   d[i] = scan.nextDouble();
       }
       Arrays.sort(d);
       for(int i=0;i<=(a-1)/2;i++){
    	    g=d[i];
    	   d[i]=d[a-1-i];
    	   d[a-1-i]=g;
       }
       for(int i=0;i<b;i++){
    	   x =x+d[i]; 
       }
       System.out.println((double)x/b);
       for(int i=1;i<a;i++){
    	   if(d[0]==d[i]){
    		   e++;
    	   }
       }
       
       if(e<=b||c==b){
    	   for(int i=0;i<d.length;i++){
    		   if(d[b-1]==d[i]){
    			   f++;
    		   }}
        for(int i=0;i<b-1;i++){
    			   if(d[b-1]==d[i]){
    			   z++;
    		   }
    		 }
               double[] n =a(f);
               
               System.out.println((long)n[z+1]);
       }else{
    	   double[] t =a(e);
    	   for(int i=b;i<=c;i++){
                  if(i<=e){
    		   y = y + t[i];
    	   }}
    	   System.out.println((long)y);
       }
	   }
	
 
public static double[] a(int f) {
 
    double[] n = new double[1];
    n[0] = 1;
    for (int i = 0; i < f; i++) {
        n = n(n);
    }
 return n;
}
public static double[] n(double[] n) {
 
	        double[] is = new double[n.length + 1];
	        is[0] = n[0];
	        for (int i = 1; i < n.length; i++) {
	            is[i] = n[i - 1] + n[i];
	        }
	        is[is.length - 1] = 1;
	        return is;
	    
}}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

pair<ll, ll> divisor(ll n, ll a) {
  if (n >= 0) return {n / a, n % a};
  else {
    n = -n;
    if (n % a == 0) {
      return {-(n / a), 0};
    }
    else {
      return {-(n / a) - 1, a - n % a};
    }
  }
}

ll gcd(ll a,ll b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a%b);
}

int main() {
  ll n, x, d;
  cin >> n >> x >> d;

  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    }
    else {
      cout << n + 1 << endl;
    }
    return 0;
  }
  if (d < 0) {
    x *= -1;
    d *= -1;
  }
  vector<ll> minq(n + 1, 0), maxq(n + 1, 0);
  rep(i, n) {
    minq[i + 1] = minq[i] + i;
    maxq[i + 1] = maxq[i] + n - 1 - i;
  }
  ll series = 1;
  if (x != 0) series = d / gcd(abs(x), d);
  ll ans = 0;
  rep(i, series) {
    if (i > n) break;
    vector<pair<ll, ll>> sec;
    for (int j = i; j <= n; j += series) {
      pair<ll, ll> p = divisor(x * j, d);
      pair<ll, ll> res = make_pair(minq[j] + p.first, maxq[j] + p.first + 1);
      sec.push_back(res);
    }
    sort(sec.begin(), sec.end());
    if (sec.size() == 0) continue;
    ll pre = sec[0].first;
    rep(j, sec.size()) {
      if (sec[j].first >= pre) {
        ans += sec[j].second - sec[j].first;
        pre = sec[j].second;
      }
      else {
        if (pre < sec[j].second) {
          ans += sec[j].second - pre;
          pre = sec[j].second;
        }
      }
    }
  }
  cout << ans << endl;
  



  
  return 0;
}

Measured memory_bytes: 9584
N, Y = map(int, input().split())

# 10000, 5000, 1000

a = -1
b = -1
c = -1

for i in range(N + 1):
    for j in range(N + 1):
        # for k in range(N + 1):
        #     cnt = i + j + k
        #     cst = 10000 * i + 5000 * j + 1000 * k
        #     if cnt == N and cst == Y:
        #         a, b, c = i, j, k
        k = N - i - j
        if k >= 0:
            cst = 10000 * i + 5000 * j + 1000 * k
            if cst == Y:
                a, b, c = i, j, k

print(a,b,c)

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

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

    vector<char> ans = {};
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'B' && ans.size() > 0) {
            ans.erase(ans.begin() + ans.size() - 1);
        }
        else if (S[i] == 'B' && ans.size() == 0) {
            continue;
        }
        else {
            ans.push_back(S[i]);
        }
    }
    
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i];
    }
    cout << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;

int main(int argc, char *argv[]) {
    vector<int> costs = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    ll n, m;
    cin >> n >> m;
    vector<int> A(m);
    for (int i = 0; i < m; ++i) {
        cin >> A[i];
    }
    vector<int> dp(n + 1, -INF);
    dp[0] = 0;
    for (int i = 1; i <= n; ++i) {
        for (auto &a : A) {
            if (i - costs[a] >= 0 && dp[i - costs[a]] != -INF) {
                dp[i] = max(dp[i], dp[i - costs[a]] + 1);
            }
        }
    }
    sort(A.begin(), A.end(), greater<int>());
    int i = n;
    while (i) {
        if (dp[i] != -INF) {
            for (auto &a : A) {
                if (i - costs[a] >= 0 && dp[i] == dp[i - costs[a]] + 1) {
                    cout << a;
                    i -= costs[a];
                    break;
                }
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()
p = reads()

q = [0] * N
for i in range(N):
  q[p[i]-1] = i+1

a = [0] * N
b = [0] * N

a[0]  = 1
b[-1] = 1

for i in range(1, N):
  a[i] = a[i-1] + q[i]
  b[-1-i] = b[-i] + q[-1-i]

print(" ".join(str(x) for x in a))
print(" ".join(str(x) for x in b))
# print(" ".join(str(a[i] + b[i]) for i in range(N)))


Measured memory_bytes: 8568
from math import sin, cos, pi, sqrt

A, B, H, M = map(int,input().split())

t = M+60*H

pos_h = (A*cos(pi/2-2*pi*t/720), A*sin(pi/2-2*pi*t/720))
pos_m = (B*cos(pi/2-2*pi*t/60), B*sin(pi/2-2*pi*t/60))

#print(pos_h[0]-pos_m[0], pos_h[1]-pos_m[1])
print(sqrt((pos_h[0]-pos_m[0])**2+(pos_h[1]-pos_m[1])**2))

Measured memory_bytes: 9588
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9??§?????? auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

string s;
ll ans=0;
ll J,O,I;
int main()
{
	cin>>s;
	J=0;
	O=0;
	I=0;
	rep(i,s.size()){
		if(s[i]=='J'){
			if(i==0||s[i]!=s[i-1]){
				J=1;
			}
			else J++;
			O=0;
			I=0;
		}
		if(s[i]=='O'){
			I=0;
			if(i==0||s[i-1]=='I'||J==O){
				J=O=I=0;
			}
			else if(s[i-1]!='I'){
				O++;
			}
		}
		if(s[i]=='I'){
			if(i==0||s[i-1]=='J'||J==0||O==0){
				J=O=I=0;
			}
			else{
				I++;
				if(J>=O&&O<=I){
					ans=max(ans,O);
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3992
/*input
3 0
1000000000 1000000000 1000000000

*/
#include<bits/stdc++.h>
#define ull         unsigned long long
#define ll             long long
#define M             1000000007
#define pb             push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()    
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp             make_pair
#define lb             lower_bound
#define ub            upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)    for(ll int i=0;i<n;i++) a[i]=0;
#define F            first
#define S            second
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

bool DEBUG = 0;

void solve()
{
    //initialize();
    ll n,k;cin>>n>>k;
    vi a(n);
    rep(i,0,n)cin>>a[i];
    sort(all(a));
    ll ans = 0;
    for(int i=0;i<(n-k);i++)
        ans += a[i];
    cout<<ans<<"\n";
}


int main(void)
{
    ios
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 4720
#include <stdio.h>
int main() {
	int a;
	scanf("%d", &a);
	char s[10] = { 0 };
	scanf("%s", s);
	if (a >= 3200&&a < 5000) { printf("%s", s); }
	else if (a >= 2800 && a < 3200) { printf("red"); }
	else { return -1; }
	return 0;

}

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

int main() {
	string S, T;
	cin >> S >> T;

	int ans = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3928
/*  ex6_2
    Rikuta  */

#include <stdio.h>
#include <string.h>
#define LIM 101
int main(void){
    char word[LIM];
    scanf("%s",&word);
    printf("%c%d%c\n",word[0],(int)strlen(word)-2,word[strlen(word)-1]);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
      string s;
      cin >> s;
      if (s=="ABC")cout << "ARC" << endl;
      else if (s=="ARC") cout << "ABC" << endl;
 	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        long n, a, b;
        
        n = sc.nextLong();
        a = sc.nextLong();
        b = sc.nextLong();

        if (a > b){
            System.out.println(0);
            System.exit(0);
        }else if(n==1){
            if(a==b){
                System.out.println(1);
                System.exit(0);
            }
            else{
                System.out.println(0);
                System.exit(0);
            }
        }else{
            long length = n - 2;
            System.out.println(length*(b-a)+1);
        }
    }
}

Measured memory_bytes: 21844
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B = map(int, input().split())
    A = (14 if A == 1 else A)
    B = (14 if B == 1 else B)
    if A > B:
        print('Alice')
    elif A < B:
        print('Bob')
    else:
        print('Draw')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {
	int n;
	int counter;
	while (cin >> n) {
		if (n == 0) {
			break;
		}
		counter = 0;
		while (n != 1) {
			if (n % 2 == 0) {
				n /= 2;
			} else {
				n = n * 3 + 1;
			}
			counter++;
		}
		cout << counter << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define Mod 1000000009
#define N 1000010
#define M 101

typedef long long ll;

const int INF=1<<30;
int n,K,f,r;
char s[N];
bool flag;

void Work()
{
		if (flag)
		{
			if (s[f]=='A')
			{
				flag^=1;
				s[++r]='A';
				f++;
			}
			else s[f]='A';
		}
		else
		{
			if (s[f]=='A') s[f]='B';
			else
			{
				flag^=1;
				s[++r]='B';
				f++;
			}
		}
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	cin >> n >> K; scanf("%s",s);
	f=0,r=n-1;
	for (int i=1;i<=2*n;i++)
	{
		if (K==0) break; K--;
		Work();
	}
	if (K&1) Work();
	if (flag) for (int i=f;i<=r;i++) printf("%c",s[i]=='A'? 'B':'A');
	else for (int i=f;i<=r;i++) printf("%c",s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<ll> x(N);
    vector<ll> y(N);
    vector<ll> p, m;
    for(size_t i=0;i<N; i++)
    {
        cin >> x[i] >> y[i];
        p.push_back(x[i]+y[i]);
        m.push_back(x[i]-y[i]);
    }
    sort(p.begin(), p.end());
    sort(m.begin(), m.end());
    cout << max(p[N-1] - p[0], m[N-1] - m[0]) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 9800
import sys
input = sys.stdin.readline
N=int(input())
L=list(map(int,input().split()))
t=0
ans=0
l=0
r=0
while r<=N-1:
 if t+L[r]==t^L[r]:
  t+=L[r]
  r+=1
 else:
  ans+=(r-l)
  t-=L[l]
  l+=1
ans+=(r-l)*(r-l+1)/2
print(int(ans))

Measured memory_bytes: 23508
#include <cstdio>

int n, m, *a, rem;

int main() {
  scanf("%d%d", &n, &m);
  a = new int[n];
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    if(i) {
      if(a[i] + a[i - 1] >= m) {
        rem = i;
      }
    }
  }
  if(!rem) {
    puts("Impossible");
  }
  else {
    puts("Possible");
    for (int i = 1; i < n; ++i) {
      if(i < rem) {
        printf("%d\n", i);
      }
    }
    for (int i = n - 1; i; --i) {
      if(i > rem) {
        printf("%d\n", i);
      }
    }
    printf("%d\n", rem);
  }
  return 0;
}

Measured memory_bytes: 1152
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto ab = new int[][](n,2);
  foreach (i; 0..n) {
    ab[i] = readln.chomp.split.to!(int[]);
  }
  sort!((x,y)=>x[0] > y[0])(ab);
  writeln(ab[0][0]+ab[0][1]);
}


Measured memory_bytes: 19708
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll N, M;
ll dp[6005][2005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    dp[3*N+1][0] = 1;
    for(int i = 3*N+1; i >= 1; i--){
        for(int j = 0; j <= N; j++){
            dp[i-1][j] += dp[i][j];
            dp[i-1][j] %= M;
            if(j < N){
                if(i-2 >= 0){
                    ll c = i-2;
                    dp[i-2][j+1] += c*dp[i][j];
                    dp[i-2][j+1] %= M;
                }
                if(i-3 >= 1){
                    ll c = ((i-2)*(i-3))%M;
                    dp[i-3][j+1] += c*dp[i][j];
                    dp[i-3][j+1] %= M;
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i <= N; i++){
        ans += dp[1][i];
        ans %= M;
    }
    cout << ans << endl;
}

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

template<typename T> void print(const T & v);


int main() {
    double R;
    cin >> R;
    cout << fixed << setprecision(5) << R * 2 * M_PI << endl;
}






// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	LLI x;
	cin >> x;
	LLI t = 100;
	REP(i, 10000)
	{
		if (x <= t)
		{
			cout << i;
			return 0;
		}
		t += t * 0.01;

	}
	return 0;
}

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

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

	int64_t mod = 1000000007;

	auto pow_mod = [](int64_t a, int64_t n, int64_t mod) {
		int64_t ret = 1;
		for (; n; n >>= 1)
		{
			if (n & 1)
			{
				(ret *= a) %= mod;
			}
			(a *= a) %= mod;
		}
		return ret;
	};

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

	cout << ((pow_mod(10, n, mod) - 2 * pow_mod(9, n, mod) % mod + mod) % mod + pow_mod(8, n, mod)) % mod << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := its root and abs-value is its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
}; // END class UnionFind

int main(){
  int n;
  while(cin>>n, n){
    vector<string> vec(n);
    rep(i,n) cin>>vec[i];
    vector<int> in(26,0), out(26,0);
    UnionFind uf(26);
    rep(i,n){
      int s=vec[i][0]-'a', t =vec[i][vec[i].size()-1]-'a';
      out[s]++;
      in[t]++;
      uf.unite(s,t);
    }

    bool ok=true;
    int sz=0;
    rep(i,26){
      if(in[i]!=out[i]) ok=false;
      if(in[i]>0) sz++;
    }
    if(uf.size(vec[0][0]-'a')!=sz) ok=false;

    if(ok) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3740
K, N = map(int, input().split())

A = list(map(int, input().split()))

rec = list()

rec.append(A[0] + K - A[-1])

for i, _ in enumerate(A[:-1]):
    rec.append(A[i+1] - A[i])

sum = 0
for r in rec:
    sum += r

max_r = max(rec)
print(sum - max_r)


Measured memory_bytes: 26444
#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

int main()
{
	string S;
	int count = 0;
	cin >> S;
	for (int i = 0; i < (int)S.size(); i++) {
		if (S[i] == 'h' && S[i + 1] == 'i') {
			count++;
		}
	}
	if ((S.size() + 1) / 2 == count) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int main(){
  string s;
  cin>>s;
  int n = s.size();
  if(s[n-1]=='s')cout<<s<<"es";
  else cout<<s<<"s";

}


Measured memory_bytes: 3624
#include <iostream>
int getgcd(int n, int m)
{
    int r;
    if (n > m)
    {
        int t = m;
        m = n;
        n = t;
    }
    while ((r = m % n) != 0)
    {
        m = n;
        n = r;
    }
    return n;
}

int main(void)
{
    int k = 0;
    scanf("%d", &k);

    int sum = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                sum += getgcd(getgcd(a, b), c);
            }
        }
    }
    printf("%d", sum);
    return 0;
}

Measured memory_bytes: 3744
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>p(n);
    rep(i, n) cin >> p[i];
    //
    ll ans = 0;
    rep(i,n-2)
    {
        ll p0 = p[i];
        ll p1 = p[i + 1];
        ll p2 = p[i + 2];
        ll mn = min({ p0,p1,p2 });
        ll mx = max({ p0,p1,p2 });
        if (p1 != mn && p1 != mx)
        {
            ++ans;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3648
object Main {
    def gcd (x : Int, y : Int) : Int = {
        if (y > x) gcd (y, x)
        else if (x % y == 0) y else gcd(y, x % y)
    }
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val n, x = sc.nextInt
        val xs = List.fill(n)(sc.nextInt)
        
        val ds : List[Int] = xs.map(y => math.abs(x - y))
        val ans = ds.fold(ds(0))(gcd(_, _))
        println(ans)
    }
}

Measured memory_bytes: 61536
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x7fffffff
#define INFL 0x7fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> n;


	printf("%lf\n", (double)n*2*M_PI);

}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
        int x,a,b,c;
        while(cin>>a>>b>>c>>x){
            x/=50;
            int sum=0;
            for(int i=0;i<=a;i++){
                for(int j=0;j<=b;j++){
                    for(int k=0;k<=c;k++){
                        if(i*10+j*2+k==x) sum++;
                    }
                }
            }
            cout<<sum<<endl;
        }
        return 0;
    }

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

public class Main {

    private static int baseNum = 100;

    public static void main(String[] args) throws Exception {
	    String line = Io.read();
	    int[] parsed = parse(line);

        int answer = 1;

        for (int i = 0; i < parsed[0]; i++) {
            answer *= baseNum;
        }
        int multi = 0;
        if (parsed[1] == 100) {
            multi = 101;
        } else {
            multi = parsed[1];
        }

        answer *= multi;

        Io.write(answer);
    }

    private static int[] parse(String line) {
        String[] strs = line.split(" ");
        int[] parsed = new int[strs.length];

        for (int i = 0; i < strs.length; i++) {
            parsed[i] = Integer.parseInt(strs[i]);
        }
        return parsed;
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        return line;
    }

    /**
     * 標準出力
     * @param answer
     */
    public static void write(int answer)
    {
        System.out.println(answer);
    }
}

Measured memory_bytes: 21332
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a; cin >> a;
    string S;cin >> S;
    if (a >= 3200) cout << S << endl;
    else cout << "red" << endl;

    return 0;
}


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

int main()
{
  int r, c;
  cin >> r >> c;

  vector< vector<int> > vec;
  vec.resize( r + 1 );
  for( int i = 0; i < r + 1; i++ ) {
    vec[ i ].resize( c + 1 );
  }

  for( int i = 0; i < r; i++ ) {
    for( int j = 0; j < c; j++ ) {
      cin >> vec[ i ][ j ];
    }
  }

  for( int i = 0; i < c; i++ ) {
    int sum = 0;
    int j;
    for( j = 0; j < r; j++ ) {
      sum += vec[ j ][ i ];
    }
    vec[ j ][ i ] = sum;
  }

  for( int i = 0; i < r + 1; i++ ) {
    int sum = 0;
    for( int j = 0; j < c + 1; j++ ) {
      if( j != 0 ) {
        cout << " ";
      }
      if( j == c ) {
        vec[ i ][ j ] = sum;
      }
      else {
        sum += vec[ i ][ j ];
      }
      cout << vec[ i ][ j ];
    }
    cout << endl;
  }
  return 0;
}

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

int64_t mod=1e9+7;

int64_t modpow(int64_t a,int64_t n){
  int64_t res=1;
  while(n>0){
    if(n&1){
      res*=a;
      res%=mod;
    }
    a*=a;
    a%=mod;
    n>>=1;
  }
  return res;
}

int64_t modinv(int64_t a){
  return modpow(a,mod-2);
}

// int64_t comb(int64_t n,int64_t r){
//   int64_t res=1;
//   for(int i=1;i<=r;i++){
//     res*=((n-i+1)*modinv(i))%mod;
//     res%=mod;
//   }
//   return res;
// }
int64_t comb(int64_t n,int64_t r){
  if(r==0){
    return 1;
  }
  return (((n-r+1)*modinv(r))%mod*comb(n,r-1))%mod;
}

int main(){
  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t ans=0;
  ans=modpow(2,n)-1;
  ans-=comb(n,a);
  ans%=mod;
  if(ans<0){
    ans+=mod;
  }
  ans-=comb(n,b);
  ans%=mod;
  if(ans<0){
    ans+=mod;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> edges;
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            if (n & 1 && j == n - i) continue;
            if (!(n & 1) && j == n - i + 1) continue;
            edges.push_back({i, j});
        }
    }
    cout << edges.size() << endl;
    for (auto v : edges) {
        cout << v[0] << " " << v[1] << endl;
    }
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
#define N 105
#define INF 1<<21
int n;
int a[N][N];
int d[N],p[N];
int color[N];
void dijksla(){
	int minv;
	for (int i = 0;i < n;i++){
		d[i] = INF;
		color[i] = 0;
	}
	d[0] = 0;
	while (1){
		minv = INF;
		int u = -1;
		for (int i = 0;i < n;i++){
			if (minv > d[i] && color[i] != 1){
				u = i;
				minv = d[i];
			}
		}
		if (u == -1) break;
		color[u] = 1;
		for (int v = 0;v < n;v++){
			if (color[v] == 0 && a[u][v] != INF){
				if (d[v] > d[u] + a[u][v]){
					d[v] = d[u] + a[u][v];
				}
			}
		}
	}
	for (int i = 0;i < n;i++){
		if (d[i] == INF){
			cout << i << " -1" << endl;
		}
		else{
			cout << i << " " << d[i] << endl;
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 0;i < n;i++){
		for (int j = 0;j < n;j++){
			a[i][j] = INF;
		}
	} 
	int x,m,y,q;
	for (int i = 0;i < n ;i++){
		cin >> x >> m;
		for (int j = 0;j < m;j++){
			cin >> y >> q;
			a[x][y] = q;
		}
	}
	dijksla();
	return 0;
 } 


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

int main() {
  int n, k;
  cin>>n>>k;
  long long cnt = 0;
  for (int b=k+1; b<=n; b++) {
    cnt += ((n - b) / b + 1) * (b - k);
    if (k == 0) {
      --cnt;
    }
    cnt += max(n % b - k + 1, 0);
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
var main = standardInput => {
  var ary = standardInput.split(" ");
  ary = ary.map((v)=>{
    return parseInt(v,10);
})
  if (ary[0] < ary[2] && ary[2] < ary[1]) {
    console.log("Yes");
  } else if (ary[0] > ary[2] && ary[2] > ary[1]) {
    console.log("Yes");
  } else {
    console.log("No");
  }
};
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

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

int main() {
  int n; cin >> n;
  vector<pair<pair<string, int>, int>> p(n);
  rep(i,n) {
    string s; int k;
    cin >> s >> k;
    p[i] = make_pair(make_pair(s, -k), i);
  }
  sort(p.begin(), p.end());
  rep(i,n) {
    cout << p[i].second+1 <<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int i,j,k,n,u,l,v,M[100][100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j>0){
        printf(" ");
      }
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 1812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n,h;
  cin >> n >> h;
  vector<pair<ll,ll>> katana;
  ll th = 0;
  for(int i = 0;i < n;i++){
    ll a,b;
    cin >> a >> b;
    th += b;
    katana.push_back(make_pair(a,0));
    katana.push_back(make_pair(b,1));
  }
  ll res = 0;
  sort(katana.begin(),katana.end());
  ll now = 0;
  for(int i = katana.size() - 1;i >= 0;i--){
    if(katana[i].second == 1){
      now += katana[i].first;
      res++;
      if(h <= now){
        break;
      }
    }
    else{
      res += (h - now) / katana[i].first;
      if((h - now) % katana[i].first != 0)res++;
      break;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int s[10]={0};
	s[a]++;
	s[b]++;
	s[c]++;
	s[d]++;
	if(s[1] && s[9] && s[7] && s[4])
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int get(int n) {
    if (n == 2) {
        return 0;
    } else if (n == 4 || n == 6 || n == 9 || n == 11) {
        return 1;
    } else {
        return 2;
    }
}

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H + 2, vector<char>(W + 2, '#'));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> a[i + 1][j + 1];
        }
    }

    for (int i = 0; i < H + 2; i++) {
        for (int j = 0; j < W + 2; j++) {
            cout << a[i][j];
        }
        cout << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265358979
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Graphi = vector<vi>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};

int main(){

    ll s; cin >> s;
    ll k = (s-1)/1000000000+1;
    cout << 0 sp 0 sp 1000000000 sp 1000000000*k-s sp 1 sp k << endl;

    return 0;

}

Measured memory_bytes: 256
package main
import "fmt"
type Pos struct{
	x, y int
}
func main(){
	var H, W int
	fmt.Scan(&H, &W)
	T := make([][]string, H)
	for i:=0; i<H; i++{
		T[i] = make([]string, W)
		var line string
		fmt.Scan(&line)
		for j, c := range []rune(line){
			T[i][j] = string(c)
		}
	}
	poss := []Pos{Pos{y: 0, x: 0}}
	steps := []int{0, 1, 0}
	flag := false
	for len(poss)>0 && !flag{
		p := poss[len(poss)-1]
		poss = poss[:len(poss)-1]
		for i:=0; i<len(steps)-1; i++{
			nx, ny := p.x+steps[i], p.y+steps[i+1]
			if nx<W && ny<H && T[ny][nx] == "#"{
				T[p.y][p.x] = "済"
				if ny==H-1 && nx==W-1{
					T[ny][nx] = "済"
					flag = true
					break
				}
				poss = append(poss, Pos{y: ny, x: nx})
			}
		}
	}
	for i:=0; i<H; i++{
		for j:=0; j<W; j++{
			if T[i][j] == "#"{
				fmt.Println("Impossible")
				return
			}
		}
	}
	fmt.Println("Possible")
}

Measured memory_bytes: 1840
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;

void solve(){
	ll a,b;
	cin>>a>>b;
	ll g = __gcd(a,b);
	int ans=1;
	int f;
	for(ll i=2; i*i <= g; i++){
		f=0;
		while(g% i == 0){
			if(f==0) ans++;
			f = 1;
			g = g/i;
		}
	}
	if(g != 1) ans++;
	cout<<ans;

}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 256
//@HelloElwin-20190817
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

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

	for (int i = max(-1000000, b - a + 1); i <= min(1000000, a + b - 1); i++) {
		printf("%d ", i);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();

    bool fl = false;

    for (int i = 0; i < n; i++) {
        string f = s.substr(n-i, i);
        string e = s.substr(0, n-i);
        string sp = f + e;
        if (sp == t) fl = true;
    }

    if (fl) cout << "Yes" << endl;
    else cout << "No" << endl;
    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 N = sc.nextInt();
        long K = sc.nextLong();
        long[] A = new long[N];
        long[] F = new long[N];
        long allcost = 0;

        for(int i=0; i<N; i++){
            A[i]=sc.nextLong();
            allcost = allcost + A[i];
        }

        for(int i=0; i<N; i++){
            F[i]=sc.nextLong();
        }

        if(allcost<=K){
            System.out.println(0);
            return;
        }
        Arrays.sort(A);
        Arrays.sort(F);

       long ok = A[N-1]*(long)F[N-1];
        long ng = 0;

        while(ok-ng>1){
            long h = (ok+ng)/2;
            long tot = 0;
            for(int i=0; i<N; i++){
                tot = tot+Math.max(A[N-i-1]-h/F[i], 0);
            }
            if(tot>K){
                ng = h;
            }else{
                ok = h;
            }
        }
        System.out.println(ok);
        
    }
}


Measured memory_bytes: 64360
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int h,w;char s[1001][1001];int dis[1001][1001];
int main()
{
	scanf("%d%d",&h,&w);for(int i=1;i<=h;++i)scanf("%s",s[i]+1);memset(dis,0x3f,sizeof(dis));dis[1][1]=0;
	for(int i=1;i<=h;++i)
	{
		for(int j=1;j<=w;++j)
		{
			if(i>1)dis[i][j]=min(dis[i][j],dis[i-1][j]+(s[i-1][j]!=s[i][j]));
			if(j>1)dis[i][j]=min(dis[i][j],dis[i][j-1]+(s[i][j-1]!=s[i][j]));
		}
	}
	if(s[1][1]=='#'&&s[h][w]=='#'){printf("%d\n",dis[h][w]/2+1);}
	else if(s[1][1]=='.'&&s[h][w]=='#'||s[1][1]=='#'&&s[h][w]=='.')printf("%d\n",(dis[h][w]+1)/2);
	else printf("%d\n",dis[h][w]/2);return 0;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }else if(a > b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int N,M,x;
    cin >> N;
    int s[N],l[N],p[N];
    for(int i = 0 ; i < N ; i++){
        cin >> s[i] >> l[i] >> p[i];
    }
    int dp[500] = {0};
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 500 ; j++){
            for(int k = s[i] ; k <= l[i] ; k++){
                if(j + k >= 500) continue;
                dp[j+k] = max(dp[j+k],dp[j]+p[i]);
            }   
        }
    }
    cin >> M;
    vector<int> res(M);
    bool check = 0;
    for(int i = 0 ; i < M ; i++){
        cin >> x;
        res[i] = dp[x];
        if(res[i] == 0) check = 1;
    }
    if(check){
        cout << -1 << endl;
    }else{
        for(auto v : res){
            cout << v << endl;
        }
    }   
    return 0;
}

Measured memory_bytes: 3120
package main

import (
	"fmt"
	"sort"
)

const D int = 1e9 + 7

func main() {
	var N int
	fmt.Scan(&N)
	C := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&C[i])
	}
	sort.Ints(C)

	// comb := make([][]int, N)
	// for i := 0; i < N; i++ {
	// 	comb[i] = make([]int, i+1)
	// 	for j := 0; j <= i; j++ {
	// 		if i == 0 || j == 0 || i == j {
	// 			comb[i][j] = 1
	// 		} else {
	// 			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % D
	// 		}
	// 	}
	// }

	// G := make([]int, N)
	// for p := 0; p < N; p++ {
	// 	for k := 0; k <= p; k++ {
	// 		G[p] = (G[p] + (k+1)*comb[p][k]) % D
	// 	}
	// }

	// H := make([]int, N)
	// for p := 0; p < N; p++ {
	// 	H[p] = G[N-p-1]
	// 	for k := 0; k < p; k++ {
	// 		H[p] = (H[p] * 2) % D
	// 	}
	// }

	H := make([]int, N)
	if N == 1 {
		H[0] = 1
	} else {
		h := 1
		for i := 0; i < N-2; i++ {
			h = (h * 2) % D
		}
		for i := 0; i < N; i++ {
			H[i] = ((N + 1 - i) * h) % D
		}
	}

	S := 0
	for i := 0; i < N; i++ {
		S = (S + C[i]*H[i]) % D
	}
	for i := 0; i < N; i++ {
		S = (S * 2) % D
	}

	fmt.Println(S)
}


Measured memory_bytes: 6656
#include <iostream>
#include <vector>
#include <utility>

void print(std::vector<int> &vec){
    for(int i = 0; i < vec.size(); ++i){
        std::cout << vec.at(i);
        if(vec.size() - 1 != i){
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
}

void insertionSort(std::vector<int> &vec){
    // This function sorts the partial array from the index "0" to "i" at each step.
    // In the loop where the "i + 1" th value is considered, the value will be inserted in a proper place in the "0-i" array or its end.
    for(int i = 1; i < vec.size(); ++i){
        auto v = vec.at(i), j = i - 1;
        while(0 <= j && v < vec.at(j)){
            vec.at(j + 1) = vec.at(j);
            --j;
        }
        // Because of "--j" at the end of the while loop, j indicate the index prior to the target place by 1.
        // Hence, j has to be incremented before the "v" is inserted in the proper place.
        vec.at(j + 1) = v;

        print(vec);
    }
}

int bubbleSort(std::vector<int> &vec){
    bool flg = true;
    int count = 0;
    while(flg){
        flg = false;
        // Compare the array in a reverse order
        for(int i = vec.size() - 1; 0 < i; --i){
            if(vec.at(i) < vec.at(i - 1)){
                std::swap(vec.at(i), vec.at(i - 1));
                flg = true; // If some two elements will be swapped, the next while loop will be activated.
                ++count;
            }
        }
    }

    return count;
}

int selectionSort(std::vector<int> &vec){
    int n = vec.size(), count = 0;
    for(int i = 0; i < n; ++i){
        auto minJ = i;
        for(int j = i; j < n; ++j){
            if(vec.at(j) < vec.at(minJ)){
                std::swap(j, minJ);
            }
        }

        if(i != minJ){
            std::swap(vec.at(i), vec.at(minJ));
            ++count;
        }
    }

    return count;
}

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

    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        std::cin >> a.at(i);
    }

    // for alds1_1_a.cpp
//    print(a);
//    insertionSort(a);

    // for alds1_2_a.cpp
//    auto val = bubbleSort(a);
//    print(a);
//    std::cout << val << std::endl;

    // for alds1_2_b.cpp
    auto val = selectionSort(a);
    print(a);
    std::cout << val << std::endl;
    
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

int main(){
	string s;
	cin>>s;
	bool ok1=false,ok2=false;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B')ok2=true;
		else ok1=true;
	}
	if(ok1&&ok2)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int K,A,B,i,s,flag=0;
    scanf("%d %d %d", &K,&A,&B);


    for(i=A; i<=B; i++)
    {

        if(i%K==0)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        printf("OK\n");
    else
        printf("NG\n");

    return 0;
}

Measured memory_bytes: 1620