akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

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

typedef pair<int, int> PII;

int h, w;
char maps[1000][1001];
int cnt[1000][1000];
queue<pair<PII, int> > qu;

bool check(int x, int y) {
	return x >= 0 && x < w && y >= 0 && y < h;
}

int main() {
	cin >> h >> w;
	REP(i, h) cin >> maps[i];
	
	REP(i, h) REP(j, h) {
		if (maps[i][j] == '.') {
			cnt[i][j] = 0;
			qu.push(MP(MP(i, j), 0));
		}
		else {
			cnt[i][j] = maps[i][j] - '0';
		}
	}

	int ans = 0;
	while (!qu.empty()) {
		pair<PII, int> now = qu.front(); qu.pop();
		PII pos = now.first;	//y, x
		ans = max(ans, now.second);
		
		int dx[] = { 1, 1, 1, 0, -1, -1, -1, 0 };
		int dy[] = { 1, 0, -1, -1, -1, 0, 1, 1 };
		REP(i, 8) {
			int nx = pos.second + dx[i], ny = pos.first + dy[i];
			if (!check(nx, ny) || cnt[ny][nx] <= 0) continue;
			cnt[ny][nx]--;
			if (cnt[ny][nx] == 0) qu.push(MP(MP(ny, nx), now.second + 1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6380
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const ll OO = 1e18+7;
const int MOD = 1e9+7;
const int N = 4e2+7;

int n;
int a[N];
ll dp[N][N];
ll pref[N];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);


    cin >> n;
    REP(i,0,n-1) {cin >> a[i];}
     pref[0] = a[0];
    REP(i,1,n-1) pref[i] = pref[i-1]+a[i];



    REP(len,1,n-1)
    {
        REP(l,0,n-1)
        {
            int r = l+len;
            if (r > n-1) break;
            dp[l][r] = OO;
            REP(i,l,r-1)
            {
                ll tmp = dp[l][i] + dp[i+1][r];
                if (l != 0) tmp += pref[r]-pref[l-1];
                else tmp += pref[r];
                dp[l][r] = min(dp[l][r],tmp);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}


Measured memory_bytes: 1536
// https://atcoder.jp/contests/abc178/tasks/abc178_f

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  cin >> N;

  VL as(N);
  rep(i, N) cin >> as[i];

  VL bs(N);
  rep(i, N) cin >> bs[i];

  auto print_and_exit = [&]() {
    cout << "Yes"
         << "\n";

    rep(i, N) {
      if (i > 0) cout << " ";
      cout << bs[i];
    }
    cout << "\n";
    throw exit_exception();
  };

  reverse(all(bs));

  // 逆順ソートすれば、被っている要素はたかだか一種類となり、範囲となる
  // [same_l, same_r) で被っているとする
  ll same_l = -1;
  ll same_r = -1;

  rep(i, N) {
    if (as[i] == bs[i] && same_l == -1) {
      same_l = i;
    }

    if (as[i] != bs[i] && same_l != -1) {
      same_r = i;
      break;
    }
  }

  if (same_l == -1) print_and_exit();
  if (same_r == -1) same_r = same_l + 1;

  ll ni = same_l;

  rep(i, N) {
    if (ni == same_r) break;
    if (same_l <= i && i < same_r) continue;

    if (as[i] != bs[ni] && bs[i] != as[ni]) {
      swap(bs[i], bs[ni++]);
    }
  }

  if (ni < same_r) drop("No");

  print_and_exit();
}


Measured memory_bytes: 6348
use std::io;

// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

fn solve(n : i64, ly : i64) -> (i64, i64, i64) {
    for x in 0..n+1 {
        for y in 0..n-x+1 {
            let z = n - x - y;
            if x * 10000 + y * 5000 + z * 1000 == ly {
                return (x, y, z)
            }
        }
    }
    return (-1, -1, -1)
}

fn main(){
    let v = read_t_in_line::<i32>();
    let n = v[0] as i64;
    let ly = v[1] as i64;
    let (a, b, c) = solve(n, ly);
    println!("{} {} {}", a, b, c);
}


Measured memory_bytes: 4352
// inputに入力データ全体が入る
  function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
  var K = Number(tmp[0]);
  var N = Number(tmp[1]);
	//文字列から10進数に変換するときはparseIntを使います
  tmp = input[1].split(" ");
  for(i=0; i<tmp.length; i++){
    tmp[i] = Number(tmp[i]);
  }


  var max = 0;
  for (var i = 1; i < tmp.length; i++) {
    dis = tmp[i] - tmp[i-1];
    if(dis > max) max = dis;
  }
  dis = K - (tmp[tmp.length-1] - tmp[0]);
  if(dis > max) max = dis;
	//出力
	console.log('%d', K-max);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
	int n,k;
	string s;
	cin >> n;
	cin >> s;
	if(s.size() > n){
		for(int i = 0; i < n; i++){
			cout << s[i];
		}
		cout << "...\n";
	}else{
		cout << s << "\n";
	}

}


Measured memory_bytes: 3632
//
// Created by yamunaku on 2019/08/17.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    string s;
    cin >> s;
    int n=s.size();
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    int ans=n;
    int pre=0;
    int sz=1;
    repl(i,1,n){
        if(sz==1&&s[pre]==s[i]){
            pre=i;
            i++;
            sz=2;
            ans--;
        }else{
            pre=i;
            sz=1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] S = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.ReadLine();
            int[] T = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int cnt = 0;

            foreach (var t in T)
            {
                foreach (var s in S)
                {
                    if (s == t)
                    {
                        cnt++;
                        break;
                    }
                }
            }

            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 19636
n,m = map(int, input().split())
ac  = [0]*n
wa = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if ac[p-1]>0:
        continue
    else:
        if s=="AC":
            ac[p-1] = 1
        else:
            wa[p-1] +=1
ans = 0
for i in range(n):
    if ac[i]>0:
        ans += wa[i]
    else:
        continue
print(sum(ac),ans)

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

int main() {
  int a[1000];
  int n;
  string ans = "APPROVED";
  cin >> n;

  rep(i,n) {
    cin >> a[i];
    if(a[i]%2 == 0) {
      if(a[i]%3 == 0 || a[i]%5 == 0) {
        ans = "APPROVED";
      } else {
        ans = "DENIED";
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  ll coc[2];
  int K;
  cin >> coc[0] >> coc[1] >> K;
  for (int i = 0; i < K; i ++) {
    int j = i % 2;
    int k = (j + 1) % 2;
    coc[j] /= 2;
    coc[k] += coc[j];
  }
  cout << coc[0] << ' ' << coc[1] << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
int main(){int n,m;while(scanf("%d",&n),n){m=0;n=1000-n;m+=n/500;n%=500;m+=n/100;n%=100;m+=n/50;n%=50;m+=n/10;n%=10;m+=n/5;n%=5;printf("%d\n",m+n);}}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int N,M;
	cin >> N >> M;
	vector<bool> answer(M);
	for(int i = 0;i < M;i++) {
		answer.at(i) = true;
	}
	for(int i = 0;i < N;i++) {
		int K;
		cin >> K;
		vector<int> vec(K);
		for(int j = 0;j < K;j++) {
			cin >> vec.at(j);
		}
		for(int j = 1;j < M + 1;j++) {
			bool A = false;
			for(int k = 0;k < K;k++) {
				if(vec.at(k) == j) {
					A = true;
				}
			}
			if(A == false) {
				answer.at(j - 1) = false;
			}
		}
	}
	int ans = 0;
	for(int i = 0;i < M;i++) {
		if(answer.at(i) == true) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i=0,j,k=0,l,p=0,q=0,x=0,y=0,m,n;
    cin>>n;
    int b[n]={0};
    while(n--){
        string a;
        cin>>a;
        if(a[0]=='A') p++;
        else if(a[0]=='W') q++;
        else if(a[0]=='T') x++;
        else y++;
    }
    cout<<"AC x "<<p<<endl;
    cout<<"WA x "<<q<<endl;
    cout<<"TLE x "<<x<<endl;
    cout<<"RE x "<<y<<endl;
    return 0;
}


Measured memory_bytes: 3980
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

int main() {
	int O, F;
	cin >> O >> F;
	if (O >= 13)
		cout << F << endl;
	else if (O <= 5)
		cout << F * 0 << endl;
	else 
		cout << F / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		String str = sc.next();
		String[] array = str.split("");

		String before = "";
		int smcount = 0;
		int grcount = 0;
		long ans = 0;

		for (int i = 0; i < array.length; i++) {

			String tmp = array[i];

			if (tmp.equals("<")) {
				if (before.equals(array[i])) {
					smcount++;
				} else {
					long sum = getArraySum(grcount, smcount);
					ans = ans + sum;
					smcount = 1;
					grcount = 0;
				}

				before = array[i];

			} else {
				if (before.equals(array[i])) {
					grcount++;
				} else {
					grcount = 1;
				}
				before = array[i];

			}
		}
		long sum = getArraySum(grcount, smcount);
		ans = ans + sum;
		System.out.println(ans);

	}

	private static long getArraySum(int a, int b) {
		long large = a > b ? a : b;
		long small = a < b ? a : b;

		small--;

		long lsum = large * (large + 1) / 2;
		long ssum = small * (small + 1) / 2;

		long sum = lsum + ssum;

		return sum;

	}

}


Measured memory_bytes: 68784
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int vs[2000+10];

int main(void) {
  int n;
  cin >> n;
  REP(i, n) {
    cin >> vs[i];
  }
  sort(vs, vs + n);
  ll res = 0;
  REP(i, n) {
    int a = vs[i];
    REP(j, i) {
      int b = vs[j];
      // a < b + c
      // b < c + a
      // abs(a-b) < c < a + b
      int *it1 = lower_bound(vs, vs + j, a+b);
      int *it2 = upper_bound(vs, vs + j, abs(a-b));
      res += max(0, (int)(it1 - it2));
    }
  }
  
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
import math as ma

a,b,h,m = map(int,input().split())

al = 360 * (h + m /60) /12
bl = m*6
rad = ma.radians(min(abs(bl - al), 360 - abs(bl - al)))
r = ma.sqrt(a**2 + b**2 -2*a*b*ma.cos(rad))
print(r)


Measured memory_bytes: 9392
#include<bits/stdc++.h>
using namespace std;
#define pu push_back
#define fi first
#define se second
#define mp make_pair
#define int long long
#define sz 200005
int dp[110][102000];
signed main()
{
	
	int n,p;
	cin>>n>>p;
	
	int P[n+5];
	int W[n+5];
	
	for(int i=1;i<=n;i++)
	{
		cin>>W[i]>>P[i];
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=1;j<=100000;j++)
		{
			dp[i][j]=1e9+7;
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=100000;j++)
		{
			dp[i][j]=min(dp[i][j],dp[i-1][j]);
			if(j>=P[i]) dp[i][j]=min(dp[i][j],dp[i-1][j-P[i]]+W[i]);
			if(dp[i][j]<=p)ans=max(ans,j);
		}
	}
	
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 82176
#include<cstdio>
using namespace std;
int N;
double A[105],Ans;
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	scanf("%lf",&A[i]);
	for(int i=1;i<=N;i++)
	Ans+=1.0/A[i];
	Ans=1.0/Ans;
	printf("%lf",Ans);
	return 0;
}

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


int main()
{
    std::string s,tmp_s;
    std::cin>>s;
    int cnt_1=0,cnt_2=0;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]=='1')cnt_1++;
        else cnt_2++;
    }
    std::cout<<std::min(cnt_1,cnt_2)*2<<std::endl;
    
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
  static int a, b, c, d, e, f;
  static final boolean DEBUG = false;

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

    a = sc.nextInt();
    b = sc.nextInt();
    c = sc.nextInt();
    d = sc.nextInt();
    e = sc.nextInt();
    f = sc.nextInt();

    int amount = 100 * a, sum = 0;
    double prob = -1;
    for(int i = 0; i * (100 * a) <= f; i++){
      for(int j = 0; i * (100 * a) + j * (100 * b) <= f; j++){
        int water = i * (100 * a) + j * (100 * b);
        for(int k = 0; k * c + water <= f; k++){
          int r = f - (k * c + water);
          int low = 0, high = r / d + 1;
          while(high - low > 1){
            int mid = (low + high) / 2;
            int s = k * c + mid * d;
            if(water + s <= f && 
                s * 100 <= e * water){
              low = mid;
            }
            else{
              high = mid;
            }
          }
          int sugar = k * c + low * d;
          if((water == 0 && sugar == 0) ||
              water + sugar > f ||
              sugar * 100 > e * water){
            continue;
          }
          double p = (double)(sugar) / (double)((water + sugar));
          if(prob < p){
            prob = p;
            amount = sugar + water;
            sum = sugar;
          }
          if(DEBUG){
            System.out.println("water = " + water + " sugar = " + sugar);
            System.out.println("amount = " + (water + sugar));
            System.out.println(i + " " + j + " " + k + " " + low);
          }
        }
      }
    }

    System.out.println(amount + " " + sum);
  }
}


Measured memory_bytes: 22996
import java.util.*;

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

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int K = scanner.nextInt();

        int sum = 0;

        while(0 < A && 0 < K) {
            sum++;
            A--;
            K--;
        }

        while(0 < B && 0 < K) {
            B--;
            K--;
        }

        while(0 < C && 0 < K) {
            sum--;
            C--;
            K--;
        }

        System.out.println(sum);


        
        
    }
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
using P = pair<pi,int>;

bool cmp(const pi &lh, const pi &rh){
    return lh.fi*rh.se < rh.fi*lh.se;
}

int main(){
    int h,w;
    cin >>h >>w;
    vector<string> f(h);
    rep(i,h) cin >>f[i];

    // find corners
    /*
    .. #. ## .#
    .# .. #. ##
    */
    map<string,int> mp;
    mp["...#"] = -1;
    mp["#..."] = 1;
    mp["###."] = -1;
    mp[".###"] = 1;

    auto field = [&](int y, int x){
        if(0<=y && y<h && 0<=x && x<w) return f[y][x];
        return '.';
    };

    auto corner = [&](int y, int x){
        string pat = "";
        rep(i,2)rep(j,2){
            pat += field(h-1-y+i, x-1+j);
        }

        if(mp.count(pat)) return mp[pat];
        return 0;
    };

    vector<P> c;
    vector<pi> v;
    for(int i=0; i<=h; ++i){
        for(int j=0; j<=w; ++j){
            int cc = corner(i,j);
            if(cc != 0){
                int g = __gcd(i,j);
                c.pb({{i/g, j/g}, cc});
                v.pb({i/g, j/g});
            }
        }
    }

    sort(all(v), cmp);
    v.erase(unique(all(v)), v.end());
    int V = v.size();
    map<pi,int> idx;
    rep(i,V) idx[v[i]] = i;

    vector<vector<int>> Q(V);
    for(const auto &p:c){
        Q[idx[p.fi]].pb(p.se);
    }

    int ans = 1;
    int cur = 1;
    rep(i,V){
        for(int j:Q[i]) cur += j;
        ans = max(ans, cur);
    }

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



Measured memory_bytes: 12812
#coding : utf-8

N,Y = [int(i) for i in input().split()]
flag = 0

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j) and flag == 0:
            print(i,j,N-i-j)
            flag = 1
            break
if flag == 0:
    print(-1,-1,-1)

Measured memory_bytes: 3060
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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

VB isPrime(2000, true);

void calc_prime(ll N) {
  isPrime[1] = false;

  NREP(i, N) {
    if (isPrime[i]) {
      ll j = 2;

      while (true) {
        if (i * j <= N) {
          isPrime[i * j] = false;
          j++;
        } else {
          break;
        }
      }
    }
  }

  return;
}

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

  ll N;
  cin >> N;
  calc_prime(N);

  ll ans = 1;

  NREP(i, N) {
    if (isPrime[i]) {
      ll Ncp = N, divnum = 0;

      while (Ncp > 0) {
        Ncp /= i;
        divnum += Ncp;
      }

      ans *= divnum + 1;
      ans %= MOD;
    }
  }

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

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

int main(){

  string str;
  int ans = 0,i;

  while(cin >> str){
    int t = 0;

    for(i=0;i<str.size()/2;i++){
      if(str[i] == str[str.size()-i-1]) t++;
    }

    if(t == i) ans++;
  }

  cout << ans << endl;
}

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

signed main(){
  lint N; cin >> N;
  lint t, ans = N;
  for(lint i = 0; i <= N; i++){
    lint ans1 = 0;
    t = i;
    while(t > 0){
      ans1 += t % 6;
      t /= 6;
    }
    t = N - i;
    while(t > 0){
      ans1 += t % 9;
      t /= 9;
    }
    ans = min(ans, ans1);
  }
  cout << ans << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  long long d, a;
  cin >> n >> d >> a;
  vector< pair<int, long long> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  int i = 0, j = 0;
  long long ans = 0;
  vector<long long> cnt(n + 1, 0);
  for (; i < n; i++) {
    while (j < n && v[j].first - v[i].first <= 2 * d) {
      j++;
    }
    j--;
    int tmp = max(0ll, (v[i].second - cnt[i] * a + a - 1) / a);
    ans += tmp;
    cnt[i] += tmp;
    cnt[i + 1] += cnt[i];
    cnt[j + 1] -= tmp;
  }
  cout << ans << '\n';
  return 0;
} 

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

typedef long long ll;
typedef long double ld;

ll dp[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, w;
    cin >> n >> w;
    ll res = 0;
    for(int i=1; i<=n; i++){
        int a, b;
        cin >> a >> b;
        for(int j=w; j>=a; j--){
            dp[j] = max(dp[j], b + dp[j-a]);
            res = max(res, dp[j]);
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1024
# B
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
ans = "War"
Xmax = max(x)
Ymin = min(y)
# print("X",X)
# print("Y",Y)
# print("Xmax",Xmax)
# print("Ymin",Ymin)
# 1
if Xmax < Ymin:
    ans = "No War"
print(ans)

Measured memory_bytes: 3064
n,k = (int(x) for x in input().split())
a_list=[]
for i in range(k):
    d=int(input())
    a=list(map(int, input().strip().split()))
    a_list.extend(a)
#print(a_list)
count=0

for i in range(1,n+1):
    if i in a_list:
        pass
    else:
        count+=1
print(count)


Measured memory_bytes: 9124
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for ( int i=0;i<n;i++)cin>>a[i];
	int b[n];
	b[0]=0;
	b[1]=abs(a[1]-a[0]);
	for( int i=2;i<n;i++){
		b[i]=min(b[i-1]+abs(a[i]-a[i-1]), b[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<b[n-1];
}

Measured memory_bytes: 4388
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 1; i <= 9; i++){
			if(n <= 111*i){
				System.out.println(111*i);
				return;
			}
		}
	}

}


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

using std::cout;
using std::endl;
using std::vector;
using std::cin;
using std::string;
int main() {
	string s,p;
	string::size_type flag = false;	// 2??±??????????????????????????????????????°
	int count = 0;		// ??????????????°??????????????°?????????????????????????????°

	// ??\???
	cin >> s >> p;
	s += s;	// ????????????2?????°??????????????¨??§????????°??¨??????
	
	flag = s.find(p);	// ????????????????????????????????????????????????????????????????????????
	if (flag==string::npos) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
 int main()
 {
 	int a,b,c,d;
 	int n,m;
 	scanf("%d %d %d",&a,&b,&c);
 	if((a*b)>=c){
 		printf("%d",c);
	 }
	 else{
	 	printf("%d",a*b);
	 }
	 return 0;
  } 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S, T;
	cin >> S >> T;
	int ans = 0;
	for (int n = 0; n < S.size(); n++) {
		if (S[n] != T[n])ans++;
	}
	cout << ans << "\n";
	return 0;
}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  int a[n];
  int b[n];
  int balance = 0;
  REP(i,n) cin >> a[i];
  REP(i,n) {
    int tmp = in();
    int diff = tmp - a[i];
    if(diff > 0) balance += diff/2;
    else if(diff < 0) balance += diff;
  }
  
  if(balance >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}

int main(){
    int N,M;
    cin >> N >> M;
    vector<string> S(N,"WA");
    vector<int> WA(N,0);
    int ac = 0,wa = 0;
    rep(i,M){
        int p;
        string s;
        cin >> p >> s;
        if(S[p-1] == "WA"){
            if(s == "WA")WA[p-1]++;
            else S[p-1] = s,ac++,wa +=WA[p-1];
        }
    }
    cout << ac <<" "<< wa;
    return 0;
}

Measured memory_bytes: 6144
using System;

namespace AtCoder20190622
{
	class ProgramB
	{
		static void Main(string[] args)
		{
			var inputs = Console.ReadLine().Split(' ');
			var N = int.Parse(inputs[0]);
			var L = int.Parse(inputs[1]);
			B(N, L);
		}

		static void B(int N, int L)
		{
			int sum = 0;
			int minAbsTaste = int.MaxValue;
			int minAbsTasteActual = 0;
			for(int i = 1; i <= N; i++)
			{
				int taste = L + i - 1;
				sum += taste;

				int absTaste = Math.Abs(taste);
				if (absTaste < minAbsTaste)
				{
					minAbsTaste = absTaste;
					minAbsTasteActual = taste;
				}
			}
			sum -= minAbsTasteActual;
			Console.WriteLine(sum);
		}
	}
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
string str[13];
int used[10],num[101],n,flg[101];

int nxp(int idx,int i,int sum,int a){
 int res=0;
 if(sum<0||idx==n)return sum==0;
 if(i<0)return nxp(idx+1,str[idx+1].size()-1,sum,1);
 
 int f=idx? -1:1,ch=str[idx][i];
 if(num[ch]!=-1) res+=nxp(idx,i-1,sum+f*(a*num[ch]),a*10);
  else 
    for(int j=0;j<10;j++){
      if(used[j]||(!i&&!j&&str[idx].size()!=1)||(!j&&flg[ch]))continue;
	used[j]=1,num[ch]=j;
	res+=nxp(idx,i-1,sum+f*(a*j),a*10);
	used[j]=0,num[ch]=-1;
      }
    
  return res;
}
  
  
int main(){
  memset(num,-1,sizeof(num));
  while(cin>>n,n){
    memset(flg,0,sizeof(flg));
    for(int i=0;i<n;i++){
      cin>>str[i];
      if(str[i].size()!=1) flg[str[i][0]]=1;
    }
    swap(str[0],str[n-1]);
    cout <<nxp(0,str[0].size()-1,0,1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <utility>
#include <cassert>
using namespace std;

template<class value_type, class size_type = size_t>
class RunLengthArray {
	using T = value_type;
	using S = size_type;

	vector<T> value;
	vector<pair<S, S>> index; // [first, second)

	size_t find(S i) {
		int left = 0, right = value.size();
		while (right - left > 1) {
			int mid = left + (right - left) / 2;
			(index[mid].first <= i ? left : right) = mid;
		}
		return left;
	}

public:
	RunLengthArray() {}
	RunLengthArray(const T& val, S size) :value({ val }), index({ {0,size} }) {}
	RunLengthArray(const initializer_list<pair<S, T>>& v) {
		index.reserve(v.size());
		value.reserve(v.size());
		S now = 0;
		for (const auto& p : v) {
			index.emplace_back(now, now + p.first);
			value.push_back(p.second);
			now += p.first;
		}
	}
	S size()const { return empty() ? 0 : index.back().second; }
	bool empty()const { return value.empty() || index.empty(); }
	explicit operator bool()const { return !empty(); }

	const T& operator[](const S i)const {
		assert(i < size());
		return value[find(i)];
	}
	const T& front()const {
		assert(!empty());
		return value.front();
	}
	const T& back()const {
		assert(!empty());
		return value.back();
	}

	pair<T, S> at(const size_t i)const {
		return make_pair(value[i], index[i].second - index[i].first);
	}
	size_t value_size()const {
		return value.size();
	}

	void clear() { value.clear(); index.clear(); }
	RunLengthArray& push_back(const T& val, const S new_size = 1) {
		if (empty() || value.back() != val) {
			value.push_back(val);
			index.emplace_back(size(), size() + new_size);
		} else {
			index.back().second += new_size;
		}
		return *this;
	}
	RunLengthArray& pop_back(const S pop_size = 1) {
		assert(pop_size <= size());
		S until = size() - pop_size;
		while (!empty()) {
			if (index.back().first == until) {
				value.pop_back();
				index.pop_back();
				break;
			} else if (index.back().first <= until && until < index.back().second) {
				index.back().second = until;
				break;
			} else {
				value.pop_back();
				index.pop_back();
			}
		}
		return *this;
	}
};


using ll = long long;

bool increment(RunLengthArray<ll, ll>& v, ll k) {
	if (v.value_size() == 1 && v.front() == k - 1) {
		return false;
	}

	if (v.back() < k - 1) {
		ll val = v.back();
		v.pop_back().push_back(val + 1);
	} else {
		ll len = v.at(v.value_size() - 1).second;
		v.pop_back(len);
		ll val = v.back();
		v.pop_back().push_back(val + 1).push_back(0, len);
	}
	return true;
}

int main() {
	int n; cin >> n;
	vector<ll> a(n);
	for (ll& i : a)cin >> i;

	auto check = [&](ll k) {
		RunLengthArray<ll, ll> v;
		v.push_back(0, a[0]);
		for (int i = 1; i < n; ++i) {
			if (a[i - 1] < a[i]) {
				v.push_back(0, a[i] - a[i - 1]);
			} else {
				if (a[i - 1] > a[i]) {
					v.pop_back(a[i - 1] - a[i]);
				}
				if (!increment(v, k))return false;
			}
		}
		return true;
	};

	if (check(1)) {
		cout << 1 << endl;
		return 0;
	}
	ll ng = 1, ok = 1e9;
	while (ok - ng > 1) {
		ll mid = (ng + ok) / 2;
		(check(mid) ? ok : ng) = mid;
	}
	cout << ok << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int kei(int,int);

int A[8][8],a[8],b[8],c[8],d[8],n;

int main(){
	int i,j,r,v;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&r,&v);
		A[r][v]=1;
		a[i]=r;
		b[i]=v;
		c[i]=r-v;
		d[i]=r+v;
	}
	kei(0,0);
	for(i=0;i<8;i++){
		for(j=0;j<8;j++){
			if(A[i][j]==1)printf("Q");
			else printf(".");
		}
		printf("\n");
	}
	return 0;
}
int kei(int i,int j){
	int k,e=0;
	while(i<8){
		while(j<8){
		  	for(k=0;k<n;k++){
				if(a[k]==i || b[k]==j || c[k]==i-j || d[k]==i+j){
				    e++;
					break;
				}
			}
			if(e==0){
				a[n]=i;
				b[n]=j;
				c[n]=i-j;
				d[n]=i+j;
				A[i][j]=1;
				n++;
				if(kei(i,j)==0){
					A[i][j]=NULL;
					n--;
				}else return 1;
			}
			e=0;
			j++;
		}
		i++;
		j=0;
	}
	if(n!=8)return 0;
	else return 1;
}



Measured memory_bytes: 2084
/* #lev5 #Tree #DFS #Math */

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;
#define		it(x)  x.begin() 
#define		all(x)  x.begin(), x.end()
#define		pb(x)   push_back(x)
constexpr int           inf = 0x3f3f3f3f;
constexpr long long 	INF = 9123456789123456789;
constexpr long long     MOD = 1000000007LL;
/*************************************************/

const int MAXN = 200010, P = 1e9 + 7;
int n, x, y, _edge, _head[MAXN], _vertex[2 * MAXN], _next[2 * MAXN], _size[MAXN];
int f[MAXN]; // f[i] i를 루트로 트리를 만들었을 때, 순서가 강제되는만큼 반영. ans[i] = n! % f[i] 이 된다.

void add_edge(int x, int y) {
    _vertex[++_edge] = y;
    _next[_edge] = _head[x]; //처음엔 0, x가 바라보는 노드를 _next로 쭉 연결시킨다.
    _head[x] = _edge;
    return;
}

// fermat's theorm에서 등장하는 multiplicative inverse function.
int mul_inv_of(int _x) {
    int p = 1e9+5;
    ll x(_x), res(1);
    while (p) {
        if (p & 1) res = (res * x) % P;
        x = (x * x) % P;
        p >>= 1;
    }
    return int(res);
}

void dfs1(int x, int parent) {
    _size[x] = 1;
    for (int e = _head[x]; e; e = _next[e]) {
        if (_vertex[e] == parent) continue;
        dfs1(_vertex[e], x);
        _size[x] += _size[_vertex[e]];
    }
    f[1] = (1ll * f[1] * _size[x]) % P;
    return;
}

void dfs2(int x, int parent) {
    for (int e = _head[x]; e; e = _next[e]) {
        int y = _vertex[e];

        if (y == parent) continue;
        ll temp = 1ll * (n - _size[y]) * mul_inv_of(_size[y]) % P;
        f[y] = ( 1ll * f[x] * temp ) % P;
        dfs2(y, x);
    }
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cin.tie(nullptr);
    cin >> n;

    f[1] = 1;
    for (int i = 1; i <= n - 1; i++) {
        cin >> x >> y;
        add_edge(x, y), add_edge(y, x);
    }

    dfs1(1, 0);
    dfs2(1, 0);

    int tmp = 1;
    for (int i = 1; i <= n; i++) 
        tmp = (1ll * tmp * i) % P; // n! % mod

    for (int i = 1; i <= n; i++) 
        cout << (1ll * tmp * mul_inv_of(f[i]) ) % P 
             << '\n';

    return 0;
}


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

int main(){
    int N, X, L, tmp=0, ans=1, dis=0, minNum=1e9, sum=0;
    cin >> N >> L;
    vector<int> v(N);
    for(int i=0; i<N;i++ ){
	v[i] = L+i;
    }

    for(int i=0; i<N;i++ ){

	if(minNum >abs(v[i])){
	    minNum = abs(v[i]);
	    tmp = i;
	}
	sum+=v[i];
    }
    ans = sum -v[tmp];
    cout << ans<< endl;

}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		String line = "";

		try {
			scanner = new Scanner(System.in);
			line = scanner.next();

			System.out.println(line.replaceAll("2017", "2018"));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int n = 0;

		try {
			scanner = new Scanner(System.in);
			n = scanner.nextInt();
			int[] wk = new int[n];

			for (int i = 0; i < n; i++) {
				wk[i] = scanner.nextInt();
			}

			Arrays.sort(wk);

			int res = 0;
			for (int i = 0; i < wk.length; i++) {
				if (i == 0) {
					res++;
				} else if (wk[i] != wk[i - 1]) {
					res++;
				}

			}

			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e3 + 10;

int n, m, x[N], y[N], c[2];
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", x + i, y + i);
		c[(x[i] + y[i]) & 1]++;
	}
	if (c[0] && c[1]) return puts("-1"), 0;
	printf(c[0] ? "32\n1 " : "31\n");
	for (int i = 30; i >= 0; i--) printf("%d%c", 1 << i, " \n"[!i]);
	for (int i = 1; i <= n; i++) {
		if (c[0]) putchar('R'), x[i]--;
		for (int j = 30; j >= 0; j--)
			if (abs(x[i]) > abs(y[i])) {
				if (x[i] > 0)
					x[i] -= 1 << j, putchar('R');
				else
					x[i] += 1 << j, putchar('L');
			} else {
				if (y[i] > 0)
					y[i] -= 1 << j, putchar('U');
				else
					y[i] += 1 << j, putchar('D');
			}
		puts("");
	}
}


Measured memory_bytes: 256
n = gets.chomp.to_i
t0 = 1
a0 = 1
n.times do
  t1, a1 = gets.chomp.split(" ").map(&:to_i)
  dd = [t0.to_r / t1, a0.to_r / a1].max.ceil
  t0 = t1 * dd
  a0 = a1 * dd
end
puts t0 + a0

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

#define pb push_back

using namespace std;

const int MX = 10000001;

int n , a, x[MX + 1], visId, match[300], vis[300];
bool b[MX + 1], np[MX + 1];
vector<int> me, mo, g[300];

bool dfs(int u) {
	vis[u] = visId;
	for (int i = 0 ; i < g[u].size(); ++i) {
		int v = g[u][i];
		if (match[v] == -1 || vis[match[v]] != visId && dfs(match[v])) {
			match[v] = u;
			return true;
		}
	}
	return false;

}
int main() {
	for (int i = 2; i <= MX; ++i) {
		if (np[i])continue;
		for (int j = i + i; j <= MX ; j+=i){
			np[j] = 1;
		}
	}
	np[0] = np[1] = np[2] = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a);
		x[a] = 1;
	}
	for (int i = 1; i <= MX ; ++i) {
		b[i] = x[i] != x[i - 1];
		if (b[i] && (i % 2 == 0))me.pb(i);
		if (b[i] && (i % 2 == 1))mo.pb(i);
	}
	for (int i = 0; i < me.size(); ++i) {
		for (int j = 0 ; j < mo.size(); ++j) {
			if (!np[abs(me[i] - mo[j])]) {
				g[i].pb(j);
			}
		}
	}
	assert((me.size()+mo.size())%2 == 0);
	int res = 0;
	memset(match,-1,sizeof match);
	for (int i = 0; i < me.size(); ++i) {
		visId++;
		if (dfs(i))res++;
	}
	int even = me.size() - res;
	int odd = mo.size() - res;
	int ans = res + (even / 2) * 2 + (odd / 2) * 2 + (odd%2)*3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 57600
N,A,B = map(int, input().split())

H = [int(input()) for i in range(N)]

d = A-B

temp = max(H)
low = temp//A - 1
high = temp//B+1

while low + 1 < high:
  mid = (low+high)//2
  offset = mid*B
  cnt = -sum((offset-h)//d for h in H if h > offset)
  if cnt > mid:
    low = mid
  else:
    high = mid

print(high)

Measured memory_bytes: 7072
def main():
    time = []
    ans = 0
    min_time = 10
    for i in range(5):
        time.append(int(raw_input()))
    for i in time:
        if i%10 == 0:
            ans += i
        else:
            ans += ((i//10)+1)*10
            min_time =min(min_time,i%10)
    print(ans + min_time - 10)



if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
# -*- coding:utf-8 -*-
"""解説
dp

dp[i][j] := 先頭i文字として考えられるもののうち、13で割ったあまりがjであるものの数

1?2?3 を分解すると、
10000 ≡ 3
 A000 ≡ A*(10**3) % MOD ≡ A*12
  200 ≡ 5
   B0 ≡ B*(10**1) % MOD
    3 ≡ 3
    -----
        11 + ? ≡ 11 + A*12 + B*10

"""


def solve():
    S = input()
    MOD = 10**9+7

    N = len(S)
    dp = [[0 for i in range(13)] for j in range(10**5+1)]
    dp[0][0] = 1

    for i in range(0, N):
        if S[i] == "?":
            c = -1
        else:
            c = int(S[i])
        
        for j in range(0, 10):
            if c != -1 and c != j: continue
            
            for ki in range(0, 13):
                dp[i+1][(ki* 10 + j)%13] += dp[i][ki]
        
        for j in range(0, 13):
            dp[i+1][j] %= MOD

    res = dp[N][5]
    print(res)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 67164
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    ll mod = 1e9 + 7;
    ll fac = 1;
    for(int i = 1; i <= n; i++) {
        fac *= ll(i);
        fac %= mod;
    }
    cout << fac << endl;
    return 0;
}


Measured memory_bytes: 3464
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scanf("%d%d", &N, &M)
	sA := make([]int, N+1)
	q := map[int]int{}
	q[0]++
	for i := 0; i < N; i++ {
		var A int
		fmt.Scanf("%d", &A)
		sA[i+1] = (sA[i] + A) % M
		q[sA[i+1]]++
	}
	ans := 0
	/*
		for i := 0; i <= N; i++ {
			for j := 0; j < i; j++ {
				if sA[i]-sA[j] == 0 {
					ans++
				}
			}
		}
	*/
	for i := 0; i <= N; i++ {
		q[sA[i]]--
		//fmt.Printf("%d %d\n", sA[i], q[sA[i]])
		ans += q[sA[i]]
	}
	fmt.Printf("%d\n", ans)
}


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

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

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			int[] b = new int[n];
			int[] c = new int[n];
			int[] d = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
			}
			for (int i = 0; i < n; i++) {
				c[i] = in.nextInt();
				d[i] = in.nextInt();
			}
			boolean[][] g = new boolean[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i] < c[j] && b[i] < d[j]) {
						g[i][j] = true;
					}
				}
			}
			out.println(bipartiteMatching(g));
		}

		private int bipartiteMatching(boolean[][] g) {
			int n = g.length;
			if (n == 0) {
				return 0;
			}
			int m = g[0].length;
			boolean[] was = new boolean[n];
			int[] pair = new int[m];
			Arrays.fill(pair, -1);
			int res = 0;
			for (int i = 0; i < n; i++) {
				Arrays.fill(was, false);
				if (dfs(i, g, was, pair)) {
					++res;
				}
			}
			return res;
		}

		private boolean dfs(int i, boolean[][] g, boolean[] was, int[] pair) {
			if (was[i]) {
				return false;
			}
			was[i] = true;
			for (int j = 0; j < g[i].length; j++) {
				if (!g[i][j]) {
					continue;
				}
				if (pair[j] < 0 || dfs(pair[j], g, was, pair)) {
					pair[j] = i;
					return true;
				}
			}
			return false;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 21844
L1 = input().split(" ")
L2 = input().split(" ")
L3 = input().split(" ")
lis1 = list(map(int, L1))
lis2 = list(map(int, L2))
lis3 = list(map(int, L3))

if lis1[1] - lis1[0] == lis2[1] - lis2[0] == lis3[1] - lis3[0] and lis1[2] - lis1[0] == lis2[2] - lis2[0] == lis3[2] - lis3[0] and lis1[1] - lis1[2] == lis2[1] - lis2[2] == lis3[1] - lis3[2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <cmath>

using namespace std;

int main() {
    size_t h, a;
    cin >> h >> a;
    cout << h / a + (h % a == 0 ? 0 : 1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
typedef long long lint;

int main() {
    int N;
    cin >> N;
    vector<lint> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    lint ans = 0;
    for (int i = N-1; i >= 0; i--) {
        lint d = (A[i] + ans + B[i] - 1) / B[i];
        ans += d * B[i] - (A[i] + ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920