akhauriyash/Code-Regression huggingface dataset:
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine().Replace(" ", "");
            int num = int.Parse(str);
            if (num % 4 == 0)
            {
                Console.WriteLine("YES");
            } else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <math.h>
using namespace std;
int main() {
	string a,b;
	int i,j,k=0;
	cin >> a >> b;
	a=a+b;
	for(i=0;i<a.size();i++)
	{
		k*=10;
		k+=a[i]-'0';
	}
	int x=sqrt(k);
	if(x*x==k)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >>A>>B>>C>>D;
  int i = 0;
  while (A>0){
    A -= D;
    i++;}
  int j = 0;
  while (C>0){
    C -= B;
    j++;}
  if (i<j){
    cout << "No" <<endl;
  }
  else {
    cout << "Yes" <<endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;

int arr[100005];
int memo[100005];
int main()
{
    int n, m;
    cin >> n >> m;
    
    memset (arr, 0, sizeof (arr));
    memset (memo, 0, sizeof (memo));
    memo[1] = 1;
    for (int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        
        arr[b]++;
        arr[a]--;
        
        if (memo[a] == 1)
            memo[b] = 1;
        if (arr[a] == -1)
            memo[a] = 0;
    }
    
    int cntr = 0;
    for (int i = 1; i <= n; i++){
        if (memo[i] == 1)
            cntr++;
    }
    cout << cntr << endl;
}

//1 2 3 4
//1 1 1 1


Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector <int> vi;
const int MOD = 1e9 + 7;

void solve(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a.back() == b[0] && b.back() == c[0]) cout << "YES";
    else cout << "NO";
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}

Measured memory_bytes: 256
N=int(input())
alist=[0]+list(map(int,input().split()))

answer=0
if alist[N]==N:
  alist[N-1],alist[N]=alist[N],alist[N-1]
  answer+=1

for i in range(1,N+1):
  if alist[i]==i:
    alist[i],alist[i+1]=alist[i+1],alist[i]
    answer+=1
    
print(answer)

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

int main() {
	int n,ic;
	int icecreams[10];
	
	while(cin>>n,n){
		for(int i=0;i<10;++i)icecreams[i]=0;
		
		for(;n;--n){
			cin>>ic;
			icecreams[ic]++;
		}
		
		for(int i=0;i<10;++i){
			if(icecreams[i]){
				for(;icecreams[i];--icecreams[i])cout<<"*";
				cout<<endl;
			}else{
				cout<<"-"<<endl;
			}
		}
	}
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int N = S.size(), M = 2019;
  reverse(S.begin(), S.end());
  vector<int> sur(M);
  int dig = 1, sum = 0;
  sur.at(sum)++;
  for (int i = 0; i < N; i++) {
    sum += (S.at(i) - '0') * dig;
    sum %= M;
    sur.at(sum)++;
    dig *= 10;
    dig %= M;
  }
  int ans = 0;
  for (auto s : sur) ans += s * (s - 1) / 2;
  cout << ans << "\n";
}

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	long long N;
	scanf("%lld", &N);

	if(N%2==0){
		printf("%lld\n", N);
	}else{
		printf("%lld\n", N*2);
	}

	return 0;
}


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

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

    ll n;
    cin >> n;
    if (n % 2) {
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    ll d = 1, ans = 0;
    while (d * 5 <= n) {
        d *= 5;
        ans += n / d;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a, b;
	bool f = false;
	cin >> a >> b;
	for (int i = 0; i < max(a, b); i++) {
		if (abs(a - i) == abs(b - i)) {
			cout << i << endl;
			f = true;
		}
	}
	if (!f)cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int N,A,B;
  in(N,A,B);
  string S;
  in(S);
  int a=0,b=0;
  rep(i,N){
    if(S[i]=='a'&&a+b<A+B){
      out("Yes");
      a++;
    }
    else if(S[i]=='b'&&a+b<A+B&&b<B){
      out("Yes");
      b++;
    }else{
      out("No");
    }
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

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

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

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

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


//ここから編集する
class Solve {
public:
    void input() {

    }

    bool check(char c) {
        if (c == 'A') {
            return true;
        } else if (c == 'T') {
            return true;
        } else if (c == 'G') {
            return true;
        } else if (c == 'C') {
            return true;
        }
        return false;
    }

    void solve() {
        input();
        string s;
        cin >> s;
        string ans = "";

        for (int i = 0; i < s.size(); ++i) {
            string tmp;
            for (int j = i; j < s.size(); ++j) {
                if (check(s[j])) {
                    tmp += s[j];
                } else {
                    break;
                }
            }
            if (ans.size() < tmp.size()) {
                ans = tmp;
            }

        }

        cout << ans.size() << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<bool> Row(H, false), Column(W, false);
    string board[H];

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

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(board[i][j] == '#') {
                Column[j] = true;
                Row[i] = true;
            }
        }
    }

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(Column[j] && Row[i]) {
                cout << board[i][j];
            }
        }
        if(Row[i]) {
            cout << endl;
        }
    }
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int N, K;
  cin>>N>>K;
  int a[N];
  REP(i, N) cin>>a[i];

  if(N==1){
    int amax=0;
    REP(i, N)amax=max(amax, a[i]);
    cout<<amax<<endl;
    return 0;
  }
  int m=N*(N+1)/2;


  LL beauty[m];
  int x=0;
  LL amax=1, temp;
  REP(i, N){
    temp=0;
    for(int j=i; j<N; ++j){
      temp += a[j];
      beauty[x]=temp;
      amax=max(amax, temp);
      ++x;
    }
  }

  sort(beauty, beauty+m, greater<LL>());
  LL y=1;
  while(y*2<amax)y*=2;

  LL ans=0;
  bool ok[m];
  bool oktemp[m];
  REP(i, m) ok[i]=true;
  int count;
  while(y>0){
    count=0;
    REP(i, m){
      if(beauty[i]&y && ok[i]){
        ++count;
        oktemp[i]=true;
      }
      else oktemp[i]=false;
    }
    if(count>=K){

      ans += y;
      //cout<<y<<" "<<ans<<endl;
      REP(i, m)ok[i]=ok[i]&oktemp[i];
    }
    y/=2;
  }



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


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a,b,c,d;
    int i=0;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0)
    {
        if(i%2==0)
        c-=b;
        else
        a-=d;
        i++;
    }
    if(a<=0)
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                      
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e5 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


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




vector < vi > mult (vector < vi > a, vector < vi > b) {
	int n = sz(a), m = sz(a[0]), k = sz(b[0]);
	vector < vi > res(n, vi(k));

	forn (i, 0, n - 1)                                                    	
		forn (j, 0, k - 1)
			forn (x, 0, m - 1)
				add(res[i][j], a[i][x] * 1ll * b[x][j] % mod);			 

	return res;
}

vector < vi > binpow (vector < vi > a, int n) {
	int m = sz(a);
	vector < vi > res(m, vi(m));	
	forn (i, 0, m - 1)
		res[i][i] = 1;

	while (n) {
		if (n & 1)
			res = mult(res, a);
		a = mult(a, a);
		n >>= 1;
	}

	return res;
}


int n, k;

main () {
	cin >> n >> k;
	vector < vi >  g(n, vi(n));
	forn (i, 0, n - 1)
		forn (j, 0, n - 1)
			cin >> g[i][j];

	g = binpow(g, k);	
	int ans = 0;;
	forn (i, 0, n - 1)
		forn (j, 0, n - 1)
			add(ans, g[i][j]);

	cout << ans << endl;
}

    

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    for (auto i = s.begin(); i != s.end(); ++i) *i = 'A' + (*i - 'A' + n) % 26;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

k = inn()
x = 0
ten2n = 1
for i in range(1,10**6):
    x = (x+7*ten2n)%k
    if x==0:
        print(i)
        exit()
    ten2n = (ten2n*10)%k
print(-1)


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

int main() {
  string n;
  cin>>n;
  set<int> s;
  rep(i,n.size()){
    if(s.count(n[i])) {
      puts("no");
      return 0;
    }      
    else s.insert(n[i]);
  }
  puts("yes");
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)
	sum := 0
	for i := 0; i < n; i++ {
		sum += a[i]
	}
	sum %= mod

	ans := 0
	for i := 0; i < n; i++ {
		sum -= a[i]
		sum %= mod
		ans += a[i] * sum
		ans %= mod
	}
	fmt.Fprintln(wr, (ans+mod)%mod)
}

const mod = 1000000007


Measured memory_bytes: 6100
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}



Measured memory_bytes: 3144
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

A,B = II()

print(max(A+B,A-B,A*B))

Measured memory_bytes: 38384
x, y = map(int, input().split())
ans = float('inf')
# for negative input return 'inf', otherwise, return input
filt = lambda z: [ z, float('inf') ][ z < 0 ]
ans = min(ans, filt(   y  -    x )    )
ans = min(ans, filt(   y  - (- x)) + 1)
ans = min(ans, filt((- y) -    x ) + 1)
ans = min(ans, filt((- y) - (- x)) + 2)
print(ans)

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

using namespace std;

int n, k;
vector<int> x;

int solve() {
    if (k >= n) return 0;
    vector<int> diff;

    for (int i = 0; i < static_cast<int>(x.size()) - 1; ++i) {
        diff.push_back(x[i+1] - x[i]);
    }

    sort(diff.begin(), diff.end(), greater<int>());

    int total = 0;
    for (auto e : diff) {
        total += e;
    }

    for (int i = 0; i < k - 1; ++i) {
        total -= diff[i];
    }

    diff.clear();
    return total;
}

int main(int argc, char const *argv[]) {
    int t;
    cin>>t;
    for (int i = 0; i < t; ++i) {
        cin>>n>>k;
        for (int j = 0; j < n; ++j) {
            int tmp;
            cin>>tmp;
            x.push_back(tmp);
        }

        cout<<solve()<<endl;
        x.clear();
    }
    return 0;
}

Measured memory_bytes: 4248
/**********************************

Sometimes the people whom no one ever imagines anything of,
do the things that no one can ever imagine.

***********************************/
#include <bits/stdc++.h>
using namespace std;

#define EPS (1e-12)
#define ll long long int
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pi 3.141592653589
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define precise(n) cout << fixed << setprecision(n)
#define pcase cout<<"Case "<<++cs<<": "
const int mod=1e9+7;
ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}



int main()
{
      int a,b,n,i,j,k,cnt=1;


      cin >> n ;
      int arr[n];
      cin >> arr[0];
      k=arr[0];
      for(i=1;i<n;i++)
      {
          cin >> arr[i];

          if(arr[i]>=arr[0]&& arr[i]>=k) {cnt++;
          k=max(arr[i],arr[i-1]);
      }
      }
      cout << cnt << endl;



      return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define inf (1<<26)

int ret , n;
vector<int> table;
void dfs(int sum , int pos , int depth , int c){
	if(depth == c-1){
		if(binary_search(table.begin()+pos,table.end(),n-sum))ret++;
		return;
	}
	for(int i = pos ; i < table.size(); i++){
		dfs(sum+table[i],i,depth+1,c);
	}
}
int main(){
	
	for(int i = 1 ; i*i <= (1<<15) ; i++){
		table.push_back(i*i);
	}
	while(cin >> n , n){
		ret = 0;
		for(int i = 1 ; i < 5 ; i++){
			dfs(0,0,0,i);
		}
		cout << ret << endl;
	}
}

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

using namespace std;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int cnt=1;
  for(int i=1;i<n;i++){
    if(s[i] !=s[i-1]){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = List.fill(n)(sc.nextLong())
  val d = a.groupBy(identity).collect{ case (k, v) =>
    List.fill(v.length / 2)(k)
  }.flatten.toList.sorted.reverse

  if (d.length >= 2) {
    println(d.take(2).product)
  } else {
    println(0)
  }
}


Measured memory_bytes: 83292
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,h[111111]={},cnt=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a;
    if(a==i)h[i]++;
  }
  for(int i=0;i<100001;i++){
    if(h[i]==1){
      if(h[i+1]==1){
	cnt++;
	h[i+1]=0;
      }else cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <queue>
#include <set>
using namespace std;
int ques[10];
int dp[50000];
const int rights[9] = {0,5040,720,120,24,6,2,1};
int qtint(int arr[])
{
	int ret(0);
	bool isf[9];
	memset(isf,0,sizeof isf);
	for(int i(1);i<=8;++i)
	{
		int cnt(0);
		for(int j(0);j<arr[i];++j)
		{
			if(!isf[j])	++cnt;	
		}
		isf[arr[i]] = true;
		ret += cnt*rights[i];
	}
	return ret;
}
int main()
{
	memset(dp,-1,sizeof dp);
	queue<int> q,qv;
	q.push(0), qv.push(0);
	dp[0] = 0;
	while(!q.empty())
	{
		int stat(q.front()),step(qv.front());
		q.pop(), qv.pop();
		int astat[10];
		bool isf[9];
		memset(isf,0,sizeof isf);
		for(int i(1);i<8;++i)
		{
			int cnt(stat/rights[i]+1);
			int pos(0);
			for(;cnt;++pos)
			{
				if(!isf[pos])	--cnt;
				if(cnt==0)	break;
			}
			isf[pos] = true;
			stat %= rights[i];
			astat[i] = pos;
		}
		for(int i(0);i<8;++i)
			if(!isf[i])
			{ astat[8] = i; break; }
		int zpx(0),zpy(0);
		for(int i(1);i<=8;++i)
		{
			if(astat[i]==0)
				zpx=(i-1)/4+1, zpy=(i-1)%4+1;
		}
		if(zpx!=1)
		{
			int zpos((zpx-1)*4+zpy),cpos((zpx-2)*4+zpy);
			astat[zpos] = astat[cpos];
			astat[cpos] = 0;
			if(dp[qtint(astat)]==-1)
			{
				dp[qtint(astat)] = step+1;
				q.push(qtint(astat)), qv.push(step+1);
			}
			astat[cpos] = astat[zpos];
			astat[zpos] = 0;
		}
		if(zpx!=2)
		{
			int zpos((zpx-1)*4+zpy),cpos((zpx)*4+zpy);
			astat[zpos] = astat[cpos];
			astat[cpos] = 0;
			if(dp[qtint(astat)]==-1)
			{
				dp[qtint(astat)] = step+1;
				q.push(qtint(astat)), qv.push(step+1);
			}
			astat[cpos] = astat[zpos];
			astat[zpos] = 0;

		}
		if(zpy!=1)
		{
			int zpos((zpx-1)*4+zpy),cpos((zpx-1)*4+zpy-1);
			astat[zpos] = astat[cpos];
			astat[cpos] = 0;
			if(dp[qtint(astat)]==-1)
			{
				dp[qtint(astat)] = step+1;
				q.push(qtint(astat)), qv.push(step+1);
			}
			astat[cpos] = astat[zpos];
			astat[zpos] = 0;

		}
		if(zpy!=4)
		{
			int zpos((zpx-1)*4+zpy),cpos((zpx-1)*4+zpy+1);
			astat[zpos] = astat[cpos];
			astat[cpos] = 0;
			if(dp[qtint(astat)]==-1)
			{
				dp[qtint(astat)] = step+1;
				q.push(qtint(astat)), qv.push(step+1);
			}
			astat[cpos] = astat[zpos];
			astat[zpos] = 0;

		}	
	}
	while(~scanf("%d",ques+1))
	{
		for(int i(2);i<=8;++i)
			scanf("%d",ques+i);
		printf("%d\n",dp[qtint(ques)]);
	}
	return 0;
}



Measured memory_bytes: 2892
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i,s.size()) rep2(j,1,s.size()-i+1) {
        string ns = s.substr(i,j);
        bool ok = true;
        for(char c : ns) if(c!='A' && c!='C' && c!='G' && c!='T') ok = false;
        if(ok) ans = max(ans,j);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] inputs = scanner.nextLine().split(" ", 0);
		int A = Integer.parseInt(inputs[0]);
		int B = Integer.parseInt(inputs[1]);
		if(A <= 5) {
			System.out.println("0");
		}else if(A <= 12) {
			System.out.println(B / 2);
		}else{
			System.out.println(B);
		}
	}
}

Measured memory_bytes: 20820
D,G = map(int,input().split())
b = []
c = []
for i in range(D):
    x,y = map(int,input().split())
    b.append(x)
    c.append(y)
res = 1e9
for i in range(1<<D):
    s = format(i,"0"+str(D)+"b")
    score = 0
    num = 0 
    for j in range(D):
        if s[j]=='1':
            num+=b[j]
            score += b[j]*(j+1)*100 + c[j]
    if score >= G:
        res = min(num,res)
    else:
        for j in range(D)[::-1]:
            if s[j] == '0':
                if score + (b[j]-1)*100*(j+1)>=G:
                    if (G-score)%(100*(j+1))==0:
                        num+= (G-score)//(100*(j+1))
                        score = G
                    else:
                        num+= (G-score)//(100*(j+1)) + 1
                        score = G
                    break
                else:
                    num+= b[j]-1
                    score += (b[j]-1)*100*(j+1)
        if score>=G:
            res = min(num,res)
print(res)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define mod ((ll)1e9+7)
#define inf ((ll)1e18+5)
#define maxx ((ll)1e6+5)
#define pb push_back
#define endl "\n"
#define time(i) cout<<"\nTime Elapsed "<<i<<" : " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#define usefile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll expm(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
/*
bool sv[maxx]={0};    // returns 0 if a num is prime
int sp[maxx]={0};     // gives smallest prime factor of the number
void Sieve() {for(int i= 2; i< maxx; i+= 2) sv[i]=1,sp[i] = 2;sv[2]=0;for(ll i = 3; i < maxx; i += 2){if (!sv[i]){sp[i] = i;for (ll j = i; (j*i) < maxx; j += 2){if (!sv[j*i])sv[j*i] = true, sp[j*i] = i;}}}}
ll fact[maxx]={0}; // returns factorial of that number
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<maxx;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncrm(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expm(fact[r],mod-2)))%mod; res=(res*(expm(fact[n-r],mod-2)))%mod; return res;}
ll inv[maxx];   // returns the modular inverse of number
void inversify( ll m){inv[1]=1;for(int i=2;i<maxx;i++){inv[i]= m- m/i*inv[m%i]%m;}}
ll ncr(ll n,ll r,ll m){int ans=1;for (int i = 0; i < r; i++){ans=ans*(n-i)%m*inv[i+1]%m;}return ans;}
*/
signed main(){
  fast;
  //usefile;
  //test
  {
    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1);
    for(int i=k;i>=1;i--){
      int times=k/i;
      dp[i]=expm(times,n);
      for(int j=2*i;j<=k;j+=i)
        dp[i]=(dp[i]-dp[j]+mod)%mod;
      // cout<<dp[i]<<" "<<i<<endl;
    }
    int ans=0;
    for(int i=1;i<=k;i++)
    {
      ans=(ans+(i*dp[i])%mod)%mod;
    }
    cout<<ans;
  }
  //time("");
  return 0;
}

Measured memory_bytes: 4000
class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        self.parent[x] = y

    def same(self, x, y):
        return self.find(x) == self.find(y)


while True:
    N, Q = map(int, input().split())
    if N == Q == 0:
        break
    parent = [0, 1] + [int(input()) for i in range(2, N+1)]
    queries = []
    marked = set([1])
    for i in range(Q):
        o, v = input().split()
        v = int(v)
        if o == 'M':
            if v in marked:
                continue
            marked.add(v)
        queries.append((o, v))

    uf = UnionFind(N+1)
    for i in range(1, N+1):
        if i not in marked:
            uf.unite(i, parent[i])

    ans = 0
    for o, v in reversed(queries):
        if o == 'M':
            uf.unite(v, parent[v])
        else:
            ans += uf.find(v)

    print(ans)



Measured memory_bytes: 28252
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.equals("A")) {
            System.out.println("T");
        } else if(s.equals("T")) {
            System.out.println("A");
        } else if(s.equals("G")) {
            System.out.println("C");
        } else if(s.equals("C")) {
            System.out.println('G');
        }
    }
}

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

using namespace std;

int main(){
	int n, ans = 1e8;
	cin >> n;
	vector<int> x(n);
	for(auto& i:x)
		cin >> i;
	for (int i = 1; i <= 100; i++)
	{
		int sp = 0;

		for (int j = 0; j < n; j++)
		{
			sp += (x[j] - i) * (x[j] - i);
		}
		ans = min(ans, sp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  if a[i]>=b[i]:
    cnt+=b[i]
  else:
    b[i]-=a[i]
    cnt+=a[i]
    if a[i+1]>=b[i]:
      cnt+=b[i]
      a[i+1]-=b[i]
    else:
      cnt+=a[i+1]
      a[i+1]=0
print(cnt)

Measured memory_bytes: 18624
#include <iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    for(int i = 0;i <= 1251;i++){
        if(int(i * 0.08) == A && int(i * 0.1) == B){
            cout  << i << endl; 
            break;
        }else if(i == 1251){
            cout  << "-1" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long 
#define mod 1000000007

int main()
{
	ll n;
	cin>>n;
	ll a[n+10];
	for(ll i=1;i<=n;i++) cin>>a[i];
	for(ll i=n;i>=1;i-=2)
	{
		cout<<a[i]<<" ";
	}
	int q;
	if(n%2==0) q=1;
	else
	{
		q=2;
	} 
	for(ll i=q;i<=n;i+=2)
	{
		cout<<a[i]<<" ";
	}
}

Measured memory_bytes: 3712
import java.util.*;

class Reader {
  Scanner sc = new Scanner(System.in);

  public int ini() {
    return sc.nextInt();
  }

  public String insl() {
    return sc.nextLine();
  }

  public void skip() {
    sc.nextLine();
  }

  public int[] vi(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextInt();
    return a;
  }

  public long[] vl(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextLong();
    return a;
  }

  public String[] vsl(int n) {
    String[] a = new String[n];
    for (int i = 0; i < n; i++) a[i] = sc.nextLine();
    return a;
  }
}

public class Main extends Reader {
  public static void main(String[] args) {
    Main main = new Main();
    main.show(main.solve());
  }

  int r;
  int a[];

  public Main() {
    r = ini();
  }
  
  int solve() {
    if (2800 <= r) return 1;
    if (1200 <= r) return 2;
    return 3;
  }

  void show(int ans) {
    System.out.println(ans == 1 ? "AGC" : ans == 2 ? "ARC" : "ABC");
  }
}

Measured memory_bytes: 35844
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = s.substring(0, Math.min(4, s.length()));
		if (t.equals("YAKI")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main() {
	int n;
	int kigu;
	int tyuuou;
	int a[200010];
	int b[200010];
 	int i;

	int a_min;
	int a_max;
	int b_min;
	int b_max;

	cin >> n;
	if(n % 2 ==0){
		kigu = 0;
		tyuuou = n / 2;
	} else {
		kigu = 1;
		tyuuou = ( n + 1 )/2;
	}
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n, greater<int>());  // a[0:n-1] を大きい順にソート
	sort(b, b + n, greater<int>());  // b[0:n-1] を大きい順にソート
	if (kigu==0){
		cout << b[tyuuou]-a[tyuuou]+b[tyuuou-1]-a[tyuuou-1]+1<< endl;
	} else {
		cout << b[tyuuou-1]-a[tyuuou-1]+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5176
package main

import (
	"fmt"
)

func main() {
	// Code for A - Wanna go back home
	var S string
	fmt.Scanf("%s", &S)

	count := make(map[string]int, len(S))
	for i := 0; i < len(S); i++ {
		count[S[i:i+1]]++
	}

	var flag1 int = 0
	if count["W"] == 0 && count["E"] == 0 {
		flag1 = 1
	} else if (count["W"] == 0 && count["E"] != 0) || (count["W"] != 0 && count["E"] == 0) {
		flag1 = 0
	} else {
		flag1 = 1
	}

	var flag2 int = 0
	if count["N"] == 0 && count["S"] == 0 {
		flag2 = 1
	} else if (count["N"] == 0 && count["S"] != 0) || (count["N"] != 0 && count["S"] == 0) {
		flag2 = 0
	} else {
		flag2 = 1
	}

	if flag1 == 1 && flag2 == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1868
{-# OPTION_GHC -O2 #-}

import Data.List (transpose, sort)

main = do

    [n, h] <- take 2 . map read . words <$> getLine
    sords <- sequence $ replicate n (map read . words <$> getLine) :: IO [[Int]]

    let [atks, thrs] = transpose sords
        maxDps = maximum atks
        needThrowSords = reverse . sort . filter (maxDps <) $ thrs
        attackCount
            | h <= sum needThrowSords = (+1). length . takeWhile (h >) . scanl1 (+) $ needThrowSords
            | otherwise               = 1 + length needThrowSords + (h - 1 - sum needThrowSords) `div` maxDps
        in
            print attackCount

Measured memory_bytes: 183676
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	s := nextString()

	n := len(s)
	if !palindrome(s) {
		fmt.Println("No")
		return
	}
	if !palindrome(s[:(n-1)/2]) {
		fmt.Println("No")
		return
	}
	if !palindrome(s[(n+3)/2-1 : n]) {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

func palindrome(s string) bool {
	i, j := 0, len(s)-1
	for i < j {
		if s[i] != s[j] {
			return false
		}
		i++
		j--
	}
	return true
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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 main() {
	ll a,b;
	cin >> a >> b;
	ll gcd = __gcd(a,b);
	int ans = 1;
	for(int i=2; i<=sqrt(gcd); i++) {
		if(gcd % i == 0) ans++;
		while(gcd % i == 0) {
			gcd /= i;
		}
	}
	if(gcd != 1) ans++;
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){



string str;
int n;
string command;
int first;
int second;
string third;
string reversestr;

cin>>str;
cin>>n;
for(int i=0;i<n;i++){
cin>>command;

if(command=="print"){

cin>>first>>second;
cout<<str.substr(first,second-first+1)<<endl;

}else if(command=="reverse"){
reversestr="";
cin>>first>>second;
for(int i=second;first<=i;i--){
reversestr=reversestr+str[i];
}
str.replace(first,second-first+1,reversestr);

}else if(command=="replace"){

cin>>first>>second>>third;
str.replace(first,second-first+1,third);
}
}


}


Measured memory_bytes: 3208
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b;
    cin >> a  >> b;
    cout << a*a-b << endl;
    
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt // 最初の数字を読み取る
  val lst1 = Array.fill(n)(sc.nextInt) ++ Array(-1) // nextIntがn回呼ばれる

  val t = sc.nextInt // 最初の数字を読み取る
  val lst2 = Array.fill(t)(sc.nextInt) // nextIntがn回呼ばれる
  
  val result = lst2.foldLeft(0){ (acc, e) =>
    lst1(n) = e
    var i = 0
    while(lst1(i)!=e)i+=1

    if(i == n) acc else acc + 1
  }
  
  println(result)

}



Measured memory_bytes: 58036
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];
vector<pair<string, int> > All;

int main() {
  int N; cin >> N;
  for (int i = 1; i <= N; i++) {
    string s; int t; cin >> s >> t;
    Input[t] = i;
    All.push_back(make_pair(s, t));
  }
  auto comparator = [](const pair<string, int> &l, const pair<string, int> & r) {
                      if (l.first == r.first) {
                        return l.second > r.second;
                      } else {
                        return l.first < r.first;
                      }
                    };
    
  sort(All.begin(), All.end(), comparator);

  for (auto x: All) {
    cout << Input[x.second] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    string S;
    cin >> S;
    int s_size = S.size();
    int one_count = 0;
    int zero_count = 0;
    for (int i=0; i<s_size; i++) {
        if (S[i] == '0') {
            zero_count += 1;
        } else {
            one_count += 1;
        }
    }

    cout << 2 * min(one_count, zero_count) << endl;
    return 0;
}

Measured memory_bytes: 3756
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#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++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

int main(void) {

	int n, l;
	cin >> n >> l;

	int ans = inf, aji = 0, I = inf;
	REP(i, n) {
		ans = min(ans, abs(l + i));
		if (ans == abs(l + i)) I = i;
		aji += l + i;
	}
	cout << aji - (l + I) << endl;

	return 0;

}

Measured memory_bytes: 256
# https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c

from decimal import Decimal

import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    a, b, c = input_int_list()
    sqrt_a = Decimal(a)**Decimal("0.5")
    sqrt_b = Decimal(b)**Decimal("0.5")
    sqrt_c = Decimal(c)**Decimal("0.5")
    if sqrt_a + sqrt_b < sqrt_c:
        print("Yes")
    else:
        print("No")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 77552
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,m,n) for(ll i=m;i<(ll)(n);i++)
typedef pair<int,long long> pint;
typedef long long ll;
const ll mod= 1e9+7;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int a[2];
  rep(i,2){
    cin>>a[i];
    if(a[i]==1)a[i]+=13;
    }
  if(a[0]>a[1])cout<<"Alice"<<endl;
  if(a[0]==a[1])cout<<"Draw"<<endl;
  if(a[0]<a[1])cout<<"Bob"<<endl;
  return 0;
  }

Measured memory_bytes: 256
def main():
    S = input()
    K = int(input())
    ans = []
    def dfs(s):
        if len(s) > K:
            return
        for i in range(97,123):
            tmp = s + chr(i)
            if tmp in S:
                ans.append(tmp)
                dfs(tmp)

    
    dfs('')
    ans.sort()
    print(ans[K-1])



if __name__ == "__main__":
    main()

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

typedef long long ll;

//2^8 works in 2 sec but make sure to see the size
//2^7 works with 2 arrray of size of 2^7 but not three


int mod = 1e9 + 7;
ll p = 2e6 + 100;
//vector<ll> com(p + 1);
vector<ll> inv(p + 1);
vector<ll> mul(p + 1);

ll power(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		b /= 2;
	}
	return ans;
}

ll C(ll n, ll k) {
	if (n < k || n < 0 || k < 0) return 0;
	ll maxm = max(k,n - k);
	ll minn = min(k,n - k);
	ll ans = 1;
	for (ll i = n; i > maxm; --i) {
		ans = (ans * i) % mod;
	}
	return (ans * mul[minn]) % mod;
}

int main() {	
	//com[0] = 1;
	//for (ll i = 1; i <= p; ++i) {
		//com[i] = (com[i - 1] * i) % mod;
	//} 
    inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= p; ++i) {
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod; 
	}
	mul[0] = 1;
	for (int i = 1; i <= p; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mod;
	}
	ll x, y;
	cin >> x >> y;
	if ((2 * x - y) % 3 != 0 || (2 * y - x) % 3 != 0) {
		cout << 0;
		return 0;
	} 
	ll a = (2 * x - y) / 3;
	ll b = (2 * y - x) / 3;
	cout << C(a + b, a);
}









Measured memory_bytes: 34248
/**
 * author: Dhakad_123
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n; 
    cin >> n;
    
    bool Ok = false;
    
    while(n != 0){
        int digit = n%10;
        if(digit == 7){
            Ok = true;
            break;
            
        }
        n = n/10;
    }
    if(Ok){
        cout << "Yes" <<"\n";
    }
    else{
        cout << "No" <<"\n";
    }
    return 0;
}

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

class Main {

	void solve() {
		
		int[][] map = {
				{inint(), inint(), inint()},
				{inint(), inint(), inint()},
				{inint(), inint(), inint()}
		};
		
		boolean[][] memo = new boolean[3][3];
		
		int n = inint();
		
		for (int i=0; i<n; i++) {
			int number = inint();
			
			for (int j=0; j<3; j++) {
				for (int k=0; k<3; k++) {
					if (map[j][k] == number) {
						memo[j][k] = true;
					}
				}
			}
			
		}
		
		out.println(isBingo(memo) ? "Yes" : "No");
		
		
		
	}
	
	public boolean isBingo(boolean[][] map) {
		
		if (
				(map[0][0] && map[0][1] && map[0][2]) ||
				(map[1][0] && map[1][1] && map[1][2]) ||
				(map[2][0] && map[2][1] && map[2][2]) ||
				(map[0][0] && map[1][0] && map[2][0]) ||
				(map[0][1] && map[1][1] && map[2][1]) ||
				(map[0][2] && map[1][2] && map[2][2]) ||
				(map[0][0] && map[1][1] && map[2][2]) ||
				(map[0][2] && map[1][1] && map[2][0])
			) {
			return true;
		}
		return false;
		
	}
	
	

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public double indouble() {
		return in.nextDouble();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    char a; cin >> a;
    if('a' <= a && a <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}

Measured memory_bytes: 3632
n,m = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
x1 = sorted(x,key=lambda x:-(x[0]+x[1]+x[2]))
x2 = sorted(x,key=lambda x:-(x[0]+x[1]-x[2]))
x3 = sorted(x,key=lambda x:-(x[0]-x[1]+x[2]))
x4 = sorted(x,key=lambda x:-(x[0]-x[1]-x[2]))
x5 = sorted(x,key=lambda x:-(-x[0]+x[1]+x[2]))
x6 = sorted(x,key=lambda x:-(-x[0]+x[1]-x[2]))
x7 = sorted(x,key=lambda x:-(-x[0]-x[1]+x[2]))
x8 = sorted(x,key=lambda x:-(-x[0]-x[1]-x[2]))
def f(l):
    a = [0]*3
    for i in range(m):
        for j in range(3):
            a[j] += l[i][j]
    return abs(a[0])+abs(a[1])+abs(a[2])
print(max(f(x1),f(x2),f(x3),f(x4),f(x5),f(x6),f(x7),f(x8)))

Measured memory_bytes: 3416