akhauriyash/Code-Regression huggingface dataset:
import math

N = int(input())

n = int(math.sqrt(N)) + 1

res = [set() for _ in range(N)]

for x in range(1, n+1):
    for y in range(1, n+1):
        for z in range(1, n+1):
            enu = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if enu <= N:
                res[enu-1].add((x, y, z))

for i in range(N):
    print(len(res[i]))


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

int main(){
        int n, cnt=0;
        while(cin >> n){
                cnt = 0;
                for(int i = 0; i <= 9; i++){
                        for(int j = 0; j<= 9; j++){
                                for(int k = 0; k <= 9; k++){
                                        for(int l = 0; l <= 9; l++){
                                                if(i+j+k+l == n)        cnt++;
                                        }
                                }
                        }
                }
        cout << cnt << endl;

        }

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(INF)
#define INF 1e17
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int cnt=0;
	int t;
	For(i,1,n){
		cin>>t;
		if(t!=i) cnt++;
	}
	if(cnt==2 || cnt==0) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}




















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

namespace Atc_0039
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int N = int.Parse(S.Split(' ')[0]);
            int D = int.Parse(S.Split(' ')[1]);

            if (N <= D)
            {
                Console.WriteLine(1);
                return;
            }

            if (N % (2 * D + 1) == 0)
            {
                Console.WriteLine(N / (2 * D + 1));
            }
            else
            {
                Console.WriteLine(N / (2 * D + 1) + 1);
            }
        }
    }
}

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

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    static final int     INF   = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        long H = nlong();
        double log = Math.log(H) / Math.log(2);
        int ilog = (int) log + 1;
        System.out.println((long) Math.pow(2, ilog) - 1);
    }
    
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    
    static long lcm(int m, int n) {
        return (long) m * n / gcd(m, n);
    }
    
    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 21972
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]

for i in range(n):
    if i == 0:
        diff_t = txy[i][0]
        diff_ab = abs(txy[i][1]) + abs(txy[i][2])
    else:
        diff_t = txy[i][0] - txy[i-1][0]
        diff_ab = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2]-txy[i-1][2])
    # 距離判定
    if diff_ab > diff_t:
        print('No')
        exit()
    # 奇数偶数判定
    if diff_ab % 2 != diff_t % 2:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 27300
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var S = Console.ReadLine();

            var hash = new HashSet<char>();
            foreach (var c in S)
            {
                hash.Add(c);
            };

            var answer = hash.Count >= 2 ? "Yes" : "No";
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11348
N = int(input())
A = list(map(int, input().split()))
lst = []
count = 0
for ele in A:
    if ele % 2 == 0:
        lst.append(ele)
for ele in lst:
    if ele % 3 == 0 or ele % 5 == 0:
        count += 1
print("APPROVED" if count == len(lst) else "DENIED")

Measured memory_bytes: 3060
def main():
    n = int(input())
    T = list(map(int, input().split()))
    A = list(map(int, input().split()))[::-1]
    mod = 1000000007
    if n == 1:
        if T[0] == A[0]:
            print(1)
        else:
            print(0)
        exit()
    INF = 1e+10
    ans = [[0, INF] for _ in range(n)]
    ans[0] = [1, T[0]]
    ans[-1] = [1, A[0]]
    for i, (t, a) in enumerate(zip(T[1:], A[1:])):
        i += 1
        an = ans[i]
        if t > T[i - 1]:
            if (an[0] == 0 and an[1] >= t) or (an[0] == 1 and an[1] == t):
                ans[i] = [1, t]
            else:
                print(0)
                exit()
        else:
            if an[0] == 0:
                ans[i][1] = min(ans[i][1], t)
            else:
                if an[1] > t:
                    print(0)
                    exit()
                else:
                    pass
        an = ans[-(i + 1)]
        if a > A[i - 1]:
            if (an[0] == 0 and an[1] >= a) or (an[0] == 1 and an[1] == a):
                ans[-(i + 1)] = [1, a]
            else:
                print(0)
                exit()
        else:
            if an[0] == 0:
                ans[-(i + 1)][1] = min(ans[-(i + 1)][1], a)
            else:
                if an[1] > a:
                    print(0)
                    exit()
                else:
                    pass
    c = 1
    for a in ans:
        if a[0] == 0:
            c = c * a[1] % mod
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28108
import java.util.*;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] group = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
		
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		if(group[x] == group[y]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		sc.close();

	}

}

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


int main(){
	int x;
	if(scanf("%d", &x)== EOF){return 0;}
	if(x < 2 || 100000 < x){return 0;}
	
	int flag = 1;
	for(int i = x; i < x*2; i++){
		if(x == 2){printf("%d\n", i); return 0;}
		for(int j = 2; j<i; j++){
			if(i%j==0){flag=0;break;}
		}
		if(flag ==0){flag = 1; continue;}
		else{printf("%d\n", i); return 0;}
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace abc147
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_abc147B();
        }

        public static void solve_abc147B()
        {
            string s = Console.ReadLine();
            int min = 0;
            int i = 0;
            int j = s.Length - 1;
            while (i <= j)
            {
                if (s[i] != s[j])
                {
                    min++;
                }
                i++;
                j--;
            }
            Console.WriteLine(min);
        }

        public static void solve_abc147A()
        {
            int[] abc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            Console.WriteLine(abc[0] + abc[1] + abc[2] >= 22 ? "bust" : "win");
        }
    }
}


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

using namespace std;

int n, d[3][110], x;
#define fo(i, n) for(int i = 1; i <= n; ++i)

int main()
{
	cin >> n;
	fo(i, 2) fo(j, n) {
		cin >> x;
		d[i][j] = max(d[i - 1][j], d[i][j - 1]) + x;
	}
	cout << d[2][n];
	
	return 0;            
}

Measured memory_bytes: 256
if __name__ == '__main__':
    
    pos = ["o","x","x"]
    ALF = ["A","B","C"]

    while True:
        try:
            s1,s2 = input().split(",")

            if s1 in ["A","B"] and s2 in ["A","B"]:
                pos[0],pos[1] = pos[1],pos[0]
            elif s1 in ["A","C"] and s2 in ["A","C"]:
                pos[0],pos[2] = pos[2],pos[0]
            elif s1 in ["B","C"] and s2 in ["B","C"]:
                pos[1],pos[2] = pos[2],pos[1]

        except EOFError:
            break
    print(ALF[pos.index("o")])



Measured memory_bytes: 5560
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

const ll INF = LONG_LONG_MAX / 2;

void warshall_floyd(const int N, vector<vector<ll>> & matrix) {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (matrix[j][i] != INF && matrix[i][k] != INF) {
                    matrix[j][k] = min(matrix[j][k], matrix[j][i] + matrix[i][k]);
                }
            }
        }
    }
}

vector<vector<ll>> prepare_edges(const int N, const int L, vector<vector<ll>> &matrix) {
    vector<vector<ll>> new_matrix(N, vector<ll>(N, INF));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (matrix[i][j] <= L) {
                new_matrix[i][j] = 1;
            }
        }
    }
    warshall_floyd(N, new_matrix);
    return new_matrix;
}

ll solve(const int s, const int t, const int N, const vector<vector<ll>> &edges) {
    queue<int> q;
    q.push(s);

    vector<ll> dist(N, INF);
    dist[s] = 0;

    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto next : edges[v]) {
            if (dist[v] + 1 < dist[next]) {
                dist[next] = dist[v] + 1;
                q.push(next);
            }
        }
    }

    return dist[t];
}

int main(void) {
    int N, M, L;
    cin >> N >> M >> L;

    // {dest, cost}
    vector<vector<ll>> matrix(N, vector<ll>(N, INF));
    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        matrix[A - 1][B - 1] = C;
        matrix[B - 1][A - 1] = C;
    }
    warshall_floyd(N, matrix);

    vector<vector<ll>> new_matrix = prepare_edges(N, L, matrix);

    int Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        ll ans = new_matrix[s][t];
        if (ans == INF) ans = -1;
        else ans -= 1;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<int> memo(1000000, INT_MAX);
void solve(){
	int n, k; cin>>n>>k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}

	memo[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for(int j=i+1;j<=i+k;j++){
			if(j<n){
				memo[j] = min(memo[j], memo[i]+abs(a[i]-a[j]));
			}
		}
	}
	cout<<memo[n-1]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    // ll t; cin>>t;
    // while(t--)
    solve();
    return 0;
}


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











#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    int n,x=0,y=0;
    cin>>n;
    vi v(n),c(n);
    rep(i,n)
    cin>>v.at(i);
    rep(i,n)
    cin>>c.at(i);
    rep(i,n){
        if(v.at(i)>c.at(i)){
            x+=v.at(i);
            y+=c.at(i);
        }
    }
    cout<<x-y<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll i = 0; i < n; i++)    cin>>a[i];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

int main(){
	init();
	ll n;	cin>>n;	ll a[n];	get(a, n);
	ll ps[n] = {0};	for(ll i = n-2; i > -1; i--)	ps[i] = mop(ps[i+1], +, a[i+1]);
	ll ans = 0;
	for(ll i = 0; i < n; i++){
		ans = mop(ans, +, mop(a[i], *, ps[i]));
	}
	cout<<ans;
}

Measured memory_bytes: 6776
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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

int n;
string s;
bool check(int len) {
	map<string, int> freq;
	for (int i = 0; i + len - 1 < n; i++) {
		string sub = s.substr(i, len);
		if (freq.find(sub) == freq.end()) freq[sub] = i + len - 1;
		else if (i > freq[sub]) return true;

	}

	return false;
}

int main() {

	cin >> n;
	cin >> s;

	int lo = 1, hi = n, ans = 0;
	while (lo <= hi) {
		int mid((lo + hi) >> 1);

		if (check(mid)) ans = mid, lo = mid + 1;
		else hi = mid - 1;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 9876
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
//queue<int>q[maxn];
int n,m;
long long gcd(long long a,long long b)
{
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
int main()
{
	int i,j,k,ans=0;
	long long x,y,z,w;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>x>>y>>z>>w;		if(w<y || x<y)
		{
			cout<<"No"<<endl;continue;
}
		if(z+1>=y){
						cout<<"Yes"<<endl;continue;
		}



		long long g=gcd(y,w);
		if((x-z-1ll)/g-(x-y)/g<=0)
            cout<<"Yes"<<endl;
       	else
            cout<<"No"<<endl;
	}
	return 0;
}


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

typedef long long int   ll;
typedef vector<int,int> pii;


#define sf              scanf
#define pf              printf
#define sfii(n,m)       scanf("%d %d",&n,&m)
#define sfll(n,m)       scanf("%lld %lld",&n,&m)
#define sfi(n)          scanf("%d",&n)
#define sfl(n)          scanf("%lld",&n)
#define pfi(n)          printf("%d",n)
#define pfl(n)          printf("%lld",n)
#define spc             printf(" ")
#define line            printf("\n")
#define pb              push_back
#define mp              make_pair
#define loop(i,x,y)     for(int i=int(x); i<=int(y); i++)
#define rloop(i,y,x)    for(int i=int(y); i>=int(x); i--)
#define caseT           int T,cs;scanf("%d",&T)
#define Numan2962       int main()
#define task_completed  return 0

#define MAX 200009

using namespace std;

Numan2962
{
    int a,b,t;
    sfii(a,b),sfi(t);
    cout<<(t/a)*b<<endl;
    task_completed;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int>v1,v2,org;
    for(int i = 0; i < n; i++) {
        org.push_back(i+1);

    }
    for (int i = 0; i< n; i++) {
        int x;
        cin >> x;
        v1.push_back(x);
    }
     for (int i = 0; i< n; i++) {
        int x;
        cin >> x;
        v2.push_back(x);
    }
    int a, b, k=0;
    do {
        if(org == v1) {
            a = k;
        }
        if(org == v2) {
            b = k;
        }
        k++;
    }while(next_permutation(org.begin(),org.end()));
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int x[20][20];
int y[20][20];
int counter(int x) {
    if (x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N+1);
    A[0] = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        for (int j = 1; j <= A[i]; ++j) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for (int i = 1; i < (1 << N);++i) {
        bool ok = true;
        for (int j = 1; j <= N; ++j) {
            if (!(i&(1 << (j-1))))continue;
            for (int k = 1; k <= A[j]; ++k) {
                if (((i >> (x[j][k]-1)) & 1) ^ y[j][k]) ok = false;
            }
            
        }
        if (ok) ans = max(ans, counter(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll dp[10010];
int main() {
    ll H, N; cin >> H >> N;
    vector<ll> A(N), B(N);
    for(int i=0; i<N; i++) cin >> A[i] >> B[i];

    fill(dp, dp + H + 1, LONGINF);
    dp[H] = 0;
    for(int i=H; i>=0; i--) {
        for(int j=0; j<N; j++) {
            int NH = max<int>(0, i - A[j]);
            chmin(dp[NH], dp[i] + B[j]);
        }
    }
    cout << dp[0] << endl;
    return 0;
}


Measured memory_bytes: 384
import heapq
n=int(input())
a=list(map(int,input().split()))

maxL=[]
l=[]
for i in range(n):
  l.append(a[i])
s=sum(l)
maxL.append(s)
heapq.heapify(l)
for i in range(n,2*n):
  heapq.heappush(l,a[i])
  s+=a[i]
  s-=heapq.heappop(l)
  maxL.append(s)

minL=[]
l2=[]
for i in range(2*n,3*n):
  l2.append(-a[i])
s2=sum(l2)
minL.append(s2*(-1))
heapq.heapify(l2)
for i in range(2*n-1,n-1,-1):
  heapq.heappush(l2,-a[i])
  s2-=a[i]
  s2-=heapq.heappop(l2)
  minL.append(s2*(-1))

minL.reverse()
ans=[]
for i in range(n+1):
  ans.append(maxL[i]-minL[i])
print(max(ans))

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll __int128
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 1e9 + 7;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

const int N = 103;
int dp[N][N][2];

int min(int a, int b, int c, int d) {
    return min(min(min(a, b), c), d);
}

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

    int h, w;
    cin >> h >> w;
    dp[1][0][1] = dp[0][1][1] = 1;
    for (int i = 2; i < N; ++i) {
        dp[i][0][0] = dp[i][0][1] = dp[0][i][0] = dp[0][i][1] = INF;
    }
    for (int i = 1; i <= h; ++i) {
        string s;
        cin >> s;
        for (int j = 1; j <= w; ++j) {
            if (s[j - 1] == '.') {
                dp[i][j][0] = min(dp[i - 1][j][0], dp[i][j - 1][0], dp[i - 1][j][1], dp[i][j - 1][1]);
                dp[i][j][1] = INF;
            } else {
                dp[i][j][0] = INF;
                dp[i][j][1] = min(dp[i - 1][j][0] + 1, dp[i][j - 1][0] + 1, dp[i - 1][j][1], dp[i][j - 1][1]);
            }
            //cout << i << ' ' << j << ' ' << dp[i][j][0] << ' ' << dp[i][j][1] << endl;
        }
    }
    cout << min(dp[h][w][0], dp[h][w][1]);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main(void){
  int cnt = 0;
  string w,t,tmp;
  cin >> w;
  do {
    getline(cin,tmp);
    t += " "+tmp;
  }while(tmp!="END_OF_TEXT");
  for (int i=1;i<t.size();i++) {
    if(t[i-1]==' '){
      for (int j=0;j<w.size();j++) {
        if (tolower(t[i])==w[j]){
          i++;
          if((j==(w.size()-1))&&(t[i]==' ')){
            cnt++;
            i--;
          }
        }else{break;}
      }
    }else{continue;}
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

ll modpow(ll x,ll y)
{
	ll res=1;
	x=x%mod;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		x=(x*x)%mod;
		y>>=1;
	}
	return res;
}

ll modpowinv(ll n)
{
	return modpow(n,mod-2);
}

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

	ll n,m;
	cin>>n>>m;
	ll f[n+1]={0};
	bool b[n+1]={0};
	while(m--)
	{
		ll p;
		string s;
		cin>>p>>s;
		if(s=="WA")
		{
			if(!b[p])
				f[p]++;
		}
		else
		{
			b[p]=1;
		}
	}
	ll ac=0,wa=0;
	for(ll i=1;i<=n;i++)
	{
		if(b[i])
		{
			ac++;
			wa+=f[i];
		}
	}
	cout<<ac<<' '<<wa<<'\n';
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "first" << endl;}
void no(){ cout << "second" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    int n ;
    cin >> n ;
    bool f = true ;
    REP(i,n){
        int a ;
        cin >> a ;
        if(a%2==1){
            f = false ;
        }
    }
    if(!f){
        yes() ;
    }
    else{
        no() ;
    }




    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  int K[40], A[40][40], cnt[40];
  for (int i = 1; i < M+1; i++) {
    cnt[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      cin >> A[i][j];
      cnt[A[i][j]]++;
    }
  }
  int res = 0;
  for (int i = 1; i < M+1 ; i++) {
    if (cnt[i] == N) {
      res++;
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#! /usr/bin/python 
# -*- coding: utf-8 -*- 
#===============================================================================
# Date created  : 2019-03-30T11:10:44+09:00
# Date modified : 2019-03-30T11:10:44+09:00
# Author        : awk
# Description   : unanswered
#===============================================================================


A , B , C , X , Y = map(int,input().split())
cost = []

for i in range(10**5 + 1):
    # 2i 枚のABピザを買う
    x = i
    y = i
    a = max(X - i, 0)
    b = max(Y - i, 0)
    cost.append(A * a + B * b + C * 2 * i)
print(min(cost))
    



Measured memory_bytes: 7104
a, b, c, d= map(int, input().split())

if a <= 0 and b <= 0 and c<= 0 and d<= 0:
    print(a * c)
elif a <= 0 and b<= 0 and c > 0 and d > 0:
    print(b * c)
elif a > 0 and b > 0 and c <= 0 and d <= 0:
    print(a * d)
elif a * c >= b * d:
    print(a * c)
elif a * c < b * d:
    print(b * d)



Measured memory_bytes: 9140
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>
 
#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;
#define PI 3.14
 
int main()
{
    double r;
    cin >> r;
    
 
    cout << 2* r * PI << endl;
    return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
using namespace std;
signed main(){
	string a;
	cin >> a;
	int b = a.size();
	int n=0,s=0,e=0,w=0;
	REP(i,b){
		if(a[i]=='N'){
			n++;
		}
		else if(a[i]=='S'){
			s++;
		}
		else if(a[i]=='E'){
			e++;
		}
		else if(a[i]=='W'){
			w++;
		}
	}
	if(n != 0 && s != 0 && e != 0 && w != 0){
		cout << "Yes" << endl;
	}
	else if(n != 0 && s != 0 && e == 0 && w == 0){
		cout << "Yes" << endl;
	}
	else if(n == 0 && s == 0 && e != 0 && w != 0){
		cout << "Yes" << endl;
	}
	else cout << "No"<< endl;
    return 0;
}

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

int main (){
    int x;cin>>x;
    int tmp=x;
    int ans=0;
    while(x){
        ans+=x%10;
        x/=10;
    }
    if(tmp%ans==0) puts("Yes");
    else puts("No");
}


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

struct P2
{
int a;
int b;

	bool operator < ( const P2 &P ) const
	{
		return ( a < P.a );
	}
};

vector<P2> X( 100000 );
auto it = X.begin();

int main()
{
int i;
int N;
int a;
int b;
long long K;
long long c;

	cin >> N;
	cin >> K;

	for( i = 0; i < N; i++ )
	{
		cin >> X[ i ].a;
		cin >> X[ i ].b;
	}

	sort( it, it + N );

	i = - 1;
	c = K;
	while( c > 0 )
	{
		i++;
		c -= X[ i ].b;
	}

	cout << X[ i ].a << endl;

	return 0;
}






Measured memory_bytes: 1024
import java.util.*;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		int n=sc.nextInt();sc.nextLine();
		while (n--!=0) {
			String str = sc.nextLine();

			String res="";
			for(int a=1;a<26;a++)for(int b=0;b<26;b++){
				String ans=getAffine(str, a, b);
				if(ans.contains("this") ||ans.contains("that")){
					res=ans;
					break;
				}
			}
			ln(res);
		}
	}
	public String getAffine(String s,int a,int b){
		char[] cs=s.toCharArray();
		for(int i=0;i<cs.length;i++){
			if(Character.isLowerCase(cs[i]))
				cs[i]=(char)((a*(cs[i]-'a')+b)%26+'a');
		}
		return String.copyValueOf(cs);
	}


	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int a[100000];
map<int, int> m;

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) {
        auto it = m.lower_bound(a[i]);
        if (it == m.begin()) {
            m[a[i]]++;
        } else {
            it--;
            m[(*it).first]--;
            if (m[(*it).first] == 0) m.erase(it);
            m[a[i]]++;
        }
    }
    int ans = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        ans += (*it).second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9
const int MAX_N=100;
const int MAX_W=100;
const int MOD=1000000007;

int dp[110][10010];

int main(){
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    for(int i=0;i<n;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    cout<<dp[n][W]<<endl;
}




Measured memory_bytes: 7016
#include<bits/stdc++.h>
#define   ll      long long int
#define   sz      200010
using namespace std;



int main()
{

      double x=0.0,a;
      ll n,i;

      cin>>n;

      while(n--)
      {
          cin>>a;
          x+=(1.0/a);
      }
      x=1.0/x;

      printf("%0.10lf\n",x);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
using namespace std;

int sumDigit(int n){
    if(n < 10) return n;
    else return n % 10 + sumDigit(n / 10);
}

int main(void){
    
    int n;
    cin >> n;
    int min = 1000;
    
    for(int i = 1; i < n; i ++){
        min = MIN(min, sumDigit(i) + sumDigit(n-i));
    }
    
    cout << min << "\n";
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int k = in.nextInt();
		int mod = 1000000007;
		long count = 0;
		for(long i=n-1;i>=1;i--) count = (count + (i*(i+1)*m*m)/2) % mod;
		for(long i=m-1;i>=1;i--) count = (count + (i*(i+1)*n*n)/2) % mod;
		System.out.println((count*nCk(n*m-2,k-2,mod))%mod);
		in.close();
	}
	
	//return a^b mod M O(logB)
		public static long pow(long a,long b,int M) {
			long ret = 1;
			long tmp = a;
			while(b>0) {
				if((b&1)==1) ret = (ret * tmp) % M;
				tmp = (tmp * tmp) % M;
				b = b>>1;
			}
			return ret;
		}
		
		//return nCk mod M (M must be prime number) O(min(k,n-k)*logM)
		public static int nCk(int n,int k,int M) {
			long ret = 1;
			int min = Math.min(k, n-k);
			for(int i=1;i<=min;i++) {
				ret = (ret * pow(i,M-2,M)) % M;
			}
			for(int i=n-min+1;i<=n;i++) {
				ret = (ret * i) % M;
			}
			return (int)ret;
		}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();
const long double EPS =1e-9;



int main(){
    ll x,res=0; cin>>x;
    
    res+=1LL*(x/500)*1000+1LL*((x%500)/5)*5;
    
    cout<<res<<endl;
}

  

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	string s;
    cin>>s;
    for(int i=0;i<s.length();i=i+1){
    	if(s[i]=='1')
    		cout<<9;
    	else 
      		cout<<1;
    }
    return 0;
}

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

int main() {
	int x[3000];
	int y[3000];
	int i;

	for (i = 0; i < 3000; i++) {
		cin >> x[i];
		cin >> y[i];

		if (x[i] == 0 && y[i] == 0)
			break;
	}

	for (int a = 0; a < i; a++)
	{
		if (x[a] < y[a])
			cout << x[a] << " " << y[a] << endl;
		else
			cout << y[a] << " " << x[a] << endl;
	}

}

Measured memory_bytes: 2960
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	double time1, time2;
	while(scanf("%lf %lf",&time1,&time2) != EOF){
		if(time1<35.50 && time2<71.00){
			cout<<"AAA"<<endl;
		}else if(time1<37.50 && time2<77.00){
			cout<<"AA"<<endl;
		}else if(time1<40.00 && time2<83.00){
			cout<<"A"<<endl;
		}else if(time1<43.00 && time2<89.00){
			cout<<"B"<<endl;
		}else if(time1<50.00 && time2<105.00){
			cout<<"C"<<endl;
		}else if(time1<55.00 && time2<116.00){
			cout<<"D"<<endl;
		}else if(time1<70.00 && time2<148.00){
			cout<<"E"<<endl;
		}else{
			cout<<"NA"<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1228
package main

import (
	"fmt"
)

func main() {
	var a, b, c int64

	fmt.Scan(&a, &b, &c)

	d := c - a - b
	if d < 0 {
		fmt.Println("No")
		return
	}

	if d*d > 4*a*b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
struct edge{ll to, cost;};
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define INF 1000000000000

using graph = vector<vector<ll>>;
vector<bool> seen;
vector<ll> ans;


void dfs(const graph &G, int v){
    seen[v] = true;



    for(auto next_v : G[v]){
        ans[next_v] = v+1;
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}

int main(){
    ll n,m;
    cin >> n >> m;
    //ll a[m],b[m];
    //ll ans[n];
    bool gomi = true;
    graph g(n);
    seen.assign(n, false);
  ans.assign(n,0);
    for(int i = 0; i < m; i++){
        ll temp1,temp2;
        cin >> temp1 >> temp2;
        //a[i] = temp1;
        //b[i] = temp2;
        g[temp1-1].push_back(temp2-1);
        g[temp2-1].push_back(temp1-1);
    }
  //dfs(g,0);

  vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        seen[v] = true;
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : g[v]) {
            if (seen[nv]) continue; // すでに発見済みの頂点は探索しない
          seen[nv] = true;
          ans[nv] = v+1;

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            que.push(nv);
        }
    }






    for(int i = 1; i < n; i++){
        if(!seen[i]) gomi = false;
    }
    if(gomi){
        //cout << "Yes";
      printf("Yes\n");
        for(int i = 1; i < n; i++){
          printf("%d\n",ans[i]);
        }
    }
    else{
        cout << "No" << endl;
    } 



}

Measured memory_bytes: 13172
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <numeric>
#include <map>
#include <sstream>
#include <bitset>
using namespace std;


bool compare_by_b(pair<string, int> a, pair<string, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}


int main()
{
    
    int N;
    cin>>N;
    string s[N+10];
    int j[N+10];
    vector<pair <string,int>> v;
    for(int i=1;i<N+1;i++){
        pair <string,int> p;
        
        cin>>s[i];
        cin>>j[i];
        p=make_pair(s[i],j[i]);
        v.push_back(p);
    }
    sort(v.begin(),v.end(),compare_by_b);

    
    
    for(auto itr=v.begin();itr!=v.end();itr++){
        for(int i=1;i<N+1;i++){
            if((*itr).first==s[i] && (*itr).second==j[i]){
                cout<<i<<endl;
            }
        }
    }
        
    }




Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, r = map(int, input().split())
if n < 10:
    print(100*(10-n)+r)
else:
    print(r)


Measured memory_bytes: 38640
#include <iostream>
#include <cmath>
#include <set>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    set<int> d;
    for(int i=1; i<=sqrt(M+1); i++){
        if(M % i == 0) {
            d.insert(i);
            d.insert(M/i);
        }
    }

    int ans = 1;
    for(auto num : d){
        if(M / num >= N) ans = num;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

int main() {
	long long W, a, b;
	cin >> W >> a >> b;
	if (a > b)
		swap(a, b);

	cout << max(0LL, b - (a + W)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

class myheap
{
public:
    myheap()
    : H(0), cbt(vs32(1, 0))
    {}
    ~myheap() {}
    int parent(int i) { return i / 2; }
    int left(int i) { return 2 * i; }
    int right(int i) {return 2 * i + 1; }

    void maxHeapify(int i)
    {
        int l = left(i);
        int r = right(i);

        int largest;
        if (l <= H && cbt[l] > cbt[i])
        {
            largest = l;
        }
        else
        {
            largest = i;
        }

        if (r <= H && cbt[r] > cbt[largest])
        {
            largest = r;
        }

        if (largest != i)
        {
            swap(cbt[i], cbt[largest]);
            maxHeapify(largest);
        }
    }

    void buildMaxHeap()
    {
        for (int i = (H / 2); i >= 1; --i)
        {
            maxHeapify(i);
        }
    }

    void insert(int u)
    {
        ++H;
        cbt.push_back(-1);
        heapIncreaseKey(H, u);
    }

    void heapIncreaseKey(int i, int key)
    {
        cbt[i] = key;

        while (i > 1 && cbt[parent(i)] < cbt[i])
        {
            swap(cbt[parent(i)], cbt[i]);
            i = parent(i);
        }
    }

    int extract()
    {
        int ret = cbt[1];
        cbt[1] = cbt[H];
        cbt.pop_back();
        --H;
        maxHeapify(1);
        return ret;
    }

    int H;
    bool dirty;
    vs32 cbt;
};

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

    char cmd[10];
    int c;

    myheap mheap;
    bool con = true;
    while (con)
    {
        // cin >> cmd;
        scanf("%s", cmd);
        if (cmd[0] == 'i')
        {
            // cin >> c;
            scanf("%d", &c);
            mheap.insert(c);
        }
        else if (cmd[0] == 'e' && cmd[1] == 'x')
        {
            c = mheap.extract();
            // cout << c << "\n";
            printf("%d\n", c);
        }
        else/* if (cmd == "end")*/
        {
            con = false;
        }
    }
    return 0;
}




Measured memory_bytes: 7080
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> N;
	vector<vector<int>>a(2, vector<int>(N));
	for (int i = 0; i < 2; i++)for (int j = 0; j < N; j++)cin >> a[i][j];
	ll sum[2];
	sum[0] = 0; sum[1] = 0;
	for (int i = 0; i < 2; i++)for (int j = 0; j < N; j++)sum[i] += a[i][j];
	ll tmp[2];
	tmp[0] = a[0][0]; tmp[1] = 0;
	ans = a[0][0] + sum[1];
	for (int i = 1; i < N; i++) {
		tmp[0] += a[0][i]; sum[1] -= a[1][i - 1];
		ans = max(tmp[0] + sum[1], ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    while(cin>>N>>M,N || M){
        int h[1501],w[1501];
        for(int i=0;i<N;i++) cin>>h[i];
        for(int i=0;i<M;i++) cin>>w[i];
        
        vector<int> nh,nw;
        for(int i=0;i<N;i++){
            int sum=h[i];
            nh.push_back(sum);
            for(int j=i+1;j<N;j++){
                sum+=h[j];
                nh.push_back(sum);
            }
        }
        sort(nh.begin(),nh.end());
        for(int i=0;i<M;i++){
            int sum=w[i];
            nw.push_back(sum);
            for(int j=i+1;j<M;j++){
                sum+=w[j];
                nw.push_back(sum);
            }
        }
        sort(nw.begin(),nw.end());
        int a[600000]={},b[600000]={};
        for(int i=0;i<nh.size();i++) a[nh[i]]++;
        for(int i=0;i<nw.size();i++) b[nw[i]]++;
        
        int ans=0;
        
        for(int i=0;i<600000;i++) ans+=a[i]*b[i];
        cout<<ans<<endl;
    }
    return 0;
}




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

using ll = long long int;
using P = std::pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rag(con) std::begin(con), std::end(con)

int main()
{
    std::string str;

    std::cin >> str;

    if (str.back() == 's')
        std::cout << str + "es" << std::endl;
    else
    {
        std::cout << str + "s" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3632