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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] str = scanner.nextLine().split(" ");
        int h = Integer.parseInt(str[0]);
        int w = Integer.parseInt(str[1]);
        boolean[][] a = new boolean[h][w];
        for (int i = 0; i < h; i++) {
            char[] s = scanner.nextLine().toCharArray();
            for (int j = 0; j < w; j++) {
                a[i][j] = s[j]=='.';
            }
        }
        int[][]dp = new int[h][w];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                dp[i][j]=Integer.MAX_VALUE-100;
            }
        }
        dp[0][0]=a[0][0]? 0:1;
        int maxK = h-1+w-1;
        for (int k = 1; k <= maxK ; k++) {
            for (int i = Math.max(0, k-(w-1)), j=k-i; i<h && j>=0; i++, j--) {
                if(a[i][j]){
                    if(i>0) dp[i][j] = Math.min(dp[i][j], dp[i-1][j]);
                    if(j>0) dp[i][j] = Math.min(dp[i][j], dp[i][j-1]);
                }else{
                    if(i>0) dp[i][j] = Math.min(dp[i][j], dp[i-1][j] + (a[i-1][j] ? 1: 0));
                    if(j>0) dp[i][j] = Math.min(dp[i][j], dp[i][j-1]+ (a[i][j-1] ? 1: 0));
                }
            }
        }
        System.out.println(dp[h-1][w-1]);
    }
}


Measured memory_bytes: 22100
#include <iostream>
using namespace std;
int main() {
   int a,b,k;
   cin>>a>>b>>k;
  int  count=0;
   int i=0;
   
   if(a>b)
   {
        swap(a,b);
   }
   i=a+1;
 
while(count!=k)
{
   i--;
    if(a%i==0&&b%i==0)
    {
        count++;
    }
   
}
cout<<i<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  int d[K],A[50000];
  int x = 0;
  for (int i = 0; i < K ; i++) {
    cin >> d[i];
        for (int j = 0; j < d[i] ; j++){
            cin >> A[x];
            x++;
        }
  }
    sort(A,A+x);
    int ans = 1;

    for (int i = 0; i < x-1; i++) {
    if(A[i] != A[i+1]){
        ans++;
    }
  }
  cout << N-ans <<endl;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
long long n,ans;
const long long mod=(long long)1000000007;
inline long long read()
{
	long long s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0' && ch<='9')s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
long long power(long long x,long long y)
{
	long long ret=1,base=x%mod;
	while(y)
	{
		if(y & 1)ret=(ret*base)%mod;
		base=(base*base)%mod;
		y>>=1;
	}
	return ret;
}
int main()
{
	n=read();
	if(n==1)
	{
		puts("0");
		return 0;
	}
	long long a=power(10,n),b=power(9,n),c=power(8,n);
	ans=a-c-(b-c)-(b-c);
	ans=(ans+(mod<<3))%mod;
	printf("%lld\n",ans);
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int N;
    int a[100];
    cin >> N;
    REP(i, N) cin >> a[i];

    int Alice = 0, Bob = 0;
    sort(a, a+N);
    REP(i, N){
        if(i % 2 == 0) Alice += a[N - 1 - i];
        else Bob += a[N - 1 - i];
    }

    cout << Alice - Bob << endl;

    return 0;
}

/*****************************************************************************/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

static uint64_t gcd(uint64_t a, uint64_t b)
{
	uint64_t temp;

	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}

	uint64_t r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

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

	vector<int32_t> A(N);
	for (int32_t i = 0; i < N; i++) {
		cin >> A[i];
	}

	int32_t prev_gcd = A[0];
	for (int32_t i = 0; i < N; i++) {
		int32_t current_gcd = gcd(prev_gcd, A[i]);
		prev_gcd = current_gcd;
	}

	cout << prev_gcd << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <assert.h>
#include <vector>
#include <cmath>

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

  int32_t N;
  std::cin >> N;
  int32_t t_prev = 0, t_tmp = 0, x_prev = 0, x_tmp = 0, y_prev = 0, y_tmp = 0;
  int32_t diff = 0, t_diff = 0;
  for(int32_t i = 0; i < N; i++){
    std::cin >> t_tmp >> x_tmp >> y_tmp;
    diff = std::abs(x_tmp - x_prev) + std::abs(y_tmp - y_prev);
    t_diff = t_tmp - t_prev;
    if (t_diff < diff || ((t_diff % 2) != (diff % 2))) {
      std::cout << "No" << std::endl;
      return 0;
    }

    t_prev = t_tmp;
    x_prev = x_tmp;
    y_prev = y_tmp;
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int n=0;
  int d0,d1;
  int N;
  int r=0;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> d0 >> d1;
    if(d0==d1){
      n++;
    }else{
      n=0;
    }
    if(n==3){
      r=1;
    }
  }

  if(r==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

enum {
	A, B, C
};

int main( void )
{
	ll n;
	cin >> n;

	ll a[n], b[n], c[n];
	rep ( i, n ) {
		cin >> a[i] >> b[i] >> c[i];
	}

	ll dp[n][3];
	dp[0][A] = a[0];
	dp[0][B] = b[0];
	dp[0][C] = c[0];

	for ( ll i = 1; i < n; i++ ) {
		dp[i][A] = max(dp[i - 1][B], dp[i - 1][C]) + a[i];
		dp[i][B] = max(dp[i - 1][A], dp[i - 1][C]) + b[i];
		dp[i][C] = max(dp[i - 1][A], dp[i - 1][B]) + c[i];
	}

	cout << max(dp[n - 1][A], max(dp[n - 1][B], dp[n - 1][C])) << endl;

	return 0;
}


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

int K, L, R;
double P, E, T;

double PP(int K, double L, double R)
{
  double mid = (L + R) / 2.0;
  if(K == 0) {
    return(fabs(T - mid) < E ? 1.0 : 0.0);
  } else if(T - R > E || L - T > E) {
    return(0.0);
  } else if(T - L <= E && R - T <= E) {
    return(1.0);
  } else if(mid <= T) {
    return(P * PP(K - 1, L, mid) + (1.0 - P) * PP(K - 1, mid, R));
  } else {
    return((1.0 - P) * PP(K - 1, L, mid) + P * PP(K - 1, mid, R));
  }
}

int main()
{
  cin >> K >> L >> R >> P >> E >> T;
  cout << fixed << setprecision(10) << PP(K, L, R) << endl;
}

Measured memory_bytes: 1292
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;i++)

int main()
{
	vector<vector<int>> a(3, vector<int>(3));
	rep(i, 3)rep(t, 3)
	{
		cin >> a[i][t];
	}
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, n) cin >> b[i];

	vector<vector<bool>> c(3, vector<bool>(3,false));
	rep(i, n)
	{
		rep(p, 3)rep(q, 3)
		{
			if (b[i] == a[p][q])
			{
				c[p][q] = true;
			}
		}
	}

	bool ans = false;
	bool tfa,tfb;
	rep(x, 3)
	{
		tfa = true;
		tfb = true;
		rep(y, 3)
		{
			tfa &= c[x][y];
			tfb &= c[y][x];
		}
		if (tfa || tfb)
		{
			ans = true;
		}

	}

	if (c[0][0] && c[1][1] && c[2][2]) ans = true;
	if (c[0][2] && c[1][1] && c[2][0]) ans = true;

	if (ans)cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
//#define int long long
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int k;
	cin >> k;
	int ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int x = 1; x <= k; x++) {
				ans += gcd(gcd(i, j), x);
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>

int main()
{
	std::string S, T;

	std::cin >> S;

	std::cin >> T;

	int ans = 0;
	for (int i = 0; i < 3; i++){
		ans = (S[i] == T[i]) ? ans + 1: ans;
	}

	std::cout << ans << std::endl;

	return 0;
}



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

int main() {
    ll H, W;
    cin >> H >> W;
    ll a,b;
    a = (H / 2) * W;
    b = (H % 2) * (W + 1) / 2;
    a += b;
    
    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else cout << a << endl;
    return 0;
}


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


int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> flag(n + 1);

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

  vector<int> dp(n + 2);
  const int mod = 1e9 + 7;
  dp[n] = 1;
  for (int j = n -1; j >= 0; j--) {
    if (flag[j]) dp[j] = 0;
    else dp[j] = (dp[j + 1] + dp[j + 2]) % mod;
  }
  cout << dp[0] << endl; 
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  int i,j;
  int a[N];
  for(i=0;i<N;i++){
	cin>>a[i];
  }
  j=0;
  int ans=0;
  while(j<=N-2){
	if(a[j]==a[j+1]){
		ans+=1;
		j+=2;
	}
	else j+=1;
  }
  cout<<ans<<endl;
  return 0;
}     


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
int main( )
{ 
	int i,p=1;
	char a[20];
	char b[20];
	scanf("%s",a);
	scanf("%s",b);
	for(i=0;a[i];i++)
	if(a[i]!=b[i])
	p=0;
	if((strlen(b)-strlen(a))!=1)
	p=0;
	if(p==0)
	{printf("No");return 0;}
	if(p==1)
	{printf("Yes");return 0;}
}


Measured memory_bytes: 1728
function Main(input) {
    input = input.trim();
    input = input.split(" ");
    var a = parseInt(input[0]);
    var b = parseInt(input[1]);
    var c = parseInt(input[2]);    

    if(c<a){
        a-=c;
        
    }else{        
        if(c-a<b){
            b-=c-a
        }else{
            b=0;
        }
        a=0;
    }


    console.log(a + " " + b);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 


Measured memory_bytes: 21064
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()

  # c=0
  # while True:
  #   if s.count('ABC')>0:
  #     c+=s.count('ABC')
  #     s=s.replace('ABC','BCA')
  #   else:
  #     break

  # print(s)
  # return c

  s=list(s)
  s.reverse()
  s=''.join(s)

  cb_c=0
  sm=0
  f=False
  for i in range(len(s)):
    if f:
      f=False
      continue
    if s[i:i+2]=='CB':
      cb_c+=1
      f=True
    elif s[i]=='A':
      sm+=cb_c
    else:
      cb_c=0

  return sm

print(main())


Measured memory_bytes: 7340
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int x,y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

# 横
A = [[-10000] * W for i in range(H)]
B = [[-10000] * W for i in range(H)]

for i in range(H):
    jj = 0
    s = 0
    for j in range(W+1):
        if j == W or S[i][j] == '#':
            for x in range(jj, j):
                A[i][x] = s
            s = 0
            jj = j + 1
        else:
            s += 1


for j in range(W):
    ii = 0
    s = 0
    for i in range(H+1):
        if i == H or S[i][j] == '#':
            for y in range(ii, i):
	            B[y][j] = s
            s = 0
            ii = i + 1
        else:
            s += 1

m = 0
for i in range(H):
    for j in range(W):
        m = max(A[i][j] + B[i][j] - 1, m)
            
print(m)     


Measured memory_bytes: 249096
from sys import stdin
def main():
    input=stdin.readline 

    n=int(input())
    A=[int(_) for _ in input().split()]
    sum_a=sum(A)
    B=[int(_) for _ in input().split()]
    for i in range(n):
        s=max(B[i]-A[i],0)
        A[i]-=min(A[i],B[i])
        A[i+1]-=min(A[i+1],s)
    print(sum_a-sum(A))

if __name__=='__main__':
    main()

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

int main(){
    int n;
    cin >> n;

    vector<long long int> a(n), b(n);
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }

    long long int ans = 0;
    for(int i=n-1; i>=0; i--){
        a[i] += ans;
        long long int rem = a[i] % b[i];
        if(rem != 0) ans += b[i] - rem;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
#define inf 1e18

llint n,m;

void solve(){
	string s; cin >> s;
	string ans ="ABC"+s;
	cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

using lint = long long;

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

void solve() {
    int n;
    lint k;
    std::cin >> n >> k;

    auto to = vec(60, vec(n, -1));
    for (int i = 0; i < n; ++i) {
        std::cin >> to[0][i];
        --to[0][i];
    }

    for (int j = 1; j < 60; ++j) {
        for (int i = 0; i < n; ++i) {
            to[j][i] = to[j - 1][to[j - 1][i]];
        }
    }

    int v = 0;
    for (int j = 59; j >= 0; --j) {
        if ((1LL << j) <= k) {
            v = to[j][v];
            k -= (1LL << j);
        }
    }

    std::cout << v + 1 << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 50980
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(), (v).end()

int main()
{
  int h, n;
  int inf = 1001001001;
  cin >> h >> n;
  vector<int> dp(h + 5, inf);
  dp[0] = 0;
  rep(i, n)
  {
    int a, b;
    cin >> a >> b;
    rep(j, h + 1)
    {
      int nj = min(j + a, h);
      dp[nj] = min(dp[nj], dp[j] + b);
    }
  }

  cout << dp[h] << endl;
}


Measured memory_bytes: 256
import itertools as it

from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


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


def II():
    return int(input())



N, K = acinput()


ary = [acinput() for i in range(N)]
x = list(map(lambda x: x[0], sorted(ary, key=lambda s: s[0])))
y = list(map(lambda x: x[1], sorted(ary, key=lambda x: x[1])))


#print(list(it.combinations(y,2)))
#print(list(x))

res = 10**20
for sy in it.combinations(y, 2):
    #print(sy)
    for sx in it.combinations(x, 2):
        #print(sx)
        #print(sy, sx)
        count = 0
        for sa in ary:
            
            if sy[0] <= sa[1] and sa[1] <= sy[1]:
                if sx[0] <= sa[0] and sa[0] <= sx[1]:
                    count += 1

        #print(count)
        if count >= K:
            #dx = np.diff(sx)[0]
            #dy = np.diff(sy)[0]
            dx=sx[1]-sx[0]
            dy=sy[1]-sy[0]
            #print(dx,dy)
            res = min(res, dx*dy)
            #print(res)

print(res)



Measured memory_bytes: 45148
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)(N);i++)
#define ck(n,a,b) (a)<=(n)&&(n)<=(b)
#define p(s) cout<<(s)<<endl
#define F first
#define S second
typedef long long ll;
using namespace std;

int main() {

	while(1){
		//int ind=0;
		char s[110]={};
		scanf("%c",&s[0]);
		if(s[0]=='\n') continue;
		if(s[0]=='.'){
			break;
		}
		int ind=0;
		while(s[ind]!='.'){
			ind++;
			scanf("%c",&s[ind]);
		}
		bool flag=true;
		stack<char> st;
		int i=0;
		while(s[i]!='.'){
			if(s[i]=='('||s[i]=='['){
				st.push(s[i]);
			}
			else if(s[i]==')'){
				if(!st.empty()&&st.top()=='('){
					st.pop();
				}else flag=false;
			}else if(s[i]==']'){
				if(!st.empty()&&st.top()=='['){
					st.pop();
				}else flag=false;
			}
			if(!flag) {
				break;
			}
			i++;
		}
		if(!st.empty()) flag=false;
		p(flag?"yes":"no");

	}

	return 0;
}

Measured memory_bytes: 3056
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vpl A(N); rep(i, N) {cin >> A[i].ff; A[i].ss = i;};
    sort(ALL(A), greater<PL>());
    
    vl ans(N, 0);
    set<ll> idxes;
    ll now_i = 0, acc = 0;
    while(now_i < N){
        ll cur = A[now_i].ff;
        ll st_i = now_i;
        while(now_i < N && cur == A[now_i].ff){
            idxes.insert(A[now_i].ss);
            now_i++;
        }
        ll nx = now_i == N ? 0 : A[now_i].ff;
        acc += now_i-st_i;
        ans[*idxes.begin()] += (cur-nx)*acc;
    }
    rep(i, N) cout << ans[i] << endstr;
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
int main() {
    using namespace std;
    int a,b,ans=-1;
    cin>>a>>b;
    for(int i=10; i<150'000; i++){
        if((i*8)/100==a && (i*10)/100==b){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
typedef long long ll;
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  ll sum1 = 0,sum2 = 0;
  rep(i,n){
    REP(j,i+1,n){
      if(a[i] > a[j]){
        sum1++;
      }
    }
  }
  rep(i,n){
    rep(j,n){
      if(i != j && a[i] > a[j]){
        sum2++;
      }
    }
  }
  ll sum = 0;
  sum1 = sum1 * k % mod;
  sum2 = sum2 * (k * (k-1) / 2  % mod) % mod;
  sum = (sum1 + sum2) % mod;
  cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long l, r; cin >> l >> r;
	r = min(r, l + 4038);
	long long ans = 1e18;
	for (long long i = l; i <= r; ++i) 
		for (long long j = i + 1; j <= r; ++j)
			ans = min(ans, (i * j) % 2019);
	cout << ans << '\n';	
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    vector<ll> B(N);
    B[0] = A[0];
    for (int i = 1; i < N; i++){
        B[i] = B[i-1] + A[i];
    }

    int num = 0;
    for (int i = 0; i < N-1; i++){
        if(B[i] * 2 < A[i+1])num = i+1;
    }

    cout << N - num << endl;

    return 0;
}

Measured memory_bytes: 4804
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    vector<Pin> v1, v2;

    REP(i, N){
        string s;
        cin >> s;
        int b = 0, e = 0;

        REP(j, s.size()) {
            if (s[j] == '(') {
                b++;
            } else {
                if (b > 0) b--;
                else e++;
            }
        }

        if(b - e >= 0) {
            v1.eb(e, b);
        } else {
            v2.eb(b, e);
        }
    }

    sort(ALL(v1));
    sort(ALL(v2), greater<>());

    int l = 0, r = 0;
    REP(i, v1.size()) {
        int b = v1[i].se, e = v1[i].fi;
        int tmp = min(r, e);
        r -= tmp, e -= tmp;
        l += e;
        r += b;
    }

    REP(i, v2.size()) {
        int b = v2[i].fi, e = v2[i].se;
        int tmp = min(r, e);
        r -=tmp, e -= tmp;
        l += e;
        r += b;
    }

    if (l != 0 || r != 0) {
        print("No");
    } else {
        print("Yes");
    }


}


Measured memory_bytes: 11184
#include <stdio.h>

int main(void)
{

    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    if(c<a && c<b){
        printf("No\n");
    }else if(c>a && c>b){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}

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

int main(){
  int a,b,k,list[100];
  int p=0;
  cin >> a >> b >> k;
  
  for(int i=100; 0<i; i--){
    if( a%i == 0 && b%i == 0){
      list[p] = i;
      p++;
    }
  }
  
  cout << list[k-1] <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))

int main(void)
{
long S, W, index;
  
  scanf("%ld %ld", &S, &W);
  if (S > W) {
    printf("safe\n");
  } else {
    printf("unsafe\n");
  }
    
  return 0;
}


Measured memory_bytes: 1656
import Control.Monad

main = do
  [n, w, h] <- fmap (map read . words) getLine
  plates <- replicateM n $ do
    [a, b] <- fmap (map read . words) getLine
    return (a, b)
  print $ (length . filter (check (w, h))) plates

check :: (Int, Int) -> (Int, Int) -> Bool
check (w, h) (a, b) = w <= a && h <= b


Measured memory_bytes: 1660
#include <stdio.h>

int main()
{
	long long A, B;
	scanf("%lld %lld", &A, &B);
	
	int i;
	long long p, parity[2][50] = {{(A + 1) % 4 / 2}, {(B + 1) % 4 / 2}};
	for (i = 1, p = 4; A >= p / 2 || B >= p / 2; i++, p *= 2) {
		if (A % p >= p / 2) parity[0][i] = (A % p + 1) % 2;
		if (B % p >= p / 2) parity[1][i] = (B % p + 1) % 2;
	}
	
	long long ans = 0;
	for (i = 49; i >= 0; i--) ans = (ans << 1) ^ parity[0][i] ^ parity[1][i];
	printf("%lld\n", ans ^ A);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int sa[105],sb[105];
int main()
{
	int N;
	cin>>N;
	int ans=0;
	int a[105],b[105];
	for(int i=1;i<=N;++i)
	   cin>>a[i],sa[i]=sa[i-1]+a[i];
	for(int i=1;i<=N;++i)
	   cin>>b[i];
	int sum=0; 
	for(int i=1;i<=N;++i)
	    sum+=b[i],sb[i]=sb[i-1]+b[i];
	for(int i=1;i<=N;++i)
	    ans=max(ans,sa[i]+sum-sb[i-1]);//cout<<ans<<endl;   
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int n,d,x;
	cin >> n >> d >> x;
	vector<int> a(n);
	int ans = 0;
	rep(i,n){
		int a;
		cin >> a;
		ans += (d-1)/a + 1;
	}
	cout << ans + x << endl;
    return 0;
}




Measured memory_bytes: 256
from numpy import *
N,M,Q = map(int,input().split())
G = zeros((N,N),int)

for m in range(M):
  l,r = map(int,input().split())
  G[N-l][r-1]+=1
  
G = cumsum(cumsum(G,axis=0),axis=1)

for n in range(Q):
  p,q = map(int,input().split())
  print(G[N-p][q-1])

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

int main(){
    int N;
    long long x=0;
    cin>>N;
    int A[N+1],B[N];
    for(int i=0;i<N+1;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];

    for(int i=0;i<N;i++){
        if(A[i]>=B[i])x+=B[i];
        else if(A[i]<B[i]&&B[i]-A[i]<=A[i+1]){
            x+=B[i];
            A[i+1]=A[i+1]-B[i]+A[i];
        }
        else {
            x+=A[i]+A[i+1];
            A[i+1]=0;
        }
    }
cout<<x<<endl;
return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <cmath>

typedef long long ll;

int n, a[200005];

int main() {
	scanf("%d", &n);
	ll A = 0, B = 0;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		A += a[i];
	}
	
	ll ans = 0x7f7f7f7f7f7f7f7fll;
	for (int i = 1; i < n; ++i) {
		A -= a[i];
		B += a[i];
		ans = std::min(ans, std::abs(A - B));
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

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

void Selection(string arr[], int n)
{
    int i, j;
    for(i = 0; i < n; i++)
    {
        int mini = i;
        for(j = i; j < n; j++)
        {
            if(arr[j][1] < arr[mini][1])
                mini = j;
        }
        if(mini != i)   swap(arr[i], arr[mini]);
        //if(i != mini) cnt++;
    }
    //return cnt;
}
void Bubble(string arr[], int n)
{
    int i, j;
    for(i = 0; i < n-1; i++)
    {
        for(j = 0; j < n - i - 1; j++)
        {
            if(arr[j][1] > arr[j+1][1])
                swap(arr[j], arr[j+1]);
        }
    }
}
bool cmp(string arr[], string arr2[], int n)
{
    for(int i = 0; i < n; i++)
        if(arr[i] != arr2[i])
            return false;
    return true;
}
void printArr(string arr[], int n)
{
    for(int i = 0; i < n; i++)
        cout << arr[i] << (i == n-1 ? '\n' : ' ');
}
int main()
{
    int n;
    cin >> n;
    string arr[n];
    string arr2[n];
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
        arr2[i] = arr[i];
    }

    Bubble(arr, n);
    printArr(arr, n);
    cout << "Stable\n";

    Selection(arr2, n);
    printArr(arr2, n);
    cout << (cmp(arr, arr2, n) ? "Stable\n" : "Not stable\n") ;
    return 0;
}




Measured memory_bytes: 3228
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
    string s;
    cin>>s;
    cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14,5)<<endl;

    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

int main() {
    double t, x;
    cin >> t >> x;
    printf("%.10f", t / x);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b, m;
    cin >> a >> b >> m;
    ll aa[a];
    ll bb[b];
    ll mina = LLONG_MAX;
    ll minb = LLONG_MAX;
    for (ll i = 0; i < a; i++)
    {
        cin >> aa[i];
        mina = min(mina, aa[i]);
    }
    for (ll i = 0; i < b; i++)
    {
        cin >> bb[i];
        minb = min(minb, bb[i]);
    }
    ll minans = mina + minb;
    while (m--)
    {
        ll ta, tb, tc;
        cin >> ta >> tb >> tc;
        ta--;
        tb--;
        minans = min(minans, aa[ta] + bb[tb] - tc);
    }
    cout << minans << endl;

}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
inline double sq(double a) { return a*a; }

int n, ox[200], oy[200];

int main() {
    for(;;) {
        scanf("%d", &n);
        if(n==0) return 0;
        rep(i, n) scanf("%d%d", ox+i, oy+i);
        vector<int> ys;
        rep(i, n) ys.push_back(oy[i]);
        sort(ys.begin(), ys.end());
        ys.erase(unique(ys.begin(), ys.end()), ys.end());
        vector<double> x;
        vector<int> y;
        rep(i, n) {
            x.push_back(ox[i]);
            y.push_back(oy[i]);
            if(i==n-1) break;
            if(oy[i]<oy[i+1]) {
                rep(j, ys.size()) if(oy[i]<ys[j] && ys[j]<oy[i+1]) {
                    const double dx = ox[i+1]-ox[i], dy = oy[i+1]-oy[i];
                    x.push_back(ox[i]+dx/dy*(ys[j]-oy[i]));
                    y.push_back(ys[j]);
                }
            }
            else if(oy[i]>oy[i+1]) {
                const int m = ys.size();
                for(int j=m-1; j>=0; j--) if(oy[i+1]<ys[j] && ys[j]<oy[i]) {
                    const double dx = ox[i+1]-ox[i], dy = oy[i+1]-oy[i];
                    x.push_back(ox[i]+dx/dy*(ys[j]-oy[i]));
                    y.push_back(ys[j]);
                }
            }
        }
        typedef pair<int, int> node;
        set<node> vis;
        priority_queue<pair<double, node> > q;
        q.push(mp(0, mp(0, x.size()-1)));
        while(!q.empty()) {
            pair<double, node> vv(q.top());
            q.pop();
            const double c = -vv.first;
            const int l = vv.second.first;
            const int r = vv.second.second;
            if(vis.find(mp(l, r))!=vis.end()) continue;
            vis.insert(mp(l, r));
            if(l==r) {
                printf("%.9f\n", c);
                break;
            }
            for(int i=-1; i<=1; i++) if(0<=l+i && l+i<(int)x.size()) {
                for(int j=-1; j<=1; j++) if(0<=r+j && r+j<(int)x.size()) {
                    if(y[l+i]==y[r+j]) {
                        const double d1 = sqrt(sq(x[l]-x[l+i])+sq(y[l]-y[l+i]));
                        const double d2 = sqrt(sq(x[r]-x[r+j])+sq(y[r]-y[r+j]));
                        if(vis.find(mp(l+i, r+j))==vis.end()) {
                            q.push(mp(-c-d1-d2, mp(l+i, r+j)));
                        }
                    }
                }
            }
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  set<int> s;
  rep(i,n) s.insert(a[i]);
  if (s.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 10368
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<ll,ll> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main(){
	ll n; cin >> n;
	vector<ll> div;
	rep(i, 1, sqrt(n) + 1) {
		if (n % i == 0) {
			div.push_back(i-1);
			if (1LL*i * i != n) div.push_back(n / i-1);
		}
	}
	sort(div.begin(), div.end());
	ll ans = 0;
	rep(i, 0, div.size()) {
		if (div[i] == 0) continue;
		if (n % div[i] == n / div[i]) ans += div[i];
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<tuple<string, int, int>> V(N);
    REP(i, N) {
        string S;
        int P;
        cin >> S >> P;
        V[i] = make_tuple(S, -P, i + 1);
    }
    SORT(V);
    REP(i, N) {
        cout << get<2>(V[i]) << endl;
    }
    return 0;
}


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

typedef long long ll;

struct edge{
    int to, id;
};

vector<vector<edge>> G;
vector<int> ans;

void dfs(int v, int c=-1/*やってきた辺の色*/, int p=-1/*親の頂点*/){
    int k = 1;
    for (int i=0;i<G[v].size();i++){
        int u = G[v][i].to;
        int ei = G[v][i].id;
        if (u == p) continue;
        if (k == c) k++;
        ans[ei] = k; k++; /*この最後のk++は次の子に向けるときに必要*/
        dfs(u, ans[ei], v);
    }
}

int main() {
    int N;
    cin >> N;
    G.resize(N);
    ans.resize(N-1);
    for (int i=0;i<N-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back((edge){b,i});
        G[b].push_back((edge){a,i});
    }
    dfs(0);
    int m = 0;
    for (int i=0;i<N;i++) m = max(m,int(G[i].size()));
    cout << m << endl;
    for (int i=0;i<N-1;i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 8320
n = int(input())
d = dict()
m = 0
for _ in range(n):
    x = input()
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
    if m < d[x]:
        m = d[x]
for p in sorted([e for e in iter(d) if d[e] == m]):
    print(p)

Measured memory_bytes: 33116
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100

int stack_data[N];
int stack_num=0;

void push(int);
int pop();


int main(){
  int a,b,x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a=pop();
      b=pop();
      push(b+a);
    } else if ( s[0] == '-' ){
      a=pop();
      b=pop();
      push(b-a);
    } else if ( s[0] == '*' ){ 
      a=pop();
      b=pop();
      push(a*b);
    } else {
      x = atoi(s);
      push(x);

    }  
  }
  printf("%d\n",pop());
    return 0;
}
void push(int push_data)
{
    if (stack_num < N) {
        stack_data[++stack_num] = push_data;
    }
	else {
	  fprintf(stderr," erroe overflow \n");
	  exit(1);
    }
}

int pop()
{
    if (stack_num > 0) {
        stack_num --;
        return stack_data[stack_num+1];

    } else {
      fprintf(stderr,"error anderflow \n");
      exit(2);
    }
}

Measured memory_bytes: 548
height,width = gets.split.map(&:to_i)

# 入力

input_line = []
last_line = Array.new(width+1){0}
lines = []

for input_count in 0...height

  input_line = gets.split.map(&:to_i)
  input_line = input_line[0...width]
  input_line << input_line.inject{|sum,n| sum + n }

  for str_count in 0..width
    last_line[str_count] += input_line[str_count]
  end

  lines << input_line
end

lines << last_line

# 出力

for output in lines

  print output.join(" ") + "\n"

end


Measured memory_bytes: 7096
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	vector<ld> x(3), y(3);
    rep(i, 3) {
        cin >> x[i] >> y[i];
    }
    ld a = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1])), b = sqrt((x[0] - x[2]) * (x[0] - x[2]) + (y[0] - y[2]) * (y[0] - y[2])), c = sqrt((x[2] - x[1]) * (x[2] - x[1]) + (y[2] - y[1]) * (y[2] - y[1]));
    ld s = (a + b + c) / 2;
    ld S = sqrt(s * (s - a) * (s - b) * (s - c));
    //cerr << S << " " << a << " " << b << " " << c << endl;
    ld r = 2.0 * S / (a + b + c);
    cout << max({a * r / (a + 2 * r), b * r / (b + 2 * r), c * r / (c + 2 * r)}) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using namespace std;

// unsigned euclidean_gcd(unsigned a, unsigned b) {
//   if(a < b) return euclidean_gcd(b, a);
//   unsigned r;
//   while ((r=a%b)) {
//     a = b;
//     b = r;
//   }
//   return b;
// }

int main(){
    int a,b;
    cin >> a >> b;
    if(a != 1 && b != 1){
        cout << 1 << endl;
    }else if(a != 2 && b != 2){
        cout << 2 << endl;
    }else if(a != 3 && b != 3){
        cout << 3 << endl;
    }
}


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

int main()
{
    int x;
string S;
cin>>x;
cin>>S;
if(x%2!=0)
    cout<<"No";
    else{
int a=0,b=x/2;
bool B=true;
for(int i=0;i<x/2;i++)
{
    if(S[a]!=S[b])
        B=false;
        a++;
        b++;
}
if(B==true)
    cout<<"Yes";
else cout<<"No";}
    return 0;

}

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

using namespace std;

struct edge
{
	int x,y,z;
	
	inline bool operator < (const edge t) const
	{
		return z<t.z;
	}
};

edge e[300000];

int f[300000],h[300000];
long long g[300000];
int i,m,n,t,fx,fy;

inline int getfather(int x)
{
	if (f[x]==x)
		return x;
	else
		return f[x]=getfather(f[x]);
}

int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		scanf("%lld",&g[i]);
	for (i=1;i<=m;i++)
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].z);
	sort(e+1,e+m+1);
	for (i=1;i<=n;i++)
		f[i]=i;
	for (i=1;i<=m;i++)
	{
		fx=getfather(e[i].x);
		fy=getfather(e[i].y);
		if (fx!=fy)
			f[fx]=fy,g[fy]=g[fy]+g[fx],h[fy]=h[fy]+h[fx];
		h[fy]++;
		if (g[fy]>=e[i].z)
			h[fy]=0;
	}
	for (i=1;i<=n;i++)
		if (getfather(i)==i)
			t=t+h[i];
	printf("%d",t);
	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
  	cin.tie(NULL);cout.tie(NULL); cerr.tie(NULL); 
  	#ifdef LOCAL
  		freopen("in.txt", "r", stdin);
  		freopen("out.txt", "w", stdout);
  	#endif
  	
  	long long n,k;
  	cin >> n >> k;
  	cout << min(n % k , k - n % k);

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

template<class V> class BIT {
private:
	int n;
	vector<V> bit;

public:
	void add(int i,V x)
	{
		while(i < n){
			bit[i] += x;
			i += i & -i;
		}
	}
	V sum(int i)
	{
		V s = 0;
		while(i>0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	//?????????????????????0?????´???
	BIT(int sz){
		n = sz + 1;
		bit.resize(n,0);
	}
	BIT(vector<V> v) {
		int sz = (int)v.size();
		n = sz + 1;
		bit.resize(n);
		rep(i,sz){
			 add(i+1,v[i]);
		}
	}
};

int main()
{
    int n,m;
    cin >> n >> m;
    BIT<int> bt(vector<int>(n,0));
    rep(i,m){
        int k,x,y;
        cin >> k >> x >> y;
        if(k){
            cout << bt.sum(y) - bt.sum(x-1) << "\n";
        }else{
            bt.add(x,y);
        }
    }
    return 0;
}

Measured memory_bytes: 3560
s=input()
if len(s)<=2:
    print(len(set(list(s))));exit()
dp=[0]*(len(s)+ 1)
dp[0]=0
dp[1]=1
dp[2]=(len(set(list(s[:2]))))

for i in range(3,1+len(s)):
    dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2)
print(dp[-1])

Measured memory_bytes: 11240