akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
IOS;
int n,x,t,k;
cin>>n>>x>>t;
k=n/x;
if(n%x!=0)k++;
cout<<t*k<<"\n";
}
/*sjleepy*/


Measured memory_bytes: 3636
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  SCIN(ss,tt);
  CIN(q);VC2(q,a,b,c,d);

  V sv,tv;
  sv.pb(0);
  tv.pb(0);
  REP(i,ss.size())
    sv.pb(sv[i]+(ss[i]=='A'?1:2));
  REP(i,tt.size())
    tv.pb(tv[i]+(tt[i]=='A'?1:2));


  REP(i,q){
    int sc=sv[b[i]]-sv[a[i]-1];
    int tc=tv[d[i]]-tv[c[i]-1];
    YES(sc%3 == tc%3);
  }
  
  return 0;
}


Measured memory_bytes: 5944
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)



int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", a*b);
	
	return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;

#define PI 3.14159265358979323846264338327950L

ll res;

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

    ll N,K;
    cin >> N >> K;
    res = K * pow(K - 1, N-1);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()
a_list = list(map(int, input().split()))
count = 0

a1 = a_list[0]

while a1 % 2 == 0:
    a1 /= 2
    count += 1

if count == 0:
    print(0)

else:
    for a in a_list:
        if a % (2 ** count) == 0:
            continue

        else:
            temp_count = 0
            while a % 2 == 0:
                a /= 2
                temp_count += 1

            count = temp_count
            if count == 0:
                break

    print(count)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;
using Graph = vector<vector<int>>;

signed _main(){
  int N,M; cin >> N >> M;
  v<int> ans(N);
  // グラフ
  Graph G(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);

    // 無向グラフの場合は以下を追加
    G[b].push_back(a);
  }

  // BFS のためのデータ構造
  vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
  queue<int> que;

  // 初期条件 (頂点 0 を初期ノードとする)
  dist[0] = 0;
  que.push(0); // 0 を橙色頂点にする

  // BFS 開始 (キューが空になるまで探索を行う)
  while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop();

    // v から辿れる頂点をすべて調べる
    for (int nv : G[v]) {
      if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
      // 新たな白色頂点 nv について距離情報を更新してキューに追加する
      dist[nv] = dist[v] + 1;

      que.push(nv);
    }
  }
  for(int i=1;i<N;i++){
    fore(j,G[i]){
      if(dist[j]==dist[i]-1){
        ans[i]=j;
        break;
      }
    }
  }
  Yes
  for(int i=1;i<N;i++){
    cout << ans[i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 13652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    if(n%1000==0) cout << 0 << endl;
    else 
    cout << 1000 - n%1000 << endl;
    return 0;
}


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

using namespace std;

template<class T> inline T sqr(const T& a) {
  return a * a;
}

template<class T> inline int len(const T &c) {
  return static_cast<int>(c.size());
}

typedef long long li;
const int N = 100100;

vector<int> g[N];
bool used[N];
int od[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  li single = 0;
  vector<li> o, e;
  for (int i = 0; i < n; ++i) {
    if (used[i]) {
      continue;
    }
    if (g[i].empty()) {
      ++single;
      used[i] = true;
      continue;
    }
    int card = 1;
    bool odd = false;
    queue<int> q;
    q.push(i);
    od[i] = 0;
    used[i] = true;
    while (!q.empty()) {
      int fm = q.front();
      q.pop();
      int nod = 1 - od[fm];
      for (int to : g[fm]) {
        if (used[to]) {
          if (nod != od[to]) {
            odd = true;
          }
        } else {
          ++card;
          q.push(to);
          od[to] = nod;
          used[to] = true;
        }
      }
    }
    if (odd) {
      o.push_back(card);
    } else {
      e.push_back(card);
    }
  }

  printf("%lld\n", sqr(single) + single * (n - single) * 2 + sqr<li>(len(o)) + sqr<li>(len(e)) * 2 + li(len(o)) * li(len(e)) * 2);
  return 0;
}


Measured memory_bytes: 7424
import sys
import collections
input = sys.stdin.readline
N = int(input())
tree = [[] for _ in range(N+1)]
tree_cost = [1000000001 for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])
Q, K = map(int, input().split())

queue = collections.deque()
queue.append([K, 0])
tree_cost[K] = 0
while len(queue) > 0:
    now = queue.popleft()
    for next in tree[now[0]]:
        if tree_cost[next[0]] == 1000000001:
            queue.append(next)
            tree_cost[next[0]] = tree_cost[now[0]] + next[1]

for _ in range(Q):
    x, y = map(int, input().split())
    print(tree_cost[x]+tree_cost[y])


Measured memory_bytes: 81968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
          ll n,c=0;
          set<ll>s;
          for(ll i=0;i<3;i++)
          {
                    cin>>n;
                    s.insert(n);
          }
          if(s.size()==2)
                    cout<<"Yes";
          else cout<<"No";
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
 
int main()
{
    int n, left, right, res;
    string buf;
    while (cin >> n, n) {
        left = right = res = 0;
        for (int i = 0; i < n; i++) {
            cin >> buf;
            if (buf == "lu") {
                left = 1;
            } else if(buf == "ld"){
                left = 0;
            } else if(buf == "ru"){
                right = 1;
            } else {
                right = 0;
            }
            if ((res % 2 == 0 && left == 1 && right == 1) || (res % 2 == 1 && left == 0 && right == 0))
                res++;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

//  COMMAND TO USE WHEN RUNNING CODE: g++ day1.cpp -o day1 -std=c++11 -O2  | to run: ./(name of file)  //

int N, M, a;
long long b;
priority_queue<int> PQ;

int main() {
    cin >> N >> M;
    for ( int i=0; i<N; i++ ) {
        cin >> a;
        PQ.push(a);
    }
    for ( int i=0; i<M; i++ ) {
        b = PQ.top();
        b /= 2;
        PQ.pop();
        PQ.push(b);
    }
    b = 0;
    for ( int i=0; i<N; i++ ) {
        b += PQ.top();
        PQ.pop();
    }
    cout << b << "\n";
}

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n;
    scanf("%d",&n);
    int *p;
	p=(int*)malloc((n+1)*sizeof(int));
    int i;
    for(i=1;i<=n;i++){
    scanf("%d",&p[i]);
    }
    int count=0;
    for(i=2;i<n;i++){
        if(p[i-1]<p[i]&&p[i]<p[i+1] ){
            count++;
        }
        else if(p[i+1]<p[i]&&p[i]<p[i-1]){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a)-1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a)-1; (i) >= (b); (i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<< C <<endl;
#define VI vector <int>
#define VII vector <VI>
#define VL vector <LL>
#define VLL vector <VL>
#define VD vector <double>
#define VDD vector <VD>
#define PII pair <int, int>
#define PDD pair <double, double>
#define PLL pair <LL, LL>
#define VPII vector <PII>
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF = 1e9;
const int MOD = INF + 7;

const int MAX = 1e5 + 10;
#define int LL
int H, W, N;
int a[MAX], b[MAX];
int ans[10];

bool inside(int h, int w) {
    bool res = true;
    if (h < 0 || h >= H - 2) res = false;
    if (w < 0 || w >= W - 2) res = false;
    return res;
}

signed main(void) {
    scanf("%d %d %d", &H, &W, &N);
    ans[0] = (H - 2) * (W - 2);
    map <PII, int> mp;
    REP (i, N) {
	scanf("%d %d", &a[i], &b[i]);
	a[i]--; b[i]--;
	REP (j, 3) REP (k, 3) {
	    PII p = MP(a[i] - j, b[i] - k);
	    mp[p]++;
	}
    }
    FORE(el, mp) {
	int h = el.first.first;
	int w = el.first.second;
	if(!inside(h, w)) continue;
	//cout << h << " " << w << endl;
	ans[el.second]++;
    }
    FOR (i, 1, 10) {
	ans[0] -= ans[i];
    }
    REP (i, 10) {
	cout << ans[i] << endl;
    }
}


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

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

ll p,q,r,n,m,ans;
char b;
string s,t;

int main(){
  ios::sync_with_stdio(false);
  cin>>p>>q>>r;
  ans=q/r-p/r;
  if(p%r==0)dump(ans+1);
  else dump(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define int ll
#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

void solve() {
    int n;
    cin>>n;
    int curr = 0;
    f(i, n) {
        int d1, d2;
        cin>>d1>>d2;
        if(d1 == d2) {
            curr++;
        } else curr = 0;
        if(curr == 3) {
            cout<<"Yes\n";
            return;
        }

    }
    cout<<"No\n";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int t = 1;
    //cin>>t;
    for(int test = 1; test <= t; test++) {
        //cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3596
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
ans = 0
for hn in range(2**H):
    hp = list("{:0>{}b}".format(hn,H))
    for wn in range(2**W):
        wp = list("{:0>{}b}".format(wn,W))
        kuronum = 0
        for hc in range(H):
            if hp[hc] == "1":
                continue
            for wc in range(W):
                if wp[wc] == "0" and c[hc][wc] == "#":
                    kuronum += 1
        if kuronum == K:
            ans += 1
print(ans)

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

int main() {
  string X, Y;
  cin >> X >> Y;

  if ( X > Y ) {
    cout << ">" << endl;
  }
  
  else if ( X < Y ) {
    cout << "<" << endl;
  }
  
  else {
    cout << "=" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[55];
vector<P> ans;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint mn = 0, mx = 0;
	for(int i = 1; i <= n; i++){
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	
	if(mx >= -mn){
		int p;
		for(int i = 1; i <= n; i++){
			if(a[i] == mx){
				p = i;
				break;
			}
		}
		for(int i = 1; i <= n; i++){
			if(a[i] < 0) ans.push_back(P(p, i));
		}
		for(int i = 1; i < n; i++) ans.push_back(P(i, i+1));
	}
	else{
		int p;
		for(int i = 1; i <= n; i++){
			if(a[i] == mn){
				p = i;
				break;
			}
		}
		for(int i = 1; i <= n; i++){
			if(a[i] > 0) ans.push_back(P(p, i));
		}
		for(int i = n; i > 1; i--) ans.push_back(P(i, i-1));
	}
	
	cout << ans.size() << endl;
	for(int i = 0; i < ans.size(); i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;

	for(int i=a;i<c;i++) cout<<'R';
	for(int i=b;i<d;i++) cout<<'U';
	for(int i=c;i>a;i--) cout<<'L';
	for(int i=d;i>b;i--) cout<<'D';

	a--;
	d++;
	cout<<'L';

	for(int i=b;i<d;i++) cout<<'U';
	for(int i=a;i<c;i++) cout<<'R';
	cout<<'D';

	a++;
	d--;
	b--;
	c++;
	cout<<'R';

	for(int i=d;i>b;i--) cout<<'D';
	for(int i=c;i>a;i--) cout<<'L';

	cout<<'U'<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s.length()==2){
    cout<<s<<endl;
  }
  else{
    cout<<s[2];
    cout<<s[1];
    cout<<s[0]<<endl;
  }
}

Measured memory_bytes: 256
li = [int(i) for i in input().split()]

x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
x.append(li[2])
y.append(li[3])

x.sort()
y.sort()
if((int(x[-1])) <int(y[0])):
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <cassert>
#include <cstring>
#include <algorithm>
#define meow(args...) fprintf(stderr, args)

typedef std::pair<int, int> pair;
struct Element {
	int l, r;
	pair v;
	bool operator<(const Element &o) const {return l<o.l;}
};

const int N=2e5;

int n, l, x[N];
pair y[N];

template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
int read() {
	int a=0;
	unsigned char c;
	while((c=getchar()-'0')>9);
	while(a=a*10+c, (c=getchar()-'0')<=9);
	return a;
}
long long calc(std::vector<pair> jar) {
	int len=jar.size();
	long long ans=0, lsum=0;
	for(int i=l-1; i<len; ++i) {
		lsum+=jar[i-l+1].first;
		ans+=lsum*jar[i].second;
	}
	return ans;
}
int main() {
	n=read(), l=read();
	std::generate(x, x+n, read);
	for(int i=0; i<n; ++i) y[i]=pair(x[i], i);
	std::sort(y, y+n);

	int m=0;
	pair *pos=y;
	long long ans=n;
	std::vector<Element> a, b;
	while(true) {
		if(a.empty()) {
			if(pos==y+n) break;
			m=pos->first;
		} else ++m;
		for(; pos->first==m; ++pos) a.push_back({pos->second, pos->second+1, pair(1, 1)});
		std::sort(a.begin(), a.end());
		b.clear();
		for(int i=0, j=0; i<a.size(); i=j) {
			while(++j<a.size()&&a[j-1].r==a[j].l);
			int len=j-i, cnt=len/l;
			if(cnt!=0) {
				std::vector<pair> cur, val(cnt);
				for(int k=i; k<j; ++k) cur.push_back(a[k].v);
				for(int k=i; k<j; ++k) {
					int tl=k-i+1, tr=j-k;
					if(tl>=l) val[tl/l-1].second+=a[k].v.second;
					if(tr>=l) val[cnt-tr/l].first+=a[k].v.first;
				}
				ans+=calc(cur)-calc(val);
				for(int k=0; k<cnt; ++k) b.push_back({a[i].l+k, a[i].l+k+1, val[k]});
				b.back().r=a[j-1].r;
			}
		}
		a=b;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 10860
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "math"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextFloatVec() []float64 {
  L := strings.Split(NextLine(), " ")
  N := make([]float64, len(L))
  for i := range N {
    N[i], _ = strconv.ParseFloat(L[i], 64)
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func MaxFloat(x, y float64) float64 {
  if x < y { return y }
  return x
}
func Dist02(A *[]float64) float64 {
  x, y := (*A)[0], (*A)[1]
  return x * x + y * y
}
func InnerProduct(A, B *[]float64) float64 {
  return (*A)[0] * (*B)[0] + (*A)[1] * (*B)[1]
}
func Angle(A, B *[]float64) float64 {
  acos := math.Acos(InnerProduct(A, B) / math.Sqrt(Dist02(A)) / math.Sqrt(Dist02(B)))
  return acos / math.Pi * 180.0
}

type Engines [][]float64
func (E Engines) Len() int { return len(E) }
func (E Engines) Less(i, j int) bool { return E[i][2] < E[j][2] }
func (E Engines) Swap(i, j int) { E[i], E[j] = E[j], E[i] }

func main() {
  N := NextInt()
  E := make([][]float64, 0)
  X := []float64{1.0, 0.0}
  for i := 0; i < N; i++ {
    XY := NextFloatVec()
    if XY[0] != 0.0 || XY[1] != 0.0 {
      angle := Angle(&X, &XY)
      if XY[1] < 0 { angle = 360.0 - angle }
      XY = append(XY, angle)
      E = append(E, XY)
      E = append(E, []float64{0.0, 0.0, angle - 180.0})
      E = append(E, []float64{0.0, 0.0, angle + 180.0})
      E = append(E, []float64{XY[0], XY[1], angle + 360.0})
      E = append(E, []float64{0.0, 0.0, angle + 540.0})
    }
  }
  sort.Sort(Engines(E))
  ans := 0.0
  t := 0
  D := []float64{0.0, 0.0}
  for _, e := range E {
    if 360.0 <= e[2] { break }
    for E[t][2] - e[2] < 180.0 {
      D[0] += E[t][0]
      D[1] += E[t][1]
      t++
    }
    ans = MaxFloat(math.Sqrt(Dist02(&D)), ans)
    D[0] -= e[0]
    D[1] -= e[1]
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<set>
#include<vector>
#include<map>
#include<queue>

#define N 500005
#define M 8000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k,A[N],L[N],R[N],Q[N],B[N];

vector<pair<int,int> >v[N];

set<pair<int,int> >st; 

int main()
{	
		scanf("%d",&n); m=1<<n;
		for (i=0;i<m;++i) scanf("%d",&A[i]);
		for (i=m-1;i>=0;--i)
		{
				R[i]=m;
				if (A[i]) R[i]=A[i];
				for (j=0;j<n;++j)
						if ((i^(1<<j))>i) R[i]=min(R[i],R[i^(1<<j)]);
		}
		for (i=0;i<m;++i)
		{
				L[i]=1;
				if (A[i]) L[i]=A[i];
				for (j=0;j<n;++j)
						if ((i^(1<<j))<i) L[i]=max(L[i],L[i^(1<<j)]);		
		}
		for (i=0;i<m;++i) v[L[i]].pb(mk(R[i],i));
		for (i=1;i<=m;++i)
		{
				for (j=0;j<(int)v[i].size();++j) st.insert(v[i][j]);
				if (!st.size()||(*st.begin()).fi<i)
				{
						puts("NO");
						return 0;
				}
				A[(*st.begin()).se]=i;
				st.erase(st.begin());
		}
		puts("YES");
		Q[Q[0]=1]=0;
		for (i=0;i<n;++i)
		{
				for (j=1;j<=(1<<i);++j) Q[++Q[0]]=Q[j]+(1<<(n-1-i));
		}
		for (i=1;i<=m;++i) B[Q[i]]=A[i-1]; 
		for (i=0;i<m;++i) printf("%d ",B[i]);
}


Measured memory_bytes: 35056
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>

using namespace std;


int main()
{
	int n;
	char s[101];
	int x = 0, m = 0;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		m = max(m, x);
	}
	cout << m << endl;
}

Measured memory_bytes: 256
/*
Author :: Shahadat Hossain Nirob
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define Long long long
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
using namespace std;

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

const int INF = 2000000009;
const int MX = 200005;
const double EPS = 1e-9;
const int MOD = 1000000007;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod)x-=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))

typedef string st;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define endl '\n'
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    */
    
    Long n=LL();
    string S = to_string(n);

    int num = 0;
    rep(i,S.size())
        num += stoi(S.substr(i, 1).c_str());

    if (n% num == 0)
        cout << "Yes" << endl;
     
    else 
        cout << "No" << endl;
    
	return 0;
}



Measured memory_bytes: 256
// 2020-09-19 19:56:30
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
int dp[3], p[3];
void answer() {
  int n;
  cin >> n;
  rep(i, n) {
    swap(dp, p);
    int a, b, c;
    cin >> a >> b >> c;
    dp[0] = max(p[1], p[2]) + a;
    dp[1] = max(p[0], p[2]) + b;
    dp[2] = max(p[0], p[1]) + c;
  }
  cout << max({dp[0], dp[1], dp[2]}) << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main() {
	int n;
	cin>>n;
int nums [100005][3];

	for(int i=0; i<n; i++){
	cin>>nums[i][0]>>nums[i][1]>>nums[i][2];
	}
	vector<int> temp(3,0);
	vector<int> dp(3,0);
	
	for(int i=0; i<n; i++){
		temp=dp;
		temp[0]=nums[i][0]+max(dp[1],dp[2]);
		temp[1]=nums[i][1]+max(dp[0],dp[2]);
		temp[2]=nums[i][2]+max(dp[0],dp[1]);
		dp=temp;
	}
	cout<<max(dp[0],max(dp[1],dp[2]));
	
}

Measured memory_bytes: 1408
//C - AtCoDeer and Election Report: 
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

ll ceil(ll a, ll b) {
    return (a + (b-1)) / b;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll ans, x, y, ax, ay, m;

    cin >> n;
    cin >> x >> y;
    ax = x; ay = y;
    loop(i, 1, n) {
        cin >> x >> y;
        m = max(ceil(ax, x), ceil(ay, y));
        ax = x * m;
        ay = y * m;
    }
    ans = ax + ay;
    cout << ans << "\n";
}
    

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


public class Main {
	private	static	BufferedReader	br = null;
	private	static	int				IX = 0;
	private	static	int				IY = 1;
	private	static	int				IZ = 2;
	private	static	double			ZR = 1e-6;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(solve(parsePos())?"HIT":"MISS");
	}

	private static boolean solve(double[][] pos) {
		double[]	nv = getNormalVec(pos[2], pos[3], pos[4]);
		double[]	pv = new double[3];
		double		da = dot(sub(pos[2],pos[0]), nv);
		double		de = dot(sub(pos[1],pos[0]), nv);
		double		rt = da / de;

		// バリアと並行の向きに敵がいる
		if (Math.abs(de) < ZR) {
			return true;
		}

		// バリアのある平面とは逆の向きの敵がいる
		if (rt < -ZR) {
			return true;
		}

		// バリアのある平面より手前に敵がいる
		if (rt-ZR > 1.0) {
			return true;
		}

		// バリアのある平面との交点を求める
		for (int i = IX; i <= IZ; i++) {
			pv[i] = pos[0][i]*(1.0-rt)+pos[1][i]*rt;
		}

		// 交点がバリアの中にあるかチェックする
		{
			double[]	c1 = cross(sub(pos[3], pos[2]), sub(pv, pos[2]));
			double[]	c2 = cross(sub(pos[4], pos[3]), sub(pv, pos[3]));
			double[]	c3 = cross(sub(pos[2], pos[4]), sub(pv, pos[4]));
			double		d1 = dot(c1, c2);
			double		d2 = dot(c1, c3);

			if (d1 < -ZR || d2 < -ZR) {
				return true;
			}
		}

		return false;
	}

	private static double[] getNormalVec(double[] a, double[] b, double[] c) {
		double[]	ab = sub(b, a);
		double[]	ac = sub(c, a);
		double[]	n  = cross(ab, ac);

		return n;
	}
	
	private static double[] sub(double[] v1, double[] v2) {
		double[]	v3 = { v1[IX]-v2[IX], v1[IY]-v2[IY], v1[IZ]-v2[IZ] };
		return v3;
	}

	private static double[] cross(double[] v1, double[] v2) {
		double[]	v3 = { v1[IY]*v2[IZ]-v1[IZ]*v2[IY], v1[IZ]*v2[IX]-v1[IX]*v2[IZ], v1[IX]*v2[IY]-v1[IY]*v2[IX] };
		return v3;
	}

	private static double dot(double[] v1, double[] v2) {
		return v1[IX]*v2[IX]+v1[IY]*v2[IY]+v1[IZ]*v2[IZ];
	}

	private static double[][] parsePos() {
		double[][]	pos = new double[5][3];

		for (int i = 0; i < 5; i++) {
			String		str = parseStdin();
			String[]	lns = str.split(" ");

			for (int j = IX; j <= IZ; j++) {
				pos[i][j] = Double.parseDouble(lns[j]);
			}
		}

		return pos;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 17108
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int tmp = 10*b + c;
    if(tmp % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

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

typedef long long ll;

int main()
{
    int n; cin >> n;
    ll dp[n+5][5];
    for(int i = 0;i < n;i++)for(int j = 0;j < 3;j++)cin >> dp[i][j];

    for(int i = 1; i < n; i++){
        for(int j = 0; j < 3; j++){
            if(j == 0)
                dp[i][j] += max(dp[i-1][j+1],dp[i-1][j+2]);
            else if(j == 1)
                dp[i][j] += max(dp[i-1][j+1],dp[i-1][j-1]);
            else
                dp[i][j] += max(dp[i-1][j-1],dp[i-1][j-2]);
        }
    }
    ll ans = 0;
    for(int i = 0; i < 3; i++)ans = max(ans,dp[n-1][i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4096
H, W = map(int, input().split())
maze = [list(input()) for _ in range(H)]
done = [[10**4 + 1]*(W) for _ in range(H)]

min_count = 10 ** 4 + 1

def dfs(h, w, before_black, count):
    if maze[h][w] == "#":
        is_black = True
        if not before_black:
            count += 1
    else:
        is_black = False
    if done[h][w] <= count:
        return
    done[h][w] = count
    if h == H-1 and w == W-1:
        global min_count
        if count < min_count:
            min_count = count
    elif h == H-1:
        dfs(h, w+1, is_black, count)
    elif w == W-1:
        dfs(h+1, w, is_black, count)
    else:
        dfs(h+1, w, is_black, count)
        dfs(h, w+1, is_black, count)

dfs(0,0,False,0)
print(min_count)


Measured memory_bytes: 58072
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var H = cin.ReadInt;
            var W = cin.ReadInt;
            var h = cin.ReadInt;
            var w = cin.ReadInt;

            WriteLine(H*W-h*W-H*w+h*w);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define INF 1e9

using namespace std;

typedef long long ll;

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

  vi w = vi(n, 0);
  vi csum = vi(n, 0);
  vi c = vi(n, 0);
  REP(i, n)
  {
    cin >> c[i] >> w[i];
  }
  vvi dp = vvi(n, vi(n, INF));
  REP(i, n)
  {
    dp[i][i] = 1;
  }
  csum[0] = w[0];
  for (int i = 1; i < n; i++)
  {
    csum[i] = csum[i - 1] + w[i];
  }
  for (int count = 2; count <= n; count++)
  {
    REP(left, n)
    {
      int right = left + count - 1;
      if (right >= n)
      {
        continue;
      }

      // 一番下が一人になる時
      if (csum[right] - csum[left] <= c[left] && dp[left + 1][right] == 1)
        dp[left][right] = 1;
      if (csum[right - 1] - csum[left - 1] <= c[right] && dp[left][right - 1] == 1)
        dp[left][right] = 1;

      // min
      for (int k = left; k < right; k++)
      {
        dp[left][right] = min(dp[left][right], dp[left][k] + dp[k + 1][right]);
      }
    }
  }
  cout << dp[0][n - 1] << endl;
  return 0;
}


Measured memory_bytes: 6832
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 140000;

int n;
vector<int> eds[MAXN];
ll cs[MAXN];

vector<ll> dfs1(int v, ll x) {
	vector<ll> ans;
	if (eds[v].empty()) {
		ans.push_back(0);
		ans.push_back(0);
		return ans;
	}
	vector<ll> vv1 = dfs1(eds[v][0], x);
	if (vv1.empty())
		return vv1;
	for (int i = 0; i < (int)vv1.size(); ++i)
		vv1[i] += cs[eds[v][0]];
	vector<ll> vv2 = dfs1(eds[v][1], x);
	if (vv2.empty())
		return vv2;
	for (int i = 0; i < (int)vv2.size(); ++i)
		vv2[i] += cs[eds[v][1]];
	if (vv1.size() < vv2.size())
		swap(vv1, vv2);
	int now = vv1.size() - 1;
	vector<pair<ll, ll> > vv;
	for (int i = 0; i < (int)vv2.size(); ++i) {
		ll fr = x - vv2[i];
		while (now >= 0 && vv1[now] > fr)
			--now;
		if (now < 0)
			break;
		ll a = vv2[vv2.size() - 1 - i];
		ll b = vv1[vv1.size() - 1 - now];
		if (a > b)
			vv.push_back(make_pair(b, a));
		else
			vv.push_back(make_pair(a, b));
	}
	sort(vv.begin(), vv.end());
	vector<pair<ll, ll> > vv3;
	for (int i = 0; i < (int)vv.size(); ++i) {
		if (!vv3.empty() && vv3.back().first <= vv[i].first && vv3.back().second <= vv[i].second)
			continue;
		vv3.push_back(vv[i]);
	}
	for (int i = 0; i < (int)vv3.size(); ++i)
		ans.push_back(vv3[i].first);
	for (int i = (int)vv3.size() - 1; i >= 0; --i)
		ans.push_back(vv3[i].second);
	return ans;
}

int check(ll x) {
	vector<ll> vv = dfs1(0, x);
	if (vv.empty())
		return 0;
	return 1;
}


int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		int x;
		scanf("%d%lld", &x, cs + i);
		--x;
		eds[x].push_back(i);
	}
	ll l = -1;
	ll r = 1e11;
	while (r - l > 1) {
		ll mid = (l + r) >> 1;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r << "\n";
	return 0;
}




Measured memory_bytes: 22016
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        ArrayList<Integer> commonDivisor = new ArrayList<>();
        for (int i = 1; i <= Math.max(a, b); i++) {
            if (a % i == 0 && b % i == 0) {
                commonDivisor.add(i);
            }
        }

        Collections.sort(commonDivisor);
        System.out.println(commonDivisor.get(commonDivisor.size() - k));
    }
}

Measured memory_bytes: 23636
import sys
input = sys.stdin.readline


def s(n):
    return sum(map(int, list(str(n))))


def f(x):
    nines = max(0, len(str(x)) - 3)
    base = 10**nines - 1
    d = 10**nines
    snuke = x
    ratio = x / s(x)
    candidate = base + (x-base+d-1) // d * d
    for _ in range(150):
        new_ratio = candidate / s(candidate)
        if new_ratio < ratio:
            snuke = candidate
            ratio = new_ratio
        candidate += d
    return snuke


def main():
    k = int(input())
    snuke = 0
    for _ in range(k):
        snuke = f(snuke+1)
        print(snuke)


if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 25;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;



int main() {
	
	string s;
	cin >> s;

	int a, b;
	a = b = 0;

	REP(i, s.size()) {
		if (s[i] == '1')a++;
		else b++;
	}

	cout << min(a,b) * 2 << endl;

	

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#define MOD 1000000007
int prime[1000000+10];
void makep(int n){prime[0]=prime[1]=1;for(int i=2;i*i<=n;i++)if(!prime[i])for(int j=i*i;j<=n;j+=i)prime[j]=1;}

int dp[100010];//a[i]を素数として使う場合の数
int a[100010];
int main(){
	makep(1000005);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	dp[1]=!prime[a[1]];
	
	for(int i=2;i<=n;i++)if(!prime[a[i]]){
		//素数
		if(a[i-1]<a[i])dp[i]+=dp[i-1];
		if(a[i-2]<a[i])dp[i]+=dp[i-2];
		dp[i]%=MOD;
	}
	printf("%d\n",(dp[n]+dp[n-1])%MOD);
}


Measured memory_bytes: 6452
#include <stdio.h>

int main(void){
  float T = 0.0f;
  float X = 0.0f;
  float t = 0.0f;

  scanf("%f %f", &T, &X);

  if((T<1) && (T>100)) return -1;
  if((X<1) && (X>100)) return -1;

  // 0除算にはならない。
  t = T/X;

  printf("%f", t);
  return 0;
}

Measured memory_bytes: 128
n = int(input())
ans = 0
lis = list(map(int,input().split()))
for i in range(n):
  for j in range(i,n):
    for k in range(j,n):
      if i != j and j != k and i != k:
        if lis[i] != lis[j] and lis[j] != lis[k] and lis[i] != lis[k]:
          if max(lis[i],lis[j],lis[k]) < lis[i]+lis[j]+lis[k]-max(lis[i],lis[j],lis[k]):
            ans += 1
print(ans)

Measured memory_bytes: 9208
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>

#define MAX 2000

using namespace std;


int M,N,now,mx=0;
char S[MAX+1],T[MAX+1];
int s[MAX+1],t[MAX+1];
int dp[MAX+1][MAX+1][2];

int main(){
	scanf("%d %d",&M,&N);
	//scanf("%s",S);
	//scanf("%s",T);
	string st1;
	s[M]=-1;
	t[N]=-1;
	cin>>st1;
	for(int i=0;i<M;i++){
		s[i]=(st1[i]=='I' ? 1:0);
	}
	cin>>st1;
	for(int i=0;i<N;i++){
		t[i]=(st1[i]=='I' ? 1:0);
	}
	for(int i=M;i>=0;i--){
		for(int j=N;j>=0;j--){
			if(s[i]==0&&t[j]==0)
			now=max(dp[i+1][j][1]+1,dp[i][j+1][1]+1);
			else if(s[i]==0)
			now=dp[i+1][j][1]+1;
			else if(t[j]==0)
			now=dp[i][j+1][1]+1;
			else
			now=0;
			dp[i][j][0]=now;
			//
			if(s[i]==1&&t[j]==1)
			now=max(dp[i+1][j][0]+1,dp[i][j+1][0]+1);
			else if(s[i]==1)
			now=dp[i+1][j][0]+1;
			else if(t[j]==1)
			now=dp[i][j+1][0]+1;
			else
			now=0;
			dp[i][j][1]=now;
		}
	}
	for(int i=0;i<M;i++){
		for(int j=0;j<N;j++){
			if(dp[i][j][1]%2!=0)
			mx=max(dp[i][j][1],mx);
			else
			mx=max(dp[i][j][1]-1,mx);
		}
	}
	printf("%d\n",mx);
}

Measured memory_bytes: 34608
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
	int h,w;
	cin>>h>>w;
	char ch[h][w];
	rep(i,h){
		rep(j,w)cin>>ch[i][j];
	}
	bool check=true;
	rep(i,h){
		rep(j,w){
			if(ch[i][j]=='.')continue;
			if(i==0&&j==0&&h>1&&w>1){
				if(ch[1][0]=='#' && ch[0][1]=='#'){
					check=false;
					break;
				}
			}
			if(h>1&&w>1&&i==h-1&&j==w-1){
				if(ch[i-1][j]=='#' && ch[i][j-1]=='#'){
					check=false;
					break;
				}
			}
			int num=0;
			rep(k,4){
				if(i+dy[k]<0||i+dy[k]>=h)continue;
				if(j+dx[k]<0||j+dx[k]>=w)continue;
				if(ch[i+dy[k]][j+dx[k]]=='#')num++;
			}
			if(num>2){
				check=false;
				break;
			}
			if(i+1>=h && ch[i][j+1]=='.'){
				check=false;
				break;
			}else if(j+1>=w && ch[i+1][j]=='.'){
				check=false;
				break;
			}else{
				if(ch[i+1][j]=='.' && ch[i][j+1]=='.'){check=false;break;}
			}
		}
		if(!check)break;
	}
	cout<<(check?"Possible":"Impossible")<<endl;
	return 0;
}

Measured memory_bytes: 256
def fib(n):
    l = [0]*(n+1)
    l[0] = 1
    l[1] = 1
    for i in range(2, n+1):
        l[i] = l[i-1] + l[i-2]
    return l[n]

n = int(input())
print(fib(n))


Measured memory_bytes: 5600