akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int N;
	int A[101],B[101],C[101];
	int ans = 0;

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

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


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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
// #include <bits/stdc++.h>
#define req(i,h) for(int i = 0; i < h; i++)

using namespace std;


int main(void) {
        string s,t;
        cin >> s >> t;
        req(i,s.length()) {
            if(s == t) {
                cout << "Yes";
                return 0;
            }
            s = s.back() + s.substr(0. , s.length() - 1);
        }
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  for(int bit=0;bit<(1<<3);bit++){
    int sum=s[0]-'0';
    for(int i=0;i<3;i++){
      int C=(1<<i)&bit;
      if(C!=0){
        sum+=s[i+1]-'0';
      }else{
        sum-=s[i+1]-'0';
      }
    }
    // cout<<bitset<8>(bit)<<endl;
    // cout<<sum<<endl;
    if(sum==7){
      string S;
      rep(i,3){
        S+=s[i];
        int C=(1<<i)&bit;
        if(C!=0)
        S+='+';
        else
        S+='-';
      }
      S+=s[3];
      S+="=7";
      cout<<S<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	if n % 2 == 0 {
		fmt.Println(n)
	} else {
		fmt.Println(n * 2)
	}
}

Measured memory_bytes: 640
import sys
from collections import Counter
a_ls = []
_dict = {}
for i in range(3):
    a = [int(i) for i in sys.stdin.readline().split()]
    for j, _a in enumerate(a):
        _dict[_a] = [i, j]
    a_ls.append(a)
n = int(input())
i_ls = Counter()
j_ls = Counter()
res = []
for i in range(n):
    b = int(input())
    _b = _dict.get(b)
    if _b is not None:
        res.append(_b)
flg = False
for i in range(3):
    if [i,0] in res and  [i,1] in res and [i,2] in res:
        flg = True
        break
    if [0,i] in res and [1,i] in res and [2,i] in res:
        flg = True
        break
if [0,0] in res and [1,1] in res and [2,2] in res:
    flg = True
if [2,0] in res and [1,1] in res and [0,2] in res:
    flg = True
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        int n=Integer.parseInt(br.readLine());
        TreeSet<String> set=new TreeSet<>();
        for(int i=0;i<n;i++)
        {
            String s=br.readLine();
            set.add(s);
        }
        pw.println(set.size());
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 67756
N = int(input())
A = sorted(list(map(int, input().split())),reverse=True)
x, y = 0, 0
for i in range(N-1):
    if A[i] == A[i+1]:
        x = A[i]
        break
for j in range(i+2,N-1):
    if A[j] == A[j+1]:
        y = A[j]
        break
print(x*y)

Measured memory_bytes: 14252
#include <iostream>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <algorithm>

#define in (int)10e9
using namespace std;
int main()
{	
	int ans=0, i, j, k;
	int N;
	cin >> N;
	
	if(N/10==0){
		cout << N << endl;
		return 0;
	}
	
	i = N;
	j = 1;
	while (i / 10)
	{
		j++;
		i /= 10;
	}

	ans = 9;
	for (i = 2; i <= j;i++){
		if(i%2){
			if(i<j){
				ans += pow(10, i)-pow(10,i-1);
			}
			else{
				ans += N - pow(10, i - 1) + 1;
				break;
			}
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
    long long n,p[200001],min=200001,ans=0;
    cin >> n;
    rep(i,n){
        cin >> p[i];
        if(min >= p[i]){
            min = p[i];
            ans++;
        }
    }
    cout << ans << endl;
} 


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    string s;
    cin >> s;

    int len = s.length();
    int score = 0;
    for(int i = 0; i < len; i ++)
    {
    	if(i % 2 == 0)
    	{
    		if(s[i] == 'p')
    			score --;
    	}
    	else if(i % 2 == 1)
    	{
    		if(s[i] == 'g')
    			score ++;
    	}
    }
    cout << score << endl;
}

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

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

  vector<pair<int , int>> p(N);
  
  for(int i = 0; i < N ; i++){
    int a;
    int b;
    cin >> a >> b;
    p.at(i) = make_pair(a, b);
  }
  
  sort(p.begin(), p.end());
    
  cout << p.at(N-1).first + p.at(N-1).second << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
using namespace std;
long long N;
int main() 
{
	scanf("%lld",&N);
	printf("50\n");
	for(int i = 0; i < 50; i++) 
	{
		if(i) 
		{
			printf(" ");
		}
		printf("%lld",49-i+(N+49-i)/50);
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [int(num) for num in input().split(" ")]
q = int(input())
t = [int(num) for num in input().split(" ")]

sum = 0
for j in range(q):
    for i in range(n):
        if s[i] == t[j]:
            sum += 1
            break

print(sum)


Measured memory_bytes: 6552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define pl pair<ll,ll>
#define m_p make_pair
#define MOD 1000000007
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //ll n;
    ll t;
    t =1;

    //cin >> t;

    while(t--)
    {
        long long n;
        cin >> n;
        if(n%2==1)
        {
            cout << 0 << endl;
        }
        else
        {
            ll i,ans =0;
            ll val = 10;
            /*for(i=0;i<18;i++)
            {
                ans += n/val;
                val *= 10 ;

            }
            */
            val = 5;
            
            ll cnt = n / val;
            cnt = cnt/2;
            while(cnt >0)
            {
                ans += cnt ;
                val *= 5;
                cnt = n/ val;
                cnt = cnt/2;

            }
            cout << ans << endl;

        }

    }


    return 0;

}


// #include <bits/stdc++.h>
// using namespace std;
// #define ll long long
// int main()
// {
  
//   }
//   return 0;
// }


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

#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define pb push_back
#define endl '\n'
#define MOD 1000000007
#define maxN 1e5

int main() {
	Omar45
    ll n; cin >> n;
    if (n%2==0)
        cout << n/2 << endl;
    else
        cout << n/2 + 1 << endl;
}


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

namespace Atcoder
{
    class ABC130_A
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int x = int.Parse(str[0]);
            int a = int.Parse(str[1]);
            if(x < a)
            {
                Console.Write(0);
            }
            else
            {
                Console.Write(10);
            }
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
using ll = long long;
using namespace std;


int main() {
    int n, k, l[50];
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    sort(l, l + n, greater<int>());
    int ans = 0;
    for (int i = 0; i < k; i++)ans += l[i];
    cout << ans;
    return 0;
}


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

int main() {
	char s[10001]={};
	while(1){
		s[0]=' ';
		cin >> s;
		if(s[0]==' '){return 0;}
		int i=0,ioi=0,j=0,joi=0;
		for(int k=0;s[k]!='\0';k++){
			switch(j){
				case 1:
				if(s[k]=='O'){
					j=2;
				}else{
					j=0;
				}
				break;
				case 2:
				if(s[k]=='I'){
					j=0;
					joi++;
				}else{
					j=0;
				}
			}
			if(s[k]=='J'){
				j=1;
			}
			switch(i){
				case 1:
				if(s[k]=='O'){
					i=2;
				}else{
					i=0;
				}
				break;
				case 2:
				if(s[k]=='I'){
					ioi++;
				}else{
					i=0;
				}
			}
			if(s[k]=='I'){
				i=1;
			}
		}
		cout << joi << endl;
		cout << ioi << endl;
	}
}

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

int main()
{
  int n;
  int ans = 0;
  string str;
  cin >> n;
  map<string, bool> gacha;
  for (int i = 0; i < n; i++) {
    cin >> str;
    if (!gacha[str]) {
      gacha[str] = true;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int cnt = 0;
    int min = 300000;
    rep(i, n) cin >> p[i];
    rep(i, n)
    {
        if (p[i] < min)
        {
            min = p[i];
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>                                          
#include <cstdio>                                            
using namespace std;                                         
                                                             
int main() {                                                 
  int a, b;                                                  
  cin >> a >> b;                                             
  int d = a/b;                                               
  int r = a%b;                                               
  double f = (double)a/b;                                    
  printf("%d %d %.5f\n", d, r, f);                           
  return 0;                                                  
}                                                            
           

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), x = sc.nextInt(), a[] = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();

        long cnt = 0;
        cnt += Math.max(0, a[0]-x); //First element
        long current = a[0]-cnt;
        for (int i = 1; i < n; i++) {
            cnt += Math.max(0, current+a[i]-x);
            current = a[i]-Math.max(0, current+a[i]-x);
        }
        System.out.println(cnt);
    }
}

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

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

  int a, b;
  string s;
  cin >> a >> b >> s;

  for (int i = 0; i < a; ++i) {
    if (s[i] < '0' || s[i] > '9') {
      cout << "No" << "\n";
      return 0;
    }
  }

  if (s[a] != '-')  {
    cout << "No" << "\n";
    return 0;
  }

  for (int i = a + 1; i < s.size(); ++i) {
    if (s[i] < '0' || s[i] > '9') {
      cout << "No" << "\n";
      return 0;
    }
  }

  cout << "Yes" << "\n";
}


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

int main( void )
{
    int n, m;
    while ( cin >> n >> m && n && m ) {
        int T[101];
        memset( T, 0, sizeof(T) );
        for ( int i = 0; i < n; i++ ) {
            int M;
            cin >> M;
            for ( int j = 0; j < M; j++ ) {
                int t;
                cin >> t;
                T[t]++;
            }
        }
        int maxm = 0;
        int maxd = 0;
        for ( int i = 0; i < 101; i++ ) {
            if ( T[i] >= m && T[i] > maxm ) {
                maxm = T[i];
                maxd = i;
            }
        }

        cout << maxd << endl;
    }
    return 0;
}

Measured memory_bytes: 0
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

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

const int N = (int) 1e6 + 6, mod = 0;
int a[N];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] + a[i + 1] >= l) {
            cout << "Possible" << endl;
            for (int j = n - 1; j > i + 1; --j)
                cout << j << '\n';
            for (int j = 1; j <= i; ++j)
                cout << j << '\n';
            cout << i + 1 << '\n';
            return 0;
        }
    }
    cout << "Impossible";




}








Measured memory_bytes: 1280
// This file is a "Hello, world!" in Java language by OpenJDK for wandbox.
import java.util.*;
import java.io.*;

class Main
{
    public static void main(String[] args)
    {
		new Main().run();
	}
	
	void run(){
		Scanner sc=new Scanner(System.in);
		String S=sc.next();
		String T=sc.next();
		String ans=T+S;
		System.out.println(ans);
	}
	
	void tr(Object...objects){
		System.out.println(Arrays.deepToString(objects));
	}
}

// OpenJDK reference:
//   http://openjdk.java.net/

// Java language references:
//   http://docs.oracle.com/javase


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    vector<vector<int>>c(3,vector<int>(3));
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    bool judge=false;
    for(int i=-200;i<200;i++){
        for(int j=-200;j<=200;j++){
            for(int k=-200;k<=200;k++){
                int x=c[0][0]-i;
                int y=c[0][1]-i;
                int z=c[0][2]-i;
                if(x+j==c[1][0]&&x+k==c[2][0]&&y+j==c[1][1]&&y+k==c[2][1]&&z+j==c[1][2]&&z+k==c[2][2]){
                    judge=true;
                    break;
                }
            }
        }
    }
    if(judge) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std ;

int N,W ;
int m[1010][2] ;
int dp[1010][1010] ;
int cnt = 0 ;

int main(){
	
	while( cin >> W , W ){
		cin >> N ;
		cnt++;
		for( int i=0 ; i<1010 ; i++ )
			for( int j=0 ; j<1010 ; j++ )
				dp[i][j] = 0 ;
		
		for( int i=1 ; i<=N ; i++ ){
			scanf("%d,%d",&m[i][0] ,&m[i][1]) ;
		}
		
		for( int i=1 ; i<=N ; i++ ){
			for( int j=0 ; j<=W ; j++ ){
				if( j-m[i][1] >= 0 ){
					dp[i][j] = max( dp[i-1][j] , dp[i-1][j-m[i][1]] + m[i][0] ) ;
				}
				else{
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		
		int best[2] = {0} ;
		for( int j=0 ; j<=W ; j++ ){
			if( best[0] < dp[N][j] ){
				best[0] = dp[N][j] ;
				best[1] = j ;
			}
		}
		
		cout << "Case " << cnt << ':' << endl ;
		cout << best[0] << endl ;
		cout << best[1] << endl ;
	}
	
return 0;
}

Measured memory_bytes: 5236
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
#define edge(u) for(re int i=head[u];i;i=e[i].nxt)
#define ll long long
using namespace std;
const int N=5005;
const int mod=1e9+7;
inline int read(){
	int x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while('0'<=ch&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,sz[N],cnt,head[N];
ll g[N],dp[N][N],tmp[N];
struct edge{
	int to,nxt;
}e[N<<1];
void add(int a,int b){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u,int f){
	sz[u]=dp[u][1]=1;
	edge(u){
		int v=e[i].to;
		if(v==f) continue;
		dfs(v,u);
		inc(j,1,sz[u]+sz[v]) tmp[j]=0;
		inc(j,1,sz[u])
			inc(k,0,sz[v])
				(tmp[j+k]+=dp[u][j]*dp[v][k])%=mod;
		inc(j,1,sz[u]+sz[v]) dp[u][j]=tmp[j];
		sz[u]+=sz[v];
	}
	for(re int i=2;i<=sz[u];i+=2) (dp[u][0]+=mod-1LL*dp[u][i]*g[i]%mod)%=mod;
}
int main(){
	g[0]=1,n=read();
	for(re int i=2;i<=n;i+=2) g[i]=g[i-2]*(i-1)%mod;
	inc(i,2,n){
		int a=read(),b=read();
		add(a,b),add(b,a);
	}
	dfs(1,0);
	printf("%lld",(mod-dp[1][0])%mod);
}

Measured memory_bytes: 194944
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n;
int h[100005],ans[100005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=n;i>=1;i--){
		if(ans[i])continue;
		int j=i-1;
		while(j>=1&&h[j]>=h[j+1])j--;
		for(int k=j+1;k<=i;k++)ans[k]=k-j-1;
	}
	cout<<*max_element(ans+1,ans+n+1)<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll h[100010];for(int i=0;i<n;i++)cin>>h[i];
    ll ng=0;ll ok=INF;
    while(ok-ng>1){
        ll mid=(ok+ng)/2;
        ll c=0;
        for(int i=0;i<n;i++){
            if(h[i]>b*mid){
                c+=(h[i]-b*mid)/(a-b);
                if((h[i]-b*mid)%(a-b)){
                    c++;
                }
            }
        }
        if(c<=mid){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long 
#define mod 1000000007 
void fast(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
}
void setIO(string name) {
  freopen((name+".in").c_str(),"r",stdin);
  freopen((name+".out").c_str(),"w",stdout);
}
vector<int> adj[200005];
int visited[200005]={0};
int ender=-1;
int n;
long long k;
vector<int> c;
void dfs(int node){
  visited[node]=1;
   c.pb(node);
  for(auto next:adj[node]){
    if(!visited[next]){
      dfs(next);
    }else{
      ender=next;
      break;
    }
  }
 
}

int main() {
   fast();
   cin>>n;
   cin>>k;
   for(int i=0;i<n;i++){
    int l;
    cin>>l;
    --l;
    adj[i].pb(l);
   }
   dfs(0);
  
  
     int x;
      for(int i=0;i<c.size();i++){
        if(c[i]==ender){
           x=i;
           break;
        }
      }
     if(k<=x){
       cout<<c[k]+1<<"\n";
       return 0;
     }else{
      long long y=c.size()-x;
      k-=x;
      k%=y;
      cout<<c[k+x]+1<<"\n";
      return 0;
     }
      
   

   

   

   
   



   
}
 


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

char N[15];

int main(){

	scanf("%s",N);

	int len=strlen(N);

	int i;

	int SN=0;
	for(i=0;i<len;i++){
	SN+=N[i]-'0';
	}
	if(atoi(N)%SN==0){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}

return 0;
}

Measured memory_bytes: 128
type Dice = (Int,Int,Int) -- (top,south,east)
type Command = String

main = do
    n <- readLn
    if n == 0 then return () else do
        proc n 1 (1,2,3)
        main

proc 0 acc _    = print acc
proc n acc dice = do
    cmd <- (head . words) `fmap` getLine
    let
        dice'@(a',_,_) = operate cmd dice
    proc (n-1) (acc+a') dice'

operate :: Command -> Dice -> Dice
operate "North" (a,b,c) = (b,7-a,c)
operate "East"  (a,b,c) = (7-c,b,a)
operate "West"  (a,b,c) = (c,b,7-a)
operate "South" (a,b,c) = (7-b,a,c)
operate "Right" (a,b,c) = (a,c,7-b)
operate "Left"  (a,b,c) = (a,7-c,b)

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

long long l[87];
int main(){
  l[0]=2;
  l[1]=1;
  REP(i,87){
    if(i==0 || i==1){
      continue;
    }
    l[i] = l[i-1]+l[i-2];
  }
  
  int n;
  cin>>n;
  cout<<l[n]<<endl;
  return 0;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x;
    cin >> n >> m >> x;
    int s=0,e=0;
    REP(i,m){
        int a;
        cin >> a;
        if(a<x) s++;
        else e++;
    }
    cout << min(s,e) << endl; 
    

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; else return gcd(b, a % b); }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
template <class T> bool amax(T &x, T y) { if (x < y) { x = y; return 1; } else return 0; }
template <class T> bool amin(T &x, T y) { if (x > y) { x = y; return 1; } else return 0; }
template <class T> i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template <class T> i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }

int main() {
  ioinit();
  int n, k;
  cin >> n >> k;
  vector<int> v0, v1;
  {
    vector<vector<int>> v(100010);
    rep(i, n) {
      int t, d;
      cin >> t >> d;
      v[t].push_back(d);
    }
    rep(i, 100001) {
      if (v[i].size() == 0) continue;
      sort(all(v[i]));
      v1.push_back(v[i][v[i].size() - 1]);
      rep(j, v[i].size() - 1) v0.push_back(v[i][j]);
    }
  }
  sort(all(v0)); reverse(all(v0));
  sort(all(v1)); reverse(all(v1));
  {
    i64 ans = 0, sum = 0;
    i32 cnt = 0, kind = 0;
    rep(i, min(k, (int) v0.size())) { sum += v0[i]; cnt++; }
    rep(i, max(0, k - cnt)) { sum += v1[i]; kind++; }
    amax(ans, sum + (i64) kind * kind);
    while (cnt > 0 && kind < v1.size()) {
      sum -= v0[--cnt];
      sum += v1[kind++];
      amax(ans, sum + (i64) kind * kind);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 6396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,y;
	cin>>n>>y;
	if(n*10000==y){cout << n << " 0 0" << endl;return 0;}
	rep(i, n){
		if(10000*i > y)break;
		int t = y - 10000*i;
		if(t>=(n-i)*1000&&t<=(n-i)*5000&&(t-(n-i)*1000)%4000 == 0){
			int s = (t-(n-i)*1000)/4000;
			cout << i << ' ' << s << ' ' << n-i-s << endl;
			return 0;
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}


Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const A = parseInt(arg[1]);
    const B = parseInt(arg[2]);
    const C = parseInt(arg[3]);
    const D = parseInt(arg[4]);
    const E = parseInt(arg[5]);
    
    console.log(Math.ceil(N / Math.min(A, B, C, D, E) + 4));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21576
import sys
import collections
import heapq


def main():

    input = sys.stdin.readline

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

    edges = [list(map(int, input().split())) for _ in range(M)]

    ans_list = [0] * (N + 1)

    syori_list = []

    adjacent_dict = collections.defaultdict(list)

    
    for frm, to in edges:
        adjacent_dict[frm].append(to)
        adjacent_dict[to].append(frm)

    tmp_list = []
    tmp_list = adjacent_dict[1]
    for i in tmp_list:
        syori_list.append(i)
        ans_list[i] = 1

    for i in syori_list:
        tmp_list = adjacent_dict[i]
        for j in tmp_list:
            if ans_list[j] == 0:
                syori_list.append(j)
                ans_list[j] = i
    
    check_list = ans_list[2:]

    if check_list.count(0) > 0:
        print("No")
        return
    else:
        print("Yes")
    
    for i in check_list:
        print(i)

if __name__ == "__main__":
    main()

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL h, w, dp[1001][1001], MOD = 1e9 + 7;
string s[1001];

int main() {
	cin >> h >> w;
	inc(i, h) { cin >> s[i]; s[i] += "@"; }
	s[h] = string(w + 1, '@');
	
	dp[0][0] = 1;
	inc(i, h) {
	inc(j, w) {
		if(s[i + 1][j] == '.') { (dp[i + 1][j] += dp[i][j]) %= MOD; }
		if(s[i][j + 1] == '.') { (dp[i][j + 1] += dp[i][j]) %= MOD; }
	}
	}
	
	cout << dp[h - 1][w - 1] << endl;
	
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int h, w;
    cin >> h >> w;
    vector<vector<int> > c(10, vector<int>(10));
    rep (i, 10) rep (j, 10) cin >> c[i][j];
    rep (k, 10) rep (i, 10) rep (j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
    int res = 0;
    rep (i, h) {
        rep (j, w) {
            int a;
            cin >> a;
            if (a == -1) continue;
            res += c[a][1];
        }
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
n, x = map(int, input().split())
X = list(map(int, input().split()))

Y = [abs(x_ - x) for x_ in X]

import fractions
#import math
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
    #return reduce(math.gcd, numbers)

print(gcd_list(Y))

Measured memory_bytes: 83988
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 87;
int a[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    int s = 0;
    for (int i = 1; i <= n + 1; ++i)
        s += abs(a[i] - a[i-1]);
    for (int i = 1; i <= n; ++i)
        cout << s - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << '\n';
}

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

int main() {
    char s[11];
    char t[11];

    scanf("%s", s);
    scanf("%s", t);

    int i = 0;
    int len = strlen(t);
    while(i < (len - 1)) {
        if (s[i] != t[i])
        {
            printf("%s\n", "No");
            return 0;
        }

        i++;
    }
    printf("%s\n", "Yes");
    return 0;
}



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

dx = [1,1,0,-1,-1,-1,0,1]
dy = [0,1,1,1,0,-1,-1,-1]

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            cnt = 0
            for k in range(8):
                x = i + dx[k]
                y = j + dy[k]
                if 0 <= x < H and 0 <= y < W and S[x][y] == "#":
                    cnt += 1
            S[i][j] = str(cnt)

for s in S:
    print("".join(s))

Measured memory_bytes: 3188
program ABC117B
    implicit none
    integer(8)::N,i
    integer(8),allocatable,dimension(:)::L
    read(5,*)N
    allocate(L(N))
    read(5,*)(L(i),i=1,N)
    L=iqsort(L)

    do i=1,N-1
        L(N)=L(N)-L(i)
    end do

    if(L(N)<0)then
        print'(A)',"Yes"
    else
        print'(A)',"No"
    end if

contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program ABC117B

Measured memory_bytes: 640
// Problem : C - One Quadrillion and One Dalmatians
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

ll pow2(ll a, ll b) {
	if (b == 0) return 1;
	if (b == 1) return a;
	ll d = pow2(a, b / 2);
	d = d * d;
	if (b % 2) return d * a;
	return d;	
}

void solve(int len, ll n) {
	// cout << len << " " << n << endl;
	if (len == 0) return;
	if (n == 0) return;
	REP(i, 26) {
		if (pow2(26, len - 1) < n) {
			n -= pow2(26, len - 1);
		} else {
			cout << (char)(i + 'a');
			solve(len - 1, n);
			break;
		}
	}
}

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	int len = 0;
	RI(i, 100) {
		// cout << pow2(26, i) << " " << i << " " << n << endl;
		if (pow2(26, i) < n) {
			// cout << "ay" << endl;
			n -= pow2(26, i);
		} else {
			len = i;
			break;
		}
	}
	// cout << len << endl;
	solve(len, n);
	return 0;
}
 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    string S;
    cin >> S;
    int N;
    cin >> N;
    stack<char> st;
    int T[N][2] = {};
    char C[N] = {};
    rep(i,N){
        cin >> T[i][0];
        if(T[i][0] == 2) cin >> T[i][1] >> C[i];
    }
    bool flag = true;
    for(int i=N-1;0<=i;i--){
        if(T[i][0] == 1){
            flag = !flag;
        }else{
            if(T[i][1] == 1){
                if(flag){
                    cout << C[i];
                }else{
                    st.push(C[i]);
                }
            }else{
                if(flag){
                    st.push(C[i]);
                }else{
                    cout << C[i];
                }
            }
        }
    }
    if(!flag){
        reverse(S.begin(),S.end());
    }
    cout << S;
    while(!st.empty()){
        char c = st.top();
        st.pop();
        cout << c;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(void)
{
	int n,i,p[25],cnt=0;
	cin>>n;
	for(i=0;i<n;i++) cin>>p[i];
	for(i=1;i<n-1;i++){if((p[i-1]<p[i] && p[i]<p[i+1]) || (p[i+1]<p[i]&& p[i]<p[i-1])) cnt++;}
	cout<<cnt<<endl;
	return 0;
}

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

int main () {
  int N;
  int sm,bg;
  cin >> N;
  vector<int> AB(N);
  for (int i=0; i<N; i++) {
    cin >> AB[i];
  }
  sort(AB.begin(),AB.end());
  if (AB[N-1] - AB[0] > 1) {
    cout << "No" << endl;
  }
  else if (AB[N-1] - AB[0] == 1) {
    sm = 1;
    for (int i=1; i<N; i++) {
      if (AB[0] == AB[i]) {
        sm++;
      }
    }
    bg = N-sm;
    if (sm < AB[N-1] && AB[N-1] <= sm + bg/2) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    if (AB[0] == N-1 || (1 <= AB[0] && AB[0] <= N/2)) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int num[] = new int[n];
        long sum = 0;
        for(int i = 0 ; i < n ; i++)
            num[i] = sc.nextInt();
        int max = num[0];
        int min = max;
        sum += max;
        for(int i = 1 ; i < n ; i++)
        {
            if(num[i] > max)
                max = num[i];
            else if(num[i] < min)
                min = num[i];
            sum += num[i];
        }
        System.out.println(min + " " + max + " " + sum);
    }
}


Measured memory_bytes: 41492
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include<functional>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 30005
#define maxn 100005
typedef pair<int,int> PII;
typedef long long LL;

int n,m,k,ans;
struct Node{int to,next;}node[5005];
int head[2010],hcnt;
inline void add(int x,int y){
    node[hcnt].to=y;node[hcnt].next=head[x];
    head[x]=hcnt++;
}
int ct(int u,int fa,int num){
    if(num==0)return 1;
    int temp=1;
    for(int i=head[u];~i;i=node[i].next){
        int e=node[i].to;
        if(e==fa)continue;
        temp+=ct(e,u,num-1);
    }
    return temp;
}
int main(){
    //freopen("in.txt","r",stdin);
    int i,j,x,y;
    mst(head,-1);
    scanf("%d%d",&n,&k);
    for(i=2;i<=n;++i){
        scanf("%d%d",&x,&y);
        add(x,y);add(y,x);
    }
    LL num=1;
    for(LL i=0;i<2000000000*1000000000;++i)
        num=num*5%MOD+MOD;
    ans=0;
    if(k&1){
        for(i=1;i<=n;++i){
            for(int l=head[i];~l;l=node[l].next){
                int e=node[l].to;
                if(e<=i)continue;
                int temp=ct(i,e,k/2)+ct(e,i,k/2);
                ans=max(ans,temp);
            }
        }
    }
    else{
        for(i=1;i<=n;++i){
            ans=max(ans,ct(i,-1,k/2));
        }
    }
    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    string s;
    IN s;
    vector<int> a(s.length(),0);
    int temp=1;
    int MOD=2019;
    rloop(i,s.length()-1,0)
    {
        if(i!=s.length()-1)
        {
            a[i]=a[i+1];
        }
        a[i]+=(((s[i]-'0')*temp)%MOD);
        a[i]%=MOD;
        temp*=10;
        temp%=MOD;
    }
    vector<int> b(s.length(),0);
    rloop(i,s.length()-1,0)
    {
        if(i!=s.length()-1)
        {
            b[i]=b[i+1];
        }
        b[i]+=(s[i]-'0');
        b[i]%=3;
    }
    map<pair<int,int>,int> m;
    int ans=0;
    m[{b[0],a[0]}]++;
    loop(i,0,s.length())
    {
        int t1=0;
        if(i!=s.length()-1)
        {
            t1=b[i+1];
        }
        int t2=0;
        if(i!=s.length()-1)
        {
            t2=a[i+1];
        }
        ans+=m[{t1,t2}];
        m[{t1,t2}]++;
    }
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 5152
import java.util.*;

public class Main {

    Map<Integer, List<Integer>> friendmap;
    Map<Integer, List<Integer>> blockmap;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] hairetu = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int num = sc.nextInt();
        System.out.println(hairetu[num-1]);
    }

}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

vector<int> z_algorithm(const string& s) {
  vector<int> prefix(s.size());
  for (int i = 1, j = 0; i < s.size(); i++) {
    if (i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k])
        ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int)s.size();
  return prefix;
}

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

  int ans=0;
  rep(i, N) {
    auto p = z_algorithm(S.substr(i, (N - i)));
    repp(j, i+1, N-1) {
      chmax(ans,min(j-i,p[j-i]));
    }
  }
  cout << ans << endl;
}

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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel";
    } else {
        cout << "consonant";
    }
}


Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int N;
  cin>>N;
  bool ok=false;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      if(4*i+j*7==N){
        ok=true;
      }

    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }




  

  



}



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

int MOD=1000000007;
int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}
int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
    int n,m;cin>>n>>m;
    vector<pair<int,int>>a(m);
    rep(i,m){
      cin>>a[i].second>>a[i].first;
    }
    sort(a.begin(),a.end());
    int last=a[0].first;
    int ans=1;
    rep(i,m){
      if(last<=a[i].second){
        ans++;
        last=a[i].first;
      }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e6+9, M = (1<<31), OO = 0x3f3f3f3f;
bool can[N];
int n;
LL memo[N];
LL solve(int idx)
{
  if(idx==n) return 1;

  LL &ret=memo[idx];
  if(~ret) return ret;
  ret = 0;
  if(!can[idx+1] && (idx+1)<=n) ret += (solve(idx+1))%MOD;
  if(!can[idx+2] && (idx+2)<=n) ret += (solve(idx+2))%MOD;

  return ret%MOD;
}
int main()
{
  memset(memo,-1,sizeof memo);
  int k;
  scanf("%d%d",&n,&k);
  while(k--)
  {
    int x;
    scanf("%d",&x);
    can[x]=true;
  }
  printf("%lld",solve(0));
  
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 11520
# -*- coding: utf-8 -*-

n = int(input())

a = list()

for i in range(n):
    j, k = input().split()
    k = int(k)
    a.append([i+1, j, k])
a.sort(key=lambda x:(x[1], -x[2]))


for i in a:
    print(i[0])


Measured memory_bytes: 3060