akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String roop = scanner.next();
		String search = scanner.next();
  		
  		roop = roop.concat(roop);
  		
  		int result = roop.lastIndexOf(search);
  	
		if (result != -1) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		scanner.close();
  }
}


Measured memory_bytes: 26268
/*
  || Shree Ganeshay Namah ||

     || Jai Shree Ram ||
  || Nabh Sparsham Diptam ||
*/
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define mod 1000000000000000001
#define block 180
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f1 first
#define s1 second
int jai_shree_ram()
{
    return 1;
}
int shree_ganeshay_namah()
{
    return 1;
}
ll power(ll x,ll y)
{
    ll r=1;
    while(y>0)
    {
        if(y%2!=0)
            r=r*x;
        x=x*x;
        y=y/2;
    }
    return r;
}
ll ncr(ll n,ll k)
{

    ll c[k+1];
    memset(c,0,sizeof(c));
    c[0]=1;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=min(i,k);j>0;j--)
            c[j]=c[j]+c[j-1];
    }
    return c[k];
}

bool prime[500001];
void sieve()
{
    ll i,j;
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(i=2;i<=sqrt(100001);i++)
    {
        if(prime[i])
        {
            for(j=i*i;j<=100001;j=j+i)
                prime[j]=false;
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i,j,f,k;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    f=0;
    for(i=0;i<k;i++)
        f=f+a[i];
    cout<<f;
    return 0;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    out((a+b+1)/2)

    return 0;
}

Measured memory_bytes: 256
import sys

N,M,Q=map(int,input().split())

a=[[0]*(N+1) for i in range(N+1)]

for i in range(M):
    L,R=map(int,input().split())
    a[L][R]+=1

b=[[0]*(N+1) for i in range(N+1)]

for i in range(1,N+1):
    for j in range(i,N+1):
        b[i][j]=a[i][j]+b[i][j-1]

ans=[[0]*(N+2) for i in range(N+2)]
for q in range(1,N+1):
    for p in range(q,0,-1):
        ans[p][q]=ans[p+1][q]+b[p][q]

for i in range(Q):
        p,q=map(int,input().split())
        print(ans[p][q])

Measured memory_bytes: 15220
#include <iostream>
#include <stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

//??¶????????°
int n;
//?????\??????
int M[N][N];
//??°?????¶???????¢????
int color[N];
//??\??¶????????°??¶???
int d[N];
//??\??¶???????????¶???
int f[N];
//??¶???
int tt;

//????????????????????????u?????????v
int next(int u){
    for(int v=0;v<n;v++){
        if(M[u][v]&&color[v]==WHITE)
            return v;
    }
    return -1;
}

//??¨????????°?????±?????????????´¢
void dfs_visit(int r){
    
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    //?????°??¶???
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1&&color[v]==WHITE){
            color[v]=GRAY;
            d[v]=++tt;
            S.push(v);
        }
        else{
            //????????????
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs(){
    //????§????
    for(int i=0;i<n;i++)
        color[i]=WHITE;
    tt=0;

    //??\????????????u?????????????????±?????????????´¢
    for(int u=0;u<n;u++)
        if(color[u]==WHITE)
            dfs_visit(u);

    for(int i=0;i<n;i++)
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
}

int main(){
    int u,k,v;

    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;

    for(int i=0;i<n;i++){
        cin>>u>>k;u--;
        for(int j=0;j<k;j++){
            cin>>v;v--;
            M[u][v]=1;
        }
    }

    dfs();
}

Measured memory_bytes: 3092
/*
	Created on 19-09-20 17:30

	@author: roastedcoder
*/

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const int MX = 2e5 + 5;
#define all(x) x.begin(), x.end()
#define int long long
#define endl "\n"
#define pb push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________


int32_t main() {
	roastedcoder
	string s; cin>>s;
	int k = s.length();
	if(s[k-1] == 's') cout<<s<<"es\n";
	else cout<<s<<"s";
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/
/*
MY NOTES:
  int for long long
  Don't make Segment Tree and Fenwick Tree 0-based you FOOL.
  Always try to exhaust the time being provided and PACE yourself.
  First think Greedily not DPily, LOL... Who says that :P
  Greedy solution is better than DP solution, if you can find one.
  DP is OP.
*/

Measured memory_bytes: 3664
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    s_x = [i for i in s if i != 'x']
    l_s_x = len(s_x)
    for i in range(l_s_x):
        if s_x[i] != s_x[l_s_x-1-i]:
            print(-1)
            return

    x_num = []
    cnt = 0
    for i in s:
        if i == 'x':
            cnt += 1
        else:
            x_num.append(cnt)
            cnt = 0
    if s[-1] == 'x':
        x_num.append(cnt)
    else:
        x_num.append(0)

    len_x_num = len(x_num)
    ans = 0
    for i in range(len_x_num):
        ans += max(x_num[len_x_num-1-i] - x_num[i], 0)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
ll a[100010],b[100010];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=m;i++)
        scanf("%lld",&b[i]);
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans += a[i]*(i-1);
        ans%=mod;
    }
    for(int i=1;i<=n;i++)
    {
        ans -= a[i]*(n-i);
        ans%=mod;
    }
    ll ans2 = 0;
    for(int i=1;i<=m;i++)
    {
        ans2 += b[i]*(i-1);
        ans2%=mod;
    }
    for(int i=1;i<=m;i++)
    {
        ans2 -= b[i]*(m-i);
        ans2 %= mod;
    }
    ans = (ans*ans2)%mod;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1792
N, K = map(int, input().split())
x = list(map(int, input().split()))

count_m = 0
count_p = 0
for i in range(N):
    if x[i] > 0:
        count_m = i
        count_p = N-i
        break
    elif x[i] == 0:
        count_m = i
        count_p = N-i-1
        K -= 1
        N -= 1
        x.remove(x[i])
        break
if count_m == 0 and count_p == 0:
    count_m = N

ans = 0
    

y = K
z = K - y


if count_m >= 1 and count_p>=1:
    # for j in (range(1,y)):
    #     if count_m-j>=0  and count_m+y-1-j<N:
    #         print(x[count_m+y-1-j], x[count_m-j])
    tmp = min(x[count_m+y-1-j]-x[count_m-j] *2 for j in range(1, y) if count_m-j>=0  and count_m+y-1-j<N)
    tmp2 = min(x[count_m+y-1-j]*2-x[count_m-j] for j in range(1, y) if count_m-j>=0 and count_m+y-1-j<N)
else:
    tmp = tmp2 = 1000000000

if N==0:
    ans = 0


elif count_p>=K:
    # print(y, "1chi")
    ans = min(tmp, tmp2, x[count_m+min(y, count_p)-1])
elif count_m>=K:
    #print("ni")
    ans = min(tmp, tmp2, -x[count_m-K])
else:
    #print("san", tmp, tmp2)
    ans = min(tmp, tmp2)


print(ans)


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

int main()
{
  int n,m;
  cin >> n >> m;
  
  int a[n];
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(a[i] * (4*m) >= sum){
      ans++;
    }
  }
  
  if(ans >= m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
    
}

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

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> G(N);
  vector<bool> seen(N,false);
  vector<long long> ans(N,0);
  queue<int> que;
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    ans[p-1] += x;
  }
  
  que.push(0);
  seen[0] = true;
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int nv : G[v]) {
      if (seen[nv]) continue;
      seen[nv] = true;
      ans[nv] += ans[v]; 
      que.push(nv);
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << ans[i];
    if (i < N-1) cout << " ";
  }
  cout << endl;
}

Measured memory_bytes: 16372
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long num1=0,num2=0,ans=0;
  cin>>num1>>num2;
  ans=num1%num2;
  while(1){
    if(ans<=abs(ans-num2)){
      break;
    }else{
      ans=min(ans,abs(ans-num2));
    } 
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val v = readLine()!!.split(' ').map(String::toInt)
    val odd = IntArray(100001)
    val eve = IntArray(100001)
    for (i in 0 until n) {
        if (i % 2 == 0) eve[v[i]]++
        else odd[v[i]]++
    }
    var mO = odd.max()!!
    var mE = eve.max()!!
    val dic = mutableSetOf<Int>()
    for (i in 1..100000) {
        if (odd[i] == mO) {
            dic.add(i)
            odd[i] = 0
        }
        if (eve[i] == mE) {
            dic.add(i)
            eve[i] = 0
        }
    }
    if (dic.size > 1) {
        println(n - mO - mE)
        return
    }
    var mO2 = odd.max()!!
    var mE2 = eve.max()!!
    var xx = Math.max(mO+mE2, mE+mO2)
    println(n - xx)
}

Measured memory_bytes: 57928
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
int player[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k, q;
	cin >> n >> k >> q;
	int a;
	for (int i = 0; i < q; ++i) {
		cin >> a;
		++player[a];
	}
	for (int i = 1; i <= n; ++i)
		if (q - player[i] >= k)
			cout << "No\n";
		else
			cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Vector2d> p = new ArrayList<>();
		for (int i=0; i<n; i++) {
			double x = sc.nextDouble();
			double y = sc.nextDouble();
			p.add(new Vector2d(x, y));
		}
		sc.close();
		System.out.println(String.format("%1$.1f", solve(p)));
	}

	static class Vector2d {
		Vector2d(Double x, Double y){
			this.x = x;
			this.y = y;
		}
		Double x;
		Double y;
		public String toString() {
			return String.format("%1$.10f %2$.10f", x, y);
		}
	}

	public static Vector2d sub(Vector2d v1, Vector2d v2){
		return new Vector2d(v2.x - v1.x, v2.y - v1.y);
	}

	public static Double solve(List<Vector2d> p) {
		Double v2times = 0.0;
		int s = p.size();
		for (int i=0; i<s; i++) {
			v2times += (p.get(i).x * p.get((i+1)%s).y - p.get(i).y * p.get((i+1)%s).x);
		}
		return v2times / 2;
	}
}



Measured memory_bytes: 28892
#include<iostream>
#include<string.h>
#include<string>
#define MAX 100
using namespace std ;
 
int main()
{
    int n;
    int t=0,h=0,comp=0;
    string tarou,hanako;
     
    cin >> n ;
     
    for(;n>0;n--)
	{     
        cin >> tarou >> hanako;

		comp = strcmp(tarou.c_str(),hanako.c_str());
         
        if(comp>0)
		{
            t+=3;
        } 
        else if(comp==0)
		{
            t++;
            h++;
        }
		else
		{
            h+=3;
        }
    }    
     
    cout << t << ' ' << h << endl ;
     
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int s, w;
    cin >> s >> w;
    if(w>=s){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
const int MOD = 998244353;

vector<vector<int>> g;
vector<int> comp;
vector<bool> vis;

int clr = 0;

void dfs(int v){
    vis[v] = true;
    comp[v] = clr;
    for (auto& a : g[v]){
        if (!vis[a]){
            dfs(a);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie();
    int n, m, k;
    cin >> n >> m >> k;
    g.resize(n);
    comp.assign(n,-1);
    vis.resize(n);
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        g[--x].push_back(--y);
        g[y].push_back(x);
    }
    for (int i = 0; i < n; i++){
        if (comp[i] == -1){
            dfs(i);
            clr++;
        }
    }
    vector<int> sz(clr);
    for (auto& v : comp)
        sz[v]++;
    vector<int> ans(n);
    for (int i = 0; i < n; i++){
        ans[i] = sz[comp[i]]-1 - g[i].size();
    }
    for (int i = 0; i < k; i++){
        int x, y;
        cin >> x >> y;
        if (comp[--x] == comp[--y]){
            ans[x]--;
            ans[y]--;
        }
    }
    for (auto& v : ans)
        cout << v << ' ';
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, a[100005], cnt[100005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int ma = -1, mi = 100005;
	FOR(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	if (ma - mi > 1) cout << "No" << endl;
	else if (ma == mi) {
		if (ma == n-1 || n >= 2*ma) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (ma > cnt[mi] && cnt[ma] >= 2*(ma-cnt[mi])) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
void chmax(int &a,int b){	a=max(a,b);	return;	}
void chmin(int &a,int b){	a=min(a,b);	return;	}

#define MAX_N 50

int main(){
	int n,d[MAX_N+1],dp[MAX_N][MAX_N];
	cin>>n;
	d[0]=0;
	for(int i=1;i<=n;++i) cin>>d[i];
	if(n==1){
		cout<<d[1]<<endl;
		return 0;
	}
	sort(d+1,d+n+1);
	dp[0][1]=d[1];
	for(int i=2;i<n;++i){
		if(i==2) dp[i-1][i]=min(d[1],d[2]);
		else{
			dp[i-1][i]=0;
			for(int j=i-3;j>=0;--j){
				chmax(dp[i-1][i],min(dp[j][i-2],min(d[i]-d[j],d[i-1]-d[i-2])));
			}
			chmax(dp[i-1][i],min(dp[i-2][i-1],d[i]-d[i-2]));
		}
		for(int j=i-2;j>=0;--j){
			dp[j][i]=dp[j][j+1];
			for(int k=j+1;k<i;++k) chmin(dp[j][i],d[k+1]-d[k]);
		}
	}
	int ans=0;
	for(int i=0;i<n-1;++i) chmax(ans,min(dp[i][n-1],min(d[n]-d[n-1],24-d[n]-d[i])));
	for(int i=0;i<n-1;++i) chmax(ans,min(dp[i][n-1],min(24-d[n]-d[n-1],d[n]-d[i])));
	cout<<ans<<endl;
}

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

int main()
{
	int n,m,c;
	cin>>n>>m>>c;
	int a[n+1][m+1],i,j,b[m+1];
	rep(i,1,m)
	{
		cin>>b[i];
	}
	rep(i,1,n)
	{
		for (j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	int ans,cnt;
	cnt=0;
	rep(i,1,n)
	{
		ans=0;
		for (j=1;j<=m;j++)
		{
			ans+=(a[i][j]*b[j]);
		}
		ans+=c;
		if (ans>0)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
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()))

a, b, c  = in_ints()
print(c, a, b)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int f=1;
	for(int i=0;i<3;i++)
		if(s[i]==s[i+1]){
			f=0; break;
		}
	if(f) cout<<"Good";
	else cout<<"Bad";
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int j = 1;
  REP(i, 5) {
    int x;
    cin >> x;
    if (x == 0) {
      cout << j << endl;
      return 0;
    }
    j++;
  }
  return 0;
}

Measured memory_bytes: 3564
#include<iostream>

using namespace std;

int main(){

    int N, R, T;
    cin>> N>> R>> T;
    int p[N];
    for(int i=0; i<N; i++){
        cin>> p[i];
    }

    int d[N], w[T+5][R];
    int ans=0;
    fill(d, d+N, 0); fill(w[0], w[T+5], 0);
    for(int i=1; i<=T; i++){
        for(int j=0; j<N; j++){
            d[j]=(d[j]+p[j])%R;
            //cout<< i<<" "<< j<<" "<<d[j]<< endl;
            if(i>1){
                for(int k=i+1; k<=T; k++){
                    w[k][d[j]]++;
                }
            }
            if(w[i][d[j]]==0){
                //cout<< i<<" "<< j<<" "<<d[j]<< endl;
                ans++;
            }else{
                for(int k=i; k<=T; k++){
                    w[k][d[j]]--;
                }
            }
        }
    }

    cout<< ans<< endl;

    return 0;
}

Measured memory_bytes: 6932
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] x = new int[n];
		

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

		int min = 100000000;
		for(int j=1;j<100;j++){
			int sum = 0;
			for(int t=0;t<n;t++){
				sum +=  (x[t] - j) * (x[t] - j);
				
			}
			if(sum < min){
				min = sum;
			}	
		 }

		 System.out.println(min);
		}
	}

Measured memory_bytes: 35648
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int T = sc.nextInt();
		
		int[] c = new int[n];
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		
		int min = Integer.MAX_VALUE;
		int mini = -1;
		for (int i = 0; i < n; i++) {
			if (t[i] <= T && c[i] < min) {
				min = c[i];
				mini = i;
			}
		}
		
		if (mini == -1) {
			pr.println("TLE");
		} else {
			pr.println(c[mini]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<cstring>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1111111];
int memo2[1111111];
 
int solve(int n){
   
  if(!n) return 0;
  if(~memo[n]) return memo[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(n >= p[i]) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(~memo2[n]) return memo2[n];
 
  int ans = INF;
  for(int i=180;i>0;i--) if(p[i]&1 && n >= p[i]) ans = min(ans, solve2(n-p[i])+1);
 
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  memset(memo, -1, sizeof(memo));
  memset(memo2, -1, sizeof(memo2));
 
  for(int i=0;i<181;i++) p[i] = i*(i+1)*(i+2)/6;

  for(int i=0;i<1111111;i+=100){ solve(i), solve2(i); }
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
 
}

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

int main() {
  int num;
  cin >> num;
  bool Y = 0;
  for (int i = 0;i < num;i++) {
    string line;
    cin >> line;
    if ("Y" == line) {
      Y = 1;
    }
  }
  
  if (Y == 1) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

void solve(long long H, long long W)
{
    ll ans = LONG_MAX;
    ll A, B, C;
    for (size_t i = 1; i <= H - 1; i++)
    {
        A = W * i;
        B = W * floor((double)(H - i) / 2);
        C = H * W - A - B;
        ans = min(ans, max(max(A, B), C) - min(min(A, B), C));

        B = (H - i) * floor((double)W / 2);
        C = H * W - A - B;
        ans = min(ans, max(max(A, B), C) - min(min(A, B), C));
    }

    for (size_t i = 1; i <= W - i; i++)
    {
        A = H * i;
        B = H * floor((double)(W - i) / 2);
        C = H * W - A - B;
        ans = min(ans, max(max(A, B), C) - min(min(A, B), C));

        B = (W - i) * floor((double)H / 2);
        C = H * W - A - B;
        ans = min(ans, max(max(A, B), C) - min(min(A, B), C));
    }

    cout << ans << endl;
}

int main()
{
    long long H;
    scanf("%lld", &H);
    long long W;
    scanf("%lld", &W);
    solve(H, W);
    return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    a = [0]*(len(s)+1)
    b = [0]*(len(t)+1)
    for i, c in enumerate(s):
        if c == "A":
            a[i+1] = 1
        else:
            a[i+1] = 2
        a[i+1] += a[i]
    for i, c in enumerate(t):
        if c == "A":
            b[i+1] = 1
        else:
            b[i+1] = 2
        b[i+1] += b[i]
    q = int(input())
    ans = [None]*q
    for i in range(q):
        a1, a2, b1, b2 = map(int, input().split())
        x, y = a[a2] - a[a1-1], b[b2] - b[b1-1]
        if abs(x-y) % 3 == 0:
            ans[i] = "YES"
        else:
            ans[i] = "NO"
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()

Measured memory_bytes: 18060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    string st;
    cin>>st;
    st[m-1]+=32;
    cout<<st<<endl;
    return 0;
}

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

int main(){
	int D, N;
	cin >> D >> N;
	
	if(N == 100) {
		if(D == 0) {
			cout << 101 << endl;
		} else if(D == 1) {
			cout << 10100 << endl;
		} else {
			cout << 1010000 << endl;
		}
	} else {
		for(int i = 0; i < D; i++) {
			N *= 100;
		}
		cout << N << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

int main()
{
    char t[101];
    scanf("%s",t);
    int a=strlen(t);
    for(int i=0;i<a;i++)
        t[i]='x';
    printf("%s\n",t);
    return 0;
}


Measured memory_bytes: 256
while True:
    size = map(int,raw_input().split())
    if size[0] == size[1] == size[2] == 0:
        break
    size = sorted(size)
    rmin2 = size[0]**2 + size[1]**2
    
    n = input()
    for i in range(n):
        R2 = 4 * input()**2
        if rmin2 < R2:
            print 'OK'
        else:
            print 'NA'

Measured memory_bytes: 4204
import sys
sys.setrecursionlimit(10**5)
N = int(input())
h = list(map(int, input().split()))
dp = [-1 for i in range(N)]
def rec(n):
    if dp[n] == -1:
        if n == 0:
            dp[n] = 0
        elif n == 1:
            dp[n] = abs(h[1]-h[0])
        else:
            dp[n] = min(rec(n-2)+abs(h[n]-h[n-2]), rec(n-1)+abs(h[n]-h[n-1]))
    return dp[n]
rec(N-1)
print(dp[N-1])

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

#define MAXN 310

int n,m,a[MAXN][MAXN],choice[MAXN],cnt[MAXN],vis[MAXN];

bool check(int mid)
{
	memset(cnt,0,sizeof(cnt));
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;++i)choice[i]=1,++cnt[a[i][1]];
	while(1)
	{
		int full=0;
		for(int i=1;i<=m;++i)
			if(cnt[i]>mid)
			{
				full=i;
				break;
			}
		if(!full)return true;
		vis[full]=true;
		for(int i=1;i<=n;++i)
		{
			if(a[i][choice[i]]==full)
			{
				--cnt[full];
				while(choice[i]<=m && vis[a[i][choice[i]]])++choice[i];
				if(choice[i]>m)return false;
				++cnt[a[i][choice[i]]];
			}
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)scanf("%d",&a[i][j]);
	int l=1,r=n;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(check(mid))r=mid;else l=mid+1;
	}
	printf("%d\n",l);
}

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

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    int findRoot(int x) {
        return data[x] < 0 ? x : data[x] = findRoot(data[x]);
    }
    void uniteSet(int x, int y) {
        x = findRoot(x), y = findRoot(y);
        if (x != y) {
            if (data[x] < data[y]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
    }
    int size(int x) {
        return -data[findRoot(x)];
    }
    bool same(int x, int y) {
        return findRoot(x) == findRoot(y);
    }
};


int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(M);
    vector<bool> used(M, false);

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

        int l;
        cin >> l;
        l--;
        used.at(l) = true;
        for (int j=1; j<K; j++) {
            int ll;
            cin >> ll;
            ll--;
            uf.uniteSet(l, ll);
            used.at(ll) = true;
        }
    }

    // 雑に一つ取る
    int base = -1;
    for (int i=0; i<M; i++) {
        if (used.at(i)) {
            base = i;
            break;
        }
    }

    bool ok = true;
    for (int i=0; i<uf.data.size(); i++) {
        if (used.at(i)) {
            if (!uf.same(base, i)) {
                ok = false;
                break;
            }
        }
    }

    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#define SIZE 100000
#define SIZE2 50000
using namespace std;

bool compare(int a, int b)
{
    return a < b;
}

int a[SIZE];
int b[SIZE2];
int main()
{
    int q;

    cin>>q;
    for(int i = 0;i < q;i++)
    {
        cin>>a[i];
    }

    sort(a, a + q, compare);

    int t;
    cin>>t;
    for(int j = 0;j < t;j++)
    {
        cin>>b[j];
    }

    int n = 0;
    for(int i = 0;i < t;i++)
    {
        int l = 0, r = q-1;
        while(l <= r)
        {
            int m = (l + r)/2;
            if(a[m] < b[i])
                l = m + 1;
            else if(a[m] > b[i])
                r = m - 1;
            else if(a[m] == b[i])
            {
                n++;
                break;
            } 
        }
    }

    cout<<n<<endl;
    
}


Measured memory_bytes: 3584
import math

k = int(input())
a, b = map(int, input().split())

if k == 1:
    print("OK")
    exit()
elif a <= k <= b :
    print("OK")
    exit()

cnt = 1
while True:
    tmp = cnt * k
    if a <=  tmp <= b:
        print("OK")
        exit()
    elif b <= tmp:
        print("NG")
        exit()
    cnt += 1 

Measured memory_bytes: 9124
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

row_list = [[0] * w for _ in range(h)]
for i in range(h):
    r = 0
    cnt = 0
    for l in range(w):
        if s[i][l] == '#':
            row_list[i][l] = 0
            r += 1
            cnt = 0
            continue

        while r < w and s[i][r] == '.':
            cnt += 1
            r += 1

        row_list[i][l] = cnt

col_list = [[0] * h for _ in range(w)]
for i in range(w):
    r = 0
    cnt = 0
    for l in range(h):
        if s[l][i] == '#':
            col_list[i][l] = 0
            r += 1
            cnt = 0
            continue

        while r < h and s[r][i] == '.':
            cnt += 1
            r += 1

        col_list[i][l] = cnt

res = 0
for i in range(h):
    for j in range(w):
        res = max(res, row_list[i][j] + col_list[j][i] - 1)

print(res)

Measured memory_bytes: 247432
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

class  Q {
public:
  ll sum;
  int i,j,k;
  Q(ll sum, int i,int j, int k) {
    this-> sum = sum;
    this->i = i;
    this->j = j;
    this->k = k;
  };
  
};

bool operator< (const Q &Q1, const Q &Q2){
  return Q1.sum < Q2.sum;
};
bool bol[1000][1000][1000];

inline void solve(){
  int x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x),b(y),c(z);
  FOR(i,x)
    cin >> a[i];
  FOR(i,y)
    cin >> b[i];
  FOR(i,x)
    cin >> c[i];
  sort(ALL(a),greater<ll>());
  sort(ALL(b),greater<ll>());
  sort(ALL(c),greater<ll>());

  priority_queue<Q> que;
  que.push(Q(a[0]+b[0]+c[0],0,0,0));
  FOR(i,k){
    Q now = que.top();
    que.pop();
    int aa = now.i;
    int bb = now.j;
    int cc = now.k;
    //    cout << a[aa] __ b[bb] __ c[cc] ___ ;
    cout << now.sum fin;
    if(x-1 > aa and  !bol[aa+1][bb][cc]){
      bol[aa+1][bb][cc] = true;
      que.push(Q(a[aa+1]+b[bb]+c[cc],aa+1,bb,cc));
    }
    if(y-1 > bb and !bol[aa][bb+1][cc]){
      bol[aa][bb+1][cc] = true;
      que.push(Q(a[aa]+b[bb+1]+c[cc],aa,bb+1,cc));
    }
    if(x-1 > cc and !bol[aa][bb][cc+1]){
      bol[aa][bb][cc+1] = true;
      que.push(Q(a[aa]+b[bb]+c[cc+1],aa,bb,cc+1));
    }
  }
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 294784
#include <bits/stdc++.h>
#define int long long
using namespace std;

vector<int> diviser(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  return res;
}

signed main() {
  int N;
  cin >> N;

  vector<int> v = diviser(N);

  int ans = 1e13;
  for (auto x : v) {
    int temp = x + N / x - 2;
    ans = min(ans, temp);
  }

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

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  int k = 0;
  ll ans = 0;
  ll tmp = 0;
  while(k <= n){
    if(k == 0){
      ans = 2;
    }
    else if(k == 1){
      ans = 1;
      tmp = 2;
    }
    else{
      ll tmpp = ans + tmp;
      tmp = ans;
      ans = tmpp;
    }
    k++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;

int main(){
    string N;
    cin >> N;
    int sum=0;
    for(int i=0;i<N.length();i++){
        sum += (N[i] - '0');
        sum %= 9;
    }
    if(sum == 0){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int n;ll a[200001];

ll com(ll x){
  return (x*(x-1))/2;
}

int main(){
  cin>>n;rep(i,n)cin>>a[i];
  repd(i,1,n)a[i] += a[i-1];
  a[n] = 0;
  sort(a,a+n+1);
  ll ren = 0,past = 0;
  ll ans = 0;
  rep(i,n+1){
    if(a[i] == past)ren++;
    else{
      ans += com((ll)ren);
      ren = 1;
      past = a[i];
    }
  }
  ans += com((ll)ren);
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int h, n; scanf("%d%d", &h, &n);
	REP(i, n){
		int a; scanf("%d", &a);
		h -= a;
	}
	if(h <= 0) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//const int mod = 1000000007;
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//入力
ll a,b,c,d;
mint dp[3010][3010];


int main(){
    cin >> a >> b >> c >> d;
    dp[a][b]=1;
    for(int i=a+1;i<=3000;i++){
        dp[i][b]=dp[i-1][b]*b;
    }
    for(int i=b+1;i<=3000;i++){
        dp[a][i]=dp[a][i-1]*a;
    }
    for(int i=a+1;i<=3000;i++){
        for(int j=b+1;j<=3000;j++){
            dp[i][j]=dp[i-1][j]*j+dp[i][j-1]*i-dp[i-1][j-1]*(i-1)*(j-1);
        }
    }
    cout << dp[c][d] << endl;

    return 0;
}


Measured memory_bytes: 74388
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<pair<string, pair<int,int>>>p(N);
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].first >> p[i].second.first;
		p[i].second.second = i+1;
	}
	for (int i = 0; i < N; i++)
	{
		p[i].second.first *= -1;
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < N; i++)
	{
		cout << p[i].second.second<<endl;
	}
}

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

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

    static class TaskB {
        public void go(char[] s, PrintWriter out) {
            int[] freq = new int[26];
            for (int i = 0; i < s.length; i++) {
                if (freq[s[i] - 'a'] > 0) {
                    out.println("no");
                    return;
                }
                freq[s[i] - 'a']++;
            }
            out.println("yes");
        }

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            go(s, out);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream i) {
            br = new BufferedReader(new
                    InputStreamReader(i));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 23380
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	vector <vector<ll>>p(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		p[a].pb(b);
	}
	ll s, t;
	cin >> s >> t;
	s--; t--;
	//グラフを3倍して、BFS
	queue<pair<ll, ll>>q;//頂点番号と距離を3で割った余りを持ちたいのでpair
	vector<vector<ll>>dist(n, vector<ll>(3, INF));
	dist[s][0] = 0;
	q.push(mp(s, 0));
	while (!q.empty()) {
		ll v = q.front().first;
		ll m = q.front().second;
		q.pop();
		for (ll x : p[v]) {
			if (dist[x][(m + 1) % 3] != INF)continue;
			q.push(mp(x, (m+ 1) % 3));
			dist[x][(m+ 1) % 3] = dist[v][m]+1;
		}
	}
	ll ans = dist[t][0];
	if (ans == INF)ans=-1;
	else ans /= 3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main()
{
    char b;
    cin >> b;
    switch (b)
    {
    case 'A':
        cout << 'T' << endl;
        break;
    case 'T':
        cout << 'A' << endl;
        break;
    case 'G':
        cout << 'C' << endl;
        break;
    case 'C':
        cout << 'G' << endl;
        break;
    default:
        break;
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            ACalc solver = new ACalc();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class ACalc {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int a = s.nextInt();
            w.println(a + a * a + a * a * a);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25704
# include <bits/stdc++.h>
using namespace std;
long long n,ans,k;
int main()
{
	cin>>n;
	for (long long i=1; i<=n; i++)
	{
		for (long long j=1; j<=n; j++)
		{
			for (long long w=1; w<=n; w++)
			{
				k=__gcd(i,j);
				k=__gcd(k,w);
				ans+=k;
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sz size()
#define S second
#define F first
#define all(x) x.begin(), x.end()
#define int ll

typedef pair < int, int > pii;
typedef vector < int >  vi;
typedef vector < vector < int > >  vvi;

int dp[10000];
int  mod = 1e9 + 7;

void solve(){
    int s;
    cin >> s;
    dp[1]=0;
    dp[2]=0;
    dp[3]=1;
    dp[4]=1;
    dp[5]=1;
    /*dp[6]=2;
    dp[7]=3;
    dp[8]=4;
    dp[9]=6;*/
    for(int i = 6; i <= s; i++){
        dp[i] = dp[i - 1] + dp[i - 3];
        //dp[i] = (dp[i] - dp[i - 4] + mod) % mod;
        dp[i] %= mod;
    }
    cout << dp[s];
}

signed main() {
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}





Measured memory_bytes: 3632
#include<iostream>
#include<vector>
using namespace std;
int N;
long S[1<<17];
long sum[300][2<<17];
long f(int A,int B)
{
	int dif=A-B;
	int k=(N-1-A)/dif+1;
	if(A%dif==0&&A/dif<k)return-1;
	long now=0;
	if(dif<300)now=sum[dif][0]-sum[dif][k*dif]+sum[dif][A]-sum[dif][A+k*dif];
	else
	{
		for(int i=A;i-A<k*dif&&i<N;i+=dif)now+=S[i];
		for(int i=0;i<k*dif&&i<N;i+=dif)now+=S[i];
	}
	return now;
}
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>S[i];
	for(int i=1;i<300;i++)
	{
		for(int j=N;j--;)sum[i][j]=S[j]+sum[i][j+i];
	}
	long ans=0;
	for(int A=1;A<N;A++)
	{
		int tmp=N-1-A;
		for(int i=1;i*i<=tmp;i++)
		{
			if(tmp%i==0)
			{
				if(A>i)ans=max(ans,f(A,A-i));
				if(tmp/i!=i&&A>tmp/i)ans=max(ans,f(A,A-tmp/i));
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 613504
n, x = map(int, input().split())
A = list(map(int, input().split()))
memo = A[:]
ans = sum(memo)
for k in range(1, n):
  memo = [min(m, A[itr - k]) for itr, m in enumerate(memo)] 
  ans = min(ans, sum(memo) + x * k)
print(ans)

Measured memory_bytes: 3188