akhauriyash/Code-Regression huggingface dataset:
/*
Author : Hocky Yudhiono
5/31/2020 7:02:20 PM

1. You can sort the query if offline!
2. Don't bring the dp remaining state when dfsing on DP on Tree.
3. Try to reverse (Think from the back) if you stuck.
4. Be careful when submitting Div. 2 D-F, dont waste it on stupid WAs.
5. Try to reduce a problem
*/

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef vector<int> vi;
typedef pair<LL,LL> PLL;
typedef pair<LL,int> PLI;
typedef pair<int,int> PII;
typedef pair<int,int> pii;
typedef vector<vector<LL>> VVL;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define mp make_pair
#define pb push_back
#define remove erase
#define fi first
#define se second

//If the time limit is strict, try not to use long double

//Remember to undefine if the problem is interactive
#define endl '\n'
#define DEBUG(X) cout << ">>> DEBUG(" << __LINE__ << ") " << #X << " = " << (X) << endl

const double EPS = 1e-9;
const int INFMEM = 63;
const int INF = 1061109567;
const LL LINF = 4557430888798830399LL;
const double DINF = numeric_limits<double>::infinity();
const LL MOD = 1000000007;
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
// Do dir^1 to get reverse direction
const char dch[4] = {'R','L','D','U'};
// const string ds[8] = {"E","W","S","N","SE","NW","SW","NE"};
const double PI = 3.141592653589793;

inline void open(string a){
    freopen((a+".in").c_str(),"r",stdin);
    freopen((a+".out").c_str(),"w",stdout);
}

inline void fasterios(){
    //Do not use if interactive
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

LD a,b;

int main(){
    cin >> a >> b;
    cout << fixed << setprecision(0) << floor(a*b) << endl;
    return 0;
}

Measured memory_bytes: 3792
A,B = list(map(int,input().split()))
para_a = str(B)
para_b = str(A)

for i in range(A-1):
    para_a = para_a + str(B)

for i in range(B-1):
    para_b = para_b + str(A)

if para_a < para_b:
    print(para_a)
else:
    print(para_b)


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

long long N, M;
vector<long long> X;
vector<long long> diff;

int main(){
	cin >> N >> M;
	for(long long i = 0; i < M; i++){
		long long x;
		cin >> x;
		X.push_back(x);
	}
	sort(X.begin(), X.end());
	for(long long i = 0; i < M-1; i++){
		diff.push_back(abs(X[i+1] - X[i]));
	}
	sort(diff.begin(), diff.end(), greater<long long>());
	long long ans = 0;
	for(long long i = 0; i < diff.size(); i++){
		if(i >= N-1){
			ans+= diff[i];
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2548
n, k = map(int, input().split())
s = list(input())
k -= 1
if s[k] == 'A':
  s[k] = 'a'
elif s[k] == 'B':
  s[k] = 'b'
else:
  s[k] = 'c'
ans = ''
for i in s:
  ans += i
print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int[] box = new int[k*2-1];
        
        for(int i=0; i<box.length;i++) {
            box[i]=(x-k)+(i+1);
            System.out.println(box[i]);
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define fast                          \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);
#define FOR(n) for(int i(0);i<n;++i)
#define ASC(i,a,b) for(int i(a); i <=b; ++i)
#define DESC(i,a,b) for(int i(a);i>=b;i--)
#define WL(t) while(t--)
#define SZ(a) int((a).size())
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define BB begin()
#define EE end()
#define all(c) c.BB, c.EE
#define present(container, element) (container.find(element) != container.end())
// ^^for set,map etc
#define cpresent(container, element) (find(all(container), element) != container.end())
// for vector,array etc
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a), (b))
typedef long long LL;
typedef long double LD;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef map<char,int> mci;
typedef pair<int, int> pii;
typedef map<int,pii> ipii;
const float INF = numeric_limits<float>::infinity();
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846264338;
const LL big=998244353;

#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif


int main(){
	int n,k;
	cin >> n >> k;
	if(k==1){
		cout << 0;
	}
	else{
		cout << n-k;
	}
}

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


int main(){
    int N;
    cin>>N;
    vector<int> buka(N,0);
    for (int i=1;i<N;i++){
        int Ai;
        cin>>Ai;
        buka.at(Ai-1)++;
    }
    for(int i=0;i<N;i++){
        cout<<buka.at(i)<<endl;
    }

}

Measured memory_bytes: 4052
def main():
    N = int(input())
    A = list(map(int, input().split()))
    admit = True
    for n in range(N):
        if A[n] % 2 == 0 and not (A[n] % 3 == 0 or A[n] % 5 == 0):
            admit = False
    if admit:
        print('APPROVED')
    else:
        print('DENIED')
    
main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
const int INF = 1 << 30;

typedef long long ll;

struct Cake {ll x, y, z;};

int main() {
  int N, M;
  cin >> N >> M;
  vector<Cake> C(N);
  for (int i = 0; i < N; i++) {
    ll x, y, z;
    cin >> x >> y >> z;
    C[i] = (Cake){x, y, z};
  }
  
  ll ans = 0;
  for (int i = 0; i < 8; i++) {
    vector<ll> sum(N);
    int a, b, c;
    if (i >> 0 & 1) a = 1; else a = -1;
    if (i >> 1 & 1) b = 1; else b = -1;
    if (i >> 2 & 1) c = 1; else c = -1;
    for (int j = 0; j < N; j++) {
      sum[j] = a * C[j].x + b * C[j].y + c * C[j].z;
    }
    sort(sum.begin(), sum.end(), [](ll a, ll b){return a > b;});
    ll s = 0;
    for (int m = 0; m < M; m++) {
      s += sum[m];
    }
    ans = max(ans, s);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()
 
#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream &os, vector<T> V){
  os<<"[";for(auto vv:V)os<<vv<<",";return os<<"]";
} 

template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}


#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
 
#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue
 
#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb fflush(stdout)

vector<PII> dol;
vector<PII> prawo;
vector<PII> gora;
vector<PII> lewo;

int r, c;

bool brzeg(int a, int b) {
	return (a==0 || b==0 || a==r || b==c);
}

void wstaw(int a, int b, int nr) {
	if (a==0) dol.pb(mp(b,nr));
	else if (b==c) prawo.pb(mp(a,nr));
	else if (a==r) gora.pb(mp(-b,nr));
	else if (b==0) dol.pb(mp(-a,nr));
}

set<int> kutas;
stack<int> stos;

int rob(vector<PII> xxx) {
	FORE(i, xxx) {
		int val = i->nd;
		if (stos.empty()) {
			kutas.insert(val);
			stos.push(val);
		} else if (stos.top() == val) {
			stos.pop();
			kutas.erase(val);
		} else {
			if (kutas.find(val) != kutas.end()) {
				printf("NO\n");
				return 0;
			} else {
				kutas.insert(val);
				stos.push(val);
			}
		}
	}
	return 1;
}

int main () {
	read2(r, c);
	make(n);
	FOR(i,0,n) {
		make4(x,y,z,t);
		if (!brzeg(x,y) || !brzeg(z,t)) continue;
		wstaw(x,y,i);
		wstaw(z,t,i);
	}
	sort(all(dol));
	sort(all(prawo));
	sort(all(gora));
	sort(all(lewo));
	if (rob(dol) == 0) return 0;
	if (rob(prawo) == 0) return 0;
	if (rob(gora) == 0) return 0;
	if (rob(lewo) == 0) return 0;
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 4832
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
ans = []
flag = false
as.each_with_index do |a,i|
  if i.even?
    ans.push(a)
  else
    ans.unshift(a)
  end
  flag = !flag
end

puts flag ? ans.reverse.join(" ") : ans.join(" ")

Measured memory_bytes: 29024
#include<bits/stdc++.h>
using namespace std;
	int main()
{
	while(1){
	int x,y;
	cin>>x>>y;
	if(x ==0 && y==0) break;
	if(x>y) swap(x,y);
	cout<<x<<" "<<y<<endl;
}
	return 0;
}


Measured memory_bytes: 3064
// ボール: 区別あり, 箱：区別なし, 入れ方: 制限なし
// ベル数
// B(n, k) = S(n, 0) + S(n, 1) + ... + S(n, k)
#include <iostream>
using namespace std;
const int MOD = 1000000007;
const long long MAXN = 1010;
long long S[MAXN][MAXN] = {};

void star_init() {
  S[0][0] = 1;
  for(int n = 1; n < MAXN; n++) {
    for(int k = 1; k < MAXN; k++) {
      S[n][k] = S[n - 1][k - 1] + k * S[n - 1][k];
      S[n][k] %= MOD;
    }
  }
}


int main() {
  
  star_init();
  int n, k; cin >> n >> k;
  long long B = 0;
  for(int i = 0; i <= k; i++) {
    B += S[n][i];
    B %= MOD;
  }
  cout << B << endl;
  return 0;
}



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

using namespace std;

#define ll  long long
#define ld  double

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

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<int,int>   ii;

int f[N];
int h[N];

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

    int n;  cin >> n;

    for(int i = 1 ; i <= n ; ++i)   {
        cin >> h[i];

        if (i > 1)  f[i] = 1e9 + 7;
        if (i > 1)  f[i] = min(f[i],f[i - 1] + abs(h[i - 1] - h[i]));
        if (i > 2)  f[i] = min(f[i],f[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << f[n] << endl;   
}

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
}
  

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

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

const int M = 333333;
int sosu[M];

int main(){
	sosu[0]=sosu[1]=1;
	rep(i,M){
		if(sosu[i]==1)continue;
		for(int j=i*2;j<M;j+=i){
			sosu[j]=1;
		}
	}
	
	
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		int ans = 0;
		reps(i,n+1,2*n+1){
			if(sosu[i]==0)ans++;
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 2448
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**9)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #r = [int(stdin.readline()) for i in range(3)]
    
    a = list(map(int, r.split()))
    n = a[0]
    k = a[1]
    s = a[2]

    tmp = 0
    if s == 10**9:
        tmp = 1
    else:
        tmp = 10**9
    res = [tmp]*n
    for i in range(k):
        res[i] = s
    print(*res)

    #'Yes', 'No', 'YES', 'NO', ':(', 'Yay!'
    #res = 0
    #a, b = map(int, r.split())
    #print()

if __name__ == '__main__':
    main()



Measured memory_bytes: 46580
// D - String Equivalence
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	set<string> s{"a"};
	while(--N){
		set<string>t; swap(s,t);
		for(auto pre:t){
			char mx='a'; for(auto c:pre) mx = max(mx, c); mx++;
			for(char c='a'; c<=mx; ++c) s.insert(pre + string(1,c));
		}

	}
	for(auto x:s) cout<< x <<endl;
}

Measured memory_bytes: 14336
from collections import deque
S = deque(input())
ans = list()
while S:
  tmp = S.popleft()
  if not ans:
    ans.append(tmp)
    continue
  if ans[-1] == tmp:
    if S:
      tmp += S.popleft()
    else:
      break

  ans.append(tmp)
    
print(len(ans))

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

int main() {
    int a,b;
    cin >> a >> b;
    vector<int> s(a);
    for(int i = 0; i<a; i++) {
        cin >> s[i];
    }

    int min = s[0];
    int res;
    for(int i = 0; i<a; i++) {
        if(min > s[i]) min = s[i];
        b -= s[i];
        res++;
    }
    cout << res + (b / min) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
int main(){
    long long K,X;
    cin >> K >> X;
    repr(i,X-K+1,X+K){
        cout << i << ' ' ;
    }

    
    return 0;
}


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

int main() {
	int n; cin >> n; if (n % 2 == 0) {cout << -1 << endl; return 0;} 
	int c = 7; if (c % n == 0) {cout << 1 << endl; return 0;}
	for (int i = 0; i < n+1; i++) {
		c %= n; c *= 10; c += 7; c %= n; if (c == 0) {cout << i+2 << endl; return 0;}
	} cout << -1 << endl; return 0;
}

Measured memory_bytes: 3516
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
 int a,b;
 char x[10],y[10];
 cin>>a>>b;

 for(int i=0;i<a;i++){
   x[i]=b;
 }
 for(int i=0;i<b;i++){
   y[i]=a;
 }

 if(a<=b){
   for(int i=0;i<b;i++){
     cout<<a;
   }
 }
 if(a>b){
   for(int i=0;i<a;i++){
     cout<<b;
   }
 }

 return 0;
}


Measured memory_bytes: 256
# ABC142E - Get Everything
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    p, INF = 1 << N, 1 << 60
    # bitDP of minimum cost to buy the subset of items represented by binary
    dp = [INF] * p
    dp[0] = 0
    for _ in range(M):
        a, _ = map(int, input().split())
        x = sum(1 << (i - 1) for i in map(int, input().split()))
        for y in range(p):
            dp[x | y] = min(dp[x | y], dp[y] + a)
    ans = dp[-1] if dp[-1] != INF else -1
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int a=0;

	if (s[0] == '1') {
		a = a + 1;
	}
	if (s[1] == '1') {
		a = a + 1;
	}
	if (s[2] == '1') {
		a = a + 1;
	}
	cout << a;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    string s;
    int q;
    cin>>s>>q;
    bool rev=false;
    string prefix="";
    rep(i,q){
        int in;
        cin>>in;
        if(in==1){
            rev=!rev;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if((!rev &&f==1)||(rev&&f==2)){
                prefix+=c;
            }
            else{
                s=s+c;
            }
        }
    }
    if(rev)reverse(s.begin(),s.end());
    else reverse(prefix.begin(),prefix.end());
    if(rev)cout<<s+prefix<<endl;
    else cout<<prefix+s<<endl;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  string s;
  cin >> n >> s;
  int W = 0, E = 0;
  rep(i,n) {
    if(s[i] == 'W') W++;
    else E++;
  }
  int lw = 0, le = 0;
  int ans = inf;
  rep(i,n) {
    int rw = W - lw;
    int re = E - le;
    if(s[i] == 'E') re--;
    else rw--;
    int tmp = re + lw;
    chmin(ans, tmp);
    if(s[i] == 'E') le++;
    else lw++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 720
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

const int N = 26, D = 365;

using namespace std;
int main() {
    int d;
    cin >> d;
    vector<int> c(N);
    vector<vector<int>> s(D, vector<int>(N));
    for (int i = 0; i < N; ++i)
        cin >> c[i];
    for (int i = 0; i < d; ++i)
        for (int j = 0; j < N; ++j)
            cin >> s[i][j];
    vector<int> ans;
    double best = LLONG_MIN;
    for (int start = 0; start < N; ++start) {
        for (int second = 0; second < N; ++second) {
            double tot = s[0][start] + s[1][second];
            vector<int> last(N, 0), cans = {start + 1, second + 1};
            for (int i = 0; i < N; ++i) {
                if (i != start)
                    tot -= c[i];
                if (i != second) {
                    if (i == start)
                        tot -= c[i];
                    else
                        tot -= c[i] * 2;
                }
            }
            last[start] = 1;
            last[second] = 2;
            for (int i = 3; i <= d; ++i) {
                int maxt = 0;
                double maxg = LLONG_MIN, maxpts = LLONG_MIN;
                for (int j = 0; j < N; ++j) {
                    double gain = s[i - 1][j];
                    double pts = gain;
                    for (int k = 0; k < N; ++k)
                        if (k != j) {
                            pts -= c[k] * (i - last[k]);
                            gain -= c[k] * (i - last[k]) * (i - last[k]);
                        }
                    if (gain > maxg) {
                        maxg = gain;
                        maxpts = pts;
                        maxt = j;
                    }
                }
                last[maxt] = i;
                cans.emplace_back(maxt + 1);
                tot += maxpts;
            }
            if (tot > best) {
                best = tot;
                ans = cans;
            }
        }
    }
    for (int i : ans)
        cout << i << endl;
}


Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll H, n;
    cin >> H >> n;

    vl a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }

    vvl dp(n+1, vl(H+1, INF));  // dp[i+1][j] : i番目の魔法まででモンスターの体力がjのとき倒すのに必要な魔力の合計の最小値
    dp[0][0] = 0;
    rep(i, n) {
        exrep(j, 0, H) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][j], dp[i+1][max(0LL, j - a[i])] + b[i]);
        }
    }

    out(dp[n][H]);
    re0;
}

Measured memory_bytes: 78592
#!/usr/bin/env python3
#CODEFESTIVAL2017 Final C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
D = LI()
D.sort()
a = D[:]
b = D[:]
if n == 1:
    print(D[0])
    quit()
for i in range(n):
    if i % 2:
        continue
    a[i] = 24 - a[i]
a.sort()
for i in range(n):
    if i % 2:
        b[i] = 24 - b[i]
b.sort()
d = [0] + a + [24]
ans1 = inf
for i in range(n+1):
    ans1 = min(ans1,d[i+1] - d[i])
d = [0] + b + [24]
ans2 = inf
for i in range(n+1):
    ans2 = min(ans2,d[i+1] - d[i])
print(max(ans1,ans2))    

Measured memory_bytes: 38384
N,M=map(int,input().split())
XY=[list(map(int,input().split())) for i in range(M)]
borldata=[1 for i in range(N)]
akaidxlist=[0 for i in range(N)]
akaidxlist[0]=1
for i in XY:
    x,y=i
    x,y=x-1,y-1
    if akaidxlist[x]==1:
        akaidxlist[y]=1
        if borldata[x]==1:akaidxlist[x]=0
    borldata[x]-=1
    borldata[y]+=1
print(len([i for i in akaidxlist if i]))


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n=S.size();
    int cnt=0;
    for (char c:S) cnt+=(c=='o');
    cout << (8<=cnt+(15-n)?"YES":"NO") << '\n';
}

Measured memory_bytes: 256
import math

num = raw_input()
num_list = []
for i in range(int(num)):
    a = raw_input()
    num_list.append(int(a))
count = 0

for num in num_list:
    if num <= 1:
        continue
    elif num == 2:
        count += 1
    elif num % 2 == 0:
        continue
    else:
        count += 1
        for i in range(3, int(math.sqrt(num))+1, 2):
            if num % i == 0:
                count -= 1
                break
print count

Measured memory_bytes: 6992
/*==============================
 * Authot : ylsoi
 * Time : 2018.3.20
 * Problem : ARC92F
 * File : ARC92F.cpp
 * Algorithm : Strange Algorithm
 * ===========================*/
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
void File(){
	freopen("ARC92F.in","r",stdin);
	freopen("ARC92F.out","w",stdout);
}
#define REP(i,a,b) for(register int i=a;i<=b;++i)
#define DREP(i,a,b) for(register int i=a;i>=b;--i)
#define mem(a) memset(a,0,sizeof(a))
const int maxn=1000+10;
const int maxm=200000+10;
vector<int>E[maxn];
int n,m,beg[maxn],len,num[maxn][maxn];
bool can[maxn][maxn],vis[maxn],can1[maxn][maxn];
int vis1[maxn],vis2[maxn],from[maxm],to[maxm];
void dfs(int u,int rt){
	vis[u]=1;
	can[rt][u]=1;
	int size=E[u].size()-1;
	REP(i,0,size){
		int v=E[u][i];
		if(vis[v])continue;
		dfs(v,rt);
	}
}
void dfs1(int u){
	vis[u]=1;
	int size=E[u].size()-1;
	REP(i,0,size){
		int v=E[u][i];
		if(vis[v])continue;
		vis1[v]=num[u][v];
		dfs1(v);
	}
}
void dfs2(int u){
	vis[u]=1;
	int size=E[u].size()-1;
	DREP(i,size,0){
		int v=E[u][i];
		if(vis[v])continue;
		vis2[v]=num[u][v];
		dfs2(v);
	}
}
int main(){
	//File();
	scanf("%d%d",&n,&m);
	REP(i,1,m){
		int u,v;
		scanf("%d%d",&u,&v);
		E[u].push_back(v);
		num[u][v]=++len;
		from[len]=u;
		to[len]=v;
	}
	REP(i,1,n){
		dfs(i,i);
		mem(vis);
	}
	REP(i,1,n){
		dfs1(i);
		mem(vis);
		dfs2(i);
		mem(vis);
		int size=E[i].size()-1;
		REP(j,0,size){
			int v=E[i][j];
			if(vis1[v]!=num[i][v] || vis2[v]!=num[i][v])
				can1[i][v]=1;
		}
		mem(vis1);
		mem(vis2);
	}
	REP(i,1,m){
		int u=from[i],v=to[i];
		if((can[v][u]^can1[u][v])==0)
			puts("same");
		else puts("diff");
	}
	return 0;
}


Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;

using namespace std;

int main() {
  ll n,m;
  cin>>n;
  vector<int> d(n);
  rep(i,n) cin>>d[i];
  cin>>m;
  vector<int> t(m);
  rep(i,m) cin>>t[i];
  bool ans=true;
  
  sort(all(d));
  sort(all(t));
  int st=0;
  rep(i,m){
   // cout<<t[i]<<endl;
    if(!ans) break;
    for(int j = st ; j < n ; j ++ ){
    	if(t[i]<d[j]) {
    		   ans=false;
    		  break;
          t[i]=-1;
   		}
        if(t[i]==d[j]){
          d[j]=-1;t[i]=-1;
          st=j+1;
         break; 
        }
    
    }
    if(t[i]!=-1){
      ans=false;
      break;
      }
    
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main() {
    string s , t;
    cin >> s >> t;
    int l1 = s.size();
    int l2 = t.size();
    int dp[l1+1][l2+1];
    for(int i = 0 ; i <=l1 ; i++){
        for(int j = 0 ; j <=l2 ; j++){
            if(i == 0 || j == 0)dp[i][j] = 0 ;
            else if(s[i-1] == t[j-1])dp[i][j] = dp[i-1][j-1] + 1 ;
            else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
        }
    }
    int len = dp[l1][l2];
    char lcs[len+1];
    lcs[len] = '\0' ;
    int  i = l1  , j = l2;
    while(i > 0 && j >0 && len >0){
        if(s[i-1] == t[j-1]){
            lcs[len-1] = s[i-1];
            i--;
            j--;
            len--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else j--;
    }
    cout << lcs << endl ;
    return 0;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int a, b;
        cin >> a >> b;
        cout << max( 0 , a - 2 * b ) << endl;
        return 0;
}










Measured memory_bytes: 256
#include<stdio.h>
int x,y,z;
 
int main(void){
    scanf("%d%d%d",&x,&y,&z);
    if(x == y && x != z){
      printf("Yes");
    }else if(y == z && y != x){
      printf("Yes");
    }else if(z == x && z != y){
      printf("Yes");
    }else{printf("No");}
  return 0;
}



Measured memory_bytes: 128
a = gets.to_i
b = gets.split.map(&:to_i)
co = 0
sum = 0
b.each do |e|
  co += 1 if e.zero? || e.negative?
  sum += e.abs
end

sum -= 2 * b.map(&:abs).sort[0] if co.odd?

p sum

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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

/////////////////////////////////

int const MAX = 741;
int const INF = 1e9 + 41;

vpii a;

int n, m;
int w[MAX][MAX];
int col[MAX];
bool u[MAX];

vi e[MAX];

void bad() {
	printf("-1\n");
	exit (0);
}

int cnt[2];

bool dfs(int x) {
	cnt[col[x]]++;
	u[x] = 1;
	for (int y : e[x]) {
		if (!u[y]) {
			col[y] = (1 - col[x]);
			if (dfs(y)) return 1;		
		}
		if (col[y] != 1 - col[x]) return 1;
	}
	return 0;
}

int d[MAX][MAX];
int ans;

void solve() {
	fi(1, n) {
		fj(1, n) {
			if (i == j) continue;
			if (w[i][j]) continue;
			e[i].pb(j);
		}
	}
	fi(1, n) {
		if (u[i]) continue;
		memset(cnt, 0, sizeof(cnt));
		if (dfs(i)) {
			bad();
		}
		a.pb(mp(cnt[0], cnt[1]));
	}
	/*
	err("%d\n", sz(a));
	fi(1, n) {
		err("i = %d col = %d\n", i, col[i]);
	}
	*/
	d[0][0] = 1;
	fi(0, sz(a) - 1) {
		fj(0, MAX - 1) {
			if (!d[i][j]) continue;
			int x = j + a[i].first;
			int y = j + a[i].second;
			d[i + 1][x] = 1;
			d[i + 1][y] = 1;
		}
	}
	ans = INF;
	fi(0, MAX - 1) {
		if (d[sz(a)][i]) {
			int x = i;
			int y = n - x;
			int pans = x * (x - 1) / 2 + y * (y - 1) / 2;
			ans = min(ans, pans);
		}
	}
	printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d %d", &n, &m);
  fi(1, m) {
  	int x, y;
  	scanf("%d %d", &x, &y);
  	w[x][y] = w[y][x] = 1;
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

enum Face : int { Top, Front, Right, Left, Back, Bottom };
struct cube {
  int f[6];
  unordered_map<int, string> mp;
  cube(){}
  /*
            1(Top)
    4(Left) 2(Front) 3(Right) 5(Back)
            6(Bottom)
  */
  cube(vector<int> const& vs){ for(int i=0; i<6; i++) f[i] = vs[i]; }
  cube(vector<string> const& vs) { for(int i=0; i<6; i++) mp[i+1] = vs[i]; }
  void roll_z() { roll(1, 2, 4, 3); }
  void roll_y() { roll(0, 2, 5, 3); }
  void roll_x() { roll(0, 1, 5, 4); }
  void roll(int i, int j, int k, int l) {
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }

  void roll(int k) {
    if(k == 0) roll_y();
    if(k == 1) roll_x();
    if(k == 2) for(int i=0; i<3; i++) roll_y();
    if(k == 3) for(int i=0; i<3; i++) roll_x();
  }

  bool roll_top_front(int top, int front) {
    for(int k = 0; k < 6; (k & 1 ? roll_y() : roll_x()), k++)
      for(int i = 0; i < 4; roll_z(), ++i)
        if(top == f[Top] && front == f[Front]) return true;
    return false;
  }

  bool operator == (cube const& rhs) const {
    for(int i=0; i<6; i++)
      if(f[i] != rhs.f[i]) return false;
    return true;
  }

  bool isomorphic(cube rhs) const {
    for(int i=0; i<6; i++) {
      for(int j=0; j<4; j++) {
        if(operator==(rhs)) return true;
        rhs.roll_z();
      }
      if(i % 2 == 0) rhs.roll_y();
      else rhs.roll_x();
    }
    return false;
  }

};

int main() {

  cube c; for(int i=0; i<6; i++) cin >> c.f[i];
  int q; cin >> q;
  rep(i, q) {
    int t, f; cin >> t >> f;
    c.roll_top_front(t, f);
    cout << c.f[Right] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3036
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoderBeginnerContest
{
    internal class Program
    {
        private static int a;
        private static int b;

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            var inputs = CR.GetIntegers().ToList();
            a = inputs[0];
            b = inputs[1];

            var xx = string.Join("", Enumerable.Range(0, a).Select(x => b.ToString()));
            var yy = string.Join("", Enumerable.Range(0, b).Select(x => a.ToString()));

            return new string[] { xx, yy }.OrderBy(x => x).First();
            //return xx < yy ? xx : yy;
        }
    }
}


Measured memory_bytes: 11616
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int k;
	cin>>k;
	long long sum =0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int l=1;l<=k;l++)
			{
				sum+=gcd(gcd(i,j),l);
			}
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long h, w;
long n;

//divCeil
long divCeil(long a, long b){
    return (a-1)/b+1;
}

int main(){
    scanf("%ld%ld%ld", &h, &w, &n);
    printf("%ld\n", divCeil(n, std::max(h, w)));
}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.print(a * b);
        System.out.print(" ");
        System.out.println(2*(a+b));
    }
}


Measured memory_bytes: 26144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] string = line.split(" ");
		int a = Integer.parseInt(string[0]);
		int b = Integer.parseInt(string[1]);

		if (a > b) {
			System.out.println("a > b");
		}
		if (a < b) {
			System.out.println("a < b");
		}
		if (a == b) {
			System.out.println("a == b");
		}
	}

}

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

char s[100100];
int l;


int main() {
	scanf("%s", s);
	l = strlen(s);

	if(s[0] == s[1])return cout << 1 << " " << 2, 0;

	for(int i = 2; i < l; ++i) {
		if(s[i] == s[i - 1])return cout << i << " " << i + 1, 0;
		if(s[i - 2] == s[i])return cout << i - 1 << " " << i + 1, 0;
	}

	cout << -1 << " "<< -1;

}


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 IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			 System.out.println(b%a==0?a+b:b-a);
		}
	}
}

Measured memory_bytes: 25288
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979;
int main()
{
    int t;
    double x, sum = 0;
    string s;
    cin >> t;
    while(t --){
      cin >> x >> s;
      if(s == "JPY")  sum += x;
      else sum += (x * 380000);
    }
    printf("%lf\n", sum);
    return 0;
}


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

int main(void){
   int H,W;
   cin>>H>>W;
   vector<string>S(H);
   for(int i=0;i<H;i++){
      cin>>S[i];
   }

   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         if(S[i][j]=='#') cout<<"#";
         else{
            int count=0;
            for(int dx=-1;dx<=1;dx++){
               for(int dy=-1;dy<=1;dy++){
                  int nx=i+dx;
                  int ny=j+dy;
                  if(nx<0||ny<0||nx>=H||ny>=W) continue;
                  if(S[nx][ny]=='#') count++;
               }
            }
            cout<<count;
         }
      }
      cout<<endl;
   }
   return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, double>  iidb;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 400
#define offset 200
int bit2d[tam+20][tam+20];
ll tot=0;
void update(int posi,int posj)
{
	if (posi<0|| posj<0){
		//<<"filo";
		return ;
	}
	for(int i=posi;i<tam;i+=i&(-i))
	{
		for(int j=posj;j<tam;j+=j&(-j))
		{
			bit2d[i][j]++;
		}
	}
	//<<"termino";
}
int query(int posi,int posj)
{
	if (posi<0|| posj<0)
		assert(false);
	int rtot=0;
	for(int i=posi;i>0;i-=i&(-i))
	{
		for(int j=posj;j>0;j-=j&(-j))
		{
			rtot+=bit2d[i][j];
		}
	}
	return rtot;
}
void go(string txt)
{

	ll valor=0;
	bool valid=0;
	int pos=0;
	forr(i,0,txt.size())
	{
		if (txt[i]=='.'){
			valid=1;
			continue;
		}
		if (valid)
			pos++;
		valor*=10;
		valor+=(txt[i]-'0');
	}	
	//<<valor<<" ";
	int c2,c5;
	c2=c5=0;
	while(valor%2==0)
		valor/=2,c2++;
	while(valor%5==0)
		valor/=5,c5++;
	//<<c2<<" "<<c5<<endl;
	int cant2=c2-pos,cant5=c5-pos;
	//<<cant2<<" "<<cant5<<endl;
	tot+=query(tam-1,tam-1);
	//<<tot<<endl;
	tot-=query(offset-cant2-1,tam-1);
	//<<tot<<endl;
	tot-=query(tam-1,offset-cant5-1)-query(offset-cant2-1,offset-cant5-1);
	//<<tot<<endl;
	//<<query(tam-1,tam-1)<<" "<<(query(offset-cant2,tam-1)+query(tam-1,offset-cant5)-query(offset-cant2,offset-cant5))<<endl;
	//<<tot<<" "<<cant2<<" "<<cant5<<endl;
	update(offset+cant2,offset+cant5);
	//<<"cagada\n";
}
int main()
{
	int n;
	cin>>n;
	string num;
	forr(i,0,n)
	{
		cin>>num;
		go(num);
	}
	cout<<tot<<endl;
}				

Measured memory_bytes: 3616
n = gets.chomp.to_i

keta = 1
while 26**keta < n
  n -= 26**keta
  keta += 1 
end
n -= 1

ans = ""
keta.times do |i|
  ans = ('a'.ord + n % 26).chr + ans
  n /= 26
end

puts ans

Measured memory_bytes: 14332
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1126

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int W,H;
int dw[2] = {0, 1};
int dh[2] = {1, 0};
vector< vector<char> > matrix;
vector< vector<string> > dp;

string max(string str1, string str2)
{	
	if(str1.length() == str2.length())
	{
		rep(i,str1.size())
		{
			if(str1[i] != str2[i]){
				return str1[i] > str2[i] ? str1 : str2;
			}
		}
		return str1;
	}
	else{
		return str1.length() > str2.length() ? str1 : str2;
	}
}

string dfs(int w, int h)
{
	if(dp[h][w] != "#"){ return dp[h][w]; }

	string res="";
	rep(i,2)
	{
		int nw = w+dw[i];
		int nh = h+dh[i];
		if(nw < 0 || nw >= W || nh < 0 || nh >= H){ continue; }
		if(!isdigit(matrix[nh][nw])){ continue; }
		res = max(res, dfs(nw,nh));
	}

	dp[h][w] = matrix[h][w] + res;
	return dp[h][w];
}

int main()
{
	while(cin >> W >> H && W)
	{
		matrix.clear();
		matrix.resize( H, vector<char>(W) );

		rep(h,H){
			rep(w,W){
				cin >> matrix[h][w];
			}
		}

		dp.clear();
		dp.resize(H, vector<string>(W,"#"));

		string ans;
		rep(h,H){
			rep(w,W){
				if(isdigit(matrix[h][w]) && matrix[h][w] != '0'){
					ans = max(ans,dfs(w,h));
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1364
#include <iostream>
#define N 105
using namespace std;
typedef long long ll;
char Rot(char);
int GetNum(char);

int main(){
  int h,w,y,x,r,me[N][N][4],ansy,ansx,flag;
  char c;
  string s[N];
  ll l,t;
  while(1){
    cin>>h>>w>>l;
    if(!h&&!w&&!l) break;
    for(int i=0;i<h;i++) cin>>s[i];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	if(s[i][j]!='.'&&s[i][j]!='#') y=i,x=j,c=s[i][j];
	for(int k=0;k<4;k++) me[i][j][k]=-1;
      }
    t=0;
    r=GetNum(c);
    me[y][x][r]=t;
    while(1){
      int ny=y,nx=x;
      if(c=='N') ny--;
      if(c=='E') nx++;
      if(c=='S') ny++;
      if(c=='W') nx--;
      t++;
      flag=0;
      if(ny<0||h<=ny||nx<0||w<=nx||s[ny][nx]=='#') flag=1;
      if(t==l&&!flag){
	ansy=ny+1,ansx=nx+1;
	break;
      }
      if(!flag&&me[ny][nx][r]!=-1&&t-me[ny][nx][r]!=0){
	t=l-((l-me[ny][nx][r])%(t-me[ny][nx][r]));
	if(l-t==0){
	  ansy=ny+1,ansx=nx+1;
	  break;
	}
      }
      if(flag) ny=y,nx=x,c=Rot(c),t--;
      y=ny,x=nx;
      r=GetNum(c);      
      me[ny][nx][r]=t;
    }
    cout<<ansy<<' '<<ansx<<' '<<c<<endl;
  }
  return 0;
}

char Rot(char c){
  if(c=='N') return 'E';
  if(c=='E') return 'S';
  if(c=='S') return 'W';
  return 'N';
}

int GetNum(char c){
  if(c=='N') return 0;
  if(c=='E') return 1;
  if(c=='S') return 2;
  return 3;
}

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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<int>furui(55556,1);
  furui[0]=0;
  furui[1]=0;
  for(int i=2;i<=furui.size()-1;i++){
    if(furui[i]==1){
      for(int j=2*i;j<=furui.size()-1;j=j+i){
        furui[j]=0;
      }
    }
  }
vector<int>ans(0);
  for(int i=1;i<furui.size();i++){
    if(i%10==1&&furui[i]==1)ans.push_back(i);
  }
  rep(i,n)cout<<ans[i]<<' ';

  }


Measured memory_bytes: 3752
///*Bismillahir Rahmanir Rahim***///
///**Author Thasin Sheikh**///
/*    #include <regex>
    ...
    std::string string("hello $name");
    string = std::regex_replace(string, std::regex("\\$name"), "Somename");
    */
#include<bits/stdc++.h>
using namespace std;
vector<int>primes;
#define MAX 35000
#define makefast__  ios_base::sync_with_stdio(false);
using ll=long long int  ;
using dl =double;
ll aarray[100000+10];
ll magic[501][501];
ll ar[200000+10];
ll vi[40000+10];
ll  a,b;
int main()
{
    makefast__
    string ptr,str;
    ll m1,m2,m3,m4,i,j,n,k,m5,l,m,r,ta,t,ans,flag,g,nmpo=INT_MAX,hariken=INT_MAX;
    ll w1,w2,w3,w4,w5;
    vector<ll>dvi;
    bool primes[1000007];
    memset(primes,true,sizeof(primes));
    primes[0]=primes[1]=false;
    set<ll>sl;
    for(i=2; i<=100001; i++)
    {
        if(primes[i])
        {
            for(j=i; i*j<=1000001; j++)
            {
                primes[i*j]=false;
            }
        }
    }
    cin>>n;
    if(primes[n]){
        cout<<n<<endl;
    return 0;}
    for(i=n+1;;i++)
    {
        if(primes[i])
        {
            cout<<i<<endl;
            return 0;
        }
    }


}


Measured memory_bytes: 1280
from itertools import accumulate
S=[int(i) for i in input()]

N=len(S)
sac=[0]+list(accumulate(S))
ans=0

for i in range(N):
  ans+=int(sac[i]*2**(i-1)+2**i*S[i]) * 10**(N-1-i)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
ll a[100001];
ll b[100001];
ll c[100001];
ll memo[100001][4];
ll findans(ll i,ll flag)
{
    if(i==n)
    {
        return 0;
    }
    
    if(memo[i][flag]!=-1)
    {
        return memo[i][flag];
    }
    ll ans1=0,ans2=0,ans3=0;
    if(flag!=0)
    {
       // cout<<a[i]<<'\n';
        ans1=a[i]+findans(i+1,0);
    }
    if(flag!=1)
    {
        ans2=b[i]+findans(i+1,1);
    }
    if(flag!=2)
    {
        ans3=c[i]+findans(i+1,2);
    }
    //ans2=abs(h[i]-h[i+2])+findans(h,i+2,n);
    return memo[i][flag]=max(ans1,max(ans2,ans3));
}
int main(){
    // Your code here!
    
    cin>>n;
    
    for(ll i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    for(ll i=0;i<=100000;i++)
    {
        for(ll j=0;j<4;j++)
        {
        memo[i][j]=-1;
        }
    }
    //cout<<a[0]<<b[0]<<c[0]<<'\n';
    cout<<findans(0,3);
    
    
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define P push
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    FAST();
    ll int n,m,res=1000;
    cin>>n;

    n=n%res;  if(n==0)n=res;

    cout<<res-n<<endl;


}



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

int main() {
  int s;
  
  cin >> s;
  int s_1;
  int d_1;
  int s_2;
  int s_3;
  s_1 = s/100;
  d_1 = s%100;
  s_2 = d_1/10;
  s_3 = s%10;
  

  cout << s_1 + s_2 + s_3 <<endl;
  
}

Measured memory_bytes: 256