akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    ll x;
    cin >> x;
    for(ll a = -200; a <= 200; a++){
        for(ll b = -200; b <= 200; b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

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

int main() {
  int n, m;
  cin >> n >> m;
  int p;
  string s;
  int wa = 0;
  map<int, int> mp;
  rep(i, m) {
    cin >> p >> s;
    if (mp[p] != -1) {
      if (s == "AC") {
        wa += mp[p];
        mp[p] = -1;
      } else {  // s == "WA"
        mp[p]++;
      }
    }
  }
  int ans = 0;
  for (auto x : mp)
    if (x.second == -1) ans++;
  cout << ans << ' ' << wa << endl;
  return 0;
}


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

#define Max(a, b) ((a>b)?a:b)

int main() {
  int n;
  cin >> n;
  int a[n], cnt[100000] = {};
  for (int i=0; i<n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  int ans = 0;
  for (int i=1; i<100000-1; i++)
    ans = Max(ans, cnt[i-1]+cnt[i]+cnt[i+1]);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1024
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=sorted(a,reverse=True)
d=deque(b)
ans=0
tmp=0
flag1=False
flag2=False
while d:
    if d[0]==tmp and flag1==False:
        flag1=True
        d.popleft()
        h1=tmp
        tmp=0
    elif flag1 and d[0]==tmp:
        h2=tmp
        ans=h1*h2
        break
    elif d[0]!=tmp:
        tmp=d.popleft()
print(ans)

Measured memory_bytes: 14636
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

int main() {
	int n, c;
	cin >> n >> c;
	int lie = 0;
	for (int i = 0; i < c; i++) {
		int cake;
		cin >> cake;
		lie += cake;
	}
	cout << (lie + n) / (n + 1) << endl;
	return 0;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL N, K, sum[300040], tmp[300050], b[300050], tree[300050], a[300050];
int cnt;
void insert(int x){
	for(;x <= cnt; x += -x & x){
		tree[x]++;
	}
}
LL ask(int x){
	LL ans = 0;
	for(;x > 0; x -= -x & x){
		ans += tree[x];
	}
	return ans;
}
int find(LL x){
	int l = 1, r = cnt;
	while(l <= r){
		int mid = (l + r) >> 1;
		
		if(b[mid] == x){
			return mid;
		}
		if(b[mid] > x)r = mid - 1;
		else l = mid + 1;
	}
	return -1;
}
int main(){
//	freopen("game16.in", "r", stdin);
	cin>>N>>K;
	LL ans = 0;
	for(int i = 1;i <= N; i++){
		scanf("%lld", &a[i]);
		sum[i] = sum[i-1] + a[i] - K;
		if(sum[i] >= 0)ans++;
		tmp[i] = sum[i];
	}
	sort(tmp + 1, tmp + N + 1);
	b[++cnt] = tmp[1];
	for(int i = 2;i <= N; i++){
		if(tmp[i] == tmp[i-1])continue;
		b[++cnt] = tmp[i];
	}
	for(int i = 1;i <= N; i++){
//		printf("yuan=%d\n", sum[i]);
		sum[i] = find(sum[i]);
//		printf("sum[%d]=%lld\n", i, sum[i]);
	}
	for(int i = 1;i <= N; i++){
		ans += ask(sum[i]);
		insert(sum[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10752
n, s = int(input()), input()
w = [0] * n
e = [0] * n

for i in range(1,n):
  w[i] = w[i-1] + 1 if s[i-1] == "W" else w[i-1]
for i in range(0,n-1)[::-1]:
  e[i] = e[i+1] + 1 if s[i+1] == "E" else e[i+1]

tmp = []
for i in range(n):
  tmp.append(w[i]+e[i])
print(min(tmp))
  

Measured memory_bytes: 29728
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <fstream>
#include <math.h>
#include <iomanip>
#include <deque>
#include <map>
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 505;

int dist[MAXN][MAXN];
int used[MAXN][MAXN];
int n;

void get(int i, int j, vector<pair<int, int> >& a) {
	if (i > 0)
		a.push_back({ i - 1, j });
	if (i < n - 1)
		a.push_back({ i + 1, j });
	if (j > 0)
		a.push_back({ i, j - 1 });
	if (j < n - 1)
		a.push_back({ i, j + 1});
}

int main() {
	cin >> n;
	int N = n * n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dist[i][j] = min(min(i, n - i - 1), min(j, n - j - 1));
		}
	}
	vector<int> arr(N);
	for (int i = 0; i < N; i++) {
		cin >> arr[i];
		arr[i]--;
	}
	int ans = 0;
	for (int k = 0; k < N; k++){
		int i1 = arr[k] / n;
		int j1 = arr[k] % n;
		ans += dist[i1][j1];
		used[i1][j1] = 1;
		deque<pair<int, int> > D;
		D.push_back({ i1, j1 });
		while (D.size() > 0) {
			auto elem = D[0];
			D.pop_front();
			int i2 = elem.first;
			int j2 = elem.second;
			vector<pair<int, int> > hel;
			get(i2, j2, hel);
			for (auto elem2 : hel) {
				int i3 = elem2.first, j3 = elem2.second;
				if (dist[i3][j3] > dist[i2][j2] + 1 - used[i2][j2]) {
					dist[i3][j3] = dist[i2][j2] + 1 - used[i2][j2];
					D.push_back({ i3, j3 });
				}
			}
		}
	}
	cout << ans << endl;
}
//*/

Measured memory_bytes: 6252
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n];
    rep(i, n) cin >> a[i];
    int sm = 0;
    rep(i, n) sm += a[i];
    int num = 0;
    int b;
    if (sm % (4 * m) == 0){
        b = sm / (4 * m);
    }else{
        b = sm / (4 * m) + 1;        
    }
    
    rep(i, n){
        if (a[i] >= b){
            num++;
        }
    }
    if (num >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
using namespace std;
#define repn(i,s,n) for (int i=int(s); i < int(n); i++)
#define rep(i,n) repn(i,0,n)
#define repd(i,n) for (int i=int(n)-1; i >= 0; i--)

typedef vector<int> VI;


int main() {
  int n;
  cin >> n;
  VI ps(n);
  rep(i,n) cin >> ps[i];

  VI state(n);  // 0: undefined, 1: traversing, 2:fixed
  VI dest(n);   // テ」ツδ榲」ツつケiテ」ツ?ォテヲツュツ「テ」ツ?セテ」ツ?」テ」ツ?淌ヲツ卍づ」ツ?ョティツ。ツ古・ツ?暗」ツ??1テ」ツ?ェテ」ツつ嘉ァツ?。テゥツ卍静」ツδォテ」ツδシテ」ツδ療」ツ??

  function<int(int)> dfs = [&](int v) -> int {
    if (ps[v] == 0) {
      // vテ」ツ?古・ツ按ーテァツ敖?・ツ慊ーテ」ツ?ョテ」ツδ榲」ツつケ
      state[v] = 2;
      return dest[v] = v;
    }
    if (state[v] == 2) {
      // vテ」ツ?古・ツ按ーテァツ敖?・ツ慊ーテ」ツ?古」ツ?ゥテ」ツ?禿」ツ?凝ァツ「ツコテ・ツョツ堙」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツδ榲」ツつケ
      return dest[v];
    }
    if (state[v] == 1) {
      // テァツ?。テゥツ卍静」ツδォテ」ツδシテ」ツδ療ヲツ、ツ愿・ツ?コ
      return -1;
    }
    state[v] = 1;
    dest[v] = dfs(v + ps[v]);  // テ・ツ?暗」ツ?クテゥツ?イテ」ツつ禿」ツ?ァテァツ「ツコテ・ツョツ堙」ツ?陛」ツ?崚」ツつ?
    state[v] = 2;
    return dest[v];
  };
  rep(i, n) {
    if (state[i] == 0) dfs(i);
  }

  // テゥツ鳴凝・ツァツ凝ァツつケテ」ツ?凝」ツつ嘉・ツケツ?・ツ?ェテ・ツ?暗ヲツ篠「テァツエツ「
  queue<int> que;
  que.push(0);
  VI dist(n, -1);
  dist[0] = 0;

  while(!que.empty()) {
    int v = que.front();
    que.pop();
    repn(i, v+1, v+7) {
      if (i >= n) break;
      int d = dest[i];
      if (d == -1) continue;
      if (dist[d] != -1) continue;
      dist[d] = dist[v] + 1;
      que.push(d);
    }
  }

  cout << dist[n-1] << endl;
  return 0;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int k;
    cin >> k;
    int s[] = { 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << s[k-2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> to(n+1,vector<int>(0,0));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> v(n);
  rep(i,n) v[i] = i+1;
  int ans = 0;
  do{
    if(v[0] != 1) continue;
  	bool fail_at_least_i = 0;
    rep(i,n-1){
      int now = v[i];
      int next = v[i+1];
      bool suc_at_least_j = 0;
      rep(j,to[now].size()){
        if(to[now][j] == next) suc_at_least_j = 1;
      }//j
      if(!suc_at_least_j) fail_at_least_i = 1;
    }//i
    if(!fail_at_least_i) ans ++;
  }while (next_permutation(v.begin(), v.end()));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

int main() {
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t;
	for(char c : s) {
		if(c == 'C' && t.size() && t.back() == 'B') t.back() = 'D';
		else t.push_back(c);
	}
	long long ans = 0;
	int combo = 0;
	while(t.size()) {
		char c = t.back(); t.pop_back();
		if(c == 'A') ans += combo;
		else if(c == 'D') combo++;
		else combo = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 916
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        int Hh = H - h;
        int Ww = W - w;

        int res = Hh * Ww;

        System.out.println(res);
    }

}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, K;
  cin >> N >> K;

  string S;
  cin >> S;

  vector<int> stand;
  char prev = '1';
  int len = 0;
  for(int i = 0; i < N; i++){
    if(S[i] == prev){
      len++;
    } else{
      stand.push_back(len);
      len = 1;
    }
    if(i == N-1) stand.push_back(len);
    prev = S[i];
  }
  if(S[N-1] == '0') stand.push_back(0);
  
  if( 2*K+1 >= stand.size()){
    cout << N << endl;
    return 0;
  }
  
  int sum = 0;
  for(int i = 0; i < 2*K+1; i++) sum+=stand[i];
  int ans = sum;
  for(int i = 2; i+2*K <= stand.size(); i+=2){
    sum -= stand[i-1];
    sum -= stand[i-2];
    sum += stand[i-1+2*K];
    sum += stand[i+2*K];
    if(ans < sum) ans = sum;
  }
  cout << ans << endl;
  return 0;
}




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

typedef long long ll;

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
g = defaultdict(int)
h,w,m = map(int, input().split())
d = [0]*(3*10**5+1)
e = [0]*(3*10**5+1)
for i in range(m):
  h,w = map(int, input().split())
  g[h*(3*10**5+1)+w]+=1
  d[h]+=1
  e[w]+=1
h1=max(d)
w1=max(e)
ans=h1+w1
h = []
l = []
for i in range(3*10**5+1):
  if d[i] == h1:
    h.append(i)
  if e[i] == w1:
    l.append(i)
for i in h:
  for j in l:
    if g[i*(3*10**5+1)+j]==0:
      print(ans)
      exit()
print(ans-1)

Measured memory_bytes: 166432
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int x, n;
int p[105];

int main(){
	scanf("%d%d", &x, &n);
	for(int i=1; i<=n; ++i){
		int c;
		scanf("%d", &c);
		p[c] = 1;
	}
	if(p[x] == 0){
		printf("%d\n", x);
		return 0;
	}
	int cnt, cntt;
	cnt = 1, cntt = 1;
	for(int i=x-1; i>=1; --i){
		if(p[i] != 0)  cnt++;
		else break;
	}
	for(int j=x+1; j<101; ++j){
		if(p[j] != 0)  cntt++;
		else break;
	}
	if(cnt <= cntt)
		printf("%d\n", x-cnt);
	else printf("%d\n", x+cntt);
	return 0;
} 

Measured memory_bytes: 3216
#include<iostream>
main(){int p[30001],M=30001,T,a,i,j,k;for(i=1;i*i++<M;)for(j=i+i;!p[i]&j<M;j+=i)p[j]=1;for(;std::cin>>T,T;printf("%d\n",a))for(a=0,i=2;i<T;i++)for(j=i;!p[i]&j<=(k=T-i-j);)!p[j]&!p[k]&i+j++>k&&a++;}

Measured memory_bytes: 0
print([0,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,121645100408832000,2432902008176640000][int(input())])


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#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 rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO

int main(){
    int n ;
    vector<string> s;
    cin>>n;
    rep(i,n){
        string S;
        cin>>S;
        s.push_back(S);
    }
    
    sort(s.begin(),s.end());
    
    int ans=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    
    cout<<ans<<endl;
    
    

}


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

int main() {
  int n, m;
  cin >> n >> m;
  ll total = 0;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    total += a;
  }
  ll ans = n - total;
  if (ans >= 0) cout << n - total << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    using P = pair<int, int>;
    vector<P> v(m);
    for(int i = 0; i < m; i++)
    {
        P p;
        cin >> p.second >> p.first;
        v[i] = p;
    }
    sort(v.begin(), v.end());

    int i = 0;
    int ans = 0;
    while(i < m)
    {
        int e = v[i].first;
        while(i < m && v[i].second < e) i++;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    double x1,y1,x2,y2,X,Y,r;
    cin >> x1 >> y1 >> x2 >> y2;
    //Xはx1,x2の距離,Yはy1,y2の距離
    X =  x1 - x2;
    Y =  y1 - y2;
    r = sqrt(X * X + Y * Y);

    cout << fixed << setprecision(8) << r << endl;

}


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

int main()
{
int a,b,c;
  cin>>a>>b>>c;
  
  bool ans=false;
    
  if(a==b&&a!=c)
    ans=true;
  
  else if(b==c&&b!=a)
    ans=true;
  
  else if(a==c&&b!=a)
    ans=true;
  
  else ans=false;  
  
  if(ans)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
from decimal import *

a, b = input().rstrip().split(' ')

getcontext().prec = max(len(a), len(b)) + 1

ans = Decimal(a) / Decimal(b)
ans = ans.quantize(Decimal('1.'), rounding=ROUND_DOWN)
if ans == 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 6380
def main():
    A, B, C = map(int, input().split())
    if A == B:
        if B==C:
            print("No")
        else:
            print('Yes')
    else:
        if B==C:
            print('Yes')
        else :
            if C==A:
                print("Yes")
            else :
                print("No")
main()



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

    string s;
    cin >> s;

    int a = 0, b = 0, c = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'a') a++;
        else if (s[i] == 'b') b++;
        else c++;
    }
    
    bool ok;
    if (abs(a - b) <= 1 && abs(a - c) <= 1 && abs(b - c) <= 1) ok = true;
    else ok = false;

    cout << (ok ? "YES" : "NO") << endl;

}

Measured memory_bytes: 3184
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<queue>
#include<set>
typedef long long ll;
using namespace std;


int main(){
    int n;
    cin>>n;
    vector<int>A(n);
    vector<int>B(n);
    vector<int>C(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        cin>>B[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>C[i];
    }
    int sum = 0;
    int prev = -1;
    for(int i=0;i<n;i++){
        sum += B[A[i]-1];
        if(A[i]==prev+1 && A[i]>1){
            //cout<<"a:"<<prev<<endl;
            sum += C[prev-1];
        }
        prev = A[i];
    }
    cout<<sum<<endl;
    return 0;
}

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


//SHORTCUTS

#define ll long long
#define endl '\n'
#define i1(a) cin>>a
#define i2(a,b) cin>>a>>b
#define i3(a,b,c) cin>>a>>b>>c
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define f(i,a,b) for(int i = a;i<b;i++)
#define fe(i,a,b) for(int i = a;i<=b;i++)
#define fi(i,a,b) for(i=a;i<b;i++)
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair


// DEBUG CODE & FAST OUTPUT

#define printv(a) for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
#define printvl(a) for (int i = 0; i < a.size(); i++) cout << a[i] << endl;
#define printa(a, n) for (int i = 0; i< n; i++) cout << a[i] << ' ';
#define printal(a, n) for (int i = 0; i < n; i++) cout << a[i] << endl;


//DATA STRUCTURES

#define pq priority_queue
#define ms multiset
// #define y0 _y0_
// #define y1 _y1_
// #define div divi

typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

//IMP CONSTANT
const int mod = 1e9 + 7, inf = 1e9 + 7;
const ll infll = 1e18 + 7;
bool google_contest = false;


//MODULAR OPERATIONS
ll myadd(ll a,ll b){
    ll ans = a+b;
    ans-= ans>=mod ? mod : 0;
    return ans; 
}
ll mysub(ll a, ll b){
    return (a-b+mod)%mod;
}
ll mymul(ll a,ll b){
    return (a*b)%mod;
}
ll mypow(ll a, ll b){
    ll ans = 1;
    while(b>0)
        if(b&1) ans = mymul(ans,a),b--;
        else a = mymul(a,a),b >>= 1;
    return ans;
}
ll nCr(ll n,ll r){
    if(r==0)return 1;
    if(r==1)return n;
    if(n==0)return 0;
    return mymul(n,mymul(nCr(n-1,r-1),mypow(r,mod-2)));
}

//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    | 



int main(){

ios_base::sync_with_stdio(0);
cin.tie(0); 
cout.tie(0);

int t,tt;
t=1;
// i1(t);
if(google_contest)tt=1;

while(t--){

int k;
i1(k);

string s;
i1(s);
if(s.length()<=k)o1(s);
else {
    string a = s.substr(0,k);
    o1((a+"..."));
}

if(google_contest){
    cout<<"Case "<<tt++<<": ";
}
}

return 0;   
}


//    /\    |  |\  /|                      
//   /__\   |  | \/ |           
//  /    \  |  |    |   OVER!!!!


Measured memory_bytes: 3608
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

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

  for(long long int i = 0; i < S.length(); i++){
    std::cout << 'x';
  }std::cerr << std::endl;

  return 0;
}


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

typedef long long int ll;

#define endl '\n'

ll n,k;
ll arr[100005];
ll dp[100005];

ll solve(ll i)
{
    if(i==n-1){
        return 0;
    }
    //cout<<i<<endl;
    if(dp[i]==-1){

        ll val = 1e18;

        for(ll ii=1;ii<=k;ii++){
            if(ii+i<n){
                val = min(val,abs(arr[i]-arr[ii+i])+solve(ii+i));
            }
          	else{
            	break;
        	}
        }
        dp[i] = val;
    }
    //cout<<i<<" "<<dp[i]<<endl;
    return dp[i];
}

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

    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }

    cout<<solve(0)<<endl;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int h,n; cin>>h>>n;
	int a,ret=0;
	for (int i=0; i<n; i++)
		cin>>a,ret+=a;
	cout<<((h<=ret)?"Yes":"No");
	return 0;
}


Measured memory_bytes: 256
s = input()
if 1<=int(s[0:2])<=12 and 1<=int(s[2:4])<=12:
    print("AMBIGUOUS")
elif 1<=int(s[0:2])<=12:
    print("MMYY")
elif 1<=int(s[2:4])<=12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int a,b;
	int sum;
	int loop_i,loop_j;
	int cnt=0;

	while(scanf("%d %d",&a,&b) != EOF){
		sum = 0;
		sum = a+b;
		for(loop_i = 0;sum != 0;loop_i++) sum/= 10;
		printf("%d\n",loop_i);
	}
	return 0;
}

Measured memory_bytes: 1028
#パーティション

N = int(input())
*A, = map(int, input().split())
 
def partition(A, p, r):
    x = A[r]
    i = p
    for j in range(p, r):
        if A[j] <= x:
            A[i], A[j] = A[j], A[i]
            i += 1
        
        
    A[i], A[r] = A[r], A[i]
    
    return i
 
j = partition(A, 0, N-1)
print(*(str(x) if i != j else "[%d]" % x for i, x in enumerate(A)))


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


int main(){
    int n,p[200][3];
    cin>>n;
    for(int i=0;i<n;++i){
        for(int j=0;j<3;++j) cin>>p[i][j];
    }
    int sum[200]={0};
    for(int i=0;i<3;++i){
        int c[101]={0};
        for(int j=0;j<n;++j) ++c[p[j][i]];
        for(int j=0;j<n;++j) if(c[p[j][i]]<2) sum[j] +=p[j][i];
    }
    for(int i=0;i<n;++i) cout<<sum[i]<<endl;
    return 0;
}

Measured memory_bytes: 3092
MOD = 1000000007

n, k = map(int, raw_input().split())
a = map(int, raw_input().split())

dp = [[0] * (k + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(1, n + 1):
    suma = 0
    l = 0
    r = 0
    for j in range(k + 1):
        if l < j - a[i - 1]:
            suma -= dp[i - 1][l]
            l += 1
        if r <= j:
            suma += dp[i - 1][r]
            r += 1
        suma %= MOD
        dp[i][j] += suma
        dp[i][j] %= MOD
print(dp[n][k])


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

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

    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a[200001],s;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
	int left=i+1,right=n; 
	while(left<=right)
	{
		int mid=(right+left)/2;
		if(a[mid]==a[i])
		{
			cout<<"NO";
			return 0;
		}
		else
		if(a[mid]>a[i])
		right=mid-1;
		else
		if(a[mid]<a[i])
		left=mid+1;
	}
}
    cout<<"YES";
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <functional>
#include <map>
#include <cmath>
#include <deque>
#include <string>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	vector <int> vec;
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);a--;
		vec.push_back(a);
	}
	vector <int> ans;
	for(int i=0;i<n;i++)
	{
		vector <int> nxt;
		bool up=false;
		for(int j=vec.size()-1;j>=0;j--)
		{
			if(!up&&vec[j]==j)
			{
				up=true;
				ans.push_back(vec[j]);
			}
			else nxt.push_back(vec[j]);
		}
		if(!up)
		{
			puts("-1");
			return 0;
		}
		reverse(nxt.begin(),nxt.end());
		vec=nxt;
	}
	for(int i=n-1;i>=0;i--) printf("%d\n",ans[i]+1);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <set>
#include <unordered_set>

using namespace std;

typedef long long ll;

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() {
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);
    vector<vector<int>> fnd(n), blk(n);
    for (int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        fnd[a].push_back(b);
        fnd[b].push_back(a);
        uf.merge(a,b);
    }
    for (int i=0;i<k;++i){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        blk[a].push_back(b);
        blk[b].push_back(a);
    }
    for (int i=0;i<n;++i){
        int a = uf.size(i)-fnd[i].size()-1;
        for (int j : blk[i]) {
            if (uf.issame(i,j))
                --a;
        }
        cout<<a<<" ";
    }
}

Measured memory_bytes: 13432
n,m,k = map(int, input().split())

# ---------------------------------------
# nCr(n, r, m) テンプレ
mod = 998244353

fac = [1,1] # 階乗 n!
inv = [0,1] # 逆元 1/n
finv = [1,1] # 逆元の階乗 (n^-1)! = (1/n)!

for i in range(2, n+1):
    fac.append( (fac[-1] * i ) % mod )
    inv.append( (-inv[mod%i] * (mod//i)) % mod )
    finv.append( (finv[-1] * inv[-1]) % mod )

def nCr(n, r, m):
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m
# ----------------------------

ans = 0
colors = m
for p in range(n-1, -1, -1):
    if p <= k:
        groups = nCr(n-1, p, mod)
        ans += groups * colors % mod
        ans %= mod
    colors *= m - 1
    colors %= mod
ans += mod
ans %= mod
print(ans)


Measured memory_bytes: 32964
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();

        Pair hoge = fuga(N);

        System.out.println(hoge.sum());
    }
    private static Pair fuga(long number) {
        double sqrt = Math.sqrt(number);
        long floor = (long) Math.floor(sqrt);

        long current = floor;
        while (current > 0) {
            if (number % current == 0) {
                return new Pair(current, number / current);
            }
            current--;
        }
        return new Pair(1L, number);
    }

    private static class Pair {
        long a;
        long b;
        Pair(long a, long b) {
            this.a = a;
            this.b = b;
        }

        public long sum() {
            return (a-1) + (b-1);
        }

        @Override
        public String toString() {
            return "(" + a + ", " + b + ")";
        }
    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

ll mod(ll a) {
	if (a > 0) return a % MOD;
	if (a % MOD == 0) return 0;
	ll x = -a / MOD + 1;
	a += x * MOD;
	return a % MOD;
}

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(double x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll n, k;
ll s[64] = {};
vector<ll> a;

ll rec(int i, ll tmp) {
	ll t	= 1ll << i;
	ll cnt1 = 0, cnt0 = 0;
	if (i < 0) return 0;
	for (int j = 0; j < n; ++j) {
		if ((a[j] & t) == t)
			cnt1++;
		else
			cnt0++;
	}
	if (cnt1 >= cnt0 || tmp + t > k) {
		return cnt1 * t + rec(i - 1, tmp);
	} else {
		return max(s[i] + cnt1 * t, rec(i - 1, tmp + t) + cnt0 * t);
	}
}

int main() {
	IOS();
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; ++i) { cin >> a[i]; }
	for (ll i = 62; i >= 0; --i) {
		ll t	= 1ll << i;
		ll cnt1 = 0, cnt0 = 0;
		for (int j = 0; j < n; ++j) {
			if ((a[j] & t) == t)
				cnt1++;
			else
				cnt0++;
		}
		if (cnt1 >= cnt0) {
			s[i + 1] = cnt1 * t;
		} else {
			s[i + 1] = cnt0 * t;
		}
	}
	for (int i = 1; i < 64; ++i) { s[i] = s[i - 1] + s[i]; }
	for (int i = 0; i < 63; ++i) {}
	ll ans = rec(62, 0);
	dump(ans);
}

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

int main()
{
    int a,c,n;
    
    cin >> n;
    
    if(n%2==0){
        double x =double(2)/4;
        
        cout << fixed << setprecision(10) << x << endl;
    }
    
    else
    {
      double  b = ceil(double(n)/2);
        cout << fixed << setprecision(10) << b/n << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 101;
ll x, k, d;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>x>>k>>d;
    ll ans= abs(x);
    if(x<0) {
        ll req = (-x)/d;
        if(k<req) {
            ans = abs(x+k*d);
        }else if(k>=req) {
            if((k&1)==(req&1)) {
                ans = abs(x%d);
            }else {
                ans = abs(x%d+d);
            }
        }

    }else {
        ll req = x/d;
        if(k<req) {
            ans = x-k*d;
        }else if(k>=req) {
            if((k&1)==(req&1)) {
                ans = x%d;
            }else {
                ans = abs(x%d-d);
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
from bisect import *
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
print(sum(bisect_left(A,b)*(N-bisect_right(C,b)) for b in B))

Measured memory_bytes: 29076
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<vector<int> > ans;
    vector<int> one;
    one.push_back(1);
    ans.emplace_back(one);
    ans.emplace_back(one);
    int l = 2;
    while (l <= n) {
        int need = ans.size();
        if (need + l - 1 > n) {
            cout << "No\n";
            return 0;
            break;
        }
        ans.emplace_back(vector<int>());
        for (int j = 0; j < need; j++) {
            ans.back().push_back(l);
            ans[j].push_back(l);
            l++;
        }
        if (l > n) break;
    }
    cout << "Yes\n";
    cout << ans.size() << "\n";
    for (auto it: ans) {
        cout << it.size();
        for (auto jt: it) cout << " " << jt;
        cout << "\n";
    }
    return 0;
}

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

using namespace std;

int main(){
	vector<int> a(3);
	for(int i=0;i<3;++i){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	if(a[0]+a[1] != a[2])cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io;
use std::fs::File;
use std::str::FromStr;
use std::io::BufReader;
#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = String;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let stones = input_vectors[0][0].chars();
    let mut previous_stone = input_vectors[0][0].chars().next().unwrap();
    let mut sum = 0;
    for stone in stones {
        if previous_stone != stone {
            sum += 1
        };
        previous_stone = stone;
    }
    println!("{}", sum);
}

Measured memory_bytes: 636
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        char[] C=new char[N];
            C=sc.next().toCharArray();
        int left=0;
        int right=N-1;
        int result=0;
        while(left<right){
            for(int i=left;i<=right;i++){
                left=i;
                if(C[i]!='R'){
                    break;
                }
            }
            for(int i=right;i>=left;i--){
                right=i;
                if(C[i]!='W'){
                    break;
                }
            }
            if(left>=right){
                break;
            }
            left++;
            right--;
            result++;
        }


        System.out.println(result);
    }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  int n,a; cin >> n >> a;
  cout << (n%500<=a ? "Yes" : "No") << endl;
}


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

typedef long long ll;

int main() {
    int N, A;
    map<int, int> mp;
    string ans = "YES";
    cin >> N;
    rep(i, N) {
        cin >> A;
        if (++mp[A] == 2) ans = "NO";
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int x,y;
  cin>>x>>y;
  rep(i,101){
    rep(j,101){
      if(i+j==x&&2*i+4*j==y){
        puts("Yes");
        return(0);
      }
    }
  }
  puts("No");
  return(0);
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  string s; 
  cin >> s;
  int sum=0;
  rep(i,3){
    if(s.at(i)=='1') sum++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#define ll long long
using namespace std;
int gcd(int a,int b) {
    while (a ^= b ^= a ^= b %= a);
    return b;
}
int T;
int main() {
//    for (cin >> T; T; T--) {
//
//    }
    int k,a,b,flag=0,num=0;
    scanf("%d%d%d",&k,&a,&b);
    for(int i=1;num<=b;i++)
    {
        num+=k;
        if(num>=a&&num<=b)
        {
            printf("OK");
            flag=1;
            break;
        }
    }
    if(!flag) printf("NG");
}

Measured memory_bytes: 3248
n = int(input())
a = 1
ans = 0
if a >= n:
    ans = 1
else:
    for i in range(2,n+1):
        a += i
        if a >= n:
            ans = i
            break
for k in range(1,ans+1):
    if a - n != k:
        print(k)
    else:
        continue

Measured memory_bytes: 9120
def main():
    input()
    a=input().split()
    if "0" in a:
        print(0)
        return
    s=1
    for i in a:
        s*=int(i)
        if s>1e+18:
            print("-1")
            return
    else:
        print(s)
    return
if __name__ == "__main__":
    main()

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


/*
int calc(int x){
    int ret = 0;
    while(x % 100 == 0){
        x = x/100;
        ++ret;
    }
    return ret;
}

int main(){
    int D, N;
    cin >> D >> N;
    int cnt=0, val = 0;
    while (cnt<N){
        ++val;
        if(calc(val) == D){
            ++cnt;
        }
    }
    cout << val << endl;
}
*/

int main(){
    int d,n; cin >> d >> n;
    if(d == 0){
        cout << n+n/100 << endl;
    }else if(d == 1){
        cout << (n+n/100)*100 << endl;
    }else{
        cout << (n+n/100)*10000 << endl;
    }
}

Measured memory_bytes: 3636
#include <stdio.h>

int binarySearch(int [], int, int);

int main(void)
{
    int n, q, S[100000], t, i, C;

    C = 0;

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

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &t);
        if (binarySearch(S, n, t) >= 0)
            C++;
    }

    printf("%d\n", C);
}

int binarySearch(int arr[], int size, int x)
{
    int low, mid, high;

    low = 0, high = size;

    while (low < high) {
        mid = (low + high) / 2;
        if (arr[mid] == x)
            return mid;
        else if (arr[mid] > x)
            high = mid;
        else
            low = mid + 1;
    }

    return -1;
}


Measured memory_bytes: 2112
S = list(input())
S.append('R')
N = len(S)

R_cnt = 0
L_cnt = 0

futureS = [0]*N

RLpoint = 0
for i in range(N):
    if S[i] == 'R':
        if L_cnt > 0:
            if R_cnt%2 == 0:
                futureS[RLpoint-1] += R_cnt//2
                futureS[RLpoint] += R_cnt//2
            else:
                futureS[RLpoint-1] += R_cnt//2+1
                futureS[RLpoint] += R_cnt//2
                
            if L_cnt%2 == 0:
                futureS[RLpoint-1] += L_cnt//2
                futureS[RLpoint] += L_cnt//2
            else:
                futureS[RLpoint-1] += L_cnt//2
                futureS[RLpoint] += L_cnt//2+1
            R_cnt = 1
            L_cnt = 0
        else:
            R_cnt += 1
    else:
        if L_cnt == 0:
            RLpoint = i
        L_cnt += 1

futureS.pop(-1)
ans = ''
for c in futureS:
    ans = ans + str(c) + ' '
print(ans.rstrip())

Measured memory_bytes: 5428
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef long double ld;


int main(){
  ll s,w;
  cin >> s >> w;
  if(w>=s){
    cout << "unsafe";
  }
  else{
    cout << "safe";
  }
  
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

struct edge {
    int to, cost;
};

int V;
vector<edge> G[1000000];
ll d[1000000];

void addedge(int st, int ed, int co) {
    edge e;
    e.to = ed;
    e.cost = co;
    G[st].push_back(e);
}

void dijkstra(int s) {
    priority_queue<plglg, vector<plglg>, greater<plglg> > que;
    fill(d, d + V + 10, llmax);
    d[s] = 0;
    que.push(plglg(0, s));

    while (!que.empty()) {
        plglg p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) {
            continue;
        }
        int len = G[v].size();
        for (int i = 0; i < len; i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(plglg(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int N;
    cin >> N;
    V = N;
    for (int i = 0; i < V; i++) {
        int p;
        cin >> p;
        if (p == 0) {
            for (int j = 1; j <= 6; j++) {
                addedge(i, i + j, 1);
            }
        } else {
            addedge(i, i + p, 0);
        }
    }
    dijkstra(0);
    ll ans = d[V - 1];
    cout << ans << endl;
}



Measured memory_bytes: 32080
t, x, y = 0, 0, 0
for i in range(int(input())):
    t_next, x_next, y_next = map(int, input().split())
    dif = abs(x - x_next) + abs(y - y_next)
    if dif > abs(t - t_next) or (dif - (t- t_next))%2 == 1:
        print('No')
        exit(0)
    t, x, y = t_next, x_next, y_next
print('Yes')

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
///////////////////////___combination___////////////////////
vector<ll> fac, finv, inv;
void COMinit(const int MAX = 5000000, const ll &MOD = MOD){
  fac.resize(MAX);finv.resize(MAX);inv.resize(MAX);
  fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
  repd(i,2,MAX){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
ll 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 n,c[210000],t[210000],dp[210000];
signed main(){
  cin>>n;rep(i,n)cin>>c[i];
  t[c[0]] = dp[0] = 1;
  repd(i,1,n){
    if(c[i] == c[i-1])dp[i] = dp[i-1];
    else{
      dp[i] = (dp[i-1] + t[c[i]]) %MOD;
      t[c[i]] = (t[c[i]] + dp[i-1]) % MOD;
    }
  }
  cout << dp[n-1] << endl;
}



Measured memory_bytes: 4992
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
#endif

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
typedef long long Long;

const int N = 1003;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  string s;
  cin >> s;

  for (char& c : s) {
    if (c == '?') c = 'D';
    cout << c;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3744