akhauriyash/Code-Regression huggingface dataset:
from collections import deque
Q = deque()
q = int(input())
for i in range(q):
    a = input()
    if   a[0] == '0': Q.append(a[2:])      # pushBack
    elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess
    else:             Q.pop()              # popBack


Measured memory_bytes: 20256
#include "bits/stdc++.h"
#define ll long long
#define mk make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
using namespace std;
const int MAXN=1e5+9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,a,b,c;
	cin>>n>>a>>b>>c;
	string s[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	bool flag=true;
	map<char,ll> cnt;
	cnt['A']=a;
	cnt['B']=b;
	cnt['C']=c;
	vector<char> v;
	for(int i=0;i<n;i++)
	{
		ll ff=cnt[s[i][0]];
		ll ss=cnt[s[i][1]];
		if(ff<ss)
		{
			ff++;
			ss--;
			v.pb(s[i][0]);
		}
		else if(ff==ss)
		{
			int flip=0;
			if(ff==1)
			{
				if(i+1<n)
				{
					if(s[i+1]!=s[i])
					{
						if(s[i][1]==s[i+1][0]||s[i][1]==s[i+1][1])
						{
							flip=1;
						}
					}
				}
				if(flip)
				{
					ff--;
					ss++;
					v.pb(s[i][1]);
				}
				else
				{
					ff++;
					ss--;
					v.pb(s[i][0]);
				}
			}
			else
			{
				ff++;
				ss--;
				v.pb(s[i][0]);
			}
		}
		else
		{
			ff--;
			ss++;
			v.pb(s[i][1]);
		}
		if(ff<0||ss<0)
		{
			flag=false;
			break;
		}
		cnt[s[i][0]]=ff;
		cnt[s[i][1]]=ss;
	}
	if(!flag)
	{
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<v.size();i++)
	{
		cout<<v[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d; 
  string s; cin >> s;
  int mn = min(c,d)-1;
  int mx = max(c,d)-1;
  //? ~~ A   ? ~ B   ? ~ C,D ~ C,D ~~ ?
  //0 ~~ a-1 a ~ b-1 b ~ mn  ~ mx  ~~ length()-1
  //連続した##のとき除外
  for(int i=a; i<mx; i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
  }
  
  if(c<d){
    cout << "Yes" << endl;
    return 0;
  }else{//(c>d)
    //連続した...ならok
    for(int i=b-2; i<=mn-1; i++){
      if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }  
  return 0;
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int64 k, a, b, ret;
  cin >> k >> b >> a;
  if (a <= b + 2) {
    ret = 1 + k;
  } else {
    if (k <= b - 1) {
      ret = 1 + k;
    } else {
      k -= b - 1;
      ret = b + k / 2 * (a - b);
      ret += k % 2;
    }
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;

class Dice{
public:
  int u,d,n,s,e,w;
  Dice(){
    u = 1;
    d = 6;
    s = 2;
    n = 5;
    e = 3;
    w = 4;
  }
  void cir(int & a , int & b , int & c , int & d){
    int t = a;
    a = b;
    b = c;
    c = d;
    d = t;
  }
  void rot(string com){
    if(com == "North"){
      cir(u , s , d , n);
    } else if(com == "South"){
      cir(u , n , d , s);
    } else if(com == "East"){
      cir(u , w , d , e);
    } else if(com == "West"){
      cir(u , e , d , w);
    } else if(com == "Right"){
      cir(s , e , n , w);
    } else if(com == "Left"){
      cir(s , w , n , e);
    }
  }
};

int main(void){
  int n;
  while(cin >> n , n){
    int sum = 1;
    Dice D;
    for(int i = 0; i < n; i++){
      string com;
      cin >> com;
      D.rot(com);
      sum += D.u;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream> 
#include <algorithm>
using namespace std; 
  
 
int main() 
{
    int x , y ;
    cin>>x>>y;
    
    if ( x >= 0 )
    {
        if ( y >=0 )
        {
            if ( y > x )
            {
                cout<<y-x<<endl;
            }
            else if ( y < x )
            {
               if ( y==0 )
               {
                   cout<<x-y+1<<endl;
               }
               else
               {
                   cout<<x-y+2<<endl;
               }
            }
        }
        else if ( y < 0 )
        {
            if ( abs(y) >= x )
            {
                cout<<abs(y)-x+1<<endl;
            }
            else if ( abs(y) <= x )
            {
                cout<<x-abs(y)+1<<endl;
            }
        }
    }
    if ( x < 0 )
    {
        if ( y >=0 )
        {
            if ( y >= abs(x) )
            {
                cout<<y-abs(x)+1<<endl;
            }
            else if ( y <= abs(x) )
            {
                if ( y == 0 )
                {
                    cout<<abs(x)-y<<endl;
                }
                else 
                {
                    cout<<abs(x)-y+1<<endl;
                }
            }
        }
        else if ( y < 0 )
        {
            if ( abs(y) > abs(x) )
            {
                cout<<abs(y)-abs(x)+2<<endl;
            }
            else if ( abs(y) < abs(x) )
            {
                cout<<abs(x)-abs(y)<<endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import collections

N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

DS=collections.Counter(D)
TS=collections.Counter(T)

for i,k in TS.items():

    if k > DS[i]:
        print('NO')
        exit()

print('YES')


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

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N;
	int K;
	scanf("%d %d",&N,&K);

	long long ans = 0;

	if(K==0){
		long long tmp = N;
		tmp*= tmp;
		printf("%lld\n", tmp);
		return 0;
	}

	for(int b=K+1;b<=N;b++){
		long long tmp = (N+(b-N%b))/b;
		tmp *= b-K;
		if(N%b<K) tmp -= b-K;
		else tmp -= b-1-(N%b);
		ans += tmp;
		//printf("%lld\n",tmp);
	}

	printf("%lld\n", ans);

	return 0;
}


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

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

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

using namespace std;

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

    while(true){
        c -= b;
        a -= d;

        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }else if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }


    return 0;
}

Measured memory_bytes: 3596
N,dum=gets.chomp.split(' ').map{|n| n.to_i}
A=[]
A=gets.chomp.split(' ').map{|n| n.to_i}
# puts A

i = 0

while(A.reject{|n| (n >> 1) << 1 == n}.empty?)
	i += 1
	A = A.map{|n| n >> 1}
end
puts i


Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

vector<vector<int>> split(const vector<int>& vP){
    vector<vector<int>> vvNew;
    
    uint i=0;
    while(i<vP.size()){
        while(i<vP.size() && vP[i]==0){ ++i; } // pass empty
        
        vector<int> vNew;
        while(i<vP.size() && vP[i]!=0 ){ vNew.push_back( vP[i] ); ++i; } // copy
        vvNew.push_back( move(vNew) );
    }
    return vvNew;
}
vector<vector<int>> split(const vector<vector<int>>& vvP){
    vector<vector<int>> vvNew;
    for(uint vi=0; vi<vvP.size(); ++vi){
        vector<vector<int>> vvTmp = split( vvP[vi] );
        
        vvNew.reserve(vvNew.size() + vvTmp.size());
        std::copy(vvTmp.begin(), vvTmp.end(), std::back_inserter(vvNew));
        /*
        for(uint i=0; i<vvTmp.size(); ++i){
            if( vvTmp[i].size()==0 ){ continue; } // rm empty
            vvNew.push_back( move(vvTmp[i]) );
        }
        //*/
    }
    return vvNew;
}

int main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    
    uint N; cin >> N;
    vector<vector<int>> vvP(1, vector<int>(N));
    for(uint i=0; i<N; ++i){ cin>>vvP[0][i]; }
    
    int64 cnt=0ll;
    while(vvP.size()!=0){
        for(uint vi=0; vi<vvP.size(); ++vi){
            vector<int>& vP = vvP[vi];
            if( vP.size()==0 ){ continue; } // rm empty
            
            int minVal = *std::min_element(vP.begin(), vP.end());
            cnt += minVal;
            
            for(uint i=0; i<vP.size(); ++i){ vP[i] -= minVal; }
        }
        
        vvP = split( vvP );
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
 
public class Coder
{

    public static int[] ReadArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt32(m));
    }

    public static int ReadInt()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    public static string ReadStr()
    {
        return Console.ReadLine();
    }

    public static long ReadLong()
    {
        return Convert.ToInt64(Console.ReadLine());
    }

    public static long[] ReadLongArray()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '), m => Convert.ToInt64(m));

    }

    public static void Main()
    {

        var a = ReadInt();
        int[] A = ReadArray();

        var dict = new SortedDictionary<double,int>();

        foreach(var i in A)
        {
            if (!dict.ContainsKey(i))
                dict.Add(i, 0);

            dict[i]++;
        }
    

        while(true)
        {
            var item1 = dict.First().Key;

            dict[item1]--;

            if (dict[item1] == 0)
                dict.Remove(item1);

            var item2 = dict.First().Key;

            dict[item2]--;

            if (dict[item2] == 0)
                dict.Remove(item2);

            double avg = (double)(item1 + item2) / 2;

            if (!dict.ContainsKey(avg))
                dict.Add(avg, 0);

            dict[avg]++;

            if (dict.Count == 1 && dict.First().Value == 1) break;

        }

        Console.WriteLine(dict.First().Key);


    }

}


Measured memory_bytes: 13652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s1 = in.next();
            String s2 = in.next();

            String cc = "abcdefghijklmnopqrstuvwxyz";

            for (int i = 0; i < s1.length(); i++) {
                if (cc.charAt(s1.charAt(i) - 'a') != s2.charAt(i)) {
                    char temp = cc.charAt(s1.charAt(i) - 'a');
                    cc = cc.replace(s2.charAt(i), 'T');
                    cc = cc.replace(cc.charAt(s1.charAt(i) - 'a'), s2.charAt(i));
                    cc = cc.replace('T', temp);
                }
            }
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s1.length(); i++) {
                sb.append(cc.charAt(s1.charAt(i) - 'a'));
            }

            out.println(sb.toString().equals(s2) ? "Yes" : "No");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 54088
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int long long

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 , inf = 3e18 + 20 ;
int n , a[N] , b[N] , ans ;
map <int , int> cnt ;

int const MAX = 3000 ;
bool np[MAX] ;
vector <int> vec ;

void pre () {
	np[0] = np[1] = 1 ;

	for (int i = 2 ; i < MAX ; i ++) {
		if (np[i]) continue ;
		vec.push_back(i) ;
		for (int j = 2 * i ; j < MAX ; j += i) np[j] = 1 ;
	}
}

inline int get (int x) {
	for (int d : vec) {
		while (x % (d * d * d) == 0) x /= d * d * d ;
	}
	return x ;
}

inline int f (int x) {
	int y = 1 ;
	for (int d : vec) {
		if (x % d) continue ;

		if (x % (d * d) == 0) y = min((ld)inf , (ld)y * d) , x /= d * d ;
		else y = min((ld)inf , (ld)y * d * d) , x /= d ;
	}

	int ss = sqrt(x) ;
	if (ss * ss == x) y = min((ld)inf , (ld)y * ss) ;
	else y = min((ld)inf , (ld)y * x * x) ;

	return y ;

}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	pre() ;

	cin >> n ;
	for (int i = 0 ; i < n ; i ++) cin >> a[i] , a[i] = get(a[i]) , b[i] = f(a[i]) , cnt[a[i]] ++ ;

	for (int i = 0 ; i < n ; i ++) {
		if (a[i] == 1 && cnt[1]) ans ++ ;
		else ans += max(cnt[a[i]] , cnt[b[i]]) ;
		cnt[a[i]] = cnt[b[i]] = 0 ;
	}

	cout << ans << '\n' ;
}


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




int main(){
    int N, T, A, B;
    int t_sum, ans;
    cin >> N >> T;

    vector<pair<int, int>> dish(N);
    vector<vector<int>> dp(N+1, vector<int>(T));

    t_sum = 0;
    ans = 0;
    for(int i=0; i<N; i++){
        cin >> A >> B;
        t_sum += A;
        ans += B;
        dish[i].first = A;
        dish[i].second = B;
    }
    // 全部食べられる
    if(t_sum <= T){
        cout << ans << endl;
        return 0;
    }

    sort(dish.begin(), dish.end());


    for(int i = 0; i < T; i++){
        dp[0][i] = 0;
    }
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= T-1; j++){
            if(j >= dish[i].first){
                dp[i+1][j] = max(dp[i][j],dp[i][j-dish[i].first] + dish[i].second);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, dp[i][T-1] + dish[i].second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

int keta(int x){
  for(int i=1;i<11;i++){
    if(x==0||x==1){
      return 1;
    }

    if(x!=0&&x!=1){
    if(x%int(pow(10,i))==x){
return i;
      break;
    }
  }
}

}

int main(){
  ll N;
  cin>>N;
  ll x=1;
  ll ans=1;
  while(x<=(N/x)){
    if(N%x==0){
ans=x;
    }
    x++;
  }
  cout<<keta((N/ans))<<endl;
}

    

Measured memory_bytes: 512
// 解けなかった雪辱をフローで果たす

#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

struct edge{
    int v,c,r;
    // u->v cap() u<-v
};

int N;
using pii = pair<int,int>;
vector< pii > red;
vector< pii > blue;
vector< vector<edge> > e; // e[u] : e.first = u->v ; e.second = cap(u);
vector< bool > used;


void addedge(int a, int b, int c){
    e[a].push_back( edge{b,c,(int)e[b].size()} );
    e[b].push_back( edge{a,0,(int)e[a].size()-1} );
}

void scan(){

    Scd(N);
    e.assign( N*2+2, vector<edge>(0) );
    int a,b;
    Rep(i,N){
        Scd2(a,b);
        red.push_back(pii(a,b));
    }
    Rep(i,N){
        Scd2(a,b);
        blue.push_back(pii(a,b));
    }

}

void build(){

    Rep(i,N){
        addedge( N*2,i,1 );
        addedge( N+i,N*2+1,1 );
    }
    Rep(i,N){
        Rep(j,N){
            if( red[i].first < blue[j].first && red[i].second < blue[j].second ){
                addedge( i,N+j,1 );
            }
        }
    }

}

// v:now , t:sink , c:capacity
int dfs( int v, int t, int c){
    if( v==t ) return c;
    used[v] = true;
    // Ford-Fulkerson algorithm
    for( int ei = 0; ei < e[v].size(); ei++ ){
        edge &ez = e[v][ei];
        if( !used[ez.v] && ez.c > 0){
            int d = dfs( ez.v,t,min(c,ez.c));
            if( d>0 ){
                ez.c -= d;
                e[ez.v][ez.r].c += d;
                return d;
            }
        }
    }
    return 0;
}

int ans( int s , int t ){
    int flow = 0;
    while(1){
        used.assign( N*2+2, false );
        int f = dfs(s,t,INF);
        if( f ) flow+=f;
        else break;
    }
    return flow;
}

int main() {

    scan();
    build();
    printf ("%d\n", ans(N*2,N*2+1) );

    return 0;
}



Measured memory_bytes: 384
#include <cstdio>
using namespace std;
 
#define lo(n,m) for(int i=n; i<m; i++)
 
int main(){
  int a[3],j=0,k=0;
 
  lo(0,3){
    if (scanf("%d",&a[i]) !=1 ){
      printf("None.\n");
    }
  }
 
  lo(0,3){
    if ( a[i] == 5){
      j++;
    }else if(a[i] == 7){
      k++;
    }
  }
 
  if ( j == 2 && k == 1){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  
 
  
  
 
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a,b,Maxx,Minn=100000000000000;
int main()
{
	cin>>a;
	while(cin>>b)
	{
		Maxx=max(Maxx,b);
		Minn=min(Minn,b);
	}
	cout<<Maxx-Minn<<endl;
}

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

using namespace std;

int main()
{
    char ch[2000006];
    scanf("%s",ch);
    int i;
    long long n=0;
    for(i=0;i<strlen(ch);i++)
    {
        n=n+ch[i]-'0';

    }
    if(n%9==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

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

	int n;
	cin>>n;
	ll x;
	cin>>x;
	ll min_x = 1e9;
	ll su = 0;
	
	for(int i=0; i<n; ++i){
		ll m; cin>>m;
		su += m;
		min_x = min(min_x, m);
	}
	x -= su;
	ll burg = n;
	burg += (x/min_x);
	cout<<burg<<endl;

	return 0;
}


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

int W,H;
int board[20][20];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

bool search(int i, int y, int x) {
  if(i==0) return false;
  // printf("i=%d, (%d,%d)\n", i, y, x);
  // for(int y = 0; y < H; y++) {
  //   for(int x = 0; x < W; x++) printf("%d ",board[y][x]);
  //   printf("\n");
  // }

  for(int dir = 0; dir < 4; dir++) {
    // printf("i=%d, dir=%d\n",i,dir);
    int yy=y+dy[dir],xx=x+dx[dir];
    if(0<=yy && yy < H && 0<=xx && xx < W && board[yy][xx]!=1) {
      while(true) {
        // printf("board[%d][%d]==%d\n", yy,xx,board[yy][xx]);
        if(board[yy][xx] == 3) return true;
        yy += dy[dir];
        xx += dx[dir];
        if(0<=yy && yy<H && 0<=xx && xx<W) {
          if(board[yy][xx] == 1) {
            board[yy][xx]=0;
            if(search(i-1,yy-dy[dir],xx-dx[dir])) return true;
            board[yy][xx]=1;
            break;
          }
        } else {
          break;
        }
      }
    }
  }
  return false;
}

int main() {
  for(int tci = 0; ; tci++) {
    scanf("%d%d", &W, &H);
    if(W==0) break;
    int sy=0,sx=0;
    for(int y = 0; y < H; y++) {
      for(int x = 0; x < W; x++) {
        scanf("%d", &board[y][x]);
        if(board[y][x]==2) sy=y,sx=x;
      }
    }
    int i;
    for(i = 1; i <= 10; i++) {
      if(search(i,sy,sx)) break;
    }
    if(i==11) i=-1;
    printf("%d\n", i);
  }
  return 0;
}

Measured memory_bytes: 1028
package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    var r string
    r, _ = readOneLine(scanner)
    ios := strAry2intAry(split(r))
    var a = ios[0]
    var b = ios[1]
    fmt.Print(calc(a, b))
}

func calc(a int , b int) int {
    var i = 1
    var min int
    var max int
    var res int
    if a < b {
        min = a
        max = b
    } else {
        min = b
        max = a
    }
    for {
        if min * i % max == 0 {
            res = min * i
            break;
        }
        i++
    }
    return res
}

func readOneLine(scanner *bufio.Scanner) (string, bool) {
    var s string
    var eof = false
    if scanner.Scan() {
        s = scanner.Text()
    } else {
        eof = true
    }
    return s, eof
}

func s2i(s string) int {
    var intVal,_ = strconv.Atoi(s)
    return intVal
}

func i2s(i int) string {
    return string(i)
}

func s2f(s string) float64 {
    var floatVal,_ = strconv.ParseFloat(s, 64)
    return floatVal
}

func sum(i []int) int {
    sum := 0
    for _,val := range i {
        sum += val
    }
    return sum
}

func split(s string) []string {
    return strings.Fields(s)
}

func strAry2intAry(strs []string) []int {
    var ret = make([]int, 0, len(strs))
    for _ , str := range strs {
        var intVal, _ = strconv.Atoi(string(str));
        ret = append(ret, intVal)
    }
    return ret
}

func intAry2strAry(nums []int) []string {
    var ret = make([]string, 0, len(nums))
    for _ , num := range nums {
        var strVal = strconv.Itoa(num);
        ret = append(ret, strVal)
    }
    return ret
}

func ary2str(strs []string) string {
    return strings.Join(strs, " ")
}


Measured memory_bytes: 640
from collections import deque
d = deque(input())

reverse = -1
n = int(input())
for i in range(n):
    query = input().split()
    if len(query) == 1:
        reverse *= (-1)
    else:
        f = int(query[1])
        c = query[2]
        if reverse == -1:
            if f == 1:
                d.appendleft(c)
            else:
                d.append(c)
        else:
            if f == 1:
                d.append(c)
            else:
                d.appendleft(c)

if reverse == 1:
    d.reverse()

print("".join(d))


Measured memory_bytes: 8436
import java.util.*;

public class Main{
  public static void main(String[] args){

  Scanner sc = new Scanner(System.in);
  int[] data = {0,0,0};
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
     data[0] = a;
     data[1] = b;
     data[2] = c;
     for(int i = 0; i <data.length-1; i++){
       for(int j = i+1; j <data.length; j++){
         if(data[i] > data[j]){
           int k = data[i];
           data[i] = data[j];
           data[j] = k;
         }
       }
     }
     for(int i = 0; i < data.length-1; i++){
       System.out.print(data[i] + " ");
     }
     System.out.print(data[2]);
     System.out.print("\n");
     }
   }


Measured memory_bytes: 26292
L=lambda:list(map(int,input().split()))
n,m=L();h=L()
e,c=[[]for _ in range(n)],0
for i in range(m):
  a,b=L();e[a-1]+=b-1,;e[b-1]+=a-1,
for i in range(n):
  if all(h[i]>h[v]for v in e[i]):c+=1
print(c)

Measured memory_bytes: 93220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Optional;
import java.util.OptionalDouble;
import java.util.stream.DoubleStream;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String line;
      String[] lines;
      double[] s;
      while( !(line = br.readLine()).equals("0") ){

        int n = Integer.parseInt(line);
        lines = br.readLine().split(" ");

        s =
          Stream.of(lines)
            .parallel()
            .mapToDouble(Double::parseDouble)
            .toArray();
        
        double dm =
          Arrays.stream(s)
            .parallel()
            .average()
          .getAsDouble();

        double result =
        Arrays.stream(s)
          .parallel()
          .map(d -> Math.pow((d-dm),2) / n)
          .sum();

        System.out.printf("%.8f\n" , Math.sqrt(result));
      }
    }
  }
}


Measured memory_bytes: 33572
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define pb push_back
# define mp make_pair
//# define int ll
using namespace std;

ll n,a[maxn],x,ans1,ans2;

int32_t main(){_
    //freopen("input","r",stdin);
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }
    for(int i = 1;i <= n;i++)
    {
        x += a[i];
        if(i % 2 == 1)
        {
            if(x == 0) {ans1++;x = 1;}
            else if(x < 0) {ans1 += abs(x) + 1;x = 1;}
        }
        else {
            if(x == 0) {ans1++;x = -1;}
            if(x > 0) {ans1 += x + 1;x = -1;}
        }
    }
    x = 0;
    for(int i = 1;i <= n;i++)
    {
        x += a[i];
        if(i % 2 == 0)
        {
            if(x == 0) {ans2++;x = 1;}
            else if(x < 0) {ans2 += abs(x) + 1;x = 1;}
        }
        else {
            if(x == 0) {ans2++;x = -1;}
            if(x > 0) {ans2 += x + 1;x = -1;}
        }
    }
    rc(min(ans1,ans2));
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

#define MAX 10000

int main(void) {
  char str[MAX];
  int length;

  scanf("%s", str);

  length = strlen(str);

  for(int i=length-1; i >= 0; --i) {
    printf("%c", str[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;
  int ans=0;
  for(int i=1; i<=n/2; i++){
    ll a=n-i;
    if(a!=i) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

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

const int INF = 1001001001;

int main(){
  int a, b; cin >> a >> b;
  
  int res = -INF;
  chmax(res, a+b);
  chmax(res, a-b);
  chmax(res, a*b);

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	while( true ){
		c -= b;
		if( c <= 0 ){
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if( a <= 0 ){
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    bool edge[n][n];
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            edge[i][j] = false;
        }
    }
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        edge[a-1][b-1] = true;
        edge[b-1][a-1] = true;
    }
    int perm[n];
    for(int i=0; i<n; i++){
        perm[i] = i;
    }
    int cnt = 0;
    do{
        if(perm[0]!=0) break;
        bool flag = true;
        for(int i=0; i<n-1; i++){
            if(!edge[perm[i]][perm[i+1]]){
                flag = false;
                break;
            }
        }
        if(flag) cnt++;
    }while(next_permutation(perm, perm+n));
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10000
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Node{int p,l,r;};
Node T[MAX];
int D[MAX],H[MAX];
void preorder(int u){
    if(u==-1)return;
    printf(" %d",u);
    preorder(T[u].l);
    preorder(T[u].r);
}
void inorder(int u){
    if(u==-1)return;
    inorder(T[u].l);
    printf(" %d",u);
    inorder(T[u].r);
}
void postrder(int u){
    if(u==-1)return;
    postrder(T[u].l);
    postrder(T[u].r);
    printf(" %d",u);
}
int main(){
    int root,n,a,b,c;
    cin>>n;
    r(i,n)T[i].p=-1;
    r(i,n){
      cin>>a>>b>>c;
      T[a].l=b;
      T[a].r=c;
      if(b!=-1)T[b].p=a;
      if(c!=-1)T[c].p=a;
    }
    r(i,n)if(T[i].p==-1)root=i;
    printf("Preorder\n");
    preorder(root);
    cout<<endl;
    printf("Inorder\n");
    inorder(root);
    cout<<endl;
    printf("Postorder\n");
    postrder(root);
    cout<<endl;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, a) for (int i=0; i<(a); i++) 
#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define mp make_pair
#define pb push_back
#define pi 3.141592653589793
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define bitcount(a) __builtin_popcount(a) // count set bits
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7;
const int inf = 1e9+9;
const long long INF = 1e18+3;

//to debug 
#define dbg(x) cout << "Line " << __LINE__ << " | " #x ": " << (x) << endl

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M
ll add(ll a,ll b,ll M)  { return ( mod(a,M ) + mod(b,M ))%M;     }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M;   }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

                /* -------------------------------Main Code------------------------------- */

const int N=1e5+5;

int main() 
{
    FAST;
    int k,x;cin>>k>>x;
	int l = (x-k+1);
	int r = (x+k-1);
	for(int i=l;i<=r;i++) cout<<i<<" ";
	cout<<endl;
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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




  while(true){
    cin >> s;
    if(s == "#") break;
    int place[s.size()+1][3][3][2];
    rep(i,3)rep(j,3)rep(k,2) place[0][i][j][k] = 0;
    FOR(x,1,s.size()+1)rep(i,3)rep(j,3)rep(k,2) place[x][i][j][k] = 1e9;
    rep(i,s.size()){
      int next = (s[i] - '0' + 2) % 3;
      rep(l,3) rep(rr,3) rep(prev,2){
        if(prev == 0){// 前回左足で動かした
          if(rr >= next) place[i+1][next][rr][0] = min(place[i+1][next][rr][0],place[i][l][rr][prev] + 1);// left move
          if(l <= next) place[i+1][l][next][1] = min(place[i+1][l][next][1],place[i][l][rr][prev]); // right move
        }else{// 前回右足で動かした
          if(rr >= next) place[i+1][next][rr][0] = min(place[i+1][next][rr][0],place[i][l][rr][prev]);// left move
          if(l <= next) place[i+1][l][next][1] = min(place[i+1][l][next][1],place[i][l][rr][prev]+1); // right move
        }
      }
    }
    int ans = 1e9;
    rep(i,3) rep(j,3) rep(k,2){
      ans = min(place[s.size()][i][j][k],ans);
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 10256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
table = [[0]*9 for _ in range(9)]
for i in range(N):
    s = str(i+1)
    a,b = int(s[0]),int(s[-1])
    if b == 0:
        continue
    table[a-1][b-1] += 1
ans = 0
for i in range(9):
    for j in range(9):
        ans += table[i][j]*table[j][i]
print(ans)

Measured memory_bytes: 73104
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
struct edge{ll to,cost;};
int main(){
    ll n; 
    cin >> n;
    ll ans = 0;
    if(n%2){
        cout << 0 << endl;
        return 0;
    }
    n/=2;
    while(n!=0){
        ans += n/5;
        n/=5;
    }
    cout << ans << endl;

}

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

using namespace std;

pair<int, int> point[4][100005];
int cr[4], c, r, n, x, y, z, t,mmmm;

bool check(int x,int y)
{
    if(x == 0 || y == 0 || x == r || y == c)
        return true;
    return false;
}

void func(int x,int y,int indx)
{
    if(y == 0)
        point[0][cr[0]++] = make_pair(x, indx);
    else if(x == r)
        point[1][cr[1]++] = make_pair(y, indx);
    else if(y == c)
        point[2][cr[2]++] = make_pair(x, indx);
    else if(x == 0)
        point[3][cr[3]++] = make_pair(y, indx);
}

bool cmp1(pair<int,int> a, pair<int,int> b)
{
    return a.first < b.first;
}

bool cmp2(pair<int,int> a, pair<int,int> b)
{
    return a.first > b.first;
}

int main() {
	cin >> r >> c >> n;
	for(int i = 1; i <= n; i++) {
		cin >> x >> y >> z >> t;
		if(check(x, y) && check(z, t)) {
			func(x, y, i);
			func(z, t, i);
		}
	}
	sort(point[0], point[0] + cr[0], cmp1);

	sort(point[1], point[1] + cr[1], cmp1);

	sort(point[2], point[2] + cr[2], cmp2);

	sort(point[3], point[3] + cr[3], cmp2);

	stack<int> S;
	for(int i = 0; i < 4; i++) {
		for(int j = 0; j < cr[i]; j++) {
			if(S.empty()) {
				S.push(point[i][j].second);
			}
			else {
				if(S.top() == point[i][j].second) S.pop();
				else S.push(point[i][j].second);
			}
		}
	}
	if(!S.empty()) cout << "NO";
	else cout << "YES";
return 0;
}

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


int main(){
  int n,m,i,j;
  cin >> n >> m;
  vector<int> k(n);
  map<int,int> mp;
  for(i=0;i<n;++i){
    cin >> k[i];
    for(j=0;j<k[i];++j){
      int a;
      cin >> a;
      mp[a]++;
    }
  }
  int ans=0;
  for(auto p : mp){
    if(p.second==n){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main() {
    int D,G;
    cin>>D>>G;
    vector<int> p(D),c(D);
    int result;
    for(int i=0;i<D;i++){
        cin>>p.at(i)>>c.at(i);
        result+=p.at(i);
    }
    for(int tmp=0;tmp<(1<<D);tmp++){
        bitset<10> complete(tmp);
        int score=0;
        int pnum=0;
        for(int i=0;i<D;i++){
            if(complete.test(i)){
                score+=(i+1)*100*p.at(i)+c.at(i);
                pnum+=p.at(i);
            }
        }
        if(score<G){
            int ncp=-1;
            for(int i=0;i<D;i++){
                if(!complete.test(i)){
                    ncp=i;
                }
            }
            if(ncp==-1){
                break;
            }
            for(int i=1;i<p.at(ncp);i++){
                score+=(ncp+1)*100;
                pnum++;
                if(score>=G){
                    result=min(pnum,result);
                    break;
                }
            }
        }
        else{
            result=min(pnum,result);
        }
    }
    cout<<result<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
  int max = 0, longest=0,i;
  map<string,int> word, cnt;
  string s, max_s, longest_s;
  while(cin>>s){
    word[s]++;
    if(word[s]>max){
      max = word[s];
      max_s = s;
    }
    i=0;
    while(s[i] != '\0' && s[i] != '\n'){
      i++;
    }
    cnt[s] = i;
    if(cnt[s]>longest){
      longest=cnt[s];
      longest_s=s;
    }
  }  
  cout<<max_s<<' '<<longest_s<<endl;
  return 0;
}
  

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#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()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	char c;
	cin >>c;
	cout << char(c + 1) << endl;
	return 0;
}

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

using namespace std;

const int MAXN = 1e3 + 5;
const double INF = 1 / .0;

vector<vector<double>> adjMat(MAXN, vector<double> (MAXN, -1));
vector<double> dp(MAXN, INF);

void dijkstra(int n)
{
  vector<int> sptSet(MAXN, 0);
  dp[0] = 0.;
  for(int i = 0; i <= n; i++)
  {
    int u = 0;
    double mm = INF;
    for(int j = 0; j <= n; j++)
    {
      if(sptSet[j] == 0 && dp[j] < mm)
      {
        mm = dp[j];
        u = j;
      }
    }
    sptSet[u] = 1;
    for(int j = 0; j <= n; j++)
    {
      if(sptSet[j] == 0 && adjMat[u][j] != -1 && dp[u] != INF && dp[u] + adjMat[u][j] < dp[j])
      {
        dp[j] = dp[u] + adjMat[u][j];
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  double xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  int n;
  cin >> n;
  vector<pair<double, pair<double, double>>> circ(n + 2);
  circ[0] = {0.0, {xs, ys}};
  circ[n + 1] = {0.0, {xt, yt}};
  for(int i = 1; i <= n; i++)
  {
    cin >> circ[i].second.first >> circ[i].second.second >> circ[i].first;
  }
  for(int i = 0; i <= n + 1; i++)
  {
    adjMat[i][i] = 0.0;
    for(int j = i + 1; j <= n + 1; j++)
    {
      double dis = max(0.0, sqrt((circ[i].second.first - circ[j].second.first) * (circ[i].second.first - circ[j].second.first) + (circ[i].second.second - circ[j].second.second) * (circ[i].second.second - circ[j].second.second)) - (circ[i].first + circ[j].first));
      adjMat[i][j] = dis;
      adjMat[j][i] = dis;
    }
  }
  dijkstra(n + 1);
  cout << setprecision(10) << fixed << dp[n + 1] << endl;
  return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cstring>
#include <queue>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define rev(v) (v).rbegin(), (v).rend()
#define MP make_pair
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> P;
typedef long long ll;

int main(){
	//freopen("test.txt", "r", stdin);

	int	w, d;
	while(cin >> w >> d, w|d){
		vi h(w);
		rep(i, w) cin >> h[i];
		vi h2(d);
		rep(i, d) cin >> h2[i];

		sort(rev(h));
		sort(rev(h2));

		int p = 0;
		int p2 = 0;
		int sum = 0;
		while(p < w || p2 < d){
			if(p >= w) sum += h2[p2++];
			else if(p2 >= d) sum += h[p++];
			else{
				if(h[p] < h2[p2]) sum+=h2[p2++];
				else if(h[p] > h2[p2]) sum+=h[p++];
				else if(h[p] == h2[p2]) sum+=h[p], p++, p2++;
			}
		}
		//cout << "sum:";
		cout << sum << endl;
	}

	return 0;
}

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

namespace AtCoder
{
    class ABC
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] t = new long[N + 1];
            long[] x = new long[N + 1];
            long[] y = new long[N + 1];

            t[0] = 0;
            x[0] = 0;
            y[0] = 0;

            for (long i = 1; i <= N; i++)
            {
                long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();
                t[i] = n[0];
                x[i] = n[1];
                y[i] = n[2];
            }

            bool flag = true;
            for(long i = 1; i <= N; i++)
            {
                if ((t[i] - t[i - 1] - Math.Abs(x[i] - x[i - 1]) - Math.Abs(y[i] - y[i - 1])) % 2 != 0) flag = false;
                if (Math.Abs(x[i] - x[i - 1]) + Math.Abs(y[i] - y[i - 1]) > t[i] - t[i - 1]) flag = false;
            }

            Console.WriteLine(flag ? "Yes" : "No");
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 17504
n = int(input())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

add = 0

for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        add += c[a[i] - 1]

total = sum(b) + add

print(total)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc076/tasks/abc076_c

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

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string min = "~";
    REP(i, S.length() - T.length() + 1) {
        string sub = S.substr(i, T.length());
        bool can = true;
        REP(j, T.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }

        if (can) {
            string P = S;
            REP(j, T.length()) {
                P[i+j] = T[j];
            }
            REP(j, P.length()) {
                if (P[j] == '?') P[j] = 'a';
            }
            min = std::min(min, P);
        }
    }

    if (min == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << min << "\n";
    }

    return 0;
}


Measured memory_bytes: 256