akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;


#define SZ(x) ((int)(x).size())
#define BIT(n) (1ll<<(n))
#define SORT(c) sort((c).begin(),(c).end())
#define RALL(a) (a).rbegin(), (a).rend()
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define CLR(a) memset((a), 0 ,sizeof(a))
#define retrun return
//#define INF 1000000010ll
#define MOD 1000000007ll
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,n)  
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
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; }

//------------------------------------------------------------------------------------------------------

int N, Ma, Mb;
int a[41], b[41], c[41];
const int INF = 1 << 29;
int dp[41][40 * 10 + 1][40 * 10 + 1];
//------------------------------------------------------------------------------------------------------

int main() {
	cin >> N >> Ma >> Mb;

	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i] >> c[i];

	}

	REP(i, 0, N+1)REP(j, 0, 40 * 10 + 1)REP(k, 0, 40 * 10 + 1) {
		dp[i][j][k] = INF;
	}

	dp[0][0][0] = 0;

	REP(i, 0, N)REP(j, 0, 40 * 10 + 1)REP(k, 0, 40 * 10 + 1) {
		if (dp[i][j][k] == INF) continue;
		dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
		dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
	}
	int ans = INF;

	REP(j, 1, 40 * 10 + 1)REP(k, 1, 40 * 10 + 1) {
		if (Ma*k == Mb*j) ans = min(ans, dp[N][j][k]);
	}

	if (ans == INF) ans = -1;

	COUT(ans);

	return 0;
}


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

int N;
int P; //even or odd//
int A[55];
long long memo[5005][55];

long long bags (long long biscuits, long long bag)
{
    if (memo[biscuits][bag]!=-1)
    {
        return memo[biscuits][bag];
    }

    if (bag>N && biscuits%2==P)
    {
        return memo[biscuits][bag]=1;
    }

    if (bag>N && biscuits%2!=P)
    {
        return memo[biscuits][bag]=0;
    }

    long long sum=0;

    return memo[biscuits][bag]=bags(biscuits+A[bag], bag+1)+bags(biscuits, bag+1);
}

int main()
{
    memset(memo, -1, sizeof(memo)); 

    cin>>N>>P;

    for (int i=1; i<=N; i++)
    {
        cin>>A[i];
    }

    cout<<bags(0, 1)<<endl;
}

Measured memory_bytes: 2432
def xor(_x) :
    if _x % 4 == 0:
        return _x
    elif _x % 4 == 1:
        return 1
    elif _x % 4 == 2:
        return 1 ^ _x
    else:
        return 0


A, B = map(long, raw_input().split())
print(xor(A - 1) ^ xor(B))


Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = (int)s.length(), c = n;
    bool y = 0;
    s = 'c' + s;
    if (s[n] == '1' || s[1] == '0') y = 1;
    for (int i = 1; i < n; i++) if (s[i] != s[n - i]) y = 1;
    if (y) {cout << -1; return 0;}
    for (int i = n - 1; i; i--) {
        cout << c << ' ' << i << '\n';
        if (s[i] == '1') c = i;
    }
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B, C;

	cin >> A >> B >> C;
	cout << (A == B && B == C ? "Yes" : "No") << endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  if (N%10==3)
    cout << "bon";
  else if ((N%10==0)||(N%10==1)||(N%10==6)||(N%10==8))
    cout << "pon";
  else
    cout << "hon";
}

Measured memory_bytes: 3620
use std::cmp::max;
use std::collections::HashMap;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut map: HashMap<String, i32> = HashMap::new();
    for _ in 0..n {
        let k: String = read(&mut stdin_lock, &mut buf, b'\n');
        let v: i32 = *map.get(&k).unwrap_or(&0);
        map.insert(k, v + 1);
    }
    let m: usize = read(&mut stdin_lock, &mut buf, b'\n');
    for _ in 0..m {
        let k: String = read(&mut stdin_lock, &mut buf, b'\n');
        match map.get(&k) {
            Some(&v) => map.insert(k, v - 1),
            None => None,
        };
    }

    let max_key = map.keys().max_by_key(|&k| map.get(k).unwrap()).unwrap();
    let ans = max(*map.get(max_key).unwrap(), 0);
    println!("{}", ans);
}


Measured memory_bytes: 4352
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
int n , m;
int x[ N ] , y[ N ];
void init(){
  n = getint();
  m = getint();
  for( int i = 0 ; i < n ; i ++ )
    x[ i ] = getint();
  for( int i = 0 ; i < m ; i ++ )
    y[ i ] = getint();
}
void solve(){
  int xx = 0 , yy = 0;
  for( int i = 0 , ps = 0 ; i < n ; i ++ ){
    x[ i ] = ( x[ i ] % mod7 + mod7 ) % mod7;
    xx = add( xx , sub( mul( i , x[ i ] ) , ps ) );
    ps = add( ps , x[ i ] );
  }
  for( int i = 0 , ps = 0 ; i < m ; i ++ ){
    y[ i ] = ( y[ i ] % mod7 + mod7 ) % mod7;
    yy = add( yy , sub( mul( i , y[ i ] ) , ps ) );
    ps = add( ps , y[ i ] );
  }
  printf( "%lld\n" , mul( xx , yy ) );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
ans = 1
flg = 0
max = 10 ** 18 + 1

for i in range(n):
    if a[i] == 0:
        ans = 0
        break
    if flg == 0:
        ans = ans * a[i]
    if ans // max > 0:
        ans = -1
        flg = 1

if flg != 0 and ans != 0:
    ans = -1

print(ans)

Measured memory_bytes: 21636
/*2020/03/14 PanasonicProgrammingContest2020*/

#include<bits/stdc++.h>
using namespace std;

int main() {
     vector<int> vec={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
     int k;
     cin >> k;
     cout << vec[k-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int n, m;   cin >> n >> m;
  PQ a;
  for(int i = 0 ; i < n ; i++){
    int input;	  cin >> input;
    a.push(input);
  }

  for(int i = 0 ; i < m ; i++){
    int max_val = (a.top() / 2);  a.pop();
    a.push(max_val);
  }

  ll ans = 0;
  for(int i = 0 ; i < n ; i++){
    ans += a.top(); a.pop();
  }

  SCOUT(ans) << endl;

  return 0;

}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>

using namespace std;

void out() {
     cerr << endl << "OUT" << endl;
     int bred;
     cin >> bred;
}
const int MOD = 1000000007;
void solve() {
     int n;
     cin >> n;
     int x;
     cin >> x;
     x = 1;
     int kol = 1;
     long long ans = 1;
     for (int i = 2; i <= n; ++i) {
         cin >> x;
         if (x >= 2*kol + 1)
            ++kol;
         else
             ans = (ans * (kol + 1)) % MOD;
     }
     
     for (int i = 1; i <= kol; ++i)
         ans = (ans * i) % MOD;
     cout <<ans << endl;;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    out();
    return 0;
}


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

int n, a, lst, cur, ans;

int main() {
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) {
    scanf("%d", &a);
    (a != lst) ? (ans += cur >> 1, cur = 1) : (++cur);
    lst = a;
  }
  ans += cur >> 1;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

def chk(a,b,c):
    return True if uf.diff(a,b) == c else False
n,m = inpl()
z = [-1] * n
uf = WeightedUnionFind(n)
for i in range(m):
    a,b,c = inpl()
    a -= 1; b -= 1
    if uf.same(a,b):
        if not chk(a,b,c):
            print('No')
            quit()
    else:
        uf.union(a,b,c)
print('Yes')

Measured memory_bytes: 123420
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*/
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
ll n,m,k;
bool ok = true;
ll dp[2003][2003];
vpll v;
ll solve(ll i , ll j)
{
    if(i==n)
    {
        return(0);
    }
    if(dp[i][j]!=-1)
    {
        return(dp[i][j]);
    }
    ll ans = 0;
    ll x = j;
    ll y = n - (i+1-x);
    ans = max(solve(i+1,j+1)+v[i].fi*abs(v[i].se-x),solve(i+1,j)+v[i].fi*abs(v[i].se-y));
    dp[i][j] = ans;
    return(ans);
}
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,e,i,j,t,x,y,z,x1,y1,z1,f;
    //double p,q,r,u,w ;
    char ch,chr ;
    //string str,st,str2,str3;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    rep(i,0,n)
    {
        cin>>a;
        v.pb(mkp(a,i+1));
    }
    sort(rall(v));
    memset(dp,-1,sizeof(dp));
    a = solve(0,1);
    cout<<a;
}

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

int main(){
	int N,p[50];
	cin >> N;
	int count =0;
	for(int i = 0;i < N;i++){
  cin >> p[i];
  if(p[i]!= i+1){
  	count++;
  }
	}

	if(count > 2){
		cout << "NO";
	}
	else{
		cout << "YES";
		
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int u = 0;
    int z;
    int y = 500;
    z = x / y;
    x -= z * y;
    u += z * 1000;

    y = 5;
    z = x / y;
    u += z * 5;

    cout << u << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  cin >> s;
  cout << 'A' << s[0] << 'C' << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, l, a, b, c = 0, d;

	scanf("%d %d", &n, &l);
	
	if(l <= 0 && l >= 1 - n){
		a = 0;
	}else if(l < 1 - n){
		a = n + l - 1;
	}else{
		a = l;
	}
	
	for(b = 1; b <= n; b++){
		c = c + b + l - 1;
	}
	
	d = c - a;
	
	printf("%d", d);
	
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
    #include <bits/stdc++.h>
    #define ll  long long
    #define pb push_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define vi vector<int>
    #define br cout <<"\n";
    #define all(x)  (x).begin(),(x).end()
    #define tr(c,i) for(auto i : c)
    #define pii pair< int,int >
    #define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
    #define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
    #define er(x) cout << x << " "
    #define err(x,y) cout << x << " "<<y
    const int M = 200005;
    using namespace std;
    clock_t time_p=clock();
    void dem()
    {
        time_p=clock()-time_p;
        cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
    }
    using namespace std ;
    const int MAX =  1000 * 1000 + 10;
    const int dx[] = { 1, -1 , 0 , 0  };
    const int dy [] = { 0 ,0 , 1 , -1  };
    const int MOD = 1000 * 1000 * 1000 + 9 ;
    int main (){
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    int cur = 1 ;
    vector<int> res ;
    for ( int i = 1 ; i <  n ; ++ i ){
        if ( s[i] == s[i -1 ]){
            cur ++ ;
        }
        else
        {
        res.push_back ( cur );
        cur = 1 ;
        }
    }

    cout << ( res.size() +  ( cur > 0 ) ) ;

        return 0 ;
    }



Measured memory_bytes: 1020
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
#define rep(i,j,k) for(ll i=0;i<j;i+=k)
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll n;
	cin>>n;
	vector<ll> ans;
	while(n!=0) {
		int rem= n%26;
		if(rem==0)
			rem=26;
		if(rem==0)
			ans.push_back(26);
		else
			ans.push_back(rem);
		n= (n-rem)/26;
	}
	for(ll i=ans.size()-1;i>=0;i--)
		cout<<(char)(ans[i]+96);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
	int N, X, T;
	int i, time = 0;
	scanf("%d %d %d", &N, &X, &T);
	for(i = 0; ; i++){
		N -= X;
		time += T;
		if(N <= 0){
          break;
		}
	}
	printf("%d\n", time);
	return 0;
}

Measured memory_bytes: 1732
/*Rating is just a NUMBER*/
#include <bits/stdc++.h>
#define endl "\n";
#define pii pair<int,int>;
using namespace std;
typedef long long ll;
const ll BIG=1000000007;
const double PI=3.141592653589793238;
ll binpow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a)%m;}
    b>>=1;a=(a*a)%m;
    }
    return res;
}
template <typename T,typename Q>
T max(T a,Q b)
{
    if(a<b)
        return b;
    return a;
}
template <typename T,typename Q>
T min(T a,Q b)
{
    if(a>b)
        return b;
    return a;
}
long gcd(long a,long b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
ll check(ll n)
{
	ll sum=0;
	while(n)
	{
		sum+=n/5;
		n/=5;
	}
	return sum;
}
void solve()
{
	cout<<"ACL";
}
int main() {
    int t;cin>>t;
    while(t--)
        solve();
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int gcd(int64_t x, int64_t y) {
  if(x < y) swap(x,y);
  int64_t z = x % y;
  while(z != 0) {
    x = y;
    y = z;
    z = x % y;
  }
  return y;
}

int main () {
  int n;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  int64_t ans = a.at(0);
  rep(i,n-1) {
    ans = gcd(ans,a.at(i+1));
    }
  cout << ans;             
}


Measured memory_bytes: 1024
n = int(input())
uv = [list(map(int, input().split())) for _ in range(n - 1)]

ans = 0
for i in range(1, n + 1):
    ans += (1 + n - i + 1) * (n - i + 1) // 2

for u, v in uv:
    u, v = min(u, v), max(u, v)
    ans -= u * (n - v + 1)

print(ans)


Measured memory_bytes: 102656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int r = Integer.parseInt(br.readLine());
        System.out.println(problem104a(r));
    }

    private static String problem104a(int r) {
        if (r < 1200) {
            return "ABC";
        } else if (r < 2800) {
            return "ARC";
        }
        return "AGC";
    }
}

Measured memory_bytes: 21204
N,D = map(int,input().split())
X = [0]*N
Y = [0]*N
for i in range(N):
    X[i],Y[i] = map(int,input().split())
counter = 0
for i in range(N):
    if X[i]**2 + Y[i]**2 <= D**2:
        counter += 1
print(counter)

Measured memory_bytes: 77664
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n = 5;
    ll x = lin();
    VL a(n);
    REP(i,n) a[i] = lin();
    ll y = *min_element(ALL(a));
    ll ans = (x + y - 1) / y + 4;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
L=[input()[0] for _ in range(n)]
L=[L.count(s) for s in 'MARCH']
a=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      a+=L[i]*L[j]*L[k]
print(a)

Measured memory_bytes: 3924
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<pair<int, int>, int> tup;

inline void solve()
{
	string s, t;
	cin >> s >> t;
	cout << t << s;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <assert.h>
using namespace std;
typedef long long ll;
const long long MOD = 1e9+7;
long long powmod(long long a,long b){ll res=1;a%=MOD;assert(b>=0);for(;b;b>>=1){
    if(b&1)res=res*a%MOD;a=a*a%MOD;}
    return res;
}
void solve(){
//    long long n;
//    cin >> n;
//    for(int i = 1;i < n ;i++)if(n%i==0)cout << i << endl;
     long long n,k,ans=0;
     cin>>n>>k;
     vector<ll> a(k+1);
     for(int i=k;i>=1;i--){
        a[i] = powmod(k/i,n);
        for(int j=2*i;j<=k;j+=i){
            a[i] = (a[i]-a[j]+MOD)%MOD;
        }
        ans += a[i]*i;
        ans%=MOD;
     }
     cout<<ans;
}
int main(){
    int T = 1;
    //cin >> T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
using namespace std;
int main()
{
       ios_base::sync_with_stdio(0);
       cin.tie(0);

       int t=1;
       //cin>>t;
       while(t--)
       {
            int n;
            cin>>n;
            int a[n+1];
            int c=0;
            for(int i=1;i<=n;++i)
            {
                 cin>>a[i];
                 if(i%2==1 && a[i]%2==1)
                    c++;
            }
            cout<<c;
       }
}


Measured memory_bytes: 3636
import collections

N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
c = collections.Counter(A)

if (K - Q) > 0:
    for _ in range(N):
        print('Yes')
else:
    l = ['No'] * N
    for i,v in dict(c).items():
        if v >(Q - K):
            l[i-1] = 'Yes'
    for j in l:
        print(j)

Measured memory_bytes: 18484
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const auto INF = numeric_limits<long long>::max() / 2;
template<typename T>
void warshall_floyd(vector<vector<T>> &dp) {
    for (int k = 0; k < (int)dp.size(); k++) {
        for (int i = 0; i < (int)dp.size(); i++) if (dp[i][k] != INF) {
            for (int j = 0; j < (int)dp.size(); j++) if (dp[k][j] != INF) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<int> b(n);
    for (auto &bi: b) cin >> bi;
    vector<int> cost;
    for (int nc = 51; nc >= 1; nc--) {
        vector<vector<long long>> mat(51, vector<long long>(51, INF));
        for (int i = 0; i <= 50; i++) mat[i][i] = 0;
        for (int c: cost) for (int i = 0; i <= 50; i++) mat[i][i % c] = 0;
        for (int c = 1; c < nc; c++) {
            for (int i = 0; i <= 50; i++) chmin(mat[i][i % c], 1LL << i);
        }
        warshall_floyd(mat);
        bool ok = true;
        for (int i = 0; i < n; i++) ok &= mat[a[i]][b[i]] != INF;
        if (!ok) {
            if (nc == 51) return !(cout << -1 << endl);
            else cost.emplace_back(nc);
        }
    }
    long long ans = 0;
    for (int c: cost) ans |= 1LL << c;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<algorithm>
int main()
{
long long int t=1,rr,i,sss,c=0,n,m,d1,d2,l,r;
	scanf("%lld%lld",&n,&m);
	for(i=22;i<=m;){
		d1=i%10;
		d2=i/10;
		if((d1*d2)<=n)
		c++;
		if(d1==9)
		i=i+3;
		else
		i++;
	}
		
	printf("%lld\n",c);

	return 0;
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


//combination mod prime
//https://marycore.jp/prog/cpp/member-initializer-list/ メンバ初期化子

struct combination{
    vector<mint> fact, ifact;
    //メンバ初期化指定子
    combination(int n):fact(n+1),ifact(n+1){
        fact[0]=1;
        for(int i=1; i<=n; i++) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for(int i=n; i>=1; i--) ifact[i-1] = ifact[i]*i;
    }
    //関数呼び出し時の定義
    mint operator()(int n, int k) {
        if (k<0 || k>n) return 0;
        return fact[n]*ifact[n-k]*ifact[k];
    }
};
//2^nを返す関数
mint f(int n){
    if(n==0) return 1;
    mint a = f(n/2);
    a *= a;
    if(n%2==1) a*=2;
    return a;
}
mint comb(int n, int a){
    mint x=1, y=1;
    for(int i=1; i<=a; i++){
        x*=n-i+1;
        y*=i;
    }
    return x/y;
}
int main(){
    int n,a,b; cin >> n >> a  >> b;
    mint ans = f(n);
    ans -= comb(n,a);
    ans -= comb(n,b);
    ans -= 1;
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import product

ipt = input()
A, B, C, D = int(ipt[0]), int(ipt[1]), int(ipt[2]), int(ipt[3])
for b, c, d in product([1, -1], repeat=3):
    if A + b*B + c*C + d*D == 7:
        ans = str(A) + ('+' if b > 0 else '-') + str(B) + ('+' if c > 0 else '-') + str(C) + ('+' if d > 0 else '-') + str(D) + '=7'
        print(ans)
        break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b == c || b+c == a || c+a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
int a[2005][2005];
int r[2005][2005];
int d[2005][2005];
int main(){
    scanf("%d%d%d",&n,&m,&q);
    memset(a,-1,sizeof(a));
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            char x;
            scanf(" %c",&x);
            a[i][j] = x == '1';
            if (a[i][j-1] == a[i][j]){
                r[i][j-1] = a[i][j-1];
            }
            if (a[i-1][j] == a[i][j]){
                d[i-1][j] = a[i-1][j];
            }
        }
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            r[i][j] += (r[i-1][j]+r[i][j-1]-r[i-1][j-1]);
            d[i][j] += (d[i-1][j]+d[i][j-1]-d[i-1][j-1]);
            a[i][j] += (a[i-1][j]+a[i][j-1]-a[i-1][j-1]);
        }
    }
    for (int i = 0; i < q; i++){
        int sx,sy,ex,ey;
        scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
        int numblue = a[ex][ey] - a[ex][sy-1] - a[sx-1][ey] + a[sx-1][sy-1];
        int numdown = d[ex-1][ey] - d[ex-1][sy-1] - d[sx-1][ey] + d[sx-1][sy-1];
        int numright = r[ex][ey-1] - r[ex][sy-1] - r[sx-1][ey-1] + r[sx-1][sy-1];
        //printf("%d %d %d\n",numblue,numdown,numright);
        printf("%d\n",numblue-numdown-numright);
    }
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;

int N;
bool pairwise=true,setwise=true;
int main(){
    clock_t start = clock();    // スタート時間
    cin.tie(0);
    ios::sync_with_stdio(false);

    

    cin>>N;
    vector<long long>A(N); 
    for(int i=0;i<N;i++)cin>>A[i];
    map<long long,bool>factor;
    map<long long,long long>f_cnt;

    for(int k=0;k<N;k++){
        long long Num=A[k];
        for(long long i=2LL;i*i<=Num;i++){
            if(Num%i==0LL&&factor[i])pairwise=false;
            if(Num%i==0LL)factor[i]=true,f_cnt[i]++;
            while(Num%i==0LL)Num/=i;
        }
        if(Num!=1LL){
            if(factor[Num])pairwise=false;
            factor[Num]=true,f_cnt[Num]++;
        }
        clock_t end = clock();     // 終了時間
        if( (double)(end - start) / CLOCKS_PER_SEC >1.5){cout<<"setwise coprime"<<endl;return 0;}
        //cout<<(double)(end - start) / CLOCKS_PER_SEC<<endl;

    }

    for(auto x:f_cnt)if(x.second==N)setwise=false;

    if(pairwise){cout<<"pairwise coprime"<<endl;return 0;}
    if(setwise){cout<<"setwise coprime"<<endl;return 0;}
    cout<<"not coprime"<<endl;
    return 0;
}


Measured memory_bytes: 18172
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int dp[1001][(1<<12)];

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

  int N, M, A[1000], B;
  cin >> N >> M;
  INTV C(M);
  REP(i, M){
    cin >> A[i] >> B;
    int tmp = 0;
    REP(j, B){
      int c; cin >> c;
      tmp |= (1<<(c-1));
    }
    C[i] = tmp;
  }

  REP(i, M+1) REP(j, (1<<N)) dp[i][j] = VERYBIG;

  dp[0][0] = 0;
  REP(i, M) REP(j, (1<<N)){
    dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
    dp[i+1][j | C[i]] = min(dp[i+1][j | C[i]], dp[i][j] + A[i]);
    
  }
  cout << (dp[M][(1<<N)-1]!=VERYBIG ? dp[M][(1<<N)-1] : -1) << endl;
}


Measured memory_bytes: 32256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;
ll gcd(ll a,ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
ll ans(ll x) {
	if (x == 1)return 1;
	else return(ans(x / 2) * 2 + 1);
}
int main() {
	ll N;
	cin >> N;
	cout << ans(N) << endl;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String[] tmpArray = br.readLine().split(" ");
		
		int input[] = new int[n];
		
		int diff = 0;
		for(int i = 1; i <= n; i++){
			input[i - 1] = Integer.parseInt(tmpArray[i - 1]);
			if(input[i - 1] != i){
				diff++;
			}
		}
		
		if(diff <= 2){
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21076
#include <iostream>
#include <limits>
#include <vector>
#include <cmath>

int main() {
        int n, k;
        std::cin >> n >> k;
        std::vector<int> candles(n);
        for (auto& candle : candles) {
                std::cin >> candle;
        }

        auto min_val = std::numeric_limits<int>::max();
        for (auto i = 0; i <= candles.size() - k; ++i) {
                auto val = candles[i + k - 1] - candles[i] +
                        std::min(
                                std::abs(candles[i]),
                                std::abs(candles[i + k - 1]));
                if (min_val > val) {
                        min_val = val;
                }
        }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 100, MAX_W = 10000;

int N, W, v[MAX_N], w[MAX_N];

int dp[MAX_W + 1];
int main() {
    cin >> N >> W;
    REP(i, N) cin >> v[i] >> w[i];

    REP(i, W + 1) dp[i] = 0;

    REP(i, N) {
        for (int j = 1; j * w[i] <= W; j++) dp[j * w[i]] = max(dp[j * w[i]], j * v[i]);
    }

    REP(i, W + 1) {
        REP(j, i) dp[i] = max(dp[i], dp[j] + dp[i - j]);
    }
    PRINT(dp[W]);
    return 0;
}


Measured memory_bytes: 3152
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,x,y,z;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a<0){
		x=-1*a;
		y=x*c;
		z=e*b;
		printf("%d\n",y+z+d);
	}
	else if(0<a){
		x=b-a;
		printf("%d\n",x*e);
	}
	else{
		x=b*e;
		printf("%d\n",x+d);
	}
	return 0;
}


Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int sensor=0;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j ++){
            if( N == i * j){
                cout << "Yes" << endl;
                sensor = 1;
                break;
            }
        }
    if(sensor == 1){
        break;
    }
    }
    if(sensor == 0){
        cout << "No" << endl;
    }

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

const double PI = acos(-1);
#define MOD 1000000007  ///1e9+7

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) abs((a)*(b))/gcd((a),(b))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

///******************************** C o d e ********************************///



main()
{
    ll k,i,a,b;
    while(cin>>k>>a>>b){
        for(i=a;i<=b;i++) if(i%k==0) {cout<<"OK" el; break;}
        if(i>b) cout<<"NG" el;
    }

}



///Thank you.



///Brainless_Loco Terminates Here!


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;


int main(){
  ll k,a,b;cin>>k>>a>>b;
  if(a>=b-1){
    cout<<1+k<<endl;return 0;
  }
  cout<<a+((k-a+1)/2)*(b-a)+(k-a+1)%2<<endl;
}





Measured memory_bytes: 3596
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, X, M = LI()

    A = []
    seen = set()
    tmp = X
    head_idx = -1
    while True:
        A.append(tmp)
        seen.add(tmp)
        tmp = pow(tmp, 2, M)
        if tmp in seen:
            head_idx = A.index(tmp)
            break
    # print(A, head_idx)

    cnt = [0] * len(A)
    for i in range(len(A)):
        if i < head_idx:
            if i <= N:
                cnt[i] = 1
        else:
            l = len(A) - head_idx
            cnt[i] = (N - head_idx) // l
    for i in range(head_idx, head_idx + (N - head_idx) % l):
        cnt[i] += 1
    # print(cnt)

    ans = sum([a * c for a, c in zip(A, cnt)])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 17692
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll> a(n);
        for(int i=0;i<n;i++)
        cin>>a[i];
        ll sum=a[n-1],ans=0;
        for(int i=n-2;i>=0;i--)
        {
            ans=(ans+(sum*a[i])%mod)%mod;
            sum=(sum+a[i])%mod;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

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

int main() {
    int h,w;// h rows, w columns
    cin>>h>>w;
    char arr[h][w];
    long int ans[h][w]; 
    for(int i=0;i<h;++i)
    {
        for(int j=0;j<w;++j)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<h;++i)
    {
        for(int j=0;j<w;++j)
        {
            if(arr[i][j]=='#')
            ans[i][j]=0;
            else if(i==0 && j==0)
            ans[i][j]=1;
            else if(i==0)
            ans[i][j]=ans[i][j-1];
            else if(j==0)
            ans[i][j]=ans[i-1][j];
            else
            ans[i][j]=(ans[i-1][j]+ans[i][j-1])%(1000000007);
        }
    }
    cout<<ans[h-1][w-1]<<endl;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define mp make_pair
#define all(X) X.begin(), X.end()
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int n, i;
    cin >> n;
    vi a(n, 0);

    fo(i , n)
    cin >> a[i];

    double num = 0;

    for(i = 0; i < n; i++)
    {
        num += (1.0 / a[i]);
    }
    num = 1.0 / num;
    cout << fixed << setprecision(10) << num <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    s64 a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    if ((v - w) * t >= abs(a - b))
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }

    return 0;
}



Measured memory_bytes: 3644
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;
ll arr[200005];

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m=1000000007,j,k,x,y,a,b,c,d,t,r,sm=0,f,sf,sb;
	string s;
	
	cin >> n >> k;
	sf=(k*(k-1))/2;
	sb=(n*(n+1))/2-((n-k)*(n-k+1))/2;
	a=0;
	x=k,y=n-k;
	for(i=k;i<=n+1;i++)
	{
//		cout << sf << " " << sb << endl;
		a=(a+max(0LL,1+sb-sf))%m;
		sf+=x;
		sb+=y;
		x++,y--;
	}
	cout << a;
	return 0;
}


Measured memory_bytes: 3656
N,T=map(int,input().split())
t=list(map(int,input().split()))
now=t[0]+T
ans=T
for i in range(1,N):
  if now < t[i]:
    ans+=T
    now=t[i]+T
  else:
    ans+=T-(now-t[i])
    now=t[i]+T
print(ans)

Measured memory_bytes: 26832