akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, k;
	cin >> n >> k;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int ans = 0;
	rep(i, k) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3600
import java.util.*;
    public class Main {// Main
        public static void main(String[] args){
            Scanner scanner = new Scanner(System.in);
            int x = scanner.nextInt();
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int y = (x-a);
            int n = (y/b);
            int f = y-(n*b);
            System.out.println(f);
}
}

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

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

  // Input
  int n;
  cin >> n;

  int answer;
  if (n%2==0) {
    answer = n;
  } else {
    answer = n * 2;
  }

  // Output
	cout << answer << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,n;
  cin>>n;
  int a[n];
  for(i=1;i<=n;i++)
  {
      cin>>a[i];
  }
  int j,sum=0;
  for(i=1;i<n;i++)
  {
      for(j=i+1;j<=n;j++)
      {
          sum=sum+(a[i]*a[j]);
      }
  }
	cout<<sum;
	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
x = [0 for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    x[a - 1] = max(x[a - 1], h[b - 1])
    x[b - 1] = max(x[b - 1], h[a - 1])
ans = sum(list(map(lambda i: 1 if x[i] < h[i] else 0, range(n))))
print(ans)

Measured memory_bytes: 85068
from collections import defaultdict
import time
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = []
start = time.time()
group = [0] * n

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl.append((a,b))


g_num = 0
for i in range(n):
    if group[i] != 0:
        continue
    g_num += 1
    unvisited = set({i})
    while len(unvisited) > 0:
        v = unvisited.pop()
        group[v] = g_num
        for w in fr[v]:
            if group[w] > 0 or w in unvisited:
                continue
            unvisited.add(w)

group_size = defaultdict(int)
for x in group:
    group_size[x] += 1

bl_in_group = [0] * n
for a,b in bl:
    if group[a] == group[b]:
        bl_in_group[a] += 1
        bl_in_group[b] += 1

for i in range(n):
    print(group_size[group[i]] - len(fr[i]) - bl_in_group[i] - 1, end=' ')

print()

Measured memory_bytes: 76392
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chkmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chkmax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef long long ll;

const int INF = 1001001001;
const int MAX_N = 100000 + 10;
int dp[MAX_N][2];

int N, M;
vector<int> g[MAX_N];
vector<int> path;
bool vis[MAX_N];

void dfs(int p) {
  vis[p] = true;
  path.emplace_back(p);
  for (auto x : g[p]) {
    if (!vis[x]) {
      dfs(x);
      break;
    }
  }
}
int main2() {
  REP(i, MAX_N) g[i].clear();
  memset(vis, 0, sizeof(vis));

  scanf("%d%d", &N, &M);
  REP(i, M) {
    int a, b; scanf("%d%d", &a, &b);
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }

  path.clear();
  dfs(0);
  reverse(path.begin(), path.end());
  path.pop_back();
  vis[0] = false;
  dfs(0);

  printf("%d\n", (int)path.size());
  REP(i, path.size()) {
    if (i > 0) printf(" ");
    printf("%d", 1 + path[i]);
  }
  printf("\n");
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout << min(a,b)+min(c,d) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
using namespace std;
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int main() {
	int n;
	cin >> n;
	n %= 10;
	if (n == 3)
		cout << "bon" << endl;
	else if (n == 0 || n == 1 || n == 6 || n == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define pi acos(-1)
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<int, int> PII;

inline void quickread(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int pow(int a, int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}

int pow(int a, int b, int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}
const int maxn = 100000 + 5;

int main()
{
    quickread();
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        if(i * 2 + (x - i)*4 == y){
            cout <<"Yes";
            return 0;
        }
    }
    cout <<"No";
    return 0;
}

Measured memory_bytes: 3616
#include<cstdio>

int main(){
  int h,w;
  char a[200][200];
  scanf("%d %d", &h,&w);
  for(int i=0;i<h;i++){
    scanf("%s", a[i]);
  }
  for(int i=0;i<w;i++){
    printf("#");
  }
  printf("##\n");

  for(int i=0;i<h;i++){
    printf("#");
    printf("%s",a[i]);
    printf("#\n");
  }

  for(int i=0;i<w;i++){
    printf("#");
  }
  printf("##\n");

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define pb push_back


///Input/Output macros!
#define gi(x) scanf("%d", &x)
#define gi2(x, y) scanf("%d%d", &x, &y)
#define gi3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define gill(x) scanf("%lld", &x)
#define gill2(x, y) scanf("%lld%lld", &x, &y)
#define gill3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define pi(x) printf("%d\n", x)
#define pill(x) printf("%lld\n", x)


///Basic Debugging macros!
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(ll __i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(ll __i__=0;__i__<r;__i__++){for(ll __j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}

using namespace std;

///Power of 2 till 2^31!
ll pow2[32] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648};

///Power function!
ll power(ll x,ll y)
{
        ll res = 1;
        while(y>0){
            if(y&1)
                res *= x;
            y>>=1;
            x*=x;
        }
        return res;
}

///Basic Sieve of Eratosthenes!
void Sieve(ll n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (ll i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (ll p=2; p<=n; p++)
       if (prime[p])
        cout<<p<<' ';
          //cout <<  << " ";
}

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

bool isPerfectSquare(ll x){ ll s = sqrt(x); return (s*s == x);}

bool isFibonacci(int n){return isPerfectSquare(5*n*n + 4) || isPerfectSquare(5*n*n - 4);}

bool isPrime(int n){if (n <= 1)return false;if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0)return false;
    return true;
}

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;


const int MOD = 1000000007;
const long double PI = 4*atan((long double)1);
const ll INF = 1e18;


int main()
{
    ios::sync_with_stdio(false);
    int d1,m1,d2,m2;
    cin>>m1>>d1>>m2>>d2;
    map<int,int> mp;
    mp[1] = 31;
    mp[2] = 28;
    mp[3] = 31;
    mp[4] = 30;
    mp[5] = 31;
    mp[6] = 30;
    mp[7] = 31;
    mp[8] = 31;
    mp[9] = 30;
    mp[10] = 31;
    mp[11] = 30;
    mp[12] = 31;
        if(mp[m1]==d1){
            cout<<1<<'\n';
            return 0;
        }
    cout<<0<<'\n';
    return 0;
}


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

using namespace std;

signed main()
{
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int k;
    cin >> s >> k;
    int n = s.size();
    for(int i = 0; i < n; i++)
    {
        s[i] -= 'a';
        if(k >= (26 - s[i]) % 26)
        {
            k -= (26 - s[i]) % 26;
            s[i] = 0;
        }
    }
    if(k > 0)
    {
        s[n - 1] += k % 26;
    }
    for(auto &it: s)
    {
        it += 'a';
        cout << it;
    }
    return 0;
}


Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <map>

int main() {

    int N, M;
    char a, b;

    while(1) {
        std::cin >> N;
        if (N == 0) break;
        std::string str = "";
        std::map<char, char> dic;
        for (int i = 0; i < N; i++) {
            std::cin >> a >> b;
            dic.insert({a, b});
        }
        std::cin >> M;

        for (int i = 0; i < M; i++) {
            std::cin >> a;
            if (dic.find(a) == dic.end()) {
                str += a;
            } else {
                str += dic[a];
            }
        }
        std::cout << str << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3336
//一点更新、区間取得を求めるBIT
#include<bits/stdc++.h>
using namespace std;
struct BinaryIndexedTree{
    int N;
    vector<int> bit;
    //全て0で初期化
    BinaryIndexedTree(int size){
        bit.resize(size+1,0);
        N=size+1;
    }
    //bit[a]に値wを加える。O(log n)
    void add(int a,int w){
        for(int x=a;x<=N;x+=(x & -x)) bit[x]+=w;
        return;
    }
    //bit[1,a]の和bit[1]+bit[2]+   +bit[a]を求める。 O(log n)
    int sum(int a){
        int ret=0;
        for(int x=a;x>0;x-=(x & -x)) ret+=bit[x];
        return ret;
    }
};

//動作確認はAOJ DSL 2 B Range Sum Query(RSQ)にて行いました。
int main(){
    int n,q;
    cin>>n>>q;
    BinaryIndexedTree BIT(n+5);
    int com,x,y;
    for(int i=0;i<q;i++){
        cin>>com>>x>>y;
        if(com==0){
            BIT.add(x,y);
        }
        else{
            cout<<BIT.sum(y)-BIT.sum(x-1)<<'\n';
        }
    }
    return(0);
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

ll dfs(int K, vector<vector<int>> &graph, int from, int now)
{
  int usable_color;
  if (from == -1)
  {
    usable_color = K - 1;
  }
  else
  {
    usable_color = K - 2;
  }

  ll comb = 1;
  for (auto next : graph.at(now))
  {
    if (next == from)
      continue;
    comb *= usable_color--;
    comb %= mod;
  }
  for (auto next : graph.at(now))
  {
    if (next == from)
      continue;
    comb *= dfs(K, graph, now, next);
    comb %= mod;
  }
  return comb;
}

int main()
{
  int N, K;
  cin >> N >> K;
  vector<vector<int>> graph(N);
  for (int i = 1; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph.at(a).push_back(b);
    graph.at(b).push_back(a);
  }
  ll ans;
  ans = K * dfs(K, graph, -1, 0) % mod;
  cout << ans << endl;
}

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

int A,B,N;

int main(){
  //cin >> N;
  cin >> A >> B;
  if(A % B == 0) cout << A / B << endl;
  else  cout << A / B + 1 << endl;
  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++)

int main(){
  int a,b;
  cin >> a >> b;
  
  int n=b-a, x=0;
  rep(i,n) x += i;
  x -= a;
  cout << x << endl;
  
  return 0;

}


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> vec(12,vector<int>(10));

  for(int i = 0; i < N; i++){
    int b, f, r, v; //b棟f階のr番目の部屋にv人が追加で入居
    cin >> b >> f >> r>> v;
    
    if(b==1) vec.at(3*b+f-4).at(r-1)+=v;
    else if(b==2) vec.at(3*b+f-4).at(r-1)+=v;
    else if(b==3) vec.at(3*b+f-4).at(r-1)+=v;
    else vec.at(3*b+f-4).at(r-1)+=v;
   }
  
  for(int i=0; i<12;i++){
    for(int j=0; j<10;j++){      
      cout << " " << vec.at(i).at(j);
      if(j ==9) cout << endl;
    }
    if((i+1)%3==0 && i!=11) cout << "####################"<<endl;
  } 
}


Measured memory_bytes: 3152
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    
    int[] price = new int[N];
    for(int i=0;i<N;i++){
      price[i] = sc.nextInt();
    }
    
    Arrays.sort(price);
    
    int money = 0;
    for(int i=0;i<K;i++){
      money = money + price[i];
    }
    
    System.out.println(String.valueOf(money));
  }
}

Measured memory_bytes: 38652
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int num[3],n;
  cin >> n;
  for(int i= 0;i<n;i++){
    cin >> num[0] >> num[1] >> num[2];
    sort(num,num+3);
    if((num[1] * num[1]) + (num[0] * num[0]) == num[2] * num[2]){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
    
  }
}

Measured memory_bytes: 1168
N=int(input())
ff=list(map(int,input().split()))
ss=[0]*(N+1)
ans=ss[0]=ff[0]
nss=1
for f in ff[1:]:
  if f==ss[nss-1]: continue
  if f>ss[nss-1]: 
    ans+=(f-ss[nss-1])
    ss[nss]=f; nss+=1
    continue
  t=nss;
  while t>0 and f<ss[t-1]: t-=1
  ss[t]=f; nss=t+1
print(ans)


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

int n, i, j, k, a[100009][3], dp[100009][3];

int main()
{
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        for(j = 0; j < 3; j++)
            cin >> a[i][j];
    }

    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(i = 1; i <= n; i++)
    {
        for(j = 0; j < 3; j++)
        {
            dp[i][j] = -1;
            for(k = 0; k < 3; k++)
            {
                if(j == k)
                    continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> v(3e5,0);
    int cnt = 1;
    int si = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] != s[i -1]) {
            v[si] = cnt;
            cnt = 1;
            si++;
        }else {
            cnt++;
        }
    }
    v[si] = cnt;
    si++;
    int a = 0;
    if (s[0] == '1') a++;
    int sa = 0;
    int sb;
    int sc;
    int ans = 0;
    rep(i, 2+2*(k-1)) sa += v[i];
    sb = v[2*k];
    ans = sa + sb*a;
    for (int i = 1; i< si; i++) {
        //cout << ans << endl;
        sa += v[i + 1 + 2*(k-1)] - v[i-1];
        sb = v[2*k + i];
        ans = max(ans, sa + sb*((a+i)%2));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4472
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 


signed main(){
    FASTER;
    int n,m;cin>>n>>m;
    vi a(n),pre(n);cin>>a;
    sort(all(a));
    pre=a;
    for(int i=1;i<n;i++)pre[i]+=pre[i-1];

    
    vii v(m);cin>>v;
    
    sort(all(v),[](pii a,pii b){return a.second>b.second;});
    
    int st=0,sum=pre[n-1];
    for(int i=0;i<m;i++){
        int id=upper_bound(a.begin()+st,a.end(),v[i].second)-a.begin();
        if(id!=st){
            id--;
            //st to id
            if(id-st+1>v[i].first)id=st+v[i].first-1;
            sum-=(pre[id]-pre[st]+a[st]);
            sum+=(id-st+1)*v[i].second;
            st=id+1;
        }
    }
    cout<<sum;
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define loop(i,k,n) for (ll i = k ; i < n ; ++i)
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    int n;
    cin >> n;
    int t = 0 , ans = 0;
    while (t % 360 || !ans){
        t += n;
        ans++;
    }
    cout << ans;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<endl)
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


Measured memory_bytes: 3592
N = int(input())

counter = [[0]*10 for _ in range(10)]

# 先頭末尾の組み合わせを数える
for i in range(1,N+1):
    x = str(i)
    counter[int(x[0])][int(x[-1])] += 1

ans = 0

# (先頭末尾)と(末尾先頭)の組み合わせ
for i in range(10):
    for j in range(10):
        ans += counter[i][j] * counter[j][i]
        
print(ans)

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

int main(){
	string str;
	getline(cin,str);
	str += str;
    string check;
	getline(cin,check);
 	if(str.find(check) <= str.length()){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}	
	return 0;
}

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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> ans(3, 0);
    int x;
    for (int i = 0; i < n; i++){
        cin >> x;
        if (x <= a) ans[0]++;
        else if (x <= b) ans[1]++;
        else ans[2]++;
    }
    cout << *min_element(ans.begin(), ans.end()) << endl;
}

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

using namespace std;

const int MAXN = 1e5 + 2;
int n, m, num[MAXN];
bool red[MAXN];

int main()
{
    cin >> n >> m;
    fill(num + 1, num + n + 1, 1);
    red[1] = true;
    for(int i = 0;i < m;i++)
    {
        int x, y;
        cin >> x >> y;
        num[x]--;
        num[y]++;
        if(red[x] == true)red[y] = true;
        if(num[x] == 0)red[x] = false;
    }
    int ans = 0;
    for(int i = 1;i <= n;i++)
        ans += red[i];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 768
N=list(input())
A=int(N[0])
B=int(N[1])
C=int(N[2])
D=int(N[3])
if A+B+C+D==7:
  key=N[0]+'+'+N[1]+'+'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A+B+C-D==7:
  key=N[0]+'+'+N[1]+'+'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()
if A+B-C+D==7:
  key=N[0]+'+'+N[1]+'-'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A-B+C+D==7:
  key=N[0]+'-'+N[1]+'+'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A-B-C+D==7:
  key=N[0]+'-'+N[1]+'-'+N[2]+'+'+N[3]+'=7'
  print(key)
  exit()
if A-B+C-D==7:
  key=N[0]+'-'+N[1]+'+'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()
if A+B-C-D==7:
  key=N[0]+'+'+N[1]+'-'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()
if A-B-C-D==7:
  key=N[0]+'-'+N[1]+'-'+N[2]+'-'+N[3]+'=7'
  print(key)
  exit()

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

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long money=1000,kabu=0;
  for(int i=0;i<n-1;i++){
    if(kabu==0 && a[i]<a[i+1]){
      kabu=floor(money/a[i]);
      money-=kabu*a[i];
    }
    if(kabu!=0 && a[i]>a[i+1]){
      money+=kabu*a[i];
      kabu=0;
    }
  }
  money+=kabu*a[n-1];
  cout << money <<endl;
  return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int n,m;
int ans = INT_MAX;
int sum[301];
VVI a;

void dfs(vector<bool> &ng){

  memset(sum,0,sizeof(sum));

  rep(i,n){
    int minIdx = INT_MAX;
    int addIdx = m;

    rep(j,m){
      if(ng[j]) continue;
      if(minIdx > a[i][j] ){
        minIdx = a[i][j];
        addIdx = j;
      }
    }
    sum[addIdx]++;
  }

  if(sum[m] > 0) return;
  int maxNum = -1;
  rep(i,m) maxNum = max(sum[i],maxNum);
  // rep(i,m){
  //   if(maxNum == 2){
  //     if(ng[i]) cout << "- ";
  //     else cout << sum[i] << " ";
  //
  //     if(maxNum == 2 && i == m-1) cout << endl;
  //   }
  // }
  ans = min(ans, maxNum);

  rep(i,m){
    if(maxNum == sum[i]){
      ng[i] = true;
      dfs(ng);
      ng[i] = false;
    }
  }

}

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

  cin >> n >> m;
  a.resize(n,VI(m));

  rep(i,n) rep(j,m){
    int tmp;
    cin >> tmp;
    a[i][tmp-1] = j;
  }
  vector<bool> ng(m+1,false);
  dfs(ng);

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
     
    const int N = 101;
    const int K = 100001;
    int a[N], g[K], n, k;
     
    int main() {
        cin >> n >> k;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        for (int pile = 1; pile <= k; pile++) {
            vector<bool> visited(k + 1, false);
            for (int i = 1; i <= n; i++) {
                if (pile - a[i] >= 0) {
                    visited[g[pile - a[i]]] = true;
                }
            }
            int mex = 0;
            while (visited[mex]) {
                mex++;
            }
            g[pile] = mex;
        }
        if (g[k] != 0) {
            cout << "First";
        } else {
            cout << "Second";
        }
        return 0;
    }

Measured memory_bytes: 640
program hello
      integer a
      read *,a
      if (a==25) then
      print '(A)','Christmas'
      endif
      if (a==24) then
      print '(A)','Christmas Eve'
      endif
      if (a==23) then
      print '(A)','Christmas Eve Eve'
      endif
      if (a==22) then
      print '(A)','Christmas Eve Eve Eve'
      endif
end program hello


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


int main() {
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    cout << v[0] + v[1] << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		Console.ReadLine();
		var c = Console.ReadLine();
		var chars = c.ToCharArray();
		var size = new List<int>[10];
		for(int i = 0; i < c.Length; i++)
		{
			if(size[c[i] - '0']==null)
			{
				size[c[i] - '0'] = new List<int>();
			}
			size[c[i] - '0'].Add(i);
		}
		
		var indexes = new int[10][];
		for(int i = 0; i < 10; i++)
		{
			if(size[i]==null)
			{
				indexes[i] = new int[0];
				continue;
			}
			indexes[i] = size[i].ToArray();
		}
		long wa = 0;
		for(int i = 0; i <= 9; i++)
		{
			if(indexes[i].Length == 0)
				continue;
			int ii = indexes[i][0];
			for(int j = 0; j <= 9; j++)
			{
				int ij = UpperBound(indexes[j], ii);
				if(ij >= indexes[j].Length)
					continue;
				ij = indexes[j][ij];
				if(ii >= ij)
					continue;
				for(int k = 0; k <= 9; k++)
				{
					int ik = UpperBound(indexes[k], ij);
					if(ik >= indexes[k].Length )
						continue;
					ik = indexes[k][ik];
					wa++;
				}
			}
		}
		Console.WriteLine(wa);
	}


public static int UpperBound<T>(T[] arr, int start, int end, T value, IComparer<T> comparer)
{
    int low = start;
    int high = end;
    int mid;
    while (low < high)
    {
        mid = ((high - low) >> 1) + low;
        if (comparer.Compare(arr[mid], value) <= 0)
            low = mid + 1;
        else
            high = mid;
    }
    return low;
}

//引数省略のオーバーロード
public static int UpperBound<T>(T[] arr, T value)
{
    return UpperBound(arr, 0, arr.Length, value, Comparer<T>.Default);
}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13920
#include<bits/stdc++.h>
using namespace std;
long long int dp[200005];
long long int sum[200005];
long long int yoyo[200005];
int main(){
	int t;
	cin>>t;
	cin>>yoyo[1];
	sum[1]=yoyo[1];
	for(int i=2;i<=t;i++){
		cin>>yoyo[i];
		if(i%2)sum[i]=sum[i-2]+yoyo[i];
	}
	for(int i=2;i<=t;i++){
		if(i%2)dp[i]=max(dp[i-1],dp[i-2]+yoyo[i]);
		else dp[i]=max(sum[i-1],dp[i-2]+yoyo[i]);
	}
	cout<<dp[t]<<endl;
}

Measured memory_bytes: 8304
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int a[4], b[2];
    scn(4, a); scn(2, b);
    sort(a, a + 4); sort(b, b + 2);
    pri(a[1] + a[2] + a[3] + b[1]);


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1180
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
nexts = {}
for i in range(N):
    nexts[i+1] = n()

n = 1
seen = set()
seen.add(n)

while n != 2:
    n = nexts[n]
    if n in seen:
        print(-1)
        import sys
        sys.exit()
    seen.add(n)

print(len(seen)-1)


Measured memory_bytes: 22236
H, W = map(int,input().split())
s = []
for k in range(H):
    s.append(input())

B = []
for k in range(H):
    for l in range(W):
        if s[k][l] == "B":
            B.append([k,l])
ans = 0
for e in B:
    for f in B:
        ans = max(ans,abs(e[0]-f[0])+abs(e[1]-f[1]))
print(ans)



Measured memory_bytes: 5604
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        a: [(usize1, usize); m],
    }
    for v in 0..1000 {
        let s: Vec<usize> = v.to_string().chars().map(|c| c.to_digit(10).unwrap() as usize).collect();
        if s.len() != n {
            continue;
        }
        let mut ok = true;
        for &(x, c) in a.iter() {
            ok &= s[x] == c;
        }
        if ok {
            println!("{}", v);
            return;
        }
    }
    println!("-1");
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, m;
	cin>>n>>m;
	int ar[n];
	fore(i, 0, n) cin>>ar[i];
	int res = MOD;
	sort(ar, ar + n);
	fore(i, 0, n - m + 1)
		res = min(res, ar[i+m-1] - ar[i]);
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 640
n=int(input())
s=input()
for p in range(4):
    first=p//2
    second=p%2
    l=[first,second]+[0]*(n-2)
    for i in range(1,n):
        if s[i]=="o":
            l[(i+1)%n]=l[i-1] if l[i] else 1-l[i-1]
        else:l[(i+1)%n]=1-l[i-1] if l[i] else l[i-1]
    d=""
    for i in range(n):
        if s[i]!="ox"[int(l[(i-1)%n]==l[(i+1)%n])-l[i]]:break
    else:
        print("".join("WS"[x] for x in l))
        exit()
print(-1)

Measured memory_bytes: 5476
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  int cur = 0;
  for (int i = 0; i < N; i++) {
    if (a[i] == cur+1) {
      cur++;
    }
  }
  if (cur == 0) {
    cout << -1 << endl;
  } else {
    cout << N-cur << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> mypair;

int main(){
int v,e;
cin>>v>>e;
vector<vector<mypair> > g(v);
for(int i=0;i<e;i++){
int s,t,v2;
cin>>s>>t>>v2;
g[s].push_back(mypair(v2,t));
g[t].push_back(mypair(v2,s));
}
vector<bool> used(v,true);
priority_queue<mypair,vector<mypair>,greater<mypair> > q;
used[0]=false;
for(int i=0;i<g[0].size();i++){
q.push(g[0][i]);
}
int respoint=v-1;
int ans=0;
while(!q.empty()){
mypair tmp=q.top();
q.pop();
if(!used[tmp.second])continue;
ans+=tmp.first;
used[tmp.second]=false;
for(int i=0;i<g[tmp.second].size();i++){
q.push(g[tmp.second][i]);
}
respoint--;
if(respoint==0)break;
}
cout<<ans<<endl;

return 0;
}



Measured memory_bytes: 7796
import java.util.*;

public class Main {
    static int k;
    static TreeSet<String> set;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        k = sc.nextInt();
        set = new TreeSet<String>();
        int n = str.length();
        
        String[] array = new String[n];
        for (int i = 0; i < n; i++) {
            array[i] = String.valueOf(str.charAt(i));
        }
        
        solve("", array);
        
        int i = 1;
        for (String s : set) {
            if (i == k) {
                System.out.println(s);
                break;
            }
            i++;
        }

    }
    
    public static void solve(String str, String[] array) {
        Set<String> privateSet = new TreeSet<String>();
        
        for (int i = 0; i < array.length - (str.length() - 1); i++) {
            String str2 = "";
            for (int j = i; j < i + str.length(); j++) {
                str2 += array[j];
            }
            
            if (str.equals(str2) && i + str.length() < array.length) {
                privateSet.add(str2 + array[i + str.length()]);
            }
        }
        
        for (String s : privateSet) {
            set.add(s);
            if (set.size() >= k) return;
            solve(s, array);
        }
    }
}


Measured memory_bytes: 28884
#include<iostream>
#define MAX 200000
using namespace std;


int A[MAX],M[MAX];

int main()
{
    int n;
    cin >> n;
    int minn;
    for(int i=0;i<n;i++)
    {
        cin >> A[i];
        if(i==0)minn=A[i];
        else minn= {minn < A[i] ? minn : A[i]};
        M[i]=minn;
    }

    int maxprofit=A[1]-A[0];
    for(int i=1;i<n;i++)
    {
        if(A[i]-M[i-1]>=maxprofit)maxprofit=A[i]-M[i-1];
    }
    cout << maxprofit << endl;
    return 0;
}



Measured memory_bytes: 4676
#include <stdio.h>

int
main(int argc, char *argv[])
{
    int N;

    scanf("%d", &N);
    if(N%2==0){
        printf("0.5\n");
    }
    else {
        printf("%G\n", (double)(N/2+1)/(double)N);
    }
    return 0;
}

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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

/* 文字から数値に変換 */
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

/* 文字列から数値へ変換して key を生成する */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


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

using namespace std;

#define INF 2140000000000000LL
#define MOD 1000000007

long long fun(long long n, long long b) {
	long long sum = 0;

	while (n) {
		sum += n % b;
		n /= b;
	}

	return sum;
}

int main() {
	long long n, s, b = 2, ans = INF;;

	cin >> n >> s;

	if (n == 1) {
		if (s == 1) {
			cout << 2;
		}
		else {
			cout << -1;
		}
		return 0;
	}

	if (fun(n, n + 1) ==  s) {
		cout << n + 1 << endl;
		return 0;
	}

	while (b * b <= n) {
		if (fun(n,b) == s) {
			ans = min(ans, b);
		}
		b++;
	}

	b = 1;

	while (b * b <= n - s) {
		if ((n - s) % b == 0) {
			if (fun(n, b + 1) == s) {
				ans = min(ans, b + 1);
			}

			if (fun(n, (n - s) / b + 1) == s) {
				ans = min(ans, (n - s) / b + 1);
			}
		}
		b++;
	}

	if (ans != INF) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())

b = [[0, 0, 0],[0, 0, 0], [0, 0, 0]]
flag = 0

for _ in range(n):
    x = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == x:
                b[j][k] = 1
                
if b[0] == [1, 1, 1]:
    flag = 1
elif b[1] == [1, 1, 1]:
    flag = 1
elif b[2] == [1, 1, 1]:
    flag = 1
elif b[0][0] == 1 and b[1][0] == 1 and b[2][0] == 1:
    flag = 1
elif b[0][1] == 1 and b[1][1] == 1 and b[2][1] == 1:
    flag = 1
elif b[0][2] == 1 and b[1][2] == 1 and b[2][2] == 1:
    flag = 1
elif b[0][0] == 1 and b[1][1] == 1 and b[2][2] == 1:
    flag = 1
elif b[0][2] == 1 and b[1][1] == 1 and b[2][0] == 1:
    flag = 1
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

typedef long long ll;
//#define int long long
constexpr int INF = 1e9;

decltype(1) main() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    if (n % 2) {
        cout << "No" << endl;
    } else {
        const int size = n / 2;
        for (int i = 0; i < size; ++i) {
            if (s[i] != s[i + size]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
$in = explode(" ",trim(fgets(STDIN)));
$w = $in[0];
$h = $in[1];
$x = $in[2];
$y = $in[3];
$r = $in[4];

if($x < 0 || $y < 0)
{
    echo "No\n";
}
else {
    if(($x + $r) <= $w)
    {
        if(($y + $r) <= $h)
        {
            echo "Yes\n";
        }
        else {
            echo "No\n";
        }
    }
    else {
        echo "No\n";
    }
}

Measured memory_bytes: 15300
#include<stdio.h>
#include<math.h>

double cubicRoot( double ab )
{
	double cr,a;
	double i;
	
	if( 0==ab ) { return 0; }
	
	for( i=1; ; i+=0.00001 ) {
		if( ab<=(i*i*i)  ) {
			a=i-0.00001;
			break;
		}
	}
	
	cr = a+(ab-(a*a*a))/(3*a*a);
	
	return cr;
}
int main( void ) 
{
	int n;
	int i;
	double x[1001],y[1001];
	double tmp;
	double Dxy,Dxy2,Dxy3,Dmax;
	
	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
    	scanf( "%lf", &x[i] );
    }
    Dxy=Dxy2=Dxy3=Dmax=0;
	for( i=0; i<n; i++ ) {
    	scanf( "%lf", &y[i] );
    	tmp=fabs( x[i]-y[i] );
    	Dxy+=tmp;
    	Dxy2+=(tmp*tmp);
    	Dxy3+=(tmp*tmp*tmp);
    	if( Dmax < tmp ) {
    		Dmax=tmp;
    	}
    }
	printf( "%.5lf\n", Dxy );
	printf( "%.5lf\n", sqrt( Dxy2 ) );
	printf( "%.5lf\n", cubicRoot( Dxy3 ) );
	printf( "%.5lf\n", Dmax );

		
	return 0;
}

Measured memory_bytes: 672
from collections import Counter

n, x, y = map(int, input().split())
x -= 1
y -= 1

dists = Counter([min(j - i, abs(x - i) + abs(y - j) + 1) for i in range(n - 1) for j in range(i + 1, n)])
[print(dists.get(i, 0)) for i in range(1, n)]


Measured memory_bytes: 67428
import sys
import math

def main():
    n = int(input().rstrip())
    r = 1.05
    digit = 3
    a = 100000
    
    for i in range(n):
        a = math.ceil(a*r/10**digit)*10**digit

    print(a)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 7648
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    string s; cin>>s;
    string t; cin>>t;
    if(t.substr(0,s.size())==s){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}








Measured memory_bytes: 3628
/*
		@Author :- Gaurav Bharti
		National Institute of Technology, Jamshedpur.
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test ll t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define jaldibazi ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
const int N=1e5+10;


int main(){
	jaldibazi;

	int n,k,ans=0; cin >> n >> k;
	vector <int > v(n);

	for(int i=0; i<n; ++i) cin >>v[i];

	sort(all(v));
	
	for(int i=0;i <k;++i) ans+=v[i];
	cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
int main(){
    string s;
    cin >> s;
    int cnt0,cnt1;
    cnt0 = 0;///010101
    cnt1 = 0;///101010
    for(int i=0;i<s.size();i++){
        if(i%2 == 0){
            if(s[i]=='0')cnt1++;
            if(s[i]=='1')cnt0++;
        }
        if(i%2 == 1){
            if(s[i]=='0')cnt0++;
            if(s[i]=='1')cnt1++;
        }
    }

    cout <<  min(cnt0,cnt1)<<endl;
    
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
using namespace std;

int main(void) {
	int n, l;
	char s[101][101];
	char p[101];
	cin >> n >> l;
	FOR(i, 0, n - 1) {
		cin >> s[i];
	}
	FOR(i, 0, n - 1) {
		FOR(t, i, n - 1) {
			if (strcmp(s[i], s[t]) > 0) {
				strcpy(p, s[i]);
				strcpy(s[i], s[t]);
				strcpy(s[t], p);
			}
		}
	}
	FOR(i, 0, n - 1) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 300005;
int n,k,a,b;
char s[N];
int sumw[N],sume[N];
int main() {
	scanf("%d%s",&n,s+1);
	for(int i=1; i<=n; i++) {
		sume[i] = sume[i-1]+(s[i]=='E');
		sumw[i] = sumw[i-1]+(s[i]=='W');
	}
	int ans = 0x3f3f3f3f;
	for(int i=1; i<=n; i++) {
	//	cout << sume[i-1] << ' ' << sumw[n]-sumw[i] << endl;
		ans = min(ans, sumw[i-1]+sume[n]-sume[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2944
from collections import namedtuple
from functools import partial
from operator import attrgetter

Path = namedtuple('Path', ('length', 'left_seat', 'right_seat'))

m = set()
f = set()


def is_suitable_path(p: 'Path', m: 'set', f: 'set') -> 'bool':
    if p.length <= 1:
        return False
    if p.length % 2 == 0:
        return (p.left_seat in m and p.right_seat in f) or (p.left_seat in f and p.right_seat in m)
    else:
        return (p.left_seat in m and p.right_seat in m) or (p.left_seat in f and p.right_seat in f)


is_suitable_path = partial(is_suitable_path, m=m, f=f)

n = int(input())

checked = [n]
x = 0
for _ in range(20):
    print(x)

    checked.append(x)
    checked.sort()

    res = input()
    if res[0] == 'V':
        break
    else:
        if res[0] == 'M':
            m.add(x)
            if x == 0:
                m.add(n)
        else:
            f.add(x)
            if x == 0:
                f.add(n)

        t = sorted(filter(is_suitable_path,
                          (Path(length=t - s, left_seat=s, right_seat=t) for s, t in zip(checked, checked[1:]))),
                   key=attrgetter('length'))
        x = (t[0].left_seat + t[0].right_seat) // 2


Measured memory_bytes: 38852
#include "bits/stdc++.h"
using namespace std;
const int maxn = 100;
char s[maxn];
int main(int argc, char const *argv[])
{
    scanf("%s", s);
    int cnt = 0;
    for (int i = 0; i < 6; i++) cnt += s[i] == '1';
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256