akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); ++i)
//using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))   //最大値を求める
#define MIN(x) *min_element(ALL(x))   //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647    //int値の最大値
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                            //vectorヘの挿入
#define MP make_pair                            //pairのコンストラクタ
#define F first                                 //pairの一つ目の要素
#define S second                                //pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x) //小数点以下の桁数指定
template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;        
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b){
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b){

    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b){
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x){
    int sum = 0;
    while (x >0) {
        sum += (x %10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x){
    int reverse = 0;
    int r;
    while (x >0){
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    ll n;
    cin >> n;
    int mi = 10000;
    
    for (int i = 1; i <=n/2; i++) {
        int a=sumDight(i)+sumDight(n-i);
            if(a<mi){
                mi = a;
            }
        
        
    }
    cout << mi << endl;
}


Measured memory_bytes: 3620
a=int(input())
b=int(input())

if a==1 :
  if b==2:
    print(3)
  elif b==3:
    print(2)
elif a==2:
  if b==1:
    print(3)
  elif b==3:
    print(1)
elif a==3:
  if b==1:
    print(2)
  elif b==2:
    print(1)
  

Measured memory_bytes: 2940
import itertools

N, M, Q = map(int, input().split())
abcd = []
for i in range(Q):
    *v, = map(int, input().split())
    abcd.append(v)

ans = 0
c = [i for i in range(1, M+1)]
for A in itertools.combinations_with_replacement(c, N):
    ta = 0
    for a, b, c, d in abcd:
        if (A[b-1]-A[a-1]) == c:
            ta += d
    if ans < ta:
        ans = ta

print(ans)


Measured memory_bytes: 67788
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
    int n, ans = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            if (i < n && a[i + 1] == a[i + 1]) {
                ans++;
                swap(a[i], a[i + 1]);
            }
            else if (i > 1) {
                swap(a[i], a[i - 1]);
                ans++;
            }
            else {
                swap(a[i], a[i + 1]);
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    ll diff = 1LL<<30, ans = 0;
    rep(i, n) {
        if (abs(sum - a[i] * n) < diff) {
            diff = abs(sum - a[i] * n);
            ans = i;
        }
    }
    cout << ans << endl;
}

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

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

typedef long long ll;
const ll INF = 1LL << 60;

int main ()
{
	int n, w;
  	cin >> n >> w;
  	ll weight[110], value[110];
  	ll dp[110][100010] = {0};
  	for(int i = 0; i < n; i++)
    {
    	cin >> weight[i] >> value[i];
    }
  	for(int i = 0; i < n; i++)
    {
    	for(int sum_w = 0; sum_w <= w; sum_w++)
        {
        	if(sum_w >= weight[i])
            {
            	chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }
          	chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }
  	cout << dp[n][w] << endl;
}

Measured memory_bytes: 86144
a = list(raw_input())
b = list(raw_input())
c = list(raw_input())
mydict = {'A':a, 'B':b, 'C':c}
nextp = mydict['A']

while True:
    char = nextp.pop(0)
    nextp = mydict[char.upper()]
    if not nextp:
        print char.upper()
        break

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

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

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define vi vector<int>
#define vii vector< vector<int> >

int a, b;

int main() {

	cin >> a >> b;

	int m = min(a, b);
	int M = max(a, b);
	int ans = 0;

	rep(i, M) ans += m * pow(10, i);
	cout << ans << endl;

}


Measured memory_bytes: 384
beforex_plus_y=[]
beforex_minus_y=[]
for i in range(int(input())):
  xy=list(map(int,input().split()))
  beforex_plus_y.append(xy[0]+xy[1])
  beforex_minus_y.append(xy[0]-xy[1])

print(max(max(beforex_plus_y)-min(beforex_plus_y),max(beforex_minus_y)-min(beforex_minus_y)))

Measured memory_bytes: 24808
#include<iostream>
using namespace std;
	int d[1000];
	int c[1000];
	int a[1000][1000];

int main(){
	int n=0;
	int m=0;
	int e=0;
	int f=0;
	int i=0;
	int j=0;
	int k=0;
	
	for(i=0;i<1000;i++){
		d[i]=0;
		c[i]=0;
		for(j=0;j<1000;j++){
			a[i][j]=0;
		}
	}
	cin>>n;
	cin>>m;
	for(i=0;i<n;i++){
		cin>>d[i];
	}
	for(i=0;i<m;i++){
		cin>>c[i];
	}                   
	for(i=1;i<m+1;i++){
		for(j=1;j<n+1;j++){
			if(j<i){
				e=a[i-1][j];
				f=a[i-1][j-1]+c[i-1]*d[j-1];
				if(e<f){
					a[i][j]=e;
				}else{
					a[i][j]=f;
				}
			}
		}
		if(i<=n){
			a[i][i]=a[i-1][i-1]+c[i-1]*d[i-1];
		}
	}      
	cout<<a[m][n]<<endl;
}

Measured memory_bytes: 6996
a=list(input())
if ("N" in a and"S"in a)or(not"N" in a and not "S" in a):
    if ("W" in a and"E"in a)or(not"W" in a and not "E" in a):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())
c,I,ans = 0,1,[]
lis = 'abcdefghijklmnopqrstuvwxyz'

I_=0
while 26**I+I_<N:
  I_+=26**I
  I+=1
  
for i in range(I):
  N,mod = divmod(int(N),26)
  if mod == 0:
    N-=1
  #print('N',N)
  #print('mod',mod)
  ans.append(lis[mod-1])

ans.reverse()
print(''.join(ans))
  
  
    
    

Measured memory_bytes: 9136
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
    int n; 
    cin >> n;
    int a[n + 1];
    a[0] = 1; a[1] = 1;
    for(int i = 2; i <= n; i++){
        a[i] = a[i-1] + a[i-2];
    }
    cout << a[n] << endl;
}


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

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

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

    bool judge=true;

    for(int i=1; i<n; i++){
        if(w[i-1][w[i-1].size()-1]!=w[i][0]){
            judge=false;
        }
        for(int j=0; j<i; j++){
            if(w[i]==w[j]){
                judge=false;
            }
        }
    }

    cout<<(judge==true ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
int main(){
	int n,k;
	cin>>n>>k;
	long long ans=1;
	if(n>k) {cout<<0<<endl; return 0;}
	lp(i,n) ans*=k,k--,ans%=(1000000007);
	cout<<ans<<endl;
	return 0;		
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    string s1, s2, s3;

    cin >> s1 >> s2 >> s3;

    cout << "A" << s2[0] << "C" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    if(K <= A) {
        cout << K << endl;
    } else if(K <= A+B) {
        cout << A << endl;
    } else {
        cout << A - (K-A-B) << endl;
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans*= i;
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <map>
#include <string>
using namespace std;
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; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

struct info{
    string name;
    int score;
    int order;
};

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


    int N, M; cin >> N >> M;
    vector<vector<int>> switchs (M, vector<int>());
    vector<int> p(M);
    for (int i = 0; i < M; i++) {
        int k;
        cin >> k;
        vector<int> tmp(k);
        for (int i = 0; i < k; i++) {
            cin >> tmp.at(i);
        }
        switchs.at(i) = tmp;
    }

    for (int i = 0; i < M; i++) {
        cin >> p.at(i);
    }

    int res = 0;
     // bit全探索
    for (int bit = 0; bit < (1 << N); ++bit) {
        int sucCount = 0;
        for (int i = 0; i < M; ++i) {
            int tmp = 0;
            for (auto x : switchs.at(i)) {
                if (bit & (1 << (x - 1))) {
                    ++tmp;
                }
            }
            if (tmp % 2 == p.at(i)) {
                ++sucCount;
            }
        }

        if (sucCount == M) {
            ++res;
        }
    }

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


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const int MAX = 200002;

ll N,M;
char a[MAX];

int main()
{
    cin>>N>>M;
    if(N==1&&M==1)cout<<1<<endl;
    else if(N==1||M==1)cout<<N*M-2<<endl;
    else if(N==2||M==2)cout<<0<<endl;
    else {
        cout<<N*M - 2*N-2*M+4<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'I') {
            x++;
            chmax(ans, x);
        } else {
            x--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
 int ans[1004][1005];
int main()
{
    int h,w,i,j,count=0;
    cin>>h>>w;
    char st[1005][1005];

    long long int MOD=1e9+7;

    for(i=1;i<=h;i++){
       // for(j=1;j<=w;j++)
            scanf("%s",st[i]);
    }
    ans[1][0]=1;
    for(i=1;i<=h;i++){
        for(j=0;j<w;j++){
            if(st[i][j]=='.'){
                if(st[i-1][j]=='.')
                    ans[i][j]=(ans[i][j]+ans[i-1][j])%MOD;
                if(st[i][j-1]=='.')
                    ans[i][j]=(ans[i][j]+ans[i][j-1])%MOD;
            }
        }
    }

    cout<<ans[h][w-1];

}


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

struct die_t {
	int top, front, right, left, back, bottom;

	die_t (int t, int f, int r, int l, int bk, int b)
	: top(t), front(f), right(r), left(l), back(bk), bottom(b) { }

	
	die_t ()
	: top(1), front(3), right(5), left(2), back(4), bottom(6) { }

	void rotate_swap ( int &a, int &b, int &c, int &d ) {
		swap(a, b); swap(b, c); swap(c, d);
	}

	void rotate_right( void ) { rotate_swap(top,left,bottom,right); }
	void rotate_left ( void ) { rotate_swap(top,right,bottom,left); }
	void rotate_front( void ) { rotate_swap(top,back,bottom,front); }
	void rotate_back ( void ) { rotate_swap(top,front,bottom,back); }
	void rotate_cw   ( void ) { rotate_swap(back,left,front,right); }
	void rotate_ccw  ( void ) { rotate_swap(back,right,front,left); }

	void set_tf(int t, int f) {
		// top
		if (t == top){
		}else if (t == bottom){
			rotate_back();
			rotate_back();
		}else {
			while (t != front)
				rotate_cw();
			rotate_back();
		}

		// front
		while (f != front)
			rotate_cw();
	}

	void disp( void ) { printf("%d %d %d %d %d %d", top, bottom, front, back, right, left); };
};

typedef struct area_t {
	int num;
	int height;
	int bnum;

	area_t ()
		: num(0), height(0), bnum(0) { }
} Area;

struct P {
	int x, y;
	P() {};
	P(int x, int y) : x(x), y(y) {
	}
};

int main(void) {
	int N;
	while (cin >> N, N) {
		Area area[50][50];

		for (int i = 0; i < N; i++) {
			die_t d;
			int t, f;
			cin >> t >> f;
			d.set_tf(t, f);

			P now(25, 25);

			while (true) {
				bool flg = false;
				P dr(now.x + 1, now.y + 0);
				P dl(now.x + -1, now.y + 0);
				P df(now.x + 0, now.y + 1);
				P db(now.x + 0, now.y + -1);

				for (int j = 6; j >= 4; j--) {
					P mv, dest;
					if (d.front == j && area[df.x][df.y].height < area[now.x][now.y].height){
						d.rotate_front();
						dest = df;
					}else if (d.back == j && area[db.x][db.y].height < area[now.x][now.y].height){
						d.rotate_back();
						dest = db;
					}else if (d.right == j && area[dr.x][dr.y].height < area[now.x][now.y].height){
						d.rotate_right();
						dest = dr;
					}else if (d.left == j && area[dl.x][dl.y].height < area[now.x][now.y].height){
						d.rotate_left();
						dest = dl;
					}else{
						continue;
					}
					
					now = dest;
					flg = true;
					break;
				}
				if (!flg)
					break;
			}

			area[now.x][now.y].num = d.top;
			area[now.x][now.y].height++;
		}

		// output
		vector<int> cnt(7, 0);
		for (int i = 0; i < 50; i++){
			for (int j = 0; j < 50; j++){
				cnt[area[i][j].num]++;
			}
		}

		for (int i = 1; i <= 6; i++) {
			cout << cnt[i] << (i == 6 ? "\n" : " ");
		}
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
int pre[maxn],ans[maxn],si;char s[maxn];
int main(){
	int n,m;scanf("%d%d%s",&n,&m,s);
	pre[0]=s[0]=='1'?-1:0;
	for(int i=1;s[i];i++){
		pre[i]=-1;
		if(s[i]=='1')continue;
		for(int j=min(m,i);j;j--){
			if(pre[i-j]!=-1){pre[i]=i-j;break;}
		}
	}
	if(pre[n]==-1)return puts("-1"),0;
	int x=n;
	while(x)ans[++si]=x-pre[x],x=pre[x];
	for(int i=si;i;i--)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
 vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x;
 while (getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
 template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}
//

int T;

const int mod = 1e9 + 7;
const LL inf = 0x3f3f3f3f3f3f3f3f;

const int N = 19;
int n;

struct C
{
    int x, y;
    LL p;
} city[N];

LL ans[N];

bool vis[N];
int x[N], cntx;
int y[N], cnty;

void dfs(int idx, int tot_cnt)
{
    if (idx == n + 1)
    {
        LL tmp = 0;
        // debug(cntx, cnty);
        assert(cntx + cnty - 2 <= n);
        assert(tot_cnt <= n);
        for (int i = 1; i <= n; i++)
        {
            if (vis[i]) continue;
            LL mini = inf;
            for (int j = 1; j <= cntx; j++)
            {
                mini = min(mini, abs(city[i].x - x[j]) * city[i].p);
            }
            for (int j = 1; j <= cnty; j++)
            {
                mini = min(mini, abs(city[i].y - y[j]) * city[i].p);
            }
            assert(mini != inf);
            tmp += mini;
        }
        ans[tot_cnt] = min(ans[tot_cnt], tmp);
        return;
    }

    // not choose
    dfs(idx + 1, tot_cnt);

    // choose x
    cntx++;
    x[cntx] = city[idx].x;
    vis[idx] = true;
    dfs(idx + 1, tot_cnt + 1);
    cntx--;

    // choose y

    cnty++;
    y[cnty] = city[idx].y;
    dfs(idx + 1, tot_cnt + 1);
    cnty--;
    vis[idx] = false;
}

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

    while (~scanf("%d", &n))
    {
        clr(ans, 0x3f);
        for (int i = 1; i <= n; i++) scanf("%d%d%lld", &city[i].x, &city[i].y, &city[i].p);

        clr(vis, false);
        cntx = cnty = 1;
        x[1] = y[1] = 0;

        dfs(1, 0);
        for (int i = 0; i <= n; i++)
        {
            printf("%lld\n", ans[i]);
        }
        assert(cntx == 1);
        assert(cntx == 1);
    }

    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
  int a,b,t;
  cin >>a >>b >>t;
  cout << int(t/a)*b << endl;
}

Measured memory_bytes: 256
from collections import Counter

def point(lst):
  counter = Counter(lst)
  acc = 0
  for i in range(2, 10):
    acc += i * counter[i]
  for i in range(10, 14):
    acc += 10 * counter[i]
  one_num = counter[1]
  for i in range(one_num + 1):
    if i + (one_num - i) * 11 + acc <= 21:
      acc += i + (one_num - i) * 11
      break
  else:
    acc += one_num
  if acc > 21:
    return 0
  else:
    return acc

while True:
  s = input()
  if s == "0":
    break
  lst = list(map(int, s.split()))
  print(point(lst))



Measured memory_bytes: 5992
import sys
N = int(input())
A = list(map(int, input().split()))
#%%
for a in A:
    if a % 2 == 0:
        if a % 3 == 0:
            continue
        elif a % 5 == 0:
            continue

        else:
            print('DENIED')
            sys.exit()

print('APPROVED')

Measured memory_bytes: 38256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int next_power(int k){
  int t=2;
  while(k>=t) t*=2;
  return t-k;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  map<int,int> mp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int cnt=0;
  for(int i=0;i<n;i++){
    if(mp[a[i]] != 0){
      int dif = next_power(a[i]);
      mp[a[i]]--;
      auto itr = mp.find(dif);
      if(itr != mp.end()){
	if(mp[dif]!=0){
	  mp[dif]--;
	  cnt++;
	}
      }
    }
  }
  cout << cnt << "\n";

  return 0;
}


	  


Measured memory_bytes: 10368
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) fill_n(x, sizeof(x)/sizeof(x[0]), y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scf(x) scanf("%f", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	ll well = min(C,A);
	C -= well;
	A -= well;
	ll good = min(C,B);
	C -= good;
	B -= good;
	cout << well + good + good + B + (C > 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a[502][502] = {};
    vector<pair<pii, pii>> z;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++) {
        if (i % 2) {
            for (int j = 1; j < m; j++) {
                if (a[i][j] % 2) a[i][j]--, a[i][j + 1]++, z.push_back({{i, j}, {i, j + 1}});
            }
            if (a[i][m] % 2 && i < n) a[i][m]--, a[i + 1][m]++, z.push_back({{i, m}, {i + 1, m}});
        } else {
            for (int j = m; j > 1; j--) {
                if (a[i][j] % 2) a[i][j]--, a[i][j - 1]++, z.push_back({{i, j}, {i, j - 1}});
            }
            if (a[i][1] % 2 && i < n) a[i][1]--, a[i + 1][1]++, z.push_back({{i, 1}, {i + 1, 1}});
        }
    }
    cout << z.size() << '\n';
    for (auto i : z) cout << i.first.first << ' ' << i.first.second << ' ' << i.second.first << ' ' << i.second.second << '\n';
}


Measured memory_bytes: 5232
use std::io;

fn main() {
    let (n, m) = input_size();
    let mut v = input(n, m);

    for i in 0..n {
        for j in 0..m{
            print!("{} ", v[i][j]);
        }
        v[i][m] = v[i].iter().sum();
        println!("{}", v[i][m]);
    }
    for j in 0..m{
        let c: i32 = v.iter().map(|x| x[j]).sum();
        print!("{} ", c);
    }
    let c: i32 = v.iter().map(|x| x[m]).sum();
    println!("{}", c);
}

fn input_size() -> (usize, usize) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();

    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    (n, m)
}

fn input(n: usize, m: usize) -> Vec<Vec<i32>> {
    let mut mat: Vec<Vec<i32>> = vec![];
    for _ in 0..n {
        let mut s = String::new();
        io::stdin().read_line(&mut s).expect("");
        let mut iter = s.trim().split_whitespace();

        let mut v = vec![];
        for _ in 0..m {
            v.push(iter.next().unwrap().parse().unwrap());
        }
        v.push(0);
        mat.push(v);
    }
    mat
}


Measured memory_bytes: 5052
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()
    println(problem2020a(x))
}

fun problem2020a(x: Int): Int {
    return when {
        x in 400..599 -> 8
        x in 600..799 -> 7
        x in 800..999 -> 6
        x in 1000..1199 -> 5
        x in 1200..1399 -> 4
        x in 1400..1599 -> 3
        x in 1600..1799 -> 2
        else -> 1
    }
}

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

const int MOD = 1e9 + 7;
const int MAX_N = 1e6;

long long fac[MAX_N], finv[MAX_N], inv[MAX_N];

void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX_N; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


map<int, int> prime_factor(int n) {
    map<int, int> ret;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

int main() {
    int N, M; cin >> N >> M;
    COMBinit();
    ll ans = 1;
    for (auto p : prime_factor(M)) {
        ans = (ans * COMB(p.second + N - 1, p.second)) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
long long max_(long long a,long long b)
{
	if(b>a)
	return b;
	else
	return a;
}
int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long a1=a*c,a2=a*d,a3=b*c,a4=b*d;
	long long ans=max_(a1,max_(a2,max_(a3,a4)));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
N = int(input())
A = [int(i) for i in input().split()]
A.insert(0,0)
A.append(0)
S = 0
for i in range(1,N+2):
  S += abs(A[i] - A[i-1])
for i in range(1,N+1):
  tmp = [A[i-1],A[i],A[i+1]]
  tmp.sort()
  ans = 0
  if tmp[1] == A[i]:
    ans = S
  elif tmp[2] == A[i]:
    ans = S- (tmp[2]-tmp[1])*2
  else:
    ans = S - (tmp[1]-tmp[0])*2
  print(ans)

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 3000010;
int n, m, a, b, ans;
int fac[N], ifac[N];

inline int add(const int &x, const int &y) {
	return x + y < mod ? x + y : x + y - mod;
}
inline int sub(const int &x, const int &y) {
	return x - y < 0 ? x - y + mod : x - y;
}
inline int mul(const int &x, const int &y) { return (int)((ll)x * y % mod); }
inline int get(int x, int y) {
	return mul(fac[x + y - 2], mul(ifac[x - 1], ifac[y - 1]));
}
int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	fac[0] = fac[1] = ifac[0] = ifac[1] = 1;
	for(int i = 2; i <= n + m; i++) fac[i] = mul(fac[i - 1], i);
	for(int i = 2; i <= n + m; i++)
		ifac[i] = mul(mod - mod / i, ifac[mod % i]);
	for(int i = 2; i <= n + m; i++) ifac[i] = mul(ifac[i - 1], ifac[i]);
	ans = get(n, m);
	for(int i = 1, ss; i <= b; i++) {
		ss = mul(get(n - a, i), get(a, m - i + 1));
		ans = sub(ans, ss);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<set>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()

const int N = 255;
int order[N];
bool isleft[N];
void op(string &in,int &p,int cur,bool left,int maxlevel);

void exp(string &in,int &p,int cur,bool left,int maxlevel){
  int tmp=p;
  if (cur == 0){
    op(in,p,cur,left,maxlevel);
  }else {
    exp(in,p,cur-1,left,maxlevel);
  }
  while(p < in.size()){
    if (order[in[p]] != -1 && order[in[p]] == cur){
      p++;
      exp(in,p,cur,left,maxlevel);
      if (isleft[cur]== left){
	in.insert(in.begin()+tmp,'(');
	in.insert(in.begin()+p+1,')');
	p+=2;
      }
    }else {
      break;
    }
  }
}

void op(string &in,int &p,int cur,bool left,int maxlevel){
  if (in[p] == '('){
    p++;
    exp(in,p,maxlevel,left,maxlevel);
    p++;
  }else if (isalpha(in[p])){
    p++;
  }
}

void reverse(string &in){
  reverse(ALL(in));
  rep(i,in.size())
    if (in[i] == '(')in[i]=')';
    else if (in[i] == ')')in[i]='(';
}

void erase_bl(string &in){
  int n=in.size();
  int isneed[n];
  rep(i,in.size())isneed[i]=false;

  rep(i,in.size()){
    if (order[in[i]] != -1){
      int l=i-1,r=i+1;
      int cnt=0;
      while(l>=0){
	if (in[l]=='('){
	  cnt--;
	  if (cnt == -1 && !isneed[l]){
	    isneed[l]=i;
	    break;
	  }
	}else if (in[l] == ')')cnt++;
	l--;
      }
      cnt=0;//assert(cnt = 0)
      while(r<in.size()){
	if (in[r] == ')'){
	  cnt--;
	  if (cnt == -1 && !isneed[r]){
	    isneed[r]=i;
	    break;
	  }
	}else if (in[r] == '(')cnt++;
	r++;
      }
    }
  }


  //rep(i,in.size())cout << in[i]<<"  ";
  //rep(i,in.size())cout << isneed[i]<<" ";cout << endl;

  /*
  rep(i,in.size()){
    cout << i <<" " << in[i] <<" " << isneed[i] << endl;
  }
  */

  rep(i,in.size())
      if ((in[i]=='('||in[i]==')') &&isneed[i] == 0)
        in[i]=' ';

  in.erase(remove(in.begin(),in.end(),' '),in.end());
  //cout << "answer  "<<in << endl;
}

void solve(string &in,int level){
  int p=0;
  reverse(in);
  exp(in,p,level-1,true,level-1);

  //cout <<"mid "<< endl;
  p=0;
  reverse(in);
  //cout << "tar " << in << endl;
  exp(in,p,level-1,false,level-1);

  erase_bl(in);

  cout << in << endl;
}

main(){
  int te;
  cin>>te;
  while(te--){
    rep(i,N)order[i]=-1;
    int m;
    cin>>m;
    rep(i,m){
      char lr;
      cin>>lr;
      if (lr == 'L'){
	isleft[m-i-1]=true;
      }else if (lr == 'R'){
	isleft[m-i-1]=false;
      }
      int num;
      cin>>num;
      rep(j,num){
	char tmp;
	cin>>tmp;
	order[tmp]=m-i-1;
      }
    }

    int q;
    cin>>q;
    rep(i,q){
      string in;
      cin>>in;
      solve(in,m);
    }
    if (te)cout << endl;
  }
  return false;
}

Measured memory_bytes: 928
#include<cstdio>
using namespace std;
int n;
long long a,b,c,d,i,min,max;
int main()
{
	scanf("%d",&n);
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	//add how many times?
	for (i=0;i<=n-1;i++)
	{
		//add i          ic~id
		//subtract (n-1-i) times   -(n-1-i)d~-(n-1-i)c
		max=i*d-(n-1-i)*c;
		min=i*c-(n-1-i)*d;
		if (a+max>=b&&a+min<=b)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

Measured memory_bytes: 128
<?php
[$N] = ints();
$size = 1000;
for($a = -$size; $a <= $size; $a++){
    for($b = -$size; $b <= $size; $b++){
        if($a**5-$b**5 == $N){
            echo "$a $b\n";
            exit;
        }
    }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int x,y; scanf("%d%d",&x,&y);
   ll res=INF;
   rep(f,0,2)rep(g,0,2){
      ll a=x,b=y,sub=0;
      if(f)a*=-1,sub++; if(g)b*=-1,sub++;
      if(a<=b)sub+=b-a,chmin(res,sub);
   } printf("%lld\n",res);
   return 0;
}

Measured memory_bytes: 256
n = int(input())
a = input().split()

b = [0]*n

if (n%2) == 0:
    for i in range(n):
        if(i<(n//2)):
            b[i] = a[n-(2*i)-1]
        else:
            b[i] = a[(i-(n//2))*2]
else:
    for i in range(n):
        if(i<(n//2)):
            b[i] = a[n-(2*i)-1]
        elif i == (n//2):
            b[i]= a[0]
        else:
            b[i] = a[(i-(n//2)-1)*2+1]


print(" ".join([i for i in b]))



Measured memory_bytes: 27204
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,s,d;
	cin>>a>>s>>d;
	if(a*d<=s){
		cout<<d<<endl;
	}else{
		cout<<s/a<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=0;
int st[200];
int pop(void);
void push(int);

int pop(){
  top--;
  return st[top+1];
}
void push(int x){
  st[++top]=x;
}

int main(){
  int a,b;
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }else if(s[0]=='+'){
      a=pop();
      b=pop();
      push(b+a);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2704
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
    int n,a,b;
    ll ans;
    scanf("%d%d%d",&n,&a,&b);
    if(a>b) puts("0");
    else if(a==b) puts("1");
    else if(n==1) puts("0");
    else{
        n-=2;
        ans = (ll)b*n - (ll)a*n + 1;
        printf("%lld\n",ans);
    }
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
const int inf=0x3f3f3f3f;
const long long inf2=0x3f3f3f3f3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
int x[111],y[111],h[111];
int main(){
	int n,m;
	cin>>n>>m;
	for(register int i=m/n;i>=0;--i){
		if(m%i==0){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


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

const long long int DIV = 1000000000 + 7;

int main(){
    int N;
    cin>>N;
    long long int ans=1;
    for(int i=1;i<=N;++i){
        ans = (ans*i)%DIV;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#define f cin
#define NMAX 200010
using namespace std;

// ifstream f("date.in");

long long int n, a[NMAX][4];
long long int dp[NMAX][4];

int main() {

    f >> n;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            f >> a[i][j];
        }
    }

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            int next1 = (j + 1) % 3;
            int next2 = (j + 2) % 3;
            dp[i][j] = a[i][j] + max(dp[i - 1][next1], dp[i - 1][next2]);
        }
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));


    return 0;
}


Measured memory_bytes: 8448
def solve():
    N = int(input())
    XLs = [list(map(int, input().split())) for _ in range(N)]
    XLs.sort(key = lambda x:(x[0],-1*x[1]))
    interval = (XLs[0][0]-XLs[0][1],XLs[0][0]+XLs[0][1])
    ret = 0
    for XL in XLs[1:]:
        interval_ = (XL[0]-XL[1], XL[0]+XL[1])
        if interval_[0] < interval[1]:
            interval = (max(interval[0], interval_[0]),min(interval[1], interval_[1]))
            ret += 1
        else:
            interval = interval_
            
    print(N-ret)
    
solve()

Measured memory_bytes: 38144
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	LL a, b;
	cin >> a >> b;

	int negative=0, positive=0, zero=0;
	for(int i=a; i<=b; i++){
		if(i < 0){
			negative++;
		}
		else if(i == 0){
			zero++;
		}
		else{
			break;
		}
	}

	if(zero > 0){
		printf("Zero\n");
	}
	else if((negative % 2) == 1){
		printf("Negative\n");
	}
	else{
		printf("Positive\n");
	}
	return 0;
}

Measured memory_bytes: 3620
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    S = input()
    T = input()

    dict1 = {}
    dict2 = {}
    for s, t in zip(S, T):
        if dict1.get(t) is not None and dict1[t] != s:
            print("No")
            exit()

        if dict2.get(s) is not None and dict2[s] != t:
            print("No")
            exit()

        dict1[t] = s
        dict2[s] = t

    print("Yes")


if __name__ == '__main__':
    resolve()

Measured memory_bytes: 41932
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int cnt = 0;
    while(a >= b){
        b *= 2;
        cnt++;
    }
    while(b >= c){
        c *= 2;
        cnt++;
    }
    if(cnt <= k)cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main(){
  int n;
  cin>>n;
  long long W,w[110],v[110];
  cin>>W;
  long long dp[110][100200]={0};
  
  rep(i,n)cin>>w[i]>>v[i];
  for(int j=0;j<=W;j++){  
    for(int i=0;i<=n;i++){
  dp[i+1][j]=dp[i][j];
  if(j>=w[i])dp[i+1][j]=max((dp[i][j-w[i]]+v[i]),(dp[i+1][j]));
    }
  }
  cout<<dp[n+1][W]<<endl;
  
  }

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



int main()
{	
	ios::sync_with_stdio(false);
	cin.tie(0);
    
	short int A, B, C;
	cin>>A>>B>>C;
	
	short int  five = 0;
	short int  seven = 0;
	
	if (A == 5)
	{
		five++;
	}
	if (A == 7)
	{
		seven++;
	}
	
	if (B == 5)
	{
		five++;
	}
	if (B == 7)
	{
		seven++;
	}
	
	if (C == 5)
	{
		five++;
	}
	if (C == 7)
	{
		seven++;
	}
	
	
	if (five == 2 && seven == 1)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
	

    return 0;
}

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

void Main() {
    // input
     int N;
     cin >> N;
     int now_t = 0, now_x = 0, now_y = 0;
     int next_t, next_x, next_y;

    
     for(int i = 0; i < N; i++) {
         cin >> next_t >> next_x >> next_y;
         int diff_t = next_t - now_t;
         int diff_x = next_x - now_x;
         int diff_y = next_y - now_y;

        diff_t -= abs(diff_x) + abs(diff_y);
        if (diff_t < 0 || diff_t % 2 == 1) {
            cout << "No" << endl;
            return;
        }

        now_t = next_t;
        now_x = next_x;
        now_y = next_y;
     }

    cout << "Yes" << endl;

    // translate


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n;
    cin>>n;
    vector<string> w(n);
    rep(i,n){
        cin>>w.at(i);
    }
    bool sameword=true;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            if(w.at(i)==w.at(j)){
                sameword=false;
                break;
            }
        }
        if(!sameword){
            break;
        }
    }
    bool beginend=true;
    if(sameword){
        rep(i,n-1){
            if(w.at(i).back()!=w.at(i+1).front()){
                beginend=false;
                break;
            }
        }
    }
    if(sameword==true&&beginend==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=1000000+10,mo=1000000007;
int f[maxn*2],g[maxn*2];
int i,j,k,l,t,n,m,ans;
int main(){
	scanf("%d",&n);
	f[1]=1;
	fo(i,1,n){
		if (i>=3) (f[i]+=g[i-3])%=mo;
		(f[i]+=f[i-1])%=mo;
		g[i]=(g[i-1]+f[i])%mo;
	}
	fo(i,1,n-1) (ans+=(ll)f[i]*(n-1)%mo*(n-1)%mo)%=mo;
	fo(i,1,n-1) (ans+=(ll)f[i]*min(i+1,n-1)%mo)%=mo;
	(ans+=(ll)f[n]*n%mo)%=mo;
	(ans+=mo)%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 10368
import math
import sys
import numpy as np

def input():
    return sys.stdin.readline()[:-1]

N = int(input())
A = np.array(list(map(int, input().split())))

ans = [0] * (N+1)

for i, a in enumerate(A):
    ans[a] = i+1
ans.pop(0)


print(*ans)


Measured memory_bytes: 23372
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int uf[404040];
int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
void join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p == q) return;
	uf[p] += uf[q];
	uf[q] = p;
}

int N, K, L;

map<pair<int, int>, int> M;

int main()
{
	scanf("%d%d%d", &N, &K, &L);
	for (int i = 0; i < 2 * N; ++i) uf[i] = -1;
	for (int i = 0; i < K; ++i) {
		int p, q;
		scanf("%d%d", &p, &q); --p; --q;
		join(p * 2, q * 2);
	}
	for (int i = 0; i < L; ++i) {
		int p, q;
		scanf("%d%d", &p, &q); --p; --q;
		join(p * 2 + 1, q * 2 + 1);
	}
	for (int i = 0; i < N; ++i) M[{root(i * 2), root(i * 2 + 1)}]++;
	for (int i = 0; i < N; ++i) printf("%d%c", M[{root(i * 2), root(i * 2 + 1)}], (i == N - 1) ? '\n': ' ');

	return 0;
}


Measured memory_bytes: 13568
while True :
    n = int(input())
    if n == 0 :
        break
    
    posi = 0
    right = 0
    left = 0
    cnt = 0
    task = list(input().split())
    for i in range(n) :
        if task[i] == 'lu' :
            left = 1
        elif task[i] == 'ru' :
            right = 1
        elif task[i] == 'ld' :
            left = 0
        elif task[i] == 'rd' :
            right = 0
        if posi == 0 and right == 1 and left == 1 :
            cnt += 1
            posi = 1
        elif posi == 1 and right == 0 and left == 0 :
            cnt += 1
            posi = 0
    print(cnt)


Measured memory_bytes: 5616
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n, m, s, c;
    cin >> n >> m;
    int str[n];
    bool flag = true;
    rep(i, n) str[i] = -1;
    rep(i, m){
        cin >> s >> c;
        if(str[s-1] != -1 && str[s-1] != c){
            flag = false;
            break;
        }
        str[s-1] = c;
    }
    if(n > 1 && str[0] == 0) flag = false;
    rep(i, n){
        if(str[i] == -1){
            if(i == 0 && n > 1) str[i] = 1;
            else str[i] = 0;
        }
    }
    if(flag){
        rep(i, n) cout << str[i];
        cout << endl;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256