akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		while(!primeNumber(x)){
			x++;
		}
		System.out.println(x);
		saori.close();
	}
	public static boolean primeNumber(int n){
		for(int i = 2; i < n; i++) {
            if(n % i == 0) {
                return false;
            }
		}
		return true;
	}
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int V,E;
double P,Q;
vector<int> G[15];
 
 
void printbit(int S){
  for(int i=0;i<V;i++){
    cout<<(S>>i&1)<<' ';
  }
  cout<<endl;
}
 
double func(int S,int U){
 
  double res=1;
  for(int i=0;i<V;i++){
    if(S>>i&1){
      for(int j=0;j<(int)G[i].size();j++){
        int w=G[i][j];
        if(S>>w&1)continue;
        if(U>>w&1)        res*=P;
      }
    }
  }
 
 
 
  return res;
}
 
double dp[(1<<14)];
 
double rec(int S){
 
  if(dp[S]!=-1)return dp[S];
  if(S==1)return 1.0;
 
  double res=0;
  int sup=S;
  int sub=sup;
  
 
  do{
    if(sub&1){
      if(sub!=S){
        double A=rec(sub);
        double B=func(sub,S);
        res+=A*B;
      }
    }
    sub=(sub-1)&sup;
  }while(sub!=sup);
 
  res=1.0-res;
 
  return dp[S]=res;
}
 
void init(){
  for(int i=0;i<15;i++)G[i].clear();
  for(int i=0;i<(1<<14);i++){
    dp[i]=-1;
  }
}
 
 
bool check(){
  bool visited[15]={};
  visited[0]=true;
  queue<int> que;
  que.push(0);
 
  while(!que.empty()){
    int pos=que.front();que.pop();
    for(int i=0;i<(int)G[pos].size();i++){
      int w=G[pos][i];
      if(visited[w])continue;
      visited[w]=true;
      que.push(w);
    }
  }
 
  for(int i=0;i<V;i++)
    if(!visited[i])return false;
 
  return true;
}
 
int main(){
  while(cin>>V>>E>>P){
    init();
    P/=100.0;
    Q=1.0-P;
    for(int i=0;i<E;i++){
      int a,b;
      cin>>a>>b;
      a--;b--;
      G[a].push_back(b);
      G[b].push_back(a);
    }
 
    if(!check()){
      printf("0.0\n");
      continue;
    }
    printf("%.10f\n",rec((1<<V)-1));
  }
  return 0;
}

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

class Program
{
  static void Main(string[] args)
  {

    var line = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
    var H = line[0];
    var W = line[1];
    var K = line[2];

    var dp = new int[H + 1, W];
    dp[0, 0] = 1;
    for (var hi = 0; hi < H; hi++)
    {
      for (var wi = 0; wi < W; wi++)
      {
        for (var bit = 0; bit < (1 << (W - 1)); bit++)
        {
          var invalid = false;
          for (var i = 0; i < W - 2; i++)
          {
            if ((bit & (1 << i)) != 0 && (bit & (1 << (i + 1))) != 0)
            {
              invalid = true;
            }
          }
          if (invalid) continue;

          var mod = 1000000007;
          if ((bit & (1 << (wi - 1))) != 0 && wi - 1 >= 0)
          {
            dp[hi + 1, wi - 1] += dp[hi, wi];
            dp[hi + 1, wi - 1] %= mod;
          }
          else if ((bit & (1 << wi)) != 0 && wi + 1 < W)
          {
            dp[hi + 1, wi + 1] += dp[hi, wi];
            dp[hi + 1, wi + 1] %= mod;
          }
          else
          {
            dp[hi + 1, wi] += dp[hi, wi];
            dp[hi + 1, wi] %= mod;
          }
        }
      }
    }

    Console.WriteLine(dp[H, K - 1]);
  }
}


Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



vector< vci > solve(int n) {
	vector< vci > ret(n, vci(n, -1));
	int y = n/2 + 1, x = n/2;
	ret[y][x] = 1;
	
	for_(i, 2, n*n+1) {
		y = (y + 1)%n; x = (x + 1)%n;
		
		while (ret[y][x]!=-1) {
			y = (y+1)%n; x = (x-1 + n)%n;
		}
		
		ret[y][x] = i;
	}
	
	return ret;
}

int main() {
	int n;
	
	while (1) {
		cin >> n; if (n==0) break;
		
		vector< vci > ans = solve(n);
		
		for_(i, 0, n) {
			for_(j, 0, n) {
				printf("%4d", ans[i][j]);
			}
			cout << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1244
import math
N = int(input())
a_array = list(map(int,input().split()))
ans_array = [] 
now_ball_array = [0] * N

for i in range(N-1,-1,-1):
    if a_array[i] != now_ball_array[i]:
        ans_array.append(str(i+1))
        box_root = math.ceil(math.sqrt(i+1))
        if box_root * box_root == (i+1):
            now_ball_array[box_root-1] = (now_ball_array[box_root-1] + 1) % 2  
        for j in range(1,box_root):
            if (i+1) % j == 0:
                now_ball_array[j-1] = (now_ball_array[j-1] + 1) % 2 
                now_ball_array[(i+1)//j-1] = (now_ball_array[(i+1)//j-1] + 1) % 2  
    # print(now_ball_array)
print(len(ans_array))
if len(ans_array):
    print(" ".join(ans_array))

Measured memory_bytes: 78064
#include<bits/stdc++.h>
using namespace std;
int prime[303]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,
149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,
317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,
509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,
719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,
937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,
1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,
1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,
1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,
1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,
1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999},n,k,cnt[303],xx[10003];
long long C(long long x,long long y){
	y=min(y,x-y);
	long long ans=1;
	for(int i=0;i<y;i++)xx[i]=x-i;
	for(int i=1;i<=y;i++){
		long long tmp=i;
		for(long long xxx=0;xxx<303;xxx++)
			while(tmp%prime[xxx]==0)
				tmp/=prime[xxx],
				cnt[xxx]++;
	}
	for(long long i=0;i<y;i++)
		for(long long xxx=0;xxx<303;xxx++)
			while(cnt[xxx]&&xx[i]%prime[xxx]==0)
				cnt[xxx]--,
				xx[i]/=prime[xxx];
	for(long long i=0;i<y;i++)ans=(ans*xx[i])%1000000007;
	return ans;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++)
		if(i+1<=n-k+2)
			printf("%lld\n",(C(k-1,i-1)*C(n-k+1,i))%1000000007);
		else
			printf("0\n");
}

Measured memory_bytes: 384
import copy
N, M = map(int, input().split())
INF = 2 ** 63 - 1
d = [[INF for i in range(N+1)] for j in range(N+1)]
for i in range(N+1):
    d[i][i] = 0

for i in range(M):
    a, b, c = map(int, input().split())
    d[a][b] = c
    d[b][a] = c

d_original = copy.deepcopy(d)

for k in range(1, N+1):
    for j in range(1, N+1):
        for i in range(1, N+1):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if d_original[i][j] != INF and d[i][j] != d_original[i][j]:
            ans += 1
print(ans)


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

#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

const int N = 110;
const int Mod = 1e9 + 7;

int A[N], n;
int dp[N][N][N];

void add(int &x, int y){
	x += y;
	if(x >= Mod) x -= Mod;
}

int main(){

	scanf("%d", &n);
	For(i, 1, 2 * n - 1) scanf("%d", &A[i]);
	sort(A + 1, A + 2 * n);

	dp[0][1][1] = 1;
	For(i, 1, n - 1){
		bool a = A[n - i] ^ A[n - i + 1], b = A[n + i] ^ A[n + i - 1];

		For(j, 1, 2 * i - 1) For(k, 1, j){
			int val = dp[i - 1][j][k];
			if(!val) continue;

			For(u, a ^ 1, k - 1) add(dp[i][j + a + b - (k - u - 1)][u + a], val);
			add(dp[i][j + a + b][k + a], val);
			For(u, k + 1, j + b) add(dp[i][j + a + b - (u - k - 1)][u + a - (u - k - 1)], val);
		}
	}

	int ans = 0;
	For(j, 1, 2 * n - 1) For(k, 1, j)
		add(ans, dp[n - 1][j][k]);
	printf("%d\n", ans);

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
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;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>



int main(){
    ll N,K,S; cin>>N>>K>>S;
    ll ans[N];
    for(int i=0;i<K;++i){
        ans[i] = S;
    }
    if(S==pow(10,9)){
        for(int i=K;i<N;++i){
            ans[i] = 1;
        }
    }else{
        for(int i=K;i<N;++i){
            ans[i] = S+1;
        }
    }
    REP(i,N){
        if(i<N){printf("%Ld ",ans[i]);}
        else{ printf("%Ld\n",ans[i]); }
    }
}

Measured memory_bytes: 2048
// Problem : E - Multiplication 4
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

int zeroes;
vector<int> pos;
vector<int> neg;

void report(int ns, int ps) {
    int ans = 1;
    rep(i, ns) ans = 1ll * ans * neg[neg.size()-i-1] % MOD;
    rep(i, ps) ans = 1ll * ans * pos[pos.size()-i-1] % MOD;
    if(ns % 2) ans = (MOD - ans) % MOD;
    cout << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    rep(i, n) {
        int k; cin >> k;
        if(!k) zeroes++;
        else if(k < 0) neg.pb(-k);
        else pos.pb(k);
    }
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());
    int ns = 0, ps = 0;
    while(ns + ps != k) {
        if((ps != pos.size()) && (ns == neg.size() || neg[neg.size()-ns-1] < pos[pos.size()-ps-1])) ps++;
        else if(ns != neg.size()) ns++;
        else { cout << 0 << endl; return 0; }
    }
    if(!(ns%2)) report(ns, ps);
    else{
        ll d1 = 1, n1 = 0;
        ll d2 = 1, n2 = 0;
        if(ns && ps != pos.size()) {
            d1 = neg[neg.size()-ns];
            n1 = pos[pos.size()-ps-1];
        }
        if(ns != neg.size() && ps) {
            d2 = pos[pos.size()-ps];
            n2 = neg[neg.size()-ns-1];
        }
        if(n1 == 0 && n2 == 0) {
            if(zeroes) cout << 0 << endl;
            else { reverse(pos.begin(), pos.end()); reverse(neg.begin(), neg.end()); report(ns, ps); }
        } else {
            if(n1 == 0) report(ns+1, ps-1);
            else if(n2 == 0) report(ns-1, ps+1);
            else {
                ll vv1 = n1*d2;
                ll vv2 = n2*d1;
                if(vv1 > vv2) report(ns-1, ps+1);
                else report(ns+1, ps-1);
            }
        }
    }
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int a, b, c, d;

//解法
void solve() {

	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return;
}

int main() {
	//入力
	cin >> a >> b >> c >> d;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
    int n, m;
    std::cin >> n >> m;

    int a, b;
    std::vector<std::vector<int>> roads(2 * m, std::vector<int>(2));
    std::vector<int> road(2);
    for(int i = 0; i < m; ++i){
        std::cin >> a >> b;
        road.at(0) = a;
        road.at(1) = b;
        roads.at(i) = road;
        road.at(0) = b;
        road.at(1) = a;
        roads.at(i + m) = road;
    }

//    std::sort(roads.begin(), roads.end());
//    roads.erase(std::unique(roads.begin(), roads.end()), roads.end());

    int counter;
    for(int i = 1; i <= n; ++i){
        counter = 0;
        for(int j = 0; j < roads.size(); ++j){
            if(i == roads.at(j).at(0)){
                ++counter;
            }
        }

        std::cout << counter << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto i = (m).begin(); i != (m).end(); ++i)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, K;
  vector<ll> A;
  cin >> N >> K;
  REP(i, N) {
    ll po;
    cin >> po;
    A.push_back(po);
  }
  sort(ALL(A));
  ll m = llINF;
  for (int i = 0; i <= N - K; i++) {
    if (A[i + K - 1] - A[i] < m) {
      m = A[i + K - 1] - A[i];
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 1400
package main

import "fmt"

import "sort"

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}
	p2 := make([]int, n)
	copy(p2, p)

	sort.Ints(p2)

	cnt := 0
	for i := 0; i < n; i++ {
		if p2[i] < p[i] {
			cnt++
			if cnt == 2 {
				fmt.Println("NO")
				return
			}
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std ;
using namespace  __gnu_pbds ;
using namespace __gnu_cxx ;

typedef long long ll ;
typedef long double ld ;

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

typedef vector<int> vi ;
typedef vector<ll> vll ;
typedef vector<pii> vpi ;
typedef vector<pll> vpl;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define per(i,b,a) for (int i = (b); i >= (a); i--)

#define mp make_pair
#define eb emplace_back
#define pb push_back
#define fi first
#define se second

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD1 = 1000000007 ;
const int MOD2 = 998244353 ;
const ll  INFL = 1e18 ;
const int INFI = 2e9 ;
const int MAXN = 100005 ;
const int LOGN = 30 ;
const int ALPHA = 27 ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ;

ll modpow(ll a, ll b, int MOD) { ll res = 1 ; while(b) { if(b&1) { res = res*a ; res %= MOD ; } a *= a ; a %= MOD ; b >>= 1 ; } return res%MOD ; }
void upmin(int &a, int b) { if(a < b) { a = b ; } }
void relax(int &a, int b) { if(a > b) { a = b ; } }
ll add(ll a, ll b, int MOD) { a += b ; if(a >= MOD) { a -= MOD ; } return  a ; }
ll subtract(ll a, ll b, int MOD) { a -= b ; if(a < 0) { a += MOD ; } return a ; }
ll multiply(ll a, ll b, int MOD) { b %= MOD ; a *= b ; a %= MOD ; return a ; }

int n ;
int m ;
pair<int, pair<int, ll> > edges[MAXN] ;
ll stree[2*MAXN] ;
void init() {
     rep(i,n,2*n-1) {
        stree[i] = INFL ;
     }
     per(i,n-1,1) {
         stree[i] = min(stree[2*i], stree[2*i+1]) ;
     }
     stree[n] = 0 ;
}
void update(int l, int r, ll v) {
     l += n ;
     r += n ;
     while(l < r) {
        if(l&1) {
            stree[l] = min(stree[l], v) ;
            l++ ;
        }
        if(r&1) {
            r-- ;
            stree[r] = min(stree[r], v) ;
        }
        l /= 2 ;
        r /= 2 ;
     }
}
ll query(int l) {
   ll res = INFL ;
   l += n ;
   while(l) {
         res = min(res, stree[l]) ;
         l /= 2 ;
   }
   return res ;
}
int main() {
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> n >> m ;
    rep(i,0,m-1) {
        cin >> edges[i].fi >> edges[i].se.fi >> edges[i].se.se ;
        edges[i].fi-- ;
        edges[i].se.fi-- ;
    }
    sort(edges,edges+m) ;
    init() ;
    rep(i,0,m-1) {
        int l = edges[i].fi ;
        int r = edges[i].se.fi ;
        ll cost = edges[i].se.se ;
        ll delta = query(l) ;
        if(delta == INFL) {
            cout << "-1\n" ;
            return 0 ;
        }
        ll real_cost = cost + delta ;
        update(l+1, r+1, real_cost) ;
    }
    ll res = query(n-1) ;
    if(res == INFL) {
        cout << "-1\n" ;
        return 0  ;
    }
    cout << res << endl ;
}


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

using namespace std;

typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for(int i = 0; i < n;i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int sol = 0;
	for(int i = 0; i < k; i++){
		sol += v[i];
	}
	cout << sol << '\n';
}


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

using namespace std;

const long long INF = 1e18;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int k, x;
    cin >> k >> x;
    for (int ans = x - k + 1; ans < x + k; ans++)
        cout << ans << ' ';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

void decitobinbitodeci()
{
    string binary = bitset<8>(128).to_string(); //to binary
    cout<<binary<<"\n";

    unsigned long decimal = bitset<8>(binary).to_ulong();
    cout<<decimal<<"\n";
}

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

/*
1.always remember for ncr(n,2), you can calculate by->
n*(n-1)/2
2.Power of 2 ->  (1ll<<i)
*/

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b,c,d,e=0,f=0;
    cin>>a>>b>>c>>d;
    e=min(d,a)*1;;
    d-=e;
    if(d>0)
    {
        d-=min(d,b);
    }
    if(d>0)
    {
        ll x=min(d,c)*-1;
        e+=x;
    }
    cout<<e<<endl;
}

/*Remember Remember, if you are so much excited that
your mind is shaking,
this is not the last contest that you are proceeding now,
if Almighty wants,
time will come.*/


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
const ll INF = 1e11+10;
int main(){
  int N;
  cin >> N;
  ll W;
  cin >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  for(int i = 0;i < N;i++)cin >> w[i] >> v[i];

  //dp[i][j]は,i番目までの品物を用いて価値jを達成する場合の重みの最小値.
  vector<vector<ll>> dp(N+1,vector<ll>(100000,INF));
  dp[0][0] = 0;

  //上限(枝刈り)
  vector<ll> M(N+1);
  M[0] = 0;
  for(int i = 0;i < N;i++)M[i+1] = M[i] + v[i];

  for(int i = 1;i <= N;i++){
    for(int j = 0;j <= M[i];j++){
      if(j < v[i-1])dp[i][j] = dp[i-1][j];
      else dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]] + w[i-1]);
    }
  }

  ll ans = 0;
  for(int i = 0;i <= M[N];i++){
    if(dp[N][i] <= W)ans = i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 80256
<?php
// 空白で区切られたのを配列に格納
$arr_1 = explode(' ', trim(fgets(STDIN)));
$arr_2 = explode(' ', trim(fgets(STDIN)));

// 休み日数と宿題個数を取得
$vacaation_days = $arr_1[0];
$count_of_homework = $arr_1[1];

//各宿題ごとの所用日数
$working_date = array_sum($arr_2);

//休暇日数>所用日数
if($vacaation_days >= $working_date){
  $hangout_days = $vacaation_days - $working_date;
} else {
  $hangout_days = -1;
}
echo $hangout_days;



Measured memory_bytes: 17024
#include <stdio.h>
int main (void){
int x,y,z[10001],i[10001],j,k;

for (y=0;y<10000;y++){
z[y]=0;
i[y]=0;
}

for (y=1;y<10001;y++){
 scanf ("%d",&z[y]);
	if (z[y]==0){
	break;
}

i[y]=i[y-1]+1;

}

for (y=1;y<10001;y++){
if (z[y]==0){
break;
}
printf("Case %d: %d\n",i[y],z[y]);

}

return 0;
}

Measured memory_bytes: 672
#include <bits/stdc++.h>
using namespace std;
int A[2][500005];
string S[2];
void Z(int x){
	A[x][0] = S[x].size();
	int i=1,j=0;
	while(i<S[x].size()){
		while(i+j<S[x].size() && S[x][j]==S[x][i+j])j++;
		A[x][i]=j;
		if(j==0){
			i++; continue;
		}
		int k = 1;
		while(i+k<S[x].size() && k+A[x][k]<j) A[x][i+k]=A[x][k],++k;
		i+=k;j-=k;
	}
}
vector<int>v[500005];
bool bad[500005],bad2[500005];
int main(){
	cin >> S[0];
	reverse(S[0].begin(),S[0].end());
	S[1] = S[0];
	reverse(S[0].begin(),S[0].end());
	Z(0); Z(1);
	for(int i=1;i<500005;i++)for(int j=2*i;j<500005;j+=i)v[j].push_back(i);
	for(int i=0;i<S[0].size();i++){
		for(int x=0;x<v[i+1].size();x++){
			int a = v[i+1][x];
			if(A[0][a] >= i+1-a){
				bad[i] = 1; break;
			}
		}
	}
	for(int i=0;i<S[1].size();i++){
		for(int x=0;x<v[i+1].size();x++){
			int a = v[i+1][x];
			if(A[1][a] >= i+1-a){
				bad2[i] = 1; break;
			}
		}
	}
	if(!bad[S[0].size()-1]){
		cout << 1 << endl << 1 << endl;
	}
	else{
	    int ans=0;
		for(int i=1;i<S[0].size();i++){
			if(!bad[i-1] && !bad2[S[0].size()-i-1]) ans++;
		}
		if(!ans) cout << S[0].size() << endl << 1 << endl;
		else cout << 2 << endl << ans << endl;
	}
}

Measured memory_bytes: 61732
s = input()
ans = "NO"
if s[:7] == "keyence" or s[-7:] == "keyence": ans = "YES"
elif len(s) >= 7:
    k = "keyence"
    for i in range(len(s)):
        if k[i] == s[i]: continue
        else: break
    if s[:i]+s[-(7-i):] == "keyence": ans = "YES"
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
int main() {
  string a;
  cin >> a;
  
  if (a[0] == a[1] && a[0]== a[2]) cout << "Yes" << endl; 
  else if (a[1] == a[2] && a[1]== a[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n,tem,ans=0,i;
	cin>>n;
	for(i=1;i*(i+2)<=n;i++)
		if(n%i==0)
			ans+=(n-1)/i;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int h, w, k;
	cin >> h >> w >> k;
	int ans = 0;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	rep(i, (1 << h)) {
		rep(j, (1 << w)) {
			vector<string> t = s;
			rep(x, h) {
				if ((i >> x) & 1) {
					rep(y, w) t[x][y] = '.';
				}
			}
			rep(y, w) {
				if ((j >> y) & 1) {
					rep(x, h) t[x][y] = '.';
				}
			}
			int cnt = 0;
			rep(x, h) rep(y, w) if (t[x][y] == '#') cnt++;
			if (cnt == k) ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3660
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();
        for(int i = 0; i < n; i++) {
            if(i != 0) System.out.print(" ");
            System.out.print(a[n - i - 1]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26252
n,a,b,c,d=map(int,input().split())
s=input()
def ok(p,q,s):
    return s[p-1:q].count("##")==0
if a<c<b<d:
    if ok(a,c,s) and ok(b,d,s):
        print("Yes")
    else:
        print("No")
elif a<b<c<d:
    if ok(a,c,s) and ok(b,d,s):
        print("Yes")
    else:
        print("No")
elif a<b<d<c:
    if ok(b,d,s):
        s=s[:b-1]+"#"+s[b:]
        if ok(a,c,s):
            print("Yes")
        else:
            s=s[:b-1]+"."+s[b:]
            if s[b-1:d+1].count("...")>0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")

Measured memory_bytes: 43888
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int n ,k ;
int main()
{
    cin >> n >> k;
    int ans =0 ;
    while (n)
    {
        ans++;
        n/=k;
    }
    cout << ans <<"\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
int N,sum=0,hikaku=10000;
  
  cin>>N;
  
  for(int i=0;i<N;i++)
  {
    int A;
    cin>>A;
   
    for(sum=0;A%2==0;)
    {
      A/=2;
      sum++;
    }
    if(sum<=hikaku)
      {
      hikaku = sum;
      }
  }
 
  cout<<hikaku<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,i,ai[1000];
    while(cin>>n){
        for(i=0;i<n;++i){
            cin>>ai[i];
        }
        for(i=n-1;i>=0;--i){
            if(i==0){cout<<ai[i];}
            else cout<<ai[i]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3104
ACGT = ['A', 'C', 'G', 'T']


def not_acgt(s):
    for c in s:
        if c not in ACGT:
            return False

    return True


def main():
    S = input()

    results = []
    # all_results = []
    for i in range(len(S)):
        for j in range(len(S)):
            if not_acgt(S[i:j+1]):
                results.append(S[i:j+1])
            # all_results.append(S[i:j+1])
    try:
        print(max([len(s) for s in results]))
    except Exception:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define Rep(i,v) rep(i,0,(int)v.size()-1)
#define lint long long
#define db double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;typedef pair<int,int> pii;const int N=200010;const db PI=acos(-1.0),R=10.0,L=100.0;
inline int inn() { int x,ch;while((ch=gc)<'0'||ch>'9');x=ch^'0';while((ch=gc)>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^'0');return x; }
struct segment { int l,r,v;segment *ch[2]; }*rt;pii p[N];vector<int> v;
int build(segment* &rt,int l,int r)
{
	rt=new segment,rt->l=l,rt->r=r,rt->v=0;
	if(l==r) return 0;int mid=(l+r)>>1;
	return build(rt->ch[0],l,mid),build(rt->ch[1],mid+1,r);
}
int update(segment* &rt,int p,int v)
{
	int l=rt->l,r=rt->r,mid=(l+r)>>1;
	if(l==r) return rt->v=v;
	if(p<=mid) update(rt->ch[0],p,v);
	else update(rt->ch[1],p,v);
	return rt->v=max(rt->ch[0]->v,rt->ch[1]->v);
}
int query(segment* &rt,int s,int t)
{
	int l=rt->l,r=rt->r,mid=(l+r)>>1;
	if(s<=l&&r<=t) return rt->v;int ans=0;
	if(s<=mid) ans=max(ans,query(rt->ch[0],s,t));
	if(mid<t) ans=max(ans,query(rt->ch[1],s,t));
	return ans;
}
#define rev(y) (y=-y)
int main()
{
	int x1=inn(),y1=inn(),x2=inn(),y2=inn(),n=inn(),revt=0,cnt=0,ans=0,x,y,t;
	if(x1>x2) swap(x1,x2),swap(y1,y2);if(y1>y2) revt=1,rev(y1),rev(y2);
	rep(i,1,n) { x=inn(),y=inn();if(revt) rev(y);if(x<x1||x>x2||y<y1||y>y2) continue;p[++cnt]=mp(x,y); }
	if(x1==x2||y1==y2) return !printf("%.12lf\n",double(L*(x2-x1+y2-y1)+(PI-2)*R*cnt));
	if(!cnt) return !printf("%.12lf\n",double(L*(x2-x1+y2-y1)));
	n=cnt,sort(p+1,p+n+1),build(rt,1,n);rep(i,1,n) v.pb(p[i].sec);sort(v.begin(),v.end());
	rep(i,1,n) p[i].sec=lower_bound(v.begin(),v.end(),p[i].sec)-v.begin()+1;
	rep(i,1,n) t=query(rt,1,p[i].sec)+1,ans=max(ans,t),update(rt,p[i].sec,t);
	db Ans=L*(x2-x1+y2-y1)-ans*(2-0.5*PI)*R;
	if(x2-x1+1==ans||y2-y1+1==ans) Ans+=0.5*PI*R;
	return !printf("%.12lf",double(Ans));
}

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

int main() {
  int sum=0;
  string numStr;
  cin>>numStr;
  for(int i=0; i<numStr.size(); i++){
    sum+= numStr.at(i)-'0';
  }
  if(sum%9==0){cout << "Yes" << endl;} else{cout << "No" << endl;}
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdlib>
using namespace	std;
#define	int long long
main(){

  int n,z,w,a[2000],r1=1e9,r=0;
  cin>>n>>z>>w;
  for(int i=0;i<n;i++) cin>>a[i];
  r=abs(a[n-1]-w);
  for(int i=0;i<n-1;i++){
    r1=abs(a[i]-a[n-1]);
    for(int j=i+1;j<n-1;j++){
      r1=min(r1,a[n-1]-a[j]);
    }
    r=max(r,r1);
  }
  cout<<r<<endl;
  return 0;

}






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

#define MAX 1000005

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    if( b == 0 )
        return a;
    return gcd(b, a%b);
}

vector<int> primes, sv(MAX, 0);

void gen(){
    for(ll i = 2; i < sv.size(); i++){
        if( sv[i] == 0 ){
            primes.push_back(i);
            for(ll j = i*i; j < sv.size(); j += i)
                sv[j] = 1;
        }
    }
}

ll cal(ll a){
    ll res = 1;
    int idx = 0;
    while(idx < primes.size() && a != 1){
        if( a%primes[idx] == 0 ){
            res++;
            while( a%primes[idx] == 0 )
                a = a/primes[idx];
        }
        idx++;
    }
    if( a != 1 )
        res++;
    return res;
}

int main(){

    gen();
    ll a, b;
    cin >> a >> b;
    ll c = gcd(a, b);
    cout << cal(c) << endl;
    return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define aint(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  */

class segtree
{
public:
  int n;
  vector<int> dat;

  segtree(int n_)
  {
    n = 1;
    while(n < n_) n *= 2;
    dat.resize(2*n);
  }

  void update(int k, int v)
  {
    k += n-1;
    dat[k] = v;
    while(k > 0){
      k = (k-1)/2;
      dat[k] = dat[k*2+1] | dat[k*2+2];
    }
  }

  int query(int a, int b, int k, int l, int r)
  {
    if(r <= a or b <= l) return 0;
    if(a <= l and r <= b) return dat[k];

    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    return vl | vr;
  }

  int query(int a, int b)
  {
    return query(a, b, 0, 0, n);
  }
};

signed main() {
  int n, q;
  string s;
  cin >> n >> s >> q;

  rep(i, 0, n) s[i] -= 'a';

  segtree st(n);
  rep(i, 0, n) st.update(i, 1<<s[i]);

  rep(i, 0, q) {
    int x;
    cin >> x;
    if (x == 1) {
      int y;
      char z;
      cin >> y >> z;
      st.update(y-1, 1<<(z-'a'));
      s[y - 1] = z;
    } else {
      int y, z;
      cin >> y >> z;
      auto ans = st.query(y - 1, z);
      cout << __builtin_popcount(ans) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 9092
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    char in[120];
    pair<pair<string, int>, int> p[110];
    int N; cin >> N;
    for(int i = 0; i < N; ++i) {
        int t;
        scanf("%s%d", in, &t);
        string tmp = in;
        p[i] = make_pair(make_pair(in, -t), i);
    }
    sort(p, p+N);
    for(int i = 0; i < N; ++i) {
        cout << p[i].second + 1 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    bool ans = false;
    if (s[0] == s[1]) {
        if (s[2] == s[3]) {
            ans = true;
        }
    }
    else if (s[1] == s[2]) {
        if (s[0] == s[3]) {
            ans = true;
        }
    }
    else if (s[0] == s[2]) {
        if (s[1] == s[3]) {
            ans = true;
        }
    }
    if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
        ans = false;
    }

    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;

    }
}

Measured memory_bytes: 256
def main() -> None:
    H1, M1, H2, M2, K = map(int, input().split())
    start = H2 * 60 + M2 - H1 * 60 - M1
    if start < 0:
        start += 24 * 60

    print(start - K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
using namespace std;
int n,a,k,ans,sg;
int main(){
	cin>>n;
	fo(i,1,n){
		cin>>a>>k;
		for(;;){
			int y=a%k,y2=a/k+1;
			if(y%y2==0){
				sg=y2-1;
				break;
			}
			a-=(y+y2-1)/y2*y2;
		}
		ans^=sg;
	}
	printf(ans?"Takahashi":"Aoki");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,a,b,i,c[51]={0};
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		c[a]++;
		c[b]++;
	}
	for(i=1;i<=n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

struct mint {
   ll x;
   mint(ll x = 0) { (this->x = (x + MOD)) %= MOD; }
   mint& operator+=(const mint a) {
      if ((this->x += a.x) >= MOD) x -= MOD;
      return *this;
   }
   mint& operator-=(const mint a) {
      if ((this->x += MOD - a.x) >= MOD) this->x -= MOD;
      return *this;
   }
   mint& operator*=(const mint a) {
      (this->x *= a.x) %= MOD;
      return *this;
   }
   mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
   }
   mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
   }
   mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
   }
   mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
   }
   mint inv() const { return pow(MOD - 2); }
   mint& operator/=(const mint a) { return *this *= a.inv(); }
   mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
   }
};

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

   int n, k;
   cin >> n >> k;
   vector<mint> d(k + 1);
   rep(i, 1, k + 1) {
      d[i].x = k / i;
      d[i] = d[i].pow(n);
   }
   rrep(i, k, 1) {
      for (int j = 2 * i; j <= k; j += i) {
         d[i] -= d[j];
      }
   }
   mint ans = 0;
   rep(i, 1, k + 1) ans += d[i] * i;
   cout << ans.x << endl;
   return 0;
}

Measured memory_bytes: 3992
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    A.sort()
    nDict = dict()
    for i, a in enumerate(A):
        if a in nDict: nDict[a] += 1
        else: nDict[a] = 1

    count = 0
    for i in reversed(range(N)):
        if nDict[A[i]] == 0: continue
        k = 1
        while k <= A[i]: k <<= 1
        if k - A[i] in nDict:
            if k - A[i] == A[i] and nDict[k - A[i]] > 1:
                count += 1
                nDict[A[i]] -= 2
            elif k - A[i] != A[i] and nDict[k - A[i]] > 0:
                count += 1
                nDict[A[i]] -= 1
                nDict[k - A[i]] -= 1
    print(count)
        

    return 0

if __name__ == "__main__":
    solve()

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

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

    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++i)
        cout << v[i];
}

Measured memory_bytes: 3644
a, b = gets.split.map(&:to_i)
 
#f(0,a)を求める
def f(a)
  sum = 0
  i = 0
  while (i < (10**12).bit_length) do
    cnt = 0
    #周期2**(i+1)→一応ビット演算しとく
    cycle = 1 << (i+1)
    #周期内の1の数を数える
    cnt += (a+1)/cycle * cycle/2
    #はみ出た分を足す
    rest = (a+1)%cycle - cycle/2
    cnt += rest if rest > 0
    #1の数が奇数ならその桁にビットを立てる
    if (cnt%2 == 1) then
      sum += 1 << i
    end
    i += 1
  end
  return sum
end
#f(a,b) = f(0,a-1)^f(0,b)
puts f(a-1)^f(b)

Measured memory_bytes: 1788
mod = 10**9+7
N = int(input())
S1 = input()
S2 = input()

ans = 1
for i in range(N):
    if i == 0:
        if S1[i]==S2[i]:
            c = 3
        else:
            c = 6
    else:
        if S1[i-1]==S1[i]:
            c = 1
        else:
            if S1[i-1]==S2[i-1]:
                c = 2
            elif S1[i]==S2[i]:
                c = 1
            else:
                c = 3
    ans *= c
    ans %= mod
print(ans)

Measured memory_bytes: 38384
#include <stdio.h>

int GetMax(int *pVal, int cnt)
{
    int max = *pVal;
    for (int *p = pVal + 1; p < (pVal + cnt); p++)
    {
        if (*p > max)
        {
            max = *p;
        }
    }
    return max;
}

int main(void)
{
    int val[3];
    scanf("%d %d %d", &val[0], &val[1], &val[2]);

    int cnt = 0;
    while (val[0] != val[1] || val[1] != val[2] && val[0] != val[2])
    {
        int max = GetMax(val, 3);
        int rest = 0;
        
        for (int i = 0; i < 3; i++)
        {
            if (val[i] != max)
            {
                rest++;
            }
        }
        
        if (rest == 1)
        {
            for (int i = 0; i < 3; i++)
            {
                if (val[i] != max)
                {
                    val[i] += 2;
                }
            }
        }
        else if (rest == 2)
        {
            for (int i = 0; i < 3; i++)
            {
                if (val[i] != max)
                {
                    val[i]++;
                }
            }
        }

        cnt++;
    }

    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 128
from array import array

def merge_sort(A):
    if len(A) <= 1:
        return A, 0
    mid = len(A) // 2
    left, lcount = merge_sort(A[:mid])
    right, rcount = merge_sort(A[mid:])
    merged, count = merge(left, right)
    return merged, lcount + rcount + count

def merge(left, right):
    lpos = 0
    rpos = 0
    rcount = 0
    merged = array('I', [])  # List is too slow. Use an array instead.
    len_left = len(left)
    len_right = len(right)
    while lpos < len_left and rpos < len_right:
        if left[lpos] < right[rpos]:
            merged.append(left[lpos])
            lpos += 1
        else:
            merged.append(right[rpos])
            rpos += 1
            #rcount += len(left[lpos:])
            rcount += len_left - lpos
    
    if left[lpos:]:
        merged.extend(left[lpos:])
    if right[rpos:]:
        merged.extend(right[rpos:])
    
    return merged, rcount
    
if __name__ == '__main__':
    n = int(raw_input())
    A = array('I', map(int, raw_input().split()))
    
    sorted, count = merge_sort(A)
    #print ' '.join(str(x) for x in sorted)
    print count

Measured memory_bytes: 23596
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
int main() {
	int A, B, C, X; cin >> A >> B >> C >> X;
	int cnt = 0;
	rep(a, 0, A + 1) {
		rep(b, 0, B + 1) {
			rep(c, 0, C + 1) {
				if (a * 500 + b * 100 + c * 50 == X) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
// ABC064 B - Traveling AtCoDeer Problem
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);
    int min = 1001;
    int max = -1;
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);
        if (a < min) {
            min = a;
        }
        if (a > max) {
            max = a;
        }
        // printf("min:%d, max:%d\n", min, max);
    }
    printf("%d\n", max-min);

    return 0;
}

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

int main(){
 int n;
 cin >> n;
 int a[n];
 for(int i = n-1;i >=0;i--){
  cin >> a[i];
 }
 for(int i = 0; i< n; i++){
  cout << a[i];
  if(i != n-1) cout << " ";
  else cout << endl;
 }
}


Measured memory_bytes: 3108