akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,a,sum=0,mx=0,i;
    cin>>n;
    for (i=0;i<n;i++)
    {
        cin>>a;
        mx=max(mx,a);
        sum+=a;
    }
    cout<<sum-mx/2<<endl;
}

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

int main(void){
	string S, T;
  	int ans = 0;
  	cin >> S;
  	cin >> T;
	for(int i = 0; i < 3; i++){
		if(S[i] == T[i]) ans++;
    }
  	cout << ans << endl;
  
  
  return 0;
}

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

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int[] in = new int[3];
    for(int i=0;i<3;i++){
      in[i] = scan.nextInt();
    }
    scan.close();
    
    Arrays.sort(in);
    System.out.println(in[2]*10+in[0]+in[1]);
    return;
  }
}

Measured memory_bytes: 23252
#include<iostream>
#include<vector>

typedef long long int ll;

using namespace std;

int main(){
    ll x, y,cnt=1;
    cin >> x >> y;
    
    while(1){
        x *= 2;
        if(x<=y)
            cnt++;
        else
            break;
        
    }
    cout << cnt;
}

Measured memory_bytes: 256
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> a(n+1);
	rep(i, n + 1) {
		a[i].resize(n + 1, 0);
	}
	int l, r;
	rep(i, m) {
		cin >> l >> r;
		a[l][r]++;
	}
	rep(i, n+1) {
		if (i == 0) continue;
		rep(j, n) {
			a[i][j + 1] += a[i][j];
		}
	}
	rep(i, n) {
		rep(j, n + 1) {
			if (j == 0) continue;
			a[i + 1][j] += a[i][j];
		}
	}
	rep(i, q) {
		cin >> l >> r;
		cout << a[r][r] - a[r][l - 1] - a[l - 1][r] + a[l-1][l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(6);
  for (int i = 0; i < 6; i++){
    cin >> a.at(i);
  }
  vector<int> num(4);
  num = {0,0,0,0};
  for (int i = 0; i < 6; i++){
    if(a.at(i) == 1){
      num.at(0) ++;
    }
    else if(a.at(i) == 2){
      num.at(1) ++;
    }
    else if(a.at(i) == 3){
      num.at(2) ++;
    }
    else if(a.at(i) == 4){
      num.at(3) ++;
    }
  }
  bool flag = false;
  for(int i = 0; i < 4; i++){
    if (num.at(i) >= 3){
      flag = true;
    }
  }
  if(flag){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
 
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int h = sc.nextInt(), w = sc.nextInt(), n = sc.nextInt();
		int[][] map = new int[h][w];
		boolean[][] reached = new boolean[h][w];
		int sx, sy;
		sx = sy = 0;
		for (int i = 0; i < h; i++) {
			String s = sc.next();
			for (int j = 0; j < w; j++) {
				switch(s.charAt(j)) {
				case 'S':
					map[i][j] = 0;
					sx = i; sy = j;
					break;
				case '.':
					map[i][j] = 0;
					break;
				case 'X':
					map[i][j] = -1;
					break;
				default:
					map[i][j] = Integer.parseInt(""+s.charAt(j));
					break;
				}
			}
		}
		
		Queue<Integer> qx = new LinkedList<Integer>();
		Queue<Integer> qy = new LinkedList<Integer>();
		Queue<Integer> count = new LinkedList<Integer>();
		int res = 0;
		int[] dx = {0, 0, 1, -1};
		int[] dy = {1, -1, 0, 0};
		I:for (int i = 1; i <= n; i++) {
			qx.add(sx);
			qy.add(sy);
			count.add(0);
			for (boolean[] r : reached)
				Arrays.fill(r, false);
			reached[sx][sy] = true;
			while (!qx.isEmpty()) {
				int x = qx.poll(), y = qy.poll(), c = count.poll();
				if (map[x][y] == i) {
					res += c;
					qx.removeAll(qx); qy.removeAll(qy); count.removeAll(count);
					sx = x; sy = y;
					continue I;
				}
				for (int j = 0; j < 4; j++) {
					int X = x + dx[j], Y = y + dy[j];
					if (X >= 0 && Y >= 0 && X < h && Y < w &&
							map[X][Y] >= 0 && !reached[X][Y]) {
						qx.add(X); qy.add(Y); count.add(c+1);
						reached[X][Y] = true;
					}
				}
			}
		}
		out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 138848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int xa = min(k,a);
  k = k-xa;
  int xb = min(k,b);
  k -= xb;
  int xc = k;
  int sum = xa-xc;
  cout<<sum<<endl;
  
}

Measured memory_bytes: 3624
n = gets.to_i
s = []
n.times { s << gets.chomp }
 
sorted_s = s.map { |sn| sn.chars.sort.join }.sort
 
counts = []
successive = 0
sorted_s.each_with_index do |sn, i|
  if sn == sorted_s[i - 1] || i == 0
    successive += 1
  else
    counts << successive
    successive = 1
  end
end
counts << successive
 
answer = counts.map { |n| n * (n - 1) / 2 }
 
puts answer.inject(:+)

Measured memory_bytes: 34152
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring> 
#include <map>
#include <cmath>
#include <cstdio>
#include <sstream>
#include <stack>
#include <ctime>
#include <string.h>
#include <utility>
#include <cstdlib>
#include <functional>
#include <deque>
#include <list>
#define open_in(n) freopen("n","r",stdin)
#define open_out(n) freopen("n","w",stdout)
#define rep(i,n) for (int i=0;i<n;i++)
#define repw(i,w) for(int i=w;i>0;i--)
#define repn(i,m,n) for (int i=n;i<m;i++)
#define for_all(it,n) for(__typeof((n).begin()) it=(n).begin();it!=(n).end();it++)
#define IT iterator
#define Size(n) (int)((n).size()) 
#define pb push_back
#define mpa make_pair
#define pa pair
#define all(n) (n).begin(),(n).end
#define dump(n) cerr<<#n<<"="<<(n)<<endl 
#define _abs(a) ((a)>0?(a):-(a))
#define inf 1<<32
using namespace std;
template <class t>
	t abs2(const t &x){
		return (x<0?-x:x);
	}
template <class t>	
	t max2(const t &x,const t &y){
		return (x>y?x:y);
	}
template <class t>
	t min2(const t &x,const t &y){
		return (x<y?x:y);
	}
template <class t>
    t gcd(const t &x,const t &y){
	    return x ? gcd(y%x,x) : y;
    }
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef long long ll;
typedef map<int,int> mii;
typedef queue<int> qi;
typedef set<int> si;
ll a[100005],num[2];
ll n,c,ans,mx,mx2,f;
map<ll,int> m;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		m[a[i]]++;
		if(m[a[i]]>=2) mx=max(mx,a[i]),f++;  
	}
	if(f<2) {
		cout<<0<<endl;
		return 0;
	}
	if(m[mx]>=4){
		cout<<(long long)mx*mx<<endl;
		return 0;
	}
	for(int i=0;i<n;i++){
		if(m[a[i]]>=2&&a[i]!=mx) mx2=max(mx2,a[i]);
	}
	cout<<mx*mx2<<endl;
	return 0; 
}

Measured memory_bytes: 7296
from decimal import Decimal, ROUND_HALF_UP

N = int(input(''))
list = input('').split(' ')
list = [int(n) for n in list]
mean = Decimal(str(sum(list) / len(list)))
mean = mean.quantize(Decimal('0'), rounding=ROUND_HALF_UP)
out = 0
for i in range(N):
    out += (list[i] - mean) ** 2
print(out)

Measured memory_bytes: 5076
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
#define all(x) (x).begin(),(x).end()


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

  int ans = 0;
  for(int i=1; i<=n; i += 2){
    int cnt = 0;
    for(int j=1; j<= i; j++){
      if(i % j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }
  cout << ans << ln;
 }


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let line: Vec<u64> = read_as_vec();
    let (n, m) = (line[0], line[1]);

    let (mut left, mut right) = (1, n);
    for _ in 0..m{
        let line: Vec<u64> = read_as_vec();
        let (l, r) = (line[0], line[1]);
        left = cmp::max(left, l);
        right= cmp::min(right, r);
    }

    if right < left{
        println!("0");
    }else{
        println!("{}", right-left+1);
    }
}


Measured memory_bytes: 4352
n = int(input())
s = list(map(int, input()))


def is_Lucky(x):
    x = tuple(map(int, '{:03d}'.format(x)))
    idx = 0
    for c in s:
        if x[idx] == c:
            idx += 1
            if idx == 3:
                return True
    else:
        return False


ans = 0
for i in range(1000):
    if is_Lucky(i):
        ans += 1
print(ans)


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

int main() {
    int N;
    cin >> N;
    vector<int>H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int ans = 1;
    int cnt = H[0];
    for(int i = 1; i < N; i++) {
        if(H[i] >= cnt) {
            ans++;
        }
        cnt = max(cnt,H[i]);
    }
    cout << ans << endl;
} 



Measured memory_bytes: 256
def _input():
    array = input().split()
    return int(array[0])

def input_str(number):
    array = []
    for i in range(number):
        array.append(input())
    return array

def answer(array):
    return ''.join(sorted(array))
    
if __name__ == "__main__":
    n = _input()
    array = input_str(n)
    print(answer(array))


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


int main(){
    int N,M;
    cin>>N>>M;
    vector<string> vecA(N);
    vector<string> vecB(M);

    for(auto &x:vecA)cin>>x;
    for(auto &x:vecB)cin>>x;

    for(int i=0;i<=N-M;++i){
        for(int k=0;k<=N-M;++k){
            bool temp=false;
            
            if(vecA[i][k]==vecB[0][0]){
                temp=true;
                for(int n=0;n<M;++n){
                    for(int m=0;m<M;++m){
                        if(m+k>=N||n+i>=N||vecA[i+n][k+m]!=vecB[n][m]){
                            temp=false;
                        }
                    }
                }
            }
            if(temp){
                cout<<"Yes"<<endl;
                return 0;
            }
                
        }
    }

    cout<<"No"<<endl;


}

Measured memory_bytes: 256
#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--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007

using namespace std;

int n;
int solve(){
  vector<int>t(86401);
  rep(i, n){
    int h1,m1,s1,h2,m2,s2;
    scanf("%2d:%2d:%2d %2d:%2d:%2d",&h1,&m1,&s1,&h2,&m2,&s2);
    int l = h1*3600+m1*60+s1;
    int r = h2*3600+m2*60+s2;
    t[l]++;
    t[r]--;
  }
  rep(i, 86400)t[i+1]+=t[i];
  int result = 0;
  rep(i, 86400)result = max(result, t[i]);

  return result;
}

int main(){
  while(cin>>n){
    if(n==0)break;
    cout<<solve()<<endl;
  }

  return 0;
}



Measured memory_bytes: 3488
import java.util.*;

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

        for(int i=1;;i++){
            int x = sc.nextInt();
            if(x != 0){
                System.out.println("Case "+i+": "+x);
            }else{
                break;
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 42584
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

class union_find
{
public:
    vector<int> parent;
    vector<int> count;
    vector<int> rank;

public:
    union_find(int vertex_count)
        : parent(), count(), rank()
    {
        parent.assign(vertex_count, 0);
        count.assign(vertex_count, 1);
        rank.assign(vertex_count, 1);

        for (int i = 0; i < vertex_count; i++)
        {
            parent[i] = i;
        }
    }

public:
    int find(int u)
    {
        if (parent[u] == u) return u;
        return parent[u] = find(parent[u]);
    }

    void merge(int u, int v)
    {
        u = find(u);
        v = find(v);

        if (u == v) return;
        if (rank[u] < rank[v]) swap(u, v);

        parent[v] = u;
        count[u] += count[v];
        if (rank[u] == rank[v]) rank[u]++;
    }

    int size(int u)
    {
        return count[find(u)];
    }
};

//union_find uf(N);
//uf.merge(u, v);
//int u_parent = uf.find(u);
//int u_size = uf.size(u);

#include <set>

set<int> friendship[100000];
set<int> blockship[100000];

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

	int N, M, K;
	cin >> N >> M >> K;

    union_find uf(N);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        friendship[a].insert(b);
        friendship[b].insert(a);

        uf.merge(a, b);
    }

    for (int i = 0; i < K; i++)
    {
        int a, b;
        cin >> a >> b;

        a--;
        b--;

        int pa = uf.find(a);
        int pb = uf.find(b);

        if (pa == pb)
        {
            blockship[a].insert(b);
            blockship[b].insert(a);
        }
    }

    for (int i = 0; i < N; i++)
    {
        int total = uf.size(i) - 1;
        total -= friendship[i].size();
        total -= blockship[i].size();

        cout << total << " ";
    }

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int s_size = s.size();
  
  for(int tmp = 0; tmp < (1 << s_size - 1); tmp++) {
    bitset<20> b(tmp);
    
    int sum = s.at(0) - '0';
    string ans = ""s + s.at(0);
    for (int i = 0; i < s_size - 1; i++){
      if(b.test(i)) { 
        sum += s.at(i + 1) - '0';
        ans += "+";
      }
      else {
        sum -= s.at(i + 1) - '0';
        ans += "-";
      }
      ans += s.at(i + 1);
    }
    if(sum == 7){
      ans += "=7";
      cout << ans << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
N = gets.to_i
K = gets.to_i
xs = gets.split.map(&:to_i)
ans = 0
xs.each do |x|
    roboA = (x-0).abs
    roboB = (K-x).abs
    if roboA < roboB
        ans += roboA*2
    elsif
        ans += roboB*2
    end
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  string s, t;
  cin >> s >> t;

  int shared_n = 0;
  for (int i = s.size() - 1; i >= 0; --i) {
    if (i + 1 > t.size())
      break;
    if (s.substr(i) == t.substr(0, s.size() - i))
      shared_n = s.size() - i;
  }

  for (int i = shared_n; i >= 0; --i) {
    if (s.size() + t.size() - i >= N) {
      cout << s.size() + t.size() - i << endl;
      return 0;
    }
  }

  cout << N << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int m, k; scanf("%d%d", &m, &k);
	
	if(m == 0) {
		if(k == 0) {
			printf("0 0\n");
		} else {
			printf("-1\n");
		}
		return 0;
	}
	
	if(m == 1) {
		if(k == 0) {
			printf("0 0 1 1\n");
		} else {
			printf("-1\n");
		}
		return 0;
	}
	
	int tmp = 1 << m;
	if(k >= tmp) {
		printf("-1\n");
		return 0;
	}
	
	std::vector<int> ans;
	for(int i = 0; i < tmp; i++) if(i != k) ans.push_back(i);
	ans.push_back(k);
	for(int i = tmp - 1; i >= 0; i--) if(i != k) ans.push_back(i);
	ans.push_back(k);
	
	for(auto v: ans) printf("%d ", v);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2932
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()

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

using namespace std;
typedef long long ll;
const int INF = 10000000;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n) {
        cin >> h[i];
    }

    vector<vector<int>> to(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int ans = 0;
    rep(i, n){
        bool flag = true;
        for(int e : to[i]){
            if(h[i] <= h[e]){
                flag = false;
                break;
            }
        }
        if(flag)++ans;
    }
    cout << ans << endl;
}

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

const ll mod = 998244353;
vector<ll> fat;

void precompute(ll n){
    fat.clear();
    fat.push_back(1);
    for(int i=1;i<=n;i++){
        fat.push_back((fat.back()*i)%mod);
    }
}

ll binpow(ll a, ll b){
    if(b==0){
        return 1ll;
    }
    ll temp = binpow(a,b/2)%mod;
    if(b%2){
        return (((temp*temp)%mod)*a)%mod;
    }
    return (temp*temp)%mod;
}

ll modInverse(ll x){
    return binpow(x,mod-2);
}

ll c(ll n, ll m){
    return (fat[n]*modInverse(fat[m])%mod * modInverse(fat[n-m]%mod)%mod)%mod;
}

int main(){
    ll n, m, k, acm=0;

    cin >> n >> m >> k;
    precompute(n);
    for(int i=0;i<=k;i++){
        acm = (acm + 1ll*((c(n-1,i)%mod)*((m*binpow(m-1,n-1-i))%mod))%mod)%mod;
    }

    cout << acm%mod << '\n';

    return 0;
};


Measured memory_bytes: 5348
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())

#最大公約数
def gcd(a,b):
	while b:
		a,b = b, a%b
	return a

#最小公倍数
def lcm(a,b):
	return a*b // gcd(a,b)

def hurui(n):
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

Primes = hurui(8000)

pn = []
for p in Primes:
	pn.append(p)

ans = [[0]*N for i in range(N)]
for y in range(N):
	if y%2 == 0:
		xx = range(0,N,2)
	else:
		xx = range(1,N,2)

	for x in xx:
		pl = (y+x)//2
		mn = (y-x)//2 + N + (N-1)//2
		ans[y][x] = pn[pl]*pn[mn]

ed = defaultdict(bool)
for y in range(N):
    for x in range(N):
        if ans[y][x] == 0:
            tmp = 1
            if x > 0:
                tmp = lcm(tmp,ans[y][x-1])
            if x < N-1:
                tmp = lcm(tmp,ans[y][x+1])
            if y > 0:
                tmp = lcm(tmp,ans[y-1][x])
            if y < N-1:
                tmp = lcm(tmp,ans[y+1][x])

            while ed[tmp+1]:
                tmp += tmp

            ans[y][x] = tmp + 1
            ed[tmp+1] = True

for a in ans:
    print(' '.join(map(str,a)))


Measured memory_bytes: 29248
import java.util.Scanner;

public class Main {

	static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {

		int N = s.nextInt();
		String str = s.next();
		int[] w = new int[N];
		int[] e = new int[N];



		w[0] = (str.charAt(0) == 'W') ? 1 : 0;
		for (int i = 1; i < N; i++) {
			w[i] = w[i - 1] + (str.charAt(i) == 'W' ? 1 : 0);
		}

		e[N - 1] = (str.charAt(N - 1) == 'E') ? 1 : 0;
		for (int i = N - 2; 0 <= i; i--) {
			e[i] = e[i + 1] + (str.charAt(i) == 'E' ? 1 : 0);
		}

		int min = Math.min(w[N - 1], e[0]);
		for (int i = 1; i < N - 1; i++) {
			min = Math.min(min, w[i - 1] + e[i + 1]);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 32288
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    a = ii()
    print(a + a**2 + a**3)


main()


Measured memory_bytes: 10012
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int K,A,B;
  cin>>K>>A>>B;
  if(B-A<=2)
    cout<<K+1<<endl;
  else
    cout<<(K-(A-1))/2*(B-A)+A+(K-(A-1))%2<<endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
lli calc(lli a, lli b)
{
    if (a % b == 0) {
        return a / b - 1;
    } else {
        return a / b;
    }
}
int main()
{
    int n;
    cin >> n;
    vector<lli> a(n);
    rep(i, n) cin >> a[i];
    int state = 1;
    lli ans = 0;
    rep(i, n)
    {
        //cout << state << endl;
        if (i != 0) {
            if (state < a[i]) {
                ans += calc(a[i], state);
            } else if (state == a[i]) {
                state++;
            }
        } else {
            ans += calc(a[i], state);
            state++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;




int main(void){
   int x;
   cin>>x;
   while(1){
      bool ok = true;
      for(int i=2;i<x;i++){
         if(x%i==0){
            ok=false;
            break;
         }
      }
      if(ok)break;
      x++;
   }
   cout<<x<<endl;

return 0;
}




Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(void) {
  int N;
  int *L = new int[N];
  
  cin >> N;
  int max = 0;
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> L[i];
    if(max < L[i]) {
      max = L[i];
    }
    sum += L[i];
  }
  
  sum -= max;
  if(sum > max)
    cout << "Yes";
  else
    cout << "No";
 return 0; 
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

a.sort()

alice = 0
bob = 0
flag = 0
for i in range(N):
    if flag == 0:
        alice += a[N-(i+1)]
        flag = 1
    else:
        bob += a[N-(i+1)]
        flag = 0

print(alice - bob)

Measured memory_bytes: 3064
Q = int(input())
lr_list = [list(map(int, input().split())) for _ in range(Q)]

max_val = max([lr[1] for lr in lr_list])

# エラトステネスの篩
num_list = list(range(max_val + 1))
for num in num_list[2:max_val // 2 + 1]:
    if num > 0:
        for i in range(num*2, max_val+1, num):
            num_list[i] = -1

prime_num_set = set([num for num in num_list if num>0][1:])

# 累積和
sum_list = [0, 0, 0]
for i in range(3, max_val+1):
    if i in prime_num_set and (i+1)//2 in prime_num_set:
        sum_list.append(sum_list[-1]+1)
    else:
        sum_list.append(sum_list[-1])

for l, r in lr_list:
    print(sum_list[r] - sum_list[l-1])

Measured memory_bytes: 33656
/*input
 
*/
/*
Contest: 
Problem: 
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
 
#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
#define int long long int
 
const int MOD = 1e9 + 7, MAXN = 1e2 + 10, MAXW = 1e5 + 10;
 
int N, W;
vector<int> value, weight;
int dp[MAXN][MAXW];
 
int solve(int i, int we){
    if(i < 0)
        return 0;
    if(dp[i][we] != -1)
        return dp[i][we];
    if(weight[i] > we)
        return dp[i][we] = solve(i - 1, we);
    else
        return dp[i][we] = max(solve(i - 1, we), value[i] + solve(i - 1, we - weight[i]));
}
 
signed main(){
    
    cin>> N >> W;
 
    value.resize(N);
    weight.resize(N);
 
    for(int i = 0; i < N; i++)
        cin>> weight[i] >> value[i];
 
    mem(dp, -1);
    if(W >= 1e5){
        int sum = 0;
        for(int i = 0; i < N; i++)
            sum += value[i];
        print(sum);
    }
    else{
        print(solve(N-1, W));
    }
 
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 86144
import sys
if __name__ == "__main__":
    N = int(input())
    A = [0] * N
    B = list(map(int,input().split()))
    for n in range(N-1,-1,-1):
        i = n
        while(1):
            if B[i] == i+1:
                A[n] = B.pop(i)
                break
            i -= 1
            if i < 0:
                print(-1)
                sys.exit()
    for a in A:
        print(a)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
from collections import *

def P(n, r):
    res = 1
    
    for i in range(r):
        res *= n-i
        res %= MOD
    
    return res

def bfs():
    q = deque([0])
    visited = [False]*N
    visited[0] = True
    ans = K
    
    while q:
        v = q.popleft()
        cnt = 0
        
        for nv in G[v]:
            if not visited[nv]:
                cnt += 1
                visited[nv] = True
                q.append(nv)
        
        if v==0:
            ans *= P(K-1, cnt)
            ans %= MOD
        else:
            ans *= P(K-2, cnt)
            ans %= MOD
            
    return ans

N, K = map(int, input().split())
MOD = 10**9+7
G = [[] for _ in range(N)]

for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

print(bfs())

Measured memory_bytes: 61872
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	double x,y,w,h,s1,s2;
	int i,j,k;
	while(~scanf("%lf%lf%lf%lf",&w,&h,&x,&y))
	{
	    int	k=0;
		if(x==w/2&&y==h/2) k=1;
		printf("%.12lf %d\n",1.0*w*h/2.0,k);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  uint32_t N;
  cin >> N;
  vector<uint32_t> A(N + 1), B(N + 1);
  for (uint32_t i = 1; i < N + 1; ++i) cin >> A[i];
  copy(A.begin(), A.end(), B.begin());

  for (uint32_t i = N; i > 0; --i) {
    uint32_t tmp = (uint32_t)(N / i);
    uint32_t sum = 0;
    for (uint32_t j = 1; j <= tmp; ++j) {
      sum += B[i * j];
    }
    if ((sum & 0x01) != A[i]) {
      B[i] = A[i] ^ 0x01;
    }
  }
  uint32_t BallNum = 0;
  for (uint32_t i = 1; i < N + 1; ++i) {
    BallNum += B[i];
  }
  cout << BallNum << endl;
  for (uint32_t i = 1; i < N + 1; ++i) {
    if (B[i]) cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define sz(a)       (ll)(a.size())
#define cr(P)       cout<<P<<"\n";return;
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,x,n)   for(ll i=x;i<n;i++)
#define frr(i,x,n)  for(ll i=n-1;i>=x;i--)
using namespace std;


const ll N   =  500005;
const ll mod = 1e9 + 7;



void solve(){

  ll x=0,y=0,c=0,ans=0;
  ll n,m,k;
  cin>>n >> k;
  ll a[n+1];
  for (ll i = 1; i <= n; ++i){
      cin >> a[i];
  }
  x = 1;
  vector<ll>v,vis(n+1);
  while(!vis[x]){
   vis[x] =1;
   v.pb(x);
   x = a[x];
  }
  if(sz(v)>k){
    cr(v[k]);
  }
  k -= sz(v);
  for (ll i = 0; i <= n; ++i){
      vis[i] = 0;
  }
  v.clear();
  
  while(!vis[x]){
   vis[x] =1;
   v.pb(x);
   x = a[x];
  }

  x =sz(v);
  k %= x;
  cr(v[k]);

 
}

signed main(){
     
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  //int T;cin >> T;while (T--)
  solve();
  return 0;
}


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

string s;
bool valmo(int v) {
	return v <= 12 && v > 0;
}

int main() {
	cin >> s;
	int f = (s[0] - '0') * 10 + s[1] - '0';
	int r = (s[2] - '0') * 10 + s[3] - '0';
	if (valmo(r) && valmo(f))
		cout << "AMBIGUOUS";
	else if (valmo(r))
		cout << "YYMM";
	else if (valmo(f))
		cout << "MMYY";
	else
		cout << "NA";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, ans;
    double x;

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

    x = (double)a + b;
    x = (double)x / 2;
    x = x + 0.5;
    ans = x;


    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
using System;

class Program
{
    static void Main(string[] args)
    {
        var R = 8;
        var n = int.Parse(Console.ReadLine());

        var d = new bool[R];
        var over = 0;

        var s = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            var x = int.Parse(s[i]) / 400;
            if (x < R) d[x] = true;
            else over++;
        }

        var a = 0;
        for (int i = 0; i < R; i++)
        {
            if (d[i]) a++;
        }

        var min = Math.Max(1, a);
        var max = a + over;

        Console.WriteLine($"{min} {max}");
    }
}


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


int main() {
  
  int N;
  cin>>N;
  
  vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
  int sw=0;
  int sw1=0;
  for (int i = 0; i < N; i++) {
      if(A.at(i)%2==0){
        sw++;
        if(A.at(i)%3==0||A.at(i)%5==0){
          sw1++;
          //cout<<"APPROVED"<<endl;
        }else{
          //cout<<"DENIED"<<endl;
        }
      }
}
  
  if(sw==sw1){
    cout<<"APPROVED"<<endl;
  }else{
    cout<<"DENIED"<<endl;
  }
  
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 2005
#define mod 998244353
#define ld long double
#define pb push_back
#define inf 1e9+5
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
		#ifndef ONLINE_JUDGE
	freopen("input1.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	fast;
	ll x,k,d,m1,m2;
	cin>>x>>k>>d;
	if(x==0){
		if(k&1LL)
		cout<<d;
		else
		cout<<0;
	}
	else{
		ll c=llabs(x)/d;
		//cout<<c<<endl;
		if(k<=c){
			if(x<0)
			cout<<llabs(x+d*k*1LL);
			else
			cout<<llabs(x-d*k*1LL);
		}
		else{
			if(x<0){
				m1=x+d*c*1LL;
				m2=x+(c+1)*d*1LL;
				if((k-c)&1LL)
				cout<<llabs(m2);
				else
				cout<<llabs(m1);
			}
			if(x>0){
				m1=x-d*c*1LL;
				m2=x-(c+1)*d*1LL;
				//cout<<((k-c)&1LL)<<endl;
				if((k-c)&1LL)
				cout<<llabs(m2);
				else
				cout<<llabs(m1);
			}
			
		}
	}
	
}


Measured memory_bytes: 3644
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

int main()
{
        int a, b;
        cin >> a >> b;

        int m = a * b;
        if (m % 2 == 1)
                cout << "Odd" << endl;
        else
                cout << "Even" << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a < b && b < c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}



Measured memory_bytes: 26000
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  int ans = 0, count = 0;
  for(int i = 0; i < N - 1; i++){
    if(data.at(i) >= data.at(i + 1))count++;
    else {
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<numeric>
#include<functional>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define  DESC std::greater<int>() //sort 3rd arg




int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<ll> b(n + 1, 0);
	int mod = 1000000007;
	
	REP(i,n) {
		cin >> a[i];
		b[i + 1] = b[i] + a[i];
	}

	ll ans = 0;

	REP(i,n) {
		ll sum = (b[n] - b[i + 1]) % mod;
//		ll sum = b[i + 1];

		ans += a[i] * sum;
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 5632
if __name__ == "__main__":
    N, W = map(int, input().split())
    bag = []
    for _ in range(N):
        v, w = list(map(int, input().split()))
        bag.append((v, w))

    dp = [-1 for _ in range(W+1)]
    dp[0] = 0

    for i in range(N):
        iv, iw = bag[i]
        for w in range(iw, W+1):
            if dp[w-iw] == -1:
                continue
            else:
                dp[w] = max(dp[w-iw] + iv, dp[w])

    result = max(dp)

    print(result)



Measured memory_bytes: 5984
while 1:
	n = input()
	if n == 0: break
	l = [map(int, raw_input().split())+[0] for i in range(n)]+[[0]*(n+1)]
	for r in range(n+1):
		for c in range(n):
			l[n][c] += l[r][c] if r != n else 0
			l[r][n] += l[r][c]
		print "".join(map(lambda x: str(x).rjust(5), l[r]))

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

#define INF 10100

int *p;
int *rank;

void unite(int, int);
void makeSet(int);
void link(int, int);
int findSet(int);
int Same(int, int);

int main(){
    int n,q;
    int com, x, y;
    int *ans;
    int i;

    scanf("%d %d", &n, &q);

    // create S
    p = (int *)malloc(n*sizeof(int));
    rank = (int *)malloc(n*sizeof(int));

    // create array answer
    ans = (int *)malloc(q*sizeof(int));
    for(i=0;i<q;i++){
        ans[i] = INF;
    }

    // make Set
    for(i=0;i<n;i++){
        makeSet(i);
    }

    for(i=0;i<q;i++){
        scanf("%d %d %d", &com, &x, &y);
        if(com == 0){
            unite(x, y);
        }
        else if(com == 1){
            ans[i] = Same(x, y);
        }
    }

    // output
    for(i=0;i<q;i++){
        if(ans[i]!=INF) printf("%d\n", ans[i]);
    }

    return 0;
}

void makeSet(int x){
    p[x] = x;
    rank[x]=0;
}

void unite(int x, int y){
    link(findSet(x),findSet(y));
}

void link(int x, int y){
    if(rank[x] > rank[y]) p[y] = x;
    else{
        p[x]=y;
        if(rank[x]==rank[y]) rank[y]=rank[x];
    }
}

int findSet(int x){
    if(x!=p[x]) p[x]=findSet(p[x]);
    return p[x];
}

int Same(int x, int y){
    if(findSet(x)==findSet(y)) return 1;
    else return 0;
}


Measured memory_bytes: 2204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define dump(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b;
  while(1) {
    if(!(cin >> a)) { break; }
    cin >> b;
    ll ans = 0;
    ll x = gcd(a, b);
    ll y = a / x * b;
    cout << x << ' ' << y << endl;
  }
  return 0;
}


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

using namespace std;

int main(void){
  int A, B;

      cin >> A >> B;
	if (A > 0 && A < 10 && B > 0 && B < 10) {
      cout << A * B;
    }
    else {
      cout << -1;
    }
}
    
  

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 100100100
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

 
int main(){
    int x; cin >> x;
    
    int cnt = 0;
    int t = 1;
    while (cnt < x) {
        cnt += t;
        t++;
    }
    
    cout << --t << endl;
    
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

bool check(string s,char f){
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != f) return false;
    }
    return true;
}

int main(){
    string s;
    cin >> s;
    int ans = mod;
    set<char> st;
    for(int i = 0; i < (int)s.size(); i++) st.insert(s[i]);

    for(auto f:st){
        int can = 0;
        string now = s,nxt;
        int d = 0;

        if(check(now,f)){
            cout << 0 << endl;
            return 0;
        }

        while(true){
            can++;
            for(int i = 0; i < (int)now.size()-d-1; i++){
                if(now[i+1] == f) d = 1;
                else if(now[i] == f) d = 0;
                nxt.push_back(now[i+d]);
            }
            now = nxt;
            string emp;
            swap(emp,nxt);
            //cout << now << endl;
            if(check(now,f)){
                ans = min(ans,can);
                break;
            }
        }

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

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
 
int main()
{
    ll x;
    cin >> x;
    cout << bitset<32>(x) << endl;
    cout << bitset<32>(~x) << endl;
    cout << bitset<32>(x << 1) << endl;
    cout << bitset<32>(x >> 1) << endl;
    return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt();
        
        if((0 > x-r) || (W < x+r)){
            System.out.println("No");
        }else if((0 > y-r) || (H < y+r)){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
        
        
    }
}



Measured memory_bytes: 26412
#include <stdio.h>
#include <string.h>

int main(){

  int i=0;//いれた文字列の数

  int c[100];//シャッフルの回数

  char ch[100][250];//いれた文字列そのもの

  int sh[100][150];//シャッフルの各々の値

  int a;//ループ用

  while(1){

    scanf("%s",ch[i]);//文字列入力

    if(ch[i][0]=='-')

      break;

    scanf("%*c%d",&c[i]);//シャッフル回数入力

    /*
    printf("%d\n",c[i]);
    */

    for(a=0;a<=c[i]-1;a++){

      scanf("%*c%d",&sh[i][a]);//シャッフルの値入力

      /*
      printf("%d\n",sh[i][a]);
      */

    }

    i++;

    /*
    printf("%d",i);
    */

    scanf("%*c");

  }

  /*デバッグ用
  //ここですでにバグる

  int aa,bb,cc,dd,ee;

  for(aa=0;aa<=i-1;aa++){

    printf("%s\n",ch[aa]);

    for(bb=0;bb<=c[aa];bb++){

      printf("%d\n",sh[aa][bb]);

    }

  }

  */

  int ai,iu;//ループ用

  char string[i][30000];//文字列いっぱい並べた文字列

  int shuffle[1000]={};//シャッフル値の合計

  for(ai=0;ai<=i-1;ai++){

    for(iu=1;iu<=c[ai]+1;iu++){

      sprintf(string[ai],"%s%s",string[ai],ch[ai]);//文字列いっぱい並べる

      shuffle[ai]+=sh[ai][iu-1];

    }

  }

  /*
  printf("%s",string[0]);
  */

  int s,t;

  /*
  printf("%d,%d",shuffle[0],strlen(ch[0]));
  */

  /*
  printf("%c %c",string[0][2],string[0][3]);
  */

  for(s=0;s<=i-1;s++){

    for(t=shuffle[s];t<=(shuffle[s]+strlen(ch[s]))-1;t++){

      printf("%c",string[s][t]);

    }

    printf("\n");

  }

  return 0;

}

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

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());

    //cout << s << " " << t << endl;
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#define ULL unsigned long long
using namespace std;

int main() {
    int k, s, cnt = 0;
    cin >> k >> s;
    for (int x=0; x<=k; x++)
        for (int y=0; y<=k; y++) {
            if (0 <= s-x-y && s-x-y <= k)
                cnt++;
        }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  long long  N;
  long long result = 0;
  long long m, a, r, c, h;
  m = a = r = c = h = 0;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    if (s[i][0] == 'M') {
      m++;
    }
    else if (s[i][0] == 'A') {
      a++;
    }
    else if (s[i][0] == 'R') {
      r++;
    }
    else if (s[i][0] == 'C') {
      c++;
    }
    else if (s[i][0] == 'H') {
      h++;
    }
  }
  result += m*a*r;
  result += m*a*c;
  result += m*a*h;
  result += m*r*c;
  result += m*r*h;
  result += m*c*h;
  result += a*r*c;
  result += a*r*h;
  result += a*c*h;
  result += r*c*h;

  cout << result << endl;

  return 0;
}

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

using namespace std;

const int maxn=1e5+5;

typedef long long ll;

int a[maxn];

int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<k;i++){
		int x;
		scanf("%d",&x);
		a[x]++;
	}
	
	for(int i=1;i<=n;i++){
		if(a[i]-k+m>0){
			printf("Yes\n");
		}
		else printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    for(int i=0; i<N; i++) {
        cin >> x[i];
        x[i] -= A;
    }

    int tmp = 1000;
    vector< vector<int64_t> > v(N+1, vector<int64_t>(2000));
    v[0][tmp] = 1;
    for(int i=0; i<N; i++) {
        for(int j=0; j<2000; j++) {
            v[i+1][j] += v[i][j];
            int next = j + x[i];
            if(next < 0 || next >= 2000) continue;
            v[i+1][next] += v[i][j];
        }
    }

    cout << v[N][tmp] - 1 << endl;
    return 0;
}


Measured memory_bytes: 4028
str = list(input())
for i in range(int(input())):
    cmd, a, b, *c = input().split()
    a = int(a); b = int(b)
    if cmd == "print":
        print(*str[a:b+1], sep='')
    elif cmd == "reverse":
        str[a:b+1] = reversed(str[a:b+1])
    else:
        str[a:b+1] = c[0]


Measured memory_bytes: 5740
#include <stdio.h>

int gcd(int x, int y) {
    int r;
    while ((r = x % y) != 0) {
        x = y;
        y = r;
    }
    return y;
}

int main() {
	int a, b, k;
	scanf("%d%d%d", &a, &b, &k);
    int GCD = gcd(a, b);
    for (int i = 1; i <= GCD; i++) {
        if (GCD % i == 0) {
            k--;
            if (k == 0) {
                printf("%d\n", GCD / i);
                return 0;
            }
        }
    }
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    char a[11],b[11],c[11];
    int x , y, z;
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);
    x=strlen(a)-1;
    y=strlen(b)-1;
    z=strlen(c)-1;
        if((a[x]==b[0])&&(b[y]==c[0]))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    return 0;
}

Measured memory_bytes: 2068
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		var p int
		fmt.Scanf("%d", &p)
		list[i] = p
	}

	min := math.MaxInt32
	count := 0
	for i := 0; i < n; i++ {
		if list[i] <= min {
			count++
			min = list[i]
		}
	}

	fmt.Printf("%d\n", count)
}


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

int main()
{
  int N,x,y,z,X=-1,Y_=-1,Z=-1;
  long long Y;
  cin >> N >> Y;

  for(x=0;x<=N;x++)
	{
		for(y=0;y<=N-x;y++)
		{
        if(x*10000+y*5000+(N-x-y)*1000 == Y)
			  {
				    X = x;
            Y_ = y;
            Z = (N-x-y);
            break;
	      }
		}
	}
  cout << X << ' '<< Y_ << ' ' << Z << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $sheets, $price);
for ($i=0; $i <= $sheets; $i++) { 
    for ($j=0; $j <= $sheets - $i; $j++) { 
        $k = $sheets - $i - $j;
        if ((10000 * $i) + (5000 * $j) + (1000 * $k) == $price)
        {
            echo "$i $j $k\n";
            exit;
        }
    }
}
echo "-1 -1 -1\n";

Measured memory_bytes: 4728
#!/usr/bin/env python3
import bisect

a, b, q = list(map(int, input().split()))

s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

x = [int(input()) for _ in range(q)]

s.sort()
t.sort()

i = 0


for i in range(len(x)):

    r_shrine = bisect.bisect_right(s, x[i])
    r_temple = bisect.bisect_right(t, x[i])

    l_shrine = r_shrine-1
    l_temple = r_temple-1

    # print(l_shrine, r_shrine)
    # print(l_temple, r_temple)

    ans = []
    if l_shrine >= 0 and l_temple >= 0:
        ans.append(max(x[i]-s[l_shrine], x[i]-t[l_temple]))  # <<
    if r_shrine < a and r_temple < b:
        ans.append(max(s[r_shrine]-x[i], t[r_temple]-x[i]))  # >>
    if l_shrine >= 0 and r_temple < b:
        min_ = min(x[i]-s[l_shrine], t[r_temple]-x[i])
        ans.append(min_+(t[r_temple]-s[l_shrine]))  # <>
    if r_shrine < a and l_temple >= 0:
        min_ = min(x[i]-t[l_temple], s[r_shrine]-x[i])
        ans.append(min_+(s[r_shrine]-t[l_temple]))  # <>

    print(min(ans))


Measured memory_bytes: 131928
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

int main()
{
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;

  int64_t ans;
  
  if (K <= A)
    ans = K;
  else if (K<=A+B)
    ans = A;
  else
    ans = A-(K-(A+B));
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
import java.util.*;

public class Main {

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

		while(sc.hasNext()){
			int n = sc.nextInt();
			long sum = 1;
			for(int i=2;i<=n;i++){
				sum *= i;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17160