akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>

void koch(int n, double xx, double xy, double yx, double yy)
{
	if(n==0){
		return;
	}
	
	double sx, sy, tx, ty, ux, uy;
	
	sx=(2.0*xx+1.0*yx)/3.0;
	sy=(2.0*xy+1.0*yy)/3.0;
	tx=(1.0*xx+2.0*yx)/3.0;
	ty=(1.0*xy+2.0*yy)/3.0;
	ux=(tx-sx)*cos(M_PI/3) - (ty-sy)*sin(M_PI/3) + sx;
	uy=(tx-sx)*sin(M_PI/3) + (ty-sy)*cos(M_PI/3) + sy;
	
	koch(n-1, xx, xy, sx, sy);
	printf("%.8f %.8f\n", sx, sy);
	koch(n-1, sx, sy, ux, uy);
	printf("%.8f %.8f\n", ux, uy);
	koch(n-1, ux, uy, tx, ty);
	printf("%.8f %.8f\n", tx, ty);
	koch(n-1, tx, ty, yx, yy);
}
	

int main(void)
{
	int n;
	scanf("%d", &n);
	
	double ax=0.0;
	double ay=0.0;
	double bx=100.0;
	double by=0.0;
	
	printf("%.8f %.8f\n", ax, ay);
	
	koch(n, ax, ay, bx, by);
	
	printf("%.8f %.8f\n", bx, by);
	
	return 0;
	
}


Measured memory_bytes: 2108
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] i = new int[N];

        for(int j = 0; j < N; j++){
            i[j] = sc.nextInt();
        }
        long answer = gcd(i[0],i[1]);

        for(int j = 2; j < N; j++){
            answer = gcd(answer,i[j]);
        }

        System.out.println(answer);
    }

    public static long gcd(long div, long div2){
        if(div2 == 0) {
            return div;
        }
        return gcd(div2,div%div2);


    }
}

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

using ld=long double;
const ld EPS=1e-10;
using P=complex<ld>;

void input(P &p){
    ld x,y;
    cin>>x>>y;
    p={x,y};
}
enum{WASTE,RAT,CAT};
using Graph=vector<vector<int>>;
int solve(int n){
    P ps,pt;
    input(ps),input(pt);
    vector<P> cs(n);
    vector<ld> r(n);
    for(int i=0;i<n;i++){
        input(cs[i]);
        cin>>r[i];
    }
    auto judge=[](P c,ld r,P x,P y){
        return abs(c-x)<r && abs(c-y)>r;
    };
    vector<int> type(n);
    for(int i=0;i<n;i++){
        if(judge(cs[i],r[i],ps,pt)){
            type[i]=RAT;
        }
        else if(judge(cs[i],r[i],pt,ps)){
            type[i]=CAT;
        }
        else{
            type[i]=WASTE;
        }
    }
    Graph g(n+2);
    const int RAT_V=n;
    const int CAT_V=n+1;
    g[RAT_V].push_back(CAT_V);
    for(int i=0;i<n;i++){
        if(type[i]==WASTE) continue;
        g[RAT_V].push_back(i);
        g[i].push_back(CAT_V);
        for(int j=0;j<n;j++){
            if(i==j) continue;
            ld d=abs(cs[i]-cs[j]);
            if(type[i]==RAT && type[j]==CAT){
                if(d>r[i]+r[j]+EPS){
                    g[i].push_back(j);    
                }
            }
            else if(type[i]==RAT && type[j]==RAT && r[i]<r[j]){
                if(d+EPS<r[j]-r[i]){
                    g[i].push_back(j);
                }
            }
            else if(type[j]==CAT && type[i]==CAT && r[i]>r[j]){
                if(d+EPS<r[i]-r[j]){
                    g[i].push_back(j);
                }
            }
        }
    }
    vector<int> idx(n);
    auto comp=[&](int lhs,int rhs){
        if(type[lhs]==WASTE && type[rhs]==WASTE) return r[lhs]<r[rhs];
        if(type[rhs]==WASTE) return true;
        if(type[lhs]==WASTE) return false;
        if(type[lhs]==RAT && type[rhs]==CAT) return true;
        if(type[rhs]==RAT && type[lhs]==CAT) return false;
        if(type[lhs]==RAT){
            return r[lhs]<r[rhs];
        }
        else{
            return r[lhs]>r[rhs];
        }
    };
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(),idx.end(),comp);
    vector<int> dp(n+2);
    for(auto to:g[RAT_V]) dp[to]=1;
    auto cmax=[](int &lhs,int rhs){lhs=max(lhs,rhs);};
    for(int i=0;i<n;i++){
        int id=idx[i];
        for(auto to:g[id]){
            cmax(dp[to],dp[id]+1);
        }
    }
    return dp[CAT_V]-1;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;        
    }
    return 0;
}


Measured memory_bytes: 5908
#include "bits/stdc++.h"

using namespace std;
#define FOR(i, a, b) for(int i=a;i<b;i++)
#define rep(i, b) FOR(i,0,b)
#define INF 1e9
#define all(a) (a).begin,(a).end()


int main(){
    int a,b;
    cin>>a>>b;
    if(a+b==15){
        cout<<'+'<<endl;
    }else if(a*b==15){
        cout<<'*'<<endl;
    }else {
        cout<<'x'<<endl;
    }

}


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

int main(){
  int n, r, g, b;
  cin >> r >> g >> b;
  n = int(r)*100 + int(g)*10 + int(b);
  if ( n%4==0 ){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int N;
  int H[20];
  int i,j;
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&H[i]);
  }
  
  int count = 1;
  int judge = 0;
  for(i=1; i<N; i++){
    for(j=i-1; j>=0; j--){
      if(H[i]>=H[j]){judge++;}
    }
    if(judge==i){count++;}
    judge=0;
  }
  
  printf("%d\n",count);
  
  return 0;
}


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

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  if((n * a) < b) cout << n * a <<endl;
  else  cout << b << endl;
  return 0;
}


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

int main(){
  vector<int> n;
  for(int i = 0; i < 3; i++){
    int temp; cin >> temp;
    n.push_back(temp);
  }
  sort(n.begin(), n.end(), greater<int>());
  int ans = 10*n[0] + n[1] + n[2];
  cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == 0 && b == 0)
				break;
			for (int i = 0; i < a; i++) {
				for (int c = 0; c < b; c++) {
					if ((i + c) % 2 == 0) {
						System.out.printf("#");
					} else {
						System.out.printf(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 59920
import sys
input = sys.stdin.readline
INF = 10**11
A,B,Q = map(int,input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
def binary_search(lis,x):
    ok = 0
    ng = len(lis)-1
    while ng-ok > 1:
        mid = (ok+ng)//2
        if lis[mid] < x:
            ok = mid
        else:
            ng = mid
    return ok
#print(s,t)
for _ in range(Q):
    x = int(input())
    ps = binary_search(s,x)
    pt = binary_search(t,x)
    ans = INF
    #print(ps,pt)
    for i in range(ps,ps+2):
        for j in range(pt,pt+2):
            ds = x - s[i]
            dt = x - t[j]
            
            if (ds < 0 and dt < 0) or (ds > 0 and dt > 0):
                ans = min(ans,max(abs(ds),abs(dt)))
            else:
                ans = min(ans,abs(ds)+abs(dt)+min(abs(ds),abs(dt)))
    print(ans)  
            


Measured memory_bytes: 82616
a,s=[x for x in input().split()]
for i in range(len(s)):
    if s[i]=='.':
        ans=s[0:i]+s[i+1:]
        break
p=str(int(a)*int(ans))
if len(p)<3:
    print(0)
else:
    print(p[0:len(p)-2])

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
const int N=400005;
int S,T,cur[N],ne[N],n,a[N],b[N],from1[N],from2[N],tot,fi[N],zz[N],sl[N],dis[N];
queue<int> Q;
void jb(int x,int y,int z){
	ne[++tot]=fi[x];
	fi[x]=tot;
	zz[tot]=y;
	sl[tot]=z;
	ne[++tot]=fi[y];
	fi[y]=tot;
	zz[tot]=x;
	sl[tot]=0;
}
int bfs(){
	Q.push(S);
	memset(dis,-1,sizeof dis);
	dis[S]=0;
	while (!Q.empty()){
		int now=Q.front();Q.pop();
		for (int i=fi[now];i;i=ne[i])
			if (sl[i]&&dis[zz[i]]==-1){
				dis[zz[i]]=dis[now]+1;
				Q.push(zz[i]);
			}
	}
	return dis[T]!=-1;
}
int dfs(int x,int y){
	if (x==T)return y;
	int s=0,b;
	for (int &i=cur[x];i;i=ne[i])
		if (sl[i]&&dis[zz[i]]==dis[x]+1&&(b=min(y,dfs(zz[i],min(y,sl[i]))))){
			s+=b;y-=b;
			sl[i]-=b;
			sl[i^1]+=b;
			if (!y)return s;
		}
	return s;
}
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++)scanf("%d",&a[i]);
	for (int i=0;i<n;i++)scanf("%d",&b[i]);
	S=0;int cnt=0;
	for (int i=0;i<n;i++)
		if (!from1[i]){
			++cnt;
			int v=i;
			while (!from1[v])from1[v]=cnt,v=a[v];
		}
	for (int i=0;i<n;i++)
		if (!from2[i]){
			++cnt;
			int v=i;
			while (!from2[v])from2[v]=cnt,v=b[v];
		}
	T=++cnt;
	tot=1;
	int ans=n;
	for (int i=0;i<n;i++)
		if (a[i]==b[i]&&a[i]==i)ans--;
		else if (a[i]==i)jb(S,from2[i],1);
		else if (b[i]==i)jb(from1[i],T,1);
		else if (a[i]!=b[i])jb(from1[i],from2[i],1);
		else jb(from1[i],from2[i],1),jb(from2[i],from1[i],1);
	while (bfs()){
		for (int i=S;i<=T;i++)cur[i]=fi[i];
		ans-=dfs(S,1e9);
	}
	printf("%d\n",ans);
}


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

int main(){
  int a,b,c,d,n;
  cin >> n;
  a = n/1000;
  b = (n%1000)/100;
  c = (n%100)/10;
  d = n%10;
  int sum;
  for (int i=0; i<2; i++){
    for(int j=0; j<2; j++){
      for(int k=0; k<2; k++){
        if(i==0) sum=a+b;
        else sum=a-b;
        if(j==0) sum+=c;
        else sum-=c;
        if(k==0) sum+=d;
        else sum-=d;
        if(sum==7){
          cout << a << (i==0?"+":"-")<<b<<(j==0?"+":"-")<<c<<(k==0?"+":"-")<<d<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
}
  

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<math.h>
#include<cstring>
#define ll long long int
using namespace std;
 
int main()
{
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     
     int n,m;
     cin>>n>>m;
     int a[m];
     int i;
     int s=0;
     for(i=0;i<m;i++)
     {
     	
     	cin>>a[i];
     	s=s+a[i];
     	
	 }
	 
	 int h=n-s;
	 
	 if(h<-1)
	 {
	 	
	 	cout<<"-1"<<endl;
	 	
	 }
	 
	 else
	 {
	 	
	 	cout<<h<<endl;
	 	 
	 }
 
 
 
    
    return 0;
}
    
    
    

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;

int main(){
	cin>>n;
	a=vi(n);
	b=vi(n+1);
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a[x-1]++;
	}
	sort(a.begin(),a.end());
	int id=0,s=0;
	for(int i=1;i<=n;i++){
		while(id<n&&a[id]<i) s+=a[id++];
		b[s/i+(n-id)]=i;
	}
	for(int i=n-1;i>=0;i--) b[i]=max(b[i],b[i+1]);
	for(int i=1;i<=n;i++) cout<<b[i]<<endl;
}

Measured memory_bytes: 3200
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,M;
  cin >> N;
  map<string,int> blue;
  string s;
  for(int i=0;i<N;++i){
    cin >> s;
    if(blue.count(s)) blue.at(s)++;
    else blue[s]=1;
  }
  cin >> M;
  map<string,int> red;
  for(int i=0;i<M;++i){
    cin >> s;
    if(red.count(s)) red.at(s)++;
    else red[s]=1;
  }

  int ans=-200;
  for(auto p: blue){
    auto word=p.first;
    auto value=p.second;
    if(red.count(word)){
      ans=max(ans,value-red.at(word));
    }
    else ans=max(ans,value);
  }

  if(ans<0) cout << 0 << endl;
  else cout << ans << endl;
  
  return 0;
}


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

int main(int argc, char **argv){
	int a = 0;
	int b = 0;
	int c = 0;
	std::vector<int> v;

	std::cin >> a >> b >> c;

	v.push_back(a);
	v.push_back(b);
	v.push_back(c);

	std::sort(v.begin(), v.end());

	std::cout << v[0] << " ";
	std::cout << v[1] << " ";
	std::cout << v[2] << std::endl;
	return 0;
}

Measured memory_bytes: 3180
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;;
#define ato find_by_order
#define of order_of_key
typedef long long ll;
#define pb push_back
#define flash ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define endl '\n'
ll val[100005];ll ans[100005];vector<ll> graph[100005];
ll vis[100005]; ll weight[100005];
void dfs(ll curr,ll c,ll kabad) {
    
    vis[curr]=1;
    if(val[curr]==1){
        c++;
        kabad=max(kabad,c);
        ans[curr]=kabad;
    }
    else {
        c=0;
        ans[curr]=kabad;
    }
    for(auto x:graph[curr]) {
        ll child=x;
        if(vis[child]==0){
            
            dfs(child,c,kabad);
        }
    }
}

int main(){
    ll t;
    t=1;
    while(t--) {
        double d,t,s;
        cin >> d >> t >> s;
        double T = d/s;
        if(T>t){
            cout<<"No\n";
        }
        else {
            cout<<"Yes\n";
        }
        
        
    }
}


Measured memory_bytes: 6068
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define blue ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007;

int main() {
  blue;
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];

  int dp[n];
  dp[0]=0;
  dp[1] = abs(a[1]-a[0]);
  for(int i=2;i<n;i++) {
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2]) );
  }

  cout<<dp[n-1];
}

/*
  
*/

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m + 2; i++) cout << "#";
  cout << '\n';
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    cout << "#" << s << "#" << '\n';
  }
  for (int i = 1; i <= m + 2; i++) cout << "#";
  cout << '\n';
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
struct P {
  int x,y,p,q,z;
};
 
int d[101][101][15][15][4];
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
 
bool check(int n, int m, int x, int y) {
  return (x>=0&&x<n&&y>=0&&y<m);
}
 
int main() {
  int n,m,k,INF=1<<29;
  cin >> n >> m >> k;
  string s[n];
  int gx,gy,sx,sy;
  for(int i=0; i<n; i++) {
    cin >> s[i];
    for(int j=0; j<m; j++) {
      if(s[i][j]=='G') {
    gx=i;gy=j;
      }
      if(s[i][j]=='S') {
    sx=i;sy=j;
      }
    }
  }
  for(int i=0; i<101; i++)for(int j=0;j<101;j++)for(int ii=0; ii<15;ii++)for(int iii=0;iii<15;iii++)for(int jj=0;jj<4;jj++) d[i][j][ii][iii][jj]=INF;
  d[sx][sy][k][k][2]=0;
   
  deque<P> que;
  que.push_back((P){sx,sy,k,k,2});
  while(!que.empty()) {
    P t=que.front();que.pop_front();
    int nx=t.x,ny=t.y;
    if(s[nx][ny]=='G' || (s[nx][ny]=='S'&&t.z==0)) continue;
    int x=nx+dx[t.z],y=ny+dy[t.z];
    if(check(n,m,x,y) && s[x][y]!='#') {
      if(d[x][y][t.p][t.q][t.z]>d[nx][ny][t.p][t.q][t.z]) {
        que.push_front((P){x,y,t.p,t.q,t.z});
        d[x][y][t.p][t.q][t.z]=d[nx][ny][t.p][t.q][t.z];
      }
    }
    if(s[nx][ny]=='S') continue;
    int a=1;
    if(t.z%2) a=3;
    if(t.p) {
      x=nx+dx[(t.z+a)%4],y=ny+dy[(t.z+a)%4];
      if(check(n,m,x,y) && s[x][y]!='#') {
        if(d[x][y][t.p-1][t.q][(t.z+a)%4]>d[nx][ny][t.p][t.q][t.z]+1) {
          que.push_back((P){x,y,t.p-1,t.q,(t.z+a)%4});
          d[x][y][t.p-1][t.q][(t.z+a)%4]=d[nx][ny][t.p][t.q][t.z]+1;
        }
      }
    }
    a=(a+2)%4;
    if(t.q) {
      x=nx+dx[(t.z+a)%4],y=ny+dy[(t.z+a)%4];
      if(check(n,m,x,y) && s[x][y]!='#') {
        if(d[x][y][t.p][t.q-1][(t.z+a)%4]>d[nx][ny][t.p][t.q][t.z]+1) {
          que.push_back((P){x,y,t.p,t.q-1,(t.z+a)%4});
          d[x][y][t.p][t.q-1][(t.z+a)%4]=d[nx][ny][t.p][t.q][t.z]+1;
        }
      }
    }
  }
  int ans=INF;
  for(int i=0; i<=k; i++) {
    for(int j=0; j<=k; j++) {
      for(int l=0; l<4; l++) ans=min(ans,d[gx][gy][i][j][l]);
    }
  }
  if(ans==INF) cout << "-1" << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 37876
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long A, B, C, Sm = INF;

  int X, Y, Z;

  std::cin >> A >> B >> C >> X >> Y;;

  Z = std::max(X, Y);

  for (int i = 0; i <= Z; i ++) {
    long long S = i * C * 2 + std::max(X - i, 0) * A + std::max(Y - i, 0) * B;

    Sm = std::min(S, Sm);
  }

  std::cout << Sm << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
using namespace std;
 int main(){
   string s; int mi=10e7;
   cin >> s;
   for(int a=0;a<=s.size()-3;a++){
     int x=(s[a]-'0')*100+(s[a+1]-'0')*10+s[a+2]-'0';
     mi=min(abs(x-753),mi);
   }
   cout << mi <<endl;
   return 0;
 }

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

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

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            out.println(in.next().contains("9") ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 23380
n = gets
array = gets.split.map(&:to_i)
$count = 0
def merge(array, left, mid, right)
  l = array[left...mid]
  r = array[mid...right]
  l.push(Float::INFINITY)
  r.push(Float::INFINITY)

  i = 0
  j = 0
  k = left

  until k == right
    $count += 1
    if l[i] <= r[j]
      array[k] = l[i]
      i += 1
    else
      array[k] = r[j]
      j += 1
    end

    k += 1
  end
end

def merge_sort(array, left, right)
  if left + 1 < right
    mid = (left + right) / 2
    merge_sort(array, left, mid)
    merge_sort(array, mid, right)
    merge(array, left, mid, right)
  end
end

merge_sort(array, 0, array.size)
puts array.join(' ')
puts $count



Measured memory_bytes: 66164
changeIntToChar n = ['a'..'z'] !! n
solve :: [Char] -> Int -> [Char]
solve ans n
 | n < 27    = tmp
 | otherwise = solve tmp ((n - 1) `div` 26)
  where tmp = (changeIntToChar((n - 1) `mod` 26)):ans
main = putStr =<< (solve []) . read <$> getLine

Measured memory_bytes: 3876
N=int(input())
a=[int(input()) for _ in range(N)]
#print(a)
x=1#最初に付いているボタン
count=0
for i in range(N):
    x=a[x-1]
    count+=1
    if x==2:
        break
if x!=2:
    print(-1)
else:
    print(count)

Measured memory_bytes: 7084
#include <stdio.h>
int n,A[50];

int solve(int i,int m){
 int res;

 if( m == 0 )
    return 1;
 if( i >= n )
    return 0;
 res = solve(i + 1,m) || solve(i + 1,m - A[i]);
 return res;
}


int main(){
 int q, i, m;
 
 scanf("%d",&n);
 for(i = 0;i < n;i++)
  scanf("%d",&A[i]);

 scanf("%d",&q);
 for(i = 0;i < q;i++){
  scanf("%d",&m);
  if(solve(0, m))
   printf("yes\n");
  else
   printf("no\n");
 }
 return 0;
}

Measured memory_bytes: 580
from math import ceil, floor
def chocolateBar():
    h,w=map(int,input().split())
    ans=10**18

    #縦に三等分する場合
    ans=min(ans, (ceil(w/3)-floor(w/3))*h )
    ans=min(ans, (ceil(h/3)-floor(h/3))*w )

    #縦横に一回ずつ
    for i in range(1, h):
        s1=i*w
        s2=(h-i)*floor(w*0.5)
        s3=(h-i)*ceil(w*0.5)
        ans=min(ans, max(s1,s2,s3)-min(s1,s2,s3))
    for i in range(1, w):
        s1=i*h
        s2=(w-i)*floor(h*0.5)
        s3=(w-i)*ceil(h*0.5)
        ans=min(ans, max(s1,s2,s3)-min(s1,s2,s3))
    
    return ans

print(chocolateBar())


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<map>
#define ull unsigned long long
using namespace std;
int n,ans;
const ull bas=211;
ull hah[310][310],hal[310][310],mi[310];
char s[310][310];
ull getl(int i,int l,int r)
{
//	cout<<i<<" "<<l<<" "<<r<<"l"<<endl;
	if (l>r) return 0;
	if (l==0) return hal[r][i];
	else return hal[r][i]-hal[l-1][i]*mi[r-l+1];
}
ull geth(int i,int l,int r)
{
//	cout<<i<<" "<<l<<" "<<r<<"h"<<endl;
	if (l>r) return 0;
	if (l==0) return hah[i][r];
	else return hah[i][r]-hah[i][l-1]*mi[r-l+1];
}

int main()
{
	scanf("%d",&n);
	for (int x,i=0;i<n;i++)
		scanf("%s",s[i]);
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			hah[i][j]=hah[i][j-1]*bas+s[i][j];
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			hal[i][j]=hal[i-1][j]*bas+s[i][j];
	mi[0]=1;for (int i=1;i<=n;i++) mi[i]=mi[i-1]*bas;
	for (int a=0;a<n;a++)
		for (int b=0;b<n;b++)
		{
			bool p=1;
			for (int i=0;i<n;i++)
			{
				int posi=(i+a)%n,posj=(i+b)%n;
				ull l1,l2;
				if (posi>=a) l1=getl(posj,posi,n-1)*mi[a]+getl(posj,0,a-1);
				else l1=getl(posj,posi,a-1);
				if (posj>=b) l2=geth(posi,posj,n-1)*mi[b]+geth(posi,0,b-1);
				else l2=geth(posi,posj,b-1);
			//	cout<<l1<<" "<<l2<<" "<<a<<" "<<b<<" "<<i<<endl;
				if (l1!=l2) {p=0;break;}
			}
			ans+=p;
		}
	printf("%d",ans);
}

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

ll gcd(ll, ll);
ll lcm(ll, ll);

int main() {
  int A, B;
  cin >> A >> B;

  ll ans = lcm(A, B);

  cout << ans << endl;
  return 0;

}

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

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	short int n , a , b , c , d ;
	while( cin >> n ){
		int num =0 ;
		for( a=0 ; a<10 ; a++ )
			for( b=0 ; b<10 ; b++ )
				for( c=0 ; c<10 ; c++ )
					for( d=0 ; d<10 ; d++ )
						if( a+b+c+d == n )
							num ++ ;
						cout << num << endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;using vll = vector<ll>;
int main(){
  ll k, x, ans = 0;
  cin >> k >> x;
  
  for (ll i = 0; i < 2*k-1; i++) {
    cout << i+x-k+1;
    if (i != 2*k-2) cout << ' ';
  }
  
  cout << endl;
}

Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long a=1,b=1,c=0;
		for(int i=0;i<n;i++){
			long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
			if(q[0]<a||q[1]<b){
				c=Math.Max(a/q[0]+(a%q[0]==0?0:1),b/q[1]+(b%q[1]==0?0:1));
				a=q[0]*c;b=q[1]*c;
			}
			else{a=q[0];b=q[1];}
		}
		Console.WriteLine("{0}",a+b);
	}
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0592
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int sum = 0;
            for (int i = 0 ; i < 5 ; i++)
            {
                int score = ReadInt();
                sum += Math.Max(score, 40);
            }
            Console.WriteLine(sum/5);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 17928
n,m = map(int, input().split())
l=list(map(int, input().split()))
k=[]
if len(l)==1:
    print(0)
else:
    l=sorted(l,reverse=False)
    for i in range(len(l)-1):
        k.append(l[i+1]-l[i])
    k=sorted(k,reverse=True)
    print(sum(k)-sum(k[:n-1]))


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

using namespace std;
int main(){
      int a,b,m,i;
      cin>>a>>b>>m;
      int arr[a],brr[b];
      for(i=0;i<a;i++)
           cin>>arr[i];
      for(i=0;i<b;i++)
           cin>>brr[i];
     int ans=151771171;
     for(i=0;i<m;i++)
     {
           int aa,bb,c;
           cin>>aa>>bb>>c;
           ans=min(arr[aa-1]+brr[bb-1]-c,ans);
      }
     sort(arr,arr+a);
     sort(brr,brr+b);
     ans=min(ans,arr[0]+brr[0]);
     cout<<ans;
      return 0;
}









Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int a,n;
	scanf("%d%d",&a,&n);
	long s=1,c=a,MOD=1000000007;
	while(n){
		if(n%2)s=s*c%MOD;
		c=c*c%MOD;
		n/=2;
	}
	printf("%ld\n",s);
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    string s;
    cin >> n >> s;
    vector<string> saisyo = {"SS", "SW", "WS", "WW"};
    for(i = 0;i < 4;++i){
        string tmp = saisyo.at(i);
        for(j = 1;j < n-1;++j){
            if(s.at(j) == 'o'){
                if(tmp.at(j) == 'S'){
                    tmp.push_back(tmp.at(j-1));
                }else{
                    if(tmp.at(j-1) == 'W'){
                        tmp.push_back('S');
                    }else{
                        tmp.push_back('W');
                    }
                }
            }else{
                if(tmp.at(j) == 'S'){
                    if(tmp.at(j-1) == 'W'){
                        tmp.push_back('S');
                    }else{
                        tmp.push_back('W');
                    }
                }else{
                    tmp.push_back(tmp.at(j-1));
                }
            }
        }
        bool flag = true;
        if(s.at(n-1) == 'o'){
            if(tmp.at(n-1) == 'S'){
                if(tmp.at(n-2) != tmp.at(0)) flag = false;
            }else{
                if(tmp.at(n-2) == tmp.at(0)) flag = false;
            }
        }else{
            if(tmp.at(n-1) == 'S'){
                if(tmp.at(n-2) == tmp.at(0)) flag = false;
            }else{
                if(tmp.at(n-2) != tmp.at(0)) flag = false;
            }
        }
        if(!flag) continue;
        if(s.at(0) == 'o'){
            if(tmp.at(0) == 'S'){
                if(tmp.at(1) != tmp.at(n-1)) flag = false;
            }else{
                if(tmp.at(1) == tmp.at(n-1)) flag = false;
            }
        }else{
            if(tmp.at(0) == 'S'){
                if(tmp.at(1) == tmp.at(n-1)) flag = false;
            }else{
                if(tmp.at(1) != tmp.at(n-1)) flag = false;
            }
        }
        if(!flag) continue;
        cout << tmp << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

int main(){

    ll h; cin >> h;

    bitset<40> bs(h);

    ll msb = 40-1;
    while(!bs.test(msb)) msb--;

    cout << setprecision(15) << pow(2,msb+1)-1 << endl;

    return 0;
}

Measured memory_bytes: 4252
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll n,x,t;  cin>>n>>x>>t;
    ll ans=(n/x)*t;
    if(n%x) ans+=t;
    cout<<ans;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e5;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n;

int main(){
	cin>>n;
	cout<<n/500*1000+n%500/5*5<<endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
K = int(input())

ans = []
moji = S[K-1]

for i in range(len(S)):
    if S[i] == moji:
        ans += S[i]
    else:
        ans += '*'

ans = ','.join(ans)
ans = ans.replace(',', '')

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>A(3);
  for(int i=0;i<3;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int x=2*A.at(2)-A.at(0)-A.at(1);
  if(x%2==0)
    cout<<x/2<<endl;
  else
    cout<<(x/2)+2<<endl;
   return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")


ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

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


signed main() {

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int g = lcm(C, D);

	int cntB = B - (B / C + B / D - B / g);
	int cntAm1 = (A - 1) - ((A - 1) / C + (A - 1) / D - (A - 1) / g);

	cout << cntB - cntAm1 << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin>>s;
  int n=s.size();

  int ans=n;
  string t=s;
  int res=0;
  for(int i=1;i<n;i++){
    if(t[i]==t[i-1]){
      if(t[i]=='0') t[i]='1';
      else t[i]='0';
      res++;
    }
  }

  ans=res;
  t=s;
  if(t[0]=='0') t[0]='1';
  else t[0]='1';
  res=1;
  for(int i=1;i<n;i++){
    if(t[i]==t[i-1]){
      if(t[i]=='0') t[i]='1';
      else t[i]='0';
      res++;
    }
  }
  ans=min(ans,res);
  cout<<ans<<endl;

  return 0;
}


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

int main()
{
    string s;
    cin>>s;
    int l=s.size();
    if(s[l-1]=='s'){
        cout<<s<< "es"<<endl;
    }
    else{
        cout<<s<< "s"<<endl;
    }
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n,x,total=0;
		int i,j,k;
		Scanner scan = new Scanner(System.in);
		while(true)
		{	
		n=scan.nextInt();
		x=scan.nextInt();
		if(n==0&&x==0)
			break;
		for(i=1;i<=n-2;i++) {
			for(j=i+1;j<=n-1;j++) {
				for(k=j+1;k<=n;k++) {
					if(i+j+k==x)
						total++;
				}
			}
		}
		System.out.println(total);
		total=0;
		}
	}
}

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

double rec(int n, int heads, double* arr, vector<vector<double>>& dp, vector<vector<bool>>& vis){
    if(heads<0)
        return 0.0;
    if(n==0)
        return (heads==0);
    if(vis[n][heads])
        return dp[n][heads];
    vis[n][heads]=1;
    return dp[n][heads] = arr[n]*rec(n-1,heads-1,arr,dp,vis) + (1-arr[n])*rec(n-1,heads,arr,dp,vis);
}

int main() {
    int n;
    cin>>n;
    double arr[n+1];
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, -1));
    vector<vector<bool>> vis(n+1, vector<bool>(n+1, false));
    double ans=0;
    for(int i=0;i<=n;i++){
        int tails = n-i;
        if(i>tails) ans+=rec(n,i,arr,dp,vis);
    }
    cout<<fixed<<setprecision(9)<<ans<<"\n";
}

Measured memory_bytes: 75632
package main

import (
  "fmt"
  "strconv"
)

func main() {
  var num int
  var str string

  count := 0
  fmt.Scanf("%d", &num)
  str = strconv.Itoa(num)

  for _, char := range str {
    if char == '1' {
      count++
    }
  }

  fmt.Print(count)
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy";
  else if (s == "Cloudy") cout << "Rainy";
  else cout << "Sunny";
  cout << endl;
  return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N;

  for(int i = 0; i < N; i++) {
    cin >> S;
    if(S == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    import math
    def input():
        return sys.stdin.readline()[:-1]
    N=int(input())
    A=list(map(int,input().split()))
    c=1
    if 0 in A:
        print(0)
        sys.exit()
        
    for x in A:     
        c=c*x
        if c>10**18:
            print(-1)
            sys.exit()

    print(c)
if __name__ == '__main__':
    main()


Measured memory_bytes: 22704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100010;
const int mod = 1000000007;
int h[N], e[2*N], ne[2*N], idx;
int deg[N];
ll cnt[N][2];
int n;
bool inque[N];

ll get(int num, int color, int pre){
    ll res = 1;
    if(deg[num] == 1) {
        cnt[num][1] = 1;
        cnt[num][0] = 1;
    } else if(cnt[num][color] != 0) {
        res = cnt[num][color];
    } else {
        for(int i = h[num]; i != -1; i = ne[i]) {
            int j = e[i];
            if(j == pre) continue;
            if(color == 0) {
                res *= (get(j, 0, num) + get(j, 1, num));
                res %= mod;
            } else {
                res *= get(j, 0, num);
                res %= mod;
            }
        }
        cnt[num][color] = res;
    }
    //cout << num << " " << color << " " << res << endl;
    return res;
}

void add(int a, int b) {
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx ++;
    deg[a] ++;
}
int main(){
    cin >> n;
    if(n == 1) {
        cout << 2 << endl;
        return 0;
    }
    if(n == 2) {
        cout << 3 << endl;
        return 0;
    }
    memset(h, -1, sizeof h);
    for(int i = 0; i < n- 1; i ++) {
        int a, b;
        cin >> a >> b;
        add(a, b);
        add(b, a);
    }
    for(int i = 1; i <= n ; i ++) {
        if(deg[i] > 1) {
            cout << (get(i, 0, -1) + get(i, 1, -1)) % mod << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 12544
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        Tuple[] ts = new Tuple[n];

        for (int i = 0; i < n; i++) {
            String s = in.next();
            int p = in.nextInt();
            ts[i] = new Tuple(s, p, i);
        }

        Arrays.sort(ts);

        for (int i = 0; i < n; i++) {
            System.out.println(ts[i].i + 1);
        }
    }
}

/**
 s tuple
*/
class Tuple implements Comparable<Tuple> {
    String s;
    int p;
    int i;

    public Tuple(String s, int p, int i) {
        this.s = s;
        this.p = p;
        this.i = i;
    }

    @Override
    public int compareTo(Tuple o) {
        if (!this.s.equals(o.s)) {
            return this.s.compareTo(o.s);
        } else {
            if (this.p < o.p) {
                return 1;
            } else {
                return -1;
            }
        }
    }
}


Measured memory_bytes: 21716
N = gets.to_i
H = gets.split.map &:to_i

dp = Array.new(N, nil)
dp[0] = 0

N.times do |i|
    next if i >= N - 1
    cost = (H[i+1] - H[i]).abs + dp[i]
    dp[i+1] = cost if dp[i+1].nil? || cost < dp[i+1]

    next if i >= N - 2
    cost = (H[i+2] - H[i]).abs + dp[i]
    dp[i+2] = cost if dp[i+2].nil? || cost < dp[i+2]
end

p dp[-1]

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

def is_street(s, t):
    """
    道であること（壁ではないこと）を確認
    """
    return S[s][t] == '.'

def count(maze):
    """
    最大のコストを探索
    """
    r = -1
    for i in range(H):
        for j in range(W):
            r = max(r, maze[i][j])
    return r

def bfs(h, w):
    """
    h: スタート位置（高さ）
    w: スタート位置（横）
    """
    m = []  # スタート地点からの距離が入る
    for i in range(H):
        s = [-1] * W
        m.append(s)
    m[h][w] = 0  # スタート地点は0

    q = [[h, w]]  # キュー
    while len(q) != 0:
        t, u = q.pop(0)
        cost = m[t][u]

        # 上
        uh = t-1
        uw = u
        if uh >= 0 and m[uh][uw] == -1 and is_street(uh, uw):
            m[uh][uw] = cost + 1
            q.append([uh, uw])

        # 下
        sh = t+1
        sw = u
        if sh < H and m[sh][sw] == -1 and is_street(sh, sw):
            m[sh][sw] = cost + 1
            q.append([sh, sw])

        # 左
        lh = t
        lw = u-1
        if lw >= 0 and m[lh][lw] == -1 and is_street(lh, lw):
            m[lh][lw] = cost + 1
            q.append([lh, lw])


        rh = t
        rw = u+1
        if rw < W and m[rh][rw] == -1 and is_street(rh, rw):
            m[rh][rw] = cost + 1
            q.append([rh, rw])

    max_cost = count(m)
    return max_cost

ans = -1
# 壁以外のすべてのマスをスタートにして探索
for i in range(H):
    for j in range(W):
        if is_street(i, j):
            c = bfs(i, j)
            ans = max(ans, c)

print(ans)


Measured memory_bytes: 3192
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let (H, W) = get!(usize, usize);
    let mut map = get!(String; H)
        .iter()
        .map(|s| s.chars().collect::<Vec<_>>())
        .collect::<Vec<_>>();
    let mut cnt = 0;
    let mut blacks = Vec::new();
    for (y, row) in map.clone().iter().enumerate() {
        for (x, cell) in row.iter().enumerate() {
            if *cell == '#' {
                blacks.push((x, y));
            }
        }
    }
    loop {
        let mut blacks_buf = Vec::new();
        let mut updated = false;
        for (x, y) in blacks {
            if x > 0 {
                if map[y][x-1] == '.' {
                    updated = true;
                    map[y][x-1] = '#';
                    blacks_buf.push((x-1, y));
                }
            }
            if x < W - 1 {
                if map[y][x+1] == '.' {
                    updated = true;
                    map[y][x+1] = '#';
                    blacks_buf.push((x+1, y));
                }
            }
            if y > 0 {
                if map[y-1][x] == '.' {
                    updated = true;
                    map[y-1][x] = '#';
                    blacks_buf.push((x, y-1));
                }
            }
            if y < H - 1 {
                if map[y+1][x] == '.' {
                    updated = true;
                    map[y+1][x] = '#';
                    blacks_buf.push((x, y+1));
                }
            }
        }
        blacks = blacks_buf;
        if updated {
            cnt += 1;
        } else {
            break;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 27896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char s;
  cin >> s;
  if (s=='a'|s=='e'|s=='i'|s=='o'|s=='u'){
  cout << "vowel" << endl;
}else{
  cout  << "consonant" << endl;
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.1416
#define f(i,l,r) for(int i=l;i<=r;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

 int main()
{

    ll i,j,k,sum=0,x,n,p,q,r;
    cin>>n;

f(i,1,n)
{

        if(i%3==0||i%5==0)
            continue;
        else
        {
            sum=sum+i;
        }

    }

    cout<<sum<<endl;



return 0;

}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(rng(a));
  uni(a);
  if(sz(a) == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

n = N + M
fac = [1] * (n + 1) 
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = (fac[j - 1] * j) % MOD

inv[n] = pow(fac[n], MOD-2, MOD)
for j in range(n - 1, -1, -1):
    inv[j] = (inv[j + 1] * (j + 1)) % MOD

def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return (fac[n] * inv[n - r] * inv[r]) % MOD

def perm(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return comb(n, r) * fac[r] % MOD

ans = pow(perm(M, N), 2, MOD)
# r: AiとBiが一致する個数
for r in range(1, N + 1):
    p = comb(M, r) * perm(N, r) * pow(perm(M - r, N - r), 2, MOD) % MOD
    p *= -(-1) ** (r % 2)
    ans -= p
    ans %= MOD

print(ans)

Measured memory_bytes: 87772
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m;;
    int c=0;
    cin>>n;
    m=n;
    while(n!=0)
    {
        c=c+n%10;
        n=n/10;
    }
    if(m%c==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int N, Q, a, b, mp[MAX];
ll sum;

int main(int argc, char** argv) {
	scanf("%d", &N);
	rep(i, 0, N) {
		scanf("%d", &a);
		mp[a]++;
		sum += a;
	}
	scanf("%d", &Q);
	rep(q, 0, Q) {
		scanf("%d%d", &a, &b);
		sum -= 1L*mp[a]*a;
		sum += 1LL*mp[a]*b;
		mp[b] += mp[a];
		mp[a] = 0;
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 4044