akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
    int n, l, re = 0;
    cin >> n >> l;
    if(l >= 0){
        for(int i = 1; i < n; ++i) re += i + l;
        cout << re;
        return 0;
    }else{
        if(n - 1 + l <= 0){
            for(int i = 0; i < n - 1; ++i) re += i + l;
            cout << re;
            return 0;
        }else{
            for(int i = 0; i < n; ++i) re += i + l;
            cout << re;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i,n;
  double debt,debt2,r;

  if (scanf("%d",&n)<1) exit(1);
  debt = 1.0e5;
  if (n==0) printf("%.0f\n",debt);
  else {
    for(i=0;i<n;i++) {
      debt = debt*1.05;
      debt2 = (double)(int)(debt/1.0e3)*1.0e3;
      r = debt-debt2;
      if (r!=0) debt = debt2+1.0e3;
    }
    printf("%.0f\n",debt);
  }
  return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;

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

int k, a, b;

int main() {
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int main(){
    int l; cin>>l;
    printf("%.6f\n", (double)l*l*l/27);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int A,B,M,a[150000],b[150000],m[150000],x[150000],y[150000],r,i,j,min,max;
	scanf("%d %d %d",&A,&B,&M);
	min=999999;
	for(i=0;i<A;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]<min)
		min=a[i];
	}
	max=9999999;
	for(i=0;i<B;i++)
	{
		scanf("%d",&b[i]);
		if(b[i]<max)
		max=b[i];
	}
	for(i=0;i<M;i++)
	{
		scanf("%d %d %d",&x[i],&y[i],&m[i]);
	}
	int mat=9999999;
	for(i=0;i<M;i++)
	{
		r=a[x[i]-1]+b[y[i]-1]-m[i];
		if(r<mat)
		mat=r;
	}
	if(max+min<mat)
	printf("%d",max+min);
	else
	printf("%d",mat);
return 0;
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;
int main(){
  
long long int n,d;
  cin>>n>>d;
  long long int ans=0;
  while(n--)
  {
   long long int a,b;
    cin>>a>>b;
    long long int k=a*a+b*b;
    if(k<=d*d)
    {
      ans++;
    }
    
  }
  
  cout<<ans<<endl;
  
  
  
  return 0;
}


Measured memory_bytes: 3628
//                        Bismillahir Rahmanir Rahim
//ALGO:
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=01;

int main() {
    int n, m;
    cin>>n>>m;
    cout<<((n*(n-1))/2+(m*(m-1))/2);
}



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

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

/* define const */
const long long INF = (1LL << 60);
/* end defineing */

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

    int tmp = 0;
    for (int i = 0; i < 2; i++)
    {
        if (a >= b)
        {
            tmp += a;
            a--;
        }
        else
        {
            tmp += b;
            b--;
        }
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll X;
    cin >> X;
    ll c = 100;
    for (int i = 1;; i++) {
        c *= 1.01;
        if (c >= X) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}



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

int main(){
  int a, b;
  cin >> a >> b;
  int X = (a + b) % 2;
  
  if(X == 0){
   cout << (a + b) / 2 << endl; 
  }
  else{
   cout << (a + b) / 2 + 1 << endl; 
  }
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = il()
    cnt = 0
    for n in range(N):
        if P[n] != n + 1:
            cnt += 1
        if P[P[n]-1] != n+1:
            print('NO')
            exit()
    print('NO' if cnt > 3 else 'YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10148
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
#include <string>
using namespace std;

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

    for (int i = 0; i < 10100;++i){

        int za = i * 8 / 100;
        int zb = i * 10 / 100;
        if( A == za and B == zb ){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        char[] ch = sc.next().toCharArray();
        ArrayList<Integer> ll = new ArrayList<Integer>();
        char prev = ch[0];
        int cnt = 1;
        for(int i=1;i<n-1;i++){
            if(prev==ch[i]){
                cnt++;
            }else{
                ll.add(cnt);
                cnt = 1;
                prev = ch[i];
            }
        }
        if(prev==ch[n-1]){
            cnt++;
            ll.add(cnt);
        }else{
            ll.add(cnt);
            ll.add(1);
        }
        long sum = 0;
        if((2*k+1)<ll.size()){
            for(int i=0;i<2*k+1;i++){
                sum += ll.get(i);
            }
            sum--;
            for(int i=2*k+1;i<ll.size();i++){
                sum += ll.get(i)-1;
            }
            System.out.println(sum);
        }else{
            System.out.println(n-1);
        }
    }
}

Measured memory_bytes: 25684
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m,x = mi()

d = []
for i in range(n):
    d.append(li())

mincost = 10**10
for i in range(2**n):
    cost = 0
    tsd = [0] * m
    for j in range(n):
        if (i >> j)&1 == 1:
            cost += d[j][0]
            for k in range(m):
                tsd[k] += d[j][k+1]
    
    # print(bin(i),cost)
    for j in range(m):
        if tsd[j] < x:
            break
    else:
        mincost = min(cost,mincost)

if mincost == 10**10:
    print(-1)
else:
    print(mincost)


Measured memory_bytes: 68656
#include<bits/stdc++.h>
#define rep(i,n) for(i=0; i<n; ++i)
#define xrep(i) for(; i; i&=-((i&-i)+1))
using namespace std;

int numofbits(long bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

void xnumofbits(int k, int& sum, vector<int> hw){
  int l;
  xrep(k){
    l = numofbits((k&-k)-1);
    sum += hw[l];
  }
}

void xnumofbits2(int k, int l, int& sub, string s, vector<string> ss){
  int p,q,r;
  xrep(k){
    r = l;
    xrep(r){
      p = numofbits((k&-k)-1);
      q = numofbits((r&-r)-1);
      s = ss[p];
      if(s[q]=='#') ++sub;
    }
  }
}

int binarysearch(int H, int W, int K,string s,vector<string> ss,vector<int> sh,vector<int> sw, int count){
  int hb=(int)pow(2,H),wb=(int)pow(2,W);
  int i,j,k,l,sum,sub,score=0;
  rep(i,hb){
    rep(j,wb){
      sum = 0; sub = 0;
      k = i;
      xnumofbits(k,sum,sh);
      k = j;
      xnumofbits(k,sum,sw);
      k = i;
      l = j;
      xnumofbits2(k,l,sub,s,ss);
     if((count-(sum-sub))==K) ++score;
     }
  }
  return score;
}

int main(void){
  int H,W,K; cin >> H >> W >> K;
  string s;
  vector<string> ss(H);
  int i,j,count=0;
  vector<int> sh(H,0),sw(W,0);
  rep(i,H){
    cin >> s; ss[i]=s;
    rep(j,W) if(s[j]=='#') {++sh[i]; ++sw[j]; ++count;}
  }
  cout << binarysearch(H,W,K,s,ss,sh,sw,count) << endl;
  
  return 0;
}


Measured memory_bytes: 4112
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define ld long double

using edge = pair<int, int>;

struct UnionFind{
    vector<int> data;
    /* constructor */
    UnionFind(int sz){ data.assign(sz,-1); }
    /* merge the set to which x belongs and the set to which y belongs */
    bool unite(int x,int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    /* find the root of k */
    int find(int k){
        if (data[k] < 0) return k;
        return data[k] = find(data[k]);
    }
    /* calculate the size of the set to which k belongs */
    int size(int k){ return -data[find(k)]; }
};

bool is_bridge(int id, int n, vector<edge>& e){
	UnionFind uf(n);
	for (int i = 0; i < e.size(); ++i){
		if (i != id){
			int p = e[i].first, q = e[i].second;
			uf.unite(p, q);
		}
	}
	int n1 = e[id].first, n2 = e[id].second;
	return uf.find(n1) != uf.find(n2);
}

int main(void){
	int N, M; cin >> N >> M;
	vector<edge> e(M);
	for (int i = 0; i < M; ++i){
		int a, b; cin >> a >> b;
		--a, --b;
		e[i] = {a, b};
	}
	int res = 0;
	for (int i = 0; i < M; ++i)
		res += is_bridge(i, N, e);
	cout << res << endl;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;
 
typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
 
ll powmod(ll x, ll y) 
{ 
    ll res = 1;  
    x = x % MOD;
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % MOD; 
        y = y>>1; // y = y/2 
        x = (x*x) % MOD;   
    } 
    return res; 
} 
string s;
ll rigt[2*ee5];
ll bc[2*ee5],a[2*ee5];
int main()
{
    #if !ONLINE_JUDGE
 //   freopen("in.txt","r",stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>s;
    ll n=s.size();

    for(ll i=n-1;i>=0;i--){
        if(i+1<n and s[i+1]=='A')
        rigt[i]=rigt[i+1];
        else if(s[i]=='A')
            rigt[i]=i;
    }

    for(ll i=n-2;i>=0;i--){
        if(s[i]=='B' and s[i+1]=='C')
            bc[i]=1+bc[i+2];
    }     
    for(ll i=0;i<n;i++){
        if(s[i]=='A')
            a[i]=(i?a[i-1]:0)+1;
    }

    ll ans=0;  
    for(ll i=0;i+2<n;i++){
        if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
            ans+=(a[i]*bc[i+1]);
            if(i+1+2*bc[i+1]<n and s[i+1+2*bc[i+1]]=='A')
                a[rigt[i+1+2*bc[i+1]]]+=a[i];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 5268
l = [300000,200000,100000]
a,b = map(int,input().split())
res = 0 
if a in range(1,4):
    res +=l[a-1]
if b in range(1,4):
    res +=l[b-1]
if a == b and a==1:
    res+=400000
print(res)

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

int main(void)
{
    int N, Y;
    std::cin >> N >> Y;
    for(int x = 0; x <= N; x++) {
        for(int y = 0; y <= N; y++) {
            int z = (N - (x + y));
            if(z >= 0){
                if(((x * 10000) + (y * 5000) + (z * 1000)) == Y) {
                    std::cout << x << " " << y << " " << z << std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout << -1 << " " << -1 << " " << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String data = sc.nextLine();
        
        String[] array = data.split(" ");
        int a = Integer.parseInt(array[0]);
        int b = Integer.parseInt(array[1]);
        int c = Integer.parseInt(array[2]);
        
        String result = "";
        
        if(a == b && b != c)
        {
            result = "Yes";
        }
        else if(b == c && c != a)
        {
            result = "Yes";
        }
        else if(c == a && a != b)
        {
            result = "Yes";
        }
        else
        {
            result = "No";
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
// code.begin();
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back 
#define what_is(x) cerr<<#x<<" is "<<x<<endl;
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define my_time ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define endl "\n"
#define MOD 1000000007
const long long int INF=1e18;
#define mod 1000000007
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    ordered_set; 
//find_by_order(x)
//order_of_key(x)  


int power(int x,unsigned int y)
{
    int res=1;
    
    while(y>0)
    {
        // if y is odd multiply with result
        if(y&1)
        res=res*x;
        
        y=y>>1; // y=y/2;
        x=x*x;
        
    }
    return res;
}

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

ll  max3(ll  a, ll  b, ll c)
{
    return max(c, max(a, b));
}
int min3(int a, int  b, int  c)
{
    return min(a, min(b, c));
}

int  powermod(int  x, int  y, int p )
{
    int res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int logg(int  a)
{
    int  x = 0;
    while (a > 1)
    {
        x++;
        a /= 2;
    }
    return x;
}


int modinv(int x)
{
    return powermod(x, mod - 2, mod);
}



int  main(){
	my_time;



int t;
t=1;
//cin>>t;int test=0;
while(t--)
{
	
	string str;
	cin>>str;
	int sum=0;
	for(int i=0;i<str.size();i++)
	{
		int x=str[i]-'9';
		sum=(sum+x)%9;
		
	}
	
	if(sum==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}
    return 0;
}


//code.end();





Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define pb push_back
#define in(x) int x; cin>>x;
#define ln(x) long long x; cin>>x;
#define memf(a) memset(a,false,sizeof(a))
#define F first
#define S second
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
vector<set<int>> v;
vector<int> vv;
 bool prime[1000001];
 int a[1000001];
void SieveOfEratosthenes(int n) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true.  
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) vv.pb(p);
} 

int main()
{
	fast
	SieveOfEratosthenes(1e6);
	int n;
	cin>>n;
	int o;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.insert(a[i]);
		if(i==0)
			o=a[i];
		else
			o=__gcd(o,a[i]);
	}
	v.resize(1e6+1);
	int f=1;
	for(auto i:vv)
	{
		for(int j=i;j<=1e6;j+=i)
			{
				v[j].insert(i);
			}
			
	}
	set<int> xx;
	int zz=0;
	for(int i=0;i<n;i++)
	{
		zz+=((int)v[a[i]].size());
		for(auto j:v[a[i]])
			xx.insert(j);
	}
	if((int)zz==xx.size())
		f=1;
	else
		f=0;
	if(f)
		cout<<"pairwise coprime";
	else
	{
		if(o==1)
			cout<<"setwise coprime";
		else
			cout<<"not coprime";

	}
	return 0;
}

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

using ll = long long;
using P = pair<int, int>;
using PP = pair<string, P>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  int p[N];
  for (int i = 0; i < N; i++) cin >> s[i] >> p[i];

  vector<PP> ans;
  for (int i = 0; i < N; i++) {
    ans.push_back(PP(s[i], P(-p[i], i + 1)));
  }

  sort(ans.begin(), ans.end());
  for (int i = 0; i < N; i++) {
    cout << ans[i].second.second << endl;
  }

  return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
{ [x, y] <- getInts
; if x == 0 && y == 0 then done
  else do
    { case compare x y of
        LT -> putInts [x,y]
        GT -> putInts [y,x]
        EQ -> putInts [x,y]
    ; main
    }
 }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 3968
program main
  implicit none

  character(len=100) :: s, t, s2
  integer :: i, n, l

  read(*,*) s, t

  n = len_trim(s)

  do i = 1, n
     s2 = s(i:n)//s(1:i-1)
     if(t == s2) then
        write(*,*) 'Yes'
        stop
     end if

  end do

  write(*,*) 'No'

end program main

  

  


Measured memory_bytes: 2800
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main() {
    int d, t, s ;
    cin >> d >> t >> s ;
    if(d % s == 0){
        d /= s ;
    }
    else {
        d = d/s + 1 ;
    }
    if(d <= t){
        cout << "Yes" << endl ;
    }
    else {
        cout << "No" << endl ;
    }
} 

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

using ll=long long;

int main() {
  int N; cin >>N;
  vector<int> A(N);
  rep(i,0,N) {
    cin >>A[i];
  }
  sort(A.begin(),A.end());
  string ans="YES";
  rep(i,1,N) {
    if (A[i]==A[i-1]) {
      ans="NO";
      break;
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y;cin>>x>>y;
  ll ans=x+y/2;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define ba 47
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    if(c == '-') f = -1;
    c = getchar();
    }
    while(c >= '0' && c <= '9') {
    res = res * 10 +c - '0';
    c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
void Solve() {
    read(N);read(K);
    if(K == 1) puts("0");
    else {
    out((N - (K - 1)) - 1);enter;
    }
}
int main(){
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}

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

typedef long long ll;
ll mod = 1000000007;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, k;
    cin >> n >> k;

    ll count=0;
    ll arr[n+1]={};

    ll x;
    ll p;

    for(int i=1; i<=k; i++){
        cin >> x;
        for(int j=1; j<=x; j++){
            cin >> p;
            arr[p]++;
        }
    }

    for(int i=1; i<=n; i++){
        if(arr[i]==0) count++;
    }

    cout<< count<<'\n';

    return 0;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x = n % 10;
        if(n < 1000){
            if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9){
                System.out.println("hon");
            }
            if(x == 0 || x == 1 || x == 6 || x == 8){
                System.out.println("pon");
            }
            if(x == 3){
                System.out.println("bon");
            }
        }
    }
}

Measured memory_bytes: 35784
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,m,i=0,j,s,a[200010],min=1000000,goukei=0;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
    }
    sort(a,a+n);
    a[n+1]=0;
    for(i=0;i<n;i++)
    {
        if(a[i]==a[i+1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    
    
    cout << "YES" << endl;
    return 0;

}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,x;
ll kai(ll n,ll k){
  ll ret=1;
  for(ll i=0;i<k;i++)ret*=n;
  return ret;
}
ll dfs(ll u,ll d,ll k){
  if(k==0)return 1;
  ll mid=(u+d)/2;
  //cout<<mid<<endl;
  ll ret=0;
  if(x<mid){
    if(x==d)ret=0;
    else if(x==mid-1)ret+=kai(2,k)-1;
    else ret+=dfs(mid-1,d+1,k-1);
  }
  if(x==mid)ret+=pow(2,k);
  if(x>mid){
    if(x==u)ret+=kai(2,k+1)-1;
    else ret+=kai(2,k)+dfs(u-1,mid+1,k-1);
  }
  return ret;
}
int main(){
  //for(ll i=0;i<52;i++)t*=2;
  //cout<<t;return 0;
  cin>>n>>x;
  ll ans=dfs(kai(2,n+2)-3,1,n);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

a = []
i = 0
while N > 0:
    a.append(N % K)
    N = N // K
    i += 1

ans = ''
while i > 0:
    ans += str(a[i - 1])
    i -= 1

ansl = len(ans)

print(ansl)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  
  if(c>a&&c<b){
   cout<<"Yes"<<endl; 
  }
  else if(c>b&&c<a){
   cout<<"Yes"<<endl; 
  }
  else{
   cout<<"No"<<endl; 
  }

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
int main() {
	int n;
	int p[22];
	cin >> n;

	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 2; i <= n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1])ans++;
		else if (p[i + 1] < p[i] && p[i] < p[i - 1])ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
int n,f;
ll a[1000010],b[1000010];
ll ans=0;
bool check(ll sum,ll k)
{
  f=1;
  for (int i=n;i>=1;i--)
  {
    if (a[f]*b[i]<=sum)
	{
		f++;
		continue;
	}
    if ((a[f]-sum/b[i])>k) 
		return false;
    k-=a[f]-sum/b[i];
    f++;
  }
  return true;
}
int main()
{
  	ll k;
  	scanf("%d%lld",&n,&k);
  	for (int i=1;i<=n;i++) 
 		scanf("%lld",&a[i]);
  	for (int i=1;i<=n;i++) 
  		scanf("%lld",&b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
 	ll l=0,r=0;
  	r=b[n]*a[n];
  	ans=r;
  	while (l<=r)
  	{	
      	ll mid=(l+r)/2;
      	if (check(mid,k)) 
	  	{
	  	ans=mid;
	 	 r=mid-1;
	  	}
      	else 
	  	l=mid+1;
  	}
  	printf("%lld\n",ans);
  	return 0;
}


Measured memory_bytes: 5888
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;

ll plmi(ll a){
    if(a<0) return -1;
    else if(a==0) return 0;
    else if(a>0) return 1;
}


signed main(){
    ll t1,t2,a1,a2,b1,b2;
    ll s1,s2,p1,p2,an;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    s1 = t1*a1 + t2*a2;
    s2 = t1*b1 + t2*b2;
    p1 = t1*(a1-b1);
    p2 = s1-s2;
    if(p2==0)  cout<<"infinity"<<endl;
    else{
        if(plmi(p1)*plmi(p2)>0) cout<<"0"<<endl;
        else{
            if(abs(p1)%abs(p2)==0){
                an = 2*(abs(p1)/abs(p2));
                cout<<an<<endl;
            }else{
                an = 2*(abs(p1)/abs(p2))+1;
                cout<<an<<endl;
            }
        }
    }
}


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

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

int main(){
    int n; cin >> n;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    vector<ll> l(n); rep(i,n-1) l[i+1] = gcd(l[i],a[i]); 
    vector<ll> r(n); for(int i= n-1; i>0; i--) r[i-1] = gcd(r[i], a[i]);

    ll ans = 1;
    rep(i,n){
        if(i == 0) ans = max(ans, r[0]);
        if(i == n-1) ans == max(ans, l[n-i]);
        ans = max(ans, gcd(l[i], r[i]));
    }

    cout << ans << endl;

    //rep(i,n) cout << l[i] << " " << r[i] << endl;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define long long long
using namespace std;
int n;
vector<int>tw,th,sx;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin>>n;
  if(n==3)
  {
    cout<<2<<" "<<5<<" "<<63<<endl;
    return 0;
  }
  cout<<2<<" "<<4<<" "<<3<<" "<<9<<" ";
  n-=4;
  for(int i=5;i<=30000;i++)if(i%2==0&&i%6!=0)tw.push_back(i);
  for(int i=10;i<=30000;i++)if(i%3==0&&i%6!=0)th.push_back(i);
  for(int i=5;i<=30000;i++)if(i%6==0)sx.push_back(i);

  reverse(tw.begin(),tw.end());
  reverse(th.begin(),th.end());
  reverse(sx.begin(),sx.end());

  if(n&1)
  {
    cout<<sx.back()<<" ";
    sx.pop_back();
    n--;
  }

  while(n)
  {
    if(tw.size())
    {
      cout<<tw.back()<<" ";
      tw.pop_back();
    }
    else if(th.size())
    {
      cout<<th.back()<<" ";
      th.pop_back();
    }
    else
    {
      cout<<sx.back()<<" ";
      sx.pop_back();
    }
    n--;
  }
  cout<<endl;
  return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, m;
map<string, int> h;

int main()
{
    cin >> n;
    while(n--)
    {
        string t;
        cin >> t;
        h[t]++;
    }
    cin >> m;
    while(m--)
    {
        string t;
        cin >> t;
        h[t]--;
    }

    int res = 0;
    for(auto it = h.begin(); it != h.end(); it++)
        res = max(res, it->second);

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
n = input()
h = int(n[0]) * 100
if int(n) - h == int(n[0] + n[0]):
    print(int(n))
elif int(n) - h < int(n[0] + n[0]):
    print(int(n[0]*3))
else:
    print(int(str(int(n[0])+1)*3))

Measured memory_bytes: 38256
#include <float.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

char s[7];
int main(void){
	nextstr(s);
	puts(s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
ll k, a[N], f[N], prod[N], b[N];

int check(ll x)
{
	ll cnt = 0; 
	for (int i = 1; i <= n; i++) {
		b[i] = x / f[i];
	}
	sort(b + 1, b + 1 + n);
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] - b[i] > 0)
			sum += a[i] - b[i];
	}
	if (sum > k)
		return 0;
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> f[i];
	}
	sort(a + 1, a + 1 + n);
	sort(f + 1, f + 1 + n, greater<ll>());
	ll max_prod = 0;
	for (int i = 1; i <= n; i++) {
		prod[i] = a[i] * f[i];
		max_prod = max(max_prod, prod[i]);
	}
	ll l = -1, r = max_prod + 1;
	while (l + 1 < r) {
		ll mid = (l + r) >> 1;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

ll n;
ll h[100005];
ll ans = 0;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    h[n] = 1ll << 60ll;
    h[n + 1] = h[n] + 1;

    ll p = 0;
    for (int i = 0; i <= n; i++) {
        if (h[i] >= h[i + 1]) {
            p++;
        }
        else {
            ans = max(p, ans);
            p = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int cnt=0;
  for(int i=1;i<n-1;i++){
    int sum=a[i-1]+a[i]+a[i+1];
    int big=max(a[i-1],max(a[i],a[i+1]));
    int small=min(a[i-1],min(a[i],a[i+1]));
    if(sum-big-small==a[i])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //Compute c1 = new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();

        int dd=d*2+1;
        while (true)
        {
            ++count;
            if (dd*count>=n) break;
        }


        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        //System.out.println(answer);
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int, int> P;
#define MAXN 100005
ll dp[MAXN][3] = {};
ll a[MAXN] = {};
ll b[MAXN] = {};
ll c[MAXN] = {};
ll n;

void make() {

	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];

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

int main(){
	cin >> n;
	rep(i,n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	make();
	ll ma = max(dp[n-1][0], dp[n-1][1]);
	ma = max(ma, dp[n-1][2]);
	cout << ma << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    if(n%10 == 3){
        cout << "bon\n";
    }
    else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8){
        cout << "pon\n";
    }
    else cout << "hon\n";
    return 0;
}


Measured memory_bytes: 3644
def solve(string):
    n, *a = map(int, string.split())
    ans = [0] * n
    for _a in a:
        ans[_a - 1] += 1
    return "\n".join(map(str, ans))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 34276
(defparameter s (read-line))
(defparameter n (length s))
(defparameter flag 0)
(dotimes (i (- n 1))
  (if (not (= (count (char s i) s :test #'equal) 2)) (setq flag 1)))

(if (= flag 1) (princ "No") (princ "Yes"))

Measured memory_bytes: 7656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sum=0;
    char a[5],b[5],c[5];
    string d;
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    strcpy(c,a);
        a[0]-='0';a[1]-='0';a[2]-='0';a[3]-='0';
        if(a[0]+a[1]+a[2]+a[3]==7) cout<<c[0]<<'+'<<c[1]<<'+'<<c[2]<<'+'<<c[3]<<"=7"<<endl;
        else if(a[0]+a[1]+a[2]-a[3]==7) cout<<c[0]<<'+'<<c[1]<<'+'<<c[2]<<'-'<<c[3]<<"=7"<<endl;
        else if(a[0]+a[1]-a[2]+a[3]==7) cout<<c[0]<<'+'<<c[1]<<'-'<<c[2]<<'+'<<c[3]<<"=7"<<endl;
        else if(a[0]+a[1]-a[2]-a[3]==7) cout<<c[0]<<'+'<<c[1]<<'-'<<c[2]<<'-'<<c[3]<<"=7"<<endl;
        else if(a[0]-a[1]+a[2]+a[3]==7) cout<<c[0]<<'-'<<c[1]<<'+'<<c[2]<<'+'<<c[3]<<"=7"<<endl;
        else if(a[0]-a[1]-a[2]+a[3]==7) cout<<c[0]<<'-'<<c[1]<<'-'<<c[2]<<'+'<<c[3]<<"=7"<<endl;
        else if(a[0]-a[1]+a[2]-a[3]==7) cout<<c[0]<<'-'<<c[1]<<'+'<<c[2]<<'-'<<c[3]<<"=7"<<endl;
        else if(a[0]-a[1]-a[2]-a[3]==7) cout<<c[0]<<'-'<<c[1]<<'-'<<c[2]<<'-'<<c[3]<<"=7"<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int a[6];
  int i;
  int cnt=0;
  int ans=0;
  int N=0;

  for(i=0;i<5;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<5;i++){
    cnt = cnt + (a[i]%10);
  }

  if(cnt==0){
    for(i=0;i<5;i++){
      ans=ans+a[i];
    }
  }

  else{
    a[5]=a[0];
    for(i=1;i<5;i++){
      if((a[5]%10==0)||(((a[5]%10)>(a[i]%10))&&((a[i]%10)!=0))){
	a[5]=a[i];
	N=i;
      }
    }

    for(i=0;i<N;i++){
      ans = ans + ((a[i]+9)/10)*10;
    }

    for(i=N+1;i<5;i++){
      ans = ans + ((a[i]+9)/10)*10;
    }

    ans = ans + a[5];

  }

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

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<queue>
#define MAX_N 110
#define INF (1<<30)
bool A[MAX_N][MAX_N];
int rooter_num;
using namespace std;
int bfs(int,int);
int main()
{
  int n,startNode,goalNode,TTL;
  int r,k,t;
  int a;
  memset(A,false,sizeof(A));
  cin>>rooter_num;
  /*------------input---------------*/
  for(int i=0;i<rooter_num;i++)
    {
      cin>>r>>k;
      for(int j=0;j<k;j++)
	{
	  cin>>t;
	  A[r][t]=true;
	}
    }
  cin>>n;
  /*-------------search--------------*/
  for(int i=0;i<n;i++)
    {
      cin>>startNode>>goalNode>>TTL;
      a=bfs(startNode,goalNode);
      //cout<<"TTL="<<TTL<<";"<<"a-1="<<a<<endl;
      /*
	 TTLの減少値 = (それまでに通ったルータの数) - 1
	 直前のNodeでTTLが1以上ならばパケットが通るので
	 goal地点でのTTLの減少値がTTLと同等,またはそれ以下ならば
	 パケットが通る事になる。
       */
      if(a<=TTL)cout<<a<<endl;
      else cout<<"NA"<<endl;
       
    }
  return 0;
}
int bfs(int startNode,int goalNode)
{
  queue<int>Q;
  int visited[rooter_num+1];
  /*
    visitedは既に通過しているかの判定と経由したルータの数を保持する
  */
  memset(visited,0,sizeof(visited));
  /*
    memsetによって全てを０で初期化する
  */

  int currentNode=startNode;
  Q.push(currentNode);
  visited[currentNode]=1;

  /*-------BFS--------*/  
  while(!Q.empty())
    {
      currentNode=Q.front();
      Q.pop();
      for(int nextNode=1;nextNode<=rooter_num;nextNode++)
	{

	  if(A[currentNode][nextNode]==0)continue;
	  /*
	    接続されていない場合を切り取った
	  */
	  if(nextNode==goalNode)return visited[currentNode]+1;
	  /*
	    goalNodeの接続を確認したので探索を打ち切る
	  */
	  if(visited[nextNode]<=0)
	    {
	      visited[nextNode]=visited[currentNode]+1;
	      Q.push(nextNode);
	    }
	  /*
	    まだ訪れていない(かつ接続出来るNodeを)キューに追加する
	   */
	}
    }
  return INF;
  /*
    接続出来ない場合無限大を返す
   */
}

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

long int min(long int a,long int b){
  if(a < b){
    return a;
  }else{
    return b;
  }
}

long int V_W[101][100001];  //重さ[N][V] <= W ならおっけいってやつ

int main(){
  int N,W;
  scanf("%d%d",&N,&W);
  long int w[N+1],v[N+1];
  for(int i = 1;i <= N;i++){
    scanf("%ld%ld",&w[i],&v[i]);
  }

  for(int j = 0; j <= 100001;j++){
    if(j == v[1]){
      V_W[1][j] = w[1];
    }else{
      V_W[1][j] = -1;
    }
  }
  for(int i = 0;i <= N;i++){
    V_W[i][0] = 0;
  }
  

  for(int i = 2;i <= N;i++){
    for(int j = 1;j <= 100001;j++){
      long int keep1 = W*2;
      long int keep2 = W*2;
      if(V_W[i-1][j] != -1)keep1 = V_W[i-1][j];
      if(j >= v[i] && V_W[i-1][j-v[i]] != -1)keep2 = V_W[i-1][j-v[i]]+w[i];
      V_W[i][j] = min(keep1,keep2);
    }
  }

  for(int j = 100001;j > 0;j--){
    if(V_W[N][j] <= W && V_W[N][j] > 0){
      printf("%d\n",j);
      return 0;
    }
  }
}


Measured memory_bytes: 78336
def insertionSort(A,N):
    for i in range(N):
        v = A[i]
        j = i -1
        while j >= 0 and A[j] > v:
            A[j+1]  = A[j]
            j -=1
        A[j+1] = v
        print(" ".join(map(str,A)))

N = int(input())
A = []
A = list(map(int,input().split()))
insertionSort(A,N)

Measured memory_bytes: 7696
import math

while 1 :
    n = int( input().strip() )
    if n == 0 :
        break

    s = input().strip().split()
    for i in range(0, len(s)) :
        s[i] = float(s[i])

    m = sum(s)/n

    sigma = sum( [ ( si - m ) ** 2 for si in s ] )

    a = math.sqrt( sigma/n )
    print("{0:.8f}".format(a))


Measured memory_bytes: 5708
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (n, m) = scan!(sc; i32, usize);
  let mut flag = (1 << m) - 1;
  for _ in 0..n {
    let k = scan!(sc; usize);
    let a = scan!(sc => k; i32);
    let mut mask = 0;
    for &like in a.iter() {
      mask |= 1 << (like - 1);
    }
    flag &= mask;
  }
  println!("{}", format!("{:b}", flag).chars().filter(|&c| c == '1').count());
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 200005
#define X first
#define Y second
#define MOD 998244353
#define inf 1e18
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll n,i,j,t;

int main()
{
    fastio;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++){
        ll a=s[i]-'A';
        ll b=(a+n)%26;
        s[i]='A'+b;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(!(h == 0 && w == 0)){
                for(int j=0;j<w;j++){
                    System.out.print("#");
                }
                System.out.println("");
                for(int i=0;i<h-2;i++){
                    System.out.print("#");
                    for(int j=0;j<w-2;j++){
                        System.out.print(".");
                    }
                    System.out.print("#");
                    System.out.println("");
                }
                for(int j=0;j<w;j++){
                    System.out.print("#");
                }
                System.out.println("");
                System.out.println("");
            }else{
                break;
            }
        }
    }
}


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

typedef long long ll;
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define rerepi(i, a, b) for(int i = int(a)-1; i >= b; --i)
#define rerep(i, n) rerepi(i, n, 0)

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; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) {o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const long long INF = 1LL << 60;

// 降順ソート
// std::sort(data.begin(),data.end(),std::greater<ll>());
// 昇順ソート
// std::sort(data.begin(),data.end());

// vector型の「data」に xが存在するかを、True or Falseで返す
// vector_finder(data, x)
int vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
  }
  else { // 発見できなかったとき
    return false;
  }
}

// ここから開始だよ！
ll S;
std::vector<ll> v;

ll run(ll n) {
	if(n % 2 == 0) {
		return n / 2;
	} else {
		return 3 * n + 1;
	}
}

int main() {
	// 呪文エリア
	cin.tie(0);
	ios::sync_with_stdio(false);
	// 詠唱完了
  
	cin >> S;
	v.push_back(S);
	
	ll i = 1;
	while (true) {
		ll tmp = run(v[i-1]);
		i++;
		if (vector_finder(v, tmp)) {
			break;
		} else {
			v.push_back(tmp);
		}
	}
	
	cout << i << endl;
	return 0;
}


Measured memory_bytes: 256
nums = input()

op_cnt = len(nums) -1

sum = 0

for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if(i >> j & 1):
            op[j] = "+"
    # print(op)

    formula = ""

    for p_n,p_o in zip(nums,op + [""]):
        formula += (p_n + p_o)

    sum += eval(formula)

print(sum)

Measured memory_bytes: 9052
def main():

    N = int(input())
    d = dict()
    cnt = 0
    for _ in range(N):
        s = input()
        d[s] = d.get(s, 0) + 1
        cnt = max(cnt, d[s])
    ans = []
    for s in d:
        if d[s] == cnt: ans.append(s)
    ans = sorted(ans)
    for s in ans:
        print(s)

    # return " ".join(map(str, sorted(ans)))

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


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

int main(){
  int a, b, c, d;
  
  cin >> a >> b >> c >> d;
  
  if(a+b>c+d){
    cout << "Left";
  }
  else if(a+b==c+d){
    cout << "Balanced";
  }
  else if(a+b<c+d){
    cout << "Right";
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256