akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long spf[1000002]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2;i<1000002; i++) 
    spf[i] = i; 
    for (int i=4; i<1000002; i+=2) 
    spf[i] = 2; 
  
    for (int i=3; i*i<1000002; i++) 
    { 
      if (spf[i] == i) 
        { 
            for (int j=i*i; j<1000002; j+=i) 
            if (spf[j]==j) 
            spf[j] = i; 
        } 
    } 
} 
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    sieve();
      long long n,i,j,k,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>n;
      long long a[n];
      map<long long ,long long>m1,m2;
      for(i=0;i<n;i++)
      {
          cin>>a[i];
          k=a[i];
          while(k!=1)
          {
              if(m1[spf[k]]==0)
              { m1[spf[k]]++;
                m2[spf[k]]++;
                if(m2[spf[k]]==2)
                ans=1;
              }
              k=k/spf[k];
          }
          m1.clear();
      }
      if(ans==0)
      {
          cout<<"pairwise coprime";
          return 0;
      }
      k=a[0];
      for(i=0;i<n;i++)
      {
          k=__gcd(k,a[i]);
      }
      if(k==1)
      {
           cout<<"setwise coprime";
          return 0;
      }
      cout<<"not coprime";
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    string s;
    long long int left = 0, right = 0;
    for (int i = 0; i < N; i++) {
        long long int n, p;
        char c;
        cin >> p >> c >> n;

        if (c == '(') left += n;
        else right += n;

        if (right == left) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3092
#include <stdio.h>
int main(){
  int W, H, x, y, r;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
  if (x >= 0+r && x <= W-r && y >= 0+r && y <= H-r)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;

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

		int n = src.nextInt();

		//配列arrayとコピー
		int[] array = new int[n];
		int[] copy = new int[n];
		
		for (int i=0; i<n; i++)
			array[i] = copy[i] = src.nextInt();

		int q = src.nextInt();

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

			int b = src.nextInt();
			int m = src.nextInt();
			int e = src.nextInt();

			for(int k=0; k<(e - b); k++) {
				
				 copy[b + ((k + (e - m)) % (e - b))] = array[b+k];
//					System.out.print(array[k] + "debug");
			}
			for(int j=0; j<n; j++) {
				array[j] = copy[j];
			}

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


Measured memory_bytes: 36516
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 3e18;
vector<int> g[N];

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
       int n,m;
       cin>>n>>m;
       vi h(n);
       cin>>h;
       for(int i=0;i<m;i++)
       {
           int x,y;
           cin>>x>>y;
           g[x].pb(y);
           g[y].pb(x);
       }
       int cnt=0;
       for(int i=1;i<=n;i++)
       {
           bool ok =true;
           if(g[i].size()==0)
           {
               cnt++;
           }
           else
           {
               for(auto it:g[i])
               {
                   if(h[i-1]<=h[it-1])
                   {
                       ok=false;
                   }
               }
               if(ok)cnt++;
           }
       }
       cout<<cnt<<"\n";
       
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 12056
/*
I don't wanna die alone
I don't wanna live forsaken
I refuse to let this go
Because my soul is breaking

I don't wanna let you know
That my heart is just so jaded
I refuse to let it show
I refuse to let it go

Wake me up when this is over
I'm tired of living life like its a dream
Please wake me up when its all over
I'm tired of living right here in between
I refuse

I've always walked alone
I chose the path less taken
I refuse to let you win
Life's a bitch and I've been shaken

Its not a joke at all
Inside my spirit's fading
I refuse to take the fall
Cause no one cares at all

Wake me up when this is over
I'm tired of living life like its a dream
Please wake me up when its all over
I'm tired of living right here in between
I refuse

Cause at the end of the day I'm not you
I refuse

Wake me up when this is over
I'm tired of living life like its a dream
Please wake me up when its all over
I'm tired of living right here in between
Wake me up when this is over
I'm tired of living life like its a dream
Please wake me up when its all over
I'm tired of living right here in between

I refuse
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int n,ar[N];

vector<pair<int,int > > mx[1<<18],temp;
int ans[1<<18];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	for (int i=0;i<(1<<n);i++){
		cin>>ar[i];
	}

	for (int mask=0;mask<(1<<n);mask++){
		mx[mask].clear();
		mx[mask].push_back(make_pair(ar[mask],mask));
		for (int i=0;i<n;i++){
			if (mask&(1<<i)){
				int othr=mask-(1<<i);
				mx[mask].push_back(mx[othr][0]);
				if (mx[othr].size()>1)
					mx[mask].push_back(mx[othr][1]);
			}
		}
		sort(mx[mask].begin(),mx[mask].end());
		temp=mx[mask];
		mx[mask].clear();
		reverse(temp.begin(),temp.end());
		for (int i=0;i<temp.size();i++){
			if (i==0||temp[i]!=temp[i-1]){
				if (mx[mask].size()<2)
					mx[mask].push_back(temp[i]);
			}
		}
		int here=0;
		for (int i=0;i<mx[mask].size();i++){
			here+=mx[mask][i].first;
		}
		ans[mask]=here;
	}

	for (int i=1;i<(1<<n);i++){
		ans[i]=max(ans[i],ans[i-1]);
		cout<<ans[i]<<endl;
	}

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 73088
N, A, B = list(map(int, input().split()))

if A > B or (A != B and N == 1):
    print("0")
    quit()
if A == B:
    print("1")
    quit()

mn = (N - 2) * A
mx = (N - 2) * B

print (str(mx - mn + 1))


Measured memory_bytes: 3060
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n, k = read_ints()
    mod = 998244353
    dp = [0] * (n + 1)
    dp[0] = 1
    s = 1
    query = [read_int_list() for _ in range(k)]
    
    for i in range(1, n + 1):
        s += dp[i]
        for l, r in query:
            if l + i <= n:
                dp[i + l] = (dp[i + l] + s) % mod
            if r + i + 1 <= n:
                dp[i + r + 1] = (dp[i + r + 1] - s) % mod
    print(dp[n])

if __name__ == '__main__':
    Main()

Measured memory_bytes: 16796
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

//        int a = sc.nextInt();
//        int b = sc.nextInt();
//        int c = sc.nextInt();
//        int d = sc.nextInt();
//        int e = sc.nextInt();
        int a[] = new int[5];
        int ten[] = new int[5];
        int one[] = new int[5];

        int min=9;


        for (int i=0; i<5; i++){
            a[i] = sc.nextInt();
        }

        for (int i=0; i<5; i++){
            ten[i] = a[i]/10;
            if (a[i]%10!=0) ten[i] = a[i]/10+1;
        }
        for (int i=0; i<5; i++){
            one[i] = a[i]%10;
            if ((one[i]!=0)){
                min= Math.min(min, one[i]);
            }
        }
        int total=0;
        for (int i=0; i<5; i++){
            total += ten[i]*10;
        }
        if ((a[0]%10==0)&(a[1]%10==0)&(a[2]%10==0)&(a[3]%10==0)&(a[4]%10==0)) {
            System.out.println(a[0] + a[1] + a[2] + a[3] + a[4]);
//        for (int i=0; i<5; i++) System.out.println(a[i]);
        }else{
            System.out.println(total-10+min);

        }
    }
}



Measured memory_bytes: 23508
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//??????????????°
		double yama;
		double sa = 0;
		double max = 0;
		double min = 1000000;

		Scanner scan = new Scanner(System.in);

		while(scan.hasNextDouble()){

			yama = scan.nextDouble();
			//?????§????????¢???
			if(max < yama){
				max = yama;
			}

			//????°?????????¢???
			if(min > yama){
				min = yama;
			}

		}
		//???????¨????
		sa = max - min;

		System.out.println(sa);

	}

}

Measured memory_bytes: 27904
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

signed main()
{
    fast;
    int a,b,c;

    cin>>a>>b>>c;

    if ( 4*a*b < (c-a-b)*(c-a-b) && (c-a-b) > 0 )
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    int b = 0;
    for (int i = 0; i <= n; i++) {
        int x = k - m * i;
        int y = n - 2 * i;
        if (x == 0 || (y != 0 && x % y == 0 && 0 <= x / y && x / y <= m)) { b = 1; break; }
    }

    cout << (b ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(void){
    long long n,p[200000];
    cin>>n;
    n*=2;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    double u=0,m=n-1;
    for(int i=0;i<n;i++){
        u+=p[i]*i;
    }
    u/=m;
    cout<<setprecision(24)<<u<<endl;
}


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

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

    bool flg = true;
    for (int i = 1; i < s.length(); i++) {
        if (s[i] != '9') {
            flg = false;
            break;
        }
    }

    int ret = (s.length() - 1) * 9 + (s[0] - (flg ? 48 : 49));

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N string
	fmt.Scanf("%s", &N)

	switch string(N[len(N)-1]) {
	case "1":
		fmt.Println("pon")
	case "2":
		fmt.Println("hon")
	case "3":
		fmt.Println("bon")
	case "4":
		fmt.Println("hon")
	case "5":
		fmt.Println("hon")
	case "6":
		fmt.Println("pon")
	case "7":
		fmt.Println("hon")
	case "8":
		fmt.Println("pon")
	case "9":
		fmt.Println("hon")
	case "0":
		fmt.Println("pon")
	}

}


Measured memory_bytes: 1832
#encoding:utf-8

N,H,W = map(int, input().split())
A = []
B = []
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

count = 0
for i in range(N):
    if A[i] >= H and B[i] >= W:
        count += 1

print(count)


Measured memory_bytes: 3060
n,m=map(int,input().split())

if m == 0:
  print(0,0)
  exit(0)

results=[]
for i in range(n+1):
  results.append([0,0])
  
ac = 0
wa = 0
memo = [0]*(n+1)
for i in range(m):
  p,s=input().split()
  p = int(p)
  s = s.strip()

  if memo[p] != -1:
    if s == 'WA':
      memo[p] += 1
    else:
      ac += 1
      wa += memo[p]
      memo[p] = -1

print(ac,wa)

Measured memory_bytes: 18444
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N; int x[N], y[N]; vector<int> array(N);
  rep(i, N){
    cin >> x[i];
  }
  rep(i, N){
    cin >> y[i];
  }
  rep(i, N){
    array[i] = i;
  }
  int cnt = 0, a, b;
  do{
    bool checkx=true, checky=true;
    rep(i, N){
      if(x[i]!=array[i]+1) checkx=false;
      if(y[i]!=array[i]+1) checky=false;
    }
    if(checkx)a=cnt;  if(checky) b=cnt; cnt++;
  }
  while(next_permutation(array.begin(), array.end()));
  //cout << a << " " << b << endl;
  cout << abs(b-a) << endl;
    
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for(int i = 0; i < h; i++){
        cin >> a[i];
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#'){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    for(int i = 0; i < h; i++){
        if(row[i]){
            for(int j = 0; j < w; j++){
                if(col[j]){
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;

string s;

bool input() {
    s = readln.chomp;
    if (s == "#") return false;
    return true;
}

const INF = int.max / 4;
int check(int l, int r, int lr) {
    const LEFT = 0, RIGHT = 1;
    int[int] D = [
        1: 0, 4: 0, 7: 0,
        2: 1, 5: 1, 8: 1,
        3: 2, 6: 2, 9: 2
    ];
    int ret = 0;
    for (int i = 0; i < s.length; i++) {
        auto c = cast(int)(s[i] - '0');
        if (lr == LEFT) {
            if (D[r] < D[c]) {
                r = c;
                ret++;
            } else {
                l = c;
                lr = RIGHT;
            }
        } else {
            if (D[c] < D[l]) {
                l = c;
                ret++;
            } else {
                r = c;
                lr = LEFT;
            }
        }
    }
    return ret;
}

void solve() {
    int ans = INF;
    for (int l = 1; l <= 9; l++) {
        for (int r = 1; r <= 9; r++) {
            for (int lr = 0; lr < 2; lr++) {
                ans = min(ans, check(l, r, lr));
            }
        }
    }
    writeln(ans);
}

void main() {
    while (input) solve;
}

Measured memory_bytes: 2556
import java.util.*;

public class Main {
	public static int count;
	public static int m;
	public static int[] G = new int[100];
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = stdIn.nextInt();
		
		shellSort(a, n);
		
		System.out.println(m);
		for (int i = m - 1; i >= 0; i--) {
			if (i != 0)
				System.out.print(G[i] + " ");
			else
				System.out.println(G[i]);
		}
		System.out.println(count);
		for (int i = 0; i < n; i++)
			System.out.println(a[i]);
	}
	
	public static void insertionSort(int[] a, int n, int g) {
		for (int i = g; i < n; i++) {
			int v = a[i];
			int j = i - g;
			while (j >= 0 && a[j] > v) {
				a[j+g] = a[j];
				j -= g;
				count++;
			}
			a[j+g] = v;
		}
	}
	
	public static void shellSort(int[] a, int n) {
		
		count = 0;
		m = 0;
		
		for (int i = 1; ;i = 3 * i + 1) {
			if (i > n) break;
			G[m] = i;
			m++;
		}
		
		
		for (int i = m - 1; i >= 0; i--)
			insertionSort(a, n, G[i]);

	}
}


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

int main() {
	vector<P>table;
	int N; scanf("%d", &N);
	rep(i, N) {
		int h, m; scanf("%d%d", &h, &m);
		table.push_back(P(h, m));
	}
	int M; scanf("%d", &M);
	rep(i, M) {
		int k, g; scanf("%d%d", &k, &g);
		table.push_back(P(k, g));
	}
	sort(table.begin(), table.end());
	table.erase(unique(table.begin(), table.end()), table.end());
	rep(i, table.size()) {
		printf("%d:%02d", table[i].first, table[i].second);
		if (i < table.size() - 1)printf(" ");
		else printf("\n");
	}
}

Measured memory_bytes: 3228
package main

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

func main() {
    var sc = bufio.NewScanner(os.Stdin)
    
    var nStr string
    if sc.Scan() {
        nStr = sc.Text()
    }
    n, _ := strconv.Atoi(nStr)
    
    var Rs []int
    for i := 0; i < n; i++ {
        if sc.Scan() {
            t := sc.Text()
            R, _ := strconv.Atoi(t)
            Rs = append(Rs, R)
        }
    }

    max := -999999999
    min := Rs[0]

    for i := 1; i < n; i++ {
        R := Rs[i]
        result := R - min
        if max < result {
            max = result
        }
        if min > R {
            min = R
        }
    }

    fmt.Println(max)
    
}


Measured memory_bytes: 9512
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(v-w<=0){
    cout<<"NO"<<"\n";
    return 0;
  }
  if(abs(b-a)<=(v-w)*t)cout<<"YES"<<"\n";
  else cout<<"NO"<<"\n";
}


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

int main()
{
  char s;
  scanf(" %c", &s);
  if(s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u')
    printf("vowel\n");
  else
    printf("consonant\n");
  return 0;
}


Measured memory_bytes: 128
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))

cost, left, right = {}, 0, 0

for i in a:
    cost[i] = True

for i in reversed(range(0, x)):
    left += (1 if i in cost else 0)

for i in range(x, n + 1):
    right += (1 if i in cost else 0)

print(min(left, right))


Measured memory_bytes: 3064
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if ((a*b*c) == 175){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll A[1000];
ll B[1000];
ll row[1000001];
ll column[1000001];
int main() {
	int N, M;
	cin >> N >> M;
	set<int> R, C;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		column[A[i]]++;
		C.insert(A[i]);
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
		row[B[i]]++;
		R.insert(B[i]);
	}
	for (int i = 1; i <= N * M; i++) {
		if (row[i] > 1 || column[i] > 1) {
			cout << 0 << endl;
			return 0;
		}
	}
	for (int i = N * M - 1; i >= 1; i--) {
		row[i] += row[i + 1];
		column[i] += column[i + 1];
	}
	ll ans = 1;
	for (int i = N * M; i >= 1; i--) {
		bool b1 = 0, b2 = 0;
		if (R.find(i) != R.end()) b1 = 1;
		if (C.find(i) != C.end()) b2 = 1;
		if (b1 && b2) continue;
		if (b1) {
			(ans *= column[i]) %= MOD;
		}
		else if (b2) {
			(ans *= row[i]) %= MOD;
		}
		else {
			ll t = row[i];
			(t *= column[i]) %= MOD;
			(t += MOD - (N*M - i)) %= MOD;
			(ans *= t) %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 16000
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;


int main()
{
	
	int n;
	string color;
	cin >> n >> color;
	
	int red = 0;
	int blue = 0;
	for (int i = 0; i < n; i++) {
		if (color[i] == 'R') {
			red++;
		}
		else {
			blue++;
		}
	}
	
	string ans;
	if (red > blue) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;
	return 0;

}

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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}
string s;

int main(){
  cin >> s;
  cin >> s;
  cout << "A";
  cout << s[0];
  cout << "C" << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] str = Console.ReadLine().Split(' ');

            var data = new List<int>();

            for(int i = 0; i < n; i++)
            {
                data.Add(int.Parse(str[i]));
            }

            data.Sort();

            data.Reverse();

            int ans = 0;

            for(int i = 0; i < data.Count; i++)
            {
                if(i % 2 == 0)
                {
                    ans += data[i];
                }
                else
                {
                    ans -= data[i];
                }
            }

            Console.WriteLine(ans);

        }

    }

}
    


Measured memory_bytes: 11092
N, T = map(int, input().split())
c, t = [0] * N, [0] * N
for i in range(N):
    c[i], t[i] = map(int, input().split())

ans = []
for i in range(N):
    if t[i] <= T:
        ans.append(i)
if len(ans) > 0:
    print(min([c[x] for x in ans]))
else:
    print('TLE')

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    // sx = tx 

    int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
    string s = "";
    rep(i,ty-sy) s.push_back('U');
    rep(i,tx-sx) s.push_back('R');
    rep(i,ty-sy) s.push_back('D');
    rep(i,tx-sx+1) s.push_back('L');
    rep(i,ty-sy+1) s.push_back('U');
    rep(i,tx-sx+1) s.push_back('R');
    s.push_back('D');
    s.push_back('R');
    rep(i,ty-sy+1) s.push_back('D');
    rep(i,tx-sx+1) s.push_back('L');
    s.push_back('U');
    cout << s << '\n';
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t a[3], b[3];
    int64_t town[4] = {0};

    scanf("%"PRId64"%"PRId64, &a[0], &b[0]);
    scanf("%"PRId64"%"PRId64, &a[1], &b[1]);
    scanf("%"PRId64"%"PRId64, &a[2], &b[2]);

    town[a[0] - 1] += 1;
    town[a[1] - 1] += 1;
    town[a[2] - 1] += 1;
    town[b[0] - 1] += 1;
    town[b[1] - 1] += 1;
    town[b[2] - 1] += 1;

    if (town[0] < 3 && town[1] < 3 && town[2] < 3 && town[3] < 3) {
        puts("YES");
    } else {
        puts("NO");
    }

    return 0;
}


Measured memory_bytes: 128
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<i64>();
    let mut mi = 0;
    let mut max = 0;
    for i in 0..n {
        if v[i].abs() > max {
            mi = i;
            max = v[i].abs();
        }
    }
    if max == 0 {
        println!("0");
    } else {
        println!("{}", 2 * n - 1);
        for i in 0..n {
            println!("{} {}",mi+1,i+1);
        }
        if v[mi] > 0 {
            for i in 1..n {
                println!("{} {}",i,i+1);
            }
        } else {
            for i in 1..n {
                println!("{} {}",n-i+1,n-i);
            }
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
vector<int> V[maxn];
int main(){
	int n,m;
	int ans = 0;
	cin>>n>>m;
	int v,d;
	for(int i=0;i<n;i++){
		cin>>d>>v;
		if(d<=m){
			V[m-d+1].push_back(v);
		}
	} 
	priority_queue<int> Q; 
	for(int i=m;i>=1;i--){
		if(V[i].size()>0){
			for(int j=0;j<V[i].size();j++){
				Q.push(V[i][j]);
			}
		}
		while(!Q.empty()){
				ans+=Q.top();
				Q.pop();
				break; 
			}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  ll n;
  cin >> n ;
	VI a(n);
  rep(i,n) cin >> a.at(i);
  int m=1;
  int count=0;
  rep(i,n){
    m=a.at(m-1);
    count++;
    if(m==2) break;
  }
  if(m!=2) cout << -1 << endl;
  else cout << count << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

static const int N = 1000;

void trace(int A[], int n){
	int i;
	for (i = 0; i < n; i++){
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

int main(){
	int n, i, j;
	int A[N+1];
	int key;
	scanf("%d", &n);

	for (i = 0; i < n; i++)
		scanf("%d", &A[i]);

	trace(A, n);

	for (i = 1; i < n; i++) {
		key = A[i];
		j = i-1;
		while (j >= 0 && A[j] > key){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = key;
		trace(A, n);
	}


	return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

ll mypow(ll X, ll n) {  // 繰り返し２乗法　計算量log(n)
    if(n == 0) return 1ll;
    ll Y = mypow(X, n/2);
    if(n % 2 == 1) return X * Y % MOD * Y % MOD;
    else return Y * Y % MOD;
}

int main() {
    int n; cin >> n;
    ll res = 0;
    // 最小公倍数は素因数分解した形で、vectorに入れておrく
    vector<pair<int, int>> lcm;
    rp(i, 0, n) {
        int a; cin >> a;
        // 素因数分解して、結果をvectorに入れる
        vector<pair<int, int>> p;
        for(int j = 2; j * j <= a; j++) {
            int c = 0;
            while(a % j == 0) {
                c++; a /= j;
            }
            p.emplace_back(j, c);
        }
        if(a > 1) p.emplace_back(a, 1);

        // lcm, pを順に見ていき、新たな最小公倍数を作りながらresを更新
        vector<pair<int, int>> lcm_new;
        ll b = 1ll;
        int k = 0; int l = 0;
        while(k < (int)lcm.size() or l < (int)p.size()) {
            if(k == (int)lcm.size()) {
                auto x = p[l];
                res *= mypow(x.first, x.second); res %= MOD;
                lcm_new.emplace_back(x);
                l++;
            } else if(l == (int)p.size()) {
                auto x = lcm[k];
                b *= mypow(x.first, x.second); b %= MOD;
                lcm_new.emplace_back(x);
                k++;
            } else {
                auto x = lcm[k]; auto y = p[l];
                if(x.first < y.first) {
                    b *= mypow(x.first, x.second); b %= MOD;
                    lcm_new.emplace_back(x);
                    k++;
                } else if(x.first > y.first) {
                    res *= mypow(y.first, y.second); res %= MOD;
                    lcm_new.emplace_back(y);
                    l++;
                } else {
                    if(x.second < y.second) {
                        res *= mypow(y.first, y.second - x.second); res %= MOD;
                        lcm_new.emplace_back(y);
                    } else {
                        b *= mypow(x.first, x.second - y.second); b %= MOD;
                        lcm_new.emplace_back(x);
                    }
                    k++; l++;
                }
            }
        }
        res += b; res %= MOD;
        lcm = lcm_new;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 500050;
const int K = 20;
int f[N], l[N], r[N], u, n, lm;
string s[N];
void add(int v, int i, int j){
    if (j == s[i].length()) return;
    if (s[i][j] == '0'){
        if (l[v] == 0){
            u++;
            l[v] = u;
            add(l[v], i, j + 1);
        } else{
            add(l[v], i, j + 1);
        }
    } else{
        if (r[v] == 0){
            u++;
            r[v] = u;
            add(r[v], i, j + 1);
        } else{
            add(r[v], i, j + 1);
        }
    }
}
int gr(int x){
    if (x == 0) return 0;
    int y = 1;
    while(y + y <= x) y += y;
    if (y == x) return x;
    return gr(x - y);
}
int solve(int v, int h){
    int L, R;
    if (l[v] == 0) L = gr(h); else L = solve(l[v], h - 1);
    if (r[v] == 0) R = gr(h); else R = solve(r[v], h - 1);
    return (L ^ R);
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> lm;
    u = 1;
    for (int i = 1; i <= n; i++){
        cin >> s[i];
        add(1, i, 0);
    }
    int ans = solve(1, lm);
    if (ans) cout << "Alice"; else cout << "Bob";
}


Measured memory_bytes: 13776
#include <iostream>
using namespace std;
typedef long long ll;
ll inf = 1e9+7;
ll fact[1010] = {0};
ll inv[1010] = {0};

ll mult(ll n, ll m){
    if(m==0) return 1;
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			fact[i] = 1;
			inv[i] = 1;
		}
		else{
			fact[i] = (i*fact[i-1])%inf;
			inv[i] = mult(fact[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(n<k) return 0;
	if(n<0 || k<0) return 0;
	else return (((fact[n]*inv[k])%inf)*inv[n-k])%inf;
}

ll permutation(ll n,ll k){
    return (comb(n,k)*fact[k])%inf;
}

int N,A,B,C,D;
ll dp[1010][1010] = {};

int main(){
    cin >> N >> A >> B >> C >> D;
    factorial(N);
    for(int i=0;i<=B;i++) dp[i][0] = 1;
    ll ans = 0;
    for(int i=A;i<=B;i++){
        for(int j=1;j<=N;j++){
            for(int k=0;k<=D;k++){
                if(j-i*k<0) break;
                if(0<k && k<C) continue;
                ll v = (mult(inv[i],k)*inv[k])%inf;
                ll r = (permutation(N-j+i*k,i*k)*v)%inf;
                (dp[i][j] += (dp[i-1][j-i*k]*r)%inf)%=inf;
            }
        }
    }
    cout << dp[B][N] << endl;
}

Measured memory_bytes: 8192
let () = Scanf.scanf "%d %d\n" @@ fun n m ->
  let count = Array.make n true in
  for i = 0 to m - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      count.(a - 1) <- not count.(a - 1);
      count.(b - 1) <- not count.(b - 1);
  done;
  print_endline @@
  if List.for_all (fun b -> b) @@ Array.to_list count then "YES" else "NO"


Measured memory_bytes: 6272
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
a=list(map(int,input().split()))
cnt=0
maxa=max(a)
while 2**cnt<2*maxa:
    cnt+=1
    # print(2**cnt)

lsta=[0]*n
ans=0
for i in range(1,cnt+1)[::-1]:
    dic=defaultdict(list)
    for j in range(n):
        if 2**i>a[j] and lsta[j]==0:
            if dic[a[j]]!=[]:
                lsta[j]=-1
                lsta[dic[a[j]].pop()]=-1
                ans+=1
            else:
                dic[2**i-a[j]].append(j)
    # print(dic)
# print(lsta)
# ans=-sum(lsta)//2
print(ans)

Measured memory_bytes: 192524
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int a[3], b[3];
    int num_appear[4 + 1] = {};

    for(int i = 0; i < 3; i++){
        cin >> a[i] >> b[i];
        switch (a[i]){
            case 1:
                num_appear[1]++;
                break;
            case 2:
                num_appear[2]++;
                break;
            case 3:
                num_appear[3]++;
                break;
            default:
                num_appear[4]++;
                break;
        }

        switch (b[i]){
            case 1:
                num_appear[1]++;
                break;
            case 2:
                num_appear[2]++;
                break;
            case 3:
                num_appear[3]++;
                break;
            default:
                num_appear[4]++;
                break;
        }
    }

    int num1 = 0, num2 = 0;
    for(int i = 1; i < 4 + 1; i++){
        if(num_appear[i] == 1){
            num1++;
        }else if(num_appear[i] == 2){
            num2++;
        }
    }

    string ans = (num1 == 2 && num2 == 2)? "YES" : "NO";

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

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

int stack[102];
int top;
char b[2000];


int main(){

  int n1,n2;
  char *p;


  fgets(p=b, 500, stdin);
  top=0;

  while(*p>=' '){
    while(isspace(*p))p++;
    if(isdigit(*p)){
      n1=0;
      while(isdigit(*p)) n1=10*n1+(*p++ & 0xf);
      stack[top++] = n1;
    }

    else{
      n1=stack[--top];
      n2=stack[--top];
      if (*p=='+') n2+=n1;
      else if(*p=='-')n2-=n1;
      else if(*p=='*')n2*=n1;
      stack[top++]=n2;
      p++;
	}
  }

  printf("%d\n",stack[--top]);
  return 0;
}
  



Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
struct P{
    int year,base;
    string name;
   
    bool operator < (const P &a)const{
	if(year != a.year){
	    return year < a.year;
	}
	else{
	    return base < a.base;
	}
    }
 
    P(int y = 0,int b = 0,string s = "") : year(y),base(b),name(s){}
 
};
 
int main(){
    int N,Q,b,y;
    string str;
 
 
    while(cin >> N >> Q){
	vector<P> v;
 
	for(int i = 0 ; i < N ; i++){
	    cin >> str >> b >> y;
	    v.push_back(P(y,b,str));
	}
 
	sort(v.begin(),v.end());
 
	int in;
 
	for(int i = 0 ; i < Q ; i++){
	    bool found = false;
 
	    cin >> in;
	    for(int j = 0 ; j < N ; j++){
		if(in <= v[j].year){ 
		    if(v[j].year-v[j].base < in){
			cout << v[j].name << " " << in-(v[j].year-v[j].base) << endl;
			found = true;
			break;
		    }
		}
	    }
	    if(!found) cout << "Unknown" << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3216
#include<stdio.h>
#include<math.h>

int main(void){
	
	int n,i;
	int max,min;
	int readed,ans;
	int avg = 0;
	
	while(1){
		
		scanf(" %d",&n);
		
		max = 0;
		min = 2000;
		
		if(n==0){
			break;
		}
		
		for(i = 0;i < n;i++){
			
			scanf(" %d",&readed);
			
			if(max < readed){
				max = readed;
			}
			
			if(min > readed){
				min = readed;
			}
			
			avg += readed;
		}
		
		avg -= max + min;
		
		avg /= n - 2;
		
		printf("%d\n",avg);
		
		avg = 0;
		
	}
	
	return(0);
	
}

Measured memory_bytes: 596
#include<iostream>

using namespace std;

int main() {
    int N, K;

    cin >> N >> K;

    int h;

    int count = 0;

    for(int i = 0; i < N; i++) {
        cin >> h;
        if(K <= h) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, A, B, C, D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  S = '#' + S + '#';
  bool fail_A = false;
  for (int i = A; i + 1 <= C; i++) {
    if (S[i] == '#' && S[i + 1] == '#') {
      fail_A = true;
      break;
    }
  }
  bool fail_B = false;
  for (int i = B; i + 1 <= D; i++) {
    if (i < N - 1 && S[i] == '#' && S[i + 1] == '#') {
      fail_B = true;
      break;
    }
  }
  if (fail_A || fail_B) {
    cout << "No" << endl;
    return 0;
  }
  if (C < D) {
    cout << "Yes" << endl;
    return 0;
  }
  if (D < C) {
    bool fail = true;
    for (int i = B; i <= D; i++) {
      if (S[i - 1] == '.' && S[i] == '.' && S[i + 1] == '.') {
        fail = false;
        break;
      }
    }
    if (fail) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3924
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n-1)]
l2=[list(map(int,input().split())) for i in range(q)]
connection=[[] for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
L4=[0 for i in range(n)]
for i in range(q):
  L4[l2[i][0]-1]+=l2[i][1]
distance=[0 for i in range(n)]
distance[0]=L4[0]

L=[0]
L2=[]
L3=[]
while len(L2)!=n and len(L)!=0:
  for j in range(len(L)):
    for k in range(len(connection[L[j]])):
      distance[connection[L[j]][k]]=distance[L[j]]+L4[connection[L[j]][k]]
      L3.append(connection[L[j]][k])
    L2.append(L[j])
  L=L3
  L3=[]
for i in range(len(distance)):
  distance[i]=str(distance[i])
print(' '.join(distance))

Measured memory_bytes: 154156
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
    }

    vector<ll> v1, v2, v3, v4;
    v1.push_back(v[0]);
    for (ll i = 1; i < n; i++)
    {
        ll tmp = w[i] - w[0];
        if (tmp == 0)
        {
            v1.push_back(v[i]);
        }
        else if (tmp == 1)
        {
            v2.push_back(v[i]);
        }
        else if (tmp == 2)
        {
            v3.push_back(v[i]);
        }
        else
        {
            v4.push_back(v[i]);
        }
    }
    sort(v1.begin(), v1.end(), greater<>());
    sort(v2.begin(), v2.end(), greater<>());
    sort(v3.begin(), v3.end(), greater<>());
    sort(v4.begin(), v4.end(), greater<>());

    for (ll i = 0; i < (ll)v1.size(); i++)
    {
        if (i + 1 == (ll)v1.size())
        {
            continue;
        }
        v1[i + 1] += v1[i];
    }
    for (ll i = 0; i < (ll)v2.size(); i++)
    {
        if (i + 1 == (ll)v2.size())
        {
            continue;
        }
        v2[i + 1] += v2[i];
    }
    for (ll i = 0; i < (ll)v3.size(); i++)
    {
        if (i + 1 == (ll)v3.size())
        {
            continue;
        }
        v3[i + 1] += v3[i];
    }
    for (ll i = 0; i < (ll)v4.size(); i++)
    {
        if (i + 1 == (ll)v4.size())
        {
            continue;
        }
        v4[i + 1] += v4[i];
    }

    v1.insert(v1.begin(), 0);
    v2.insert(v2.begin(), 0);
    v3.insert(v3.begin(), 0);
    v4.insert(v4.begin(), 0);

    ll ans = 0;

    for (ll i = 0; i < (ll)v1.size(); i++)
    {
        for (ll j = 0; j < (ll)v2.size(); j++)
        {
            for (ll k = 0; k < (ll)v3.size(); k++)
            {
                for (ll l = 0; l < (ll)v4.size(); l++)
                {
                    if (i * w[0] + j * (w[0] + 1) + k * (w[0] + 2) + l * (w[0] + 3) <= W)
                    {
                        chmax(ans, v1[i] + v2[j] + v3[k] + v4[l]);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
from collections import deque

n,q = map(int,input().split())
q_list = []
for i in range(n):
    q_list.append(list())

for i in range(q):
    l = list(stdin.readline().split())
    l[1] = int(l[1])
    if l[0] == '0':
        q_list[l[1]].append(l[2])
    elif l[0] == '1':
        print(' '.join(q_list[l[1]]))
    else:
        q_list[l[1]].clear()






Measured memory_bytes: 44384
#include <cstdio>
#include <vector>
#include <utility>
using std::printf;
using std::scanf;
using std::pair;
using std::vector;
 
typedef pair<int,int> pii;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
 
// fenwick tree
const int N = 125252;
int dat[N+1];
void add(int x,int v){
  while(x<=N){
    dat[x]+=v;
    x+=x&-x;
  }
}
int sum(int x){
  int ret = 0;
  while(x){
    ret+=dat[x];
    x-=x&-x;
  }
  return ret;
}
 
int n,m;
vector<pii> lens[125252];
 
int main(){
  scanf("%d%d",&n,&m);
  REP(i,n){
    int l,r;
    scanf("%d%d",&l,&r);
    r++;
    lens[r-l].push_back(pii(l,r));
  }
  printf("%d\n",n);
  int rest = n;
  FOR(d,2,m+1){
    // len==d-1
    for(pii P : lens[d-1]){
      add(P.first,1);
      add(P.second,-1);
      rest--;
    }
    int ans = rest;
    int it = d;
    while(it<=m){
      ans += sum(it);
      it += d;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    
    cout<<(a-b+1)*(a-c+1)<<endl;
}
//＼(^q^)／ｵﾜﾀ


Measured memory_bytes: 256
S = input()
A = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
B = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
if A.count(S)>B.count(S):
    print("A")
else:
    print("a")

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

using namespace std;
using ll = long long;
int main() {
	ll n;
	cin >> n;
	ll x = 1, y = 1;
	for (int i = 0; i < n; i++) {
		ll t, a;
		cin >> t >> a;
		ll s = (x + t - 1) / t;
		ll v = (y + a - 1) / a;
		ll m = max(s, v);
		x = m*t;
		y = m*a;
	}
	cout << x + y << endl;
	return 0;
}

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

int main()
{
  int D, N, p;
  cin >> N >> D;
  if (N % (2 * D + 1) == 0) {
    p = N / (2 * D + 1);
  }
  else {
    p = N / (2 * D + 1) + 1;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from decimal import Decimal
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


A,B = LS()
print(int(Decimal(A)*Decimal(B)))

Measured memory_bytes: 27304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		sc.close();
		int cnt=0;
		for(int i=0;i<n.length();i++) {
			if(n.substring(i,i+1).equals("2")) {
				cnt++;
			}
		}
		System.out.println(cnt);

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 int main()
 {
    ll int n,i,k;
    cin>>n>>k;
    ll int ar[n];
    for(i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    ll int dp[n];
    dp[0]=0;
    ll j,minn,temp,count;
    for(i=1;i<n;i++)
    {
        j=i-1;
        minn=INT_MAX;
        for(count=0;count<k;count++)
        {
            if(j<0)
                break;
            temp=dp[j]+abs(ar[i]-ar[j]);
            if(temp<minn)
                minn=temp;
            j--;
        }
        dp[i]=minn;
        //cout<<dp[i]<<" ";
    }
    //cout<<endl;
    cout<<dp[n-1];
 }

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int data[] = new int[n];
        for(int i=0; i<n; i++) data[i]=sc.nextInt();
        
        for(int i=n-1; i>0; i--) System.out.printf("%d ",data[i]);
        System.out.printf("%d\n",data[0]);
        sc.close();
    }
}


Measured memory_bytes: 26416