akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef string ST;
 
 
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 

 
LL modpow(LL a, LL n, LL mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

LL modinv(LL a, LL m) {
  LL b = m, u = 1, v = 0;
  while (b) {
    LL t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0){
     u += m;
  }
  return u;
}

bool isPrime(LL N)
{
  if (N < 2) {
    return false;
  }
  else if (N == 2) {
    return true;
  }
  else if (N % 2 == 0) {
    return false;
  }

  LD sqrtNum = sqrt(N);
  for (LL i = 3; i <= sqrtNum; i += 2)
  {
    if (N % i == 0)
    {
      return false;
    }
  }
  return true;
}

void func() {
  LL H;
  LL W;
  cin >> H;
  cin >> W;
  LL MOD = 1e9+7;
  vector<string> M(H);
  vector<vector<LL>> C(H,vector<LL>(W,0));

  REP(i,H){
    cin >> M[i];
  }


  C[0][0]=1;
  REP(i,H){
    REP(j,W){
      if(M[i][j]=='.'){
        if((j+1)<W && M[i][j+1]=='.'){
          C[i][j+1] += C[i][j];
          C[i][j+1] %= MOD;
        }
        if((i+1)<H && M[i+1][j]=='.'){
          C[i+1][j] += C[i][j];
          C[i+1][j] %= MOD;
        }
      }
    }
  }
  REP(i,H){
    //cout << M[i] << endl;
  }
  REP(i,H){
    //PRINTSP(C[i]);
  }

  cout << C[H-1][W-1];  

  return;
}



int main()
{
  func();
  return 0;
}
 

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

long long opnum[3] = {0}, n;
string s;

long long solve();
long long calc(int &id, int p);
long long number(int &id);

int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < 3; ++i)
    for(int j = 0; j < 3; ++j)
      for(int k = 0; k < 3; ++k) {
        int id = 0;
        opnum[0] = i;
        opnum[1] = j;
        opnum[2] = k;
        if(i == j && j == k && i == 0)
          ans = calc(id, 0);
        else
          ans = max(ans, calc(id, 0));
        assert(id == n);
      }
  return ans;
}

long long calc(int &id, int p) {
  long long res = 0;
  if(p != 2)
    res = calc(id, p + 1);
  else
    res = number(id);
  while(id < n) {
    if(s[id] == '+' && opnum[0] == p) {
      ++id;
      if(p != 2)
        res += calc(id, p + 1);
      else
        res += number(id);
    }
    else if(s[id] == '-' && opnum[1] == p) {
      ++id;
      if(p != 2)
        res -= calc(id, p + 1);
      else
        res -= number(id);
    }
    else if(s[id] == '*' && opnum[2] == p) {
      ++id;
      if(p != 2)
        res *= calc(id, p + 1);
      else
        res *= number(id);
    }
    else
      break;
  }
  return res;
}
long long number(int &id) {
  long long res = 0;
  if(s[id] == '(') {
    res = calc(++id, 0);
    assert(s[id] == ')');
    ++id;
  }
  else {
    assert(id < n && isdigit(s[id]));
    while(id < n && isdigit(s[id])) {
      res *= 10;
      res += s[id++] - '0';
    }
  }
  return res;
}



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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    string s;cin>>s;
    int n = s.length();
    if(s[n-1]=='s') s += "es";
    else s += 's';
    
    cout<<s<<"\n";

}




int main() {
   
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
    
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);  
   freopen("output.txt", "w", stdout); 
   #endif 

    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
        
    }
    
    return 0;
    
    
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}



Measured memory_bytes: 3664
#include <iostream>

int main()
{
	unsigned long N;
	std::cin >> N;

	unsigned long S = 0;
	unsigned long tmpN = N;

	for ( ; tmpN > 0; tmpN /= 10 )
	{
		S += tmpN % 10;
	}

	if ( N % S )
	{
		std::cout << "No" << std::endl;
	}
	else
	{
		std::cout << "Yes" << std::endl;
	}

	return ( 0 );
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  string s;
  cin >> s;
  
  if(s == "Sunny")
    cout << "Cloudy" << endl;
  if(s == "Cloudy")
    cout << "Rainy" << endl;
  if(s == "Rainy")
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string s;
    getline(cin,s);
    string ans;
    
    int used=0;
    for(int i=0; i<s.size();i++){
        if(s[i]==' ' || s[i]==','||s[i]=='.'){
            if(!(i-used<=2 || i-used>=7)){
                if(ans.size())ans+=' ';
                ans+=s.substr(used,i-used);
            }
            used=i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3152
N = gets.chomp.to_i
a = Array.new(N)
b = Array.new(N)
for i in 0...N do
    str = gets.split
    a[i],b[i] = str[0], str[1].to_i
end
X = gets.chomp

answer = 0
f = 1
for i in 0...N do
    if f == 0
        answer += b[i]
    else
        if X == a[i]
            f = 0
        end
    end
end

puts answer

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

using namespace std;

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

bool a[300000];

int main() {
    while(1) {
        int n; cin >> n;
        if(n == 0) break;
        
        // eratosthenes
        int N = 2*n+1;
        memset(a, true, N);
        REP(i, 2, sqrt(N)) {
            if(a[i]) {
                for(int j=0; i*(j+2)<N; j++) {
                    a[i*(j+2)] = false;
                }
            }
        }
        
        int ans = 0;
        rep(i, N) {
            if(i > n) if(a[i]) ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3308
from collections import deque

N,C,K = map(int, input().split())

T_list = list() #左がもっとも早く着いた人

for i in range(N):
    T = int(input())
    T_list.append(T)

T_list.sort(reverse=False)

waiting_deque = deque(T_list)
ans = 0

while 1:
    if len(waiting_deque) != 0:
        ans += 1
        bus_passenger = list()
        bus_passenger.append(waiting_deque.popleft())
        while 1:
            if len(waiting_deque)!=0 and len(bus_passenger) < C and bus_passenger[0] + K >= waiting_deque[0]:
                bus_passenger.append(waiting_deque.popleft())
            else:
                #print(bus_passenger)
                break
    else:
        break

print(ans)

Measured memory_bytes: 8120
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll a, b, c, d;

int main() {

	cin >> a >> b >> c >> d;



	cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    int vx[n];
    int vy[n];
    double sum1 = 0, sum2 = 0, sum3 = 0, chebyshev = 0;
    double d1, d2, d3;
    for (int i = 0; i < n; i++) {
        cin >> vx[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> vy[i];
    }
    for (int i = 0; i < n; i++) {
        sum1 += pow( abs(vx[i] - vy[i]), 1.0);
        sum2 += pow( abs(vx[i] - vy[i]), 2.0);
        sum3 += pow( abs(vx[i] - vy[i]), 3.0);
        if (chebyshev < abs(vx[i]-vy[i])) chebyshev = abs(vx[i]-vy[i]);
    }

    d1 = pow(sum1, 1/1.0);
    d2 = pow(sum2, 1/2.0);
    d3 = pow(sum3, 1/3.0);

    printf("%.6f\n%.6f\n%.6f\n%.6f\n", d1, d2, d3, chebyshev);

    return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cmath>
#define INF 1000000007
using namespace std ;

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

	int n ;
	string s ;
	cin>>n>>s ;
	int ans = 0 ; 

	for(int i = 0 ; i < n-2 ; i++)
	{
		string temp ;
		for(int j = i ; j < i+3 ; j++) temp.push_back(s[j]) ;
		if(temp == "ABC")++ans ;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
using namespace std;
int n;
void p(int x,int y){printf("%d %d\n",x,y);}
int main(){
	cin>>n;
	if(n<=2)return printf("No"),0;
	if(n&1){
		printf("Yes\n");
		p(1,2);
		p(2,3);
		p(3,n+1);
		p(n+1,n+2);
		p(n+2,n+3);
		for(int i=4;i<=n;i+=2)
			p(1,i),p(i,i+1),p(n+1,n+i+1),p(n+i+1,n+i);
		return 0;
	}
	int k=1;
	for(;1<<k+1<=n;++k);
	if(1<<k==n)return printf("No"),0;
	printf("Yes\n");
	int a=n^(n-1)^1;
	p(1,2);
	p(2,3);
	p(3,n+1);
	p(n+1,n+2);
	p(n+2,n+3);
	for(int i=4;i<n;i+=2)
		if(i==n-2)p(1,i+1),p(i+1,i),p(n+1,n+i),p(n+i,n+i+1);
		else p(1,i),p(i,i+1),p(n+1,n+i+1),p(n+i+1,n+i);
	p(n,n-1);
	p(n+n,a);
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    vector<ll> cnt(26);
    rep(i, N) {
        cnt[S[i][0] - 'A']++;
    }

    char c[5] = {'M', 'A', 'R', 'C', 'H'};
    ll ans = 0;
    rep(i, 5) {
        rep(j, 5) {
            rep(k, 5) {
                if (i < j && j < k) ans += cnt[c[i] - 'A'] * cnt[c[j] - 'A'] * cnt[c[k] - 'A'];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6144
n = int(input())
li = list(map(int,input().split()))
cnt = n-2
ans = 0
for i in range(cnt):
    a1 = li[i]
    a2 = li[i+1]
    a3 = li[i+2]
    if (a1 < a2) & (a2 < a3):
        ans += 1
    if (a3 < a2) & (a2 < a1):
        ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		
		boolean flgYYMM = 1 <= s % 100 && s % 100 <= 12;
		boolean flgMMYY = 1 <= s / 100 && s / 100 <= 12;
		
		if (flgYYMM) 
			if (flgMMYY)
				System.out.println("AMBIGUOUS ");
			else
				System.out.println("YYMM");
		else
			if (flgMMYY)
				System.out.println("MMYY");
			else
				System.out.println("NA");
		

		sc.close();
	}
	
}




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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


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

int main2() {
  int x1 = nextInt();
  int y1 = nextInt();
  int x2 = nextInt();
  int y2 = nextInt();

  int vx = (x2 - x1);
  int vy = (y2 - y1);
  tie(vx, vy) = make_pair(-vy, vx );
  int x3 = x2 + vx;
  int y3 = y2 + vy;
  tie(vx, vy) = make_pair(-vy, vx );
  int x4 = x3 + vx;
  int y4 = y3 + vy;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define REP1(i,n) for(int i=1; i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
using namespace std;

int main() {
  int n; cin>>n;
  cout<<1110-n<<endl;
}

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

int main() {
  int n,C,inf = 1010;
  cin >> n >> C;
  vector<vector<int>>d(C,vector<int>(C));
  vector<vector<int>>c(n,vector<int>(n));
  rep(i,0,C) rep(j,0,C) cin >> d[i][j];
  rep(i,0,n) rep(j,0,n){
    cin >> c[i][j];
    c[i][j]--;
  }
  vector<vector<int>>sum(3,vector<int>(C));
  rep(i,0,n) rep(j,0,n) rep(k,0,C) sum[(i+j)%3][k] += d[c[i][j]][k];
  int ans = 1e9+7;
  rep(i,0,C) rep(j,0,C){
    if(i == j) continue;
    rep(k,0,C){
      if(i == k || j == k) continue;
      ans = min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4600
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def toId(i, j):
    pair = A[i][j]
    if i > pair:
        i, pair = pair, i
    return ids[i][pair]

def dfs(x):
    if dp[x] != -1:
        if done[x]:
            return dp[x]
        else:
            return -1
    dp[x] = 1
    for y in G[x]:
        res = dfs(y)
        if res == -1:
            return -1
        dp[x] = max(dp[x], dfs(y)+1)
    done[x] = True
    return dp[x]

N = int(input())
A = [list(map(lambda x: int(x)-1, input().split())) for i in range(N)]
ids = [[0]*N for i in range(N)]
num = 0
for i in range(N):
    for j in range(N):
        if i < j:
            ids[i][j] = num
            num += 1
allv = N*N
G = [[] for i in range(allv)]
for i in range(N):
    for j in range(N-2):
        G[toId(i,j+1)].append(toId(i,j))
dp = [-1 for i in range(allv)]
done = [False for i in range(allv)]
ans = 0
for i in range(allv):
    res = dfs(i)
    if res == -1:
        print(-1)
        exit()
    ans = max(ans, dfs(i))
print(ans)

Measured memory_bytes: 225596
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323
int i,j,k;
// int n;
// const int N=1e6+5;
// vector<bool> prime(N);
// void sieve(){
//     for(int i=0;i<=N;i++)prime[i]=true;
//     prime[0]=prime[1]=false;
//     for(int i=2;i*i<=N;i++){
//         if(prime[i] and i*i<=N){
//             for(int j=i*i;j<=N;j+=i){
//                 prime[j]=false;
//             }
//         }
//     }
// }
const bool cmp(pii a,pii b){
    return a.F-a.S>b.F-b.S;
}

void Anon_mouS(){
    int n;
    cin>>n;
    vi a(n+1);
    for(i=1;i<=n;i++)cin>>a[i];
        int ans=0;
    for(i=1;i<=n;i++){
        if(i&1 and a[i]&1)ans++;
    }
cout<<ans<<endl;
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){
	int N; cin>>N;
	int a[100];
	int min=1000; int max=-1;
	for (int i=0;i<N;i++) {
		cin>>a[i];
		if (a[i]>max) max=a[i];
		if (a[i]<min) min=a[i];
	}
	cout<<max-min<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,j,u,k,v;

  scanf("%d",&n);

  int A[n+1][n+1];
  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      A[i][j] = 0;
    }
  }

  for(i=1 ; i<=n ; i++){
    scanf("%d%d",&u,&k);
    for(j=1 ; j<=k ; j++){
      scanf("%d",&v);
      A[u][v] = 1;
    }
  }

  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      printf("%d",A[i][j]);
      if(j<n) printf(" ");
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;

    string S = "";
    for (int i=0; i<n; i++) {
        S = S + s[i] + t[i];
    }

    cout << S << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	Main(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		for(int k = 0; k < n; k++){
			String str = sc.next();
			str = str.replaceAll("-", "");
			String tr = str.substring(0, 1);
			int p, q, cur;
			p = q = cur = 0;
			for(int i = 1, l = str.length(); i < l; i++){
				String st = str.substring(i, i+1);
				if(st.equals(">")){
					cur++;
				} else if(st.equals("<")){
					cur--;
				} else {
					if(cur < p){
						tr = st + tr;
						p = cur;
					} else if(cur > q){
						tr = tr + st;
						q = cur;
					}
				}
			}
			System.out.println(tr);
		}
	}
	
	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include<math.h>
#include <algorithm>
using namespace std;
int n,a,f=1000,total;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;total+=a;
		if(f>(total-total%(i+1))/(i+1))f=(total-total%(i+1))/(i+1);
	}
	cout<<f<<endl;
    return 0;
}


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

int score(const vector<vector<int>> &c, const vector<int> &t, int d)
{
  int weight[26];
  for (int k = 0; k < 26; k++)
  {
    weight[k] = 1;
  }

  int sum(0);
  for (int i = 0; i < d; i++)
  {
    int j = t[i] - 1;
    sum += c[i + 1][j];
    int penalty = 0;
    for (int k = 0; k < 26; k++)
    {
      if (j != k)
      {
        penalty += c[0][k] * weight[k];
        weight[k]++;
      }
      else
      {
        weight[k] = 1;
      }
    }
    sum -= penalty;
  }
  return sum;
}

int main()
{
  int d;
  cin >> d;
  vector<vector<int>> c;
  int weight[26];
  for (int k = 0; k < 26; k++)
  {
    weight[k] = 1;
  }
  for (int i = 0; i < d + 1; i++)
  {
    c.push_back(vector<int>());

    for (int j = 0; j < 26; j++)
    {
      int v;
      cin >> v;
      c[i].push_back(v);
    }
  }

  int max_sum(0);
  std::vector<int> max_js;
  int sum(0);
  for (int i = 0; i < d; i++)
  {
    int max_j = 0;
    int max_score = INT_MIN;

    for (int j = 0; j < 26; j++)
    {
      int score = c[i + 1][j];
      for (int k = 0; k < 26; k++)
      {
        if (j != k)
        {
          score -= c[0][k] * weight[k];
        }
      }
      if (max_score < score)
      {
        max_score = score;
        max_j = j;
      }
    }
    sum += max_score;
    for (int j = 0; j < 26; j++)
    {
      if (j != max_j)
      {
        weight[j]++;
      }
      else
      {
        weight[j] = 1;
      }
    }
    max_js.push_back(max_j);
  }

  max_sum = sum;
  vector<int> js;
  std::copy(max_js.begin(), max_js.end(), std::back_inserter(js));
  for (int t = 0; t < 100000; t++)
  {
    auto d_s = rand() % d;
    auto d_k = rand() % 26;
    js[d_s] = d_k;
    int sum = score(c, js, d);
    if (max_sum < sum)
    {
      for (auto j = 0; j < max_js.size(); j++)
      {
        max_js[j] = js[j];
      }
      max_sum = sum;
    }
  }
  for (auto j : js)
  {
    std::cout << j + 1 << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3700
#include<iostream>

/* n じゃんけんの回数
 * k 回前と同じダメ
 * r グーでかった時の点数
 * s チョキでかった時の点数
 * p パーでかった時の点数
 * */
using namespace std;
long long prediction_and_restriction(
    int n, int k, int r, int s, int p, char t[]) {
  char ans[100000] = {'0'};
  for(int i=0;i<k;i++) {
    int peek = i;
    while(peek < n) {
      char that = t[peek];
      char ideal;
      if(t[peek] == 'r') {
	ideal = 'p';
      } else if(t[peek] == 's') {
	ideal = 'r';
      } else {
	ideal = 's';
      }
      if(peek == i || ans[peek - k] != ideal){
	ans[peek] = ideal;
	peek += k;
	continue;
      }
      if(peek + k >= n) { // k回後がない
	ans[peek] = that;
	peek += k;
	continue;
      }
      if(ans[peek -k] == 'r' && t[peek+k] == 'r') {
	ans[peek] = 's';
      } else if(ans[peek -k] == 'r' && t[peek+k] == 's') {
	ans[peek] = 'p';
      } else if(ans[peek -k] == 'r' && t[peek+k] == 'p') {
	ans[peek] = 'p';
      } else if(ans[peek -k] == 's' && t[peek+k] == 'r') {
	ans[peek] = 'r';
      } else if(ans[peek -k] == 's' && t[peek+k] == 's') {
	ans[peek] = 'p';
      } else if(ans[peek -k] == 's' && t[peek+k] == 'p') {
	ans[peek] = 'r';
      } else if(ans[peek -k] == 'p' && t[peek+k] == 'r') {
	ans[peek] = 's';
      } else if(ans[peek -k] == 'p' && t[peek+k] == 's') {
	ans[peek] = 's';
      } else if(ans[peek -k] == 'p' && t[peek+k] == 'p') {
	ans[peek] = 'r';
      }
      peek += k;
      continue;
    }
  }
  long long rtn = 0;
  for(int i=0; i< n; i++) {
    if(t[i] == 'r' && ans[i] == 'p') {
      rtn += p;
    }
    if(t[i] == 's' && ans[i] == 'r') {
      rtn += r;
    }
    if(t[i] == 'p' && ans[i] == 's') {
      rtn += s;
    }
  }

  return rtn;
}

int main() {
  int n,k, r, s, p;
  cin >> n;
  cin >> k;
  cin >> r;
  cin >> s;
  cin >> p;
  cin.get();
  char t[n];
  for(int i=0;i<n;i++) {
    t[i] = cin.get();
  }
  cout << prediction_and_restriction(n, k, r, s, p, t);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int a, b; cin >> a >> b;
    string s; cin >> s;
    rep(i, a) {
        if('9' < s[i] || s[i] < '0') no();
    }
    if(s[a] != '-') no();
    rep(i, b) {
        if('9' < s[a+1+i] || s[a+1+i] < '0') no();
    }
    yes();
    return 0;
}


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

using mint = modint998244353;
vector<mint> ten, one;

struct S {
  mint val;
  int len;
};

using F = int;

S op(S sl, S sr) {
  return {sl.val * ten[sr.len] + sr.val, sl.len + sr.len};
}

S e() { return {0, 0}; }

S mapping(F f, S s) {
  if (f == -1) return s;
  return {f * one[s.len], s.len};
}

F composition(F f, F g) {
  if (f == -1) return g;
  return f;
}

F id() { return -1; }


int main() {
  int n, q; cin >> n >> q;
  ten.assign(n+1, 0);
  one.assign(n+1, 0);
  ten[0] = 1;
  rep(i, n) ten[i+1] = ten[i] * 10;     // 100...000 mod 998244353 を前計算
  rep(i, n) one[i+1] = one[i] + ten[i]; // 111...111 mod 998244353 を前計算

  lazy_segtree<S, op, e, F, mapping, composition, id> seg(vector<S>(n, {1, 1}));

  rep(_, q) {
    int l, r, d; cin >> l >> r >> d;
    --l;
    seg.apply(l, r, d);
    cout << seg.all_prod().val.val() << '\n';
  }
}


Measured memory_bytes: 11444
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main(){
    long a, b, c, k;
    cin >> a >> b >> c >> k;
    long a1, b1, c1;
    if (a>=k){
        a1 = k;
        b1 = 0;
        c1 = 0;
    }
    else if (b>=(k-a)){
        a1 = a;
        b1 = k-a;
        c1 = 0;
    }
    else{
        a1 = a;
        b1 = b;
        c1 = k-a-b;
    }
    cout << a1-c1 << endl;
}

Measured memory_bytes: 3596
n, tt = list(map(int, input().split()))

minC = 1001
for i in range(n):
  c, t = list(map(int, input().split()))
  if t > tt:
    continue
  
  minC = min(minC, c)

if minC == 1001:
	print("TLE")
else:
	print(minC)

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
#define set(x) cout<<fixed<<setprecision(x);
using namespace std;
//**********************************************DO IT NO****************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
    //cin>>t;
    while(t--)
    {  
       int l,r,x;
        cin>>l>>r>>x;
        if(l==0)
        {
            cout<<r/x+1;
        }
        else
        cout<<r/x-(l-1)/x;
       
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3632
n = int(input())
res = -1
m = 0

if n == 1:
    print(1)
else:
    for i in range(1, n+1):
        a = i
        b = 0
        while a % 2 == 0:
            a = a // 2
            b += 1
        if b > m:
            m = b
            res = i
    print(res)

Measured memory_bytes: 3060
N, x = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
A.sort()
i = 0
while i < N and x > 0:
    if x >= A[i]:
        if i != N-1 or x == A[i]:
            ans += 1
        x -= A[i]
    else:
        break
    i += 1

print(ans)

Measured memory_bytes: 3064
from collections import defaultdict
def solve():
  ans = 0
  N = int(input())
  C = [int(input()) for _ in range(N)]
  d = defaultdict(lambda: -1)
  dp = [1]*N
  d[C[0]] = 0
  mod = 10**9+7
  for i in range(1,N):
    dp[i] = dp[i-1]
    if d[C[i]]>-1 and d[C[i]]!=i-1:
      dp[i] += dp[d[C[i]]]
      dp[i] %= mod
    d[C[i]] = i
  return dp[-1]
print(solve())

Measured memory_bytes: 120760
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin >>S;
    int cntATGC=0;
    int maxATGC=0;
    for(int i=0;i<S.size();i++){
        if(S.at(i)=='A'||S.at(i)=='T'||S.at(i)=='G'||S.at(i)=='C'){
            cntATGC++;
        }
        else {
            if(cntATGC>maxATGC){
                maxATGC=cntATGC;
                cntATGC=0;
            }
        }
    }
    if(cntATGC>maxATGC){
        maxATGC=cntATGC;
        cntATGC=0;
    }
    cout <<maxATGC<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = ["" for _ in range(n)]
b = ["" for _ in range(m)]
for i in range(n):
    a[i] = str(input())
for i in range(m):
    b[i] = str(input())
def check(ini_x, ini_y):
    global n, m, a, b
    for x in range(m):
        for y in range(m):
            if a[ini_x + x][ini_y + y] != b[x][y]:
                return False
    return True
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if check(i, j):
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 8944
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
A = III()
temp =0
for i in range(N):
    temp += 1/A[i]

print(1/temp)

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#define pr pair<int,int>
using namespace std;
int n,d1,d2,cnt;
const int N=605;
int id[N][N],col[N*N][3];
vector<pr>d[2];
void dfs(int x,int opt)
{
	int X=(x-1)/(2*n)+1,Y=(x-1)%(2*n)+1,tox,toy;
	for(int i=0,siz=d[opt].size();i<siz;++i)
	{
		tox=X+d[opt][i].first;toy=Y+d[opt][i].second;
		if(1<=tox&&tox<=2*n&&1<=toy&&toy<=2*n&&!col[id[tox][toy]][opt])
			col[id[tox][toy]][opt]=3-col[x][opt],dfs(id[tox][toy],opt);
	}
}
int main()
{
    cin>>n>>d1>>d2;
    for(int i=0,j;i<=d1;++i)
    {
    	j=sqrt(d1-i*i);
    	if(i*i+j*j==d1)
    	{
    		d[1].push_back(pr(i,j));
    		d[1].push_back(pr(-i,j));
    		d[1].push_back(pr(i,-j));
    		d[1].push_back(pr(-i,-j));
		}
	}
	for(int i=0,j;i<=d2;++i)
    {
    	j=sqrt(d2-i*i);
    	if(i*i+j*j==d2)
    	{
    		d[2].push_back(pr(i,j));
    		d[2].push_back(pr(-i,j));
    		d[2].push_back(pr(i,-j));
    		d[2].push_back(pr(-i,-j));
		}
	}
	for(int i=1;i<=2*n;++i)
		for(int j=1;j<=2*n;++j)
			id[i][j]=(i-1)*2*n+j;
	for(int i=1;i<=2*n;++i)
		for(int j=1;j<=2*n;++j)
		{
			if(!col[id[i][j]][1])col[id[i][j]][1]=1,dfs(id[i][j],1);
			if(!col[id[i][j]][2])col[id[i][j]][2]=1,dfs(id[i][j],2);
		}
    for(int i=1;i<=2*n;++i)
    	for(int j=1;j<=2*n;++j)
    	{
    		if(col[id[i][j]][1]==1&&col[id[i][j]][2]==1)printf("%d %d\n",i-1,j-1),++cnt;
    		if(cnt==n*n)return 0;
		}
    return 0;
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define in freopen(".in", "r", stdin)
#define out freopen(".out", "r", stdout)

using namespace std;

const long long INF = (int)1e17 + 7;

int a[51];

ll dp[51][51][50*51];

int n, i, s, j, k;

ll sum = 0;

int main()
{

    scanf("%d%d",&n, &s);
    memset(dp, 0, sizeof(dp));

    for (i = 1; i <= n; i++)
    {
        scanf("%d",&a[i]);
    }
    dp[0][0][0] = 1;
    for (i = 1; i <= n; i++)
        for (j = 0; j <= i; j++)
            for (k = 0; k <= 2500; k++) {
                dp[i][j][k] += dp[i - 1][j][k];
                if (k >= a[i] && j > 0)
                dp[i][j][k] += dp[i - 1][j - 1][k - a[i]];
            }

    for (i = 1; i <= n; i++) {
        sum += dp[n][i][s * i];
    }

    printf("%lld", sum);

}




Measured memory_bytes: 51968
#include<iostream>
char* bubleSort(int* arr, char* zimu,int len);
char* SelectionSort(int* arr, char* zimu, int len);
void printAns(int* arr,char* zimu, int len);
int main() {
	using namespace std;
	int len;
	cin >> len;
	int* arr = new int[len];
	char* zimu = new char[len];
	int* narr = new int[len];
	char* nzimu = new char[len];
	for (int i = 0; i < len; i++) {
		cin >> zimu[i] >> arr[i];
		nzimu[i] = zimu[i];
		narr[i] = arr[i];
	}

	char* buble=bubleSort(arr, zimu, len);
	printAns(arr, zimu, len);
	cout << "Stable" << endl;

	char* selection=SelectionSort(narr, nzimu, len);
	printAns(narr, nzimu, len);
	for (int i = 0; i < len; i++) {
		if (zimu[i] != nzimu[i]) {
			cout << "Not stable" << endl;
			break;
		}
		else if (i == len - 1)
			cout << "Stable" << endl;
	}
	
	return 0;
}
char* bubleSort(int* arr, char* zimu,int len) {
	using std::swap;
	for (int i = 0; i < len - 1; i++) {
		for (int j = len - 1; j > i; j--) {
			if (arr[j] < arr[j - 1]) {
				swap(arr[j], arr[j - 1]);
				swap(zimu[j], zimu[j - 1]);
			}
		}

	}
	return zimu;
}
char* SelectionSort(int* arr, char* zimu, int len) {
	using std::swap;
	for (int i = 0; i < len ; i++) {
		int min = i;
		for (int j = i ; j < len; j++) 
			min = arr[min] <= arr[j] ? min : j;
		swap(arr[min], arr[i]);
		swap(zimu[min], zimu[i]);
	}
	return zimu;
}
void printAns(int* arr,char* zimu, int len) {
	using std::cout;
	using std::endl;
	for (int i = 0; i < len; i++)
	{
		if (i)
			cout << " ";
		cout << zimu[i] <<arr[i];
	}
	cout << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807
#define LLMIN       -9223372036854775808
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;
using namespace std;

int N,M;
LL cache[300+2][300+2][300+2];
vector<tuple<int,int,int> > cond[300+1];

inline bool ok(int R,int G,int B){
    if(R>G) swap(R,G);
    if(G>B) swap(G,B);
    if(R>G) swap(R,G);
    int cs[3]={R,G,B};
    int v=cs[2];
    bool flag=true;
    if(cond[v].size()==0)
            return true;
    for(auto c : cond[v]){
        // printf("c0=%d c1=%d c2=%d\n",get<0>(c),get<1>(c),get<2>(c));
        if(get<2>(c) == 1){
            if(cs[1] < get<0>(c))   ;
            else flag=false;
        }else if(get<2>(c) == 2){
            if(cs[0] < get<0>(c) && get<0>(c) <= cs[1]) ;
            else flag=false;
        }else{
            if(get<0>(c) <= cs[0])  ;
            else flag=false;
        }
    }
    return flag;
}

LL rec(int R,int G,int B){
    int v=max(R,max(G,B));
    LL &r=cache[R+1][G+1][B+1];
    if(v==N-1){
        // printf("R=%d G=%d B=%d\n",R,G,B);
        // printf("v==N\n");
        r=1;
    }else if(r!=-1){
        ;
    }else{
        v++;
        r=0;
        if(ok(v,G,B)) r+=rec(v,G,B);
        if(ok(R,v,B)) r+=rec(R,v,B);
        if(ok(R,G,v)) r+=rec(R,G,v);
        r%=1000000007;
    }
    return r;
}

int main(void){
    memset(cache,-1,sizeof(cache));
    cin>>N>>M;
    REP(i,M){
        int l,r,x;
        cin>>l>>r>>x;
        l--,r--;
        cond[r].pb(mt(l,r,x));
    }
   LL ans = rec(-1,-1,-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 215552
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long 
// int dx[]={-1,1,0,0}; int dy[]={0,0,1,-1};
// int dx[]={2,2,-2,-2,1,1,-1,-1}; int dy[]={1,-1,1,-1,2,-2,2,-2};
const long long mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector< pair< int, int > > vii;
typedef map<int, int> mii;
typedef pair<int, ii> pip;
typedef pair<ii, int> ppi;
#define arrinp(arr,init,final,size,type) type* arr=new type[size];for(int i=init;i<final;i++)cin>>arr[i];
#define cr2d(arr,n,m,t) t**arr=new t*[n];for(int i=0;i<n;i++)arr[i]=new t[m];
#define w(t) int t;cin>>t; while(t--)
#define takeInp(n) int n;cin>>n;
#define fr(i,init,final) for(int i=init;i<final;i++)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  nds; 
vi init(string s)
{
	istringstream sin(s);
	int n;
	vi arr;
	while(sin>>n)arr.push_back(n);
	return arr;
}
int pow(int x, int y)
{ 
	if(y==0)return 1;
	int u=pow(x,y/2);
	u=u*u;
	if(y%2)u=x*u;
	return u;
    
}
int gcd(int a,int b)
{
	if(a<b)return gcd(b,a);
	return (b==0?a:(a%b?gcd(b,a%b):b));
}
int gcd_e(int a,int b,int &x,int &y)
{
	
	if(b==0){x=1; y=0; return a;}
	int x1,y1;
	int p=gcd_e(b,a%b,x1,y1);
	x=y1;
	y=x1-(a/b)*y1;
	return p;
}
signed main()
{
	IOS
	int n;
	cin>>n;
	int arr[n];
	fr(i,0,n) cin>>arr[i];
	int ans=0;
	fr(i,0,n)if((i+1)%2==1&&arr[i]%2==1)ans++;
	cout<<ans;
	
}



Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = in.nextIntArray(n);

            int g = Euclid.gcd(a);
            for (int i = 0; i < n; i++) {
                if (a[i] >= k && (a[i] - k) % g == 0) {
                    out.println("POSSIBLE");
                    return;
                }
            }

            out.println("IMPOSSIBLE");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }

    static class Euclid {
        public static int gcd(int a, int b) {
            return a == 0 ? b : gcd(b % a, a);
        }

        public static int gcd(int[] array) {
            int ret = array[0];
            for (int i = 1; i < array.length; i++) {
                ret = gcd(ret, array[i]);
            }

            return ret;
        }

    }
}


Measured memory_bytes: 37088
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.Beginner162
{
    public class ABC162B
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            long sum = 0;
            for (int i=1; i<=N; i++)
            {
                if(i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 27540
import sys
N = int(input())
a, b = [], []
ans = 0

for i in range(N):
    a0, b0 = map(int, input().split())
    a.append(a0)
    b.append(b0)
b, a = zip(*sorted(zip(b, a)))
for i, j in zip(a, b):
    ans += i
    if ans > j:
        print('No')
        sys.exit()
print('Yes')


Measured memory_bytes: 51864
#include<iostream>
#include<algorithm>
using namespace std;
#define inf 1000000007
//the only difference with previous version is contstraints

int main()
{

	long long int n,w,i,j;
	cin>>n>>w;
	long long int **a=new long long int*[n+1];
	for(i=0;i<=n;i++)
	{
		a[i]=new long long int[2];
	}
	for(i=1;i<=n;i++)
	{
		cin>>a[i][0]>>a[i][1];
	}

	long long int maxval=1000*n;
	long long int dp[n+1][maxval+1];

	for(i=0;i<=maxval;i++)
	{
			dp[1][i]=inf;
	}
	dp[1][0]=0;
	dp[1][a[1][1]]=a[1][0];
	for(i=2;i<=n;i++)
	{
		for(j=0;j<=maxval;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(a[i][1]>j)
			{
				continue;
			}
			dp[i][j]=min(dp[i][j],a[i][0]+dp[i-1][j-a[i][1]]);
		}
	}
	long long int ans;
	for(j=0;j<=maxval;j++)
	{
		if(dp[n][j]<=w)
		{
			ans=j;
		}
	}
	cout<<ans<<"\n";
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double funsin_m = 2 * M_PI / 60;
    long double jisin_m = 2 * M_PI / 12 / 60;

    long double jisin_pos = (h * 60 + m) * jisin_m;
    long double funsin_pos = m * funsin_m;

    long double diff = abs(jisin_pos - funsin_pos);

    while (diff > 2 * M_PI) {
        diff -= 2 * M_PI;
    }

    cout << setprecision(15) << sqrt(a * a + b * b - 2 * a * b * std::cos(diff))
         << endl;

    return 0;
}


Measured memory_bytes: 4172
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int t[100005],x[100005],y[100005];
int main()
{
	int n,i,f;
	scanf("%d",&n);
	f=0;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		if(x[i]+y[i]>t[i])
			f=1;
	}
	for(i=1;i<n;i++)
	{
		int m,c;
		m=t[i]-t[i-1];
		c=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if((m%2)!=(c%2))
		{
			f=1;
			break;
		}  
	}
	if(f==1)printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

vector<long long> v;
void dfs(ll x, ll num, ll st, ll cc){
	if(v.size() > 100000) return;
	if(num == 0) num += x;
	else {
		num *= 10;
		num += x;
	}
	if(cc > st) return;
	if(cc == st){
		v.push_back(num);
		return;
	}
	if(x-1 >= 0) dfs(x-1,num,st,cc+1);
  	dfs(x,num,st,cc+1);
	if(x+1 <= 9) dfs(x+1,num,st,cc+1);
	return;
}

int main(){
	
	ll k; cin>>k;
	for(int i = 1; i <= 10; i++){
		for(int j = 1; j <= 9; j++){
			dfs(j,0,i,1);
		}
	}
	sort(v.begin(),v.end());
	cout<<v[k-1]<<"\n";
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int r;
    std::cin >> r;
    std::cout << 3 * r * r << std::endl;

    return 0;
}


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

int N;
vector<string> s;
vector<char> ans;

bool dfs(int cur, int a, int b, int c) {
    if(cur == N) return true;

    if(s[cur] == "AB") {
        if(a == 0 && b == 0) return false;
        if(a > 0 && dfs(cur+1, a-1, b+1, c)) {
            ans.push_back('B');
            return true;
        }
        if(b > 0 && dfs(cur+1, a+1, b-1,c)) {
            ans.push_back('A');
            return true;
        }
        return false;
    }
    if(s[cur] == "AC") {
        if(a == 0 && c == 0) return false;
        if(a > 0 && dfs(cur+1, a-1, b, c+1)) {
            ans.push_back('C');
            return true;
        }
        if(c > 0 && dfs(cur+1, a+1, b, c-1)) {
            ans.push_back('A');
            return true;
        }
        return false;
    }
    if(s[cur] == "BC") {
        if(b == 0 && c == 0) return false;
        if(b > 0 && dfs(cur+1, a, b-1, c+1)) {
            ans.push_back('C');
            return true;
        }
        if(c > 0 && dfs(cur+1, a, b+1,c-1)) {
            ans.push_back('B');
            return true;
        }
        return false;
    }
}

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

cin >> N;
int A,B,C;
cin >> A >> B >> C;
s = vector<string>(N);
rep(i,N) cin >> s[i];
dfs(0,A,B,C);

if(ans.size() == 0) cout << "No" << endl;
else {
    cout << "Yes" << endl;
    reverse(ans.begin(), ans.end());
    for(char c : ans) cout << c << endl;
}
return 0;
}

Measured memory_bytes: 12964