akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    vvi arr(n, vi(3));
    auto dp = arr;
    REP(i, 0, n)
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    dp[n-1] = arr[n-1];
    RREP(i, n-2, -1) {
        dp[i][0] = max(dp[i+1][1], dp[i+1][2]) + arr[i][0];
        dp[i][1] = max(dp[i+1][0], dp[i+1][2]) + arr[i][1];
        dp[i][2] = max(dp[i+1][0], dp[i+1][1]) + arr[i][2];
    }
    cout << max(dp[0][0], max(dp[0][1], dp[0][2])) << endl;
    return 0;
}


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

int main(){
	l1 n; cin>>n;
	string str;
	cin>>str;
	l1 red=0, white=0;
	for(int i=0; i<n; i++){
		if(str[i]=='R') red++;
		else white++;
	}
	l1 ans1=0, ans2=0;
	for(int i=0; i<red; i++){
		if(str[i]=='W') ans1++;
	}
	for(int i=red; i<n; i++){
		if(str[i]=='R') ans2++;
	}
	cout<<min(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 3720
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  var X = parseInt(input[0].split(" ")[2]);
  var Y = parseInt(input[0].split(" ")[3]);
  x = new Array(n).fill(0);
  y = new Array(m).fill(0);
  tmp1=input[1].split(" ");
  for(i=0;i<n;i++){
    x[i]=parseInt(tmp1[i]);
  }
  tmp2=input[2].split(" ");
  for(i=0;i<m;i++){
    y[i]=parseInt(tmp2[i]);
  }
  var ans = "War";
  maxx=Math.max.apply(null,x);
  miny=Math.min.apply(null,y);
  if(X<Y&&X<miny&&maxx<Y&&maxx<miny){
    ans = "No War";
  }


  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21956
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main()
{
    fast_io();
    string str;
    cin >> str;
    int n = str.length();

    if(n % 2 != 0) {
        cout << "No\n";
        return 0;
    }


    bool fg = 0;

    for (int i = 0; i < n; ++i)
    {
        if(i % 2 == 0) {
                if(str[i] != 'h') fg = 1;
        }
        else {
            if(str[i] != 'i') fg = 1;
        }
    }

    if(fg) {
        cout << "No";
    }
    else cout << "Yes";
    return 0;
}

// g++ -std=c++11


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int num=0;
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            ans+=i;
            if(ans>=n)
            {
                num=i;
                break;
            }
        }
//        if(num==0) num=n;
        cout<<num<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000007
void MOD(int &x){if(x>=mod)x-=mod;}
#define maxn 100010
#define inf (1<<30)
char s[maxn];
unsigned int h[maxn],b[maxn];
#include<map>
map<unsigned int,bool>mp;
unsigned int get(int i,int j){
	return h[i]-h[i-j]*b[j];
}
int main(){
	int n;
	in(n);
	scanf("%s",s+1);
	b[0]=1;
	FOR(i,1,n)h[i]=h[i-1]*233+s[i],b[i]=b[i-1]*233;
	int l=0,r=n+1;
	while(l+1<r){
		int mid=(l+r)>>1;
		mp.clear();
		int f=0;
		FOR(j,mid+1,n){
			if(mp.count(get(j,mid))){f=1;break;}
			if(j-mid+1-mid>=0)mp[get(j-mid+1,mid)]=1;	
		}
		if(f)l=mid;
		else r=mid;
	}
	out(l);
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Traveling Budget
            var line = ReadLines(4);
            int A = line[0];
            int B = line[1];
            int C = line[2];
            int D = line[3];

            Console.WriteLine(Math.Min(A, B) + Math.Min(C, D));
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var lines = new List<int>();
            string s;

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                s = Console.ReadLine().TrimEnd();
                lines.Add(int.Parse(s));
            }

            return lines;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){

  CIN(n,m);
  int one = 100*n+1800*m;
  int c = 1;
  REP(i,m)c*=2;
  COUT(one*c);

  return 0;
}

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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a, b; cin >> a >> b;

  if (a * b % 2 == 0) cout << "Even\n";
  else cout << "Odd\n";
  
  return (0);
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vi in(n+1);
		rep(i,n)cin>>in[i+1];
		vi cro;
		rep(i,n+1)rep(j,n+1)cro.pb(in[i]+in[j]);
		
		sort(all(cro));
		
		int out=0;
		rep(i,cro.size()){
			int d=m-cro[i];
			int h=cro.size();
			int l=0;
			while(1){
				if(h-l==1)break;
				int t=(h+l)/2;
				if(cro[t]>d)h=t;
				else l=t;
			}
			if(cro[i]+cro[l]<=m)out=max(out,cro[i]+cro[l]);
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll A;cin >> A;
  float b;cin >> b;
  ll B = 100.0*(b+1e-4);
  cout << (A * B)/100 << endl;
  return 0;
}


Measured memory_bytes: 3736
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k, tmp, ans, cnt, N;
string s;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;


int main(void) {
	bool flag = false;
	scanf("%d", &N);
	for (int i = 1; i < 10; i++) {
		if (N % i == 0) {
			if (N / i <= 9) {
				flag = true;
				break;
			}
		}
	}
	if (flag) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  char[] c = s.toCharArray();
  String[] t = new String[s.length()];
  for(int i = 0;i < s.length();i++){t[i] = String.valueOf(c[i]);}
  HashSet<String> hs = new HashSet<String>();
  for(int i = 0;i < s.length();i++){hs.add(t[i]);}
  if(hs.size()==t.length)System.out.println("yes");
  else System.out.println("no");
}}
    


Measured memory_bytes: 23764
import math

ARGS=input().split()
N=int(ARGS[0])
M=int(ARGS[1])
R=2

COMB=0
if N >= R:
    COMB=math.factorial(N) // math.factorial(N - R) // math.factorial(R)
if M >= R:
    COMB+=math.factorial(M) // math.factorial(M - R) // math.factorial(R)

print(str(COMB))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long llint;
const int Maxn = 200000 + 10;

int n; llint T,A[Maxn];

int main(){
	scanf("%d%lld",&n,&T);
	for(int i=1;i<=n;i++) scanf("%lld",&A[i]);
	llint last = T; llint ans = T;
	for(int i=2;i<=n;i++){
		if(last < A[i]) last = A[i];
		ans += T-last+A[i]; last = A[i] + T;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//const int N=1e6;
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int a,b;
    cin>>a>>b;
    for(int i=0;i<=20000;i++){
        double x=i*0.08;
        double y=i*0.1;
        int X=x;
        int Y=y;
        //if(x-X>=0.5)X++;
        //if(y-Y>=0.5)Y++;
        if(X==a&&Y==b){
            cout<<i<<endl;
            return 0;
        }
        //if(i==25)
    }
    cout<<-1<<endl;
    return 0;
}


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

def main(): 
    N,M = map(int,input().split())
    LR=[list(map(int,input().split())) for _ in range(M)]
    max = 0
    min = N
    for i in range(M):
        if LR[i][0] > max:
            max=LR[i][0]
        if LR[i][1] < min:
            min=LR[i][1]
    if min-max<0:
        print(0)
    else:
        print(min-max+1)
if __name__ == "__main__":
    main()
    

Measured memory_bytes: 55900
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int x= 0;
        for(int i = 1; true ; i++){
            x = n * i;
            if(x % 2 == 0){
                break;
            }
           
        }
        System.out.println(x);
    }
    
}


Measured memory_bytes: 23636
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x), (x + 2) / 3, -1):
        for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(n2 - 1, 0, -1):
                if n1 + n2 + n3 == x:
                    ans += 1
                    break
    return ans


while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x == 0:
        print(0)
    else:
        print(get_num(n, x))

Measured memory_bytes: 6420
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
 int n,m,a[100001],b[100001];
 string s;
 int main()
 {
     cin>>n>>m;
   cin>>s;
   if (s[n]=='-')
   {
for (int i=0;i<s.size();i++)
{
    if (i!=n)
    {
        if (int('9')<int(s[i]) || int(s[i])<int('0'))
        {
             cout<<"No"<<endl;
             return 0;
        }
    }
}
   }
   else 
   {
       cout<<"No"<<endl;
       return 0;
   }
   cout<<"Yes"<<endl;
 }

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

#define maxn 100010
int h[maxn];
long long t[maxn];
int n, A, B;
inline bool check(int x)
{
	long long p = 0;
	for (int i = 1; i <= n; ++i)
	{
		t[i] = h[i];
		t[i] -= 1ll * x * B;
		if (t[i] > 0) p += (t[i] + A - 1) / A;
	}
	return p <= x;
}
int main()
{
	scanf("%d%d%d", &n, &A, &B);
	for (int i = 1; i <= n; ++i) scanf("%d", h + i);
	A -= B;
	int left = 0, right = 1e9;
	while (left < right)
	{
		int mid = left + right >> 1;
		if (check(mid)) right = mid;
		else left = mid + 1;
	}
	printf("%d\n", left);
	return 0;
}

Measured memory_bytes: 1280
fun main(args: Array<String>) {

    fun calc(h: Int, n: Int, w: Int, N: Int): Double {
        var ans: Double = 1.0
        ans *= N
        ans *= n * w + h * w + h * n
        ans /= h.toDouble() * n * w
        return ans
    }

    val N = readLine()!!.toInt()
    for (h in 1..3500) {
        for (n in 1..3500) {
            var l = 1
            var r = 3500
            while (l + 1 < r) {
                val w = (l + r) / 2
                val ans = calc(h, n, w, N)
                if (4.0 == ans) {
                    print("$h $n $w")
                    return
                }
                if (4.0 < ans) {
                    l = w
                } else {
                    r = w
                }
            }
        }
    }

}


Measured memory_bytes: 31752
#include<stdio.h>
#include<string.h>
int main(){
  char s[100001], ans[50001];
  int l;
  scanf("%s", s);
  l = strlen(s);
  for(int i = 0; i < l; i += 2){
    ans[i / 2] = s[i];
  }
  printf("%s\n", ans);
  return 0;
}

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

#define rep(i,n) for (int i = 1; i <= (n); ++i)
typedef long long ll;



// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int N;
    cin>>N;
    vector<int>A(20);
    int x[20][20];
    int y[20][20];
    rep(i,N){
        cin>>A[i];
        rep(j,A[i]){
            cin>>x[i][j]>>y[i][j];
        }
    }
    int k=0;
    int ans=0;
    for(int bit=0;bit<(1<<N);bit++){
    bool ok = true;
        rep(i,N){
            if (!(bit & (1<<(i-1)))) continue; //are you honest? 
            rep(j,A[i]){
                if((bit>>(x[i][j]-1)&1)^y[i][j]) {ok=false;}
            }
        }
        if(ok){
            int a=0;
            rep(i,N){
                (bit>>(i-1)&1)?a++:1;
            }
            ans=max(ans,a);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100
typedef pair<i64, i64> P; // score, index
i64 N;
map<string, vector<P>> R;

bool comp(P x, P y) {
  return x.F > y.F;
}

int main() {
  cin >> N;
  string s;
  i64 p;
  REP(i, N) {
    cin >> s >> p;
    R[s].pb(mp(p, i + 1));  // 1-indexed
  }

  vector<P> points;
  for (auto it = R.begin(); it != R.end(); it++) {
    points = (*it).S;
    sort(points.begin(), points.end(), comp);
    REP(i, points.size()) {
      cout << points[i].S << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}
map<int,int> m1,m2;
vector<pi> v1,v2;
ll max11,max12,max21,max22;

void solve1(ll s,ll n,vi &a){
    for(int i=s;i<n;i+=2){
        if(s==0)
        m1[a[i]]++;
        if(s==1)
        m2[a[i]]++;
    }

}

int main(){

    ll n;
    cin>>n;
    vi a(n,0);
    rep(i,0,n,1)cin>>a[i];
    solve1(0,n,a);
    solve1(1,n,a);
   for(auto x:m1){
    v1.pb(mp(x.ff,x.ss));
   }
   for(auto x:m2){
    v2.pb(mp(x.ff,x.ss));
   }
   sort(v1.rbegin(),v1.rend(),sortbysec);
   sort(v2.rbegin(),v2.rend(),sortbysec);
   int i=0;
   ll max1=0,max2=0,max3=0,max4=0;
   ll max5=0,max6=0,max7=0,max8=0;
   for(auto x:v1){
        if(i>1)break;
    if(i==0){
    max1=x.ff;
    max2=x.ss;
    }
    if(i==1){
    max3=x.ff;
    max4=x.ss;
    }
    i++;
   }
   i=0;
   for(auto x:v2){
       if(i>1)break;
    if(i==0){
    max5=x.ff;
    max6=x.ss;
    }
    if(i==1){
    max7=x.ff;
    max8=x.ss;
    }
    i++;
   }
  // cout<<max1<<" "<<max2<<" "<<max3<<" "<<max4<<" "<<max5<<" "<<max6<<" "<<max7<<" "<<max8<<endl;
   ll d3=0;
   ll d=(n/2-max2);
   ll d2=(n/2-max6);
   d3=d+d2;
   if(max1==max5){
    d=n/2-max4;
    d3=d+d2;
       d3=min(d3,d+d2);
    d=n/2-max2;
    d2=n/2-max8;
       d3=min(d3,d+d2);
   }
   cout<<d3<<endl;

}


Measured memory_bytes: 87236
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll n,k;
     cin>>n>>k;
     vector<ll> v(n+1);
     ll i,j;
     for(i=1;i<=n;i++)
          cin>>v[i];
     vector<ll> dp(n+1,mod);
     dp[1]=0;
     for(i=2;i<=n;i++)
     {
          for(j=1;j<=k;j++)
          {
               if(i-j>=1)
                    dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
               else
                    break;
          }
     }
     cout<<dp[n]<<" ";
}

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

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var s=sc.str;
        var k = sc.intarr[0];

        var tab = new List<string>();
        for (int i = 0; i < s.Length; ++i)
        {
            for(int j = 1; j <= k&&i+j<=s.Length; ++j)
            {
                var t = s.Substring(i, j);
                
                    tab.Add(t);
                
            }
        }

        tab = tab.Distinct().ToList();
        tab.Sort();

        wr.wri(tab[k - 1]);



    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


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

n, m = map(int,input().split())

li = []
new_li = []

for i in range(2**n):
  i_bin = format(i, 'b').zfill(n)
  li.append(i_bin)
  
S = []
for i in range(m):
  s = list(map(int,input().split()))[1:]
  S.append(s)
   
p = list(map(int,input().split()))

for i in range(m):
  for j in li:
    count = 0
    for k in S[i]:
      count += int(j[k-1])
    if count % 2 == p[i]:
      new_li.append(j)
  li = new_li
  new_li = []
      
print(len(li)) #answer

Measured memory_bytes: 3064
d=[]
t=[]
(x=[u=1000,n=$_.to_i].min
([n-3*u,s=0].max..x).map{|a|s+=t[y=n-a]||=(([y-2*u,r=0].max..[x,y].min).map{|b|r+=d[z=y-b]||=[x,z].min-[z-u,0].max+1};r)}
p s)while gets

Measured memory_bytes: 8700
import java.util.*;

public class Main{

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

		char[] s=sc.next().toCharArray();
		String []ss=new String[3];
		int total=700;
		for(int i=0;i<3;i++){
			ss[i]=String.valueOf(s[i]);
		}
		for(int i=0;i<3;i++){
			if(ss[i].equals("o")){
				total+=100;
			}
		}
		System.out.println(total);


	}
}


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

int main()
{
    long long H, W;
    cin >> H >> W;

    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
        return 0;
    }

    if (H * W % 2 == 0)
    {
        cout << (H * W / 2) << endl;
    }
    else
    {
        cout << (H * W / 2) + 1 << endl;
    }
}


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

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

    int answer = INT_MAX;
    for (int k = 0; k <= 100000; k++)
    {
        answer = min(answer, 2 * c * k + max(x - k, 0) * a + max(y - k, 0) * b);
    }

    cout << answer << endl;
}

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

ll dp[101][10001];
int n,W;
ll v[100],w[100];
int main()
{
	cin >> n >> W;
	for(int i =0;i<n;++i)
	{
		cin >> v[i] >> w[i];
	}

	for(int i = 0;i<101;i++)
	{
		for(int j =0;j<10001;j++)
		{
		//	dp[i][j] = 1e9;
		}
	}

	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<=W;j++)
		{
			if(j-w[i]>=0)
			{
				dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
			}
			else
			{
				dp[i+1][j] = max(dp[i][j],dp[i][j]);
			}
		}
	}
	cout<<dp[n][W]<<endl;;
}


Measured memory_bytes: 10904
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <map>
#include <utility>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    int a,b;
    cin>>a>>b;
    if(a==1)a=15;
    if(b==1)b=15;
    cout<<(a>b?"Alice":a<b?"Bob":"Draw")<<endl;
    return 0;
}

Measured memory_bytes: 256
import copy

input = open(0).read

N, *X = map(int, input().split())


def main():
    a = copy.copy(X)
    l, r = sorted(a)[N // 2 - 1:N // 2 + 1]

    print('\n'.join([str(r) if x < r else str(l) for x in X]))
    return


main()


Measured memory_bytes: 30940
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
#define INF ( 1 << 30 )
#define fr first
#define sc second
const int dy[] = { 0, -1, 0, 1}, dx[] = { 1, 0, -1, 0}; //右上左下
typedef pair< int , int > Pt;
int m,n,mas[1005][1005],hw = 1000;
Pt buff[1000001],max_cost[1005][1005];
bool prime[1000001];
void Prime_set(){
  prime[1] = true;
  for(int i = 2 ; i * i < 1000001 ; i++ ){
    if(!prime[i]) for(int j = i + i ; j < 1000001 ; j += i ) prime[j] = true;
  }
}
bool isover(int y,int x){
  return y < 0 || y > 1001 || x < 0 || x > 1001 || !mas[y][x] || mas[y][x] > m;
}
void make_map(){
  fill_n(*mas,1005*1005,0);
  int cnt = 1,muki = 3;
  Pt now = Pt( hw / 2,  hw / 2),St;
  while(cnt <= 1000000){
    buff[cnt] = Pt(now.fr,now.sc);
    mas[now.fr][now.sc] = cnt++;
    Pt magaru = Pt( now.fr + dy[(muki + 1) % 4], now.sc + dx[(muki + 1) % 4]);
    if(!mas[magaru.fr][magaru.sc]) muki = (muki + 1) % 4, now = magaru;
    else now.fr += dy[muki], now.sc += dx[muki];
  }
}
Pt dfs(Pt now){
  if(max_cost[now.fr][now.sc] != Pt(-1,-1)) return max_cost[now.fr][now.sc];
  Pt ret = Pt(0,0);
  for(int i = 0 ; i < 3 ; i++ ){
    int nx = now.sc + dx[i];
    if(isover(now.fr+1,nx)) continue;
    ret = max(ret,dfs(Pt(now.fr+1,nx)));
  }
  if(!ret.sc && !prime[mas[now.fr][now.sc]]) ret.sc = mas[now.fr][now.sc];
  return max_cost[now.fr][now.sc] = Pt(ret.fr+!prime[mas[now.fr][now.sc]],ret.sc);
}
int main(){
  Prime_set();
  make_map();
  while(cin >> m >> n , m){
    fill_n(*max_cost,1005*1005,Pt(-1,-1));
    Pt ans = dfs(buff[n]);
    cout << ans.fr << " " << ans.sc << endl;
  }
}

Measured memory_bytes: 21908
#include<stdio.h>

int main( void ){
    int i,x,a,cnt = 0;
    scanf("%d", &x);
    while(x >= 100){
        x -= 100;
        cnt ++;
    }
    if(x >= 0 && x <= cnt*5){
        printf("1\n");
    } else {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, W int
	con.Scan(&N, &W)
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		con.Scan(&w[i], &v[i])
	}
	w0 := w[0]
	for i := 0; i < N; i++ {
		w[i] -= w0
	}
	dp := make([][][]int, 2)
	dp[0] = make([][]int, N+1)
	dp[1] = make([][]int, N+1)
	for i := 0; i <= N; i++ {
		dp[0][i] = make([]int, N*3+1)
		dp[1][i] = make([]int, N*3+1)
		for j := 0; j <= N*3; j++ {
			dp[0][i][j] = -1
			dp[1][i][j] = -1
		}
	}
	dp[0][0][0] = 0
	dp[1][0][0] = 0
	maxV := 0
	for i := 1; i <= N; i++ {
		w1 := w[i-1]
		v1 := v[i-1]
		d1 := dp[i&1]
		d0 := dp[(i-1)&1]
		for j := 1; j <= N; j++ {
			for k := 0; k <= N*3; k++ {
				if j*w0+k <= W && k >= w1 && d0[j-1][k-w1] >= 0 && d0[j-1][k-w1]+v1 > d0[j][k] {
					d1[j][k] = d0[j-1][k-w1] + v1
					if d1[j][k] > maxV {
						maxV = d1[j][k]
					}
				} else {
					d1[j][k] = d0[j][k]
				}
			}
		}
	}
	con.Println(maxV)
	return nil
}


Measured memory_bytes: 1152
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize(4)
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <bits/extc++.h>
#define fi first
#define se second
#define db double
#define mp make_pair
#define pb push_back
#define mt make_tuple
//#define pi acos(-1.0)
#define ll long long
#define vi vector<int>
#define mod 1000000007
#define ld long double
//#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define bpc __builtin_popcount
#define base 1000000000000000000ll
#define fin freopen("a.txt","r",stdin)
#define fout freopen("a.txt","w",stdout)
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define mr mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline void sub(ll &a,ll b){a-=b;if(a<0)a+=mod;}
inline void add(ll &a,ll b){a+=b;if(a>=mod)a-=mod;}
template<typename T>inline T const& MAX(T const &a,T const &b){return a>b?a:b;}
template<typename T>inline T const& MIN(T const &a,T const &b){return a<b?a:b;}
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll qp(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod,b>>=1;}return ans;}
inline ll qp(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=mul(ans,a,c);a=mul(a,a,c),b>>=1;}return ans;}

using namespace std;
//using namespace __gnu_pbds;

const ld pi = acos(-1);
const ull ba=233;
const db eps=1e-5;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=100000+10,maxn=2000000+10,inf=0x3f3f3f3f;

tuple<int,int,int>p[N];
int fa[N];
int Find(int x){return fa[x]==x?x:fa[x]=Find(fa[x]);}
int main()
{
    int n,m,q;scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)fa[i]=i;
    for(int i=1;i<=q;i++)
    {
        int a,b,c;scanf("%d%d%d",&a,&b,&c);
        a++,b++;
        p[i]=mt(a,b,c);
        if(!c)
        {
            a=Find(a),b=Find(b);
            if(a!=b)fa[a]=b;
        }
    }
    int num=0;
    for(int i=1;i<=q;i++)
    {
        int a,b,c;
        tie(a,b,c)=p[i];
        if(c)
        {
            num++;
            a=Find(a),b=Find(b);
            if(a==b)return 0*puts("No");
        }
    }
    int c=0;
    for(int i=1;i<=n;i++)c+=(fa[i]==i);
    if(!num)
    {
        if(c-1<=m-n+c&&m-n+c<=1ll*c*(c-1)/2)puts("Yes");
        else puts("No");
    }
    else
    {
        if(c<=m-n+c&&m-n+c<=1ll*c*(c-1)/2)puts("Yes");
        else puts("No");
    }
    return 0;
}
/********************

********************/


Measured memory_bytes: 1792
//#pragma comment (linker,"/STACK:256000000")
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

#define INF 1000000000
#define LLINF 10000000000000000

typedef long long ll;

typedef struct queue
{
	int front;
	int rear;
	int *data;
}queue;

/*
void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}
*/

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

double distance(int* a, int* b, int n, int p)
{
	double sum = 0.0;

	int i, j;

	int max = 0;

	for (i = 0; i < n; i++)
	{
		sum += pow(ABS(a[i] - b[i]), p);

		if (ABS(a[i] - b[i]) > max)
			max = ABS(a[i] - b[i]);
	}

	if (p == INF)
		return max;

	return pow(sum, (double)1 / p);
}

/*
typedef struct Vector
{
	int data[10];
	int size;
	int max;
}Vector;

Vector *init()
{
	Vector* p;

	//p = malloc(sizeof(int)*(10+2));
	p = (Vector*)(sizeof(int) * 12);
	//p->data = (int*)malloc(sizeof(int) * 10);
	p->size = 0;
	p->max = 10;

	return p;
}

Vector* Extend(Vector* p)
{
	Vector* q;

	q = (Vector*)malloc(sizeof(int) * p->max * 2);

	memcpy(q, p, sizeof(int) * p->size);

	p->max *= 2;

	free(p);

	return q;
}

Vector *pushBack(Vector *p,int x)
{
	if (p->size == p->max)
		p = Extend(p);

	p->data[p->size++] = 1;

	return p;
}

int randomAccess(Vector* p,int x)
{
	return p->data[x];
}

Vector* popBack(Vector* p)
{
	//free(p->data[--(p->size)]);
	--p->size;
	return p;
}
*/

int max_array(int* p, int n, int a, int b)
{
	int i, max = -INF;

	for (i = a; i < b; i++)
	{
		if (p[i] > max)
			max = p[i];
	}
	return  max;
}

int min_array(int* p, int n, int a, int b)
{
	int i, min = INF;

	for (i = a; i < b; i++)
	{
		if (p[i] < min)
			min = p[i];
	}
	return  min;
}
int main()
{
	int a[1000];
	int n;
	int temp;
	int q, l, m;

	scanf("%d", &n);

	int i, j;

	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	scanf("%d", &q);

	for (i = 0; i < q; i++)
	{
		scanf("%d%d%d", &temp,&l,&m);
		if (temp == 0)
			printf("%d\n", min_array(a, n, l, m));
		else
			printf("%d\n", max_array(a, n, l, m));
	}
	return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 
int main() {
	ll n;
	cin>>n;
	n--;
	cout << n<<endl;
	string s;
	cin>>s;
	if(s=="Vacant"){
		return 0;
	}
	ll kiso=0;
	while(true){
		ll sa=(n-kiso)/2;
		ll next=n-sa;
		if(sa==0){
			next=kiso;
		}
		cout << next<<endl;
		string t;
		cin>>t;
		if(t=="Vacant"){
			return 0;
		}
		if(sa%2==0){
		 if(s==t){
			n=next;
		}
		else{
			kiso=next;
		}
		}
		else{
					 if(s!=t){
						s=t;
			n=next;
		}
		else{
			kiso=next;
		}
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
int freq[255];
int vis[255];
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ss1,ss2;
    int ans;
    set<int>st1,st2;
    int max=0;
    for(int i=0;i<n;i++)
    {
        for(int i=0;i<26;i++) { freq[i]=0; vis[i]=0; }
        for(int j=0;j<=i;j++)
        {
            freq[s[j]-'a']++;
        }
        int cnt=0;
        for(int j=i+1;j<n;j++)
        {
            if(freq[s[j]-'a']>0 && !vis[s[j]-'a'])
            {
                cnt++;
                vis[s[j]-'a']=1;
            }
        }
        if(cnt>max) max=cnt;
    }
    cout<<max<<endl;
}



Measured memory_bytes: 256
N =int(input())
A = [int(i) for i in input().split()]
chk = 0
for i in range(N):
	if A[i]%2 == 0:
		if A[i]%3 == 0 or A[i]%5 == 0:
			continue
		else:
			chk = 1
			break
if chk == 1:
	print("DENIED")
else:
	print("APPROVED")

Measured memory_bytes: 38324
#include<bits/stdc++.h>
using namespace std;
#define maxn 500
#define P pair<int,int>
int a[maxn],n;
int mx=-1,id=1;
P op[maxn];
int cnt;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        if(abs(a[i])>mx)
        {
            mx=abs(a[i]);
            id=i;
        }
    }
    bool ok=0;
    for(int i=1;i<=n;++i)
    {
        if(i==id) continue;
        a[i]+=a[id];
        if(a[i]>0) ok=1;
        op[cnt++]=P(id,i);
    }
    if(ok) for(int i=2;i<=n;++i) op[cnt++]=P(i-1,i);
    else for(int i=n;i>=2;--i) op[cnt++]=P(i,i-1);
    printf("%d\n",cnt);
    for(int i=0;i<cnt;++i) printf("%d %d\n",op[i].first,op[i].second);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

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

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

/////////////////////////////////////////////////////////

void Main() {
  ll a, b; cin >> a >> b;
  string res;
  if(a == 0 || b == 0 || (a < 0 && 0 < b)) res = "Zero";
  else if(a > 0) res = "Positive";
  else if(b < 0){
    if((b - a) % 2) res = "Positive";
    else res = "Negative";
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
const int MAXN = 200100;
int fat[MAXN];
int inv[MAXN];

int C(int n,int k){
	if(k>n)return 0;
	return mod(fat[n]*mod(inv[n-k]*inv[k],M),M);
}

int dp[MAXN];
int cmp(pii a,pii b){
	return a.ff + a.ss < b.ff + b.ss;
}


int32_t main(){
	fastio;
    fat[0] = inv[0] = 1;
    for(int i=1;i<MAXN;i++){
		fat[i] = (i*fat[i-1])%M;
		inv[i]  = exp(fat[i],M-2,M);
	}
	int h,w,n;
	cin>>h>>w>>n;
	vector<pii> v;
	for(int i=0;i<n;i++){
		int r,c;
		cin>>r>>c;
		v.pb(pii(r,c));
	}
	v.pb(pii(h,w));
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<(int)v.size();i++){
		
		dp[i] = C(v[i].ff + v[i].ss - 2, v[i].ff - 1);
		int r = v[i].ff,c = v[i].ss;
		for(int j=0;j<i;j++){
			int r1 = v[j].ff,c1 = v[j].ss;
			if(r1<=r && c1<=c){
				dp[i] = mod(dp[i]  - dp[j]*C(r-r1 + c - c1,r-r1),M);
			}
		}
	}
	cout << dp[(int)v.size() - 1] <<endl;
	
	
}

Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));		
		char s[] = br.readLine().toCharArray();
		char t[] = br.readLine().toCharArray();
		br.close();

		int row = t.length;
		int col = s.length;
		int tb[][] = new int[row + 1][col + 1];

		for ( int r = 0; r < row; r++ ) {
			for ( int c = 0; c < col; c++ ) {
				if ( t[r] == s[c] ) {
					tb[r + 1][c + 1] = tb[r][c] + 1;
				} else {
					tb[r + 1][c + 1] = Math.max(tb[r + 1][c], tb[r][c + 1]);
				}
			}
		}

		int r = row;
		int c = col;
		ArrayDeque<Character> stack = new ArrayDeque<Character>();
		stack.add(' ');
		while ( tb[r][c] != 0 ) {

			// 左上に行けるとき
			if ( tb[r - 1][c - 1] == tb[r][c] ) {
				r -= 1;
				c -= 1;
			} else
			// 上
			if ( tb[r - 1][c] == tb[r][c] ) {
				r -= 1;
			} else
			// 左
			if ( tb[r][c - 1] == tb[r][c] ) {
				c -= 1;
			} else
			// 行き止まり
			{
				stack.addFirst( s[c - 1]);
				r -= 1;
				c -= 1;
			}
		}
		
		StringBuilder sb = new StringBuilder();
		while ( stack.size() > 0 ) {
			sb.append(stack.pollFirst());
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 78676
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
const int MAXN = 200005;
int dmx[MAXN],umx[MAXN],n,bdmn[MAXN],bsize[MAXN],nmx[MAXN],fa[MAXN];
vector<int>e[MAXN];
typedef vector<int>::iterator VI;
char s[MAXN];
void getdown(int x,int f)
{
    bsize[x]=s[x]-'0';
    for(VI v=e[x].begin();v!=e[x].end();++v){
        if(*v==f)continue;
        getdown(*v,x);
        fa[*v]=x;
        dmx[x]=max(dmx[x],dmx[*v]+1);
        if(bsize[*v])bdmn[x]=min(bdmn[x],dmx[*v]+1);
        bsize[x]+=bsize[*v];
    }
    if(s[x]=='1')bdmn[x]=min(bdmn[x],dmx[x]);
}
void getup(int x,int fa)
{
    umx[x]=max(umx[x],(fa?1:0)+umx[fa]);
    if(fa)nmx[x]=max(nmx[x],umx[x]-1);
    int pre=-1,suf=-1;
    for(int i=0,v;i<e[x].size();++i){
        v=e[x][i];
        if(v==fa)continue;
        umx[v]=max(umx[v],pre+2);
        pre=max(pre,dmx[v]);
    }
    for(int i=e[x].size()-1,v;i>=0;--i){
        v=e[x][i];
        if(v==fa)continue;
        umx[v]=max(umx[v],suf+2);
        getup(v,x);
        suf=max(suf,dmx[v]);
    }
}
int main()
{
    memset(bdmn,0x3f,sizeof(bdmn));
    scanf("%d",&n);
    for(int i=1;i<n;++i){int u,v;scanf("%d%d",&u,&v);e[u].push_back(v),e[v].push_back(u);}
    scanf("%s",s+1);
    int all0=true;
    for(int i=1;i<=n;++i)if(s[i]-'0')all0=false;
    if(all0){puts("0");return 0;}
    getdown(1,0);
    getup(1,0);
    long long ans=0;
    for(int i=1;i<=n;++i){
        int low=0x3f3f3f3f,hi=0;
        if(s[i]=='1')low=0;
        else low=min(bdmn[i],bsize[i]==bsize[1]?0x3f3f3f3f:umx[i]);
        hi=max(dmx[i],umx[i])-1;
        for(VI v=e[i].begin();v!=e[i].end();++v){
            if(*v==fa[i])hi=min(hi,dmx[i]+1);
            else hi=min(hi,nmx[*v]+1);
        }
        ans+=max(0,hi-low+1);
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 28032