akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.math.*;


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     static int dx[]={1,-1,0,0};
       static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

    //  int n=sc.nextInt();  
     int n=sc.nextInt();
     int d[][] = new int[n][10001];
     int s[] = new int[n], ans=0;
     for( int i=0; i<n; i++ ) s[i] =  sc.nextInt();
        d[0][s[0]]++;
        for( int i=1; i<n; i++ ){
            for( int t=0; t+s[i]<10001; t++ ){
                if(t==0 || d[i-1][t] > 0)d[i][t+s[i]]++;
            }
            for( int t=0; t<10001; t++ )d[i][t]+=d[i-1][t];
        }
            for( int t=0; t<10001; t++ )if(t %10 >0 && d[n-1][t]>0)ans=max(ans,t);


    out.println(ans);
    out.flush();
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}


class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



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


int main(){
  int64_t a,b;
  cin >> a >> b;
  vector<vector<int>> grid(100,vector<int>(100));
  rep(i,50){
    rep(j,100){
      grid[i][j] = 1;
    }
  }
  rep(i,a-1){
    int64_t y = (i/50)*2;
    int64_t x = (i%50)*2;
    grid[y][x] = 0;
  }
  rep(i,b-1){
    int64_t y = (49-(i/50))*2;
    int64_t x = (i%50)*2;
    grid[y][x] = 1;
  }
  cout << 100 << " " << 100 << endl;
  rep(i,100){
    rep(j,100){
      if(grid[i][j]){
        cout << '#';
      }else{
        cout << '.';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split(" "))
shops = [list(map(int, input().split(" "))) for _ in range(N)]

remained = M
cost = 0
shops = sorted(shops, key=lambda x: x[0])
for s in shops:
    cost += min(s[1], remained) * s[0]
    remained -= s[1]
    if remained <= 0:
        break
print(cost)

Measured memory_bytes: 29728
from collections import Counter

n = int(input())
vs = input().split()
even = []
odd = []

if len(list(set(vs))) == 1:
  res = int(len(vs) / 2)
else:
  for i, v in enumerate(vs):
    if i % 2 == 0:
      even.append(int(v))
    else:
      odd.append(int(v))
  counter_even = Counter(even)
  counter_odd = Counter(odd)
  if counter_even.most_common()[0][0] != counter_odd.most_common()[0][0]:
    res = len(even) - counter_even.most_common()[0][1]  + len(odd) - counter_odd.most_common()[0][1]
  else:
    res1 = len(even) - counter_even.most_common()[1][1]  + len(odd) - counter_odd.most_common()[0][1]
    res2 = len(even) - counter_even.most_common()[0][1]  + len(odd) - counter_odd.most_common()[1][1]
    res = min(res1, res2)
print(res)

Measured memory_bytes: 26092
//template
import java.util.*;
import java.util.stream.*;
import java.io.*;
public class Main{
	static BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out= new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	
	private static final int HUNDRED = 100;
	public static void main(String[] args) throws IOException{
		
		String s=in.readLine();
		long n=Long.parseLong(s);
		long se=0;
		for(int i=0;i<s.length();i++) {
			se+=Long.parseLong(s.charAt(i)+"");
		}
		if(n%se==0) out.append("Yes");
		else out.append("No");
		
		out.flush();
		in.close();
		out.close();
	}
	private static int modulo(int S, int N) { return ((S) & (N - 1)); } // returns S % N, where N is a power of 2
	private static int isPowerOfTwo(int S) { return (S & (S - 1)) == 0 ? 1 : 0; }
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}
	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}
	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}
	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}
	 
}
class Team{
	int id;
	LinkedList<Team> weekAdj;
	LinkedList<Team> strongAdj;
	public Team(int id) {
		this.id=id;
		weekAdj=new LinkedList<Team>();
		strongAdj=new LinkedList<Team>();
	}
	public void add(Team team) {
		if(weekAdj.remove(team))
			strongAdj.add(team);
		else
			weekAdj.add(team);
	}
}

Measured memory_bytes: 36820
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	cout << int(pow(n, 3)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

int b(void);
int c(void);
int d(void);

int main(void) {
	d();
	return 0;
}

int d(void) {
	double pi = 3.14159265;
	double a, b, x;
	std::cin >> a >> b >> x;
	double angle;
	if (x > a * a * b / 2) {
		double c = 2 * (b - (x / (a*a)));
		
		double temp =  std::sqrt(c * c + a * a);
		angle = 180.0 * (std::asin((1 / std::sqrt(1 + (a*a) /(c*c))))) / pi;
	}
	else if (x < a * a * b / 2) {
		double c = (2 * x / (a*b));
		
		angle = 90.0 - 180.0 * (std::asin((1 / std::sqrt(1 + b * b / (c*c))))/pi);
	}
	else {
		angle = 45.0000000;
		
	}
	std::cout.precision(10);
	std::cout << angle;
	return 0;
}

int c(void) {
	long long int N;
	std::cin >> N;
	long long int up_b = static_cast<long long int>(std::sqrt(N));
	long long int max_i = 0;
	for (int i = up_b; i > 0; i--) {
		if (N % i == 0) {
			max_i = i;
			break;
		}
	
	}
	std::cout << max_i << std::endl;
	std::cout << N / max_i << std::endl;
	std::cout << max_i + (N / max_i) -2;
	return 0;
}

int b(void) {
	int N;
	std::cin >> N;
	if (N > 81) {
		std::cout << "No";
		return 0;
	}
	else {
		for (int i = 1; i < 10; i++) {
			if (N % i == 0 && N / i < 10) {
				
				std::cout << "Yes";
				return 0;
			}
		}
	}
	std::cout << "No";
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
shop=[[int(x) for x in input().split()] for j in range(N)]

shop_s=sorted(shop)
count=0
used_money=0

for s in shop_s:
    for i in range(s[1]):
        if(M!=count and s[1]!=0):#買った数がMに達していない && 在庫が０ではない
            s[1]-=1
            count+=1
            used_money += s[0]
        else:
            break
    if  count == M:
        break
print(used_money)

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

int n,q;
string s;
char t[200005],d[200005];
int poz[2];

int ok(int i,int p){

    for(int j=1;j<=q;j++)
        if(s[i]==t[j]){

            if(d[j]=='R') ++i;
            else --i;

            if(i==-1)
                return p;
            else if(i==n)
                return 1-p;

        }

    return 0;

}

int main(){

    cin>>n>>q>>s;
    for(int i=1;i<=q;i++)
        cin>>t[i]>>d[i];

    for(int p=1;p>=0;p--){

        int s,d,m;

        s=0;
        d=n-1;

        while(d-s>1){

            m=(s+d)/2;

            if(ok(m,p)) {

                s=p*m+(1-p)*s;
                d=(1-p)*m+p*d;

            }
            else {

                s=(1-p)*m+p*s;
                d=p*m+(1-p)*d;

            }

        }

        if(ok(p*d+(1-p)*s,p))
            poz[p]=p*d+(1-p)*s;
        else if(ok((1-p)*d+p*s,p))
            poz[p]=(1-p)*d+p*s;
        else poz[p]=p*(-1)+(1-p)*n;

    }

    poz[0]=n-poz[0];
    poz[1]++;

    cout<<n-poz[0]-poz[1];

}


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

const int N = 3e5 + 9;

int32_t main()
{
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes\n"; else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

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

    int S, W;
    cin >> S >> W;
    if (W >= S) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N, A;
    cin >> N;
    set<int> s;
    REP(i, N){
        cin >> A;
        if(s.find(A) == s.end()){
            s.insert(A);
        }else{
            s.erase(A);
        }
    }

    cout << s.size();
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>

using namespace std;

int main(){
  int n; cin >> n;
  vector<long long> a,b;
  for(int i = 0; i < n; i++){
    int t;
    cin >> t;
    a.push_back(t);
    b.push_back(t);
  }
  sort(a.begin(), a.end(), greater<long long>());
  sort(b.begin(), b.end(), greater<long long >());
  int w = n-1;
  for(int i = 1; i < a.size(); i++){
    if(a[i] <= 0){
      w = i;
      break;
    }
  }
  for(int i = 1; i < b.size()-1 && i < w; i++){
    b[n-1] = b[n-1] - b[i];
  }
  for(int i = w ; i < b.size() ; i++){
    b[0] -= b[i];
  }
  cout << b[0] << endl;

  for(int i = 1; i < a.size()-1 && i < w; i++){
    cout << a[n-1] << " " << a[i] << endl;
    a[n-1] = a[n-1] - a[i];
  }
  for(int i = w ; i < a.size() ; i++){
    cout << a[0] << " " << a[i] << endl;
    a[0] -= a[i];
  }
}


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

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    //! rotation matrix is
    //!   cos Pi/2 -sin Pi/2
    //!   sin Pi/2 cos Pi/2
    //! that is
    //!   0 -1
    //!   1 0
    //! therefore
    //!   nextVx = 0 * vx - 1 * vy = -vy
    //!   nextVy = 1 * vx + 0 * vy =  vx

    int vx = x2 - x1;
    int vy = y2 - y1;

    int nextVx = -vy;
    int nextVy = vx;
    vx = nextVx;
    vy = nextVy;

    int x3 = x2 + vx;
    int y3 = y2 + vy;

    nextVx = -vy;
    nextVy = vx;
    vx = nextVx;
    vy = nextVy;

    int x4 = x3 + vx;
    int y4 = y3 + vy;

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n,ok;
int main()
{
    cin>>n;
    while (n)
    {
        if (n%10==7)
        {
            cout<<"Yes";
            ok=1;
            return 0;
        }
        n=n/10;
    }
    if (!ok)
        cout<<"No";
}


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

#define M 1000
#define mod 1000000007

string mat[M];
int H,W,dp[M][M];

inline int sol (int i, int j)
{
	if(i==H-1 && j==W-1) return dp[i][j]=1;
	if(i>=H || j>=W) return 0;
	
	if(mat[i][j]=='#') return dp[i][j]=0;
	if(dp[i][j]!=-1) return dp[i][j];
	
	return dp[i][j]= ( (sol(i+1,j)%mod) + (sol(i,j+1)%mod) ) %mod;
}


int main ()
{
	cin >> H >> W;
	for(int i=0; i<H; i++) cin >> mat[i];
	for(int i=0; i<M; i++) for(int j=0; j<M; j++) dp[i][j]=-1;
	cout << sol(0,0);
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n,a,b,c,d;cin >> n >> a >> b >> c >> d;
    a--,b--,c--,d--;
    string s;cin >> s;
    if(a<b&&d<c){
        for (int i = a; i < c-1; i++) {
            if(s[i]=='#'&&s[i+1]=='#'){
                puts("No");
                return 0;
            }
        }
        bool f=false;
        for (int i = b; i < d-1; i++) {
            if(s[i]=='#'&&s[i+1]=='#'){
                puts("No");
                return 0;
            }
        }
        for (int i = b-1; i <= d-1; i++) {
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.') f=true;
        }
        if(!f){
            puts("No");
            return 0;
        }
    }
    else{
        for (int i = a; i < c-1; i++) {
            if(s[i]=='#'&&s[i+1]=='#'){
                puts("No");
                return 0;
            }
        }
        for (int i = b; i < d-1; i++) {
            if(s[i]=='#'&&s[i+1]=='#'){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

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

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
/*		FastScanner sc = new FastScanner("6 6 \r\n" +
				"..#..#\r\n" +
				"......\r\n" +
				"#..#..\r\n" +
				"......\r\n" +
				".#....\r\n" +
				"....#.");*/
    	//FastScanner sc = new FastScanner("1000000000000");
		//long n = Long.parseLong(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		PrintWriter out = new PrintWriter(System.out);
		//for(long i = 1; i < n; i++)
		//{
		//	if(n/i==n%i)
		//	{
		//		out.println(n + ":" + i + ":" + n/i + ":" + n%i+":"+ (n/(n%i)-1));
		//	}
		//}
		int ans;
		if(a <=5)
		{
			ans = 0;
		}
		else if (a <= 12)
		{
			ans = b/2;
		}
		else
		{
			ans = b;
		}

//N=(N%M)*M
//a=N%M
//a+Ma=N =1+M=N/a

		out.println(ans);
		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }

}

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

struct node{
    int value;
    node *p,*l,*r;
};

node *root, *NIL;

void insert(int value){
    node *y, *x;
    y = NIL;
    x = root;
    node *n = (node *)malloc(sizeof(node));
    n->value = value;
    n->l = n->r = NIL;
    while(x != NIL){
        y = x;
        if(n->value < x->value)
            x = x->l;
        else
            x = x->r;
    }
    n->p = y;
    if(y == NIL) root = n;
    else{
        //x = n;
        if(n->value < y->value) y->l = n;
        else y->r = n;
    }
}


void Preorder(node *u){
    if(u==NIL) return;
    printf(" %d",u->value);
    Preorder(u->l);
    Preorder(u->r);
}

void Inorder(node *u){
    if(u==NIL) return;
    Inorder(u->l);
    printf(" %d",u->value);
    Inorder(u->r);
}

void print(){
    Inorder(root);
    printf("\n");
    Preorder(root);
    printf("\n");
}

void find(int value){
    node *x = root;
    while(x != NIL){
        if(value == x->value){
            printf("yes\n");
            return;
        }
        else{
            if(value<x->value){
                x = x->l;
            }
            else x = x->r;
        }
    }
    printf("no\n");
    return;
}

node* findNode(int value){
    node *x = root;
    while(x != NIL){
        if(value == x->value){
            return x;
        }
        else{
            if(value<x->value){
                x = x->l;
            }
            else x = x->r;
        }
    }
    return x;
}

node* getSuccessor(node *n){
    if(n->r != NIL){
        n = n->r;
        while(n->l != NIL){
            n = n->l;
        }
    }
    return n;
}

void deletenode(node *n){
    node *y, *x;
    if(n->l==NIL || n->r==NIL){
        y = n;
    }
    else{
        y = getSuccessor(n);
    }
    // determine which child node of y will be connect to y parent
    if(y->l!=NIL) x = y->l;
    else x = y->r;
    // change child's parent
    if(x!=NIL) x->p = y->p;
    // change parent's child
    if(y->p == NIL) root = x;
    else if(y == y->p->l) y->p->l = x;
    else y->p->r = x;
    //
    if(y != n) n->value = y->value;

    free(y);
}


int main(){
    int n, value;
    scanf("%d",&n);
    root = (node *)malloc(sizeof(node));
    root = NIL;
    //root->l = root->r = NIL;
    string cmd;
    for(int i=0;i<n;++i){
        cin >> cmd;
        if(cmd == "insert"){
            scanf("%d",&value);
            insert(value);
        }
        else if(cmd == "print"){
            print();
        }
        else if(cmd == "find"){
            scanf("%d",&value);
            find(value);
        }
        else if(cmd == "delete"){
            scanf("%d",&value);
            deletenode(findNode(value));
        }
    }
    return 0;
}



Measured memory_bytes: 21956
from math import factorial
from collections import Counter

def primes(n):
    a = [0] * (n + 1)
    a[0] = 1
    a[1] = 1
    i = 2
    while n // i >= i:
        if a[i] != 0:
            i += 1
            continue
        j = 2 * i
        while j <= n:
            a[j] = 1
            j += i
        i += 1
    for i, ai in enumerate(a):
        if ai == 0:
            yield i


n = int(input())
f = factorial(n)
counter = Counter()

while f > 1:
    for p in primes(n):
        if f % p == 0:
            counter[p] += 1
            f = f // p

ans = 1
for val in counter.values():
    ans *= (val + 1)

print(ans % (10**9 + 7))

Measured memory_bytes: 3316
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N, Q = map(int, input().split())
    S = input()
    CNT = [0] * (N+1)

    for i in range(2,N+1):
        CNT[i] = CNT[i-1]
        if S[i-2] == "A" and S[i-1] == "C":
            CNT[i] += 1

    for i in range(Q):
        a, b = map(int, input().split())
        print(CNT[b]-CNT[a])


if __name__ == '__main__':
    main()


Measured memory_bytes: 52824
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    string s,t1 = "dream",t2 = "dreamer",t3 = "erase",t4 = "eraser";
    cin >> s;
    while (1) {
        if (s.substr(0,5) == "dream") {
            s.erase(s.begin(), s.begin()+5);
            if(s.substr(0,5) == "erase"){
                s.erase(s.begin(), s.begin()+5);
                if (s[0] == 'r') {
                    s.erase(s.begin(), s.begin()+1);
                }
            }else if(s[0] == 'e' && s[1] == 'r'){
                s.erase(s.begin(), s.begin()+2);
            }
        }else if(s.substr(0,5) == "erase"){
            s.erase(s.begin(), s.begin()+5);
            if (s[0] == 'r') {
                s.erase(s.begin(), s.begin()+1);
            }
        }else{
            break;
        }
    }
    if (s.size() == 0) {
        YES;
    }else{
        NO;
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  while(true)
  {
    int n,x;
    cin>>n>>x;
    if(n==0&&x==0) break;
    int cnt=0;
    for (int i = 1; i <= n; ++i)
    {
      for (int j = i+1; j <= n; ++j)
      {
        for (int k = j+1; k <= n; ++k)
        {
          if(i+j+k==x) cnt++;
        }
      }
    }
    cout<<cnt<<endl;
  }
  

}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main() {
    int K, A, B;

    cin >> K >> A >> B;

    for(int i = A; i <= B; i++) {
        if(i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
using System.Linq;
using System.Text;
using System;
public class Program
{
    public static void Main()
    {
        int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        string ans = "Impossible";
        if (n[0] % 3 == 0 || n[1] % 3 == 0 || (n[0] + n[1]) % 3 == 0)
        {
            ans = "Possible";
        }
        Console.WriteLine(ans);
    }
}

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

int main()
{
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e;
if(a<40){
a=40;
}
if(b<40){
b=40;
}
if(c<40){
c=40;
}
if(d<40){
d=40;
}
if(e<40){
e=40;
}
f=(a+b+c+d+e)/5;
cout<<f<<'\n';
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0<<endl;
    else
        cout<<10<<endl;
    
}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int n, ac = 0, wa = 0, tle = 0, re = 0;
  cin >> n;
 
  for (int i = 0; i < n; i++){
    cin >> s;
    if (s == "AC") ac++;
    if (s == "WA") wa++;
    if (s == "TLE") tle++;
    if (s == "RE") re++;
  }
  cout << "AC x "  << ac << endl;
  cout << "WA x "  << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x "  << re << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
    double a, b, C;
    cin >> a >> b >> C;
    C = C  * M_PI / 180;

    double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C));
    double S = a * b * sin(C) / 2;
    double h = b * sin(C);

    printf("%.6f\n%.6f\n%.6f\n", S, L, h);

    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
int a,c,d;
char s[123456];
int main(){
    while(cin>>s[a]){
        a++;
    }
    for(int i=0;i<a;i++){
        if((i%2)==0){
            if(s[i]!='0')c++;
        }
        else{
            if(s[i]!='1')c++;
        }
    }
    for(int i=0;i<a;i++){
        if((i%2)==0){
            if(s[i]!='1')d++;
        }
        else{
            if(s[i]!='0')d++;
        }
    }
    if(c<d)cout<<c<<endl;
    else cout<<d<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>


int main()
{
  int a,b,c;
  int wk;
  int dt[3];

  scanf("%d %d %d",&a,&b,&c);
  dt[0] = a;
  dt[1] = b;
  dt[2] = c;

  if (dt[0] > dt[1]) {
	wk = dt[0];
    dt[0] = dt[1];
    dt[1] = wk;
  }
  if (dt[0] > dt[2]) {
	wk = dt[0];
    dt[0] = dt[2];
    dt[2] = wk;
  }
  if (dt[1] > dt[2]) {
	wk = dt[1];
    dt[1] = dt[2];
    dt[2] = wk;
  }
  printf("%d %d %d\n",dt[0],dt[1],dt[2]);
  return 0;
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORR(i,n,a) for(int i=(n); i>=(a); i--)
#define REPR(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;


int main() {
	string s;
	cin >> s;
	int n = s.length();

	V<int> r;
	V<int> l;

	char now = 'R';
	REP(i,n) {
		if (s[i] != now) {
			if(now == 'R') {
				r.push_back(i-1);
				now = s[i];
			} else {
				l.push_back(i-1);
				now = s[i];
			}
		}
	}
	l.push_back(n-1);


	int a,b;
	a = r[0]+1;
	b= l[0]-r[0];
	REP(i,a-1) {
		cout << 0 << " ";
	}
	cout << b/2 + a-(a/2) << " ";
	cout << a/2 + b-(b/2) << " ";
	REP(i,b-1) {
		cout << 0 << " ";
	}

	FOR(i,1,r.size()) {
		a = r[i]-l[i-1];
		b= l[i]-r[i];
		REP(i,a-1) {
			cout << 0 << " ";
		}
		cout << b/2 + a-(a/2) << " ";
		cout << a/2 + b-(b/2) << " ";
		REP(i,b-1) {
			cout << 0 << " ";
		}
	}
	cout << endl;

}



Measured memory_bytes: 1148
a, b, c, d = input()
sign = "+-"
for i in range(2):
        for j in range(2):
                for k in range(2):
                        if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                                print(a+sign[i]+b+sign[j]+c+sign[k]+d + "=7")
                                exit()

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

using namespace std;

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

    vector<int> an;
    for (int i=0;i<n;i++) {
        int a; cin >> a;
        an.push_back(a);
    }
    sort(an.begin(), an.end(), greater<int>());

    int alice=0, bob=0;
    for (int i=0;i<n;i++) {
        if (i%2==0) {
            alice += an[i];
        } else {
            bob += an[i];
        }
    }

    cout << alice - bob << endl;

    return 0;
}

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

using namespace std;

#define x first
#define y second
typedef long long ll;
const int N = 100010;
const int mod = 1000000007;
const int oo = 1e9;
const int base = 27;
typedef pair<int,int> pii;

int n , k,v[N];
pii up[N],dw[N];
vector<int> g[N];


void pull(int u,int par){
  dw[u] = make_pair(-oo,oo);
  if(v[u] != -1)dw[u] = make_pair(v[u],v[u]);
  for(auto v : g[u]){
    if(v == par)continue;
    pull(v,u);
    dw[u].first = max(dw[u].first,dw[v].first-1);
    dw[u].second = min(dw[u].second,dw[v].second+1);
  }
}
void push(int u , int par){
  up[u] = make_pair(-oo,oo);
  if(par != -1)up[u] = make_pair(up[par].first-1,up[par].second+1);
  up[u] = make_pair(max(up[u].first,dw[u].first),min(up[u].second,dw[u].second));
  if(v[u] != -1)up[u] = make_pair(v[u],v[u]);
  for(auto v : g[u]){
    if(v == par)continue;
    push(v,u);
  }
}
bool check(){
  for (int i = 1; i <= n; ++i)
    for(auto x : g[i])
      if(abs(v[x] - v[i]) != 1)return false; 
  return true;
}
int main() {
  memset(v,-1,sizeof v);
  cin >> n;
  for (int a,b,i = 0; i < n-1; ++i){
    scanf("%d%d",&a,&b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  cin >> k;
  int a = 0;
  for (int i = 0; i < k; ++i){
    scanf("%d",&a);
    scanf("%d",&v[a]);
  }
  pull(a,-1);
  push(a,-1);
  for(int i = 1;i <= n ; ++i)v[i] = up[i].second;
  if(!check()){
    puts("No");
    return 0;
  }
  puts("Yes");
  for(int i = 1; i <= n ; ++i){
    printf("%d\n", v[i]);
  }
  return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c){
    cout<<1;
    }else{
        cout<<0;
    }

}

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

using ll = long long;

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)

using namespace std;

//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);
 

void solve() {
    int N, A;
    cin >> N >> A;
    int ans = N*N-A;
    cout << ans << endl;
}
 
int main() {
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

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

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

  ll ans = 0;
  // i個選ぶ
  for (ll i = k; i <= n + 1; i++) {
    ll min = i * (i - 1) / 2;
    ll max = (n + 1) * n / 2 - (n + 1 - i) * (n - i) / 2;
    ans += (max - min + 1) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int k;
    cin >> k;
    string s;
    cin >>s;
    int n=s.size();
    if(n<=k) cout << s << endl;
    else{
        cout << s.substr(0,k) << "..." << endl;
    }
}


Measured memory_bytes: 3628
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,k,a[262144];
    int sg=0,db=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){scanf("%d",&a[i]);
        if(a[i]%4==0){db++;}
        else if(a[i]%2==0){sg++;}
    }
    if(n<=max(sg+2*db,2*db+1)){printf("Yes\n");}else{printf("No\n");}
    return 0;
}

Measured memory_bytes: 512
W,H,N=map(int,input().split())
l=0;r=W;d=0;u=H
for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        l=max(l,x)
    elif a==2:
        r=min(r,x)
    elif a==3:
        d=max(d,y)
    elif a==4:
        u=min(u,y)
print(max(r-l,0)*max(u-d,0))        

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    string A,B,C;
    cin >> A >> B >> C;
    int a=A.size(),b=B.size(),c=C.size();
    char x='a';
    while(true){
        if(x=='a'){
            if(a==0){
                cout << "A" << endl;
                return 0;
            }
            x=A[A.size()-a];
            a--;
        }
        else if(x=='b'){
            if(b==0){
                cout << "B" << endl;
                return 0;
            }
            x=B[B.size()-b];
            b--;
        }
        else{
            if(c==0){
                cout << "C" << endl;
                return 0;
            }
            x=C[C.size()-c];
            c--;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
#define llong long long
int Q;
llong f[110];
llong n,m;
llong a,b;
void calc(int i)
{
	if(!i)return;
	llong ta=a*f[i]+b*f[i-1];
	llong tb=a*f[i+1]+b*f[i];
	a=ta;b=tb;
}
int main()
{
//	freopen("fibo.in","r",stdin);
//	freopen("fibo.out","w",stdout);
	f[0]=f[1]=1;
	for(int i=2;i<=88;++i)f[i]=f[i-1]+f[i-2];
	scanf("%d",&Q);
	int ans;
while(Q--)
{
	scanf("%lld%lld",&n,&m);
	if(n>m)swap(n,m);
	if(n==1)
	{
		printf("%d %lld\n",1,m%mod);
		continue;
	}
	if(n==2&&m==2)
	{
		puts("1 4");
		continue;
	}
	for(int k=87;k>=0;--k)
		if(m>=f[k+1]&&n>=f[k])
		{
			ans=k;
			break;
		}
	printf("%d ",ans);
	llong res=0;
	for(int i=1;i<=ans;++i)
	{
		a=f[i],b=f[i+1];
		calc(ans-i);
		if(a<=n&&b<=m)
		{
			res+=(m-b)/a+1;
			res%=mod;
			if(b<=n)res+=(m-a)/b+1;
			res%=mod;
		}
	}
	printf("%lld\n",res);
}
	return 0;
}


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

int main(){
    int N; cin >> N;
    int a[N][3];
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }

    long long dp[N+1][3]={};
    int acty=10;
    int actt=0;
    int tmp=0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k) continue;
                tmp=dp[i][j]+a[i][k];
                if(dp[i+1][k]<tmp){
                    dp[i+1][k]=tmp;
                }    
            }
            
        }
        acty=actt;
    }

    long long res;
    
    cout << std::max({dp[N][0], dp[N][1], dp[N][2]}) << endl;

}

Measured memory_bytes: 3712
#include <iostream>
#include <queue>
#define ll long long
using namespace std;
ll res=0;
int n,m;
char c[410][410];
bool visit[410][410]={0};
int d1[4]={0,0,1,-1};
int d2[4]={1,-1,0,0};
inline bool ok(int x,int y)
{
	return x>=0 && y>=0 && x<n && y<m && !visit[x][y];
}
void bfs(int xt,int yt)
{
    queue<int> q;
    int t=0,tt=0;
	q.push(xt);
	q.push(yt);
	visit[xt][yt]=1;
	while (!q.empty())
	{
		int x=q.front(); q.pop();
		int y=q.front(); q.pop();
		//cout <<x<<" "<<y<<"\n";
		(c[x][y]=='.' ? t : tt)++;
		for (int i=0;i<4;i++)
		{
			int xi=x+d1[i];
			int yi=y+d2[i];
			if (ok(xi,yi) && c[xi][yi]!=c[x][y])
			    q.push(xi),q.push(yi),visit[xi][yi]=1;
		}
	}
	//cout <<"t: "<<t<<"  tt: "<<tt<<"  res(before): "<<res<<"  res(after): "<<res+(ll)t*(ll)tt<<"\n";
	res+=(ll)t*(ll)tt;
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	    for (int j=0;j<m;j++)
	        cin >>c[i][j];
    for (int i=0;i<n;i++)
	    for (int j=0;j<m;j++)
		    if (!visit[i][j]) bfs(i,j);
    cout <<res;
    return 0;
}

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

int main() {
    int n , x; cin >> n >> x;
    vector<int> m(n);
    for (int i = 0;i < n; i++) cin >> m.at(i);
    int mi = 1001;
    for (int i = 0;i < n; i++) {
        mi = min(mi, m.at(i));
    }
    //cout << mi << endl;

    int cnt = 0 , ans = 0;

    for (int i = 0;i < n; i++) {
        cnt += m.at(i);
        ans++;
    }

    while (cnt <= x) {
        cnt += mi;
        ans++;
        //cout << cnt << endl;
    }
    
    cout << ans - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
class dice:
    def __init__(self,A):
        self.side = {
            "TOP":A[0],
            "S":A[1],
            "E":A[2],
            "W":A[3],
            "N":A[4],
            "BOT":A[5],
            }
        self.reverse = {
            "E":"W",
            "W":"E",
            "S":"N",
            "N":"S"}
        
    def main(self,A):
        for s in A:
            var = int(self.side[s])
            self.side[s] = self.side["TOP"]
            self.side["TOP"] = self.side[self.reverse[s]]
            self.side[self.reverse[s]] = self.side["BOT"]
            self.side["BOT"] = var
        print("{}".format(self.side["TOP"]))

var = dice(list(map(int,input().split())))
var.main(input())


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }

string Itoa(ll v, int base){
	static const char table[] = "abcdefghijklmnopqrstuvwxyz";
	string ret;
	//static numeric_limits<TypeInt> t;
	ll n = v;
	//if (t.is_signed) {
	//	if (v < 0) n *= -1;
	//}
	while (n >= base) {
		ret += table[n%base];
		n /= base;
              --n;
	}
	ret += table[n];
	//if (t.is_signed) {
	//	if (v < 0 && base == 10) ret += '-';
	//}
	// 文字列の順番を逆にする
	reverse(ret.begin(), ret.end());

	return ret;
}



int main(void)
{
    ll n;
    cin >> n;
    cout << Itoa(n-1, 26) << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

int N, D, X = 0;
int a[120];

int get_pc(int *a, int *D) {
	int tmp_cnt = 1;
	int fcnt = 0;
	
	if (*D > *a) {
		if (*D % *a != 0) {
			fcnt = *D / *a;
		}
		else
		{
			fcnt = *D / *a - 1;
		}
	}
	else {
		fcnt = 0;
	}
	return tmp_cnt + fcnt;
}

int main(){

	cin >> N >> D >> X;

	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		a[i] = tmp;
	}

	int ans = 0;

	for (int j = 0; j < N; ++j) {
		int p_tmp = a[j];
		ans = ans + get_pc(&p_tmp , &D);
	}
	printf("%d", X + ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 500000
#define INFITY 1000000001

void merge(int [],int,int,int);
void mergeSort(int [] ,int ,int);

int counter=0;

int main(){
  int A[MAX],n,  j;

  scanf("%d",&n);

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

  mergeSort(A,0,n);
  for(j=0;j<n;j++){
    printf("%d",A[j]);
    if(j<n-1) printf(" ");
  }
  printf("\n%d\n",counter);

  return 0;
}

void merge(int A[],int left,int mid,int right)
{
  int n1,n2,i,j,k,*L,*R;

  n1 = mid - left;
  n2 = right - mid;
  L=malloc((n1+1)*sizeof(int));
  R=malloc((n2+1)*sizeof(int));
  for(i=0;i<=n1-1;i++){
    L[i] = A[left + i];
  }
  for(i=0;i<=n2-1;i++){
    R[i] = A[mid  + i];
  }

  L[n1]=INFITY;
  R[n2] = INFITY;

  i=j=0;
  for(k=left;k<right;k++){

    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      counter++;
    }
    else{
      A[k] = R[j];
      j = j + 1;
      counter++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(int A[],int left, int right){
  if(left+1 < right){
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}


Measured memory_bytes: 5468
#include <stdio.h>

int main(){
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	if((r <= x) && (x <= (w - r)) && (r <= y) && (y <= (h - r))){
		puts("Yes");
	}
	else{
		puts("No");
	}
	
	return 0;
}
 

Measured memory_bytes: 1012
#include <stdio.h>

int main(void)
{
	int i, array[10], max[3] = {0};
	
	for (i = 0; i < 10; i++){
		scanf("%d", &array[i]);
		
		if (max[0] < array[i]){
			max[2] = max[1];
			max[1] = max[0];
			max[0] = array[i];
		}
		else if (max[1] < array[i]){
			max[2] = max[1];
			max[1] = array[i];
		}
		else if (max[2] < array[i]){
			max[2] = array[i];
		}
	}
	
	for (i = 0; i < 3; i++){
		printf("%d\n", max[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N;
        int[] V;
        int[] C;
        N = sc.nextInt();
        V = new int[N];
        C = new int[N];
        for(int i = 0; i < N; i++){
            V[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            C[i] = sc.nextInt();
        }
        int result = 0;
        for(int i = 0; i < N; i++){
            if(V[i] > C[i]){
                result += V[i] - C[i];
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

#define N_MAX 1000

int main() {
    int n, m;
    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;
        int ps[N_MAX];
        for (int i = 0; i < n; i++) {
            cin >> ps[i];
        }
        sort(ps, ps+n, greater<int>());
        for (int i = m-1; i < n; i += m) {
            ps[i] = 0;
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += ps[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0
n = input()
a = list(map(int,input().split()))
b = []
for i, j in enumerate(a):
    b.append([i + 1,j])
b.sort(key=lambda x:x[1])
for i, p in enumerate(b):
    if i + 1 == n:
        print(p[0])
    else:
        print(p[0], end= " ")

Measured memory_bytes: 23300
import copy
n = int(input())
x = list(map(int,input().split()))
xs = copy.deepcopy(x)
xs.sort()
l = xs[n//2-1]
r = xs[n//2]
for i in range(n):
    if x[i] <= l:
        print(r)
    else:
        print(l)


Measured memory_bytes: 26724