akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

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

    static class AtA {
        private final FastScanner in;
        private final PrintWriter out;

        public AtA(FastScanner in, PrintWriter out) {
            this.in = in;
            this.out = out;
        }

        public void solve(int testNumber) throws IOException {
            char[] a = in.next().toCharArray();
            int ans = a.length;

            int s = 0;
            for (int i = 0; i < a.length; i++) {
                if (a[i] == 'T') {
                    if (s > 0) {
                        s--;
                        ans -= 2;
                    } else {
                        s = 0;
                    }
                } else {
                    s++;
                }
            }

            out.println(ans);
        }

    }

    static class FastScanner {
        private final static int BUFFER_SIZE = 4096;
        private final InputStream in;
        private final StringBuilder sb = new StringBuilder();
        private byte[] buffer = new byte[BUFFER_SIZE];
        private int pos = 0;
        private int size;

        public FastScanner(InputStream inputStream) throws IOException {
            in = inputStream;
            size = 0;
        }

        public String next() {
            int c = skipWhitespace();
            if (c == -1) {
                return null;
            }

            sb.setLength(0);

            do {
                sb.append((char) c);
                c = read();
            } while (c > ' ');

            return sb.toString();
        }

        private int skipWhitespace() {
            while (true) {
                int c = read();
                if (c > ' ' || c == -1) {
                    return c;
                }
            }
        }

        private int read() {
            if (pos >= size) {
                try {
                    size = in.read(buffer, 0, BUFFER_SIZE);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (size <= 0) {
                    return -1;
                }
                pos = 0;
            }
            return buffer[pos++];
        }

    }
}



Measured memory_bytes: 10580
#include <iostream>
#include <algorithm>
#include <vector>
#define INF 1e9+7
using namespace std;
typedef long long int ll;

int main() {

	int N = 0;
	int ans = 0;
	cin >> N;

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		ans += a - 1;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [0]*n
k = [0]*n

for i in range(0,n):
  a[i] = input().split()
  k[i] = a[i][0]
  del a[i][0]
c = [0]*m

for i in range(0,n):
  for j in range(0,int(k[i])):
    c[int(a[i][j])-1] += 1
k = 0
for i in range(0,m):
  if(c[i] == n):
    k += 1
    
print(k)

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());

        if (n == 0 || n % 2 != 0)
        {
            Console.WriteLine(0);
            return;
        }

        var k = 0L;
        for (long s = 10; s <= n; s *= 5)
        {
            k += n / s;
        }
        Console.WriteLine(k);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
int vis[max_n],tot;
vector<int> stk;
int n;
vector<int> G[max_n];
vector<int> cycle;
void dfs(int u){
    stk.push_back(u);
    vis[u]=tot;
    for(auto v:G[u]){
        if(!vis[v])dfs(v);
        else if(vis[v]==tot){
            while(1){
                int x=stk.back();stk.pop_back();
                cycle.push_back(x);
                if(x==v)break;
            }
            return;
        }
    }
    if(!stk.empty())stk.pop_back();
}
int sg[max_n];
int SG(int u){
    if(~sg[u])return sg[u];
    set<int> s;
    for(auto v:G[u])if(!vis[v])s.insert(SG(v));
    for(int i=0;;i++)if(s.count(i)==0)return sg[u]=i;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int x;scanf("%d",&x);
        G[x].push_back(i);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            ++tot;
            dfs(i);
        }
    }
    reverse(cycle.begin(),cycle.end());
    if(cycle.empty())printf("POSSIBLE\n");
    else{
        for(int i=1;i<=n;i++)vis[i]=0;
        for(int i=1;i<=n;i++)sg[i]=-1;
        for(auto x:cycle)vis[x]=1;
        for(auto &x:cycle)x=SG(x);
        bool f=false;
        for(int t=0;t<2;t++){
            int pre=cycle.back()+t;
            for(auto x:cycle){
                if(pre==x)pre=x+1;
                else pre=x;
            }
            f|=pre==cycle.back()+t;
        }
        if(f)printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 23540
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

#define lp(n) for(int i=0;i<n;i++)
#define LP(n,i) for(int i=0;i<n;i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483637
#define llmax 9223372036854775807
typedef long long ll;

using namespace std;


ll gcd(ll x,ll y){
	if(y==0)return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	ll g=gcd(x,y);
	return x/g*y;
}

int main(){
	string s;
	cin>>s;
	if(s[0]=='A'&&s[1]!='C'){
		int ccnt=0;
		for(int i=2;i<s.size()-1;i++){
			if(s[i]=='C'){
				ccnt++;
			}
		}
		if(ccnt!=1)cout<<"WA"<<endl;
		else{
			for(int i=1;i<s.size();i++){
				if(s[i]!='C'&&'A'<=s[i]&&s[i]<='Z'){
					cout<<"WA"<<endl;
					return 0;
				}
			}
			cout<<"AC"<<endl;	
		}	
	}
	else cout<<"WA"<<endl; 
	return 0;
}


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

#define int long long

#define f first
#define s second

const int INF = (int)1e9;

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

  
  while(true){
    int N, M;
    bool flag = false;
    int minimum = INF;
    int ans = INF;
    int HP_MAX = 0;
    vector<int> HP;
    vector<pair<int,int>> ms, ma;
    vector<int> dps, dpa;
    
    cin>>N;
    
    if(!N) break;

    HP.resize(N);
    
    for(int i = 0; i < N; i++){
      cin>>HP[i];
      HP_MAX = max(HP[i]+10, HP_MAX);
    }

    cin>>M;

    int hoge = 0;
    for(int i = 0; i < M; i++){
      string Name, Target;
      int MP, Damage;

      cin>>Name>>MP>>Target>>Damage;

      if(Target == "All"){
        ma.push_back(make_pair(MP, Damage));
      } else {
        ms.push_back(make_pair(MP, Damage));
      }
      
      if(MP == 0 && Damage > 0){
        flag = true;
      }

      hoge = max(hoge, Damage+10);
    }

    // HP_MAX = max(HP_MAX, hoge);
    
    dpa.resize(HP_MAX, INF);
    dps.resize(HP_MAX, INF);

    dpa[0] = 0;
    dps[0] = 0;

    
    for(int i = 0; i < ms.size(); i++){
      for(int j = 0; j < HP_MAX; j++){
        if(dps[j] < INF){
          if(j+ms[i].s < HP_MAX){
            dps[j+ms[i].s] = min(dps[j+ms[i].s], dps[j] + ms[i].f);
          } else {
            dps[HP_MAX-1] = min(dps[HP_MAX-1], dps[j] + ms[i].f);
          }
        }
      }
    }
    
    for(int i = 0; i < ma.size(); i++){
      for(int j = 0; j < HP_MAX; j++){
        if(dpa[j] < INF){
          if(j+ma[i].s < HP_MAX){
            dpa[j+ma[i].s] = min(dpa[j+ma[i].s], dpa[j] + ma[i].f);
          } else {
            dpa[HP_MAX-1] = min(dpa[HP_MAX-1], dpa[j] + ma[i].f);
          }
        }
      }
    }
    
    for(int i = HP_MAX-1; i > 0; i--){
      dpa[i-1] = min(dpa[i-1], dpa[i]);
      dps[i-1] = min(dps[i-1], dps[i]);
      
    }

    
    for(int i = 0; i < HP_MAX; i++){
      if(dpa[i] >= INF) continue;
      int hoge = dpa[i];
      for(int j = 0; j < N; j++){
        int num = max(0ll, HP[j] - i);

        hoge += dps[num];
      }
      
      ans = min(ans, hoge);
    }

    if(flag) ans = 0;

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



Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll n, k;
  cin >> n >> k;
  double ans = 0;

  repI(i, 1, n+1) {
    ll tmp = i;
    double p = 1;
    while(tmp <= k-1) {
      tmp *= 2;
      p /= 2;
    }

    ans += p;
  }

  ans /= n;
  printf("%.9f\n", ans);
  // cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {

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

	cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end());
	return 0;
}

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

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;
void solve(void)
{
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<stdbool.h>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<set>
#include<string>
#include<stdlib.h>
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(),s.end());
	if (s == "abc")cout << "Yes" << endl;
	else cout << "No\n";

	return 0;

}
	

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

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int ab=0, bb=0;
    rep(i, n){
        if(s.at(i)=='a' & ab < a+b){
            cout << "Yes" << endl;
            ab+=1;
        }
        else if(s.at(i)=='b' & bb < b & ab < a+b){
            cout << "Yes" << endl;
            bb+=1;
            ab+=1;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
dp = [[0] * 200005 for _ in range(2)]

n = int(input())
s = [1 if c=='.' else 0 for c in input()]

dp[s[0]][0] = 0
dp[s[0]^1][0] = 1

for i, c in enumerate(s[1:]):
    dp[1][i+1] = dp[1][i] + (c^1)
    dp[0][i+1] = min(dp[0][i], dp[1][i]) + c

print(min(dp[0][n-1], dp[1][n-1]))


Measured memory_bytes: 22240
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A=0;
  int B=0;
  int C=0;
  cin >> A;
  cin >> B;
  
if(A > 9 || B > 9)
{
  cout << -1 << endl;
}
else
 {
    cout << A*B << endl; 
 }

}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int w, a, b; cin >> w >> a >> b;
    cout << max({0, b - a - w, a - b - w}) << endl;
    return 0;
}


Measured memory_bytes: 256
void main() {
	auto ip = readAs!(long[]), A = ip[0], B = ip[1], K = ip[2];
	void solve() {
		if(K >= A) {
			K -= A;
			A = 0;
		} else {
			A -= K;
			return;
		}
		//writefln("%d %d %d", A, B, K);

		if(K >= B) {
			B = 0;
			return;
		} else {
			B -= K;
			return;
		}
	}
	solve();
	writefln("%d %d", A, B);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll R, G;

signed main()
{
    cin >> R >> G;
    printf("%lld\n", 2 * G - R);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
long long GCD(long long a,long long b)
{
    if(a==0&&b==0)
        return 0;
    if(a==0) return 1;
    if(b==0) return a;
    else return GCD(b,a%b);
}
int main()
{
    long long x,y;
    while(cin>>x>>y)
    {
        long long ans1=GCD(x,y);
        long long ans2=(x*y)/ans1;
        cout<<ans1<<" "<<ans2<<"\n";
    }
	return 0;
}

Measured memory_bytes: 1156
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];
    
    vector<ll> accum1(n+1), accum2(m+1);
    IFOR(i, 1, n){
        accum1[i] = accum1[i-1] + a[i-1];
    }
    IFOR(i, 1, m){
        accum2[i] = accum2[i-1] + b[i-1];
    }

    int ans = 0;
    IFOR(i, 0, n){
        int rest = k - accum1[i];
        auto pos = upper_bound(accum2.begin(), accum2.end(), rest);
        if(pos == accum2.begin())
            continue;
        int j = distance(accum2.begin(), pos);
        ll tm = accum1[i] + accum2[j-1];
        if(tm <= k){
            ans = max(ans, i+j-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9120
def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

DIV = (10**9) +7

def make1d_arr(n,val=INF):
    return [val for i in xrange(n)]

def make2d_arr(w,h,val =INF):
    return [[val for i in xrange(w)]for i in xrange(h)]


N = int_raw()

dp = [0]*(N+1)
dp_a = [0]*(N+1)
dp_g = [0]*(N+1)

dp[0] = 1
dp[1] = 4
dp[2] = 16
dp[3] = 61

#dp_ng[3]=3

dp_a[1]=1
dp_a[2]=4
dp_a[3]=16

dp_g[1]=1
dp_g[2]=4
dp_g[3]=15

#dp_t[1]=1
#dp_t[2]=4
#dp_t[3]=16


for i in xrange(4,N+1):
    dp_a[i] = dp[i-1] %DIV
    dp_g[i] = (dp[i-1] - dp[i-3] + dp_g[i-3]) %DIV
    dp [i] = (dp[i-1] + dp_a[i] + dp_g[i] + dp[i-1] - dp_a[i-3]*3 -dp_a[i-2]  - dp_g[i-2]  )%DIV

print dp[N]



Measured memory_bytes: 2696
// Problem : B - Golden Coins
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { if (a < 0) {a += mod;} if (b < 0) {b += mod;} return (a % mod + mod - b % mod) % mod;  }

#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << " | ";
	err(++it, args...);
}

const ll inf = 1e18;
const int nax = 1e5 + 5;

int main()
{
	speedup_IO;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		ll x;
		cin>>x;
		
		ll ans = 0;
		ans += (x/500)*1000;
		
		ans += ((x%500)/5)*5;
		cout<<ans;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int N = 1e5 + 2;
const int M = 1e3 + 5;
const int Mod = 1e9 + 7;

int n, m, q, a[N], b[N], c[N], d[N];
ll ans;
int t[N];

void Try(int cur,int pre)
{
	if (cur > n)
	{
		ll score = 0;
		for (int i = 0; i < q; i++)
			if (t[b[i]] - t[a[i]] == c[i])
				score += d[i];
		ans = max(ans, score);
		return;
	}
	for (int i = pre; i <= m; i++)
		t[cur] = i,Try(cur + 1, i);
}

int main()
{
	GO;
	cin >> n >> m >> q;
	for (int i = 0; i < q; i++)
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	Try(1, 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
import copy
M = []
H,W,K = map(int, input().split())  
for i in range(H):
    M.append(list(input()))

ans=0

for i in range(2 ** H):
    CM = copy.deepcopy(M)
    for j in range(H):  
        if ((i >> j) & 1):  
            for k in range(W):
                CM[j][k] = '.'
    for l in range(2 ** W):
        CCM = copy.deepcopy(CM)
        for m in range(W):
            if ((l >> m) & 1):
                for n in range(H):
                    CCM[n][m]='.'
        cnt = 0
        for n in range(H):
            for m in range (W):
                if CCM[n][m] == '#':
                    cnt += 1
        if cnt == K:
            ans+=1

print(ans)

Measured memory_bytes: 71896
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#define Pll make_pair
using namespace std;
typedef long long ll;
const int MAXN=1e5+50;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int phi=1e9+6;
string a,b,x;
int main()
{
    cin>>a>>b;
    int n,m;
    cin>>n>>m;
    cin>>x;
    if(x==a){
        printf("%d %d\n",n-1,m);
    }
    else
    {
        printf("%d %d\n",n,m-1);
    }
    return 0;
}
/*

 */

Measured memory_bytes: 256
n,h = gets.chomp.split(" ").map(&:to_i)
attack = []
n.times do
  attack << gets.chomp.split(" ").map(&:to_i)
end

# 普通に攻撃するなら振る攻撃力が高いものを使うのが吉．
# 投げつけるなら，投げつける攻撃力が高いものから順に投げつけるのが吉．

# 何度か殴って，順番に投げる
# 攻撃回数を最小にしたい．
# 何個まで投げるか：k
# 目標値から投げる分引いた分だけ殴る
#   0 ≦ k ≦ N を全部試す

attack.sort_by!{|atk| atk[1]}.reverse!
swing_max = attack.max_by{|atk| atk[0]}[0]
ans = h / swing_max + 1

(n+1).times do |k|

  # k個投げる
  if k > 0
    h -= attack[k-1][1]
  end

  # 殴る回数
  cnt = 0
  if h > 0
    cnt = (h+swing_max-1)/swing_max
  end

  ans = [ans,cnt+k].min
end

puts ans

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

int main() {
  ll N; cin >> N;
  vector<ll> A(N);
  map<ll, ll> MAP;
  for (int i = 0; i <= 1e5; i++) {
    MAP[i] = 0;
  }
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    MAP[A[i]] ++;
    sum += A[i];
  }
  ll Q; cin >> Q;
  vector<ll> ans(Q);
  for (int i = 0; i < Q; i++) {
    ll a, b;
    cin >> a >> b;
    ll x = a*MAP[a];
    ll y = b*MAP[a];
    MAP[b] += MAP[a];
    MAP[a] = 0; 
    ans[i] = sum-x+y;
    sum -= x;
    sum += y;
  }
  for (int i = 0; i < Q; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 11176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
vector<int> d(101);

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

  int i;
  set<int> s;
  for(i=0;i<N;i++){
    cin>>d[i];
    s.insert(d[i]);
  }
  int ans=s.size();

  cout<<ans<<endl;

}


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

int main(void){
    int n;//�}���b�N�֐��Ŏ󂯎���Ă��
    char s[100];
    int i;//����p
    int no_of_red=0;
    int no_of_blue=0;
    scanf("%d",&n);
   // s=malloc(sizeof(char)*n);
    scanf("%s",s);
    for(i=0;i<n;i++){
        if(s[i]=='R')
        no_of_red++;
        else
        {
            no_of_blue++;
        }
        
    }
  //  printf("�����܂ł͂�����\n");
/*for(i=0;i<n;i++){
    printf("%c",s[i]);
}*/
    if(no_of_red>no_of_blue)
    printf("Yes");
    else
    printf("No");
    system("pause");
    return 0;
}







Measured memory_bytes: 376
import math
import copy
x,y = map(int, input().split())
m = 1000000007

if (x+y)%3!=0:
    print(0)
    exit()


step = (x+y)//3

step_x = (step+abs(x-y))//2
step_y = (step-abs(x-y))//2

if (step_y<0):
    print(0)
    exit()
    
def com(n,r,m):
    #a = math.factorial(n)%m
    a = 1
    for i in range(1,n+1):
        a *= i
        a %= m
    A = pow(a,m-2,m)
    
    
    b= copy.deepcopy(A)   
    for i in range(n,r,-1):
        b = (b*i)%m
    
    c = copy.deepcopy(A)
    for i in range(n,n-r,-1):
        c = (c*i)%m
       
    return (a*b*c)%m
    
    
print(int(com(step_x+step_y,step_x,m)))

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

int main() {
    int N, K;
    cin >> N >> K;
    int l[55];
    rep(i, N) { cin >> l[i]; }
    sort(l, l + N);
    reverse(l, l + N);
    int total = 0;
    rep(i, K) { total += l[i]; }
    cout << total << endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
    int n;
    cout << fixed << setprecision(8);
    while (cin >> n, n) {
        double sum = 0, Sum = 0, s;
        for (int i = n; i--;) {
            cin >> s;
            sum += s;
            Sum += s * s;
        }
        cout << sqrt(Sum / n - pow(sum / n, 2)) << endl;
    }

    return 0;
}


Measured memory_bytes: 3236
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
#define LATTE 1000000000

const int d[2][2]={{0,1},{-1,0}};

int main(){
	int num[200][200];
	char c;
	int w[200]={},dp[200][200]={};
	for(int i=0;;i++){
		int latte=0;
		for(int j=0;;){
			int r = scanf("%c",&c);
			if(r==EOF) goto NEXT;
			if(c==',' || c=='\n'){
				num[i][j] = latte;
				latte = 0;
				w[i] = ++j;
				if(c=='\n') break;
			}
			else{
				latte = latte*10+(c-'0');
			}
		}//puts("");
	}
	NEXT:
	dp[0][0] = num[0][0];
	for(int i=0;;i++){
		if(w[i+1]==0){
			printf("%d\n",dp[i][0]); break;
		}
		for(int j=0;j<w[i];j++){
			int latte;
			if(w[i]<w[i+1]) latte=0;
			else latte=1;
			for(int k=0;k<2;k++){
				if(j+d[latte][k]<0 || w[i+1]<=j+d[latte][k]) continue;
				dp[i+1][j+d[latte][k]] = max(dp[i+1][j+d[latte][k]],dp[i][j]+num[i+1][j+d[latte][k]]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1380
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static short[][] d;
	static final short INF = Short.MAX_VALUE;

	public static void main(String[] args) {

		PrintWriter out = new PrintWriter(System.out);
		Scanner scan = new Scanner(System.in);
		short n = scan.nextShort();
		d = new short[n][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = i!=j ? INF : 0;
			}
		}
		for (int i = 0; i < n; i++) {
			short id = scan.nextShort();
			short c = scan.nextShort();
			for (int j = 0; j < c; j++) {
				d[id-1][scan.nextShort()-1]=1;
			}
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					d[i][j] = (short)Math.min(d[i][j], d[i][k]+d[k][j]);
				}
			}
		}

		int p = scan.nextInt();
		for (int i = 0; i < p; i++) {
			short s = scan.nextShort();
			short g = scan.nextShort();
			short ttl = scan.nextShort();
			out.println(ttl<=d[s-1][g-1] || d[s-1][g-1]==INF ? "NA" : d[s-1][g-1]+1);
		}
		out.flush();
	}
}

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

using namespace std;

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

  int n; 
  cin >> n;
  vector<int> L(n);
  int sum = 0;
  for (auto &l : L) {
    cin >> l;
    sum += l;
  }
  sort(L.begin(), L.end());
  cout << (2*L[n-1] < sum ? "Yes" : "No") << endl;

  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

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

    cin.ignore();
    set<char> st;
    rep(i,n){
        char x;
        cin>>x;
        st.insert(x);
    }
    
    if(st.size()==4)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




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

    for (int i = x; i <= 100003; i++){
       
        for (int j = 2; j <=i; j++) {
            if (j == i) {
                cout << j << endl;
                return 0;
            }
            if (i % j == 0)break;
            
        }
    }
}


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

#define o(output) cout << output << endl

using namespace std;

string s,t,u;
int a,b,c,d;
char A,B;
priority_queue<int,vector<int>,greater<int> >small;

int main(){
  cin>>a>>b>>c;
  small.push(a);
  small.push(b);
  small.push(c);
  a=small.top();
  small.pop();
  b=small.top();
  small.pop();
  c=small.top();
  if(a+b==c)o("Yes");
  else o("No");
}

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> a(H);
  
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }
  
  // 1行目
  for (int i = 0; i < W + 2; i++)
    cout << '#';
  cout << endl;
  
  for (int i = 0; i < H; i++) {
    cout << '#';
    
    cout << a.at(i);
    
    cout << '#' << endl;
  }
  
  // 最後の行
  for (int i = 0; i < W + 2; i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int x = scan.nextInt();
		List<Integer> a = new ArrayList<>();
		for(int i=0;i<m;i++) {
			a.add(scan.nextInt());
		}
//System.out.println(a);
		//xからnへ行くとき
		//int[]east =new int[n-x];
		int countEast = 0;
		for(int i=x;i<=n;i++) {
			if(a.contains(i)) {
				countEast++;
			}
		}
//System.out.println(countEast);
		int countWest = 0;
		for(int i=x;i>=0;i--) {
			if(a.contains(i)) {
				countWest++;
			}
		}
		//System.out.println(countWest);
		System.out.println(Math.min(countEast, countWest));
	}

}


Measured memory_bytes: 21716
function Main(inp) {
    var input = inp.split('\n')[0].split(' ').map(function(n) {
        return Number(n);
    });
    var count = 0;
    for(var i = 0; i <= 100; i++) {
        var onA = false, onB = false;
        if (input[0] <= i && i < input[1]) {
            onA = true;
        }
        if (input[2] <= i && i < input[3]) {
            onB = true;
        }
        if (onA && onB) {
            count += 1;
        }
    }
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
  int n, i, cnt;
  string str, ans;
  char init;
  vector<string> mp{"", ".,!? ","abc","def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  cin >> n;
  while(n--){
    cin >> str;
    ans = "";
    i = 0;
    while(i < str.length()){
      while(str[i] == '0'){
        i++;
      }
      if(i >= str.length()){
        break;
      }
      init = str[i];
      cnt = 0;
      while(i < str.length() and str[i] == init){
        i++;
        cnt++;
      }
      ans += mp[init - '0'][(cnt - 1) % mp[init - '0'].length()];
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, n = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++) {
      int a = i / 10000;
      int b = (i % 10000) / 1000;

      int d = (i % 100) / 10;
      int e = i % 10;
      if (a == e && b == d)
        n++;
    }
    cout << n << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N;
string S;

int main(){
  cin >> N >> S;
  deque<char> dq;
  int cnt = 0;
  REP(i, S.size()){
    if(S[i] == '('){
      cnt++;
      dq.push_back('(');
    }
    else if(S[i] == ')' && cnt){
      dq.push_back(')');
      cnt--;
    }
    else{
      dq.push_front('(');
      dq.push_back(')');
    }
  }
  REP(i, cnt){
    dq.push_back(')');
  }
  for(auto c : dq){
    cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>=13)
	cout<<b;
	else if(a>=6&&a<=12)
	cout<<b/2;
	else if(a<=5)
	cout<<0;
	return 0;
}

Measured memory_bytes: 256
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long
int N;
vector<int> C,D;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  C.resize(N);
  D.resize(N + 1);
  REP(i,N){
  	int a;
  	cin >> a;
  	a--;
  	C[a]++;
  	D[C[a]]++;
  }
  vector<int> S;
  S.resize(N+1);

  for(int i = 1; i < N+1; i++){
  	S[i] = S[i-1] + D[i];
  }

  for(int K = 1; K <= N; K++){
  	int ok = 0; int ng = N+1;
  	while(ng - ok > 1){
  		int mid = (ng + ok)/2;
  		if(S[mid] >= K * mid){
  			ok = mid;
  		}
  		else{
  			ng = mid;
  		}
  	}

  	cout << ok << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
int main() {
	ll n;
	cin>>n;
	map<ll,ll>ch;
	ll a[200010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
		ch[-1*a[i]]++;
	}
	for(ll i=0;i<n;i++){
		auto itr=ch.begin();
		if(a[i]*-1==itr->first){
			if(itr->second==1){
				itr++;
			}
		}
		cout <<abs(itr->first)<<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 12468
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};

const int NPrime=3000000;
bool prime[NPrime+1];
vi EnumeratePrime(){
	fill(prime+2,prime+NPrime+1,true);
	vi a;
	for(int i=2;i<=NPrime;i++) if(prime[i]){
		a.emplace_back(i);
		for(int j=2*i;j<=NPrime;j+=i) prime[j]=0;
	}
	return a;
}

int f(string s){
	reverse(s.begin(),s.end());
	int n=s.size(),res=0;
	for(int i=0;i<n;i++){
		if(isalpha(s[i])){
			int t=1;
			if(s[i]=='x') t=10;
			if(s[i]=='c') t=100;
			if(s[i]=='m') t=1000;
			if(i+1<n&&isdigit(s[i+1])){
				t*=s[i+1]-'0';
			}
			res+=t;
		}
	}
	return  res;
}

string g(int n){
	string s,t="ixcm";
	int I=0;
	while(n){
		if(n%10!=0){
			s+=t[I];
			if(n%10>1) s+=(char)('0'+n%10);
		}
		I++;
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}

int n;
string s,t;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>t;
		cout<<g(f(s)+f(t))<<endl;
	}
}


Measured memory_bytes: 3212
n, l = map(int, input().split())
sumA = 0
index = 0
while index < n:
    sumA+=index
    index+=1
if l <= 0 <= l+n-1:
    print(sumA+n*l)
else:
    if l > 0:
        print(sumA+n*l-l)
    else:
        print(sumA+n*l-l-n+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++) //(i, 0, n)でi=0~n-1までn回
#define REPn(i, a, n) for(int i=a; i<=n; i++) //(i, 1, n)でi=1~nまでn回
#define sortv(v) sort(v.begin(), v.end());
#define sortg(v) sort(v.begin(), v.end(), greater<>());
#define rev(v) reverse(v.begin(), v.end()); //逆順に並べ替え

int main() {
  int R, G, B, n, cnt=0;
  cin >> R >> G >> B >> n;
  REP(r, 0, 1+n/R){
    REP(g, 0, 1+(n-R*r)/G){
      if((n-R*r-G*g)%B==0 && (n-R*r-G*g)>=0)cnt++;
    }
  }
  cout << cnt << endl;        
}


Measured memory_bytes: 256
l = input()
mod = 10**9 + 7
r = 0
one = 0

for i in range(0, len(l)):
    if l[i] == "1":
        r = (r + pow(2, one, mod) * pow(3, len(l) - i - 1, mod)) % mod
        one += 1

r = (r + pow(2, one, mod)) % mod

print(r)

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    vector<int> a(5);
    for (int i = 0; i < 5; i++) cin >> a[i];
    int maxE = 0;
    int tmp = a[0] % 10;
    for (int i = 0; i < 5; i++) {
        int r = a[i] % 10;
        if (r == 0) continue;
        if (r < tmp) {
            maxE = i;
            tmp = r;
        }
    }
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        if (i == maxE) ans += a[i];
        else ans += ceil((double)a[i] / 10) * 10;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
using namespace std;
 
signed main() {
	int d, n;
	cin >> d >> n;
	if (n == 100) n++;
	if (d == 0) cout << n << endl;
	else if (d == 1) cout << 100 * n << endl;
	else cout << 10000 * n << endl;
	return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
using namespace std;
int N, M, arr[100005], parent[100005], result;

int find(int node)
{
    if(node == parent[node])
    {
        return node;
    }
    return parent[node] = find(parent[node]);
}

void uni(int node1, int node2)
{
    int p1, p2;
    p1 = find(node1);
    p2 = find(node2);
    if(p1 != p2)
    {
        parent[p2] = p1;
    }
}

int main()
{
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= N; i++)
    {
        parent[i] = i;
        scanf("%d", &arr[i]);
    }
    for(int i = 0; i < M; i++)
    {
        int x, y;
        scanf("%d %d", &x, &y);
        uni(x, y);
    }
    for(int i = 1; i <= N; i++)
    {
        if(find(i) == find(arr[i]) || arr[i] == i)
        {
            result++;
        }
    }
    printf("%d", result);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int x,y,s;
    while(cin>>x>>y>>s,x|y|s){
        int mx=0;
        FOR(i,1,1001)FOR(j,1,1001){
            if(i*(100+x)/100+j*(100+x)/100==s){
                mx=max(mx,i*(100+y)/100+j*(100+y)/100);
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
# Problem https://atcoder.jp/contests/abc081/tasks/abc081_b
# Ruby 2nd Try
N = STDIN.gets.chomp
A = STDIN.gets.chomp.split(' ').map(&:to_i)
oddFlag = false
answer = 0
while true
    A.length.times do |j|
        modNumber = A[j] % 2
        if modNumber == 1
            oddFlag = true            
        end
    end 
    if oddFlag
        break
    end
    A.length.times do |j|
        A[j] = A[j] / 2
    end
    answer = answer+1
end
puts(answer)

Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
using namespace std;


int main(void){
  char a[100001];
  int i,n;

  scanf("%s",a);

  n = strlen(a);

  for(i=0;i<n;i++){
    if(i%2==0)
      printf("%c",a[i]);
  }
  printf("\n");

  return 0;
}


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

int main() {
	const int N = 10;
	int data[N];
	int tmp;

	for (int i = 0;i<N;i++) cin >> data[i];
	for (int i = 1;i <= 3;i++) {
		for (int j = 0;j<N - i;j++) {
			if (data[j]>data[j + 1]) {
				tmp = data[j];
				data[j] = data[j + 1];
				data[j + 1] = tmp;
			}
		}
	}
	cout << data[N - 1] << endl << data[N - 2] << endl << data[N - 3] << endl;

	return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 5005;

int n;

class Participant{
public:
	int h, p;
	bool operator < (const Participant &oth)const{ return MP(h + p, -h) < MP(oth.h + oth.p, -oth.h); }
}a[maxn];

ll dp[maxn][maxn];

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		scanf("%d%d", &a[i].h, &a[i].p);
	}
	sort(a, a + n);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	FOR(i, 0, n) REP(j, 0, n) if(dp[i][j] != INF){
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		if(dp[i][j] <= a[i].h)
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + a[i].p);
	}
	for(int j = n; j >= 0; --j) if(dp[n][j] != INF){
		printf("%d\n", j);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b;
  cin>>n;
  cout<<(n*(n-1))/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  if(a==b) cout << "EQUAL" << endl;
  else if(a.size()>b.size()) cout << "GREATER" << endl;
  else if(a.size()<b.size()) cout << "LESS" << endl;
  else{
    if(a>b) cout << "GREATER" << endl;
    else cout << "LESS" << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n, k = list(map(int, input().split()))
    x = list(map(int, input().split()))
    ans = float('inf')

    for i in range(n - k + 1):
        left = x[i]
        right = x[i + k - 1]

        if left * right >= 0:
            ans = min(ans, max(abs(left), abs(right)))
        else:
            ans = min(ans, 2 * abs(left) + abs(right), abs(left) + 2 * abs(right))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int stoi (string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}


// 配列の総和
// greater


ll dp[101][101010]={};

int main(){	
	// ll A;
    // cin >> A;
	// cout << "hello" << endl;
	// cout << stoi("14") << endl;
	// cout << max({1,3}) << endl;

	ll N;
	cin >> N;
	ll L[N];
	rep(i, N)cin >> L[i];
	ll ma = *max_element(L, L+N);
	ll mi = -ma;
	rep(i, N)mi += L[i];
	cout << (ma < mi ? "Yes" : "No") << endl;

}








Measured memory_bytes: 256
//
// Created by TakahiroYamaji on 2020/07/29.
//
#include<iostream>
#include<algorithm>
typedef long long ll;
ll X, Y;
int main(){
    std::cin >> X >> Y;
    ll res = 0;
    while (X <= Y){
        X = 2 * X;
        res++;
    }
    std::cout << res << std::endl;
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>

using namespace std;

//??\???
#define MAX_N 100000
#define MAX_M 100000
int N,M;
int s[MAX_N];
int a[MAX_M];

int main() {
  ios::sync_with_stdio(false);

  cin >> N >> M;

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

  for(int i = 0; i < M; i++) {
    cin >> a[i];
  }

  int cs[N];
  cs[0] = 0;
  for(int i = 1; i < N; i++) {
    cs[i] = cs[i-1] + s[i-1];
  }

  long long dis = 0;
  int cur = 0;
  for(int i = 0; i < M; i++) {
    assert(cur + a[i] >= 0);
    dis += abs( cs[cur + a[i]] - cs[cur] );
    cur = cur + a[i];
  }
  // cout <<  dis << "\n";
  cout << dis%100000 << "\n";
  return 0;
}

Measured memory_bytes: 4404