akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mes(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10;
const int INF = 0x3f3f3f3f;
const int inf = - INF;
const int mod = 1e9+7;
const double pi = acos(-1.0);

int a[11];
bool judge(int x){
    while(x){
        int t=x%10;
        x/=10;
        if(a[t]) return false;
    }
    return true;
}
int main(){
    int n,k;
    cin>>n>>k;
    rep(i,1,k){
        int t;
        cin>>t;
        a[t]=1;
    }
    rep(i,n,99999){
        if(judge(i)){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = 998244353;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		//Scanner sc = new Scanner(System.in);
		FastReader sc = new FastReader();
		long n = sc.nextLong();
		long total= 0;
		total += (n/500)*1000;
		n-=((n/500)*500);
		total+=(n/5)*5;
		System.out.println(total);
	}
  
	
	public static class pair{
		long bal;
		long wt;
		long diff;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return Long.valueOf(o1.diff).compareTo(Long.valueOf(o2.diff));
		}
	}
		
	static class FastReader 
		{ 
		final private int BUFFER_SIZE = 1 << 16; 
		private DataInputStream din; 
		private byte[] buffer; 
		private int bufferPointer, bytesRead; 
  
		public FastReader() 
		{ 
			din = new DataInputStream(System.in); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public FastReader(String file_name) throws IOException 
		{ 
			din = new DataInputStream(new FileInputStream(file_name)); 
			buffer = new byte[BUFFER_SIZE]; 
			bufferPointer = bytesRead = 0; 
		} 
  
		public String readLine() throws IOException 
		{ 
			byte[] buf = new byte[64]; // line length 
			int cnt = 0, c; 
			while ((c = read()) != -1) 
			{ 
				if (c == '\n') 
					break; 
				buf[cnt++] = (byte) c; 
			} 
			return new String(buf, 0, cnt); 
		} 
  
		public int nextInt() throws IOException 
		{ 
			int ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do
			{ 
				ret = ret * 10 + c - '0'; 
			}  while ((c = read()) >= '0' && c <= '9'); 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public long nextLong() throws IOException 
		{ 
			long ret = 0; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		public double nextDouble() throws IOException 
		{ 
			double ret = 0, div = 1; 
			byte c = read(); 
			while (c <= ' ') 
				c = read(); 
			boolean neg = (c == '-'); 
			if (neg) 
				c = read(); 
  
			do { 
				ret = ret * 10 + c - '0'; 
			} 
			while ((c = read()) >= '0' && c <= '9'); 
  
			if (c == '.') 
			{ 
				while ((c = read()) >= '0' && c <= '9') 
				{ 
					ret += (c - '0') / (div *= 10); 
				} 
			} 
  
			if (neg) 
				return -ret; 
			return ret; 
		} 
  
		private void fillBuffer() throws IOException 
		{ 
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
			if (bytesRead == -1) 
				buffer[0] = -1; 
		} 
  
		private byte read() throws IOException 
		{ 
			if (bufferPointer == bytesRead) 
				fillBuffer(); 
			return buffer[bufferPointer++]; 
		} 
  
		public void close() throws IOException 
		{ 
			if (din == null) 
				return; 
			din.close(); 
		} 
	} 
}



Measured memory_bytes: 22612
#[allow(unused_imports)]
use proconio::{fastout, input};

#[macro_use]
extern crate lazy_static;

use std::collections::HashMap;

lazy_static! {
    static ref HASHMAP: HashMap<&'static str, u32> = [
        ("SUN", 7),
        ("MON", 6),
        ("TUE", 5),
        ("WED", 4),
        ("THU", 3),
        ("FRI", 2),
        ("SAT", 1),
    ]
    .iter()
    .copied()
    .collect();
}

#[fastout]
fn main() {
    input!(s: String);

    println!("{}", HASHMAP.get::<str>(&s.to_string()).unwrap());
}


Measured memory_bytes: 2156
import java.util.*;
public class Main{
  
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        double m, a2;
        int s[] = new int[1000];
        while(true){
            n = sc.nextInt();
            if(n == 0)break;
            m = 0;
            a2 = 0; 
            for(int i = 0; i < n; i++){
                s[i] = sc.nextInt();
                m += s[i];
            }
            m = m/ n;
            for(int i = 0; i < n; i++){
                a2 += (s[i] - m)*(s[i] - m) / n;
            }
            System.out.printf("%.8f\n",Math.sqrt(a2));
        }
    }
  
}


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

int main()
{
    string str;
    cin >> str;
    int length = str.length();
    if(length%2==0){
        length --;
    }
    length --;
    while(str.compare(0,length/2,str,length/2,length/2)!=0){
        length -= 2;
    }
    cout << length << endl;
    return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int D, G;
int p[maxn], c[maxn];


int solve(int mask) {
    int score = 0;
    int solved = 0;
    for (int i=0; i<D; i++) {
	if (mask>>i&1) {
	    solved += p[i];
	    score += (i+1)*100*p[i];
	    score += c[i];
	}
    }

    for (int i=D-1; i>=0 && score<G; i--) {
	if (mask>>i&1) continue;
	for (int j=0; j<p[i] && score<G; j++) {
	    solved++;
	    score+=(i+1)*100;
	}
	score+=c[i];
    }

    return solved;
}

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

    cin>>D>>G;
    for (int i=0; i<D; i++) {
	cin>>p[i]>>c[i];
    }


    int res = 1e9;
    for (int mask=0; mask<(1<<D); mask++) {
	res = min(res, solve(mask));
    }


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


Measured memory_bytes: 2304
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<iostream>
using namespace std;
int dp[100000][3]={0};

int topdown(int a[100000][3],int n)
{
	int best=0;
	for(int i=0;i<3;i++)
	{
		dp[n-1][i]=a[n-1][i];
		best=max(best,dp[n-1][i]);
	}

	for(int i=n-2;i>=0;i--)
	{
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(j==k)
					continue;
				dp[i][j]=max(dp[i][j],a[i][j] + dp[i+1][k]);
				best=max(best,dp[i][j]);
			}
		}
	}
	return best;
}

int main()
{
	ios_base::sync_with_stdio(0);         
	cin.tie(NULL);
	cout.tie(NULL);
	int n,a[100000][3];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	}
	cout<<topdown(a,n)<<endl;
    
    return 0;
}

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

int main() {
  int temp[5];
  int A, B, count{0};
  cin >> A >> B;
  for (int i = A; i <= B; ++i) {
    int ii = i;
    for (int j = 4; j >= 0; --j) {
      temp[j] = ii % 10;
      ii /= 10;
    }
    bool judge{true};
    for (int j = 0; judge && j < 5 / 2; ++j) {
      if (temp[j] != temp[4 - j]) {
        judge = false;
      }
    }
    if (judge) {
      ++count;
    }
  }
  cout << count << '\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
d = {}
ans = []

for i in range(n):
    order = list(map(str, input().split()))
    if order[0] == 'insert':
        d[order[1]] = i
    else:
        if d.__contains__(order[1]):
            ans.append('yes')
        else:
            ans.append('no')

print(*ans, sep='\n')



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

using ld=long double;
int main(){
    int m,n;
    cin>>m>>n;
    vector<vector<ld>> p(m,vector<ld>(n));
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++) cin>>p[i][j];
    }
    vector<vector<vector<ld>>> dp(2,vector<vector<ld>>(m,vector<ld>(1<<m,0)));
    for(int i=0;i<m;i++){
        for(int bit=0;bit<(1<<m);bit++){
            if((bit>>i)&1) dp[n&1][i][bit]=1;
        }
    }
    for(int i=n-1;i>=0;i--){
        for(int bit=(1<<m)-1;bit>=0;bit--){
            for(int j=0;j<m;j++){
                if(!((bit>>j)&1)) continue;
                ld x=p[j][i]*dp[(i+1)&1][j][bit];
                ld y=0;
                for(int k=0;k<m;k++){
                    if(!((bit>>k)&1)) y=max(y,dp[i&1][k][bit|(1<<k)]);
                }
                dp[i&1][j][bit]=x+(1-p[j][i])*y;
            }
            
        }
    }

    ld res=0;
    for(int i=0;i<m;i++){
        res=max(res,dp[0][i][(1<<i)]);
    }
    cout<<fixed<<setprecision(10);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 53424
package main

import (
        "fmt"
)

//    展望台iから一本の道を使って辿り着けるどんな展望台よりも展望台iの方が標高が高い
// -> 展望台iから一本の道を使って辿り着ける展望台の標高の最大値よりも展望台iの標高が高い
func solution(h []int, matrix [][]int) int {
        memo := make([]int, len(h))
        for i := range matrix {
                ai := matrix[i][0] - 1
                bi := matrix[i][1] - 1
                memo[ai] = max(memo[ai], h[bi])
                memo[bi] = max(memo[bi], h[ai])
        }

        c := 0
        for i := 0; i < len(h); i++ {
                if h[i] > memo[i] {
                        c++
                }
        }
        return c
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        h := make([]int, 0, n)
        for i := 0; i < n; i++ {
                var num int
                fmt.Scan(&num)
                h = append(h, num)
        }
        matrix := make([][]int, 0, m)
        for i := 0; i < m; i++ {
                var a, b int
                fmt.Scan(&a, &b)
                matrix = append(matrix, []int{a, b})
        }
        fmt.Println(solution(h, matrix))
}

Measured memory_bytes: 11060
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
  int a, b,c,d;
  cin >> a >> b;
  d = b;
  while ((d /= 10) > 0)
    a *= 10;
  c = a*10 + b;
  if(c == pow(int(sqrt(c)),2.0))cout<<"Yes" ;
  else
    cout << "No";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 1e9 + 7;
ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

const int IMAX = 1000000;
ll fac[IMAX + 1], ifac[IMAX + 1];
inline ll comb(int A, int B) {
	return fac[A] * ifac[B] % mod * ifac[A - B] % mod;
}

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


	int X, Y;
	cin >> X >> Y;

	int kei = X + Y;

	if (kei % 3) {
		co(0);
		return 0;
	}

	if (X > Y) swap(X, Y);

	int M = kei / 3;
	if (X < M) {
		co(0);
		return 0;
	}

	fac[0] = 1;
	rep1(i, IMAX) fac[i] = fac[i - 1] * i % mod;
	ifac[IMAX] = modpow(fac[IMAX], mod - 2);
	for (int i = IMAX; i > 0; i--) ifac[i - 1] = ifac[i] * i % mod;

	co(comb(M, X - M));

	Would you please return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int N,D;
  cin>>N>>D;
  
  vector<long int>X(N);
  vector<long int>Y(N);
  
  for(int i=0;i<N;i++){
    cin>>X.at(i)>>Y.at(i);
  }
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    if(X.at(i)*X.at(i)<=(D+Y.at(i))*(D-Y.at(i))){
      ans++;
    }
  }
  cout<<ans<<endl;
}                     

Measured memory_bytes: 6424
import java.util.Scanner;
//
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int a=sc.nextInt();
		int b=sc.nextInt();
		String a_st =String.valueOf(a);
		String b_st =String.valueOf(b);
		for (int i=0;i<b-1;i++) {
			a_st +=String.valueOf(a);
		}
		for (int i=0;i<a-1;i++) {
			b_st +=String.valueOf(b);
		}
		if (a_st.compareTo(b_st)<=0) {
			System.out.println(a_st);
		} else{
			System.out.println(b_st);
		}
		
		//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//メソッド置き場

	//----------------------------------------
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
/*--------------------------------------------*/
int n;
V take(3+1);
V l(8+1);//l[i]の竹をAで使うか，Bで使うか，Cで使うか，使わないかの全探索
//その都度合成していき,最後に伸ばしたり縮めたりして調整
//4^8=66536通り
int tmp;
int dfs(int depth,int a,int b,int c){
    if(depth==n){
        if(!a||!b||!c)return INF;//A,B,Cを構成する竹がないことはない
        return abs(take[0]-a)+abs(take[1]-b)+abs(take[2]-c);
    }
    //not use
    int res=dfs(depth+1,a,b,c);
    //use
    res=min(res,dfs(depth+1,a+l[depth],b,c)+(a==0?0:10));//depth番目の竹をaとして使う
    res=min(res,dfs(depth+1,a,b+l[depth],c)+(b==0?0:10));//最初の竹は合成ではない
    res=min(res,dfs(depth+1,a,b,c+l[depth])+(c==0?0:10));
    return res;
}
int main(){
    cin>>n;rep(i,3){cin>>take[i];}
    rep(i,n){cin>>l[i];}
    cout<<dfs(0,0,0,0)<<endl;//無邪気に使用する竹全てに合成魔法使っているので,30引け
}


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
    int K,N;
    cin>>K>>N;
    vector<int> A(N);
    rep(i,N) cin>>A[i];
    int mav=0;
    rep(i,N-1) mav=max(mav,A[i+1]-A[i]);
    mav=max(mav,A[0]+K-A[N-1]);
    cout<<K-mav<<endl;
    return 0;
}


Measured memory_bytes: 4028
n=int(input())
a=list(map(int,input().split()))
hindo=dict()
for i in a:
    if i in hindo:
        hindo[i]+=1
    else:
        hindo[i]=1
ans=0
for num,cnt in hindo.items():
    if num==cnt:
        continue
    else:
        if num>cnt:
            ans+=cnt
        else:
            ans+=cnt-num
print(ans)

Measured memory_bytes: 21840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int n, k;
  cin >> n >> k;
  deque<int> deq;
  rep(i,n) {
    int v;
    cin >> v;
    deq.push_back(v);
  }
  int ans = 0;
  for(int i = 0; i<=k; i++) {
    for(int j = 0; j<=k-i; j++) {
      deque<int> d = deq;
      vi have;
      rep(m,i) {
        if(!d.empty()) {
          have.push_back(d.front());
          d.pop_front();
        }
      }
      rep(l,j) {
        if(!d.empty()) {
          have.push_back(d.back());
          d.pop_back();
        }
      }
      sort(have.begin(),have.end());
      int tmp = 0;
      rep(m,have.size()) tmp += have[m];
      rep(m,k-i-j) {
        if(m<have.size() && have[m]<0) tmp -= have[m];
      }
      ans = max(ans,tmp);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    int g[15][15], ans = 0;
    rep(i,n)rep(j,n) g[i][j] = -1;
    
    rep(i,n){
        int m;
        cin >> m;
        rep(j,m){
            int x, y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }

    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n) if(i>>j&1) {
            d[j] = 1; // j番目の人は正直な人
        }
        bool ok = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        int n = scn.nextInt();
        System.out.println(bubbleSort(createArray(n)));
    }
    
    private static int[] createArray(int n) {
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) {
            ary[i] = scn.nextInt();
        }
        return ary;
    }
    
    private static int bubbleSort(int[] ary) {
        int cnt = 0;
        for(int i = 0; i < ary.length; i++) {
            for(int j = ary.length - 1; j > i; j--) {
                if(ary[j] < ary[j - 1]) {
                    ary[j] ^= ary[j - 1];
                    ary[j - 1] ^= ary[j];
                    ary[j] ^= ary[j - 1];
                    cnt++;
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        for(int elm : ary) {
            sb.append(elm + " ");
        }
        System.out.println(sb.toString().trim());
        return cnt;
    }
}

Measured memory_bytes: 26400
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
 
 
ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
}
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans;
ll a,b,c,d,e,h,w;
 
//ll x[500005],y[500005],z[500005];
ll u[500005],v[500005];
ll suzi[1005][1005];
ll table[1005][1005];
 
int main(){
    cin>>n;
	d = INF;
	c = -100;
	for(i=0;i<n;i++){
		cin>>a>>b;
		c = max(a,c);
		d = min(b,d);
	}
	p(c+d);
	return 0;
}

Measured memory_bytes: 6016
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static CompareInfo ci = new System.Globalization.CultureInfo("ja-JP").CompareInfo;
        private static int Compare(string a, string b) { return ci.Compare(a, b, System.Globalization.CompareOptions.Ordinal); }

        static void Main(string[] args)
        {
            Console.WriteLine(Read().Contains("7") ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 25772
#include <stdio.h>

int main(){
  int a,b,m,n,k;

  scanf("%d %d",&a,&b);

  if(a>=b){
    m=a;
    n=b;
  }
  else{
    m=b;
    n=a;
  }
  while(n!=0){
    k=n;
    n=m%n;
    m=k;
  }
  printf("%d\n",m);

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;

int chk(vector<int> a){
    int n=a.size();
    fr(i,0,n){
        cout << a.at(i);
    }
    cout << endl;
}

int gcd(int a,int b){ //a>b
    int tmp=a%b;
    a=b;
    b=tmp;
    if(b!=0){
        return gcd(a,b);
    }else{
        return a;
    }
}

ll power(ll a,ll n){
    if(n==1){
        return a;
    }
    else if(n&1==1){
        --n;
        return power(a,n)*a;
    }else{
        n=n>>1;
        return power(a,n)*power(a,n);
    }
}

int main(void){
    int N,K;
    cin >> N >> K;

    int c=0;
    
    while(N!=0){
        N=N/K;
        c+=1;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main()
{
   int N,X,T;
   scanf("%d%d%d", &N,&X,&T);

   int ans;
   ans=(N+X-1)/X;
   ans=ans*T;

   printf("%d", ans);

   return 0;
}

Measured memory_bytes: 1676
#include<bits/stdc++.h>
#define pb push_back
#define N 100000

using namespace std;

vector<int> sieve() {
    bool is_prime[N];
    memset(is_prime, 1, sizeof(is_prime));

    for (int i = 2; i < N; i++) {
        if (!is_prime[i]) continue;
        for (int j = i * 2; j < N; j += i) is_prime[j] = 0;
    }
    vector<int> prime;
    for (int i = 2; i < N; i++) {
        if (is_prime[i]) prime.pb(i);
    }
    return prime;
}

int main() {
    //vector<int> prime = sieve();

    int n, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        bool succ = 1;
        for (int j = 2; j <= (int)sqrt(x); j++) {
            if (x % j == 0) {
                succ = 0;
                break;
            }
        }
        if (succ) cnt++;
    }
    cout << cnt << endl;

    return 0;
}



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

#define ll long long
#define pb push_back

int ans[2003][2003];
deque < int > v;
int sti1, sti2, fii1, fii2;

main() {
    int n = 38 * 37 + 1;
//    freopen("inp.in", "w", stdout);
    int k = 38;
    printf ("%d %d\n", n, k);
    int cnt = 2;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            if (j == 1) {
                ans[i][j] = 1;
            } else {
                ans[i][j] = cnt++;
            }
        }
    }
    int add = k - 1;
    sti1 = 2, fii1 = k;
    for (int i = 2; i <= k; i++) {
        for (int j = 2; j <= k; j++) {
            v.pb(ans[j][i]);
        }
    }
    for (int i = k + 1; i <= k + add; i++) {
        ans[i][1] = 2;
        for (int j = 2; j <= k; j++) {
            ans[i][j] = v.front();
            v.pop_front();
        }
    }
    sti1 = k + 1, fii1 = sti1 + add - 1;
    sti2 = sti1 + add, fii2 = sti2 + add - 1;
    cnt = 3;
    int xi = sti1;
    int res = 0;
    int cn = 0;
//    cout << sti1 << ' ' << fii1 << endl;
//    cout << sti2 << ' ' << fii2 << endl;
    for (int i = sti2; i <= n; i++) {
        ans[i][1] = cnt;
        res++;
        v.clear();
        int ri = sti1 + cn;
        int rj = 2;
        for (int j = 2; j <= k; j++) {
            v.pb(ans[ri][j]);
            ri++;
            if (ri > fii1) {
                ri = sti1;
            }
        }
        for (int j = 2; j <= k; j++) {
            ans[i][j] = v[j - 2];
        }
        cn++;
        if (res >= add) {
            sti1 = sti2;
            fii1 = fii2;
            sti2 = fii1 + 1;
            fii2 = sti2 + add - 1;
            res = 0;
            cnt++;
            cn = 0;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= k; j++) {
            printf ("%d ", ans[i][j]);
        }
        puts("");
    }
}


Measured memory_bytes: 11776
n = int(input())
P = list(map(int, input().split()))
ans = 0
for x in range(n-2):
    if P[x] > P[x + 1] and P[x + 1] > P[x + 2]:
        ans += 1
    elif P[x] < P[x + 1] and P[x + 1] < P[x + 2]:
        ans += 1
print(ans)

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

int main() {
  int N;
  cin >> N;
  bool x = true;
  for(int i=0;i<50000;i++){
    if(floor(i*1.08) == N){
      cout << i << endl;
      x = false;
      break;
    }
  }
    if(x)
      cout << ":(" << endl;
      
}


Measured memory_bytes: 3640
import java.util.*;
import java.util.ArrayList;


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

		// 値を取得
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ymd = new ArrayList<>();
		int M = sc.nextInt();
		String D = sc.next();
		int DNUM = Integer.parseInt(D); 
		int cnt = 0;
		//System.out.println(d1 + d10);

		// 月分回す
		for(int i= 1;i<=M;i++){
			// 日数分回す
			for(int j=1;j<=DNUM;j++){

				// 桁数チェック
				if(j < 10){
					continue;
				}

				// 桁の積を計算
				int d1 = Integer.parseInt(String.valueOf(j).substring(0,1));
				int d10 = Integer.parseInt(String.valueOf(j).substring(1,2));
				int pr = d1 * d10;
				// 条件チェック
				if(d1 >= 2 && d10 >= 2 && pr == i){
					cnt++;
				}
			}
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 22996
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (1 ? 1e9 + 7 : 998244353);
const int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
ll a, b, c, d, e, f, n, T;




int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	string z;
	cin >> a >> z;
	b = 0; c = 0;
	for (int i = 0; i < a; i++)if (z[i] == 'R')b++;
	for (int i = 0; i < b; i++)if (z[i] == 'W')c++;
	cout << c << endl;
}



Measured memory_bytes: 3776
<?php
    while(true){
        list($height, $width) = explode(" ",trim(fgets(STDIN)));

        if($height == 0 && $width == 0) exit;
    
        $bar1 = str_repeat("#",$width)."\n";
        $bar2 = "#".str_repeat(".",$width-2)."#\n";

        print $bar1;
        for($j = 0; $j < $height - 2 ; $j++){
            print $bar2;
        }
        print $bar1."\n";
    }    

Measured memory_bytes: 15360
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t ;

	int r_c = 0, s_c = 0, p_c = 0;
	for (int i = 0;i < t.length();i++) {
		if(k > i){
			if (t[i] == 'r')r_c++;
			else if (t[i] == 's')s_c++;
			else p_c++;
		}
		else {
			if (t[i] != t[i - k]) {
				if (t[i] == 'r')r_c++;
				else if (t[i] == 's')s_c++;
				else p_c++;
			}
			else {
				t[i] = 0;
			}
		}
	}

	long long ans = 0;
	ans += r_c * p;
	ans += s_c * r;
	ans += p_c * s;
	cout << ans << endl;
	return 0;
}

//CCCCCCCCCCCCCCCCCC
//int main() {
//	int x;
//	cin >> x;
//	vector<int> sosuu(100004);
//
//	for (int i = 2;i <= 100003;i++) {
//		sosuu[i] = 0;
//	}
//
//	for (int i = 2;i <= 100003;i++) {
//		if (sosuu[i] == 0) {
//			for (int j = i*2;j <= 100003;j = j + i) {
//				sosuu[j]++;
//			}
//		}
//	}
//
//	for (int i = x;i <= 100003;i++) {
//		if (sosuu[i] == 0) {
//			cout << i << endl;
//			return 0;
//		}
//	}
//
//	return 0;
//}

//BBBBBBBBBBBBBBBBBB
//int main() {
//	long long a, b, k;
//	cin >> a >> b >> k;
//
//	if (k > a) {
//		k -= a;
//		a = 0;
//		b -= k;
//		if (b < 0)b = 0;
//	}
//	else {
//		a -= k;
//	}
//
//	cout << a << " " << b << endl;
//
//	return 0;
//}

//AAAAAAAAAAAAAAAAA
//int main() {
//	string s, t;
//	cin >> s >> t;
//
//	cout << t << s << endl;
//
//	return 0;
//}

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

typedef long long ll;

const int MAXN = 2e5 + 5;

int N, Q;
int a[MAXN], b[MAXN];
int diff[MAXN];
multiset <int> pos, neg;
ll sum;

void in(int x) {
	diff[x] = b[x] - a[x];
	sum += a[x];
	if (x == 1 || x == N)
		return;
	if (diff[x] < 0)
		neg.insert(diff[x]);
	else {
		pos.insert(diff[x]);
		sum += diff[x];
	}
}

void out(int x) {
	sum -= a[x];
	if (x == 1 || x == N)
		return;
	if (diff[x] < 0)
		neg.erase(neg.find(diff[x]));
	else {
		pos.erase(pos.find(diff[x]));
		sum -= diff[x];
	}
}

int main() {
	scanf("%d%d", &N, &Q);
	N *= 2;
	for (int i = 1; i <= N; i++)
		scanf("%d", a + i);
	for (int i = 1; i <= N; i++)
		scanf("%d", b + i);

	for (int i = 1; i <= N; i++) 
		in(i);
	
	while (Q--) {
		int p, x, y;
		scanf("%d%d%d", &p, &x, &y);
		out(p);
		a[p] = x;
		b[p] = y;
		in(p);
		printf("%lld\n", sum + (pos.size() % 2 ? max(-*pos.begin(), *neg.rbegin()) : 0));   
	}
	
	return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN
    
    string s;cin>>s;
    int y = stoi(s.substr(0,4));
    int m = stoi(s.substr(5,2));
    int d = stoi(s.substr(8,2));
    tuple<ll,ll,ll> t = make_tuple(y,m,d);
    if (make_tuple(2019,4,30)>=t){
        cout<<"Heisei"<<endl;
        return 0;
    }
    cout<<"TBD"<<endl;
    return 0;
}

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> p (N);
  for(int i; i < N; i++)
  {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i; i < K; i++)
  {
    ans += p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

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

        BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
        String str[] = (br.readLine()).split("\\s+");
        int A = Integer.parseInt(str[0]);
        int P = Integer.parseInt(str[1]);
        System.out.println((P+3*A)/2);

        } catch(IOException e) {
            System.out.println("Exception :" + e);
        }

    }
}

Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve()
{
    string s;

    cin >> s;

    vector<bool> saw(128, false);

    for (char c : s)
    {
        if (saw[c])
        {
            cout << "no" << endl;
            return 0 ;
        }

        saw[c] = true;
    }

    cout << "yes" << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

int s[maxn], p[maxn];
vector <pair <int, int> > a[maxn];
ll ans;
int n;

void dfs(int v, int pr)
{
	p[v] = pr;
	s[v] = 1;
	ri(0, a[v].size())
	{
		if (a[v][i].X != pr)
		{
			dfs(a[v][i].X, v);
			s[v] += s[a[v][i].X];
		}
	}
	if (2 * s[v] == n)
	{
		ri(0, a[v].size())
		{
			if (a[v][i].X == pr)
			{
				ans -= a[v][i].Y;
			}
		}
//		cout << v << " " << ans << endl;
	}
	int fl = 1;
	if (2 * s[v] <= n)
		fl = 0;

	ri(0, a[v].size())
	{
		if (a[v][i].X != pr)
		{
			if (2 * s[a[v][i].X] >= n)
				fl = 0;
		}
	}

	if (fl)
	{
//		cout << v << " " << pr << endl;
		ans = -inf;
		ri(0, a[v].size())
		{
			ans = max(ans, (ll)-a[v][i].Y);
		}
//		cout << ans << endl;
	}
	return;
}

int main()
{
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, n - 1)
    {
    	int x, y, z;
    	cin >> x >> y >> z;
    	a[x].pb(mp(y, z));
    	a[y].pb(mp(x, z));
    }
    ans = 0;
    dfs(1, 0);
    fi(1, n)
    {
    	rj(0, a[i].size())
    	{
    		if (a[i][j].X != p[i])
    		{
	    		ans += 2ll * (ll)min((n - s[a[i][j].X]), s[a[i][j].X]) * (ll)a[i][j].Y;
	    	}
    	}
    }


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

Measured memory_bytes: 13184
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int i,j,n;
    scanf("%d",&n);
    getchar();
    for(i=0;i<n;i++)
    {
        char a[1050]={0};
        //fflush(stdin);
        scanf("%[^\n]",a);
        getchar();
        for(j=0;j<strlen(a);j++)
        {
            if(a[j]=='H'&&a[j+1]=='o'&&a[j+2]=='s'&&a[j+3]=='h'&&a[j+4]=='i'&&a[j+5]=='n'&&a[j+6]=='o')
            {
                a[j+6]='a';
            }
        }
        printf("%s\n",a);
        //for(j = 0; j < 1050; j++)a[j]=0;
    }
    return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
 
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
  int n;
  cin>>n;
  int ans=0;
  int ctr=0;
  rep(i,n){
    int cur=i+1;
    int tmp;
    cin>>tmp;
    if(tmp==cur) ++ctr;
    else{
      ans+=(ctr+1)/2;
      ctr=0;
    }
  }
  ans+=(ctr+1)/2;
  cout<<ans<<endl;
}
  


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static char S[100001];

static bool cExist['z' - 'a' + 1];

static void initCExist(void) {
	for (size_t i = 0; i < (size_t)('z' - 'a' + 1); i++) {
		cExist[i] = false;
	}
}

#define MOD_VAL (UINT64_C(1000000007))

static uint64_t aa(uint64_t a) {
	uint64_t result = 1;

	while (1 < a) {
		result = result * a % MOD_VAL;

		a--;
	}

	return result;
}

int main(void) {
	size_t N;

	scanf("%zu\n%s", &N, S);

	uint64_t count['z' - 'a' + 1];
	for (size_t i = 0; i < (uint64_t)('z' - 'a' + 1); i++) {
		count[i] = 0;
	}

	for (size_t i = 0; i < N; i++) {
		count[S[i] - 'a']++;
	}

	uint64_t result = 1;

	for (size_t i = 0; i < (uint64_t)('z' - 'a' + 1); i++) {
		result = result * (count[i] + 1) % MOD_VAL;
	}

	printf("%"PRIu64, result - 1);

	return 0;
}


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

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

    string s;
    ll k;
    cin >> s >> k;
    rep(i, min((ll)s.size(), k)) {
      if(s[i] >= '2') {
        cout << s[i] << endl;
        return 0;
      }
    }
    cout << 1 << endl;
    return 0;
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
int N, D;
cin >> N >> D;
vector<vector<int>> X(N, vector<int>(D));
for(int i = 0; i < N; i++){ 
   for(int j = 0; j < D; j++){ 
      cin >> X[i][j];
   }
}

int cnt = 0;
for(int i = 0; i < N; i++){ 
   for(int j = i + 1; j < N; j++){ 
     int sum = 0;
     for(int m = 0; m < D; m++){ 
        sum += pow(abs(X[i][m] - X[j][m]), 2);
     }
     bool flag = false;
    //  print(sum);
     for(int k = 0; k <= sum; k++){ 
        if(k * k == sum) flag = true;
     }
     if(flag) cnt++;
   }
}

print(cnt);
 }

Measured memory_bytes: 256
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

// macro templates

#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < n;i++)
#define dv(TYPE,VAL) TYPE VAL;cin >> VAL;
#define vi(TYPE,NAME,SIZE,INIT) vector<TYPE> NAME(SIZE,(INIT))
#define vin(TYPE,NAME,SIZE) vector<TYPE> NAME(SIZE);rep(i,SIZE)cin >> NAME[i]
#define vout(ARRAY) for(auto i : ARRAY)cout << i << ' ';cout << '\n'
#define vvi(TYPE,NAME,LOW,COL,INIT) vector<vector<TYPE>> NAME(LOW,vector<TYPE>(COL,INIT))
#define vpi(T1,T2,NAME,SIZE,I1,I2) vector<pair<T1,T2>> NAME(SIZE,make_pair(I1,I2))
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define dup(x,y) (x + y - 1)/(y)
#define sz(v) (int64_t)v.size()
#define CUM(arr,cum) vector<ll> cum(sz(a)+1,0); rep(i,sz(a)) cum[i+1] = cum[i] + 1
#define PY(COND) if(COND){cout << "YES" << '\n';return;}
#define PN(COND) if(COND){cout << "NO" << '\n';return;}
#define PYN(COND) cout << ((COND) ? "YES" : "NO") << '\n';
#define Py(COND) if(COND){cout << "Yes" << '\n';return;}
#define Pn(COND) if(COND){cout << "No" << '\n';return;}
#define Pyn(COND) cout << ((COND) ? "Yes" : "No") << '\n';return

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pi acos(-1)
#define fi first
#define se second
#define pq priority_queue

#define MULTITEST; int t;cin >> t;rep(_,t)main2();
#define IOB; cin.tie(0);ios::sync_with_stdio(false);

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

// templates end

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

    rep(i,5){
        int64_t foo;cin >> foo;
        if(foo == 0){
            cout << i + 1 << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 3604
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();

    let c0 = cv.iter().filter(|&&c| c == '0').count();
    let c1 = cv.len() - c0;
    let ans = min(c0, c1) * 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main() {
  int th, ta, ah, aa;
  cin >> th >> ta >> ah >> aa;
  while(true) {
  	ah -= ta;
    if(ah <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    th -= aa;
    if(th <= 0) {
    	cout << "No" << endl;
      return 0;
    }
  }
}

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


using namespace std;

int main(){
    /*
    string a,b;
    cin >> a>>b;
    
    if(a == b){
    cout << "=";
    }else if(a < b){
        cout << "<";
    }else {
    cout << ">";
    }
    */
  int a,b;
    cin >> a>>b;
   cout << a*a-b;
    
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  string s; cin >> s;
  int left = 0, right = 0; // W, E
  REP(i, n) if (s[i] == 'E') ++right;
  int ans = n;
  // i 人目 (0-based) より左にいる人は'E'
  //                      右          'W'でなければならない
  REP(i, n) {
    if (s[i] == 'E') --right;
    ans = min(ans, left + right);
    if (s[i] == 'W') ++left;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 720
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int a[120];
int n;
int cnt =0;
void bubblesort(){
	for(int i = n-1;i >0;i--){
		for(int j =0;j < i;j++){
			if(a[j+1]<a[j]){
				swap(a[j],a[j+1]);
				cnt++;
			}
		}
	}
}

int main(){

	while(cin>>n,n){
		cnt = 0;
		for(int i =0;i <120;i++){
			a[i]=0;
		}
		for(int i =0;i < n;i++){
			cin>>a[i];
		}
		/*rep(i,n){
			cout <<a[i];
			if(i!=n-1)cout <<" ";
		}cout <<endl;*/
		bubblesort();
		/*rep(i,n){
			cout <<a[i];
			if(i!=n-1)cout <<" ";
		}
		cout <<endl;*/
		cout <<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        string s = to_string(i+1);
        if (s.size()%2 == 1) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };
 
signed main() {
	int N;
	cin >> N;

	vector<int> a(N);
	rep(i, N) scanf("%lld", &a[i]);

	unordered_map<int, int> m;
	rep(i, N) m[a[i]] = i;

	int ret = 0;
	set<int> st;
	st.insert(-1);
	st.insert(N);
	REP(i, 1, N) {
		int idx = m[i];
		auto it = st.lower_bound(idx);
		it--;
		int left = idx - *it;
		int right = *(st.upper_bound(idx)) - idx;
		ret += i * right * left;
		st.insert(idx);
	}

	cout << ret << endl;
}


Measured memory_bytes: 19400