akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;class Main {
    public void yatary(){
        Scanner sc = new Scanner(System.in);
        int H = 0,W = 0;
        int x,y,a,b;
        H = sc.nextInt();
        W = sc.nextInt();
          while(H != 0 || W != 0){
              for(x = 1; x <= H;x++){ 
                  for(y = 1; y <= W;y++){
                      a = x % 2;
                      b = y % 2;
                      if(b == 1){
                      if(a == 1){
                          System.out.print("#");
                      }else{
                          System.out.print(".");
                      }
                      }else if(a == 0){
                          System.out.print("#"); 
                      }else{    
                          System.out.print(".");   
                      } 
                  }
        System.out.println();          
              }
        System.out.println();
        H = sc.nextInt();
        W = sc.nextInt();
        }
    }
    public static void main(String[] args) { 
        new Main().yatary();
    } 
}

Measured memory_bytes: 26844
object Main {
  import java.io.PrintStream

  def main(args: Array[String]): Unit = {
    val s = new Main()
    val ps = new PrintStream(Console.out)
    Console.withOut(ps) {
      s.solve()
    }
    ps.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag
  import scala.Console

  val MOD = 1000000007

  def solve(): Unit = {
    val A, B, C, K = nl()
    val ans = if (K % 2 == 0) A - B else B - A
    println(ans)
  }


  class InputReader(reader: BufferedReader) {
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(Console.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    rep(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    rep(n) { i =>
      rep(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Int](as.length + 1)
    rep(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

Measured memory_bytes: 27432
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

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

int main() {
    int n, m;
    int k[11];
    int s[11][11];
    int p[11];
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++)
        {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    ll cnt = 0;
    for (int bit = 0; bit < 1 << n; bit++)
    {   int line = 0;
    
        for (int j = 0;  j< m; j++)
        {
            int sum = 0;
            for (int l = 0; l < k[j]; l++)
            {
                for (int i = 0; i < n; i++)
                {
                    if (bit & (1 << i))
                    {     
                        if (s[j][l] == i)
                            {
                                sum++;
                            }
                        }
                }
                } 
                        if(sum%2==p[j]){
                            line++;
                        }
        }
                if(line==m){
                    cnt++;
                }
    }                
    cout << cnt << endl;
    


    return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    vll a(N);
    REP(i,N) cin >> a[i];


    //本文
    ll ans =0,current = 0;
    while(ans<N){
        current = a[current]-1;
        ans ++;
        if(current==1){
            cout << ans;
            return 0;
        }
    }

    cout << -1;

    //出力
    //cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

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

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

    vector<double> c, d;
    double k = a;
    int z = 0;
    int flag = 0;
    for(int i = 0; i < 99; i++){
        double q = k / 0.08;
        if(flag == 0){
            if(q > (int)q){
                flag = 1;
                z = (int)q;
            }else if(q == (int)q){
                flag = 2;
            }
        }else if(flag = 1){
            if(z != (int)q){
                flag = 2;
            }
        }

        if(flag == 2){
            c.push_back(q);
        }

        k += 0.01;
    }
    
    k = b;
    flag = 0;
    for(int i = 0; i < 99; i++){
        double q = k / 0.1;
        if(flag == 0){
            if(q > (int)q){
                flag = 1;
                z = (int)q;
            }else if(q == (int)q){
                flag = 2;
            }
        }else if(flag = 1){
            if(z != (int)q){
                flag = 2;
            }
        }

        if(flag == 2){
            d.push_back(q);
        }
        k += 0.01;
    }
    flag = 0;
    int ans = 10000;

    for(int i = 0; i < c.size(); i++){
        for(int j = 0; j < d.size(); j++){
            if((int)c[i] == (int)d[j]){
                flag = 1;
                if(ans > (int)c[i]){
                    ans = (int)c[i];
                }
            }
        }
    }

    if(flag == 1){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
import math

n = input()
for i in xrange(n):
    xa, ya, ra, xb, yb, rb = map(float, raw_input().split())
    d = math.sqrt(((xa - xb) ** 2) + ((ya - yb) ** 2))
    if ra + rb < d: print 0
    elif ra + rb >= d and abs(ra - rb) <= d: print 1
    else: print 2 if ra > rb else -2

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;




int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  int a_tot=0;
  rep(i,n){
    cin>>a[i];
    a_tot=a_tot^a[i];

  }
  rep(i,n){
    cout<<(a[i]^a_tot)<<endl;
  }



  return 0;
}


Measured memory_bytes: 4668
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pp pair<int, int>
#define ppp pair<pp, int>
#define fi first
#define se second
#define esp 1e-15
#define inf 1000000001
#define mod 1000000007
#define N 55
#define base 311097
typedef long long ll;
typedef long double ld;
const long long oo = (ll)1e18;
using namespace std;
int n, ma, mb;
int a[N];
int b[N];
int c[N];
int f[444][444];

int main() {
   //  freopen("in.in", "r", stdin);

  //  freopen("in2.in", "r", stdin);
   // freopen("ou.ou", "w", stdout);

    cin >> n >> ma >> mb;

    for (int i = 0; i <= 400; i++)
        for (int j = 0; j <= 400; j++)
            f[i][j] = inf;
    f[0][0] = 0;

    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        for (int u = 400; u >= 0; u--)
            for (int v = 400; v >= 0; v--)
            if (u - a[i] >= 0 && v - b[i] >= 0)
                f[u][v] = min(f[u][v], f[u - a[i]][v - b[i]] + c[i]);
    }

    int ret = inf;
    for (int i = 1; i <= 400; i++)
    for (int j = 1; j <= 400; j++) {
        int ii = i / __gcd(i, j);
        int jj = j / __gcd(i, j);
        if (ii == ma && jj == mb) ret = min(ret, f[i][j]);
    }
    if (ret == inf) ret = -1;

    cout << ret;
    /**/ return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair< ll, ll > pll;
typedef pair< int, int > pii;

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  ll N;
  cin >> N;

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

  sort(A, A + N);

  for (ll i = 1; i < N; i++) {
    if (A[i - 1] == A[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1792
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,m = get_nums_l()
H = [0] + get_nums_l()

edges = [ [] for _ in range(n+1)]
for i in range(m):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

ans = 0
for u in range(1, n+1):
    ok = True
    for v in edges[u]:
        if H[u] <= H[v]:
            ok = False
            break
    if ok:
        ans += 1

print(ans)


Measured memory_bytes: 90164
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	map<int, int> x;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		x[a]++;
	}

	
	vector<int> p(n);
	for (auto i : x)
	{
		p.at(i.first - 1) = i.second;
	}

	sort(all(p));

	int res = 0;
	int l = x.size() - k;
	if (l > 0)
	{
		for (int i = 0; i < n; i++)
		{
			if (p.at(i) > 0)
			{
				res += p.at(i);
				l--;
				if (l == 0)
				{
					break;
				}
			}
		}
	}

	println(res);
}

Measured memory_bytes: 10368
#include <iostream>

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == t[i]) ++ans;
    }

    cout << ans << endl;

    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
typedef struct E{
  ll to,cost;
}edge;
const ll MAX_V=200100;
const ll Inf=1e18;
vector<vector<edge> >E(MAX_V);
ll d[MAX_V];
void dijkstra(ll s){
  priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >que;
  fill_n(d,MAX_V,Inf);
  d[s] = 0;
  que.push(pair<ll,ll>(0,s));
  while(!que.empty()){
    pair<ll,ll> p=que.top();que.pop();
    ll v = p.second;
    if(d[v]<p.first)continue;
    for(int j=0;j<E[v].size();j++){
      edge t = E[v][j];
      if(d[t.to]>d[v]+t.cost){
	d[t.to]=d[v]+t.cost;
	que.push(pair<ll,ll>(d[t.to],t.to));
      }
    }
  }
}
int main(){
  ll n;cin>>n;
  for(int i=0;i<n-1;i++){
    ll a,b,c;cin>>a>>b>>c;
    edge e;e.to=--b;e.cost=c;
    E[--a].pb(e);
    e.to=a;
    E[b].pb(e);
  }
  ll q,k;cin>>q>>k;
  dijkstra(k-1);
  for(int i=0;i<q;i++){
    ll a,b;cin>>a>>b;
    a--;b--;
    cout<<d[a]+d[b]<<endl;
  }
  return 0;
}


Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int dp[maxn];
int main()
{
	int n;
  	cin>>n;
  	cin>>a[1];
  	dp[1]=a[1];
  	for(int i=2;i<=n;i++) {
    	cin>>a[i];
      	dp[i]=min(dp[i-1],a[i]);
    }
  	int ans=0;
  	for(int i=1;i<=n;i++){
    	if(dp[i]==a[i]) ans++;
    }
  	cout<<ans<<'\n';
  	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=0;char ch=getchar();
    while(!isdigit(ch))f|=ch=='-',ch=getchar();
    while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
    return f?-x:x;
}
inline void Yeah(){puts("Yes");exit(0);}
int main()
{ 
    int n=read(),m=read(),k=read();
    for(int i=1;i<=n;++i)
    {
        int kk=(k-i*m),a=n-i-i;
        if(!kk || a && (kk>>31&1)==(a>>31&1) && kk%a==0 && kk/a<=m)Yeah();
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif
const int N = 3005;
double dp[N][N];
int vis[N][N];
double n;
double a[N];
double solve(int i,int cur){
    if(i == n){
        if(cur >=  (n - cur)){
            return 1;
        }
        return 0;
    }
    int &ans = vis[i][cur];
    if(ans){
        return dp[i][cur];
    }
    vis[i][cur] = 1;
    dp[i][cur] = a[i] * solve(i+1,cur+1);
    dp[i][cur] += (1 - a[i]) * solve(i+1,cur);
    return dp[i][cur];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    memset(vis,0,sizeof(vis));
    cout<<fixed<<setprecision(12)<<solve(0,0)<<endl;
    
    return 0;
    
}



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

vector<ll> h(51);//レベルnバーガーの高さ
vector<ll> p(51);//レベルnバーガーのパティの枚数
ll j_ans;

ll dfs(ll a, ll b) {
	ll ans = 0;
	if (a == 0) return 1;
	if (b >= 1) b--;//一番上のバン
	if (b >= 1) {//レベルa-1バーガー
		if (b >= h[a - 1]) {
			b -= h[a - 1];
			ans += p[a - 1];
		}
		else {
			ans += dfs(a - 1, b);
			b = 0;
		}
	}
	if (b >= 1) {//真ん中のパティ
		b--;
		ans++;
	}
	if (b >= 1) {//レベルa-1バーガー
		if (b >= h[a - 1]) {
			b -= h[a - 1];
			ans += p[a - 1];
		}
		else {
			ans += dfs(a - 1, b);
			b = 0;
		}
	}
	if (b >= 1) {
		b--;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	ll x;
	cin >> x;
	ll cnt = 0;
	h[0] = 1;
	for (int i = 0; i <= n - 1; ++i) {
		h[i + 1] = h[i] * 2 + 3;
	}
	p[0] = 1;
	for (int i = 0; i <= n - 1; ++i) {
		p[i + 1] = 2 * p[i] + 1;
	}
	j_ans = dfs(n, x);
	cout << j_ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
 
const int inf = int(1e9);
const int mod = 1e9 + 7;
const int N = 1e6 + 555;
const long double PI = acos(-1.0);


map<string, vector<int> > v;
map<pair<string, int>, int> u; 
void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		string s;
		int p;
		cin >> s >> p;
		v[s].pb(p);
		u[mp(s, p)] = i + 1;
	}
	for(auto it : v){
		sort(all(it.S));
		reverse(all(it.S));
		rep(i, sz(it.S)){
			cout << u[mp(it.F,it.S[i])] << endl;
		}
	}



}

int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(1e5 + 10, 0);
  ll sum = 0;
  REP(i, n) {
    ll x;
    cin >> x;
    sum += x;
    cnt[x]++;
  }
  ll q;
  cin >> q;
  while (q--) {
    ll b, c;
    cin >> b >> c;
    sum += cnt[b] * (c - b);
    cout << sum << endl;
    cnt[c] += cnt[b];
    cnt[b] = 0;
  }
}

Measured memory_bytes: 4044
#include "bits/stdc++.h"
using namespace std;
#define dump(x) cout << (x) << endl;
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 114514810893364364;

int main() {
  Int a, b, c;
  cin >> a >> b >> c;
  dump(b - a ==  c - b ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

readInt :: B.ByteString -> Maybe (Int,B.ByteString)
readInt xs = do
    (x,ys) <- B.readInt xs
    return (x,B.tail ys)

main :: IO ()
main = do
    (h,w) <- (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
    print $ if h == 1 || w == 1 then 1
            else if h `mod` 2 == 0 then (h*w) `div` 2 
            else (((h-1)*w) `div` 2) + w `div` 2 + w `mod` 2

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> num(K, 0);
    for (int i = 1; i <= N; i++)
        num[i % K]++;
    ll res = 0;
    rep(a, K) {
        int b = (K - a) % K;
        int c = (K - a) % K;
        if ((b + c) % K != 0)
            continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
}


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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
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>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        ll v1,v2;
        cin>>x>>v1>>y>>v2>>n;
        if(v1<=v2)
        {
            cout<<"NO";
            return 0;
        }
        ll d=abs(x-y);
        ll v=abs(v1-v2);
        ll t;
        if(n*v>=d)
        {
            cout<<"YES";
        }
        else
            cout<<"NO";
    }
    return 0;
}

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

class Combination {
public:
    Combination(int n, int m)
        :fact(n+1)
        , inv_fact(n+1)
        , mod(m) {

        fact[0] = 1;
        for(int i = 1; i <= n; i++){
            fact[i] = fact[i-1] * i % mod;
        }
        inv_fact[n] = power(fact[n], mod-2);
        for(int i = n; i >= 1; i--){
            inv_fact[i-1] = inv_fact[i] * i % mod;
        }
    }

    ll operator()(int n, int r){
        ll temp = fact[n] * inv_fact[n-r] % mod;
        return temp * inv_fact[r] % mod;
    }

private:
    int mod;
    vector<ll> fact, inv_fact;

    ll power(ll a, ll x){
        if(x == 0) return 1;
        if(x % 2) return a * power(a, x-1) % mod;
        return power(a * a % mod, x / 2);
    }
};

const int mod = 1e+9 + 7;

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

    Combination c(n, mod);

    ll ans = 0;
    for(int i = 0; i <= min(n-1, k); i++){
        ll temp = c(n, i) * c(n-1, i) % mod;
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;int main(){int a[3][3];for(int i=0;i<3;i++){for(int j=0;j<3;j++){cin>>a[j][i];}}cout<<(a[0][1]-a[0][0]==a[1][1]-a[1][0]&&a[1][1]-a[1][0]==a[2][1]-a[2][0]&&a[0][2]-a[0][1]==a[1][2]-a[1][1]&&a[1][2]-a[1][1]==a[2][2]-a[2][1]?"Yes\n":"No\n");return 0;}


Measured memory_bytes: 256
import java.util.*;
 
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 c = Integer.parseInt(sc.next());
        System.out.println(max(a, max(b,c)) - min(a, min(b,c)));
    }
    public static int min(int a, int b) {
        if(a <= b) return a;
        else return b;
    }
    public static int max(int a, int b) {
        if(a <= b) return b;
        else return a;
    }
}

Measured memory_bytes: 23508
#include <stdio.h>
 
void drawRectangle(int height, int width);

int main(void) {
 
    int i;
    int j;
    int width;
    int height;
 
    while(1) {
        scanf("%d %d", &height, &width);
         
        if(width == 0 && height == 0) {
            break;
        }

        drawRectangle(height, width);

        printf("\n");
    } 
 
    return 0;
}

void drawRectangle(int height, int width) {

    int i;
    int j;
    
    for(i = 0; i < height; i++) {
        for(j = 0; j < width; j++) {
            putchar('#');
        }
        printf("\n");
    }

    return;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MIN(a,b) (((a)<=(b))?(a):(b))
#define MAX(a,b) (((a)>=(b))?(a):(b))
#define ll long long int
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    ll s = 0;
    for (int i = 0; i < (n - 1); i++){
        for (int j = (i + 1); j < n; j++){
            s += (a[i] * a[j]);
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
main(){
int a,b,c;
cin>>a>>b>>c;
if(a>b)swap(a,b);
if(b>c)swap(b,c);
if(a>b)swap(a,b);
cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}



Measured memory_bytes: 3100
//
//  C - 2D Plane 2N Points.cpp
//  AtCoder Regular Contest 092
//
//  Created by Huang,Zhiqiang on 2018/3/22.
//  Copyright © 2018年 Huang,Zhiqiang. All rights reserved.
//

#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;

bool cmp(const pair<pair<int, int>, int>& a, const pair<pair<int, int>, int>& b) {
    int x1 = a.first.first, y1 = a.first.second;
    int x2 = b.first.first, y2 = b.first.second;
    return x1 <= x2;
}

int main() {
    int n;
    cin >> n;
    vector< pair<pair<int, int>,int> > nodes;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        nodes.push_back(make_pair(make_pair(x, y), 0));
    }
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        nodes.push_back(make_pair(make_pair(x, y), 1));
    }
    sort(nodes.begin(), nodes.end(), cmp);
    set<int> reds_y;
    int cnt = 0;
    for (int i = 0; i < nodes.size(); i++) {
        if (nodes[i].second == 0) {
            reds_y.insert(nodes[i].first.second);
        } else {
            int y = nodes[i].first.second;
            int ty = 0;
            bool found = false;
            set<int>::iterator iter = reds_y.begin();
            while (iter != reds_y.end()) {
                if (*iter < y) {
                    if (!found) {
                        ty = *iter;found = true;
                    } else {
                        if (*iter > ty) {
                            ty = *iter;
                        }
                    }
                }
                iter++;
            }
            if (found) {
                reds_y.erase(ty);cnt++;
                
            }
        }
    }
    cout << cnt << endl;
}


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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){

	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int a,b = 0;
	scanf("%c %c",&a,&b);
	printf("%c\n", a ^ b ? 'D' : 'H');
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int N, A[100];
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  
  int count = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = N - 1; j > i; --j) {
      if (A[j] < A[j-1]) {
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        ++count;
      }
    }
  }
  
  for (int i = 0; i < N; ++i) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << count << endl;
}

Measured memory_bytes: 3060
H, W, M = map(int, input().split())
A = [0]*H
B = [0]*W
D = set()
for _ in range(M):
    h,w = map(int, input().split())
    A[h-1] += 1
    B[w-1] += 1
    D.add((h-1,w-1))
a, b = max(A), max(B)
res = a+b-1
E, F = [], []
for i in range(H):
    if A[i] == a:
        E.append(i)
for j in range(W):
    if B[j] == b:
        F.append(j)
for i in E:
    for j in F:
        if (i,j) not in D:
            print(res+1)
            exit()
print(res)

Measured memory_bytes: 166852
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

  if(s.length() == 2) cout << s << endl;
  else{
    cout << s[2];
    cout << s[1];
    cout << s[0] << endl;
  }
  return 0;
}


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

using namespace std;

vector<int> vec;
int n;

bool prime(int n) {
    for (int i = 2; i * i <= n; i++)
	if (n % i == 0)
	    return false;
    return n != 1;
}

int main() {
    for (int i = 1; vec.size() < 55; i++)
	if (prime(i * 10 + 1))
	    vec.push_back(i * 10 + 1);
    cin >> n;
    for (int i = 0; i < n; i++)
	cout << vec[i] << " ";
}


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

#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define SZ(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
using namespace std;

typedef long long ll;
typedef pair<int,int> PI;
typedef unsigned long long ull;

#define PR(...) do{cerr << "line : " << __LINE__ << endl; pr(#__VA_ARGS__, __VA_ARGS__);}while(0);
template<class T>
void pr(const string& name, T t){
  cerr << name << ": " << t << endl;
}

template<typename T, typename ... Types>
void pr(const string& names, T t, Types ... rest) {
  auto comma_pos = names.find(',');
  cerr << names.substr(0, comma_pos) << ": " << t << ", ";
  
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest ...);
}

template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
template<class T> ostream& operator<< (ostream& o, const set<T> &v){o << "{";for(auto e : v) o << e << ", ";return o << "}";}
template<class T, class U> ostream& operator<< (ostream& o, const map<T,U> &v){o << "{";for(auto e : v) o << e.F << ": " << e.S << ", ";return o << "}";}

//                < v > ^
const int dx[] = {0,1,0,-1, 1, 1, -1, -1};
const int dy[] = {-1,0,1,0, 1, -1, 1, -1};
#define endl '\n'

const ll mod = 1e9 + 7;
int n, x, y, z;

ll modpow(ll p, ll n, ll mod){
  ll ret = 1;
  while(n){
    if(n&1) ret = (ret*p)%mod;
    p = p*p % mod;
    n >>= 1;
  }
  return ret;
}

ll memo[41][1 << 17];

ll dfs(int res, int st) {
  if (st & (1 << (x + y + z))) return modpow(10, res, mod);
  if (res == 0) return 0;
  if (memo[res][st] >= 0)
    return memo[res][st];
  ll& ret = memo[res][st] = 0;
  for (int i = 1; i <= 10; ++i) {
    int nst = 1;
    for (int j = 0; j < x; ++j) {
      if ((~st >> j)& 1) continue;
      if (j + i > x) continue;
      nst |= 1 << (j + i);
    }

    for (int j = 0; j < y; ++j) {
      if ((~st >> (x + j))& 1) continue;
      if (j + i > y) continue;
      nst |= 1 << (x + j + i);
    }

    for (int j = 0; j < z; ++j) {
      if ((~st >> (x + y + j))& 1) continue;
      if (j + i > z) continue;
      nst |= 1 << (x + y + j + i);
    }

    ret += dfs(res - 1, nst);
    ret %= mod;
  }
  return ret;
}

int main(int argc, char *argv[])
{
  cin >> n >> x >> y >> z;
  memset(memo, -1, sizeof(memo));
  cout << dfs(n, 1) << endl;
  return 0;
}


Measured memory_bytes: 42240
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
ll san(ll n) {
    return n * (n - 1) / 2;
}

ll rev(ll n) {
    if (n <= 2) return -1;

    ll lb = 0;
    ll ub = n + 1;
    while (ub - lb > 1) {
        ll mid = (lb + ub) / 2;
        if (san(mid) == n) {
            return mid;
        } else if (san(mid) < n) {
            //midは小さかった...
            lb = mid;
        } else {
            ub = mid;
        }
    }
    return -1;
}


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

    ll n;
    cin >> n;

    if(n == 1){
        cout << "Yes" << endl;
        cout << 2 << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
        return 0;
    }

    int x = (int) rev(n);
    if (x == -1) {
        cout << "No" << endl;
        return 0;
    }

    vector<vector<int> > ans(x);
    int p1 = 0, p2 = 1;
    for (int i = 1; i <= n; ++i) {
        ans[p1].push_back(i);
        ans[p2].push_back(i);
        p2++;
        if (p2 == x) {
            p1++;
            p2 = p1 + 1;
        }
    }

    cout << "Yes" << endl;
    cout << x << endl;
    for (auto vec : ans) {
        cout << vec.size() << " ";
        for (int i = 0; i < vec.size(); ++i) {
            cout << vec[i];
            if (i == vec.size() - 1) {
                cout << endl;
            } else {
                cout << " ";
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdint>

int main() {
    int64_t N,A,B,C,D,E;
    std::cin >> N >> A >> B >> C >> D >> E;
    
    int64_t bottle_neck = std::min({A,B,C,D,E});
    int64_t ans = std::ceil(N / (double)bottle_neck) + 4;
    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long N = lread();
    long cnt;
    foreach (i; 0 .. N)
    {
        long l, r;
        scan(l, r);
        cnt += r - l + 1;
    }
    writeln(cnt);
}


Measured memory_bytes: 380
<?php


$string = trim(fgets(STDIN));

$parts = explode(" ", $string);

$dogs = $parts[0];
$monkeys = $parts[1];



if (abs($dogs-$monkeys) > 1)
{
	echo "0\n";
	die();
	
}


if ($dogs == $monkeys)
{
	$result = (( mod_fact($dogs) * mod_fact($monkeys) ) * 2) % 1000000007;
}
else
{
	$result = (( mod_fact($dogs) * mod_fact($monkeys) )) % 1000000007;
}



function mod_fact($num)
{
	$ans = 1;
	$mod = 1000000007;
	
	for ($i = 1; $i <= $num; $i++ )
	{
		$ans = ($ans*$i)%$mod;
	}
	
	return $ans;
}


echo $result . "\n";

Measured memory_bytes: 3828
n=int(input());a=[list(map(int,input().split()))for i in range(n)];t=[0]*(1<<n)
for i in range(1,1<<n):
    p=i&(i-1)
    t[i]=sum([sum([a[j][h]for h in range(n)if 1<<h&i])for j in range(n)if 1<<j&i])
    while p:
        t[i]=max(t[i],t[p]+t[i^p])
        p=(p-1)&i
print(t[-1]//2)

Measured memory_bytes: 45020
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
int n,m,a,b;
long long ans;
pair<int,int> E[100000];
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        E[i]=make_pair(a,b);
    }
    sort(E,E+n);
    for(int i=0;m;i++){
        ans+=(long long)min(m,E[i].second)*E[i].first;
        m-=min(m,E[i].second);
    }
    cout<<ans;
    return 0;
}

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

int main(){ 
    string s,t;
    cin>>s;
    cin>>t;
    if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]){
        cout<<"YES";
    }else{
        cout<<"NO";
    }

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[1]*(n+1)
flg=0
for i in range(m):
  a[int(input())]=-1
for i in range(2,n+1):
  if a[i]==-1:
    pass
  elif a[i-1]==-1 and a[i-2]==-1:
    flg=1
    break
  elif a[i-1]==-1:
    a[i]=a[i-2]
  elif a[i-2]==-1:
    a[i]=a[i-1]
  else:
    a[i]=a[i-1]+a[i-2]
if flg==1:
  print(0)
else:
  print(a[-1]%1000000007)

Measured memory_bytes: 465964
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const int maxn = 2e5;
int dp[maxn];
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n; cin>>n;
int cnt=0;
F (i,1,n+1,1) {
  cnt+=((n-1)/i);
}
cout<<cnt;
return 0;
}


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

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

  if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }

}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    // 事前準備, 累積和を求める
    vector<ll> acc_sum(n+1, 0);
    rep(i, n) {
        auto itr = upper_bound(c.begin(), c.end(), b[i]);
        ll c_itr = itr - c.begin();
        acc_sum[i+1] = acc_sum[i] + c.size() - c_itr;
    }

    ll ans = 0;
    rep(i, n) {
        auto itr = upper_bound(b.begin(), b.end(), a[i]);
        ll b_itr = itr - b.begin();
        ans += acc_sum[b.size()] - acc_sum[b_itr];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>
int HN(int n){
  int a,b,c;
  int count=0;
  do{
    a=n/10;
    b=a*10;
    c=n-b;
    count+=c;
    n=a;
  }while(a>10);
  return count+a;
}
int main(){
  int N;
  scanf("%d",&N);
  if(N%HN(N)==0){
    printf("Yes");
  }
  else{
    printf("No");
  }
}


Measured memory_bytes: 128