akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

bool comparator(pair<int, int> a, pair<int, int> b) 
{ 
    return (a.first > b.first); 
} 

int main() {
	// your code goes here
	int n,m;

	int a,b,c;
	register int i;
	long long int sum=0;

	cin >> n >> m;
	priority_queue <int, vector<int>, greater<int>> pq;
	for(i=0;i<n;i++){
		//cin >> a;
		scanf("%d", &a);
		pq.push(a);
		sum+=a;
	}

	vector<pair<int,int>> v;
	for(i=0;i<m;i++){
		scanf("%d",&b);
		scanf("%d",&c);
		v.push_back(make_pair(c,b));
	}
	sort(v.begin(), v.end(), comparator);
	for(i=0;i<m;i++){
		//scanf("%d",&b);
		//scanf("%d",&c);
		//cin >> b >> c;
		b = v[i].second;
		c = v[i].first;
		//cout << b << " " <<  c << endl;
		while(b!=0){
			int temp = pq.top();
			if(temp >= c)
				break;
			pq.pop();
			pq.push(c);
			sum = sum + c - temp;
			b--;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1784
#include<iostream>
#include<algorithm>

int gcd(int a, int b, int c) {

	for (int i = std::min(a, std::min(b, c)); i > 1; i--) {
		if (a % i == 0 && b % i == 0 && c % i == 0)
			return i;
	}

	return 1;
}

int main() {

	int n;

	long long res = 0;

	std::cin >> n;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				res += gcd(i, j, k);
			}
		}
	}

	std::cout << res << std::endl;

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

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

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

ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];

int main() {
	cin >> N >> M >> L;
    rep (i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i] -= 1;
        B[i] -= 1;
    }
    cin >> Q;
    rep (i, Q) {
        cin >> s[i] >> t[i];
        s[i] -= 1;
        t[i] -= 1;
    }

    rep (i, N) {
        rep (j, N) {
            fuel[i][j] = LINF;
            dist[i][j] = LINF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    rep (i, M) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    rep (i, N) rep (j, N) rep (k, N) {
        chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
    }
    rep (i, N) rep(j, N) {
        if (i==j) continue;
        if (fuel[i][j] <= L) chmin(dist[i][j], 1LL);
    }
    rep (i, N) rep(j, N) rep(k, N) {
        chmin(dist[j][k], dist[j][i] + dist[i][k]);
    }

    rep(i, Q) {
        if(dist[t[i]][s[i]] < LINF) cout << dist[t[i]][s[i]] - 1 << endl;
        else cout << -1 << endl;
    }
	return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int N, count = 0;
    cin >> N;
    int L[N];
    rep(i, N) cin >> L[i];
        sort(L,L+N);
    for (int a = 0; a < N - 2; a++){
        for (int b = a + 1; b < N - 1; b++){
            for (int c = b + 1; c < N; c++){
                if(L[c]<L[a]+L[b])count++;
            }
        }
    }
    cout<<count<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,m;cin>>n>>m;
    n--;
    cout << (m-1+n-1)/n << endl;
    return 0;
}



Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pi pair<ll,ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
ll factorial(ll n)
{
	if (n == 0)
		return 1;
	ll i = n, fact = 1;
	while (n / i != n) {
		fact = (fact % MOD) * (i % MOD);
		i--;
	}
	return fact % MOD;
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		cout << factorial(n);
	}
	return 0;
}

Measured memory_bytes: 3552
/*ex7_3
 Sweet_Sweet_Soul */
#include <stdio.h>
#include <stdlib.h>

int main(void) {
    int hei,wid;/*hei=height、wid＝width*/
    int *hei_ture,*wid_ture;/*各行や列に'#'があれば1を記録する配列*/
    char **grid;/*入力用の多次元配列*/
    scanf("%d%d",&hei,&wid);
    grid=(char**)calloc(hei,sizeof(char*));/*まず各配列の先頭のポインタを確保*/
    if(grid==NULL){
        exit(1);
    }
    for(int i=0;i<hei;i++){
        grid[i]=(char*)calloc(wid,sizeof(char));/*各配列の要素を確保*/
        if(grid[i]==NULL){
            exit(1);
        }
    }
    hei_ture=(int*)calloc(hei,sizeof(int));/*他二つのtrue配列も確保*/
    if(hei_ture==NULL){
        exit(1);
    }
    wid_ture=(int*)calloc(wid,sizeof(int));
    if(wid_ture==NULL){
        exit(1);
    }
    for(int i=0;i<hei;i++){
        for(int j=0;j<wid;j++){
            scanf(" %c",&grid[i][j]);/*gridに入力*/
            if(grid[i][j]=='#'){
                hei_ture[i]=1;/*ついでに真偽値も記録*/
                wid_ture[j]=1;
            }
        }
    }
    for(int i=0;i<hei;i++){
        if(hei_ture[i]==1){
            for(int j=0;j<wid;j++){
                if(wid_ture[j]==1){
                    printf("%c",grid[i][j]);/*行、列ともに真偽値1なら出力*/
                }
            }
            printf("\n");/*行ごとに改行*/
        }
    }
    /*先に各要素の配列のメモリを解放*/
    for(int i=0;i<hei;i++){
        free(grid[i]);
    }
    /*次に先頭のポインタを解放*/
    free(grid);
    free(hei_ture);
    free(wid_ture);
    return 0;
}


Measured memory_bytes: 1624
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

ll dp[N];
ll v[N];
int w[N];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j,m;
    int W;
    cin>>n>>W;
    rep(i,1,n)cin>>w[i]>>v[i];
    ll ans =  0;
    rep(i,1,n)
    {
        for(int j=W;j>=w[i];j--)
        {

            dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
            ans = max(ans,dp[j]);
        }
    }
    cout<<ans<<"\n";

            

    
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  string ans = "";
  for(int i = 0; i < s.size(); i += 2) ans += s[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
const int maxn=200010;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int h[maxn],dp[maxn],n;
int main()
{
    n=read();
    for(int i=1;i<=n;i++)
        h[i]=read();
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    int n;cin >>n;
    vv a(2, vi(n));
    
    rep(i,2)rep(j,n)cin>>a[i][j];
    rep(i,n-1)a[0][i+1]+=a[0][i];
    rep(i,n-1)a[1][n-2-i]+=a[1][n-1-i];
    
    int ans = 0;
    rep(i,n)ans = max(ans, a[0][i]+a[1][i]);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3588
import java.util.*;
class Main {
 
	//最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}
   //整数かどうかを判定する
 static boolean isInteger(double number){return Math.ceil(number) == Math.floor(number); }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
 
		int n = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		if(t*s >= n){
			System.out.println("Yes");
		} else System.out.println("No");
	}
}

Measured memory_bytes: 35628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
int inf = 1000000000;
ll INF = 1000000000000000000;
int n, a[100010];
int main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int cnt = 0;
	int syu = 1;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i])cnt++;
		else syu++;
	}
	if (cnt % 2)cout << syu - 1 << endl;
	else cout << syu << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	int x = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		ans = max(x, ans);
		if (s[i] == 'I') {
			x++;
		} else {
			x--;
		}
		ans = max(x, ans);

	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    S=readline().strip()

    t_left=0
    t_right=N-1
    left=0
    right=0
    for i in range(1,N):
        if S[i]=="W":
            right+=1

    res=0
    min_res=N
    for i in range(N):
        res=abs(t_left-left)+abs(t_right-right)
        min_res=min(min_res,res)
        if i!=N-1:
            t_left+=1
            t_right-=1
            if S[i]=="E":
                left+=1
            if S[i+1]=="W":
                right-=1

    print(min_res)
if __name__=="__main__":
    main()

Measured memory_bytes: 3828
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
		String a = sc.nextLine();
		if ("ABC".equals(a)) {
          System.out.println("ARC");
        }else if ("ARC".equals(a)){
          System.out.println("ABC");
        }
	}
}

Measured memory_bytes: 35668
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        int ans = 0;
        String p = "No";
        for (int i = 0; i<n; i++){
            int a = sc.nextInt();
            int b = sc.nextInt();

            if (a==b)
                ans++;
            else
                ans = 0;
            if (ans==3){
                p = "Yes";
                break;
            }
        }
        System.out.println(p);
    }
}

Measured memory_bytes: 36060
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a%10 == a && b%10==b){
        pr(a*b);
    }else{
        pr(-1);
    }
}

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

using namespace std;

int main() {

    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    int max_a, min_a;
    max_a = max({a1, a2, a3});
    min_a = min({a1, a2, a3});

    cout << max_a - min_a << endl;
}

Measured memory_bytes: 256
// F.cpp
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
string a, b;
int dplen[3100][3100], lena, lenb;
short ldp[3100][3100], rdp[3100][3100];
int main()
{
    cin >> a >> b;
    if (a.length() < b.length())
        swap(a, b);
    lena = a.length(), lenb = b.length();
    a = ' ' + a, b = ' ' + b;
    for (int i = 1; i <= lena; i++)
        for (int j = 1; j <= lenb; j++)
            if (a[i] == b[j])
            {
                dplen[i][j] = dplen[i - 1][j - 1] + 1;
                ldp[i][j] = i, rdp[i][j] = j;
            }
            else
            {
                if (dplen[i][j - 1] > dplen[i - 1][j])
                    dplen[i][j] = dplen[i][j - 1],
                    ldp[i][j] = ldp[i][j - 1], rdp[i][j] = rdp[i][j - 1];
                else
                    dplen[i][j] = dplen[i - 1][j],
                    ldp[i][j] = ldp[i - 1][j], rdp[i][j] = rdp[i - 1][j];
            }
    string str;
    for (int x = ldp[lena][lenb], y = rdp[lena][lenb]; x != 0;)
    {
        str += a[x];
        int x_ = x;
        x = ldp[x - 1][y - 1], y = rdp[x_ - 1][y - 1];
    }
    reverse(str.begin(), str.end());
    cout << str;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int n;
    cin >> n;

    vector<int> cnt(100005, 0);
    rep(i, n){
        int a;
        cin >> a;
        cnt[a]++;
        cnt[a+1]++;
        if(a > 0) cnt[a-1]++;
    }

    int ans = 0;
    for (auto& p : cnt) {
        ans = max(ans, p);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
# -*- coding:utf-8 -*-

def solve():
    S = input()
    pre_moji = S[0]
    for i in range(1, len(S)):
        if S[i] == pre_moji:
            print("Bad")
            return
        pre_moji = S[i]
    print("Good")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
//=================================
// Created on: 2018/07/04 14:05:12->14:07; 14:22->
//=================================
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
int main()
{
    for (int W, H;;) {
        cin >> W >> H;
        if (W == 0 and H == 0) { break; }
        using Map = vector<int>;
        Map f(H, 0);
        int sy, sx, gy, gx;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int c;
                cin >> c;
                if (c == 1) { f[i] |= (1 << j); }
                if (c == 2) { sy = i, sx = j; }
                if (c == 3) { gy = i, gx = j; }
            }
        }
        vector<vector<vector<map<Map, int>>>> memo(10, vector<vector<map<Map, int>>>(H, vector<map<Map, int>>(W)));
        constexpr int INF = 1 << 30;
        constexpr int d[] = {1, 0, -1, 0, 1};
        auto in = [&](const int y, const int x) { return y >= 0 and y < H and x >= 0 and x < W; };
        auto rec = [&, d](auto&& self, const int moved, const int y, const int x, const Map& map) -> int {
            if (y == gy and x == gx) { return 0; }
            if (moved == 10) { return INF; }
            if (memo[moved][y][x].find(map) != memo[moved][y][x].end()) { return memo[moved][y][x][map]; }
            int ans = INF;
            for (int di = 0; di < 4; di++) {
                const int dy = d[di], dx = d[di + 1];
                int newy = y + dy, newx = x + dx;
                if (not in(newy, newx) or (map[newy] & (1 << newx))) { continue; }
                for (; in(newy, newx) and not(map[newy] & (1 << newx)) and not(newy == gy and newx == gx); newy += dy, newx += dx) {}
                if (not in(newy, newx)) { continue; }
                if (newy == gy and newx == gx) { return memo[moved][y][x][map] = 1; }
                Map newmap = map;
                newmap[newy] -= (1 << newx);
                newy -= dy, newx -= dx;
                ans = min(ans, self(self, moved + 1, newy, newx, newmap) + 1);
            }
            return memo[moved][y][x][map] = ans;
        };
        const int ans = rec(rec, 0, sy, sx, f);
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}



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

int main()
{
	string S;
	cin >> S;
	if (S.size()==2)
	{
		cout << S << endl;
	}
	else
	{
		cout << S[2] << S[1] << S[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#define rep(i, x) for(ll i = 0; i < x; i++)
using namespace std;
typedef long long ll;
const ll MOD = (ll)998244353;
const ll N = 1e5+5, inf = 1e9+5000;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    for (int i = 0; i < n; i++) {
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i+1];
        b[i+1] += b[i];
    }
    ll ans = 0;
    for (ll left = 0; left < n+1; left++) {
        ll left_cnt = a[left];
        if (left_cnt > k) break;
        ll rest = k - left_cnt;
        auto it = upper_bound(begin(b), end(b), rest);
        ll right = it - b.begin() - 1;
        ans = max(ans, left+right);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6044
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let arr: String = read();
    let arr: Vec<char> = arr.chars().collect();
    let mut r = Vec::new();
    let mut w = Vec::new();
    for i in 0..n {
        if arr[i] == 'R' {
            r.push(i);
        } else {
            w.push(i);
        }
    }
    if w.is_empty() || r.is_empty() {
        println!("0");
    } else {
        let mut ans = 0;
        while r.last().unwrap() > w.first().unwrap() {
            r.pop();
            w.remove(0);
            ans += 1;
            if r.is_empty() || w.is_empty() {
                break;
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4964
import sys


def solve(K: int, X: int):
    s = X - (K - 1)
    e = X + (K - 1)
    ans = []
    for i in range(2000001):
        x = i - 1000000
        if s <= x <= e:
            ans.append(str(x))
    return " ".join(ans)
        


# -----------------------------------------------------------------------------
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()

    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int

    ans = solve(K, X)
    if ans is not None:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import math
n = int(input())
all_li = []
for _ in range(n-1):
    tmp_li = list(map(int,input().split()))
    all_li.append(tmp_li)
if n == 1:
    tmp = all_li[0]
    print(tmp[0]+tmp[1])
    exit()
for i,a in enumerate(all_li):
    now = a[1]+a[0]
    #print(i,now,all_li[i+1:])
    for aa in all_li[i+1:]:
        x,y,z = (aa[0],aa[1],aa[2])
        if now <= y:
            now = y+x
        else:
            now = math.ceil((now-y)/z)*z + y + x
    print(now)
    now = 0
print(0)

Measured memory_bytes: 42572
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	int n,q;
	cin>>n>>q;
	vector<string> name(n);
	vector<int> time(n);
	queue<int> que;
	rep(i,n){
		cin>>name[i]>>time[i];
		que.push(i);
	}
	int x;
	int timen=0;
	while(que.empty()==0){
		x=que.front();
		que.pop();
		if(time[x]<=q){
			timen+=time[x];
			cout<<name[x]<<" "<<timen<<endl;
		}else{
			timen+=q;
			time[x]-=q;
			que.push(x);
		}
	}
}

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

using namespace std;
using ll = long long;
const ll MOD = 1000003;
ll x, d, n;

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

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define LEN(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int a,b; cin >>a >>b;
	if (b>=a) {
		cout <<"unsafe";
		return 0;
	}
	cout <<"safe";
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
using namespace std;
int n,m;
vector<pair<int,int> > v[100005];
bool vis[100005];
int num[100005];
bool dfs(int x,int fill)
{
	if(vis[x]) return num[x]==fill;
	vis[x]=true;
	num[x]=fill;
	for(int i=0;i<v[x].size();i++){
		pair<int,int> y=v[x][i];
		if(!dfs(y.first,num[x]+y.second)) return false;
	}
	return true;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d;
		v[l].push_back(make_pair(r,d));
		v[r].push_back(make_pair(l,-d));
	}
	for(int i=1;i<=n;i++) if(!vis[i]) if(!dfs(i,0)) {cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 12032
n,k = map(int,input().split())
ans = 0
for i in range(min(n,k)):
  j = 0
  while (i+1) * (2 ** j) < k:
    j += 1
  ans += (1/n) * ((1/2)**j)
if n - k > 0:
  ans += (n - k)/n
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <cstring>
using namespace std;
map <string,bool> dict;
int main() {
	int n;
	cin >> n;
	for (int i=0;i<n;i++) {
		string a,b;
		cin >> a >> b;
		if (a=="insert") dict[b]=true;
		else {
			if (dict.find(b)!=dict.end()) cout << "yes\n";
			else cout << "no\n";
		}
	}
	return 0;
}


Measured memory_bytes: 36432
import java.util.Scanner;

public class Main {

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

		boolean isStepable = true;
		String ans = "";

		// 奇数文字にLがくるとだめ。偶数にRが来てもだめ。
		for (int i = 0; i < S.length(); i++) {
			if (i % 2 == 0) {
				// 偶数
				if (S.charAt(i) == 'L') {
					isStepable = false;
				}
			} else {
				// 奇数
				if (S.charAt(i) == 'R') {
					isStepable = false;
				}
			}
		}

			if (isStepable) {
				ans = "Yes";
			} else {
				ans = "No";
			}
			System.out.println(ans);

		

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define aint(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 1000005;


int32_t main()
{

    IOS




    int n;
    cin >> n;

    map<int,int> mp;

    for(int i = 2; i*i <= n; i++)
    {
    	while(n%i == 0)
    	{
    		n/=i;
    		mp[i]++;
    	}
    }

    if(n != 1)mp[n]++;

    int ans = 0;
    for(auto i : mp)
    {
    	int j = 1 ,k = i.second;
    	while(k-j >=0)
    	{
    		k-=j;
    		j++;
    		ans++;
    	}
    }


    cout << ans;



    return 0;
}


Measured memory_bytes: 3632
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int n , k;
const int M = 2e5 ;
int a[M];
ll ans ;
int main()
{
    scanf ("%d%d" , &n ,&k);
    for (int i =0 ; i < n;i++)
        scanf ("%d" ,a+i);
    sort(a,a+n);
    for (int i =0 ; i < n - k;i++)
        ans += a[i];

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

}


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

using namespace std;

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

    vector<int> v(n);
    vector<int> idx(n);
    for (int i=0; i<n; ++i) {
        cin >> v[i];
        idx[i] = i;
    }

    sort(idx.begin(), idx.end(), [&v](int l, int r) {
        return v[l] < v[r];
    });

    for (int i=0; i<n; ++i) {
        cout << idx[i]+1 << " \n"[i==n-1];
    }
}

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    int N, K; cin >> N >> K;
    vector<ll> A(N), in(N), ex(N);
    vector<ll> insum(N), exsum(N), st(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    bool judge;
    for (int i = 0; i < K; i++) {
        for (int j = 0; j < N; j++) {
            in.at(j) = 0;
            ex.at(j) = 0;
            insum.at(j) = 0;
            exsum.at(j) = 0;
            st.at(j) = 0;
        }
        for (int j = 0; j < N; j++) {
            int X = j - A.at(j);
            X = max(0, X);
            in.at(X)++;
            ex.at(min((ll)(N - 1), j + A.at(j)))++;
        }
        insum.at(0) = in.at(0);
        exsum.at(0) = ex.at(0);
        st.at(0) = in.at(0) - ex.at(0);
        for (int j = 1; j < N; j++) {
            insum.at(j) = insum.at(j - 1) + in.at(j);
            exsum.at(j) = exsum.at(j - 1) + ex.at(j);
            st.at(j) = insum.at(j) - exsum.at(j);
        }
        A.at(0) = in.at(0);
        for (int j = 1; j < N; j++) {
            A.at(j) = in.at(j) + st.at(j - 1);
        }
        for (int j = 0; j < N; j++) {
            if (A.at(j) == N) judge = true;
            else judge = false;
        }
        if (judge) {
            break;
        }
    }
    for (int i = 0; i < N; i++) {
        if (i != N - 1) cout << A.at(i) << ' ';
        else cout << A.at(i) << endl;
    }
    return 0;
}


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

int main() {
	int l[10];
	int x1,x2;
	while (cin >> l[0])
	{
		int sum=0;
		for (int i=1; i<10; i++)scanf(",%d",&l[i]);
		for (int i=0; i<10; i++)sum+=l[i];
		scanf(",%d,%d",&x1,&x2);
		double time=(double)(sum)/(x1+x2);
		double d=time*x1;
		int r=0;
		while (d>0)
		{
			d-=l[r];
			r++;
		}
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import math
a, b, C = map(float, input().split())
C_rad = math.radians(C)
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C_rad))
S = a * b * math.sin(C_rad) / 2
L = a + b + c
h = b * math.sin(C_rad)
print("{0} {1} {2}".format(S, L, h))

Measured memory_bytes: 7788
def solve():
    N, T = map(int, input().split())
    ct = list(list(map(int, input().split())) for _ in range(N))
    if any([t <= T for c, t in ct]):
        return min([c for c, t in ct if t <= T])
    else:
        return "TLE"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int n;
	cin >> n;
	vi h(n);
	Foz(i, n) cin >> h[i];

	auto solve = [&] () {
		Doz(i, n - 1) {
			int d = h[i + 1] - h[i];
			if (d < -1) return false;
			if (d == -1) h[i]--;
		}
		return true;
	};

	cout << (solve() ? "Yes" : "No") << '\n';
}



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

#define minm 1000000
int s;
set<long> aset;
long avec[minm];

int main(){
    scanf("%d", &s);
    avec[0] = s;
    long idx = 0;
    aset.insert(avec[0]);
    for(long i =0 ; i< minm; i++){
        if(avec[i]%2){
            avec[i+1] = avec[i] *3 +1;
        }else{
            avec[i+1] = avec[i] / 2;
        }
        if(aset.count(avec[i+1])){
            idx = i+1;
            break;
        }
        aset.insert(avec[i+1]);
    }
    printf("%ld", idx+1);
    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll f = 0;
    ll Ncopy = N;
    while(N > 0){
        f += N % 10;
        N /= 10;
    }

    if(Ncopy % f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define LL long int

void solve(){
    int n;
    cin >> n;

    bool ans = true;

    int a;

    for(int i = 0; i < n; ++i){
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                ans = false;
            }
        }
    }

    if(ans){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }


    return ;
}

int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int N;
    string S;

    cin >> N >> S;

    int r = 0;
    int b = 0;
    for(int i = 0; i < N; i++)
    {
        if ( S[i] == 'R') {
            r++;
        } else {
            b++;
        }
    }
    string ans = r > b ? "Yes" : "No";
    
    cout << ans << endl;
        
}

Measured memory_bytes: 256
n = gets.to_i
c = gets.split.to_a
h = {}
n.times do |i|
  if h[c[i].to_i]
    h[c[i].to_i] += 1
  else
    h[c[i].to_i] = 1
  end
end
s = h.select{|k, v| v >= 4}.keys.sort{|a, b| b<=>a}
t = h.select{|k, v| v >= 2}.keys.sort{|a, b| b<=>a}
ans = 0
ans = s[0] * s[0] if s.size > 0
ans = [ans, t[0] * t[1]].max if t.size > 1
puts ans

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,ll>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

struct Edge{
    ll to, cap, rev;
};

int N;
std::vector<Edge> G[120];
bool used[120];
 
void addEdge(int from, int to, ll cap){
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, 0, (int)G[from].size()-1});
}
     
ll dfs(int v, int t, ll f){
    if(v == t){return f;}
    used[v] = true;
    for(Edge& e : G[v]){
        if(!used[e.to] && e.cap > 0){
            ll d = dfs(e.to, t, std::min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
     
ll maxFlow(int s, int t){
    ll flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        ll f = dfs(s, t, 10000);
        if(f == 0){return flow;}
        flow += f;
    }
 
    return flow;
}

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

    std::cin >> N;

    ll sum = 0ll;
    for(int i=1;i<=N;++i){
        int a;
        std::cin >> a;

        // 0 -> i: x = iの操作を行わない
        // i -> N+1: x = iの操作を行なう
        if(a > 0){
            addEdge(0, i, 0);
            addEdge(i, N+1, a);
        }else{
            addEdge(0, i, -a);
            addEdge(i, N+1, 0);
        }

        sum += max(a, 0);
    }

    for(int i=1;i<=N;++i){
        for(int j=i*2;j<=N;j+=i){
            addEdge(i, j, 1001001001001ll);
        }
    }

    ll res = sum - maxFlow(0, N+1);
    std::cout << res << std::endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];

  int change_cnt = 0;
  bool flg = true;
  while(flg) {
    flg = false;
    for(int j = n-1; 0 < j; j--) {
      if(a[j] < a[j-1]) {
        int tmp = a[j];
        a[j] = a[j-1];
        a[j-1] = tmp;

        change_cnt++;
        flg = true;
      }
    }
  }

  for(int i = 0; i < n; i++) {
    cout << a[i];
    if(i != n-1) cout << " ";
  }
  cout << endl << change_cnt << endl;
  return 0;
}



Measured memory_bytes: 3132
#include<stdio.h>
main()
{
    long long a,b,k;
    while(scanf("%lld %lld",&a,&b)==2){
        if((a+b)%2!=0){
            printf("IMPOSSIBLE\n");
        }
        else{
            printf("%lld\n",(a+b)/2);
        }
    }
}


Measured memory_bytes: 128
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - To Infinity
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

char s[16];

/* subroutines */

/* main */

int main() {
  ll k;
  scanf("%s%lld", s, &k);

  for (char *cpt = s; *cpt; cpt++) {
    k--;
    if (k == 0 || *cpt > '1') {
      printf("%c\n", *cpt);
      break;
    }
  }
  return 0;
}


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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int t = 0, ans = 0;
    rep(i, n){
        if(t != 0 && a[i] - t == 1) ans += b[a[i]-1] + c[a[i]-2];
            else ans += b[a[i]-1];
        t = a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
y = input().split()
y = int(y[0]) + 1
num = 0
for i in range(y):
    if (i%2):
        syou = 0
        for j in range(i):
            if not (i % (j+1)):
                syou = syou + 1
        if syou == 8:
            num = num + 1
print(num)


Measured memory_bytes: 3060
#include <stdio.h>
int main(int argc, const char *argv[]){
    int a,b =0;
    scanf("%d %d",&a,&b);
    if(a==b){
        printf("a == b\n");
    }else if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include<iostream>
using namespace std;
int main(void){
	int A,B,C;
  	cin >>A>>B>>C;
  	if(A==B||A==C||B==C){
      if(A==B&&B==C)cout << "No"<<endl;
      else cout << "Yes"<< endl;
    }
  	else cout << "No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<int> B(N);
	B = A;
	sort(B.begin(), B.end(), greater<int>());
	int m1 = B[0], m2 = B[1];
	for (int i = 0; i < N; i++) {
		if (m1 == m2) cout << m1 << endl;
		else if (A[i] == m1) cout << m2 << endl;
		else cout << m1 << endl;
	}
	return 0;
}

Measured memory_bytes: 4816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll N, K;
ll dp[2][41];//0:小さい 1:同じ
ll bit[41];
int main(){
    cin >> N >> K;

    for(int i = 0; i < N; i++){
        ll A;
        cin >> A;
        for(int j = 0; j < 40; j++){
           if((A >> j) & 1) bit[j]++; 
        }
    }
    for(int i = 39; i >= 0; i--){
        if(dp[0][i + 1] != 0) dp[0][i] = dp[0][i + 1] + max(bit[i], N - bit[i]) * ((ll)1 << i);
        
        if((K >> i) & 1){
            dp[1][i] = dp[1][i + 1] + (N - bit[i]) * ((ll)1 << i);
            dp[0][i] = max(dp[0][i], dp[1][i + 1] + bit[i] * ((ll)1 << i));
        }else{
            dp[1][i] = dp[1][i + 1] + bit[i] * ((ll)1 << i);
        }
    }

    cout << max(dp[0][0], dp[1][0]) << endl;
    return 0;
} 

Measured memory_bytes: 256
def is_prime(n):
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return n != 1

def witness(a, n, t, u):
    x = pow(a, u, n)  # x0 = a^u mod nを計算
    y = x

    for _ in range(0, t):
        y = (x * x) % n

        # 法nの下での1の非自明な平方根が存在するのはnが合成数であるときに限る
        if y == 1 and x != 1 and x != (n - 1):
            return True
        x = y
    return y != 1

def is_probably_prime(n, witnesses):
    t = 1
    u = n >> 1
    while u & 1 == 0:
        t = t + 1
        u >>= 1
    assert(2**t * u == n - 1)

    for a in witnesses:
        if a < n and witness(a, n, t, u):
            return False
    return True

def is_definitely_prime(n):
    if ((not (n & 1)) and n != 2) or (n < 2) or ((n % 3 == 0) and (n != 3)):
        return False
    elif n <= 3:
        return True
    else:
        return is_probably_prime(n, [2, 7, 61])

n = int(input())
answer = 0
for _ in range(0, n):
    m = int(input())
    if is_definitely_prime(m):
        answer = answer + 1
print(answer)


Measured memory_bytes: 5632
#include<stdio.h>                              
                                               
int l[100010];                                 
int r[100010];                                 
                                               
signed main()                                  
{                                              
  int n,m;                                     
  scanf("%d %d",&n,&m);                        
                                               
  int L = 0,R = 1000000;                       
  for( int i = 0; i < m; ++i ){                
    scanf("%d %d",&l[i],&r[i]);                
                                               
    if( l[i] >= L ) L = l[i];                  
    if( r[i] <= R ) R = r[i];                  
                                               
  }                                            
                                               
  int ans = R - L + 1;                         
  if( ans >= 0 ) printf("%d\n",ans);           
  else printf("0\n");                          
                                               
  return 0;                                    
                                               
}                                              

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

int main()
{
	char s[4];
	int n[3];
	cin >> s;

	int num = 0;

	rep(i, 3) {
		if(s[i] == '1') num++;
	}

	cout << num << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

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

  if(b < c || a > d) {
    cout << 0 << endl;
    return 0;
  } else {
    int x = max(a,c);
    int y = min(b,d);
    cout << y-x << endl;
  }
}

Measured memory_bytes: 256