akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

class rest {
public:
	int num, taste;
	std::string name;
};
static void exec()
{
	int N;
	get(N);

	std::vector<rest> rests(N);
	for (int i = 0; i < N; i++) {
		get(rests[i].name);
		get(rests[i].taste);
		rests[i].num = i + 1;
	}

	auto cmp = [](rest& a, rest& b) {
		if (a.name == b.name) {
			return a.taste > b.taste;
		}
		else {
			return a.name < b.name;
		}
	};
	std::sort(rests.begin(), rests.end(), cmp);

	for (int i = 0; i < N; i++) {
		printf("%d\n", rests[i].num);
	}
}


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

int main(){
  int64_t N,A,B;
  cin >> N >> A >> B;
  if(A%2==B%2){
    int64_t  x=(B-A)/2;
    int64_t mi=min(B-1,N-A);
    cout << min(x,mi) << endl;
  }else{
    int64_t ans=0;
    int64_t a=A;
    int64_t b=B;
    if(B-1<=N-A){
      ans=a-1;
      b-=ans;
      a=1;
      if(b%2!=a%2){
        b--;
        ans++;
      }
      cout <<  ans+min((b-a)/2,b-1) << endl;
      return 0;
    }else{
      ans=N-b;
      b=N;
      a+=ans;
      if(a%2!=b%2){
        ans++;
        a++;
      }
      cout << ans+min((b-a)/2,N-a) << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<LL, LL>
#define f first
#define s second
using namespace std;
const int MAXN = 200005;

LL n, d, a;
PII mon[MAXN];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    cin >> n >> d >> a;
    for (int i = 0; i < n; i++) {
        int x, h;
        cin >> x >> h;
        mon[i] = {x, h};
    }

    LL cur = 0, ptr = 0, ans = 0;
    vector<PII> bomb;
    sort(mon, mon + n);
    for (int i = 0; i < n; i++) {
        while (ptr < bomb.size() && bomb[ptr].f < mon[i].f) {
            cur -= bomb[ptr].s;
            ptr++;
        }
        LL rem = max(0LL, mon[i].s - cur), add = rem / a + (rem % a != 0);
        if (add) {
            ans += add;
            cur += add * a;
            bomb.push_back({mon[i].f + d + d, add * a});
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 9200
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int n = sc.nextInt();
      long k = sc.nextLong();

      double s = Math.pow(10,9);

      int x = (int)s + 7;

      int[] a = new int[n];
      for(int i=0;i<n;i++){
        a[i] = sc.nextInt();
      }

      int cnt1 = 0;
      int cnt2 = 0;
      int cnt = 0;
      long ans = 0;
      long aaa = 0;

      long c ;

      for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
          if(a[i]>a[j]){
            cnt1++;
          }
        }
        for(int j=i-1;j>=0;j--){
          if(a[i]>a[j]){
            cnt2++;
          }
        }
        cnt = cnt1 + cnt2;
        c = k*(k-1)/2 % x;
        aaa = (cnt * c) % x;
        ans = (ans + k*cnt1 + aaa) % x;
        cnt1 = 0;
        cnt2 = 0;
        cnt = 0;
        aaa = 0;
      }





      System.out.println(ans);
    }
}


Measured memory_bytes: 26208
#include<stdio.h>

int main(){
  int max, min;
  int read[1000];
  int n;
  int ans=1000000,tmp;
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&read[i]);
    if(i == 0){
      max = read[0];
      min = read[0];
    }
    //printf("%d ",read[i]);
    if(read[i] > max){
      max = read[i];
    }else if(read[i] < min){
      min = read[i];
    }
  }
  //printf("max=%d,min=%d\n",max,min);

  for(i=min;i<=max;i++){
    for(j=0;j<n;j++){
      tmp += (read[j] - i)*(read[j] - i);
    }
    if(tmp<ans){
      ans = tmp;
    }
    tmp = 0;
  }
  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#k = [int(i) for i in read().split()]
X = int(input())


def check(mid): # mid 以下のルンルン数は x 個以上？
    s = str(mid)
    L = len(s)    
    dp = [[0]*10 for _ in range(2)] # is_less, 上位桁
    for num,i in enumerate(s):
        ni = int(i)
        ndp = [[0]*10 for _ in range(2)] # is_less, 上位桁
        for is_less in range(2):
            for d in range(10 if is_less else ni+1):
                if d: ndp[is_less or d < ni][d] += dp[is_less][d-1]            
                ndp[is_less or d < ni][d] += dp[is_less][d]            
                if d<9: ndp[is_less or d < ni][d] += dp[is_less][d+1]            
        for j in range(1,10):
            if num == 0:
                if j==ni: ndp[0][j] += 1
                elif j<=ni: ndp[1][j] += 1
            else: ndp[1][j] += 1 
        dp = ndp
        #print(dp,num)
    return sum(dp[1])+sum(dp[0]) >= X

ng = 0
ok = 3234566668
while ok-ng > 1:
    mid = (ok+ng)//2
    if check(mid): ok = mid
    else: ng = mid

print(ok)


Measured memory_bytes: 3064
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n = I()
a = LI()

if len(a)==len(set(a)):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 27148
#include<bits/stdc++.h>
#define ll long long
#define uint unsigned
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
using namespace std;
const int N=100005;
int n,x,b[N],l[N],r[N];
struct node{
	int id;
	ll v1,v2;
	bool operator <(const node &a)const{
		return v1-v2>a.v1-a.v2;
	}
}v[N];
ll ans,sp[N],sf[N];
int check(int id,int S,ll dif){
	//printf("%d %d %lld\n",id,S,dif);
	if (dif==0)
		ans=min(ans,1ll*x*S+b[id]);
	if (dif<0){
		ll ano=(-dif-1)/r[id]+1;
		if (b[id]+ano<=x)
			ans=min(ans,1ll*x*S+b[id]+ano);
		else return 0;
	}
	if (dif>0){
		if (dif-1ll*r[id]*b[id]>0) return 2;
		ll ano;
		if (dif-1ll*l[id]*b[id]>=0) ano=0;
		else{
			ano=1ll*l[id]*b[id]-dif;
			ano=(ano-1)/l[id]+1;
		}
		ans=min(ans,1ll*x*S+ano);
	}
	return 1;
}
int main(){
	scanf("%d%d",&n,&x);
	For(i,1,n){
		scanf("%d%d%d",&b[i],&l[i],&r[i]);
		v[i]=(node){i,1ll*(x-b[i])*r[i],1ll*(-b[i])*l[i]};
	}
	sort(v+1,v+n+1);
	ans=1ll<<60;
	For(i,1,n) sp[i]=sp[i-1]+v[i].v1;
	Rep(i,n,1) sf[i]=sf[i+1]+v[i].v2;
	For(i,1,n){
		//printf("check %d %lld\n",i,ans);
		int l=0,r=n;
		while (l<=r){
			int mid=(l+r)/2;
			ll SP=sp[mid]-(i<=mid?v[i].v1:0);
			ll SF=sf[mid+1]-(i>mid?v[i].v2:0);
			int cnt=mid-(i<=mid);
			if (check(v[i].id,cnt,SP+SF)==0) l=mid+1;
			else r=mid-1;
		}
	}
	printf("%lld\n",ans);
}
/*
5 1
5 5

G=G*F

egf::(e^x+e^(-x))/2

3.5
*/

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
//#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch AllGreen | diff AllGreen.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address AllGreen.cpp && ./a.out

/*
 
 5/14/2020
 
 10:09-
 
 */

const int MAX_N=10+1;
LL P[MAX_N],C[MAX_N],G;
int N;

const int Inf=1e7;
void solve() {
  int res=Inf;
  REP(mask,1<<N) {
    int cnt=0;
    LL tot=0;
    vector<int> ps;
    REP(i,N) {
      if((mask>>i)&1) tot+=P[i]*(i+1)+C[i],cnt+=P[i];
      else ps.emplace_back(i+1);
    }
    LL rem=G-tot;
    dump(mask,rem);
    if(rem>0&&SZ(ps)) {
      int p=*max_element(ALL(ps));
      int x=min(P[p-1]-1,(LL)(rem+p-1)/p);
      cnt+=x,rem-=x*p;
      dump(mask,p,x,cnt,rem);
    }
    dump(mask,cnt,rem);
    if(rem<=0) SMIN(res,cnt);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>G;
  G/=100;
  REP(i,N) cin>>P[i]>>C[i],C[i]/=100;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  rep(i, n) cin >> s[i];

  bool y = false;

  rep(i, n){
    if(s[i] == 'Y') y = true;
  }

  if(y){
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

class COM{
  public:
    COM(void){
      return;
    };
    ~COM(void){
      return;
    };
    ll calc(ll n, ll k){
      if(n<k) return 0;
      if(n<0 || k<0) return 0;
      ll tmp=1;
      k=min(k, n-k);
      for(int i=0; i<k; ++i){
        tmp*=(n-i);
        tmp/=(i+1);
      }
      return tmp;
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, A, B;
  cin >> N >> A >> B;
  vll v(N);
  REP(i, N) cin >> v[i];

  sort(v.begin(), v.end(), greater<ll>());

  double ave = 0.0;
  REP(i, A){
    ave += (double)v[i];
  }
  ave /= (double)A;

  bool flag=true;

  ll tmp = v[0];
  ll count=1;
  FOR(i, 1, A){
    if(tmp==v[i]){
      count++;
    }else{
      tmp=v[i];
      count=1;
      flag = false;
    }
  }

  ll count2=count;
  FOR(i, A, N){
    if(tmp==v[i]){
      count2++;
    }
    else break;
  }

  COM com1;
  ll ans=0;
  if(flag){
    FOR(i, A, B+1){
      ans += com1.calc(count2, i);
    }
  }else{
    ans = com1.calc(count2, count);
  }

  printf("%.12lf\n", ave);
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  int l = 0, r = s.size()-1;
  int cnt = 0;
  while (l < r) {
    if (s[l] == s[r]) {
      l++; r--;
    } else if (s[l] == 'x') {
      l++;
      cnt++;
    } else if (s[r] == 'x') {
      r--;
      cnt++;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << cnt << endl;

  return 0;
}

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

int main(){
  int a,b,k;
  cin >>a >>b >>k;
  int minab = min(a,b);
  int ans = 0;
  int cnt2 = 0;
  for(int i = minab;;i--){
    if(a%i == 0 && b%i == 0) cnt2++;
    if(cnt2 == k) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from math import sqrt
MAX = 2**15-1
ub = int(sqrt(MAX))
square_sum = [[0 for i in range(MAX)] for j in range(4)]
for k in range(1,ub+1):
	square_k = k**2
	square_sum[0][square_k-1] = 1 
	for j in range(3):
		for i in range(1,MAX - square_k + 1):
			if square_sum[j][i-1] >= 1:
				square_sum[j+1][i-1+square_k] += square_sum[j][i-1]
while 1:
	n = int(raw_input())
	if n == 0:
		break
	print sum(square_sum[i][n-1] for i in range(4))

Measured memory_bytes: 6584
#include <iostream>

int main(void){
    int A, B;
    std::string S, ans="Yes";
    std::cin >> A >> B >> S;

    for (int i=0; i<A+B+1; ++i){
        if (i != A && S.at(i) == '-'){
            ans = "No";
            break;
        } else if (i == A && S.at(i) != '-') {
            ans = "No";
            break;
        }
    }

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


Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
//#define int long long

string s;
const long long MOD = 998244353;
int dp[5000][5000];
int cnt[5000];

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.size(); i++) cnt[i] = (i > 0 ? cnt[i - 1] : 0) + s[i] - '0';
    dp[0][0] = 1;
    for (int i = 1; i <= 2 * s.size(); i++)
    {
        for (int j = 0; j <= 2 * s.size(); j++)
        {
            if (j <= cnt[min(i - 1, (int)s.size() - 1)] &&
                i - j <= 2 * min(i, (int)s.size()) - cnt[min(i - 1, (int)s.size() - 1)])
                dp[i][j] = ((j > 0 ? dp[i - 1][j - 1] : 0) + dp[i - 1][j]) % MOD;
        }
    }
    cout << dp[2 * s.size()][cnt[s.size() - 1]];
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }


int main() {
  int n; cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  rep(i, n) {
    cin>>s[i]>>t[i];
  }
  string x; cin>>x;

  int ans = 0;
  bool flag = false;
  rep(i, n) {
    if (flag) ans += t[i];
    if (s[i] == x) flag = true;
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define lowbit(x) (x&-x)
const ll INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double EPS=1e-7;
const int N=5e5+10;
const ll mod=998244353;
const ll MOD=998244353;
inline ll read()  
{  ll f=1,x=0;char ch=getchar();
   for(;ch>'9'||ch<'0';ch=getchar())if(ch=='-') f=-1;
   for(;ch<='9'&&ch>='0';ch=getchar())x=(x<<3)+(x<<1)+(ch^48);
   return x*f;
}
struct node
{ int sum,id;
  bool operator <(const node &a)const{
     return sum>a.sum;
  }
}a[N],b[N];
int n,m,k;
map<int,map<int,int> >ma;
void solve()
{  cin>>n>>m>>k;
   for(int i=1;i<=k;i++)
   {  int x,y;
      x=read(),y=read();
      a[x].sum++;
      b[y].sum++;
      a[x].id=x;
      b[y].id=y;
      ma[x][y]=1;
   }
   sort(a+1,a+1+310000);
   sort(b+1,b+1+310000);
   int x,y,ans=0;
   for(int i=1;i<=300000;i++)
   {  if(a[i].sum<a[i-1].sum)break;
      if(a[i].sum+b[1].sum<=ans)break;
      x=a[i].id;
      for(int j=1;j<=300000;j++)
      {  if(b[j].sum<b[j-1].sum)break;
         y=b[j].id;
         ans=max(ans,a[i].sum+b[j].sum-ma[x][y]);
      }
   }
   printf("%d\n",ans);
}
int main()
{  int t=1;
   while(t--)  
   {  
      solve();
   }
}

Measured memory_bytes: 64788
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int d,n;
int hot[501];
int a[501],b[501],c[501];
int dp[501][501];
int main(void){
	scanf("%d%d",&d,&n);
	for(int i=0;i<d;i++)scanf("%d",&hot[i]);
	for(int i=0;i<n;i++)scanf("%d%d%d",&a[i],&b[i],&c[i]);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		if(a[i]<=hot[0] && hot[0]<=b[i])dp[1][c[i]]=0;
	}
	for(int i=1;i<d;i++){
		for(int j=0;j<200;j++){
			if(dp[i][j]!=-1){
				for(int k=0;k<n;k++){
					if(a[k]<=hot[i] && hot[i]<=b[k]){
						dp[i+1][c[k]]=max(dp[i+1][c[k]],dp[i][j]+abs(c[k]-j));
					}
				}
			}
		}
	}
	int res=0;
	for(int i=0;i<200;i++)res=max(res,dp[d][i]);
	printf("%d\n",res);
	return 0;
}

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

typedef std::bitset<2010> B;
B a, b, d, pre[2010], suc[2010], pa[2010], sa[2010];
char buf[2010]; int n, ans = std::numeric_limits<int>::max();
#define inc(X, Y) (((X) & (Y)) == (Y))
void solve() {
	B d;
	for (int i = 0; i < n; ++i) {
		d = a ^ pre[i]; int cur = n - 1;
		int dc = d.count();
		for (int j = 0; j < n && j * 2 + i + dc < ans; ++j) {
			while (cur >= 0 && inc(sa[j] | pa[cur], d)) --cur;
			int t = cur + 1;
			ans = std::min(ans, j * 2 + t + std::abs(t - i) + dc);
		}
	}
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> buf; n = strlen(buf);
	for (int i = 0; i < n; ++i) if (buf[i] & 1) a.set(i);
	std::cin >> buf;
	for (int i = 0; i < n; ++i) if (buf[i] & 1) b.set(i);
	if (b.none() && a != b) return std::cout << -1 << std::endl, 0;
	*pre = *suc = b;
	for (int i = 1; i < n; ++i) {
		pre[i] = pre[i - 1] >> 1; pre[i][n - 1] = pre[i - 1][0];
		suc[i] = suc[i - 1] << 1; suc[i][0] = suc[i][n]; suc[i].reset(n);
	}
	for (int i = 0; i < n; ++i) pa[i] = pre[i], sa[i] = suc[i];
	for (int i = 1; i < n; ++i) pa[i] |= pa[i - 1], sa[i] |= sa[i - 1];
	solve(); std::swap(pa, sa); std::swap(pre, suc); solve();
	std::cout << ans << std::endl;
	return 0;
}


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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"

#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))


#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e5 + 7;
vector <vi > adj;
bool vis[N];
int arr[105];
int dp[105][100005];



void solve()
{
	int n, k;
	cin >> n >> k;
	loop(i, 1, n + 1) cin >> arr[i];

	dp[0][0] = 1;
	loop(i, 1, n + 1)
	{
		loop(j, 0, k + 1)
		{
			int ans = 0;
			if (i - 1 >= 0) ans += dp[ (i - 1) ][j];
			if (j - 1 >= 0) ans += dp[ i ][j - 1], ans %= M;
			if (j - arr[i] >= 0 )
			{
				ans -= dp[ (i - 1) ][ j - 1 - arr[i] ];
				ans %= M;
			}
			if ( ans < 0 ) ans += M;
			dp[i][j] = ans;

		}
	}

	cout << dp[n][k] << endl;

	return;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cout << setprecision(9) << fixed;

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


	return 0;
}


Measured memory_bytes: 79360
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long[] map = new long[100002];
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans = 0;
        for(int i = 0; i <= k; i++){
            for(int j = 0; j <= k; j++){
                if(s-i-j >= 0 && s-i-j <= k){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
 
int main(void){
    int i,j;
    int a,b,c;
    
    i=0;
    j=0;
    
    cin>>a>>b>>c;

     if(a==5) i++;
     if(a==7) j++;
     if(b==5) i++;
     if(b==7) j++;
     if(c==5) i++;
     if(c==7) j++;

    
     if(i==2 && j==1){ 
     	cout << "YES" <<endl;
     }else{
        cout << "NO" <<endl;
    	  }
    
    return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n;
    cin >> n;
    lint ans = 1;
    REP(i, n){
        ans *= i + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	int maxf = 0;
	int maxcd = 0;
	double maxconq = -1;
	for (int i1 = 0; i1 <= 30; i1++) {
		if (i1*a * 100 <= f) {
			for (int i2 = 0; i2 <= 30; i2++) {
				if (i1 != 0 || i2 != 0) {
					for (int i3 = 0; i3 <= 3000; i3++) {
						if ((i1*a + i2 * b)*e >= i3 * c) {
							for (int i4 = 0; i4 <= 3000; i4++) {
								double conq = ((double)i3*c + i4 * d) / (100.0 * i1*a + 100.0 * i2*b + (double)i3*c + i4 * d);
								if (100 * i1*a + 100 * i2 *b + i3 * c + i4 * d <= f && (i1*a + i2 * b)*e >= i3 * c + i4 * d) {
									if (maxconq < conq) {
										maxconq = conq;
										maxf = 100 * i1*a + 100 * i2*b + i3 * c + i4 * d;
										maxcd = i3 * c + i4 * d;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << maxf << " " << maxcd << endl;
}

Measured memory_bytes: 256
n = int(input())
w = [input()]
for i in range(1,n):
  w.append(input())
if len(set(w)) != n:
  print("No")
else:
  for i in range(1,n):
    if w[i-1][-1] != w[i][0]:
      print("No")
      break
  else:
      print("Yes")

Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <iomanip>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	int a, b;
	cin >> a >> b;
	double ans = INF;
	for (double i = 1; i <= 200000; i++) {
		//cout << i << " " << floor(i * 0.08) << " " << floor(i * 0.1) << endl;
		if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
			
			ans = min(ans, i);
		}
	}
	if (ans != INF) { cout << ans << endl; }
	else { cout << "-1" << endl; }
	
	

	

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double EPS=1e-9;
const long long INF = 100001000010000100ll;

template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;


int N, K, T;

vector<pii> l;

ll dp[10+10][2000+10];
int cnt[10+10];


ll dp2[2000+10];

int main(){

	cin >> N >> K;

	memset(dp, 0, sizeof(dp));
	memset(cnt, 0, sizeof(cnt));
	memset(dp2, 0, sizeof(dp2));
	T=0;
	rep(i, N){
		int a,b;
		cin >> a >> b;
		b--;
		T=max(T, b);
		l.pb(mp(b, -a));
	}
	sort(all(l));
	rp(i, l){
		cnt[l[i].first]++;
		dp[l[i].first][cnt[l[i].first]] = dp[l[i].first][cnt[l[i].first] - 1] - l[i].second;
		//printf("%d %d %d\n",l[i].first,cnt[l[i].first],dp[l[i].first][cnt[l[i].first]]  );
	}
	rep(i, T+1){
		REP(j,1, cnt[i] + 1){
			dp[i][j] += (j - 1) * j;
			//cout << dp[i][j] << " ";
		}
		//cout << endl;
	}

	for(int j=0;j < T+1;j++){
		for(int i=K;i >= 0;i--){
			for(int k=1;k <= cnt[j]; k++){
				if(i - k >= 0){
					dp2[i] = max(dp2[i], dp2[i - k] + dp[j][k]);
				}
			}
		}
	}
	//cout << endl;

	cout << dp2[K] << endl;



	return 0;

}

Measured memory_bytes: 1568
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	ll n,s=0;
	cin>>n;
	n--;
	for(ll i=1;i<=n;i++)
	{
		s+=n/i;
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
typedef long long ll;
#define vll vector<long long> 
#define pll pair<ll,ll>
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define all(v)  (v).begin(),(v).end()
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main(){
	char c;cin>>c;
	if(islower(c)) cout<<"a\n";
	else cout<<"A\n";
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
std::random_device rd;
std::mt19937 mt(rd());
constexpr int MOD = 1e9+7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

string S; int K;

int dp[303][303][303];
int rec(int l, int r, int k) {
	if(dp[l][r][k])return dp[l][r][k];
	int res = 0;
	if (l == r)res = 1;
	else if (l + 1 == r) {
		if (S[l] == S[r] || k>0)res = 2;
		else res = 1;
	}
	else {
		chmax(res, rec(l + 1, r, k));
		chmax(res, rec(l, r - 1, k));
		if (S[l] == S[r])chmax(res, rec(l + 1, r - 1, k) + 2);
		else if (k > 0)chmax(res, rec(l + 1, r - 1, k - 1) + 2);
	}
	return dp[l][r][k] = res;
}

void solve() {
	cin >> S >> K;
	int N = S.size();
	print(rec(0, N-1, K));
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 215296
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a ; cin >> a ;
  rep(i,10){
    if(pow(2,(i+1)) > a) {
      cout << pow(2,i) << endl;
      return 0;
    }
  }
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                          
using namespace std;
int a,b; 
int main(){
    cin>>a>>b;
    if(a*b%2==0) cout<<"Even";
    else cout<<"Odd";
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  deque<char> st;
  bool rev=false;
  string s;
  cin>>s;
  rep(i,s.size() ){
    st.push_back(s[i]);
  }

  // cout<<endl;
  int q;
  cin>>q;
  rep(i,q){
    int t;
    cin>>t;
    if(t==1){
      if(rev) rev=false;
      else if(rev==false) rev=true;
    }else{
      int f;
      cin>>f;
      char c;
      cin>>c;
      if(f==1){
	if(rev) st.push_back(c);
	else st.push_front(c);
      }else{
	if(!rev) st.push_back(c);
	else st.push_front(c);
      }
    }
  }
  if(rev){
    repn(i,st.size()-1){
      cout<<st[i];
    }
    cout<<endl;
  }else{
    rep(i,st.size() ){
      cout<<st[i];
    }
    cout<<endl;
  }
      
	 

  return 0;
}


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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int m=(int)(n/1.08);		
		while((m+1)*1.08<(n+1))
		{
			m++;
		}
		if((int)(m*1.08)==n)
		{
			System.out.println(m);
		}
		else
		{
			System.out.println(":(");
		}
			
	}
}
	

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

int main() {
    string w;
    cin>>w;
    int cnt=0;
    while(1){
        string x;
        cin>>x;
        if(x=="END_OF_TEXT") break;
        for(int i=0;i<x.size();i++){
            x[i]=tolower(x[i]);
        }


        if(x==w) cnt++;

    }
    cout<<cnt<<endl;
}


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

int main(){
    int a, b, h, m;
    double s,x;
    double ans;

    cin >> a >> b >> h >> m;

    s = (60 * h - 11 * m) * 3.14159265358979323846 / 360;
    
    x = pow(a, 2) + pow(b, 2) - 2 * a * b * cos(s);
    //cout << s << endl;
    ans = sqrt(x);
    //printf("%.10f\n", ans);
    cout << fixed << setprecision(15) << ans << endl;
    //cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 4292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BStringRotation {
public:
    void solve(std::istream &in, std::ostream &out) {
        string S, T;
        in >> S >> T;
        T += T;
        bool res = T.find(S) != -1;
        out << (res ? "Yes" : "No") << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BStringRotation solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3616
n = int(input())
s = input()

a = [0, 0, 0]
for i in s:
    if i == "R":
        a[0] += 1
    elif i == "G":
        a[1] += 1
    else:
        a[2] += 1

ans = a[0] * a[1] * a[2]
for i in range(n):
    for j in range(1, n):
        if i + j * 2 >= n:
            continue
        if len(set([s[i], s[i + j], s[i + 2 * j]])) == 3:
            ans -= 1
print(ans)


Measured memory_bytes: 68272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (b % a == 0 ? a + b : b - a) << endl;

    return 0;
}

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

int main() {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n = nxt();
	long long k;
	scanf("%lld", &k);
	vector<int> a(n * 2);
	for (int i = 0; i < n; ++i) {
		a[i] = a[i + n] = nxt();
	}

	vector<int> nx(2 * n, -1);
	map<int, int> M;
	for (int i = 2 * n - 1; i >= 0; --i) {
		if (M.count(a[i])) {
			nx[i] = M[a[i]];
		}
		M[a[i]] = i;
	}

	long long total = 0;
	int idx = 0;
	do {
		total += nx[idx] - idx + 1;
		idx = (nx[idx] + 1) % n;
	} while (idx > 0);
	assert(total % n == 0);
	k %= total / n;
	k *= n;
	while (nx[idx] - idx + 1 < k) {
		k -= nx[idx] - idx + 1;
		idx = (nx[idx] + 1) % n;
	}

	vector<int> b;
	set<int> S;
	while (k--) {
		if (S.count(a[idx])) {
			while (S.count(a[idx])) {
				S.erase(b.back());
				b.pop_back();
			}
		} else {
			S.insert(a[idx]);
			b.push_back(a[idx]);
		}
		idx = (idx + 1) % n;
	}

	for (int x : b) {
		printf("%d ", x);
	}
	printf("\n");

	return 0;
}

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

string n;
int k, len;
long ans = 0;

void solve(int i,int now,int nonzero) {
	long tmp;
	if ( (i<0) || (nonzero<0) )return;
	int nokori = len - i - 1;

	if (n[i]-'0' == now) {
		if (i == len - 1) {
			if (nonzero != 0)return;
			tmp = 1;
//			cout << i << "[" << now << "] tmp = " << tmp << endl;
			ans += tmp;
		}
		else {
			for (int j = 0; j <= n[i + 1] - '0'; j++) {
				if (j == 0) {
					solve(i + 1, j, nonzero);
				}
				else {
					solve(i + 1, j, nonzero - 1);
				}
			}
		}
	}
	else {
		if(nonzero == 0) {
			tmp = 1;
		}
		else if (nonzero == 1) {
			tmp = 9 * nokori;
		}
		else if (nonzero == 2) {
			tmp = 81 * nokori*(nokori- 1) / 2;
		}
		else {
			tmp = 729 * nokori*(nokori-1)*(nokori-2) / 6;
		}
//		cout << i << "[" << now << "] tmp = " << tmp << endl;
		ans += tmp;
	}
	return;

}


int main()
{

	cin >> n;
	cin >> k;
	len = n.length();

	if (len < 2) {
		if (k == 1) {
			cout << n << endl;
		}
		else {
			cout << 0 << endl;
		}
		return 0;
	}

	solve(0, 0, k);
	for (int i = 1; i <= n[0] - '0'; i++) {
		solve(0, i, k - 1);
	}

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


Measured memory_bytes: 256