akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
//        sc.useDelimiter("\n");
//        DecimalFormat df = new DecimalFormat("0.00000000");
        
        long n = Long.parseLong(sc.next());
        long k = Long.parseLong(sc.next());
        long ans = n % k;
        long temp;
        while (true) {
            n = Math.abs(ans - k);
            if (ans < n) {
                break;
            } else {
                temp = ans;     ans = n;    n = temp;
            }
        }
        pw.println(ans);
        pw.flush();
    }
}

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


int main() {
   
   	long long int n;
   	cin>>n;
   	if(n>=30)
   	{
   		cout<<"Yes";	   }
   		else
   		{
   			cout<<"No";
		   }
   }

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int gcd(int a, int b){
    if(b>a) swap(a,b);
    int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int main(){
    int n;
  cin>>n;
    int a;
    cin>>a;
    int g=a;
    for(int i=1; i<n; i++){
        int tmp;
        cin>>tmp;
        g= gcd(g,tmp);
    }
    cout<<g<<endl;    
}

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

int josephus(int n, int k){
	if(n==1) return 0;
	return (josephus(n-1,k)+k)%n;
}

int main(){
	while(1){
		int n,k,m;
		cin >> n >> k >> m;
		if(n==0) break;
		cout << (josephus(n-1,k)+m)%n + 1 << endl;
	}
	return 0;
}

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

using namespace std;

#define int long long

const int SIZE = 21;

void unplus(vector<int> &a, vector<int> b){
    for (int i = 0; i < SIZE;++ i) {
        a[i] -= b[i];
    }
}
void pl(vector<int> &a, vector<int> b){
    for (int i = 0; i < SIZE;++ i) {
        a[i] += b[i];
    }
}
bool f (vector<int> a) {
    for (int i = 0; i < SIZE; ++ i) {
        if (a[i]== 2) return true;
    }
    return false;
}


void solve() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int> (SIZE));
    for (int i = 0; i < n; ++ i) {
        int x;
        cin >> x;
        for (int j = 0; j < SIZE; ++ j) {
            a[i][j] = x % 2;
            x /= 2;
        }

    }
    vector<int> tmp = a[0];
    int l = 0, r= 0, ans = 0;
    while (r < n) {
        if (f(tmp)) {
            unplus(tmp, a[l]);
            l++;
            continue;
        }
        ans += (r - l + 1);
        r++;
        if (r < n) pl(tmp, a[r]);
    }
    cout << ans;
}

signed main() {
    //freopen
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}

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

using namespace std;

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

    int pos = K - 1;
    S[pos] = tolower(S[pos]);
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int build[4][3][10] = {0};
    int i, j, k, n = 0, b, f, r, v;
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);
        build[b-1][f-1][r-1] += v;
    }
    for(i = 0; i < 4; i++)
    {
        for(j = 0; j < 3; j++)
        {
            for(k = 0; k < 10; k++)
            {
                printf(" %d", build[i][j][k]);
            }
            printf("\n");
        }
        if (i != 3)
        {
            printf("####################\n");
        }
       
    }
    return 0;
}


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

ll gcd ( ll a , ll b)
{
    if( b== 0)
        return a;
    return gcd( b , a%b );
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans = gcd( a[0] , a[1]);
    for(int i =2;i<n;i++)
    {
        ans = gcd ( ans , a[i] );
    }
    cout<<ans;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9 + 7;
int N,M;
bool e[16][16];
LL p1[1<<13] , p2[1<<13];
LL c1[1<<13] , c2[1<<13] , c[1<<13];
bool b1[1<<13] , b2[1<<13];
bool connect[1<<13];

int log2(int x){
	int z = 0;
	for(; x>1 ; x >>= 1) ++z;
	return z;
}

int main(){
	cin >> N >> M;
	repp(i,0,M){
		int a,b;
		cin >> a >> b;
		a = N - a;
		b = N - b;
		e[a][b] = e[b][a] = 1;
	}
	LL ans = 1;
	repp(i,0,M) ans = ans * 2 % mod;
	if(e[N-1][N-2]) return cout << ans << endl , 0;
	
	connect[0] = 1;
	repp(i,1,1<<(N-2)){
		int x = 0;
		while(x<N-2 && (!(i&(1<<x)) || !connect[i-(1<<x)])) ++x;
		if(x==N-2) continue;
		repp(j,0,N-2) if((i&(1<<j)) && e[x][j]) connect[i] = 1;
	}
	
	c[0] = 1;
	repp(i,1,1<<(N-2)){
		int x = i&-i;
		c[i] = c[i^x];
		x = log2(x);
		repp(j,0,N-2) if((i&(1<<j)) && e[x][j]) (c[i] *= 2) %= mod;
	}
	
	p1[0] = c1[0] = 1;
	b1[0] = 1;
	repp(i,1,1<<(N-2)){
		int x = i&-i;
		c1[i] = c1[i^x];
		int y = log2(x);
		repp(j,0,N-2) if((i&(1<<j)) && e[y][j]){
			(c1[i] *= 2) %= mod;
		}
		if(e[y][N-1]){
			(c1[i] *= 2) %= mod;
		}
		int z = 0;
		while(z<N-2 && (!(i&(1<<z)) || !b1[i-(1<<z)])) ++z;
		if(z<N-2){
			repp(j,0,N-2) if((i&(1<<j)) && e[z][j]) b1[i] = 1;
			if(e[z][N-1]) b1[i] = 1;
		}
		if(!b1[i]) continue;
		p1[i] = c1[i];
		for(int k = (i-1) & i ; k >= 0 ; --k){
			k &= i;
			(p1[i] -= p1[k] * c[i^k]) %= mod;
		}
	}
	
	p2[0] = c2[0] = 1;
	b2[0] = 1;
	repp(i,1,1<<(N-2)){
		int x = i&-i;
		c2[i] = c2[i^x];
		int y = log2(x);
		repp(j,0,N-2) if((i&(1<<j)) && e[y][j]){
			(c2[i] *= 2) %= mod;
		}
		if(e[y][N-2]){
			(c2[i] *= 2) %= mod;
		}
		int z = 0;
		while(z<N-2 && (!(i&(1<<z)) || !b2[i-(1<<z)])) ++z;
		if(z<N-2){
			repp(j,0,N-2) if((i&(1<<j)) && e[z][j]) b2[i] = 1;
			if(e[z][N-2]) b2[i] = 1;
		}
		if(!b2[i]) continue;
		p2[i] = c2[i];
		for(int k = (i-1) & i ; k >= 0 ; --k){
			k &= i;
			(p2[i] -= p2[k] * c[i^k]) %= mod;
		}
	}
	
	repp(i,0,1<<(N-2)){
		if(!b1[i]) continue;
		for(int j = ((1<<(N-2))-1)^i ; j >= 0 ; --j){
			j &= ((1<<(N-2))-1)^i;
			if(!b2[j]) continue;
			bool b = 1;
			repp(k,0,N-2){
				if((j&(1<<k)) && e[k][N-1]) b = 0;
				if((i&(1<<k)) && e[k][N-2]) b = 0;
				repp(l,k+1,N-2){
					if((i&(1<<k)) && (j&(1<<l)) && e[k][l]) b = 0;
					if((i&(1<<l)) && (j&(1<<k)) && e[k][l]) b = 0;
				}
			}
			if(b) (ans -= p1[i] * p2[j] % mod * c[((1<<(N-2))-1)^i^j]) %= mod;
	//		if(b) cout << i << ' ' << j << ' ' << p1[i] << ' ' << p2[j] << ' ' << c[((1<<(N-2))-1)^i^j] << ' ' << ans << endl;
		}
	}
	if(ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c)
	{
		cout<<"Yes"<<endl;
		return 0; 
	}
	else if(a==c&&a!=b)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	else if(b==c&&a!=c)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

const int mod = 1000000007;

long long pw(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1ll) {
			res = res * a % mod;
		}
		b >>= 1;
		a = a * a % mod;
	}
	return res;
}

int main(){
	int n = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	vector<int> nd(n + 1, n), ni(n + 1, n);
	for (int i = n - 2; i >= 0; --i) {
		if (a[i] <= a[i + 1]) {
			nd[i] = nd[i + 1];
		} else {
			nd[i] = i + 1;
		}
		if (a[i] >= a[i + 1]) {
			ni[i] = ni[i + 1];
		} else {
			ni[i] = i + 1;
		}
	}

	int ans = 0;
	int i = 0;
	while (i < n) {
		i = max(ni[i], nd[i]);
		++ans;
	}

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

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    int n = s.length();
    
    if((n % 2 == 0) ^ (s[0] == s[n-1])){
        cout << "Second\n";
    }
    else{
        cout << "First\n";
    }
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#define max 100005

using namespace std;

int s[max];
int main(){
    int x,y,z;
    while( ~scanf("%d%d%d",&x,&y,&z) ){
        int sum=0,ans=0;
        while( sum < x ){
            sum+=(z + y);
            ans++;
        }
        sum-=y;
        ans--;
        if(x >= sum )    printf("%d\n",ans);
        else printf("%d\n",ans-1);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

bool inte(double n) {//整数かどうかの判定
	if (ceil(n) == floor(n)) {//切り上げ関数,切り下げ関数
		return true;
	}
	else return false;
}

// (char)toupper(a[n])=文字列のn文字目を大文字で出力

// pow(a,b)=aのb乗

//グローバル関数
int a = 0, n = 0, x = 0, y = 0, ans = 0, cnt = 0, sum = 0;
string s="";

int main(void) {

	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ans = 0;
	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << rt;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << rt;
			return 0;
		}
	}

	please AC;
}

//参考：---;

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

int main(){
    int N;
    cin >> N;
    ll ans=1;
    for(int i=0; i<N; i++){
        int num;
        cin >> num;
        if(num%2==0){
            ans*=2;
        }else{
            ans*=1;
        }
    }
    cout << pow(3, N)-ans;
}

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

int main(){
  int n, m; cin >> n >> m;
  
  vector<vector<int>> graph(n+1);
  
  for(int i = 0; i < m; i++){
  	int a, b; cin >> a >> b;
  
  	graph[a].push_back(b);
  	graph[b].push_back(a);
  }
  
  queue<int> que;
  que.push(1);
  
  vector<int> seen(n+1, -1);
  seen[1] = 1;
  
  vector<int> parent(n+1);
  
  while(!que.empty()){
  	int nv = que.front();
    que.pop();
  
  	for(int v : graph[nv]){
    	if(seen[v] != -1) continue;
      	que.push(v);
      
      	seen[v] = 1;
      
      	parent[v] = nv;
  	}
  
  }
  
  cout << "Yes" << endl;
  for(int i = 2; i <= n; i++) cout << parent[i] << endl;
  
  for(int i = 0; i < n; i++){
  for(int j = 0; j < m; j++){
  
  	int a=1;
  }}
}


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

using namespace::std;



int main()
{
	string N;
	cin >> N;

	string ATGC = "ATGC";
	
	int length = (int)(N.length());


	int max = 0;
	int m = 0;


	for (int i = 0; i < length; i++) {
		for (int j = 0; j < 4; j++) {
			if (N[i] == ATGC[j]) {
				m++;
				break;
			}
			if (j == 3) {
				if (m > max) {
					max = m;
				}
				m = 0;
			}
		}

		if (m > max) {
			max = m;
		}
	}

	cout << max << endl;

	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
struct S{int a,b,o;}a[50000],t;
int main()
{
	int q,r,c,i;
	while(scanf("%d%d%d",&r,&c,&q),r)
	{
		for(i=0;i<q;++i)scanf("%d%d%d",&a[i].a,&a[i].b,&a[i].o);
		int x[]={r,c},z=0,f[2][50000]={};
		for(i=q-1;i>=0;--i)
		{
			t=a[i];
			if(f[t.a][t.b]++)continue;
			--x[t.a];
			if(t.o)z+=x[!t.a];
		}
		printf("%d\n",z);
	}
	return 0;
}

Measured memory_bytes: 1744
#include<stdio.h>

int minmin(int a,int b,int c,int d);

int main(void)
{
        int n,m,i,j,min,tmp,jj;
        int a[50],b[50],c[50],d[50];

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

        for(i=0;i<n;i++)
                scanf("%d%d",&a[i],&b[i]);
        for(i=0;i<m;i++)
                scanf("%d%d",&c[i],&d[i]);


        for(i=0;i<n;i++){
                tmp = minmin(a[i],b[i],c[0],d[0]);
                jj = 1;
                for(j=1;j<m;j++){
                        min = minmin(a[i],b[i],c[j],d[j]);
                        if(tmp>min){
                                tmp = min;
                                jj = j+1;
                        }
                }
                printf("%d\n",jj);
        }

        return 0;
}
int minmin(int a,int b,int c,int d)
{
        int min;
        if(c>a)
                min = c - a;
        else
                min =a-c;
        if(d>b)
                min +=d-b;
        else
                min +=b-d;

        return min;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, n;
    cin >> h >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<vi> dp(2, vi(h+1, INF));
    dp[0][0] = dp[1][0] = 0;
    rep(i, n) {
        rep(j, h+1) {
            int nj = min(j+a[i], h);
            dp[(i+1)%2][nj] = min(dp[(i+1)%2][nj], dp[i%2][nj]);
            dp[(i+1)%2][nj] = min(dp[(i+1)%2][nj], dp[(i+1)%2][j]+b[i]);
        }
    }
    cout << dp[n%2][h] << endl;
    return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,cnt=0;
vector<ll>g[200005];
map<ll,ll>viz;
vector<ll>v;
void dfs(ll node){
cnt++;
viz[node]=1;
for(auto it : g[node]){
    if(viz[it]==0){
        dfs(it);
    }
}
}
int32_t main(){
CODE_START;
cin>>n>>m;
for(ll i=1;i<=m;i++)
{
    ll x,y;
    cin>>x>>y;
    g[x].pb(y);
    g[y].pb(x);
}
for(ll i=1;i<=n;i++)
{
    if(viz[i]==0){
            cnt=0;
        dfs(i);
    v.pb(cnt);
    }
}
sort(v.begin(),v.end());
cout<<v[v.size()-1]<<endl;
}



Measured memory_bytes: 45752
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);


int main() {
    int x, y ,z, k;
    cin >> x >> y >> z >> k;
    vector<long> a(x), b(y), c(z);
    for(int i=0; i<x; i++) cin >> a[i];
    for(int i=0; i<y; i++) cin >> b[i];
    for(int i=0; i<z; i++) cin >> c[i];

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    vector<long> max_of_a_and_b(k, 0);
    for(int i=0; i<x; i++) {
        for(int j=0; j<y; j++) {
            max_of_a_and_b.push_back(a[i] + b[j]);
        }
    }
    sort(max_of_a_and_b.rbegin(), max_of_a_and_b.rend());
    max_of_a_and_b = vector<long>(max_of_a_and_b.begin(), max_of_a_and_b.begin() + k);

    vector<long> max_of_all;
    for(int i=0; i<k; i++) {
        for(int j=0; j<z; j++) {
           max_of_all.push_back(max_of_a_and_b[i] + c[j]); 
        }
    }
    sort(max_of_all.rbegin(), max_of_all.rend());

    for(int i=0; i<k; i++) {
        cout << max_of_all[i] << endl;
    }
     
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 51392
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
    vector<int> ans;
    while (true){
        int n; cin>>n;
        if (n==0) break;
        vector<int> s(n);
        rep(i,0,n) cin>>s[i];
        sort(s.begin(),s.end());
        int sum = 0;
        rep(i,1,n-1){
            sum+=s[i];
        }
        ans.push_back(sum/(n-2));
    }
    for (int k:ans){
        cout<<k<<endl;
    }
}


Measured memory_bytes: 3124
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    S = input().strip()

    res = 0
    for i, s in enumerate(S):
        if s == "g":
            res += i % 2
        elif s == "p":
            res -= (i + 1) % 2
    print(res)



if __name__ == "__main__":
    main()


Measured memory_bytes: 75092
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);


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

  ll now = 1;
  for (int i = 0; i < 100000; i++){
    if (now > N){
      cout << i << endl;
      return 0;
    }
    now *= K;
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        if(s.Length != 6) return;
        if(s[2] == s[3] && s[4] == s[5]){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}
 

Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
int main()
{
	char S[6];
	scanf("%s",S);
	if (S[0]==S[1]&&S[1]!=S[2]||S[1]==S[2]&&S[0]!=S[2]||S[0]==S[2]&&S[0]!=S[1])
	{
		printf("Yes");
	}
	else 
	{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 1732
a = int(input())
b = list(map(int,input().split()))
c = list(map(int,input().split()))
x = []

for i in range(a):
  l = abs(b[0] - c[i]*0.006 - b[1])
  x.append(l)
  
print(x.index(min(x)) + 1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[100010],n;
int main()
{
	scanf("%d",&n);
    int mn=n+1,mx=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
    }
    if(mx>mn+1) 
    {
    	printf("No\n");
    	return 0;
	}
    if(mx==mn)
    {
        if(mn==n-1)
        {
        	printf("Yes\n");
        	return 0;
		}
        if(2*mn<=n)
        {
        	printf("Yes\n");
        	return 0;
		}
        else
        {
        	printf("No\n");
        	return 0;
		}
    }
    else
    {
        int cnt=0;
        for(int i=1;i<=n;i++) 
		cnt+=(a[i]==mn);
        if(mn<cnt)
        {
        	printf("No\n");
        	return 0;
		}
        if(n-cnt<2*(mx-cnt))
        {
        	printf("No\n");
        	return 0;
		}
        else
        {
        	printf("Yes\n");
        	return 0;
		}
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll p = 0;
    for (auto t : s)
    {
        p += t - '0';
    }
    if (p % 9 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3756
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        sc.close();
        int len = s.length();
        if (len == 1) {
            System.out.println(k / 2);
            return;
        }
        char tmp = s.charAt(0);
        int cnt = 1;
        long ans = 0;
        List<Integer> list = new ArrayList<>();
        char c = s.charAt(1);
        for (int i = 1; i < len; i++) {
            while (true) {
                c = s.charAt(i);
                // System.out.println(c);
                if (c != tmp) {
                    break;
                }
                cnt++;
                i++;
                if (i == len) {
                    break;
                }
            }
            list.add(cnt);
            cnt = 1;
            tmp = c;
            // 異なる状態になる
        }
        if (s.charAt(len - 1) != s.charAt(len - 2)) {
            list.add(1);
        }
        if (list.size() == 1) {
            int num = list.get(0);
            if (num % 2 == 0) {
                ans += (num / 2) * k;
            } else {
                int num2 = num + 1;
                for (int i = 0; i < k; i++) {
                    if (i % 2 == 0) {
                        ans += num / 2;

                    } else {
                        ans += num2 / 2;
                    }
                }
            }
        } else if (s.charAt(0) != s.charAt(len - 1)) {
            for (int i : list) {
                // System.out.println(i);
                ans += (i / 2) * k;
            }
        } else {
            int size = list.size();
            for (int i = 1; i < size - 1; i++) {
                ans += (list.get(i) / 2) * k;
            }
            int f = list.get(0);
            int l = list.get(size - 1);
            int wa = f + l;
            ans += (wa / 2) * (k - 1);
            ans += f / 2;
            ans += l / 2;
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

const ll MOD = (ll)(1e9 + 7ll);
ll modpow(ll n)
{
    if (n == 0)
    {
        return 1ll;
    }
    ll prev = modpow(n / 2);
    if (n % 2 == 0)
    {
        return (prev * prev) % MOD;
    }
    else
    {
        return (((prev * prev) % MOD) * 2ll) % MOD;
    }
}
int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> one(60, 0);
    vector<ll> zero(60, 0);
    rep(i, n)
    {
        ll a;
        cin >> a;
        rep(j, 60)
        {
            if (((a >> j) & 1) == 1)
            {
                one[j]++;
            }
            else
            {
                zero[j]++;
            }
        }
    }
    ll ans = 0;
    rep(i, 60)
    {
        ans += (((one[i] * zero[i]) % MOD) * modpow(i)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        string s = to_string(i);
        int x = 0;
        for (auto k: s) {
            x += k-'0';
        }
        if (x >= a && x <= b) ans+= i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main()
{
    int box[20][20]={};
    int n,m;
    int current;
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >> box[i][0];
        for(int j=1;j<=box[i][0];j++){
            cin >> current;
            box[i][current]++;
        }
    }
    for(int i=1;i<=m;i++){
        cin >> box[i][11];
    }

    int lastjudge = 0;
    int ans = 0;
    int maxnum =1;
    for(int i=1;i<=n;i++){
        maxnum *= 2;
    }
    maxnum--;
    for(int i=0;i<=maxnum;i++){
        for(int j=1;j<=m;j++){
            int judge = 0;
            int two = 1;
            for(int k=1;k<=10;k++){
                judge += box[j][k]*((i/two)%2);
                two *= 2;
            }
            judge %= 2;
            if(judge != box[j][11]){
                lastjudge ++;
                break;
            }
        }
        if(lastjudge == 0){
            ans ++;
        }
        lastjudge =0;
    }

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

Measured memory_bytes: 256
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

void main() {
    char s[100];
    R(s);
    int n=strlen(s);
    bool vis[26]={};
    REP(i,n) {
        vis[s[i]-'a']=1;
    }
    if ( n==26 ) {
        string t=s;
        next_permutation(ALL(t));
        while ( t.substr(0,SZ(t)-1)>s ) t=t.substr(0,SZ(t)-1);
        if ( t>s ) W(t);
        else W(-1);
    } else {
        REP(i,26) if ( !vis[i] ) {
            s[n++]='a'+i;
            s[n]=0;
            break;
        }
        W(s);
    }
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;
    vector<ll> X(N), L(N);
    vector<PL> pr(N);
    rep(i, 0, N){
        cin >> X[i] >> L[i];
        pr[i].first = X[i] + L[i];
        pr[i].second = X[i] - L[i];
    }
    sort(ALL(pr));

    cerr << "piyo" << endl;
    ll ans = 0, i = 0, now = 0;
    while(i < N){
        i = now + 1;
        while(i < N){
            if(pr[i].second < pr[now].first){
                ans++;
                i++;
            }else{
                now = i;
                break;
            }
        }
    }

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

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

class Solver {
};

int main() {
	while (true) {
		int m, n;
		cin >> m >> n;
		if (m == 0)break;
		int max = 8000000;
		int now = 0;
		vector<bool> prime(max + 1, true);
		for (int i = m; i <= max; i++) {
			if (!prime[i])continue;

			now++;
			if (now > n) {
				cout << i << endl;
				break;
			}
			for (int j = 2; i * j <= max; j++) {
				prime[i * j] = false;
			}
		}
	}
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int l[n];
    for(int i=0; i<n; i++) cin>>l[i];
    int cnt= 0;
    for(int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            for(int k=j+1; k<n; k++){
                if(l[k]<l[i]+l[j] && l[i]<l[k]+l[j] && l[j]<l[i]+l[k]){
                    if(l[i]==l[k] || l[k]==l[j] || l[j]==l[i]) continue;
                    cnt++;
                }

            }
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3636
use proconio::input;
use proconio::marker::Chars;
//use std::collections::HashSet;
//use std::cmp::*;

fn main() {
    input! {
        chars: Chars
    }
    let m = 2019;
    let mut nums: Vec<i64> = Vec::with_capacity(chars.len());
    let l = chars.len();
    for c in chars {
        nums.push(c as i64 - 48);
    }
    nums.reverse();

    // 左からnum[i]までを取った時のあまり。
    let mut amari: Vec<i64> = vec![0; l];
    let mut num_of_amari: Vec<i64> = vec![0; 2019];
    amari[0] = nums[0];
    num_of_amari[amari[0] as usize] += 1;
    let mut tenth: Vec<i64> = vec![0; l];
    tenth[0] = 1;
    for i in 1..l {
        tenth[i] = tenth[i - 1] * 10 % 2019;

        amari[i] = (amari[i - 1] + nums[i] * tenth[i]) % m;
        num_of_amari[amari[i] as usize] += 1;
        //println!("amari[{}]={}", i, amari[i]);
    }

    let mut ans = 0;
    for n in &num_of_amari {
        ans += n * (n - 1) / 2;
    }
    ans += num_of_amari[0];
    println!("{}", ans);
}


Measured memory_bytes: 6764
import Foundation
// 第一引数に二分探索したい配列を渡す
// 第二引数に検索したい要素を渡す
// 第三引数に二分探索したい配列の大きさを渡す
func binarySearch(list:[Int],item:Int,cnt:Int)->Int{
    // 解の存在範囲を初期化
    var low = -1
    var high = cnt 
    // 解の存在範囲が1より大きい間、繰り返す
    while (high - low > 1) {
        let mid = Int(floor(Double(low + high) / 2))
        if list[mid] >= item {
            // midが条件を満たせば、解の存在範囲は(low,mid]
            high = mid
        } else {
            // midが条件を満たさなければ、解の存在範囲は(mid,high]
            low = mid
        }
    }
    // この時点で、low + 1 = highとなっている
    return high
}

// 標準入力の受け取り
let n = Int(readLine()!)!
var a = readLine()!.split(separator:" ").map{Int($0)!}
var b = readLine()!.split(separator:" ").map{Int($0)!}
var c = readLine()!.split(separator:" ").map{Int($0)!}

// とりあえず各配列をソートする
a.sort { $0 < $1 }
b.sort { $0 < $1 }
c.sort { $0 < $1 }

// 答えを入れる変数を用意
var ans = 0;

// 中部のパーツの配列に対して全探索
for i in b{
    // 各配列に対して二分探索
    let ai = binarySearch(list:a,item:i,cnt:n)
    let ci = binarySearch(list:c,item:i+1,cnt:n)
    
    // ansに考えられるパーツの組み合わせの個数を加える
    ans += (ai)*(n-ci)
}

// 答えを出力
print(ans)

Measured memory_bytes: 23104
X, K, D = map(int, input().split())

n = abs(X) // D
if n <= K:
    if X >= 0:
        res = X - D * n
        if (K - n) % 2 == 1:
            print(abs(res - D))
        else:
            print(res)
    else:
        res = X + D * n
        if (K - n) % 2 == 1:
            print(abs(res + D))
        else:
            print(abs(res))
else:
    if X >= 0:
        res = X - D * K
    else:
        res = X + D * K
    print(abs(res))


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

int main() {
	int N, K; cin >> N >> K;
	int a[200010];
	for(int i=0; i<N; ++i) cin >> a[i];
	int num[200001]={0};
	for(int i=0; i<N; ++i) ++num[a[i]];
	sort(num, num + 200001, greater<int>());
	int S=N;
	for(int i=0; i<K; ++i) S -= num[i];
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
using namespace std;
 
using ll = long long;
using weight = ll;
using P = pair<ll, ll>;
 
int main() {
    int N;
    cin >> N;
    int cnt = 0;
    for(int i=0; i<N; ++i) {
        int A;
        cin >> A;
        cnt += A % 2;
    }
    if(cnt % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,double>> graph;

lli n;
graph g;
mad p;

double dist(vdl& a,vdl& b){
  return max(0.0,sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1]))-a[2]-b[2]);
}

priority_queue<vdl,vector<vdl>,greater<vdl>> q;
set<lli> used;

int main(){
  vdl s = vdl(3);
  vdl t = vdl(3);
  cin >> s[0] >> s[1]
  >> t[0] >> t[1];
  p.push_back(s);
  p.push_back(t);
  cin >> n;
  for(lli i = 0;i < n;i++){
    vdl q = vdl(3);
    cin >> q[0] >> q[1] >> q[2];
    p.push_back(q);
  }
  for(lli i = 0;i < p.size();i++){
    for(lli j = 0;j < p.size();j++){
      g[i][j] = dist(p[i],p[j]);
    }
  }
  q.push(vdl({0.0,0.0}));
  while(!q.empty()){
    double c = q.top()[0];
    lli p = (lli)(q.top()[1]);
    q.pop();
    if(p == 1){
      cout << setprecision(17);
      cout << c << endl;
      return 0;
    }
    if(used.count(p) != 0) continue;
    used.insert(p);
    for(auto& itr : g[p]){
      if(used.count(itr.first) == 0) q.push(vdl({c+itr.second,(double)itr.first}));
    }
  }

}


Measured memory_bytes: 72616
# ABC076
def main():
    s, t = [input().rstrip() for _ in range(2)]
    len_s, len_t = len(s), len(t)
    ans = []  # list of candidates of the answer

    for i in range(len_s - len_t + 1):
        p = s[i : i + len_t]  # partial string (substring)

        if all(j in (i, "?") for i, j in zip(t, p)):
            # a candidate of the answer
            cand = (s[:i] + t + s[i + len_t :]).replace("?", "a")
            ans += [cand]

    if ans != []:
        print(sorted(ans)[0])
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n,m;
 	
 	scanf("%d",&n);
 	int ans= 0;
 	set<int>s;
 	for(int i=0,x;i<n;i++){
 		scanf("%d",&x);
 		s.insert(x);
 		if(*s.begin()==x)ans++;
 	}
 	printf("%d\n",ans );
}		


Measured memory_bytes: 9600
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void){
   int m,max,min,p[1000];
   while(1){
       int n=0,gap=0;
       scanf("%d %d %d",&m,&min,&max);
       if(m==0&&max==0&&min==0){
           break;
       }
       for(int i=0;i<m;i++){
           cin>>p[i];
       }
       for(int i=min;i<=max;i++){
           if(gap<=p[i-1]-p[i]){
               gap=p[i-1]-p[i];
               n=i;
           }
       }
       cout<<n<<endl;
   }
   return 0;
}


Measured memory_bytes: 3168
#include <iostream>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  char x = 'A' - 'a';
  cout << (char)(a[0]+x) << (char)(b[0]+x) << (char)(c[0]+x) << "\n";
  return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main {

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

		int m, n, l;
		long a1;
		long a[][];
		long b[][];
		long c[][];
		
		n = scan.nextInt();
		m = scan.nextInt();
		l = scan.nextInt();
		a = new long[n][m];
		b = new long[m][l];
		c = new long[n][l];
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a1 = scan.nextInt();
				a[i][j] = a1;
			}
		}
		for(int i = 0; i < m;i++){
			for(int j = 0; j < l; j++){
				a1 = scan.nextInt();
				b[i][j] = a1;
			}
		}
		
		for(int i = 0; i < n ;i++){
			for(int j = 0; j < l; j++){
				for(int k = 0; k < m; k++){
					c[i][j] += a[i][k] * b[k][j];
				}
				System.out.print(c[i][j]);
				if(j != l - 1){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
		
			
	}
}	

Measured memory_bytes: 55752
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()

ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        n = bisect.bisect_left(L, L[i] + L[j])
        ans += max(0, n - j - 1)

print(ans)


Measured memory_bytes: 3188
// ref: https://atcoder.jp/contests/abc110/submissions/3251714

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

uint64  divNum(uint64& target, const uint64 divisor){
    uint64 num=0ull;
    for(;;){
        if(target%divisor!=0){ break; }
        target /= divisor;
        ++num;
    }
    return num;
}

tuple<vector<uint64>,vector<uint64>> factor(uint64 target){
    vector<uint64> vecPrime;
    vector<uint64> vecNum;
    
    for(uint64 divisor=2; divisor<=target; ++divisor){
        if(target==1){ break; }
        
        uint64 num = divNum(target, divisor);
        if(num==0ull){ continue; }
        
        vecPrime.push_back(divisor);
        vecNum.push_back(num);
    }
    return tie(vecPrime, vecNum);
}

uint64 pow_mod(uint64 base, uint64 exp, const uint64 mod){
    uint64 ret=1ull;
    for(; exp>0ull; exp>>=1ull){
        if(exp & 1){
            ret = ret*base;
            ret %= mod;
        }
        base = base*base;
        base %= mod;
    }
    return ret;
}
uint64 comb_mod(uint64 n, uint64 r, const uint64 mod){
    if(n==r || n==0ull || r==0ull){ return 1ull; }
    
    uint64 p=1ull, q=1ull;
    r = min(r,n-r);
    for(uint64 i=1ull; i<=r; ++i){
        p *= n; --n;
        p %= mod;
        
        q *= i;
        q %= mod;
    }
    return (p*pow_mod(q,mod-2,mod)) % mod;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    const uint64 mod = 1e9 + 7;
    
    uint64 N, M; cin >> N >> M;
    
    vector<uint64> vecPrime, vecNum;
    tie(vecPrime, vecNum) = factor(M);
    
    uint64 ans=1ull;
    for(uint i=0; i<vecNum.size(); ++i){
        ans *= comb_mod(vecNum[i]+N-1ull, N-1ull, mod);
        ans %= mod;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>

using namespace std;

int main(void) {
	string str;
	getline(cin,str);
	int o1,o2,num;
	stack<int> s;
	bool nmode = false;
	for (int i = 0; i < str.length(); ++i) {
		if (str[i] >= '0' && str[i] <= '9') {
			if (nmode) {
				num = num*10 + (str[i]-'0');
			}
			else {
				nmode = true;
				num = str[i]-'0';
			}
		}
		else if (str[i] == ' ') {
			if (nmode) {
				s.push(num);
				nmode = false;
			}
		}
		else {
			o2 = s.top();
			s.pop();
			o1 = s.top();
			s.pop();
			if (str[i] == '+') {
				s.push(o1+o2);
			}
			else if (str[i] == '-') {
				s.push(o1-o2);
			}
			else {
				s.push(o1*o2);
			}
		}
	}
	cout << s.top() << endl;
	return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define pi acos(0.0)
#define ll long long
#define f first
#define s second
#define gap ' '
#define pb push_back
#define mod 1000000007
int main()
{
    ll n,m;
    cin>>n>>m;
    ll x[n+5],y[m+5];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>y[i];
    }
    sort(x,x+n);
    sort(y,y+m);
    ll xx=0;
    ll yy=0;
    for(int i=0;i<n;i++)
    {
        xx+=(i-(n-1))*x[i]+i*x[i];
        //cout<<xx<<endl;
    }

    for(int i=0;i<m;i++)
    {
        yy+=(i-(m-1))*y[i]+i*y[i];
    }

    ll ans=((xx%mod)*(yy%mod))%mod;
    cout<<ans;

}


Measured memory_bytes: 1792
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def primeFactorization(n):
    ans = []
    temp = n
    while temp%2 == 0:
        ans.append(2)
        temp //= 2
    for i in range(3, int(n**0.5)+1, 2):
        while temp%i == 0:
            ans.append(i)
            temp //= i
    if temp > 1:
        ans.append(temp)
    return collections.Counter(ans)

def resolve():
    N = I()

    # N!の素因数を求める
    pf_N_fact = collections.Counter()
    for i in range(1, N + 1):
        pf = primeFactorization(i)
        for k, v in pf.items():
            pf_N_fact[k] += v
    l = list(pf_N_fact.values())
    l.sort()
    pf_num = len(pf_N_fact)

    # 約数75個: 素因数の個数+1の積が75になるように組み合わせる
    # 素因数の個数を以下の組み合わせで何通り取れるかを調べる
    # (2, 4, 4), (2, 24), (4, 14), (74)
    ans = 0
    num_2 = pf_num - bisect.bisect_left(l, 2)
    num_4 = pf_num - bisect.bisect_left(l, 4)
    num_14 = pf_num - bisect.bisect_left(l, 14)
    num_24 = pf_num - bisect.bisect_left(l, 24)
    num_74 = pf_num - bisect.bisect_left(l, 74)
    ans += num_4 * (num_4 - 1) // 2 * (num_2 - 2)
    ans += num_24 * (num_2 - 1)
    ans += num_14 * (num_4 - 1)
    ans += num_74
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, k;

    cin >> n >> k;

    ll count = 0;
    while(n > 0){
        n /= k;
        count++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def resolve():
	n = int(input())
	if n == 0:
		print("0")
		return
	out = ""
	base = 1
	while n != 0:
		if n % (-2) == 0:
			out = "0" + out
		else:
			r = n % (-2)
			if r < 0:
				r = 1
			n -= r
			out = "1" + out
		n /= (-2)


	print(out)
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp map<int,int>
#define vi vector<int>
#define M INT_MAX
#define MI INT_MIN
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
#define ull long long 
void solve()
{
	ull k;
	cin>>k;
	
	queue<ull> q1;
	ll cnt=0;
	for(int i=1;i<=9;i++)q1.push(i);
	
	while(1)
	{
		cnt++;
		ull x=q1.front();
		q1.pop();
		if(cnt==k)
		{
			cout<<x;
			break;
		}
		ull a=(x*10)+(x%10)-1;
		ull b=(x*10)+(x%10);
		ull c=(x*10)+(x%10)+1;
		if(x%10!=0)
		q1.push(a);
		
		q1.push(b);
		
		if(x%10!=9)
		q1.push(c);
	}
}
int main()
{
	solve();
}

Measured memory_bytes: 1792