akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace  std;

#define ll long long
#define ull unsigned long long
#define f first
#define s second
typedef pair<int , int > pii;
typedef pair<ll,ll> pll;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

const ll MOD = 998244353;


void min_self(ll &a , ll b){a=min(a,b);}
void max_self(ll &a, ll b){a=max(a,b);}
ll add(ll x, ll y){return (x + y) % MOD;}
ll sub(ll x, ll y){return add(x, MOD - y);}
ll mul(ll x, ll y){return (x * 1ll * y) % MOD;}
ll binpow(ll x, ll y)
{
    ll z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}
ll inv(ll x){return binpow(x, MOD - 2);}
const int MXN = 1e6+10;
ll fact[MXN];
void fac_pre()
{
    fact[0]=1;
    for(ll i=1; i<MXN; i++){
        fact[i]=mul(fact[i-1],i);
    }
}
ll C(ll n, ll k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
// BIT //
const int MAXN=2*1e5+10;
vector<int> bit(MAXN,0);
int sump(int idx) {
    int ret = 0;
    for (++idx; idx > 0; idx -= idx & -idx)
        ret += bit[idx];
    return ret;
}

int sum(int l, int r) {
    return sump(r) - sump(l - 1);
}

void upd(int idx, int delta) {
    for (++idx; idx < MAXN; idx += idx & -idx)
        bit[idx] += delta;
}
/////-----//////
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll genRand(ll B) {
    return (ull)rng() % B;
}
///--//
int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    /* KEEP IN MIND
     * take care when sorting a 1 based indexed vector
     * const int N is defined way above in the starting
    */
    int n; cin>>n;
    vector<int> cnt(1e5+10,0);
    ll s=0;
    for(int i=0; i<n;i++){
        int x; cin>>x;
        cnt[x]++;
        s+=x;
    }
    int q; cin>>q;
    while(q--){
        ll b,c; cin>>b>>c;
        if( cnt[b]){
            ll ct=cnt[b];
            cnt[b]=0;
            cnt[c]+=ct;
            s+=ct*(c-b);
        }
        cout<<s<<endl;
    }
}








Measured memory_bytes: 4556
n = int(input())
d1 = []
d2 = []
for _ in range(n):
    a1,a2 = map(int,input().split())
    d1.append(a1)
    d2.append(a2)
count = 0
for i in range(n):
    if d1[i] == d2[i]:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        exit(0)
print("No")

Measured memory_bytes: 9192
import sys

def gcd(a, b):
	if a < b:
		a, b = b, a
	if not b:
		return a
	return gcd (b, a % b)
	
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(100004)]
r = [0 for i in range(100004)]

for i in range(n):
	l[i] = gcd(l[i-1], a[i])

for i in reversed(range(n)):
	r[i] = gcd(r[i+1], a[i])

ans = 0
for i in range(n):
	ans = max(ans, gcd(l[i-1], r[i+1]))
	
print(ans)


Measured memory_bytes: 14436
#include <iostream>
#include <vector>
using namespace std;
const int MAXn = 1e5 + 10;
vector<int> g[MAXn];
int n, odd[MAXn], even[MAXn];

int dfs(int v, int par) {
	if (g[v].size() == 1 && par != 0)
		return 1;
	int cnt = 0;
	for (int i = 0; i < g[v].size(); i++)
		if (g[v][i] != par) {
			cnt += dfs(g[v][i], v);
			
		}
	if (cnt > 1) {
		cout << "First";
		exit(0);
	}
	if (cnt == 1) 
		return 0;
	if (par == 0) {
		cout << "First";
		exit(0);
	}
		
	return 1;
}


int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u>> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, 0);
	
	cout << "Second";
	
}

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

pair<long long, long long> A[5];

int main() {
	for (int i = 0; i < 5; i++) {
		cin >> A[i].second;
		A[i].first = ((A[i].second + 9) % 10);
	}
	sort(A, A + 5);

	long long r = 0;
	for (int i = 4; i >= 0; i--) {
		r += A[i].second;
		if (i != 0) r = ((r + 9) / 10) * 10;
	}
	cout << r << endl;
	return 0;
}

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

int main() {
  
  string S;
  cin >> S;
  
  int s=0;
  for (int i=0; i<S.size(); i++) {
    if (S.at(i)=='+') s++;
  }
  
  cout << s*2-4 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int n; string s;
int main(){
  int count = 0;
  cin >> n >> s;
  for(int i = 0; i < n - 2 ;i++){
    if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
      ++count;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int a,b,c,d;
cin >> a >> b >> c >> d;
int x= c-a,y=d-b;
cout << c-y <<" "<<d+x <<" "<<a-y<<" "<<b+x<<endl;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int step[MAXN],x[MAXN],y[MAXN];
int main()
{
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		scanf("%d%d%d",&step[i],&x[i],&y[i]);
	}
	int x1 = 0,y1 = 0,qs = 0,flag = 0;
	for(int i = 0;i < n;i++){
		int sum = abs(x[i] - x1) + abs(y[i] - y1);
		if(step[i] - qs >= sum){
			if((sum - step[i] + qs) % 2 == 0){
				qs = step[i];
				x1 = x[i];
				y1 = y[i];
			}
			else{
				flag = 1;
				break;
			}
		}
		else {
			flag = 1;
			break;
		}
	}
	if(flag){
		printf("No\n");
	}
	else
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1408
# coding=utf-8


def solve_gcd_from_list(number_list):
    if len(number_list) == 1:
        return number_list[0]

    if len(number_list) == 2:
        return solve_gcd(number_list[0], number_list[1])
    mid = len(number_list) // 2
    return solve_gcd(solve_gcd_from_list(number_list[:mid]), solve_gcd_from_list(number_list[mid:]))


def solve_gcd(number1, number2):
    if number1 == number2:
        return number1

    if number1 < number2:
        number1, number2 = number2, number1

    if number1 % number2 == 0:
        return number2

    return solve_gcd(number2, number1 % number2)


if __name__ == '__main__':
    N, X = map(int, input().split())
    cities = list(map(int, input().split()))

    cities.append(X)
    cities.sort()

    distance_list = []

    for i in range(N):
        distance_list.append(cities[i+1]-cities[i])

    if len(distance_list) == 1:
        D = distance_list[0]
    else:
        D = solve_gcd_from_list(distance_list)
    print(D)


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

using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

  if (s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <fstream>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;



int isok(vector<int> &b){
	for(int i = 0 ; i < b.size() ; i++)
		if( b[i] != i+1 ) return 0;
	return 1;
}
int main(){
	int Q;
	cin >> Q;
	while(Q--){
		long long n = 0;
		for(int i = 0 ; i < 8 ; i++){
			char c;
			cin >> c;
			if( c >= 'a' ) c = c - 'a' + 10;
			else c = c - '0';
			n = 16 * n + (long long)c;
		}
		if( n & (1ll<<31) ){
			cout << "-";
		}
		//cout << "[" << n << endl;
		n = n & ~(1ll<<31);
		long long a = n / (1ll<<7);
		long long b = n % (1ll<<7);
		double B = 0 , W = 0.5;
		for(int i = 0 ; i < 7 ; i++){
			B += (b>>(6-i)&1) * W;
			W *= 0.5;
		}
		char tmp[128];
		sprintf(tmp,"%.16lf",(double)(a+B));
		string s = tmp;
		while(s[s.size()-1] == '0' && s[s.size()-2] != '.') s = s.substr(0,s.size()-1);
		cout << s << endl;
	}
}

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

int main() {
	ll m;
	cin >> m;
	vector<ll> d(m), c(m);
	for (int i = 0; i < m; i++) cin >> d[i] >> c[i];
	ll sum = 0;
	for (int i = 0; i < m; i++) sum += d[i] * c[i];
	sum = (sum - 1) / 9;
	ll ans = -1;
	for (int i = 0; i < m; i++) ans += c[i];
	cout << ans + sum << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
//#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


		


int main(){
	ll n,p;
	cin>>n>>p;
	if(n==1){
		cout<<p<<endl;
		return 0;
	}
	ll ans=1;
	int kon = (int)sqrt(double(p)) + 1;
	FOR(i,2,kon+1){
		ll a = 0;
		while(p%i == 0){
			p = p/i;
			a++;
		}
		rep(j,a/n){
			ans *= i;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N ;
  
  int cnt = 0;
  for (int i = 0; i< N ; i++){
   int s, e;
    cin >> s >> e;
    cnt += (e-s+1);
  }
  cout << cnt << endl;
 
  // ここにプログラムを追記
}


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

int main(){
	int K, S, a=0;
	cin >> K >> S;

	for(int X=0;X<=K;X++){
		for(int Y=0;Y<=K;Y++){
			if(S-X-Y<=K&&S-X-Y>=0) a++;
		}
	}
	cout << a ;
}

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

int main()
{
    int n;
    scanf("%d",&n);
    int mod = (n+1) / 2;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
           int now = 0, x = i, y = j;
           while (1) {
                now++;
                if (x % 2 != y % 2)
                    break;
                x /= 2; y /= 2;
           }
           printf("%d ", now);
        }
        if(i<n)puts("");
    }
}


Measured memory_bytes: 512
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int n;
vector<Int> p;

void solve(){
	int ans = 0;
	for(int i = 0;i + 2 < n;i++){
		vector<Int> v({p[i],p[i+1],p[i+2]});
		sort(ALL(v));
		if(v[1] == p[i+1])ans++;
	}
	cout<<ans<<endl;
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
    p.assign(n,Int());
    for(int i = 0 ; i < n ; i++){
        cin >> p[i];
    }
	solve();
	return 0;
}
//}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e8;
const ll infl = 1LL << 60;

int main(){
  int n,k;cin >> n >> k;
  vector<int> d(k);
  Graph a(k,vector<int>(100));
  vector<int> ans(n,0);
  rep(i,k){
      cin >> d[i];
      rep(j,d[i]){
        cin >> a[i][j],a[i][j]--;
      }
  }
  rep(i,k){
      rep(j,d[i]){
          ans[a[i][j]]++;
      }
  }
  int res = 0;
  rep(i,n) if(ans[i] == 0) res++;
  cout << res << endl;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int A, B, T;
  cin >> A >> B >> T;

  cout << T / A * B << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
*a,=map(int, input().split())

def gcd(a,b):
    while b: a,b=b,a%b
    return a

def lcm(a,b): return a*b//gcd(a,b)

ans = 1
for ai in a:
    ans = lcm(ans, ai)
print(ans)


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

using namespace std;

class MCMult
{
public:
  vector<vector<int>> mat;
  int solve();
};

int MCMult::solve()
{
  int ms = mat.size();
  vector<vector<int>> dp(ms, vector<int>(ms, 0));

  for ( auto i = 0; i < ms - 1; ++i )
    dp[i][i+1] = mat[i][0] * mat[i][1] * mat[i+1][1];

  for ( auto k = 2; k < ms; ++k )
    {
      for ( auto i = 0; i + k < ms; ++i )
        {
          int ret = dp[i+1][i+k] + mat[i][0] * mat[i][1] * mat[i+k][1];
          ret = min( ret, dp[i][i+k-1] + mat[i+k][0] * mat[i+k][1] * mat[i][0]);
          
          for ( auto j = i + 1; j < i + k - 1; ++j )
            {
              ret = min( ret, dp[i][j] + dp[j+1][i+k] + mat[i][0] * mat[j][1] * mat[i+k][1]);
            }
          dp[i][i+k] = ret;
        }
    }

  cout << dp[0][ms-1] << endl;
  
  return 0;
}

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

  MCMult m;

  for ( int i = 0; i < n; ++i )
    {
      int x;
      vector<int> v;
      
      cin >> x;
      v.push_back( x );
      cin >> x;
      v.push_back( x );
      
      m.mat.push_back( v );
    }
  
  m.solve();

  return 0;
}

Measured memory_bytes: 1264
import { readFileSync } from 'fs'

function main(input: string) {
  const [n, ...cities] = input.split('\n').map(Number)

  const neck = Math.ceil(n / Math.min(...cities))

  console.log(cities.length + neck - 1)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7372
#include <bits/stdc++.h> // only for GCC
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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

int main() {
  int n, m;  
  
  cin >> n;
  REP(i, n){
    cin >> m;
    VI v;
    REP(j, m) {
      int x;
      cin >> x;
      v.PB(x);
    }
    int up = 0, down = 0;

    REP(j, m) {
      if(j != m-1 && v[j+1]-v[j] > up) {
	up = v[j+1] - v[j];
      }
      if(j != 0 && v[j-1] - v[j] > down) {
	down = v[j-1] - v[j];
      }
    }
    cout << up << ' ' << down << endl;
  }  
}

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


int main() {
    int n;
    cin>>n;
    int L=0;
    int sum=0;
    for(int i=0;i<n;++i){
        int l;
        cin>>l;
        L=max(l,L);
        sum+=l;
    }
    sum-=L;
    if(L<sum)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = double.Parse(Console.ReadLine());
 
            Console.WriteLine(2.0 * r * Math.PI);
#if DEBUG
            Console.ReadLine();
#endif
        }
    }
}

Measured memory_bytes: 18612
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir [] = {
	{ 1,0 },{ 0,1 }
};

signed main() {
	int n;
	scanf("%d", &n);
	map<int, int> cou;
	REP(i, n) {
		int a;
		scnaf("%d", &a);
		cou[a]++;
		if (cou[a] == 3)
			cou[a] = 1;
	}
	int guc = 0;
	for(auto itr : cou) {
		if (itr.second == 2) {
			guc++;
		}
	}
	printf("%d\n", cou.size()-guc%2);
	return 0;
}

Measured memory_bytes: 4864
def main():
    n, a, b = map(int, input().split())
    quo = n // (a+b)
    rem = n % (a+b)
    ans = quo * a
    if a >= rem:
        ans += rem
    else:
        ans += a
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[] = {-1,0,1,0,-1,-1,1,1};
const int dy[] = {0,-1,0,1,1,-1,1,-1};

int main(){
  int q; cin>>q;
  rep(x,q){
    string s,t; cin>>s>>t;
    int dp[1010][1010];
    int n=s.size(),m=t.size();
    rep(i,n+1){
      rep(j,m+1){
        dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        if(s[i]==t[j])dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1]);
      }
    }
    /*if(x==3){
      rep(i,n+1){
        rep(j,m+1){
          cout<<dp[i][j];
        }
        cout<<endl;
      }
    }*/
    cout<<dp[n][m]<<endl;
  }
}



Measured memory_bytes: 7104
n, *lst = map(int, open(0).read().split())
a, b = sorted(lst)[n // 2 - 1:n // 2 + 1]
if a == b:
  print(*[a for _ in range(n)], sep='\n')
else:
  print(*[b if i <= a else a for i in lst], sep='\n')

Measured memory_bytes: 25052
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

vector<int> inv, fac, finv;

inline ll binomial(int a, int b) {
    return ((ll)fac[a] * finv[b] % MOD) * finv[a - b] % MOD;
}

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

    int N;
    cin >> N;

    vector<int> cnt(103, 1);

    for (int i = 2; i <= N; ++i) {
        int tmp = i, b = 1;
        for (int j = 2; j * j <= tmp; ++j) {
            while (tmp % j == 0) {
                tmp /= j;
                cnt[j]++;
            }
        }
        if (tmp > 1)
            cnt[tmp]++;
    }

    vector<int> cnt2(80, 0);
    cnt2[1] = 1;
    for (int i = 1; i <= N; ++i) {
        vector<int> cnttmp(80, 0);
        for (int j = 1; j <= cnt[i]; ++j) {
            for (int k = 75; k >= j; --k) {
                if (k % j)
                    continue;
                cnttmp[k] += cnt2[k / j];
            }
        }
        swap(cnttmp, cnt2);
    }

    cout << cnt2[75] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    int count = 0;
    if(s[0] == '1') count++;
    if(s[1] == '1') count++;
    if(s[2] == '1') count++;
    cout << count << endl;
    return 0;
}


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

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

    long long ans = 0;
    for (long long i = 0; i < n; i++) {
        long long t;
        cin >> t;
        ans += t - 1;
    }    
    cout << ans;
}

Measured memory_bytes: 3588
#include <stdio.h>
#define N 200000

int main(){
  int n, num[N]={0};
  int i = 0, j, max, minnum;
  
  scanf("%d", &n);
  
  while(i<n){
    scanf("%d", &num[i]);
    i++;
  }
  
  max = num[1] - num[0];
  minnum= num[0];
    
  for(i = 0; i < n; i++){
    if(minnum < num[i]){
      continue;
    }

    minnum = num[i];
    
    for(j = i+1; j < n; j++){
      if(max < num[j] - minnum){
	max = num[j] - minnum;
      }
    }  
  }
  
  /*  
  max = num[1];
  min = num[0];
  for(i = 1; i < n; i++){
    if(max <= num[i]){
      max = num[i];
      
      for(j = 0; j < i; j++){
	if(min > num[j]){
	  min = num[j];
	}
	
      }
    }
  }
  */
  
  printf("%d\n", max);
  
  return 0;
}




Measured memory_bytes: 2632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  string S,T,U;
  int A,B;
  cin >> S >> T >> A >> B >> U;
  if(S == U){
    cout << A-1 << " " << B <<endl;
  }
  else{
    cout << A << " " << B-1 <<endl;
  }
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n;
  int count_ac = 0;
  int count_wa = 0;
  int count_tle = 0;
  int count_re = 0;
  int i;
  string ans; 
  
  cin >> n;
  
  for(i = 0;i < n;i++){
  	cin >> ans;
    if(ans == "AC"){
      count_ac++;
    }else if(ans == "WA"){
      count_wa++;
    }else if(ans == "TLE"){
      count_tle++;
    }else{
      count_re++;
    }
  }
  
  cout << "AC x " << count_ac << endl;
  cout << "WA x " << count_wa << endl;
  cout << "TLE x " << count_tle << endl;
  cout << "RE x " << count_re << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t, x;
	cin >> t >> x;
	cout << fixed << setprecision(39) << t / (ld)x << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=1e5+5;
using namespace std;
struct Edge{int x,y;}e[N];
struct Node{
	long long d;int id;
	bool operator <(const Node &b)const{return d<b.d;}
}d[N];
int n,cnt;
long long size[N];
long long dis;
inline Node Make(long long _d,int _id){Node t;t.d=_d,t.id=_id;return t;}
int main(){
	
	register int i;
    long long x;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%lld",&x),d[i].d=x,d[i].id=i,size[i]=1;
	sort(d+1,d+n+1);
	for(i=n;i>=2;--i){
		long long t=d[i].d-n+size[i]*2;
		int pos=lower_bound(d+1,d+n+1,Make(t,0))-d;
		if(d[pos].d!=t) return puts("-1"),0;
		e[++cnt]=(Edge){d[i].id,d[pos].id};
		size[pos]+=size[i]; //
		dis+=size[i];
	}
	if(dis!=d[1].d) puts("-1");
	else
		for(i=1;i<=cnt;++i)
			printf("%d %d\n",e[i].x,e[i].y);
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
             
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> Pi;
typedef map<ll,ll> mi;
             
template<class T> T nrem(T x,T y){return ((x%y)+y)%y;}
             
#define For(i,a,n) for(int i=a;i<n;++i)
#define For0(i,n) for(int i=0;i<n;++i)
#define For1(i,n) for(int i=1;i<=n;++i)
#define Forl0(i,n) for(ll i=0;i<n;++i)
#define Forl1(i,n) for(ll i=1;i<=n;++i)
#define fi freopen("input.txt","r",stdin);
#define fo freopen("output.txt","w",stdout);
#define pb push_back
#define mp make_pair
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cs 200005
#define pi acos(-1)
#define INF (int)INFINITY
void in()
    {
         #ifndef ONLINE_JUDGE
         freopen("input.txt", "r", stdin);
         freopen("output.txt", "w", stdout);
        #endif
    }

vector<int> adj[cs];
int visited[cs];
int level[cs];

void bfs(int s)
{
    queue <int> Q;
    Q.push(s);

    visited[s]=1;
    level[s]=0;
    while(!Q.empty())
    {
        int u=Q.front();
        Q.pop();

        for(int i=0;i<adj[u].size();i++)
            if(visited[adj[u][i]]==0)
        {
            int v=adj[u][i];
            visited[v]=1;
            level[v]=level[u]+1;
            Q.push(v);
        }
    }
}

int main()
{  
    IOS
    in();
    
    int n,x;
    cin>>n>>x;

    int a[n];

    
    For0(i,n)
    cin>>a[i];
    
    ll op=0;

    for(int i=1;i<n;++i)
    {
        if(a[i]+a[i-1]>x)
        {
            int dif=a[i]+a[i-1]-x;

            a[i]-=dif;
            op+=dif;
            if(a[i]<0)
            {   
                a[i-1]+=a[i],a[i]=0;
                if(a[i-1]<0)
                op+=a[i-1],a[i-1]=0;
            }
        }
    }

    cout<<op<<endl;
   
}

Measured memory_bytes: 8708
import java.util.Scanner;

public class Main{
 public static void main(String[]args){
  try(Scanner sc = new Scanner(System.in)){
   String line = sc.nextLine();
   String answer = "";
   int length = line.length();
   for(int i = 0;i < length;i++){
    char ch = line.charAt(i);
    if(Character.isLowerCase(ch)){
    answer += Character.toUpperCase(ch);
    }
    else{
    answer += Character.toLowerCase(ch);
    }
   }
   System.out.println(answer);
  }
 }
}


Measured memory_bytes: 31276
#include<bits/stdc++.h>
#define ll long long
#define R register
using namespace std;
const int N =2e6+200;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int ans[N];
int main()
{
	int n, x, y;
	read(n), read(x), read(y);
	for(R int i=1; i<=n; i++)
	{
		for(R int j=i+1; j<=n; j++)
		{
			int dis=min(j-i, abs(i-x)+abs(j-y)+1);
			ans[dis]++;
		}
	}
	for(R int i=1; i<n; i++)printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Al = list(map(int,input().split()))
Ar = list(map(int,input().split()))

xl = [0]*(N+1); xr = [0]*(N+1)
xl[1] = Al[0]; xr[1] = Ar[0]
for i in range(2,N+1):
    xl[i] = xl[i-1] + Al[i-1]
    xr[i] = xr[i-1] + Ar[i-1]
ans = 0
for i in range(1,N+1):
    ans = max(ans,xl[i]+(xr[N]-xr[i-1]))
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>

using namespace std;

int main(void){
		vector<vector<int> > kek[31];
			vector<int> hn;
					vector<int> u;
		for(int i=0;i<31;i++){
			kek[i].clear();
		}
		
		
		for(int i=1;i<=30;i++){
			hn.clear();
			hn.push_back(i);
			kek[i].push_back(hn);
			
			for(int j=i-1;j>0;j--){
				
				for(int k=0;k<kek[i-j].size();k++){
					int flg=0;
					
					for(int p=0;p<kek[i-j][k].size();p++){
						if(kek[i-j][k][p]>j){
							flg=1;
							break;
						}
					}
					
					if(flg==1){
						continue;
					}
					
					u.clear();
					u.push_back(j);
					
					for(int p=0;p<kek[i-j][k].size();p++){
						u.push_back(kek[i-j][k][p]);
					}
					kek[i].push_back(u);
				}
			}
		}
		
		
	while(1){
		
		int n;
		scanf("%d",&n);
		if(n==0){break;}
		
		for(int j=0;j<kek[n].size();j++){
			printf("%d",kek[n][j][0]);
			for(int k=1;k<kek[n][j].size();k++){
				printf(" %d",kek[n][j][k]);
			}
			puts("");
		}
	}
}

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

int main ()
{
    int N;
    std::cin >> N;
    
    int A[110];
    for (int i = 0; i < N; i++) 
    {
        std::cin >> A[i];
    }
    
    sort(A, A+N);
    
    std::cout << A[N-1] - A[0] << std::endl;
    
    return 0;
}

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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int tj[2020];
char buf[200005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    gstr(buf);
	int n = strlen(buf);
	ll ans = 0; int cur = 0, p10 = 1;
	tj[0] = 1;
	for(int i=n-1; i>=0; i--) {
		cur = (cur + (buf[i] - '0') * p10) % 2019;
		p10 = p10 * 10 % 2019;
		ans += tj[cur];
		tj[cur]++;
	}
	print(ans);
}


Measured memory_bytes: 4012
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;

procedure Main is
	s:Integer;
    w:Integer;
begin
	get(s);
	get(w);
    put(s*(s-1)/2+w*(w-1)/2);
	new_line;
    
end Main;

Measured memory_bytes: 3728
#include <stdio.h>
#include <stdlib.h>

int fibonacci(int,int,int[]);

int main(int argc, char** argv) {
    int seqNum;
    scanf("%d",&seqNum);
    int fibNum[seqNum];
    for(int i = 0; i < seqNum; i++)
        fibNum[i] = NULL;
    printf("%d\n",fibonacci(seqNum,seqNum,fibNum));
    return (EXIT_SUCCESS);
}

int fibonacci(int sequence, int size, int fibArray[size]){
    if(sequence == 1 || sequence == 0){
        fibArray[sequence] = 1;
        return 1;
    }
    else if(fibArray[sequence] != NULL && sequence < size){
        return fibArray[sequence];
    }
    fibArray[sequence] = fibonacci(sequence-1,size,fibArray) + fibonacci(sequence-2,size,fibArray);
    return fibArray[sequence];
}



Measured memory_bytes: 2104
#include<iostream>
#include<iomanip>
#include<vector>
#include<complex>
#include<map>
#include<stack>

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<P,D> C;

const D EPS = 1e-8;
const D PI = acos(-1);

inline P unit(P p){return p/abs(p);}
inline D dot(P x, P y){return real(conj(x)*y);}
inline D cross(P x, P y){return imag(conj(x)*y);}

inline P rotate(P v, D s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(D a,D b,D c){return acos( (b*b+c*c-a*a)/(2*b*c) );}

inline int cpr(C a,C b){
  D d = abs(a.fs-b.fs);
  if(a.sc+b.sc + EPS < d)return -1;      //no cross point (outside)
  if(b.sc+d + EPS < a.sc)return 1;       //no cross point (inside,B in A)
  if(a.sc+d + EPS < b.sc)return 2;       //no cross point (inside,A in B)
  if(abs(a.sc+b.sc - d) < EPS)return -3; //one cross point (outside)
  if(abs(b.sc+d - a.sc) < EPS)return 3;  //one cross point (inside,B in A)
  if(abs(a.sc+d - b.sc) < EPS)return 4;  //one cross point (inside,A in B)
  return 0;                              //two cross point
}

inline vector<P> cp_cir_to_cir(C a, C b){
  vector<P> v;
  int pos = cpr(a,b);
  if(pos==0){
    D s = arg(b.sc,abs(b.fs-a.fs),a.sc);
    P x = a.sc * unit(b.fs - a.fs);
    v.pb(a.fs + rotate(x,s));
    v.pb(a.fs + rotate(x,-s));
  }else if(abs(pos) >= 3){
    v.pb(a.fs + a.sc * unit(b.fs-a.fs));
  }
  return v;
}

int main(){
  int n;
  while(cin >> n){
    if(n==0)return 0;

    D res = 0;
    vector<C> circles;
    for(int i=0;i<n;i++){
      int x,r;
      cin >> x >> r;
      circles.pb(C(P(x,0),r));
      res = max(res, sqrt(2)*r);
    }

    vector<D> position(n-1), height(n-1);
    for(int i=0;i<n-1;i++){
      P cp = cp_cir_to_cir(circles[i], circles[i+1])[0];
      position[i] = cp.real(); height[i] = cp.imag();
    }

    vector<D> L(n-1), R(n-1);
    stack<int> S;
    for(int i=0;i<n-1;i++){
      while(S.size() && height[S.top()]+EPS > height[i])S.pop();
      L[i] = S.size()?S.top()+1:0;
      S.push(i);
    }

    while(S.size())S.pop();
    for(int i=n-2;i>=0;i--){
      while(S.size() && height[S.top()]+EPS > height[i])S.pop();
      R[i] = S.size()?S.top()-1:n-2;
      S.push(i);
    }

    for(int i=0;i<n-1;i++){
      int l = L[i], r = R[i]+1;
      D h = height[i];
      D r1 = circles[l].sc, r2 = circles[r].sc;

      D a = 0, b = min(r1,r2), d = circles[r].fs.real() - circles[l].fs.real();
      for(int hoge=0;hoge<50;hoge++){
	D mid = (a+b)/2;
	if( sqrt(r1*r1-mid*mid) + sqrt(r2*r2-mid*mid) + d > 2*mid)a = mid;
	else b = mid;
      }
      res = max(res, min(2*h, 2*a) );
    }

    cout << fixed << setprecision(10) << res << endl;
  }
}

Measured memory_bytes: 4380
import math
if __name__ == "__main__":
    a, b, c, d = map(int, input().split())
    num_takahashi = math.ceil(c / b)
    num_aoki = math.ceil(a / d)
    
    if num_takahashi <= num_aoki:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9172
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    fn f(x: i64, m: usize, N: i64) -> i64 {
        let K = N.to_string().len();
        let s = x.to_string();
        let a = if x <= N && s.contains(&"7") && s.contains(&"5") && s.contains(&"3") { 1 } else { 0 };
        if m < K { a + f(10 * x + 7, m + 1, N) + f(10 * x + 5, m + 1, N) + f(10 * x + 3, m + 1, N) }
        else { a }
    }

    let ans = f(0, 0, N);

    println!("{}", ans);
}

Measured memory_bytes: 4352
from collections import Counter

N = int(input())
S = [input()[0] for i in range(N)]
S = [i for i in S if i in {'M', 'A', 'R', 'C', 'H'}]
s = list(Counter(S).values())
ans = 0

if len(set(S)) < 3:
    print(0)
else:
    for i in range(len(s) - 2):
        for j in range(i + 1, len(s) - 1):
            for k in range(j + 1, len(s)):
                ans += s[i] * s[j] * s[k]
    print(ans)

Measured memory_bytes: 4988
import java.util.Scanner;

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

        while(sc.hasNext()) {
            int n = Integer.parseInt(sc.next());

            int num = 0;
            for (int i = 0; i <= 9; i++) {
                for (int j = 0; j <= 9; j++) {
                    for (int k = 0; k <= 9; k++) {
                        for (int l = 0; l <=9; l++) {
                            if (i + j + k + l == n) num++;
                        }
                    }
                }
            }
            System.out.println(num);
        }
    }
}

Measured memory_bytes: 26336
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int count =0;
        int multiple=0;
        boolean flag = true;
        while(flag){
            count++;
            multiple=K*count;
            if(A<=multiple&& multiple<=B){
                System.out.println("OK");
                break;
            }
            if(multiple>=1000) {
                flag=false;
                System.out.println("NG");
                break;
            }
        }
        ;
    }
}

Measured memory_bytes: 35728
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define P 137  //check the limits, man
#define N 5005
const ll INF = 1e18;
bool cmp(ii A,ii B)
{
    return (A.S-B.F)<(B.S-A.F);
}
int dp[N][N];
int main()
{
    int n,i,j,a,b,c;
    in(n);
    vector<ii> vp(n);
    rep(i,n)
    {
        in2(a,b);
        vp[i]={b,a};
    }
    sort(all(vp),cmp);
    dp[0][1]=vp[0].F;
    lp(j,2,n+1)
        dp[0][j]=2*M;
    lp(i,1,n)
    {
        dp[i][0]=0;
        a=vp[i].F,b=vp[i].S;
        lp(j,1,n+1)
        {
            dp[i][j]=dp[i-1][j];
            if(dp[i-1][j-1]<=b)
                dp[i][j]=min(dp[i][j],dp[i-1][j-1]+a);
        }
    }
    rep(j,n+1)
    {
        if(dp[n-1][j]==2*M)
        {
            out(j-1);
            return 0;
        }
    }
    out(n);
}


Measured memory_bytes: 98048
# -*-coding: utf-8 -*-
N = int(input())

if N <= 111:
    print(111)
elif 111 < N <= 222:
    print(222)
elif 222 < N <= 333:
    print(333)
elif 333 < N <= 444:
    print(444)
elif 444 < N <= 555:
    print(555)
elif 555 < N <= 666:
    print(666)
elif 666 < N <= 777:
    print(777)
elif 777 < N <= 888:
    print(888)
elif 888 < N <= 999:
    print(999)

Measured memory_bytes: 3064
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define add(x) accumulate(x)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end() 
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
                void solve(){
                        int n,k;
                        cin>>n>>k;
                        vll vec(n);
                        rep(i,0,n)
                                cin>>vec[i];
                        int sm=accumulate(all(vec),0ll);
                        sm=ceil(sm/(double)(4*k));
                        sort(all(vec));
                        for(int i=n-1;i>=n-k;i--){
                                if(vec[i]<sm){
                                        cout<<"No";
                                        return ;
                                }
                        }
                        cout<<"Yes";
                }
                int main(){ 
                        hs;
                        ll t;
                        t=1;
                        // cin>>t;
                        for (int i=1; i<=t; i++){
                                //cout<<"Case #"<<i<<": ";
                                solve();
                         }
        return 0; 
}         
 

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<pll> p(N);
    REP(i, N){
    	cin >> p[i].first >> p[i].second;
    }

    ll M = 1000000;
    double kaku = 2*M_PI/M;
    double res = -1;
    REP(i, M){
    	double now = 0.01 + i*kaku;
    	double x = sin(now);
    	double y = cos(now);
    	double x_tmp = 0, y_tmp = 0;
    	//dump(now)
    	//dump(x)
    	//dump(y)
    	REP(j, N){
    		if(p[j].first * x + p[j].second * y >=0 ) x_tmp += p[j].first, y_tmp += p[j].second;
    	}
    	res = max(res, sqrt(x_tmp * x_tmp + y_tmp * y_tmp));
    	//dump(res)
    }
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 384
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
vector<string> r,s;
void fn(string t,vector<string> u){
  int i;
  if(t.empty()){
    for(i=0;i<(int)u.size()-1;i++)
      cout<<u[i]<<" ";
    cout<<u[i]<<"."<<endl;
  }else{
    for(i=0;i<(int)s.size();i++){
      if(t.substr(0,s[i].length())==s[i]){
	u.push_back(r[i]);
	fn(t.substr(s[i].length()),u);
	u.pop_back();
      }
    }
  }
  return;
}
int main(){
  int i,j;
  char a[27]="22233344455566677778889999";
  int n;
  while(cin>>n&&n){
    r.clear();
    s.clear();
    for(i=0;i<n;i++){
      string t,u;
      cin>>t;
      u=t;
      int ln=t.length();
      for(j=0;j<ln;j++)
	t[j]=a[t[j]-'a'];
      r.push_back(u);
      s.push_back(t);
    }
    string t;
    cin>>t;
    vector<string> u;
    fn(t,u);
    cout<<"--"<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define max(x, y) ((x) > (y) ? (x) : (y))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abs(x) ((x) < 0 ? (-(x)) : (x))
#define rep(i,a,m) for((i) = (a) ; (i) < (m) ; ++(i))
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.end(),x.begin()
#define sz(x) ((int)x.size())
#define PI 3.14159265

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pi;

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t,T;
	cin >> T;	
    vl vec(T);
    vl A(T,0);
	for(t = 1; t <= T; ++ t){
        cin >> vec[t-1];
	}
    A[0] = vec[0];
    A[1] = abs(vec[0]-vec[1]);
    if (T == 2) {
        cout << A[1] << endl;
        return 0;
    }
    A[0] = 0LL;
    //A[1] = 0LL;
    for(int i = 2; i < T; ++ i) {
        ll x = A[i-1] + abs(vec[i]-vec[i-1]);
        ll y = A[i-2] + abs(vec[i]-vec[i-2]);
        A[i] = min(x,y);
    }
    cout << A[T-1] << endl;
	return 0;
}

Measured memory_bytes: 1792