akhauriyash/Code-Regression huggingface dataset:
//
//  Atcoder_1.cpp
//  
//
//  Created by Nishith on 17/05/20.
//

#include <stdio.h>
#include<string.h>
#include<iostream>
#include<string.h>

using namespace std;









int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    string str;
    int k;
    cin>>k;
    cin>>str;
    
    int length = str.length();
    
    if(length<=k)
    {
        cout<<str<<endl;
    }
    else{
    char arr[length+1];
    
    strcpy(arr,str.c_str());
    
        string sub = str.substr(0,k);
        
        string res = sub + "...";
        cout<<res<<endl;
    }
    
}


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

#define N 100000

int main(void){
    bool prime[N+1];
    for (size_t i = 0; i <= N; i++)
    {
        prime[i]=true;
    }
    for (size_t i = 0; i < 2; i++)
    {
        prime[i]=false;
    }
    for (size_t i = 0; i <= sqrt(N); i++)
    {
        if (!prime[i])continue;
        else
        {
            for (size_t j = 2; i*j <= N; j++)
            {
                prime[i*j]=false;
            }
        }
    }
    int likePrime[N]={};
    int likeCnt[N]={};
    for (size_t j = 1; j <= N; j++)
    {
        likeCnt[j]=likeCnt[j-1];
        if (j%2==1&&prime[j]&&prime[(j+1)/2])
        {
            likePrime[j]=true;
            likeCnt[j]++;
        }
    }
    /**************************************/
    int q;
    cin >> q;
    int l[q],r[q];
    for (size_t i = 0; i < q; i++)
    {
        cin >>l[i]>>r[i];
    }
    int ans[q]={};
    for (size_t i = 0; i < q; i++)
    {
        cout << likeCnt[r[i]]-likeCnt[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>

int search(int[], int, int);


int main(){

  int  S[10000], q, key, count=0,i,n;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){ 
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);

  for ( i = 0; i < q; i++ ){
   
    scanf("%d", &key);
    if ( search(S, n, key) == 1 ) count++;
  }
  printf("%d\n", count);


  return 0;
}
int search(int S[], int n, int key){
  int i;

  for ( i = 0; i < n; i++ ){
    if ( S[i] == key ) return 1;
  }
  return 0;
}

Measured memory_bytes: 636
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)
#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M      32000*5+9
ll isprime(ll n)
 {
     if(n==1) return false;
     for(int i=2;i*i<=n;i++)
     {
        if(n%i==0) return false;
     }
     return true;
 }
int main()
{
   int n;
   cin>>n;
   int p = n;
   while(!isprime(p)) p++;
   cout<<p<<endl;


return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,a[1010];
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> a[i];
	vector<int> b;
	for(int i = 0;i < n;i++){
		int sum = 0;
		for(int j = i;j < n;j++){
			sum += a[j];
			b.push_back(sum);
		}
	}
	int ans = 0;
	vector<bool> ok(b.size(),true);
	for(int i = 60;i >= 0;i--){
		int cnt = 0;
		for(int j = 0;j < b.size();j++){
			if(ok[j] && ((b[j] >> i) & 1)) cnt++;
		}
		if(cnt >= k){
			ans += (1ll << i);
			for(int j = 0;j < b.size();j++){
				if(ok[j] && !((b[j] >> i) & 1)) ok[j] = false;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
signed main(){
    fast();
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> ma;
    int s = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        s += a[i];
        ma[a[i]]++;
    }
    test(){
        int u, v;
        cin >> u >> v;
        s = s-ma[u]*u+ma[u]*v;
        ma[v] += ma[u];
        ma[u] = 0;
        cout << s << endl;
    }
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

Measured memory_bytes: 10084
/*BINH :))*/
#include<bits/stdc++.h>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(cc,a,b) for (int cc=a,x,y,z;cc<=b;cc++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL cout<<endl
#define maxn 1005
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#pragma GCC optimize("Ofast")
ll n,m,f[101][100001],w[3000],v[3000],binh;
int main(){
    IO
    cin>>n>>m;
    FOR(i,1,n){
        cin>>w[i]>>v[i];
        binh+=v[i];
    }
    for(ll i=0;i<=n;i++)
        f[i][0] = 0;
    
    for(ll i=0;i<=binh;i++)
        f[0][i] = 1e9;
    f[0][0] = 0;
    FOR(i,1,n){
        FOR(j,1,binh){
            int k = j - v[i];
            if(k<0) f[i][j] = f[i-1][j];
            else f[i][j] = min(f[i-1][j], w[i] + f[i-1][k]);
        }
    }
    FOD(i,binh,0){
        if(f[n][i]<=m){
            cout<<i;
            return 0;
        }
    }
}
    

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
map<pll,ll> dp;
bool uq(long long a,long long b){
	//printf("uq %lld %lld\n",a,b);
	while(a<=b&&(a&~b)) a+=a&-a;
	long long lb=b&-b;
	b-=lb;
	if(a>b) return true;
	else return false;
}
long long solve(long long a,long long b){
	if(a==b) return 1;
	if(a>b) return 0;
	if(dp.count(make_pair(a,b))) return dp[make_pair(a,b)];
	long long tmp=solve((a+1)/2,b/2)+solve(a/2,b/2);
	if(b%2==0&&uq(a/2,b/2)) tmp--;
	return dp[make_pair(a,b)]=tmp;
}
int main(){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	printf("%lld\n",solve(a,b));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,n,k,sum,max;
	int N[150000];

	while(0==0){
		scanf("%d %d",&n,&k);
		sum=0;
		if(n==0 && k==0) break;

		for(i=0;i<n;i++)
			scanf("%d",&N[i]);

		for(i=0;i<k;i++)
		    sum+=N[i];
		
		max=sum;

		for(i=k;i<n;i++){
			sum+=N[i];
			sum-=N[i-k];
			if(sum>max)max=sum;
		}

		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 1424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	static class Coordinates {
		int x,y;
		public Coordinates(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n = fr.nextInt();
		int m = fr.nextInt();
		Coordinates[] kids = new Coordinates[n];
		Coordinates[] flags = new Coordinates[m];
		for (int i=0; i<n; i++) {
			int x = fr.nextInt();
			int y = fr.nextInt();
			kids[i] = new Coordinates(x, y);
		}
		for (int i=0; i<m; i++) {
			int x = fr.nextInt();
			int y = fr.nextInt();
			flags[i] = new Coordinates(x, y);
		}
		for (int i=0; i<n; i++) {
			Coordinates cur = null;
			int c = -1;
			int minDis = Integer.MAX_VALUE;
			for (int j=0; j<m; j++) {
				if (cur == null || (minDis > Math.abs(flags[j].x - kids[i].x) + Math.abs(flags[j].y - kids[i].y))
						|| ((minDis == Math.abs(flags[j].x - kids[i].x) + Math.abs(flags[j].y - kids[i].y)) 
								&& (flags[j].x < cur.x || flags[j].y < cur.y))) {
					cur = flags[j];
					c = j;
					minDis = Math.abs(flags[j].x - kids[i].x) + Math.abs(flags[j].y - kids[i].y);
				}
			}
			System.out.println(c+1);
		}
	}
	
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){


  int n,m,x; cin>>n>>m>>x;

  int ctmin=0,ctmax=0;

  rep(i,m){
    int aa; cin>>aa;
    if(aa<x) ++ctmin;
    else ++ctmax;
  }

  cout<< min(ctmin,ctmax)<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define pi 3.141592653589793238

int main()
{
    int t=1;
    //cin>>t;


    while( t-- )
    {
        string s;
        cin>>s;

        if( s[s.size()-1]=='s' )
            cout<<s<<"es";
        else
            cout<<s<<"s";
    }
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

/* Counter Lib */
template <class T>
class Counter {
 public:
  Counter() = default;
  template <class U>
  Counter(const U& container) {
    for (auto x : container) {
      counter_[x]++;
    }
  }
  auto val(const T& key) const { return counter_.find(key)->second; }
  auto add(const T& key) { counter_[key]++; }
  auto get() { return counter_; }
  auto get() const { return counter_; }
  auto hist() const {
    map<int, int> hist_counter;
    for (auto kv : counter_) {
      hist_counter[kv.second]++;
    }
    return hist_counter;
  }

 private:
  map<T, int> counter_;
};
/* /Counter Lib */

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  Counter<int> counter;
  int a, b, c;
  cin >> a >> b >> c;
  counter.add(a);
  counter.add(b);
  counter.add(c);
  cout << counter.get().size() << endl;
  /* */

  return EXIT_SUCCESS;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define d double
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll a,b,k;
  cin>>a>>b>>k;
  
  ll n=min(a,k);
  a-=n;
  k-=n;
  
  n=min(b,k);
  b-=n;
  k-=n;
  
  cout<<a<<" "<<b<<endl;
  
  return 0;
}

Measured memory_bytes: 3608
<?php
fscanf(STDIN, "%s", $s);
$q = ['A','C','G','T'];
$x = $p = 0;
for ($i = 0; $i < strlen($s); $i++) {
	if (in_array($s[$i], $q)) {
		$p++;
	} else {
		$x = max($x, $p);
		$p = 0;
	}
}
echo max($x, $p);

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int n;
int dp[105][N];
int arr[105];

int add(int a, int b)
{
  return (((a + mod) % mod) + ((b + mod) % mod)) % mod;
}

void solve()
{
  for(int i = 0; i < N; i++)
    dp[n][i] = 1;
  for(int i = n - 1; i >= 0; i--)
  {
    for(int j = 0; j < N; j++)
    {
      int st = j, en = j - min(arr[i], j);
      if(en)
        dp[i][j] =  add(dp[i + 1][st], -dp[i + 1][en - 1]);
      else
        dp[i][j] = dp[i + 1][st];

      if(j)
        dp[i][j] = add(dp[i][j], dp[i][j - 1]);
    }
  }
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int k;
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  solve();
  if(k)
    cout << add(dp[0][k], -dp[0][k - 1]);
  else
    cout << dp[0][0];
  return 0;
}


Measured memory_bytes: 41216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void dfs(string s, int n, int type){
  if(s.size() == n){
    cout << s << endl;
    return ;
  }
  rep(i, type + 2){
    string add = s;
    add.push_back(i + 'a');
    dfs(add, n, max(type, i));
  }
}

int main(){
  int n;
  cin >> n;
  dfs("a", n, 0);
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a > b) { a = b; return 1; } return 0; }
#include <chrono>
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	long long int fbsum = 0;
	rep(i, N+1) {
		if (i % 3 != 0 && i % 5 != 0)fbsum += i;
	}
	cout << fbsum;
	return 0;
}


Measured memory_bytes: 3652
#include<cstdio>

int main(){
    int n;
    scanf("%d",&n);
    bool card[4][13];
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            card[i][j] = true;
        }
    }
    for(int i = 0; i < n; i++){
        char c;
        scanf("\n%c",&c);
        int a;
        scanf("%d",&a);
        if(c == 'S'){
            card[0][a - 1] = false;
        }
        else if(c == 'H'){
            card[1][a - 1] = false;
        }
        else if(c == 'C'){
            card[2][a - 1] = false;
        }
        else if(c == 'D'){
            card[3][a - 1] = false;
        }
    }
    for(int i = 0; i < 4; i++){
        for(int j = 0; j < 13; j++){
            if(card[i][j]){
                if(i == 0){
                    printf("S %d\n",j + 1);
                }
                else if(i == 1){
                    printf("H %d\n",j + 1);
                }
                else if(i == 2){
                    printf("C %d\n",j + 1);
                }
                else if(i == 3){
                    printf("D %d\n",j + 1);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2732
Sa = list(input())
Sb = list(input())
Sc = list(input())

def turn(X):
  if X == "a":
    if Sa == []:
      print("A")
      exit()
    A_discard = Sa.pop(0)
    turn(A_discard)
  elif X == "b":
    if Sb == []:
      print("B")
      exit()
    B_discard = Sb.pop(0)
    turn(B_discard)
  elif X == "c":
    if Sc == []:
      print("C")
      exit()
    C_discard = Sc.pop(0)
    turn(C_discard)

turn("a")
    


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
 
int n, m;
std::pair<int, int> data[100005];
int main() {
	std::cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		std::cin >> a >> b;
		data[i].first = b;
		data[i].second = a;
	}
 
	std::sort(data, data + m);
 
	int before = -1;
	int ans = 0;
	for (int i = 0; i < m; ++i) {
		if (before >= data[i].second)
			continue;
		++ans;
		before = data[i].first - 1;
	}
 
	std::cout << ans << std::endl;
	return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;
	int a,b; cin>>a>>b;
  	set<int>  s = {1,2,3};
  	s.erase(a);
  	s.erase(b);
  	auto it = s.begin();
  	cout<<*it;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;
	cin>>a>>b;
	cout<<(a+(b-1))/b;
	return 0;
}

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

int main(void){
   int k;
   char s[100];
   char S[100];

   scanf("%d", &k);
   scanf("%s", &s);
   int x = strlen(s);

   strncpy(S, s, k);
   S[k] = '\0';

   if(x <= k){
      printf("%s\n", s);
   }else{
      printf("%s...\n", S);
   }
   return 0;
}

Measured memory_bytes: 1688
import copy

n = int(input())
lis = list(map(int, input().split()))

tlis = copy.deepcopy(lis)

sortlis = sorted(lis)


for i in range(n-1):
    for j in range(i,n):
        tmp = tlis[i]
        tlis[i] = tlis[j]
        tlis[j] = tmp
        if tlis == sortlis:
            print('YES')
            exit()
        else:
            tlis = copy.deepcopy(lis)
            
print('NO')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
const long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n;
	string s;
	cin >> n >> s;

	ll finalans = INF;
	{
		bool flag = false;
		ll ans = 0;
		for (ll i = 0; i < n; i++) {
			if (s[n - 1 - i] == 'R') flag = true;
			if (s[n - 1 - i] == 'W' && flag) ans++;
		}
		finalans = min(finalans, ans);
	}

	{
		bool flag = false;
		ll ans = 0;
		for (ll i = 0; i < n; i++) {
			if (s[i] == 'W') flag = true;
			if (s[i] == 'R' && flag) ans++;
		}
		finalans = min(finalans, ans);
	}

	{
		vector<ll> v(0);
		for (ll i = 0; i < n; i++) {
			if (s[i] == 'R') v.push_back(i);
		}
		ll ans = 0;
		for (ll i = 0; i < n; i++) {
			if (v.empty()) break;
			if (i > v.back()) break;
			if (s[i] == 'W') {
				v.pop_back();
				ans++;
			}
		}
		finalans = ans;
	}

	cout << finalans << endl;
}

Measured memory_bytes: 5412
s= list(map(int, input().split()))

if((s[0]-s[1])%2 == 1):
  print("IMPOSSIBLE")
  exit()

if(s[0]==s[1]):
  print(0)
  exit()

if(s[0]<s[1]):
  print(int(s[0]+(s[1]-s[0])/2))
else:
  print(int(s[1]+(s[0]-s[1])/2))

Measured memory_bytes: 3064
S = input()
keyence = 'keyence'
List = []
for i in range(len(keyence)):
  List.append((keyence[0:i],keyence[i:len(keyence)]))
Answer = 'NO'
for A,B in List:
  a = len(A)
  b = len(B)
  if S[0:a] == A and S[-b:] == B:
    Answer = 'YES'
    break
print(Answer)

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt(), q = sc.nextInt();
		if (Math.min(n, m) == 1) {
			System.out.println(q);
			return;
		}
		ArrayList<Integer>[]adj=new ArrayList[n];
		Integer[] row = new Integer[n], col = new Integer[m], indices = new Integer[m];
		for (int i = 0; i < m; i++) {
			indices[i] = i;
			col[i]=0;
		}
		for(int i=0;i<n;i++) {
			row[i]=0;
			adj[i]=new ArrayList();
		}
//		HashSet<Long>set=new HashSet();
		while (q-- > 0) {
			int i=sc.nextInt()-1,j=sc.nextInt()-1;
			row[i]++;
			col[j]++;
//			set.add(i*1L*m+j);
			adj[i].add(j);
		}
		
		Arrays.sort(indices, Comparator.comparingInt(i -> -col[i]));
		int options=0;
		int bestCol=col[indices[0]];
		for(int i=0;i<m;i++)
			if(col[indices[i]]==bestCol)
				options++;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int val=row[i]+bestCol;
			int cnt=0;
			for(int j:adj[i])
				if(col[j]==bestCol)
					cnt++;
			if(cnt==options)
				val--;
			ans=Math.max(ans, val);
		}
		System.out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 87916
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int> Pi;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) x.begin(), x.end()

int N, K;
const int MOD = 1e9 + 7;
int pw(int x, int y){
	int res = 1;
	while(y){
		if(y & 1)res = (ll)res * x % MOD;
		x = (ll)x * x % MOD;
		y >>= 1;
	}
	return res;
}

void solve(){
	scanf("%d%d", &N, &K);
	set <int> M;
	vector <int> v;
	int flag = 1;
	if(N % 2 == 0)N /= 2, flag = 0;
	M.insert(1); M.insert(N);
	for(int i=2;i*i<=N;i++){
		if(N % i == 0){
			M.insert(i);
			if(i*i != N)M.insert(N/i);
		}
	}
	for(int e : M)v.pb(e);
	ll ans = 0;
	vector <ll> D;
	D.resize(sz(v));
	for(int i=0;i<sz(v);i++){
		if(flag == 0)D[i] = (D[i] + pw(K, v[i])) % MOD;
		else D[i] = (D[i] + pw(K, (v[i]+1)/2)) % MOD;
		//printf("%d %lld\n", v[i], D[i]);
		for(int j=i+1;j<sz(v);j++)if(v[j] % v[i] == 0)D[j] = (D[j] - D[i]) % MOD;
		ans += D[i] * v[i];
		ans %= MOD;
	}
	if(ans < 0)ans += MOD;
	printf("%lld", ans);
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

#define cerr if(0)cerr
using namespace std;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];
int near2017max=0;
int near2017[PMAX];

int main() {

  //  cerr << "first" << endl;
  fill(is_prime, is_prime + MAX, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i=2;i<RMAX;i++) {
    if (is_prime[i]) {
      for (int j=i+i; j<MAX; j+=i) {
	is_prime[j] = false;
      }
    }
  }
  // cerr << "second" << endl;
  int pm = 0;
  for (int i=0;i<MAX;i++) {
    if (is_prime[i]) {
      prime[pm++] = i;
    }
  }
  // cerr << "third" << endl;

  for (int i=1;i<100000;i+=2) {
      int j = (i+1)/2;
      //if (*lower_bound(prime,prime+pm,i) == i
      //        && *lower_bound(prime,prime+pm,j) == j) {
      if (is_prime[i] && is_prime[j]) {
          near2017[near2017max++] = i;
      }
  }
  for (int i=0;i<near2017max && near2017[i]<=2017;i++){
      cerr << near2017[i] << endl;
  }

  int q,left,right;
  cin >> q;
  for (int i=0;i<q;i++) {
      cin >> left >> right;
      // int *lp = lower_bound(near2017,near2017max,left, less<int>());
      int *lp = lower_bound(near2017,near2017+near2017max,left);
      int *rp = upper_bound(near2017,near2017+near2017max,right);
      cerr << "test: " << *lp << " " << *rp << endl;
      cout << (rp-lp) << endl;
  }
  return 0;
}

Measured memory_bytes: 768
a=list(map(int,input().split()))
if a[0]==a[1]:
    if a[1]==a[2]:
        print('No')
    else:
        print('Yes')
else:
    if a[1]==a[2]:
        print('Yes')
    else:
        if a[0]==a[2]:
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
    int N, K;
    std::cin >> N >> K;
    std::vector<int> A(N);
    for (int &Ai : A) std::cin >> Ai;

    int ans        = 1000000000;
    auto one_is_at = std::lower_bound(A.begin(), A.end(), 1);
    int it         = one_is_at - A.begin();
    for (int i = it - K + 1; i < it + K; ++i) {  // i: 区間の最初のiterator
        if (i < 0) continue;
        if (i >= N) break;
        int kl = i / (K - 1);
        if (i % (K - 1)) kl++;
        int kr = (N - i - 1) / (K - 1);
        if ((N - i - 1) % (K - 1)) kr++;
        ans = std::min(ans, kl + kr);
    }

    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
S = input()
x,y = map(int, [S[:2],S[2:]] )
if 1 <= x and x <= 12:
    if 1<= y and y <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1<= y and y <= 12:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <limits>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 200000000000000;
typedef long long ll;
double pi = 3.141592653589793;
//setprecision(20) <<

const int MOD = 1000000007;

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

long long lcm(long long a, long long b)
{
  return a / gcd(a, b) * b;
}
long myPow(long long x, long long n, long long m = MOD)
{
  if (n == 0)
    return 1;
  if (n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

class Point
{
public:
  long long x;
  long long y;
  char S;
};
const int MAX = 1000007;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X, Y;
  cin >> X >> Y;
  COMinit();
  if((X+Y)%3!=0){
    cout << 0 << endl;
    return 0;
  }

  ll _small = (X + Y) / 3;
  if (X < _small || Y < _small){
    cout << 0 << endl;
    return 0;
  }
  ll data1 = X+Y - 2*_small;
  ll data = X - _small;
  /*cout << data1 << endl;
  cout << data << endl;*/
  cout << COM(data1, data) << endl;
}


Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n, m;

    while(true){
        cin >> n >> m;
        vector<int> a(n);
        vector<int> b(m);
        if(n == 0&& m == 0) break;
        for(int i=0; i<n; i++) cin >> a[i];
        for(int i=0; i<m; i++) cin >> b[i];

        // ??????????????????
        int suma = 0, sumb = 0;
        for(int i=0; i<n; i++) suma += a[i];
        for(int i=0; i<m; i++) sumb += b[i];

        vector<pair<int, int>> res;

        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                if((suma - a[i] + b[j]) == (sumb - b[j] + a[i])){
                    res.push_back(make_pair(i, j));
                }

        if(res.size() == 0) cout << -1 << endl;
        else{
            int tmpa, tmpb, r = 999999999, tmp;
            for (int i=0; i<res.size(); i++){
                tmp = a[res[i].first] + b[res[i].second];
                if (tmp < r) {
                    r = tmp;
                    tmpa = res[i].first;
                    tmpb = res[i].second;
                }
            }
            cout << a[tmpa] << " " << b[tmpb] << endl;
        }

    }

}

Measured memory_bytes: 3196
class SegmentTree():
    """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。
    built(array)   := arrayを初期値とするセグメント木を構築する O(N)。
    update(i, val) := i番目の要素をvalに変更する。
    get_val(l, r)  := 区間[l, r)に対する二項演算の畳み込みの結果を返す。
    """

    def __init__(self, n, op, e):
        """要素数、二項演算、単位元を引数として渡す
        例) 区間最小値 SegmentTree(n, min, 10 ** 18)
            区間和     SegmentTree(n, lambda a, b : a + b, 0)
        """
        self.n = n
        self.op = op
        self.e = e
        self.size = 2 ** ((n - 1).bit_length())
        self.node = [self.e] * (2 * self.size)

    def built(self, array):
        """arrayを初期値とするセグメント木を構築する"""
        for i in range(self.n):
            self.node[self.size + i] = array[i]
        for i in range(self.size - 1, 0, -1):
            self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1])

    def update(self, i, val):
        """i番目の要素をvalに変更する"""
        i += self.size
        self.node[i] = val
        while i > 1:
            i >>= 1
            self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1])

    def get_val(self, l, r):
        """[l, r)の畳み込みの結果を返す"""
        l, r = l + self.size, r + self.size
        res = self.e
        while l < r:
            if l & 1:
                res = self.op(self.node[l], res)
                l += 1
            if r & 1:
                r -= 1
                res = self.op(self.node[r], res)
            l, r = l >> 1, r >> 1
        return res

import sys
input = sys.stdin.readline


n = int(input())
s = input()
q = int(input())
query = [list(input().split()) for i in range(q)] 
 
alph = "abcdefghijklmnopqrstuvwxyz"
to_int = {char: i for i, char in enumerate(alph)}
st = SegmentTree(n, lambda a, b : a | b, 0)
 
init = [0] * n
for i, char in enumerate(s[0:n]):
    init[i] = 1 << to_int[char]
st.built(init)

for num, l, r in query:
    if num == "1":
        st.update(int(l) - 1, 1 << to_int[r]) 
    else:
        tmp = st.get_val(int(l) - 1, int(r))
        print(bin(tmp).count("1"))

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

int main()
{
int a,b,c;
  cin >> a >> b >> c;
 if(b/a<=c)
 {
 cout << b/a << endl;
 }else if(c<b/a)
 {
 cout << c << endl;
 }
return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    char x, y;
    cin >> x >> y;
    if (x > y)
        cout << '>' << endl;
    else if (x == y)
        cout << '=' << endl;
    else
        cout << '<' << endl;

    return 0;
}

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

int main() {
  ll h;
  cin >> h;
  
  ll ans = 0;
  while(h > 1) {
    h = h/2;
    ans++;
  }
  cout << ll(pow(2,ans+1) - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#define endl '\n';
#define all(v) ((v).begin()), ((v).end())
#define sz(s)               (int)s.size()
#define Ceil(x,y)             ((x+y-1)/y)
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define vi                    vector<int>
#define pii                 pair<int,int>
#define fx(n)           fixed<<setprecision(n)
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define forr(i, n) for (int i = 0; i < int(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef double dl;
const double PI = acos(-1), EPS = 1e-7;
const int OO = 0x3f3f3f3f, N = 1e7 + 5, MOD = 1e9 + 7;
using namespace std;
void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); }
int main()
{
	fast();
	ll n,l;
	cin>>n>>l;
	multiset<string>st;
	string s;
	for(int i=0;i<n;i++)
    {
        cin>>s;
        st.insert(s);
    }
    multiset<string>::iterator it;
    for(it=st.begin();it!=st.end();it++)
        cout<<(*it);
    cout<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int ask(int y1, int x1, int y2, int x2)
{
	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
	fflush(stdout);
	int a;
	scanf("%d", &a);
	return a;
}

int H, W, N, K;
int C[50][50];

void solve(int y1, int x1, int y2, int x2, int cnt)
{
	if (y2 - y1 == 1 && x2 - x1 == 1) {
		C[y1][x1] = cnt;
		return;
	}
	if (cnt == 0) return;
	if ((y2 - y1) * (x2 - x1) == cnt) {
		for (int i = y1; i < y2; ++i) {
			for (int j = x1; j < x2; ++j) {
				C[i][j] = 1;
			}
		}
		return;
	}

	if (y2 - y1 > x2 - x1) {
		int ym = (y2 + y1) / 2;
		int a = ask(y1, x1, ym, x2);
		solve(y1, x1, ym, x2, a);
		solve(ym, x1, y2, x2, cnt - a);
	} else {
		int xm = (x2 + x1) / 2;
		int a = ask(y1, x1, y2, xm);
		solve(y1, x1, y2, xm, a);
		solve(y1, xm, y2, x2, cnt - a);
	}
}

int main()
{
	scanf("%d%d%d%d", &H, &W, &N, &K);
	solve(0, 0, H, W, N);

	int ret = 0;
	int pw = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret += C[i][j] * pw;
			ret %= K;
			pw = pw * 2 % K;
		}
	}
	printf("! %d\n", ret);
	return 0;
}


Measured memory_bytes: 504
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    int number = Integer.valueOf(a + b).intValue();
    String ans = "No";
    for (int i = 0; i * i <= number; i++) {
      if (i * i == number) {
        ans = "Yes";
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rep1(i,n) for (int i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;
int main(){
  ll a,b; cin >> a >> b ;
  cout << (a<=b ? a:a-1);
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;

// index が条件を満たすかどうか
bool isOK(vl &a,vl &b, ll index, ll key) {
	ll tim = 0;
	if (index > a.size() + b.size()) {
		return false;
	}
	ll ai, bi;
	if (index <= a.size()) {
		rep(i, index) tim += a[i];
		ai = index - 1;
		bi = 0;
	}
	else {
		rep(i, a.size()) tim += a[i];
		rep(i, index - a.size()) tim += b[i];
		ai = a.size() - 1;
		bi = index - a.size();
	}
	if (tim <= key) return true;
	while (ai >= 0 && bi < b.size()) {
		tim -= a[ai--];
		tim += b[bi++];
		if (tim <= key) return true;
	}
	return false;
}

ll binary_search(vl &a,vl &b, ll key) {
	ll ng = a.size()+b.size()+1;
	ll ok = 0;

	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;

		if (isOK(a,b, mid, key)) ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(void) {
	ll n, m, k;
	cin >> n >> m >> k;
	vl a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];
	ll ans = binary_search(a, b, k);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6368
N,M = map(int,input().split())
K,S=[],[]
for _ in range(M):
    ks = list(map(int,input().split()))
    K.append(ks[0])
    S.append(ks[1:])

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

ans = 0
for i in range(2**N):
    on_cnt = [0]*M
    ok = True
    for j in range(N):
        if (i>>j) & 1:
            for s in range(M):
                if (j+1) in S[s]:
                    on_cnt[s] += 1
    for t in range(M):
        if on_cnt[t] % 2 != p[t]:
            ok = False
    
    if ok:
        ans +=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll a,b,c,k;
   cin>>a>>b>>c>>k;
   ll no=0;
   while(b<=a)
   {
       b*=2;
       no++;
   }
   while(c<=b)
   {
       c*=2;
       no++;
   }
   if(no>k)
   {
       cout<<"No\n";
       return;
   }
   cout<<"Yes\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  in(n);
  out(800 * n - 200 * (n / 15));
  memi;
}

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

void main_()
{
    ll N;
    cin >> N;
    vector<ll> As;
    As.reserve(N + 1);
    As.push_back(0); // 1-origin
    copy_n(istream_iterator<ll>(cin), N, back_inserter(As));

    vector<ll> sums;
    sums.push_back(0);
    partial_sum(begin(As) + 1, end(As), back_inserter(sums),
        [odd = false](ll a, ll b) mutable {
            ll val = a + (odd ? b : -b);
            odd = !odd;
            return val;
        });

    for (ll i = 1; i <= N; ++i) {
        ll ans;
        if (i == 1) {
            ans = As[i] + As[N] + sums[N - 1] - sums[i];
        } else {
            ans = As[i] + As[i - 1]
                + ((i % 2 == 0) ? 1 : -1) * (sums[i - 2] - sums[N] + sums[i]);
        }
        cout << ans << " ";
    }
    cout << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

void DFS();
void tourist(int );

int k, G[MAX][MAX], d[MAX], clr[MAX], f[MAX], num=0;

int main()
{
  int i, j, u, r, n;

  scanf("%d", &k);
  for(i=0; i<=k; i++)
    {
      for(j=0; j<=k; j++)
	{
	  G[i][j] = 0;
	}
    }
  for(i=1; i<=k; i++)
    {
      scanf("%d %d", &u, &n);
      for(j=1; j<=n; j++)
	{
	  scanf("%d", &r);
	  G[u][r] = 1;
	}
      clr[u] = WHITE;
    }

  DFS();

  for(i=1; i<=k; i++) printf("%d %d %d\n", i, d[i], f[i]);

  return 0;
}

void DFS()
{
  int i; 

  for(i=1; i<=k; i++)
    {
      if(clr[i] == WHITE) tourist(i);
    }
}

void tourist(int u)
{
  int i;

  clr[u] = GRAY;
  d[u] = ++num;

  for(i=1; i<=k; i++)
    {
      if(G[u][i] == 1 && clr[i] == WHITE) 
	{
	  tourist(i);
	}
    }
  clr[u] = BLACK;
  f[u] = ++num;
}



Measured memory_bytes: 2148
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    PUTS(max(0, a-2*b));
}

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

int main(){
	int A,B,C;
	vector<int> v{ 1,2,3};
	cin >> A >> B;
	v[A-1]=0;
	v[B-1] = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i] != 0) {
			cout << v[i];
		}
	}
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s, w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe" << '\n';
    else cout << "safe" << '\n';

    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<20;



int main(){
    int N;cin >> N;
    double ans=0.0;
    for (int i = 0; i < N; i++) {
        double x;
        string s;
        cin >> x >> s;
        if(s=="JPY") ans+=x;
        else ans+=x*380000;
    }
    cout <<setprecision(10)<<fixed<< ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std ;

struct ST
{
	int tx ,ty ;
	int kx ,ky ;
	int cnt ;
	ST( int a ,int s ,int d ,int f ,int g ) : tx( a ) ,ty( s ) ,kx( d ) ,ky( f ) ,cnt( g ){}
} ;

int mx[ 4 ] = { 1 ,0 ,0 ,-1 } ;
int my[ 4 ] = { 0 ,1 ,-1 ,0 } ;
int map[ 50 ][ 50 ] ;

int w ,h ;
int tx ,kx ;
int ty ,ky ;

void ans()
{
	queue< ST > que ;
	bool came[ 50 ][ 50 ][ 50 ][ 50 ] = { false } ;
	que.push( ST( tx - 1 ,ty - 1 ,kx - 1 ,ky - 1 ,0 ) ) ;
	came[ tx - 1 ][ ty - 1 ][ kx - 1 ][ ky - 1 ] = true ;
	while( ! que.empty() )
	{
		ST st = que.front() ;
		if( st.tx == st.kx && st.ty == st.ky )
		{
			cout << st.cnt << endl ;
			return ;
		}
		else if( st.cnt >= 100 )
		{
			break ;
		}
		que.pop() ;
		for( int i = 0 ; i < 4 ; i++ )
		{
			int j = 3 - i ;
			tx = st.tx + mx[ i ] ;
			kx = st.kx + mx[ j ] ;
			ty = st.ty + my[ i ] ;
			ky = st.ky + my[ j ] ;
			if( tx < 0 || tx >= w || ty < 0 || ty >= h || map[ ty ][ tx ] )
			{
				tx = st.tx ;
				ty = st.ty ;
			}
			if( kx < 0 || kx >= w || ky < 0 || ky >= h || map[ ky ][ kx ] )
			{
				kx = st.kx ;
				ky = st.ky ;
			}
			if( came[ tx ][ ty ][ kx ][ ky ] == false )
			{
				que.push( ST( tx ,ty ,kx ,ky ,st.cnt + 1 ) ) ;
				came[ tx ][ ty ][ kx ][ ky ] = true ;
			}
		}
	}
	cout << "NA" << endl ;
}

int main()
{
	while( cin >> w >> h ,h )
	{
		cin >> tx >> ty ;
		cin >> kx >> ky ;
		for( int i = 0 ; i < h ; i++ )
		{
			for( int j = 0 ; j < w ; j++ )
			{
				cin >> map[ i ][ j ] ;
			}
		}
		ans() ;
	}
}

Measured memory_bytes: 9368