akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <list>
#include <algorithm>

const int N = 2e5 + 10, M = 20, INF = ~0u >> 2;
int n, a[N], lg2[N];
std::pair<int, int> ST1[N][M], ST2[N][M];

inline void init() {
    for (int i = 0; (1 << i) < N; i++)
        lg2[1 << i] = i;
    for (int i = 0; i < N; i++)
        if (!lg2[i])
            lg2[i] = lg2[i - 1];

    for (int i = 1; i <= n; i += 2) {
        ST1[i][0] = std::make_pair(a[i], i);
        ST2[i][0] = std::make_pair(INF, i);
    }
    for (int i = 2; i <= n; i += 2) {
        ST2[i][0] = std::make_pair(a[i], i);
        ST1[i][0] = std::make_pair(INF, i);
    }
    for (int j = 1; (1 << j) <= n; j++)
        for (int i = 1; i + (1 << j) - 1 <= n; i++) {
            ST1[i][j] = std::min(ST1[i][j - 1], ST1[i + (1 << (j - 1))][j - 1]);
            ST2[i][j] = std::min(ST2[i][j - 1], ST2[i + (1 << (j - 1))][j - 1]);
        }
}

inline std::pair<int, int> query1(int l, int r) {
    static int len, k;
    len = r - l + 1;
    k = lg2[len];
    return std::min(ST1[l][k], ST1[r - (1 << k) + 1][k]);
}

inline std::pair<int, int> query2(int l, int r) {
    static int len, k;
    len = r - l + 1;
    k = lg2[len];
    return std::min(ST2[l][k], ST2[r - (1 << k) + 1][k]);
}

inline std::list<std::pair<int, int>>* process(int l, int r) {
    auto ans = new std::list<std::pair<int, int>>;
    if (l > r)
        return ans;
    int p1, p2;
    if (l & 1) {
        p1 = query1(l, r).second;
        p2 = query2(p1 + 1, r).second;
    } else {
        p1 = query2(l, r).second;
        p2 = query1(p1 + 1, r).second;
    }
    ans -> emplace_back(a[p1], a[p2]);
    auto v1 = process(l, p1 - 1), v2 = process(p1 + 1, p2 - 1), v3 = process(p2 + 1, r);
    if (v1 -> empty() && v2 -> empty()) {
        delete v1;
        delete v2;
        delete ans;
        v3 -> emplace_front(a[p1], a[p2]);
        return v3;
    }
    if (v2 -> empty() && v3 -> empty()) {
        delete v2;
        delete v3;
        delete ans;
        v1 -> emplace_front(a[p1], a[p2]);
        return v1;
    }
    if (v3 -> empty() && v1 -> empty()) {
        delete v3;
        delete v1;
        delete ans;
        v2 -> emplace_front(a[p1], a[p2]);
        return v2;
    }
    auto it1 = v1 -> begin(), it2 = v2 -> begin(), it3 = v3 -> begin();
    while (true) {
        if (it1 != v1 -> end() && (it2 == v2 -> end() || *it1 < *it2) && (it3 == v3 -> end() || *it1 < *it3)) {
            ans -> push_back(*it1);
            it1++;
        } else if (it2 != v2 -> end() && (it3 == v3 -> end() || *it2 < *it3)) {
            ans -> push_back(*it2);
            it2++;
        } else if (it3 != v3 -> end()) {
            ans -> push_back(*it3);
            it3++;
        } else {
            break;
        }
    }
    delete v1;
    delete v2;
    delete v3;
    return ans;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", a + i);
    init();

    auto ans = process(1, n);
    for (auto it = ans -> begin(); it != ans -> end(); it++)
        printf("%d %d ", it -> first, it -> second);
    putchar('\n');

    return 0;
}



Measured memory_bytes: 87424
n,m=map(int,input().split())
PY=[]
for i in range(m):
    p,y=map(int,input().split())
    PY.append([y,p,i])
PY.sort()

pre=[0]*n
citys=['']*m
for y,p,i in PY:
    pre[p-1]+=1
    citys[i]=str(p).zfill(6)+str(pre[p-1]).zfill(6)
for city in citys:
    print(city)

Measured memory_bytes: 32164
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
colors = []
ans = [[None] * w for _ in range(h)]
dir = True

for i in range(len(a)):
    num = int(a[i])
    for j in range(num):
        colors.append(i+1)

#print(colors)

for i in range(h):
    if dir:
        for j in range(w):
            num = colors[0]
            ans[i][j] = num
            del colors[0]
        dir = not dir
    else:
        for j in reversed(range(w)):
            num = colors[0]
            ans[i][j] = num
            del colors[0]
        dir = not dir

#print(ans)

for i in range(len(ans)):
    print(*ans[i])


'''
3 5
5
1 2 3 4 5
'''

Measured memory_bytes: 43120
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 2000
#define INF 0x7fffffff
int N;
char str[MAXN+5];
vector<int> G[MAXN+5];
int Size[MAXN+5],Max[MAXN+5],Min[MAXN+5];

int All;
void dfs(int u,int fa){
    Size[u]=Max[u]=Min[u]=0;
    for(int i=0;i<int(G[u].size());i++){
        int v=G[u][i];
        if(v!=fa){
            dfs(v,u);
            Size[u]+=Size[v];
            Max[v]+=Size[v];
            Min[v]+=Size[v];
            if(max(Min[u],Min[v])<=min(Max[u],Max[v]))
                Min[u]=(Min[u]%2!=Min[v]%2);
            else
                Min[u]=max(Min[u],Min[v])-min(Max[u],Max[v]);
            Max[u]+=Max[v];
        }
    }
    if(str[u]=='1')
        Size[u]++;
}

int main(){
    N=read();
    scanf("%s",str+1);
    for(int i=1;i<=N-1;i++){
        int u=read(),v=read();
        G[u].push_back(v),
        G[v].push_back(u);
    }
    int Ans=INF;
    for(int i=1;i<=N;i++){
        All=0;
        dfs(i,-1);
        if(!Min[i])
            Ans=min(Ans,Max[i]/2);
    }
    printf("%d",Ans==INF?-1:Ans);
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int h, w;
string s[510];
char ans1[510][510], ans2[510][510];

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> h >> w;
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)ans1[i][j] = ans2[i][j] = '.';
	for (int i = 0; i < h; i++) {
		cin >> s[i];
		for (int j = 0; j < w; j++)if (s[i][j] == '#')ans1[i][j] = ans2[i][j] = '#';
	}
	for (int i = 0; i < h; i++)ans1[i][0] = '#';
	for (int i = 0; i < h; i += 2)for (int j = 0; j < w - 1; j++)ans1[i][j] = '#';
	for (int i = 0; i < h; i++)ans2[i][w - 1] = '#';
	for (int i = 1; i < h; i += 2)for (int j = 1; j < w; j++)ans2[i][j] = '#';
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)cout << ans1[i][j];
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++)cout << ans2[i][j];
		cout << endl;
	}
}

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;

int n, k, x, y;

int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }

    string str;
  //  cin >> n >> k >> x >> y;
    cin >> str;
    vector<int> cnt(26, 0);

    FOR(i, 0, str.size()) {
        cnt.at(str.at(i) - 'a')++;
    }
    string rs = "Yes";
    FOR(i, 0, cnt.size()) {
        if (1 == cnt.at(i) % 2) {
            rs = "No";
            break;
        }
    }
    cout << rs << endl;
    return 0;
}


Measured memory_bytes: 256
#coding: utf-8

_ = int(input())
array = list(map(int, input().split()))
currentMinI = 30 # log_2 pow(10, 9) = 9 log_2 10 ≒ 9/0.3010 = 29.9
for n in array:
    i = 0
    while i < currentMinI and (n & (1 << i)) == 0:
        i += 1
    currentMinI = min(currentMinI, i)
print(currentMinI)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    set<string> S;
    rep(i, N){
    string a; 
    cin >> a;
    S.insert(a);
    }

    
    cout << S.size() << endl;
}

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

using namespace std;

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> S(M);
	vector<int> C(M);
	for (int m = 0;m <M;m++){
		cin >> S[m];
		S[m] += -1 + (3-N);
		cin >> C[m];
	}
	int ans[3]={-1,-1,-1};
	int is = true;
	for (int m=0;m<M;m++){
		if (ans[S[m]] != -1 && ans[S[m]] != C[m]){
			cout << -1 << endl;
			return 0;
		}
		ans[S[m]] = C[m];
	}
	if (N==1){
		if (ans[2] == -1){
			cout << 0 << endl;
			return 0;
		}
		cout << ans[2] << endl;
		return 0;
	}
	if (N == 2){
		if (ans[1] == 0){
			cout << -1 << endl;
			return 0;
		}
		if (ans[1] == -1){
			ans[1] = 1;
		}
		if (ans[2] == -1){
			ans[2] = 0;
		}
		cout << ans[1] << ans[2] << endl;
		return 0;
	}
	if (N == 3){
		if (ans[0] == 0){
			cout << -1 << endl;
			return 0;
		}
		if (ans[0] == -1){
			ans[0] = 1;
		}
		if (ans[1] == -1){
			ans[1] = 0;
		}
		if (ans[2] == -1){
			ans[2] = 0;
		}
		cout << ans[0] << ans[1] << ans[2] << endl;
		return 0;
	}
	


	return 0;
}

Measured memory_bytes: 888
import java.util.Scanner

object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n, x = sc.nextInt()
    val s = for (_ <- 0 until n) yield sc.nextInt()
    (n, x, s.sorted)
  }


  def solve2(n: Int, x: Int, s: IndexedSeq[Int]): Long = {
    val ss = s.sorted
    val maxY = Math.max(x, ss.max)
    // dp: [0, n) * [0, maxY] => [0, infty)
    // dp(i, y) = (0 to i).map(ss).permutations.map(t => t.foldLeft(y)(_%_)).sum
    // dp(0, y) = y mod ss(0)
    // dp(i, y) = (i - 1) * dp(i - 1, y) + dp(i - 1, y mod ss(i))
    val mod = (1e9 + 7).toLong
    val initDP = IndexedSeq.tabulate(maxY + 1)(y => (y % ss(0)).toLong)
    val resultDP = (1 until n).foldLeft(initDP)((dp, i) =>
      IndexedSeq.tabulate(dp.length)(y => ((i * dp(y)) % mod + dp(y % ss(i))) % mod)
    )
    resultDP(x)
  }


  def main(args: Array[String]): Unit = {
    val (n, x, s) = read()
    println(solve2(n, x, s))
  }


  // ---以下実験用---

  // O(n!)愚直解
  def solve(n: Int, x: Int, s: IndexedSeq[Int]): Long = {
    s.permutations.map(t => t.foldLeft(x)(_ % _)).sum
  }

  def experiment(n: Int, x: Int, s: IndexedSeq[Int]): Unit = {
    s.permutations.map(t => (t, t.scanLeft(x)(_ % _))).foreach(println)
    s.permutations.map(t => (t, t.foldLeft(x)(_ % _))).foreach(println)
    s.permutations.map(t => t.foldLeft(x)(_ % _)).toIndexedSeq.groupBy(identity).map { case (e, xs) => (e, xs.length) }.foreach(println)
  }

  def experiment2(): Unit = {
    val n = 5
    val s = IndexedSeq(22, 11, 6, 5, 13)
    (0 until 200).foreach { x =>
      println(s"x=$x")
      s.permutations.map(t => t.foldLeft(x)(_ % _)).toIndexedSeq.groupBy(identity).map { case (e, xs) => (e, xs.length) }.foreach(println)
      println()
    }
  }

  def experiment3(): Unit = {
    val n = 5
    val s = IndexedSeq(22, 11, 6, 5, 13)
    (0 until 200).foreach { x =>
      println(s"x=$x, ans: ${solve(n, x, s)}")
    }
  }
}

Measured memory_bytes: 143608
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	
	bool f = false;
	for(int i = 0; i < n; i++) {
		int a; scanf("%d", &a);
		
		f += a % 2;
	}
	
	if(f) printf("first\n");
	else printf("second\n");
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std ;

int main() {

    int tes,s1,s2,s3,h,a,b;
    scanf("%d",&tes);
    while(tes-- > 0) {
        scanf("%d %d %d",&s1,&s2,&s3);
        if(s1 > s2) {
            h = s1 ;
            a = s2 ;
        }
        else {
            h = s2 ;
            a = s1 ;
        }
        if(h < s3) {
            b = h ;
            h = s3 ;
        }
        else {
            b = s3 ;
        }
        if(a*a + b*b == h*h) {
            puts("YES");
        }
        else {
            puts("NO");
        }
    }

}



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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int s,b,num;
  cin >> s;
  int a[1000000];
  for (int i = 0; i < 1000000; i++) {
    a[i] = 0;
  }
  a[s] = 1;
  num = s;
  for (int i = 1; i < 1000000; i++) {
    if (num % 2 == 0) {
      b = num/2;
    } else {
      b = 3*num+1;
    }
    num = b;
    // cout << num << endl;
    if (a[b] == 1) {
      cout << i+1 << endl;
      return 0;
    } else {
      a[b] = 1;
    }
  }
}


Measured memory_bytes: 4096
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //B
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for (int i = 0; i < n ;i++) {
    int sum = 0;
    for (int j = 0; j < m; j++) {
      int x;
      cin >> x;
      sum += x * b[j];
    }
    if (sum + c > 0) ans++;
  }
  cout << ans << endl;
  return 0;	
}

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

int main() {
    int N,m,n;
  n=0;
  m=0;
  cin >> N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
    if(H.at(i)>=m){
      n++;
      m=H.at(i);
    }
  }
    cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}




int main() {

	ll N;
	cin >> N;
	bool ch = false;
	ll k = 0;
	rep(i, N) {
		ll A, B;
		cin >> A >> B;
		if (A == B)k++;
		else k = 0;

		if (k == 3)ch = true;
	}

	if (ch)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 3568
//naru-hodo
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<time.h>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define ff first
#define ss second
#define ll long long 
#define ull unsigned long long
#define loop(i,x,n) for(int i=x; i<=n; i++)
#define rloop(i,x,n) for(int i=x; i>=n; i--)
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    loop(i,0,n-1) cin>>h[i];
    int m[n];
    m[0]=0;
    m[1]=abs(h[1]-h[0]);
    loop(i,2,n-1){
        m[i]=INT_MAX;
        int fin=i-k;
        if(fin<0) fin=0; 
        rloop(j,i-1,fin) m[i]=min(m[i],m[j]+abs(h[i]-h[j]));
    }
    cout<<m[n-1];
    return 0;
}

Measured memory_bytes: 1024
a=1
b=1
c=1
d=2
e=1
f=2
g=1
h=5
i=2
j=2
k=1
l=5
m=1
n=2
o=1
p=14
q=1
r=5
s=1
t=5
u=2
v=2
w=1
x=15
y=2
z=2
aa=5
ab=4
ac=1
ad=4
ae=1
af=51
zz=$(cat /dev/stdin)
if [ $zz -eq 1 ]; then
echo $a
elif [ $zz -eq 2 ]; then
echo $b
elif [ $zz -eq 3 ]; then
echo $c
elif [ $zz -eq 4 ]; then
echo $d
elif [ $zz -eq 5 ]; then
echo $e
elif [ $zz -eq 6 ]; then
echo $f
elif [ $zz -eq 7 ]; then
echo $g
elif [ $zz -eq 8 ]; then
echo $h
elif [ $zz -eq 9 ]; then
echo $i
elif [ $zz -eq 10 ]; then
echo $j
elif [ $zz -eq 11 ]; then
echo $k
elif [ $zz -eq 12 ]; then
echo $l
elif [ $zz -eq 13 ]; then
echo $m
elif [ $zz -eq 14 ]; then
echo $n
elif [ $zz -eq 15 ]; then
echo $o
elif [ $zz -eq 16 ]; then
echo $p
elif [ $zz -eq 17 ]; then
echo $q
elif [ $zz -eq 18 ]; then
echo $r
elif [ $zz -eq 19 ]; then
echo $s
elif [ $zz -eq 20 ]; then
echo $t
elif [ $zz -eq 21 ]; then
echo $u
elif [ $zz -eq 22 ]; then
echo $v
elif [ $zz -eq 23 ]; then
echo $w
elif [ $zz -eq 24 ]; then
echo $x
elif [ $zz -eq 25 ]; then
echo $y
elif [ $zz -eq 26 ]; then
echo $z
elif [ $zz -eq 27 ]; then
echo $aa
elif [ $zz -eq 28 ]; then
echo $ab
elif [ $zz -eq 29 ]; then
echo $ac
elif [ $zz -eq 30 ]; then
echo $ad
elif [ $zz -eq 31 ]; then
echo $ae
elif [ $zz -eq 32 ]; then
echo $af
fi

Measured memory_bytes: 536
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


def in_list():
    return (list(map(int, input().split())))


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9

n, m = in_ints()

a = in_list()

if n >= sum(a):
    print(n-sum(a))
else:
    print(-1)

Measured memory_bytes: 9876
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    vector<pair<string, pair<int, int> > > rest;
    FOR(i, 0, N) {
        string s;
        int score;
        cin >> s >> score;
        rest.push_back(make_pair(s, PAIR(-score, i + 1)));
    }
    sort(ALL(rest));

    for (auto& pr : rest)
        cout << pr.second.second << endl;
    return 0;
};


Measured memory_bytes: 256
import java.util.Scanner;

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

        for(int i = 1; ; i++) {
            int x = sc.nextInt();
            if(x == 0) break;

            System.out.println("Case " + i + ": " + x);
        }

    }
}

Measured memory_bytes: 42468
import Control.Applicative
import Data.Array.IO
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  s1 <- BS.getLine
  n <- return (case (C.readInt s1) of
                 Just x -> fst x
                 Nothing -> 0)
  nums <- newArray(0, 2100000) 0 :: IO(IOUArray Int Int)
  solve n nums 0 0

solve :: Int -> IOUArray Int Int -> Int -> Int -> IO ()
solve n nums left right = do
  if n == 0 then do { printanswer nums left right; return (); }
    else do {
    ss <- C.words <$> BS.getLine;
    if C.index (ss !! 0) 0 == 'i'
    then do {
      x <- return (case (C.readInt (ss !! 1)) of
                      Just s -> fst s
                      Nothing -> 0);
      writeArray nums right x;
      solve (n - 1) nums left (right + 1);
      return ();
      }
    else do {
      if C.length (ss !! 0) == 6
      then do {
        x <- return (case (C.readInt (ss !! 1)) of
                       Just s -> fst s
                       Nothing -> 0);
        deletex nums left right x;
        solve (n - 1) nums left right;
        return ();
        }
      else do {
        if C.index (ss !! 0) 6 == 'F' then do {
          right2 <- newright nums left right;
          solve (n - 1) nums left right2;
          }
        else do {
          left2 <- newleft nums left right;
          solve (n - 1) nums left2 right;
          }
        }
      }
    }

newright :: IOUArray Int Int -> Int -> Int -> IO Int
newright nums left right = do
  x <- readArray nums (right - 1);
  if x == (-1) then do {
    y <- newright nums left (right - 1);
    return y;
    }
    else do {
    return (right - 1);
    }

newleft :: IOUArray Int Int -> Int -> Int -> IO Int
newleft nums left right = do
  x <- readArray nums left;
  if x == (-1) then do {
    y <- newleft nums (left + 1) right;
    return y;
    }
    else do {
    return (left + 1);
    }

deletex :: IOUArray Int Int -> Int -> Int -> Int -> IO ()
deletex nums left right x = do
  if left >= right then return ()
    else do {
    y <- readArray nums (right - 1);
    if x == y then do {
      writeArray nums (right - 1) (-1);
      }
    else do {
      deletex nums left (right - 1) x;
      }
    }
  
printanswer :: IOUArray Int Int -> Int -> Int -> IO ()
printanswer nums left right = do
  if left >= right then do { putStrLn ""; return (); }
    else do {
    x <- readArray nums (right - 1);
    if x /= (-1) then do { putStr ((show x)); printanswer2 nums left (right - 1); } else printanswer nums left (right -1);
    }

printanswer2 :: IOUArray Int Int -> Int -> Int -> IO ()
printanswer2 nums left right = do
  if left >= right then do { putStrLn ""; return (); }
    else do {
    x <- readArray nums (right - 1);
    if x /= (-1) then putStr (" " ++ (show x)) else return ();
    printanswer2 nums left (right - 1);
    }

Measured memory_bytes: 81784
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++)
    cin>>a[i];
  if(count(a,a+3,5) == 2 && count(a,a+3,7) == 1)
    cout<<"YES";
  else
    cout<<"NO";
  
}

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

//dp[i][j][sum]：i番目までの中からj枚選んで総和がsumとなるような選び方の総数
ll dp[55][55][2505];
int main(){
	int n,a;
	cin >> n >> a;
	vector<int> x(n);
	rep(i,n){
		cin >> x[i];
	}
	
	//dp初期条件
	dp[0][1][x[0]] = 1;
	dp[0][0][0] = 1;
	
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= i+1 ; ++j) {
			for (int sum = 0; sum <= 2500 ; ++sum) {
				dp[i][j+1][sum+x[i]] += dp[i-1][j][sum]; //x[i]を選んだ場合
				dp[i][j][sum] += dp[i-1][j][sum]; //x[i]を選ばなかった場合
			}
		}
	}
	
	ll ans = 0;
	REP(j,n+1){
		ans += dp[n-1][j][j*a];
	}
	
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 53632
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");
   //  String nyu=sc.nextLine();


int num=Integer.parseInt(nyu[0]);
int numnext=Integer.parseInt(nyu[1]);


int count=(num+numnext)/2;
if(count*2==(num+numnext)){
System.out.println(count);

}else{
System.out.println("IMPOSSIBLE");

}



//System.out.println(count);

//System.out.println(a/b);


	}
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >>n;
  set<int> S;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    S.insert(a);
  }
  cout << *rbegin(S) - *begin(S) << endl;
}
  
  
  

Measured memory_bytes: 3596
// AOJ 1373: Placing Medals on a Binary Tree
// 2018.1.7 bal4u@uu

#include <stdio.h>

#define N 500000
int bit[500003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

void add(int i, int v)
{
    while (i <= N) bit[i] += v, i |= i+1;
}
 
int sum(int i)
{
    int s = 0;
    while (i) s += bit[i-1], i &= i-1;
    return s;
}

#define sub(a,b) (sum(a)-sum(b))

int main()
{
	int n, i, x, k, ans;

	k = 0;
	n = in(); while (n--) {
		x = in();
		ans = 1;
		if (sub(1, 0) == 1) ans = 0;
		else if (x >= N) k = 1;
		else if (sub(x+1, 0) < x) {
			for (i = x; sub(i+1, i); i--) add(i, -1); add(i, 1);
		} else if (sub(x+1, 0) == x) {
			if (k || sub(N, x+1)) ans = 0;
			else { for (i = 1; i <= x; i++) add(i, -1); add(0, 1); }
		}
		puts(ans? "Yes": "No");
	}
	return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
	int k[5],n,m,i,j,f=0;
	while (cin >> n) {
		if (f==0) f=1; else cout << endl;
		for (i=0,j=10000;i<5;i++,j/=10) k[i]=n/j % 10;
		for (i=0;i<2;i++) { 
			for (j=0;j<5;j++) if ((i==0 && k[j]<5) || (i==1 && k[j]>4)) cout << '*'; else cout << ' ';
			cout << endl;
		}
        cout << "=====" << endl;
		for (i=0;i<5;i++) {
			for (j=0; j<5; j++) {
				m=k[j]>4 ? k[j]-5 : k[j];
				if (m==i) cout << ' '; else cout << '*';
			}
			cout << endl;
		}
	}
 return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll w;
    cin>>w;
    vector<ll>weight(n);
    vector<ll>values(n);
    for(ll i = 0 ; i < n ;i++){
        cin>>weight[i]>>values[i];
    }
    vector<ll>dp(100001, 1e18);
    dp[0]=0;
    for(ll i = 0 ; i  < n ; i++){
        for(ll j = 100000 ; j >= values[i]; j--){
            if(dp[j-values[i]]!=1e9){
                dp[j] = min(dp[j], dp[j-values[i]]+weight[i]);
            }
        }
    }
    for(ll i = 100000; i>= 0;i--){
        if(dp[i]<=w){
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y.begin(), Y.end());
    int mid = Y[N / 2 - 1], next = Y[N / 2];
    for (int i = 0; i < N; i++) {
        cout << (X[i] > mid? mid: next) << endl;
    }
}



Measured memory_bytes: 3712
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int):
    tot = 0
    for i in range(1, N+1):
        if not (i % 5 == 0 or i % 3 == 0):
            tot += i
    print(tot)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int n;
vector<vector<pair<int,int>>> g;
vector<int> res;

void dfs(int v, int p, int c){
  res[v] = c;
  for(auto e:g[v]){
    if(e.first == p) continue;
    if(e.second & 1) dfs(e.first, v ,1-c);
    else dfs(e.first,v,c);
  }
}

int main(){
  cin >> n;
  g.assign(n,vector<pair<int,int>>());
  rep(i,n-1){
    int u,v,w; cin >> u >> v >> w;
    u--;v--;
    g[u].push_back(make_pair(v,w));
    g[v].push_back(make_pair(u,w));
  }
  res.assign(n,0);
  dfs(0,-1,1);
  for(auto v:res) cout << v <<endl;
  
  return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> d(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i != j) ans += d[i] * d[j];
    }
  }
  cout << ans / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  static final int N = 8;
  static boolean[] row = new boolean[N];
  static boolean[] col = new boolean[N];
  static boolean[] dpos = new boolean[2*N -1];
  static boolean[] dneg = new boolean[2*N -1];
  static boolean[][] X = new boolean[N][N];


  static void print_Board(){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        if(X[i][j]){
          if(j == N-1)
            System.out.println("Q");
          else
            System.out.print("Q");
          }
        else{
          if(j == N-1)
            System.out.println(".");
          else
            System.out.print(".");
        }
      }
    }
  }

  static void putQueen(int i){
    if(i == N){
      print_Board();
      return;
    }
    else{
      for(int j = 0; j < N; j++){
        if(X[i][j])
          putQueen(i+1);
        else if(col[j] || dpos[i+j] || dneg[i-j+N-1]){
          continue;
        }
        else{
          row[i] = true;
          col[j] = true;
          dpos[i+j] = true;
          dneg[i-j+N-1] = true;
          X[i][j] = true;
          putQueen(i+1);
          row[i] = false;
          col[j] = false;
          dpos[i+j] = false;
          dneg[i-j+N-1] = false;
          X[i][j] = false;
        }
      }
      return;
    }
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int k = stdIn.nextInt();

    for(int i = 0; i < N; i++){
      row[i] = false;
      col[i] = false;
    }
    for(int i = 0; i < 2*N-1; i++){
      dpos[i] = false;
      dneg[i] = false;
    }
    for(int i = 0; i < N; i++)
      for(int j = 0; j < N; j++)
        X[i][j] = false;

    for(int i = 0; i < k; i++){
      int x = stdIn.nextInt();
      int y = stdIn.nextInt();
      X[x][y] = true;
      row[x] = true;
      col[y] = true;
      dpos[x+y] = true;
      dneg[x-y+N-1] = true;
    }

    putQueen(0);

  }
}

Measured memory_bytes: 26348
#include <stdio.h>
int main(void) {
	int c=0,N, i[100],count=0;
	scanf("%d", &N);
	for (c = 1; c <= N;c++) {
		scanf("%d", &i[c]);
		if (c % 2 == 1&&i[c]%2==1) {
			count++;
		}
	}
	printf("%d", count);










	return 0;
}

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

int main(){
    long long int N;
    cin >> N;
    long long int i=0;
    while(true){
        if(N<pow(i,2)){
            i--;
            break;
        }else{
            i++;
        }
    }
    cout << (long long int)pow(i, 2) << endl;
    return 0;
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}

int maxn;
void out(int maxn,vector<vector<int>> &ans){
  int n=ans.size();
  cout << maxn+1 << ' ' << n << endl;
  for (auto i:ans) printf("%d %d %d\n",i[0]+1,min(maxn,i[1])+1,i[2]);
}

int main() {
  int L,diff=0,ix=1;
  cin >> L;
  L--;
  vector<vector<int>> ans;
  vector<int> memo(1,0);

  int p2=1;
  rep2(i,ix,30) {
    if (i>=ix+1) p2*=2;
    if (2*p2-1>L) {
      diff = p2;
      maxn=i-1;
      break;
    }
    ans.push_back({i-1,i,p2});
    ans.push_back({i-1,i,0});
    memo.push_back(p2);
    memo[i]+=memo[i-1];
  }
  if (L-diff==-1) {
    out(maxn,ans);
    return 0;
  }
  else {
    while (diff<=L){
      int k=L-diff;
      auto itr = upper_bound(memo.begin(),memo.end(),k);
      itr--;
      ans.push_back({itr-memo.begin(),60,diff});
      diff+=*itr+1;
    }
    out(maxn,ans);
    return 0;
    
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;


void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = k; i < n; ++i) {
        if (a[i] > a[i - k]) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>
#include <iostream>

#include <bits/stdc++.h>


using namespace std;

#define INPUT_INT(valName) int valName; cin >> valName
#define INPUT_LLINT(valName) long long int valName; cin >> valName;
#define INPUT_STR(valName) string valName; cin >> valName;
#define INPUT_LINE(valName) string valName; getline(cin,s);
#define INPUT_VECTOR_INT(valName, N) vector<int> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }
#define INPUT_VECTOR_DOUBLE(valName, N) vector<double> valName(N); for(int i=0; i < N; ++i) { cin >> valName[i]; }

#define OUTPUT(A) cout << (A) << endl;
#define OUTPUT2(A, B) cout << (A) << " " << (B) << endl;
#define OUTPUT3(A, B, C) cout << (A) << " " << (B) << " " << (C) << endl;

#define REP(valName, N) for(int valName = 0; valName < N; ++valName)

vector<string> split(const string& str, char delimiter) {
	vector<string> ret;
	string tmp = "";
	for (auto c : str) {
		if (c != delimiter) {
			tmp.push_back(c);
		} else {
			ret.push_back(tmp);
			tmp = "";
		}
	}
	ret.push_back(tmp);
	return ret;
}

template <typename T> void sortAsc(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> void sortDesc(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }

template <typename T> void insert(vector<T>& dest, const vector<T>& src) { copy(src.begin(), src.end(), back_inserter(dest)); }

template <long long int MOD> long long int mod_inv(long long int a) {
	long long b = MOD, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= MOD;
	if (u < 0) u += MOD;
	return u;
}

template <long long int MOD> long long int mod_add(long long int a, long long int b) {
	return (a + b) % MOD;
}

template <long long int MOD> long long int mod_sum(long long int a, long long int b) {
	return (a - b) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b) {
	return (a % MOD) * (b % MOD) % MOD;
}

template <long long int MOD> long long int mod_mul(long long int a, long long int b, long long int c) {
	return mod_mul<MOD>(a, mod_mul<MOD>(b, c));
}

template <long long int MOD> long long int mod_div(long long int a, long long int b) {
	return (a % MOD) * mod_inv<MOD>(b) % MOD;
}


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



int main() {

	// TODO: streamやめる

	cin.tie(0); ios::sync_with_stdio(false);

	INPUT_INT(N);
	INPUT_STR(S);

	set<string> nums1;
	set<string> nums2;
	set<string> nums3;

	for (int a = 0; a < N - 2; ++a) {

		string s1 = S.substr(a,1);
		if (nums1.count(s1) > 0) { continue; }
		nums1.insert(s1);

		for (int b = a+1; b < N - 1; ++b) {
			string s2 = s1 + S.substr(b, 1);
			if (nums2.count(s2) > 0) { continue; }
			nums2.insert(s2);

			for (int c = b + 1; c < N - 0; ++c) {
				string s3 = s2 + S.substr(c, 1);
				if (nums3.count(s3) > 0) { continue; }
				nums3.insert(s3);
			}

		}
	}

	OUTPUT(nums3.size());

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> as(n);
  for (auto &v : as)
    cin >> v;
  vector<bool> visited(n, false);

  int cur = 0;
  int ans = 0;
  bool flag = false;

  while (not visited[cur]) {
    ++ans;
    visited[cur] = true;
    cur = as[cur] - 1;
    if (cur == 1) {
      flag = true;
      break;
    }
  }

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


Measured memory_bytes: 3796
import java.io.*;
import java.util.*;

public class Main implements Runnable {
	public static void main (String[] args) {new Thread(null, new Main(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("");

		int n = fs.nextInt();
		int[] a = fs.nextIntArray(n);
		boolean yes = true;
		a[0]--;
		for(int i = 1; i < n; i++) {
			if(a[i]-1 >= a[i-1]) {
				a[i]--;
			}
			if(a[i] < a[i-1]) yes = false;
		}
		out.println(yes ? "Yes" : "No");
		
		out.close();
	}

	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) {
			try {
				in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
			}
			catch (Exception e) {
				in = new BufferedInputStream(System.in, BS);
			}
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Measured memory_bytes: 25684
sx, sy, tx, ty = map(int, input().split())
one = 'R'*(tx-sx)+'U'*(ty-sy)
two = 'L'*(tx-sx)+'D'*(ty-sy)
three = 'D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'
four = 'U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R'
print(one+two+three+four)

Measured memory_bytes: 3060
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	int x,n;
	cin>>x>>n;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans=123,diff=113;
	for(int i=0;i<=101;i++)
	{
		int f=1;
		for(int j=0;j<n;j++)  //4 7 10 6 5
		{
			if(i==a[j])
			{
				f=0;break;
			}
		}
		if(f)
		{
			if(diff>abs(x-i)){
				ans=i;
				diff=abs(x-i);
			}
		}
	}
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

vector<vp> g;
int n,m;

vi dijkstra(int s){
    priority_queue<pi,vp,greater<pi>> q;
    vi d(n,inf);
    d[s]=0;
    q.push({0,s});
    while(!q.empty()){
        pi p=q.top();q.pop();
        int v=p.se;
        if(d[v]<p.fi)continue;
        rep(i,g[v].size()){
            pi e=g[v][i];
            if(d[e.fi]>d[v]+e.se){
                d[e.fi]=d[v]+e.se;
                q.push({d[e.fi],e.fi});
            }
        }
    }
    return d;
}

int solve(int s,int t){
    vi d1=dijkstra(s),d2=dijkstra(t);
    int l=d1[t];
    vi a1(l+1),a2(l+1);
    rep(i,n){
        if(d1[i]<=l)a1[d1[i]]++;
        if(d2[i]<=l)a2[d2[i]]++;
    }
    int ret=0;
    REP(i,0,l-2){
        ret+=a1[i]*a2[l-i-2];
    }
    return ret;
}

void run(){
    int s,t;
    cin>>n>>m>>s>>t;
    s--,t--;
    g=vector<vp>(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--,y--;
        g[x].pb({y,1});
        g[y].pb({x,1});
    }
    cout<<solve(s,t)<<endl;
}


Measured memory_bytes: 16960
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define pr1(x) cout<<"[" << #x << ": " << x << "] \n";
#define pr2(x, y) cout<<"[" << #x << ": " << x <<", "<< #y << ": " << y <<"] \n";
#define mod 1000000007
#define int long long
#define sz(v) (int)(v).size()

void solve() {
        int n; cin >> n;
        if (n>= 30) cout << "Yes\n";
        else cout << "No\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3636
from sys import exit
A, B, C, D = map(int, list(input()))
ops = ["+", "-"]
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            expr = "{0}{1}{2}{3}{4}{5}{6}".format(A, op1, B, op2, C, op3, D)
            if eval(expr) == 7:
                print(expr + "=7")
                exit()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<ll> a;
  for(ll i = 1ll; i*i <= m; i++){
    if(m%i) continue;
    a.emplace_back(i);
    a.emplace_back(m/i);
  }
  sort(ALL(a));
  ll ans = 0;
  for(ll d : a) if(n*d <= m) chmax(ans, d);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 764
import java.util.*

fun main() {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextInt()
    val mod = (1e9+7).toLong()

    fun exp(a:Int, b:Int): Long {
        if(b == 0) return 1L
        if(a == 0 || a== 1) return a.toLong()
        var ret = exp(a, b / 2)
        ret *= ret
        ret %= mod
        if(b % 2 == 0) return ret
        ret *= a.toLong()
        ret %= mod
        return ret
    }

    val gcd = LongArray(k + 1)

    for(d in k downTo 1) {
        val v = k / d
        var cnt = exp(v, n)
        var i = 2
        while (d * i <= k) {
            cnt = (cnt - gcd[d * i] + mod) % mod
            ++i
        }
        gcd[d] = cnt
    }
    var ans = 0L
    for(i in 1..k) {
        ans += i * gcd[i]
        ans %= mod
    }
    print(ans)

}

Measured memory_bytes: 37480
#include <stdio.h>
#include <string.h>
#define ROW_BLOCK 4
#define COL_BLOCK 4
#define ROW_NUM (ROW_BLOCK + 2) * 2 - 1
#define COL_NUM (COL_BLOCK + 2) * 2 - 1
#define UP 0
#define RIGHT 1
#define DOWN 2
#define LEFT 3

const char command[5] = "URDL";
const int dy[4] = {-1,0,1,0}, dx[4] = {0,1,0,-1};
const int gy = 1, gx = 1;

int main(void){
	int i, j, stage[ROW_NUM][COL_NUM];
	memset(stage,0,sizeof(stage));
	for(i = 1;i < ROW_NUM - 1;i++){
		char str[ROW_BLOCK + 2];
		scanf("%s",str);
		for(j = 1 + i % 2;j < COL_NUM - 1;j+=2){
			stage[i][j] = str[(j - 1) / 2] - '0';
		}
	}
	int nd = RIGHT, nx = 1, ny = 1;
	do{
		if(stage[ny + dy[nd]][nx + dx[nd]] == 0 && stage[ny + dy[(nd + 3) % 4]][nx + dx[(nd + 3) % 4]] == 0){ // 今向いている方向に壁がなく右手にも壁がなければれば
			nd = (nd + 1) % 4;
		}else if(stage[ny + dy[(nd + 3) % 4]][nx + dx[(nd + 3) % 4]] == 1){
			nd = (nd + 3) % 4;
			ny += dy[nd] * 2;
			nx += dx[nd] * 2;
			printf("%c",command[nd]);
		}else{
			ny += dy[nd] * 2;
			nx += dx[nd] * 2;
			printf("%c",command[nd]);
		}

		/*for(i = 0;i < ROW_NUM;i++){
			for(j = 0;j < COL_NUM;j++){
				if(ny == i && nx == j){
					printf("# ");
				}else{
					printf("%d ",stage[i][j]);
				}
			}
			printf("\n");
		}
		while(getchar() != '\n');*/
	}while(!((nx == gx) && (ny == gy)));
	printf("\n");
	return 0;
}

Measured memory_bytes: 928
r, g, b, n = map(int, raw_input().split(" "))

ans = 0
for tmp_r in range(0, 3001):
    if r * tmp_r > n:
        break
    for tmp_g in range(0, 3001):
        if r * tmp_r + g * tmp_g > n:
            break
        if (n - (r * tmp_r + g * tmp_g)) % b == 0:
            ans += 1

print(ans)


Measured memory_bytes: 2820
import java.util.*;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }
    void run() {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next()),
            M = Integer.parseInt(sc.next());
        int[] a = new int[N],
              b = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
        }

        int[] c = new int[M],
              d = new int[M];
        for (int i = 0; i < M; i++) {
            c[i] = Integer.parseInt(sc.next());
            d[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N; i++) {
            int checkPoint = 0;
            for (int j = 0; j < M; j++) {
                if (Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]) <
                        Math.abs(a[i] - c[checkPoint]) + Math.abs(b[i] - d[checkPoint])) {
                    checkPoint = j;
                }
            }
            System.out.println(checkPoint + 1);
        }
    }
}

Measured memory_bytes: 21844