akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MAXN 1e6+5;

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
  	int n,m;
  	map<string,int> table;
  	string s,t;
  	cin>>n;
  	for(int i = 0; i < n; i++) {
  		cin>>s;
  		table[s]++;
  	}

  	cin>>m;
  	for(int i =0; i < m; i++) {
  		cin>>t;
  		table[t]--;
  	}

  	auto maxElement = max_element(table.begin(), table.end(), 
  		[](const pair<string,int> &a, const pair<string,int> &b) {
  			return a.second < b.second;
  		});
  	if(maxElement->second < 0)
  		cout<<0;
  	else
  		cout<<maxElement->second;

	return 0;		
}



Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.math.BigInteger;
class ppo implements Comparable<ppo>{
	int a,b;
	public ppo(int a,int b) {
		this.a=a;
		this.b=b;
	}
	public int compareTo(ppo other) {
		return this.a-other.a;
	}
}
public class Main {
	static final long mod = (int) (1e9 + 7);
	static final int inf = (int) (1e9);
	static final int maxn = (int) (1e5 + 10);
	static long solve(long x) {
		long ret=0;
		if(x%4==0) ret=x;
		if(x%4==1) ret=1;
		if(x%4==2) ret=x+1;
		if(x%4==3) ret=0;
		return ret;
	}
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		long a=cin.nextLong(),b=cin.nextLong();
		long ans=solve(b)^solve(a-1);
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int answer =0;
    int N = sc.nextInt();
    int H[] = new int[N];
    for(int i=0;i<N;i++){
      H[i]=sc.nextInt();
    }
    for(int i=0;i<N;i++){
      if(isView(H,i)){
        answer=answer+1;
      }
    }
    System.out.println(answer);
  }
  public static boolean isView(int H[],int posision){
    boolean isView = true;
    for(int i=0;i<posision;i++){
      if(H[posision]<H[i]){
        isView = false;
        break;
      }
    }
    return isView;
  }
  

  
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

// ここから編集
template<typename T = int> struct BIT{
  vector<T> node;

  int N;
  BIT(int n){
    N = n;
    node.resize(N+1);
  }

  void add(int i, T x){
    i++;
    while(i <= N){
      node[i] += x;
      i += (i & -i);
    }
  }

  T sum(int i){
    T res = 0;
    while(i > 0){
      res += node[i];
      i -= (i & -i);
    }
    return res;
  }

  

};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    
  char c; cin >> c;
  if(c>='a' && c <= 'z'){
    cout << 'a' << endl;
  }else{
    cout << 'A' << endl;
  }
    return 0;
}


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

int main() {
  int A;
  cin >> A;
  
  if(A<1200){
    cout << "ABC" << endl;
  }
  else if(A<2800){
    cout << "ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  [n, k] <- map (read::String -> Int) . words <$> getLine
  let multiples = n `div` k
      halves = n `div` (k `div` 2) - multiples
  if k `mod` 2 == 1
    then print $ multiples * multiples * multiples
    else print $ multiples * multiples * multiples + halves * halves * halves

Measured memory_bytes: 508
#include <stdio.h>

int main(void){

  int n,a,b;
  scanf("%d %d %d", &n, &a, &b);
  int max,min;
  max = a;
  if (b < max) {
    max = b;
  }
  min = 0;
  if (a+b > n) {
    min = a+b-n;
  }
  printf("%d %d\n", max, min);

  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
        	BigInteger m = BigInteger.valueOf((long)Math.pow(10, 9) + 7);
            int N = sc.nextInt();
            BigInteger A[] = new BigInteger[N];
            for (int i = 0; i < N; i++) {
                A[i] = BigInteger.valueOf(sc.nextLong());
            }
            BigInteger n = BigInteger.valueOf(0);
            for (int i = 1; i < N; i++) {
            	n = n.add(A[i]);
            }
            int j = 1;
        	long r = 0;
            for (int i = 0; i < N; i++) {
            	r += A[i].multiply(n).mod(m).longValue();
                if (i < N - 1) {
	                n = n.subtract(A[j]);
	                j++;
                }
            }
            System.out.println(Math.floorMod(r, m.longValue()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

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

int main() {
    int N,M;
    cin >> N >> M;
    int A[M];
    map<int,int> m[N];
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        m[a-1][b-1]++;
    }
    for(int i=0;i<N;i++){
        if(m[0][i] > 0 && m[i][N-1] > 0){
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
    return 0;
}

Measured memory_bytes: 28416
X[3<<17],Y[3<<17];
d[4]={1,-1};
N;s;i;
f(x,y,c,r){for(c=X[x]+1-Y[x],r=4;r--;)0<=(y=x+d[r])&y<N*N&abs(x%N-y%N)<2&&X[y]>c&&f(y,X[y]=c);}
main(P){
	scanf("%d",&N);
	for(d[2]=N,d[3]=-N;i<N*N;i++)X[i]=i%N<i/N?fmin(i%N,N-i/N-1):fmin(i/N,N-i%N-1);
	for(;~scanf("%d",&P);)f(P,Y[P]=1,s+=X[--P]);
	printf("%d",s);
}

Measured memory_bytes: 15344
#include<bits/stdc++.h>
using namespace std;
int a,b,k,x1,y_1,x2,y2,d[500005],v[1005][1005];
bool n[1005][1005],vi[500005];
char c;
struct st{
	int w,v;
	st(int V,int W){
		w=W;
		v=V;
	}
};
struct st1{
	int w,dd;
	st1(){}
	st1(int W,int DD){
		w=W;
		dd=DD;
	}
	friend bool operator < (st1 x,st1 y){return x.dd>y.dd;}
};
priority_queue<st1>q;
vector<st> ans[500005];
int Dijkstra(int s,int t){
	memset(d,0x3f,sizeof(d));
	memset(vi,0,sizeof(vi));
	d[s]=0;
	q.push(st1(s,0));
	while(q.size()){
		int x=q.top().w;
		q.pop();
		if(vi[x]){
			continue;
		} 
		vi[x]=1;
		int siz=ans[x].size();
		for(int i=0;i<siz;i++){
			int vr=ans[x][i].v,w=ans[x][i].w;
			if(d[vr]>d[x]+w){
				d[vr]=d[x]+w;
				q.push(st1(vr,d[vr]));
			}
		}
	}
	return d[t];
}
void dfs(int x,int y){
	if(x>1&&v[x-1][y]==0&&n[x-1][y]==0){
		n[x-1][y]=1;
		v[x-1][y]=k;
		dfs(x-1,y);
		n[x-1][y]=0;
	}
	if(x<a&&v[x+1][y]==0&&n[x+1][y]==0){
		n[x+1][y]=1;
		v[x+1][y]=k;
		dfs(x+1,y);
		n[x+1][y]=0;
	}
	if(y>1&&v[x][y-1]==0&&n[x][y-1]==0){
		n[x][y-1]=1;
		v[x][y-1]=k;
		dfs(x,y-1);
		n[x][y-1]=0;
	}
	if(y<b&&v[x][y+1]==0&&n[x][y+1]==0){
		n[x][y+1]=1;
		v[x][y+1]=k;
		dfs(x,y+1);
		n[x][y+1]=0;
	}
}
int main(){
	scanf("%d %d\n",&a,&b);
	scanf("%d %d\n",&x2,&y2);
	scanf("%d %d",&x1,&y_1);
	for(int i=1;i<=a;i++){
		scanf("\n");
		for(int j=1;j<=b;j++){
			scanf("%c",&c);
			if(c=='#')n[i][j]=1;
		}
	}
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			if(v[i][j]==0&&n[i][j]==0){
				k++;
				v[i][j]=k;
				n[i][j]=1;
				dfs(i,j);
				n[i][j]=0;
			}
		}
	}
	for(int i=1;i<=a;i++){
		for(int j=1;j<=b;j++){
			for(int i1=max(1,i-2);i1<=min(a,i+2);i1++){
				for(int j1=max(1,j-2);j1<=min(b,j+2);j1++){
					if(v[i][j]!=0&&v[i1][j1]!=0&&v[i][j]!=v[i1][j1]){
						ans[v[i][j]].push_back(st(v[i1][j1],1));
						ans[v[i1][j1]].push_back(st(v[i][j],1));
					}
				}
			}
		}
	}
	if(Dijkstra(v[x1][y_1],v[x2][y2])==0x3f3f3f3f){
		printf("-1");
	}else printf("%d",Dijkstra(v[x1][y_1],v[x2][y2]));
	
}

Measured memory_bytes: 65736
using System;
using System.IO;
//using System.Collections.Generic;
	class Program
	{
		public static void Main(string[] args)
		{
			
			
			
			Stream inputStream=Console.OpenStandardInput();
			StreamReader sr =new StreamReader(inputStream);
			string text =sr.ReadToEnd();
			sr.Close();
			
			string[] textArray=text.Replace("\r\n", "\n").Split('\n');
			
			double n=double.Parse(textArray[0]);
			int[] array= new int[(int)n];
			/*
			array=Array.ConvertAll(text.Replace("\r\n", "\n").Split('\n')
                ,
                new Converter<string,int>( s 
                                          => int.Parse(s) ));
			*/
			
            for(int k=0;k<array.Length;k++)
			{
            	array[k]=int.Parse(textArray[k+1]);
			}
			
			int cnt=0;
			int m=1;//?????£??????????????°???h=3???m?????????/??? h<n???
			
			while((Math.Pow(3,m+1)-1)/2<n)//?????????m+1??????
			{
				m++;
			}
			
		/*	
			for(int gap=2;(Math.Pow(3,gap)-1)/2<n;gap++)
			{			
				m++;
			}
		*/	
			int []  G=new int[m];//?????£??????????´???????????????£???????????????????????????????????????????????£??????
			for(int i=0;i<G.Length;i++)//??????.Length????????????????????? m=G.Length
			{
				G[m-1-i]=(int)((Math.Pow(3,i+1)-1)/2);
			}
			for(int s=0;s<G.Length;s++)
			{
				cnt+=sort( array, G[s]);//?????\???????????????????????????????????????????????´???????????????????????????????????????
				
				
				
			}
			//?????????????????????m???????????????G[i]????????????????????§???????????????G?????¨????????´??????count?????????
			//????????????????????????????????????
			Console.WriteLine(m);
			for(int o=0;o<G.Length-1;o++)
			{
				Console.Write(G[o]+" ");
			}
			Console.Write(G[G.Length-1]+"\r\n");//???????????§?????????
			Console.WriteLine(cnt);//?????????
			var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
Console.SetOut(sw);
/*????????????????????????*/
			for(int l=0;l<array.Length;l++)
			{
				Console.WriteLine(array[l]);
			
			}
			Console.Out.Flush();
			
		}
		public static int sort(int [] A,int g)
		{
			//g????????£??????
			int count=0;//??????????????°
			int v=0;
			int j=0;
			for (int k=0;k<g;k++)
			{
				//?????\?????????
			for(int i=k+g;i<A.Length;i+=g)
			{
				
				 v=A[i];
				 j=i-g;
				while(j>=0 &&
				       A[j]>v)//???&&????????§???????????????????????????
				{
					A[j+g]=A[j];
					
				A[j]=v;//????????????A[j]???????????????????§?????????????????????\????????????
				//??????????????????????°?????????????????????´?????????????????£?????????????????????????´??????´???????????????????°?????????????????????????0
				//?????????????????????????????\???
				j=j-g;
					//?????????????????£??????????????\??¨????????¢?????§???????????§????????????
					//??§????????????????????????????????????
				count ++; //????????????????????§????????????????????§??????????????¢??????
				
				}
				
			}
			}
			return count;
		}
		
	}
	

Measured memory_bytes: 130760
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  double r;
  cin >> r;
  double pi = 3.141592;
  printf("%lf\n", 2*r*pi);
  return 0;
}


Measured memory_bytes: 3788
import java.util.Scanner;
public class Main {
	public static void main(String[] args)
	{
		String s;
		Scanner in = new Scanner(System.in);
		s = in.next();
		s.toUpperCase();
		s = s.substring(0, 4) + ' ' + s.substring(4,12) +'\n';
		System.out.print(s);
	}
}


Measured memory_bytes: 9556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;


public class Main {
	private	static	BufferedReader		br      = null;
	private	static	ArrayList<Integer>	list    = null;
	private	static	int[]				borders = null;

	static {
		br   = new BufferedReader(new InputStreamReader(System.in));
		list = new ArrayList<Integer>();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		parseBorder();
		createPrimeList();

		for (int nLoop = 0; nLoop < borders.length; nLoop++) {
			int nCnt = getPrimeCnt(borders[nLoop]);
			System.out.println(nCnt);
		}
	}

	private static String parseNum() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}

	private static void parseBorder() {
		int[]	aWork   = new int[30];
		int		nCnt    = 0;
		String	line    = null;

		while((line = parseNum()) != null) {
			aWork[nCnt] = Integer.parseInt(line);
			nCnt++;
		}

		if (nCnt > 0) {
			borders = new int[nCnt];
			for (int nLoop = 0; nLoop < nCnt; nLoop++) {
				borders[nLoop] = aWork[nLoop];
			}
		}
	}

	private static void createPrimeList() {
		boolean	bPrime = true;
		int		nPrime = 0;
		int[]	aWork  = borders.clone();

		Arrays.sort(aWork);
		list.add(2);
		for(int nNum = 3; nNum <= aWork[aWork.length - 1]; nNum += 2) {
			bPrime = true;

			for (int nLoop = 0; nLoop < list.size(); nLoop++) {
				nPrime = list.get(nLoop);
				if (nPrime <= (int)Math.sqrt((double)nNum)) {
					if (nNum % nPrime == 0) {
						bPrime = false;
						break;
					}
				}
				else {
					break;
				}
			}

			if (bPrime) {
				list.add(nNum);
			}
		}
	}

	private static int getPrimeCnt(int nBorder) {
		int nCnt = 0;

		if (list.get(0) == nBorder) {
			nCnt = 1;
		}
		else if (list.get(0) < nBorder) {
			// 二分法＋逐次法でnBorder以下の素数の数を探す
			int nMin = 0;
			int nMax = list.size() - 1;
			int nCur = 0;

			while (nMax - nMin > 10) {
				nCur = (nMin + nMax) / 2;

				if (nBorder == list.get(nCur)) {
					break;
				}
				else if (nBorder > list.get(nCur)) {
					nMin = nCur + 1;
				}
				else if (nBorder < list.get(nCur)) {
					nMax = nCur - 1;
				}
			}

			nMin = Math.max(nMin - 1, 0);
			nMax = Math.min(nMax + 1, list.size() - 1);
			for (nCur = nMin; nCur <= nMax; nCur++) {
				if (nBorder == list.get(nCur)) {
					break;
				}
				else if (nBorder < list.get(nCur)) {
					nCur--;
					break;
				}
			}

			if (nCur > nMax) {
				nCur = nMax;
			}

			nCnt = nCur + 1;
		}

		return nCnt;
	}
}

Measured memory_bytes: 22820
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
char gr[21][21];
int n,m;
int vis[21][21];
int distt[21][21];
int dis(pair<int,int>p1,pair<int,int>p2){
    queue<pair<int,int>>q;
    rep0(i,n)rep0(j,m) vis[i][j]=1;
    q.push(p1);
    distt[p1.f][p1.s]=0;
    while(q.si){
        pair<int,int>p=q.front();
        //deb2(p.f,p.s);
        q.pop();
        if(p.f+1<n&&vis[p.f+1][p.s]&&gr[p.f+1][p.s]!='#'){
            q.push({p.f+1,p.s});
            distt[p.f+1][p.s]=distt[p.f][p.s]+1;
            vis[p.f+1][p.s]=0;
            if(p.f+1==p2.f&&p.s==p2.s) return distt[p.f+1][p.s];
        }
        if(p.f-1>=0&&vis[p.f-1][p.s]&&gr[p.f-1][p.s]!='#'){
            q.push({p.f-1,p.s});
            distt[p.f-1][p.s]=distt[p.f][p.s]+1;
            vis[p.f-1][p.s]=0;
            if(p.f-1==p2.f&&p.s==p2.s) return distt[p.f-1][p.s];
        }
        if(p.s+1<m&&vis[p.f][p.s+1]&&gr[p.f][p.s+1]!='#'){
            q.push({p.f,p.s+1});
            distt[p.f][p.s+1]=distt[p.f][p.s]+1;
            vis[p.f][p.s+1]=0;
            if(p.f==p2.f&&p.s+1==p2.s) return distt[p.f][p.s+1];
        }
        if(p.s-1>=0&&vis[p.f][p.s-1]&&gr[p.f][p.s-1]!='#'){
            q.push({p.f,p.s-1});
            distt[p.f][p.s-1]=distt[p.f][p.s]+1;
            vis[p.f][p.s-1]=0;
            if(p.f==p2.f&&p.s-1==p2.s) return distt[p.f][p.s-1];
        }
    }
    return -1;
}
void solve()
{
    cin>>n>>m;
    vector<pair<int,int>>v;
    rep0(i,n)rep0(j,m) {cin>>gr[i][j];if(gr[i][j]=='.') v.pb({i,j});}
    int mx=0;
    int xx=v.si;
    for(int i=0;i<xx-1;i++){
        for(int j=i+1;j<xx;j++){
            mx=max(mx,dis(v[i],v[j]));
        }
    }
    pr(mx);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

L = []
for i in range(len(S)):
  if len(L) == 0:
    L.append([S[i], 2])
  else:
    u = 0
    for j in range(len(L)):
      if S[i] == L[j][0]:
        L[j][1] += 1
        u += 1
    if u == 0:
      L.append([S[i], 2])
p = 1    
for l in range(len(L)):
  p *= L[l][1]
print(int((p - 1) % 1000000007))

Measured memory_bytes: 3188
#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;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



ll fpow(ll a, ll n){
    ll x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%MOD;
        }
        a=a*a%MOD;
        n >>= 1;
    }
    return x;
}
 

int main(){
    ll n;cin >> n;
    ll t = 2 * fpow(9, n) %MOD;
    ll ans = (fpow(10, n) - t + MOD)%MOD;
    ans =(ans + fpow(8, n))%MOD;
    cout << ans << endl;
    return 0;
}


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

int main() {
  string sNum;
  int result;
  
  cin >> sNum;
  
  if(sNum[0] == '1') result++;
  if(sNum[1] == '1') result++;
  if(sNum[2] == '1') result++;
  
  cout << result << endl;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int n, m, k[300005], sor[300005], mon;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		sor[i] = k[i];
	}
	sort(sor, sor + n);

	for (int i = 0; i < n; ++i) {
		if (k[i] == sor[i]) { ++mon; }
	}
	if (mon == n) {
		cout << 0 << endl;
		return 0;
	}
	cin >> m;
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		if (k[a] == sor[a]) { --mon; }
		if (k[a] == sor[b]) { ++mon; }
		if (k[b] == sor[b]) { --mon; }
		if (sor[a] == k[b]) { ++mon; }
		if (mon == n) {
			cout << i + 1 << endl;
			return 0;
		}
		swap(k[a], k[b]);
	}

	cout << -1 << endl;
}


Measured memory_bytes: 5496
while True:
    H, W = map(int, input().split())
    if(H == 0 & W == 0): break
    
    for i_h in range(H):
            for i_w in range(W):
                if( (i_h + i_w) % 2 == 0):
                    print("#", end= "")
                else:
                    print(".", end ="")
            print()
    print()


Measured memory_bytes: 7004
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int sum;
	while (cin >> sum, sum) {
		REP(i, 0, 9) {
			int value;
			cin >> value;
			sum -= value;
		}

		cout << sum << endl;
	}
	return 0;
}

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

using LL = long long;
const LL M = 1e9 + 7;

LL factorial(LL n) {
  static vector<LL> memo = {1};
  while(memo.size() <= n) memo.push_back((memo.back() * memo.size()) % M);
  return memo[n];
}

LL power(LL n, LL m) {
  if(!m) return 1;
  if(m & 1) return n * power(n, m-1) % M;
  return power(n * n % M, m >> 1);
}

LL inverse(LL n) {
  return power(n, M-2);
}

LL combination(LL n, LL r) {
  return factorial(n) * (inverse(factorial(r)) * inverse(factorial(n-r)) % M) % M;
}

int main() {
  LL H, W, A, B;
  cin >> H >> W >> A >> B;
  LL ans = 0;
  for(int i = B; i < W; ++i) ans = (ans + combination(H-A-1+i, i) * combination(A-1+W-1-i, A-1)) % M;
  cout << ans << endl;
}


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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

const double eps = 1e-7;

class P {
public:
    double x, y;
    P(double x, double y): x(x), y(y) {}
};

double sq(double x) { return x * x; }
double is_equal(double x, double y) { return abs(x-y) < eps; }

double distance(P a, P b) {
    return hypot(a.x - b.x, a.y - b.y);
}

P midpoint(P a, P b) {
    return P((a.x + b.x) / 2.0, (a.y + b.y) / 2.0);
}

P circum(P a, P b, P c) {
    // 直角三角形の場合
    if (is_equal(sq(distance(a, b)), sq(distance(b, c))+sq(distance(c, a)))) return midpoint(a, b);
    if (is_equal(sq(distance(b, c)), sq(distance(c, a))+sq(distance(a, b)))) return midpoint(b, c);
    if (is_equal(sq(distance(c, a)), sq(distance(a, b))+sq(distance(b, c)))) return midpoint(c, a);

    // ゼロ除算回避
    if (a.y == b.y) swap(b, c);
    if (b.y == c.y) swap(a, b);

    P m1 = midpoint(a, b);
    double a1 = (a.x - b.x) / (b.y - a.y);
    double b1 = m1.y - a1 * m1.x;
    P m2 = midpoint(b, c);
    double a2 = (b.x - c.x) / (c.y - b.y);
    double b2 = m2.y - a2 * m2.x;
    
    double ox = (b2 - b1) / (a1 - a2);
    double oy = a1 * ox + b1;
    return P(ox, oy);
}

bool in_circle(vector<P> ps, P o, double radius) {
    for (P p: ps) {
        if (distance(p, o) > radius + eps) {
            return false;
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<P> ps;
    for (int i=0; i<N; ++i) {
        double x, y;
        cin >> x >> y;
        ps.push_back(P(x, y));
    }

    double res = 1e7;

    // 2点が円周上にあるケース
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            P o = midpoint(ps[i], ps[j]);
            double radius = distance(o, ps[j]);
            if (in_circle(ps, o, radius)) {
                res = min(res, radius);
            }
        }
    }

    // 3点が円周上にあるケース
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {
            for (int k=j+1; k<N; ++k) {
                if (is_equal(atan2(ps[i].y - ps[j].y, ps[i].x - ps[j].x), atan2(ps[j].y - ps[k].y, ps[j].x - ps[k].x))) {
                    continue;
                }
                P o = circum(ps[i], ps[j], ps[k]);
                double radius = distance(o, ps[i]);
                if (in_circle(ps, o, radius)) {
                    res = min(res, radius);
                }
            }
        }
    }

    printf("%.18f\n", res);

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(){
  
  string s; cin >> s;
  string a,b;
  for(int i = 0; i < s.size(); i++){
    if(i < s.size() / 2){
    a.push_back(s[i]);
    }
    if(i > s.size()/ 2){
    b.push_back(s[i]);
    }
  }
  
  
  for(int i = 0; i < s.size() / 2; i++){
  if(s[i] != s[s.size() - i - 1]){
    cout << "No" << endl; return 0;
  }
  }
  for(int i = 0; i < a.size() / 2; i++){
  if(a[i] != a[a.size() - i - 1]){
    cout << "No" << endl; return 0;
  }
  }
  for(int i = 0; i < b.size() / 2; i++){
  if(b[i] != b[b.size() - i - 1]) {
    cout << "No" << endl; return 0;
  }
  }
    cout << "Yes" << endl;

    return 0;
}

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

//int a[100005];
vector<int> num(100005);
const int pnum = 1000000007;

int main(){
    int n, A;
    long long ans = 1;
    bool flag = true;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &A);
        num.at(A)++;
    }
    for (int i = 1; i <= (n+1)/2; i++)
    {
        if (n%2 == 0)
        {
            if(num.at( (2*i) - 1 ) != 2)
            {
                flag = false;
                break;
            }
        }
        else
        {
            if(i == 1)
            {
                if (num.at(0) != 1)
                {
                    flag = false;
                    break;
                }
            }
            else
            {
                if(num.at( 2*(i-1) ) != 2)
                {
                    flag = false;
                    break;
                }
            }
        }
    }

    //for (int i = 0; i < n; i++) cout << "num.at(" << i << ")=" << num.at(i) << endl;
    //cout << "flag=" << flag << endl;

    if(flag)
    {
        if (n%2 == 0)
        {
            for (int i = 0; i < (n/2); i++)
            {
                ans *= 2;
                ans %= pnum;
            }
            printf("%lld\n", ans);
        }
        else 
        {
            for (int i = 0; i < (n-1)/2; i++)
            {
                ans *= 2;
                ans %= pnum;
            }
            printf("%lld\n", ans);
        }
    }
    else
    {
        printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

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

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
bool fl[110];

int main() {
  std::cin >> N;

  rep( i, N ) {
    ll D1, D2;
    std::cin >> D1 >> D2;

    fl[i] = D1 == D2;
  }

  bool ans = false;

  rep( i, N ) {
    if( i+2 >= N )
      break;

    ans |= fl[i] && fl[i+1] && fl[i+2];
  }

  std::cout << (ans ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
using namespace std;

int main(void){
    int n, y, i, j;
    cin >> n >> y;
    y /= 1000;
    for(i=n; i>=0; i--){
        for(j=n-i; j>=0; j--){
            if(i*10 + j*5 + n-i-j == y) goto SKIP;
        }
    }
    cout << "-1 -1 -1\n";
    return 0;
SKIP:
    printf("%d %d %d\n", i, j, n-i-j);
    return 0;
}

Measured memory_bytes: 3732
s=input()
K=int(input())
L=list(s)
S=sorted(set(L))
A=[]

for _ in range(min(3,len(S))):
    H=S[_]
    A.append(H)
    HN=[]
    for i in range(len(L)):
        if L[i]==H:
            HN.append(i)
    for i in HN:
        t=2
        while i+t<len(s)+1 and t<6:
            A.append(''.join(L[i:i+t]))
            t+=1

A=sorted(list(set(A)))
print(A[K-1])

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

#define D_MAX 1000000000
#define N_MAX 100000
#define M_MAX 10000

int d;
int n;
int m;

int ad[N_MAX+1];
int ak[M_MAX+1];
int temp[N_MAX+1]; 

void MergeSort(int array[],int left,int right){
  int awork[N_MAX+1];
  int mid;
  int i;
  int j;
  int x;
  int y;
  
  if( left >= right ){
    return;
  }
  
  mid = (left + right) / 2;
  MergeSort( array, left, mid);
  MergeSort( array, mid+1, right);
  
  for( i=left; i<=mid; i++){
    awork[i] = array[i];
  }
  
  j = right;
  for( i=mid+1; i<=right; i++){
    awork[i] = array[j];
    j--;
  }
  
  x = left;
  y = right;
  
  for( i=left; i<=right; i++){
    if(awork[x] <= awork[y]){
      array[i] = awork[x];
      x++;
    }else{
      array[i] = awork[y];
      y--;
    }
  }
}

int calcDist(int k){
  int i;
  int diff;
  int preDiff = 0;
  int minDist = d;
  int tmpDist;
  int halfDist = d >> 1;
  
  for( i=0; i<=n; i++){
    diff = ad[i] - k;
    if( minDist > abs(diff) ){
      minDist = abs(diff);
    }
    preDiff = diff;
  }
  return minDist;
}

/*
int calcDist(int k){
	int i;
	int minDist = d;
	int tmpDist;
	int halfDist = d >> 1;
	
	for( i=1; i<=n; i++){
		tmpDist = abs(ad[i]-k);
		if( tmpDist > halfDist ){
			tmpDist = d-tmpDist;
		}
		if( minDist > tmpDist ){
			minDist = tmpDist;
		}
	}
	return minDist;
}
*/

void input(void){
  int i;
  scanf("%d",&d);
  if( d != 0){
    scanf("%d",&n);
    scanf("%d",&m);
    ad[0] = 0;
    for( i=1; i<=n-1; i++){
      scanf("%d",&ad[i]);
    }
    ad[n] = d;
    for( i=1; i<=m; i++){
      scanf("%d",&ak[i]);
    }
  }
}

int main(void){
  int i;
  int sumDist = 0;
  while( 1 ){
    input();
    if( d == 0 ){
      break;
    }
    MergeSort( ad, 0, n);
    for( i=1; i<=m; i++){
      sumDist += calcDist(ak[i]);
    }
    printf("%d\n",sumDist);
    sumDist = 0;
  }
}




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

typedef long long ll;

void chmin(ll &a, ll b) {
    if (a > b) a = b;
}

const ll INF = 1LL<<58;

template<class T> int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll>s(A), t(B);
    for (int i = 0; i < A; i++) cin >> s[i];
    for (int i = 0; i < B; i++) cin >> t[i];
    s.push_back(INF);
    s.push_back(-INF);
    sort(s.begin(), s.end());
    t.push_back(INF);
    t.push_back(-INF);
    sort(t.begin(), t.end());

    for (int i = 0; i < Q; i++) {
        ll x;
        cin >> x;
        ll res = INF;

        for (int i = 0; i < 2; i++) {
            ll first = (i ? s[former(s, x)] : s[latter(s, x)]);

            for (int j = 0; j < 2; j++) {
                ll second = (j ? t[former(t, first)] : t[latter(t, first)]);
                chmin(res, abs(x-first) + abs(first-second));
            }
        }

        for (int i = 0; i < 2; i++) {
            ll first = (i ? t[former(t, x)] : t[latter(t, x)]);

            for (int j = 0; j < 2; j++) {
                ll second = (j ? s[former(s, first)] : s[latter(s, first)]);
                chmin(res, abs(x-first)+abs(first-second));
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 2912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define fx(x) fixed<<setprecision(x)

int main(){
	int n; cin>>n;
	vector<pair<int,int>> vp(n);
	rep(i,n) cin>>vp[i].first>>vp[i].second;
	sort(all(vp));
	
	double ans=0; double cnt=0;
	do{
		cnt++;
		int a,b; double dis;
		for(int i=0; i<n-1; i++){
			a=vp[i].first-vp[i+1].first;
			b=vp[i].second-vp[i+1].second;
			dis+=sqrt(a*a+b*b);
		}
		ans+=dis;
	}while(next_permutation(vp.begin(),vp.end()));
	cout<<fx(10)<<ans/cnt<<endl;
}

Measured memory_bytes: 3748
from sys import stdin
input = stdin.readline

n = int(input())
R = [int(input()) for _ in range(n)]

ans = -10 ** 9

mi = R[0]

for i in range(1, n):
    ans = max(ans, R[i] - mi)
    if R[i] < mi:
        mi = R[i]

print(ans)



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

void printv(vector<int> v){
    cout << "[";
    for(int i = 0; i < v.size()-1; i++){
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << "]" << endl;
}

int main(void){
    int n, m, q, ans = 0;
    cin >> n >> m >> q;
    vector<int> a(q), b(q), c(q), d(q);
    for(int i = 0; i < q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    queue<vector<int>> que;
    for(int i = 1; i <= m; i++){
        vector<int> temp(1,i);
        que.push(temp);
    }
    while(!que.empty()){
        vector<int> top = que.front();
        if(top.size() == n){
            // calc point of top
            int point = 0;
            for(int i = 0; i < q; i++){
                if(top[b[i]-1]-top[a[i]-1] == c[i]){
                    point += d[i];
                }
            }
            ans = max(ans, point);
            que.pop();
        } else {
            for(int i = top.back(); i <= m; i++){
                // add
                vector<int> temp = top;
                temp.push_back(i);
                que.push(temp);
            }
            que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;
typedef double ld;
#define X first
#define Y second
#define mk make_pair
#define pb push_back
#define Rep(i, n) for(int i = 0; i < int(n); i ++)
#define Rep1(i, n) for(int i = 1; i <= int(n); i ++)
#define all(x) (x).begin(), (x).end()
const int MOD = (int) 1e9 + 7;
const ll base =  31;
void MAIN();
int main(){
    //freopen("input.txt", "r", stdin);
    ios:: sync_with_stdio(false); cin.tie(0);
    MAIN();
    return 0;
}
////////////////////////////////////////////////////////////////////////

const int N = 300032;

//a1 + a2 <= b*2

int n;
ii a[N];

void MAIN(){
    cin >> n;
    Rep(i, n) cin >> a[i].Y >> a[i].X;
    sort(a, a + n);
    int l = 0, r = n;
    while(l < r){
        int mid = l + r + 1 >> 1;
        ll sum = 0;
        priority_queue <int> s;
        bool ok = false;
        for(int i = n-1; i >= 0; i --){
            if(s.size() == mid - 1){
                if(sum + a[i].Y <= 1LL*a[i].X*mid) ok = true;
            }
            s.push(a[i].Y);
            sum += a[i].Y;
            if(s.size() >= mid){
                sum -= s.top();
                s.pop();
            }
        }
        if(ok) l = mid;
        else r = mid - 1;
    }
    cout << l << endl;
}

Measured memory_bytes: 6540
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ll long long int

using namespace std;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if (a + b + 1 >= c)
  {
    cout << b + c << endl;
  }
  else
  {
    cout << a + b + 1 + b << endl;
  }
}

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

int N;
int A[210];

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> A[i];

    int res = 0;

    while (true) {
        bool exist_odd = false; 
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;

        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
tx-=sx
ty-=sy
ans=""
ans+="U"*ty+"R"*tx
ans+="D"*ty+"L"*tx
ans+="L"+"U"*(ty+1)+"R"*(tx+1)+"D"
ans+="R"+"D"*(ty+1)+"L"*(tx+1)+"U"
print(ans)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		Sweet[] Sweets = new Sweet[n];

		for (int i=0;i<n;i++) {
			Sweets[i] = new Sweet();
			Sweets[i].x=sc.nextLong();
			Sweets[i].y=sc.nextLong();
			Sweets[i].z=sc.nextLong();
		}

		long ans = 0;

		for (int j=0;j<8;j++) {
			long tmpx = 0;
			long tmpy = 0;
			long tmpz = 0;
			for (int i=0;i<n;i++) {
				long partx = (j&4)>0 ? Sweets[i].x : -Sweets[i].x;
				long party = (j&2)>0 ? Sweets[i].y : -Sweets[i].y;
				long partz = (j&1)>0 ? Sweets[i].z : -Sweets[i].z;

				Sweets[i].value=partx+party+partz;
			}
			Arrays.sort(Sweets, Comparator.comparing((Sweet a) -> a.value));

			for (int i=0;i<m;i++) {
				tmpx += Sweets[i].x;
				tmpy += Sweets[i].y;
				tmpz += Sweets[i].z;
			}
			ans = Math.max(ans, Math.abs(tmpx)+Math.abs(tmpy)+Math.abs(tmpz));
		}
		System.out.println(ans);
	}


}

class Sweet {
	long x;
	long y;
	long z;
	long value;
}


Measured memory_bytes: 29928
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0
for _ in range(N):
  A = list(map(int, input().split()))
  sum = C
  for i in range(M):
    sum += A[i] * B[i]
  if sum > 0:
    cnt += 1
  
print(cnt)

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

int main(){
	int H,W;
	while(cin >> H >> W,H||W){
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout << "#";
		}
		cout << endl;
	}
	cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main()
{
    int card[4][13];
    int n,num;
    char mark;
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            card[i][j]=0;
        }
    }

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&mark);
        scanf("%c %d",&mark,&num);
        if(mark == 'S') card[0][num-1]=1;
        else if(mark == 'H') card[1][num-1]=1;
        else if(mark == 'C') card[2][num-1]=1;
        else if(mark == 'D') card[3][num-1]=1;
    }

    for(int i=1; i<=13;i++){
        if(card[0][i-1]!= 1) printf("S %d\n",i);
    }

    for(int i=1; i<=13;i++){
        if(card[1][i-1]!= 1) printf("H %d\n",i);
    }

    for(int i=1; i<=13;i++){
        if(card[2][i-1]!= 1) printf("C %d\n",i);
    }

    for(int i=1; i<=13;i++){
        if(card[3][i-1]!= 1) printf("D %d\n",i);
    }

    return 0;
}



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

int main(){
    string s;
    cin >>s;
    if(s.at(0) == s.at(1) && s.at(1) == s.at(2) || 
      s.at(0) == s.at(1) && s.at(1) == s.at(2) && s.at(2) == s.at(3) ||
      s.at(1) == s.at(2) && s.at(2) == s.at(3)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <stack>
using namespace std;
char s[200001];
stack<char> a;
int main(){
  scanf("%s",s);
  int len=strlen(s);
  for(int i=0;i<len;i++){
    if(s[i]=='S')a.push('S');
    else {
      if( a.empty()==true|| a.top() =='T') a.push('T');
      else if(a.top() == 'S')a.pop();
    }
    
  }
  cout << a.size() << endl ;
  return 0;
}


Measured memory_bytes: 640
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
for i in range(N):
    ans+=B[i]
for i in range(N):
    if i==N-1:
        ans+=0
    elif A[i]+1==A[i+1] :
        ans+=C[A[i]-1]
    else :
        ans+=0
print(ans)


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

using namespace std;

#define MAX_V 100010
#define INF 1e9
typedef vector<int> Vec;
typedef pair<int,int> pii;

int low[MAX_V],ord[MAX_V];
int V,E;
Vec G[MAX_V];
vector<pii> bridge;

void dfs(int v,int prev,int &k){
    ord[v] = low[v] = k++;
    for(int i = 0 ; i < (int)G[v].size() ; i++){
        int to = G[v][i];
        if(to == prev) continue;
        if(ord[to] == -1){
            dfs(to, v, k);
            low[v] = min(low[v], low[to]);
            if(ord[v] < low[to]){
                int a = min(v, to),b = max(v, to);
                bridge.push_back(pii(a,b));
            }
        }
        low[v] = min(low[v], ord[to]);
    }
}

void init(){
    bridge.clear();
    for(int i = 0 ; i < V ; i++){
        G[i].clear();
        ord[i] = -1; low[i] = INF;
    }
}

int main(){
    int s,t;
    cin >> V >> E; init();
    for(int i = 0 ; i < E ; i++){
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    int k = 0;
    for(int i = 0 ; i < V ; i++){
        if(ord[i] == -1){
            dfs(i, -1, k);
        }
    }
    sort(bridge.begin(),bridge.end());
    for(int i = 0 ; i < (int)bridge.size() ; i++){
        cout << bridge[i].first << " " << bridge[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 5328
#include<bits/stdc++.h>
using namespace std ;
int SumofDigit(int i ){
  int pre = 0 ;
  while(i>0){
    pre += i%10;
    i /= 10 ;
  }
  return pre ;
}

int main () {
  int N ;
  cin >> N ;
  int ans = 100000000 ;
  for(int i = 1 ; i < N ; i++ ){
    int pre = SumofDigit(N - i );
    ans = min(ans,pre+SumofDigit(i)) ;
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
job = sorted(AB)
reward_list = []
ans = 0
j = 0
for i in range(1, M + 1):
    while j < N and job[j][0] <= i:
        heapq.heappush(reward_list, -job[j][1])
        j += 1
    if len(reward_list) > 0:
        ans -= heapq.heappop(reward_list)
print(ans)


Measured memory_bytes: 32364
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\



     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
 ll n,step=0,ans=99999999999999999;
 cin>>n;
 for(ll i=1;i<=sqrt(n);i++)
 {
     if(n%i==0)
     {
         ll d=n/i;
         step=i+d-2;
         ans=min(ans,step);

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



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

#define ll long long
const int mxm = 1e9+7;

int main() {
	int n;
	cin >> n;
	vector <int> h(n);
	for(int i=0;i<n;i++) {
		cin >> h[i];
	}
	vector <int> dp(n,mxm);
	dp[0] = 0;
	for(int j=0;j<n-1;j++) {
		int i1 = j+1;
		int i2 = j+2;
		if(i1 < n) {
			dp[i1] = min(dp[i1],dp[j] + abs(h[j] - h[i1]));
		}
		if(i2 < n) {
			dp[i2] = min(dp[i2],dp[j] + abs(h[j] - h[i2]));
		}
	}
	cout << dp[n-1] << '\n';
	return 0;
}

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

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 100005;

int n;
int a[Maxn];
int has[Maxn];
int res = 1;

int main()
{
    scanf("%d", &n);
    has[0] = 3;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        if (!has[a[i]]) { printf("0\n"); return 0; }
        res = ll(res) * has[a[i]] % mod;
        has[a[i]]--;
        has[a[i] + 1]++;
    }
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 1024