akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    long long n, sum = 0, ac_max = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n-1; i++){
        sum += a[i];
        if(sum * 2 < a[i+1]) ac_max = i+1;
    }
    cout << n - ac_max << endl;
    return 0;
}

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

int main()
{
    int line[5] = {};
    int k;

    for (int i = 0; i < 5; i++)
    {
        cin >> line[i];
    }
    cin >> k;

    if ((line[4] - line[0]) > k)
    {
        printf(":(\n");
    }
    else
        printf("Yay!\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
int N;
cin>>N;
bool flag=false;
fx(N){
	char s;
	cin>>s;
	if(s=='Y'){
		flag=true;
	}
}

if(flag){
	ce("Four")
}else{
	ce("Three")
}

}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N, A[101], B[101];


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for(int i=0; i<N-1; i++)
    {
        cin >> B[i];
    }

    for(int i=1; i<N-1; i++)
    {
        A[i] = min(B[i-1], B[i]);
    }
    A[0] = B[0];
    A[N-1] = B[N-2];
    int ans = 0;
    for(int i=0; i<N; i++)
    {
        ans += A[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9

static const int limit = 50;
bool G[limit + 1][limit + 1];
bool visited[limit + 1];

int N, M; 

bool dfs(int start) {
	for (int i = 1; i <= N; i++) visited[i] = false; // 初期化
	visited[start] = true;
	stack<int> S;
	S.push(start);

	while (!S.empty()) {
		int x = S.top(); S.pop();
		for (int i = 1; i <= N; i++) {
			if (G[x][i] == true && visited[i] != true) {
				S.push(i);
				visited[i] = true;
			}
		}
	}

	int ans = 1;
	for (int i = 1; i <= N; i++) ans *= visited[i];
	if (ans) return true;
	else return false;
}

int main() {
	cin >> N >> M;
	int a[M+1], b[M+1];

	/* いらない boolはfalseで初期化される
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			G[i][j] = false;
		}
	}
	*/

	for (int i = 1; i <= M; i++) {
		cin >> a[i] >> b[i];
		G[a[i]][b[i]] = true;
		G[b[i]][a[i]] = true;
	}

	int ans = 0;
	for (int i = 1; i <= M; i++) {
		G[a[i]][b[i]] = false;
		G[b[i]][a[i]] = false;
		if (!dfs(1)) {
			// cout << "(" << a[i] << " , " << b[i] << ")" << " ";
			ans++;
		}
		
		G[a[i]][b[i]] = true;
		G[b[i]][a[i]] = true;
	}
	cout << ans << endl;

	return 0;
}

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

scanf("%d%d%d",&a,&b,&c);
 if(c!=a&c!=b){
 printf("%d",c);
 }
  if(b!=a&b!=c){
  printf("%d",b);
 }
  if(a!=b&a!=c){
   printf("%d",a);
 }


 return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a <= 8 && b <= 8)
    {
        outline("Yay!");
        return 0;
    }
    outline(":(")
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long C=sc.nextLong();
		if(A+B+1>=C) {
			pl(B+C);
		}
		else {
			long e=B+A+B+1;
			pl(e);
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}



Measured memory_bytes: 22612
#!/usr/bin/env python3
h, w = map(int, input().split())
if h == 1 and w == 1:
    answer = 1
elif h == 1:
    answer = w - 2
elif w == 1:
    answer = h - 2
else:
    answer = (h - 2) * (w - 2)
print(answer)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+5;
const int mod=1e9+7;
int a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin>>n>>k;
	ll ans1=n%k;
	ll ans2=abs(ans1-k);
	cout<<min(ans1,ans2)<<'\n';





}




Measured memory_bytes: 256
import math
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=(x[i][k]-x[j][k])**2
    if math.sqrt(tmp).is_integer():
      ans+=1
print(ans)

Measured memory_bytes: 3064
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // */

    lli N,i,j;
    cin>>N;
    
    lli K;
    cin>>K;
    
    vlli V(N);
    rep(i,0,N)
    {
        cin>>V[i];
    }
    
    lli GCD=0;
    rep(i,0,N)
    {
        cin>>V[i];
        GCD=__gcd(GCD,V[i]);
    }
    
    lli Max=*max_element(V.begin(),V.end());
    if(Max<K)
    {
        cout<<"IMPOSSIBLE";
        exit(0);
    }
    
    rep(i,0,N)
    {
        if(abs(V[i]-K)%GCD==0)
        {
            cout<<"POSSIBLE";
            exit(0);
        }
    }
    
    cout<<"IMPOSSIBLE";
    
    

 return 0;
}

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

int main()
{
	int a1,a2,a3,b1,b2,b3;
	int x[4][4];
	
	for(int i=1; i<=3; i++)
	{
		for(int j=1; j<=3; j++)
		{
			cin>>x[i][j];
		}
	}
	
	a1=0;
	b1=x[1][1]-a1;
	b2=x[1][2]-a1;
	b3=x[1][3]-a1;
	
	a2=x[2][1]-b1;
	a3=x[3][1]-b1;
	
	if(a2+b2==x[2][2] && a2+b3==x[2][3] && a3+b2==x[3][2] && a3+b3==x[3][3])
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import math


def main():
    import sys
    input = sys.stdin.readline
    from fractions import gcd

    X = int(input())

    for x in range(X, 10**6):
        if prime_judge(x):
            print(x)
            exit()


def prime_judge(n):
    for i in range(2, int(math.sqrt(n)+1)):
        if n % i == 0:
            return False
    return True


if __name__ == "__main__":
    main()


Measured memory_bytes: 5176
## debug用


n, k = map(int,input().split())
s = input()

def count(s):
    count = 0
    s = 'R' + s +'L'
    for i in range(1, n+1):
        if s[i] == 'R':
            if s[i+1] == 'R':
                count += 1
        else:
            if s[i-1] == 'L':
                count += 1
    return count

# 変換後の文字
if s[0] == 'R':
    c_l = 'R'
else:
    c_l = 'L'

# 連続のリストを作る

s_list = []
counter = 1
for i in range(n):
    
    s_check = s + 'E'
    if s_check[i] == s_check[i+1]:
        counter += 1
    else:
        s_list.append(s[i]*counter)
        counter = 1

# 
        
if k <= len(s_list)//2:
    for i in range(1,k+1):
        num = len(s_list[i*2-1])        
        s_list[i*2-1] = c_l*num
    
    s_ans = ''.join(s_list)
    ans = count(s_ans)

else:
    ans = n-1
             
print(ans)



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


int main() {
  int A, B;
  cin >> A >> B;
  
  if (A >= 13) {
    cout << B;
  }
  else if (A <= 5) {
    cout << 0;
  }
  else {
    cout << B/2;
  }
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define m 1000000007
int main()
{
	ll n,x;
	cin>>n;
	ll dp[n][3],a[n][3];
for(ll i=0;i<n;i++)
cin>>a[i][0]>>a[i][1]>>a[i][2];
dp[0][0]=a[0][0];
dp[0][1]=a[0][1];
dp[0][2]=a[0][2];
for(ll i=1;i<n;i++)
    {
	for(ll j=0;j<3;j++){
     ll r=-10;
     if(j!=0)
     r=max(r,dp[i-1][0]);
     //cout<<r<<endl;
     if(j!=1)
     r=max(r,dp[i-1][1]);
     //cout<<r<<endl;
     if(j!=2)
     r=max(r,dp[i-1][2]);
     //cout<<r<<endl;
     r+=a[i][j];
     dp[i][j]=r;
    }
}
n--;
cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
return 0;
}


Measured memory_bytes: 8172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;


//円環の問題は0を開いてしまい、2周分とかの数直線にすると楽
int main(){
    int n, k;
    cin >> k >> n;
    vector<int> a(n);
    ll sum=0;
    rep(i,n){
        cin >> a.at(i);
        sum += a.at(i);
    }
    sort(all(a));

    int ans=0;
    int nouse=0;
    for(int i=0; i<n-1;i++){
        nouse = max(nouse,a[i+1]-a[i]);
    }
    nouse = max(nouse,k-a[n-1]+a[0]);
    
    ans = k - nouse;
    cout << ans << endl;

   

}

Measured memory_bytes: 4048
#include <iostream>
#include <queue>
#include <cstring>

using namespace std;
struct PointPair {
        int step;
        int tx, ty, kx, ky;
};

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

bool passed[50][50][50][50];
bool field[50][50];

int main(){
        while(true){
                memset(passed, 0, sizeof(passed));
                memset(field, 0, sizeof(field));
                int X, Y, tx, ty, kx, ky;
                cin >> X >> Y;
                if(X == 0 || Y == 0){ break; }
                cin >> tx >> ty >> kx >> ky;
                for(int i = 0; i < Y; ++i){
                        for(int j = 0; j < X; ++j){
                                int f;
                                cin >> f;
                                field[i][j] = (f != 0);
                        }
                }
                --tx; --ty; --kx; --ky;
                PointPair init = { 0, tx, ty, kx, ky };
                queue<PointPair> q;
                q.push(init);
                passed[tx][ty][kx][ky] = true;
                int answer = -1;
                while(!q.empty()){
                        PointPair p = q.front();
                        if(p.step >= 100){ break; }
                        if(p.tx == p.kx && p.ty == p.ky){
                                answer = p.step;
                                break;
                        }
                        q.pop();
                        for(int i = 0; i < 4; ++i){
                                PointPair next;
                                next.step = p.step + 1;
                                next.tx = p.tx + dx[i];
                                next.ty = p.ty + dy[i];
                                if(
                                        field[next.ty][next.tx] ||
                                        next.tx < 0 || next.tx >= X ||
                                        next.ty < 0 || next.ty >= Y
                                ){
                                        next.tx = p.tx;
                                        next.ty = p.ty;
                                }
                                next.kx = p.kx - dx[i];
                                next.ky = p.ky - dy[i];
                                if(
                                        field[next.ky][next.kx] ||
                                        next.kx < 0 || next.kx >= X ||
                                        next.ky < 0 || next.ky >= Y
                                ){
                                        next.kx = p.kx;
                                        next.ky = p.ky;
                                }
                                if(!passed[next.tx][next.ty][next.kx][next.ky]){
                                        passed[next.tx][next.ty][next.kx][next.ky] = true;
                                        q.push(next);
                                }
                        }
                }
                if(answer < 0){
                        cout << "NA" << endl;
                }else{
                        cout << answer << endl;
                }
        }
        return 0;
}

Measured memory_bytes: 7216
def solve_dp(p):
    i = 0
    while i < N:
        if p == 0:
            dp[0] = 0
        elif p == 1:
            dp[1] = abs(h[1] - h[0])
        elif p >= 2 and p <= N - 1:
            if abs(h[p] - h[p-1]) + dp[p-1] > abs(h[p] - h[p-2]) + dp[p-2]:
                dp[p] = abs(h[p] - h[p-2]) + dp[p-2]
            else:
                dp[p] = abs(h[p] - h[p-1]) + dp[p-1]
        else:
            return

        p += 1
        i += 1

N = int(input())
h = [int(x) for x in input().split()]

dp = [0] * N
solve_dp(0)

print(dp[N-1])


Measured memory_bytes: 13928
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#include <limits>
using namespace std;
using ll = long long int;
#define inf numeric_limits<ll>::max()

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long C, std::vector<std::vector<long long>> D, std::vector<std::vector<long long>> c){
  ll ans = inf;
  vector<ll> x(C, 0);
  vector<ll> y(C, 0);
  vector<ll> z(C, 0);

  for(ll i=0; i<C; i++) {
    for(ll j=0; j<N; j++) {
      for(ll k=0; k<N; k++) {
	if((j+k+2) % 3 == 0) {
	  x[i] += D[c[j][k]-1][i];
	} else if((j+k+2) % 3 == 1) {
	  y[i] += D[c[j][k]-1][i];
	} else {
	  z[i] += D[c[j][k]-1][i];
	}
      }
    }
  }

  //std::cout << "!!!" << std::endl;
  
  for(ll i=0; i<C; i++) {
    for(ll j=i+1; j<C; j++) {
      for(ll k=j+1; k<C; k++) {
	vector<ll> col = {i, j, k};
	do {
	  ans = min(ans, x[col[0]]+y[col[1]]+z[col[2]]);
	} while(next_permutation(col.begin(), col.end()));
      }
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long C;
  scanf("%lld",&C);
  std::vector<std::vector<long long>> D(C, std::vector<long long>(C));
  for(int i = 0 ; i < C ; i++){
    for(int j = 0 ; j < C ; j++){
      scanf("%lld",&D[i][j]);
    }
  }
  std::vector<std::vector<long long>> c(N, std::vector<long long>(N));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      scanf("%lld",&c[i][j]);
    }
  }
  solve(N, C, std::move(D), std::move(c));
  return 0;
}



Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[][] arr=new int[s[1]][];
		int[] h=new int[s[0]+1];
		for(int i=0;i<s[1];i++){
			arr[i]=Array.ConvertAll((Console.ReadLine()+" "+i.ToString()).Split(),int.Parse);
		}
		Array.Sort(arr,(u,v)=>u[1]-v[1]);
		for(int i=0;i<s[1];i++){
			h[arr[i][0]]++;
			arr[i][1]=h[arr[i][0]];
		}
		Array.Sort(arr,(u,v)=>u[2]-v[2]);
		for(int i=0;i<s[1];i++){
			Console.WriteLine("{2}{0}{3}{1}",arr[i][0],arr[i][1],new string('0',6-arr[i][0].ToString().Length),new string('0',6-arr[i][1].ToString().Length));
		}
	}
}

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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll a[n];
    bool pos = true;
    ll mini=1e9,ma=-1e9;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mini = min(mini,a[i]);
        ma = max(ma,a[i]);
        if(i && a[i] < a[i-1])pos=false;
    }
    if(pos){
        cout << 0 << endl;
        return 0;
    }
    vector<array<int,2>> v;
    if(abs(ma) > abs(mini)){
        int p = 0;
        for(int i=0;i<n;i++){
            if(ma == a[i])p=i;
        }
        for(int i=0;i<n;i++){
            // if(i==p)continue;
            v.push_back({p,i});
        }
        for(int i=0;i<n-1;i++){
            v.push_back({i,i+1});
        }
    }
    else{
        int p = 0;
        for(int i=0;i<n;i++){
            if(mini == a[i]) p=i;
        }
        for(int i=0;i<n;i++){
            // if(i==p)continue;
            v.push_back({p,i});
        }
        for(int i=n-1;i>=1;i--){
            v.push_back({i,i-1});
        }
    }
    cout << v.size() << endl;
    for(auto i:v){
        cout << i[0]+1 << " " << i[1]+1 << "\n";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;

int main()
{
  int n, d;
  cin >> n >> d;
  int k = (d << 1) + 1;
  if(n % k == 0)  cout << n / k << endl;
  else            cout << n / k + 1 << endl;
  return 0;
}

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

const ll mod = 1e9 + 7;
int a[25][25];
int N;
ll DP[1 << 21][22];
bool vis[1 << 21][22];

ll solve(int state , int pos){
    if(pos == 0){
        return state == 0;
    }
    if(vis[state][pos]){
        return DP[state][pos];
    }
    ll& ret = DP[state][pos];
    vis[state][pos] = 1;
    for(int j = 1; j <= N; ++j){
        if((state & (1 << (j - 1))) && a[pos][j]){
            ret += solve(state ^ (1 << (j - 1)) , pos - 1);
            ret %= mod;
        }
    }
    return DP[state][pos];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= N; ++j){
            cin >> a[i][j];
        }
    }
    cout << solve((1 << N) - 1 , N) << endl;
}


Measured memory_bytes: 405888
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#define MAXN 100005
#define LL long long
#define pb push_back
#define X first
#define Y second
using namespace std;
int n,m;
int s,w;
LL mod;
int a[MAXN];
map<LL,int> mp;
void getai()
{
    int g=s;
    for(int i=0;i<n;i++)
    {
        a[i]=(g/7)%10;
        if(g%2==0)g=g/2;
        else g=(g/2)^w;
    }
}
int main()
{
    int i;
    while(scanf("%d%d%d%lld",&n,&s,&w,&mod)!=EOF)
    {
        if(n==0&&s==0&&w==0&&mod==0)break;
        getai();
        LL ans=0;
        if(mod==2||mod==5)
        {
            int cnt=0;
            for(i=0;i<n;i++)
            {
                if(a[i]!=0)cnt++;
                if(a[i]==0||a[i]%mod==0)ans+=cnt;
            }
            printf("%lld\n",ans);
        }
        else
        {
            mp.clear();
            LL k=1,sum=0;
            for(i=n-1;i>=0;i--)
            {
                sum=(k*a[i]%mod+sum)%mod;
                int tmp=mp[sum]++;
                if(a[i]!=0)ans+=tmp;
                if(a[i]!=0&&sum==0)ans+=1;
                k=k*10%mod;
            }
            printf("%lld\n",ans);
        }
    }
    return 0;
}

Measured memory_bytes: 7116
n = int(input())

for i in range(1, n + 1):
	x = i

	if x % 3 == 0:
		print("", i, end = "")
		continue

	while True:
		if x % 10 == 3:
			print("", i, end = "")
			break

		x //= 10

		if x != 0:
			continue

		break
print()


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

int main()
{
    int N;
    cin >> N;
    int an, ans;
    an = N/1000;
    ans = N%1000;
    if (ans == 0)
    {
        cout << 0;
    }
    else
    {
        cout << (an+1)*1000-N;
    }
    

}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;

	int n = 0, m = 0;

	if (a == "A")n = 10;
	else if (a == "B")n = 11;
	else if (a == "C")n = 12;
	else if (a == "D")n = 13;
	else if (a == "E")n = 14;
	else if (a == "F")n = 15;

	if (b == "A")m = 10;
	else if (b == "B")m = 11;
	else if (b == "C")m = 12;
	else if (b == "D")m = 13;
	else if (b == "E")m = 14;
	else if (b == "F")m = 15;

	if (n > m) {
		cout << '>' << endl;
	}
	else if (n < m) {
		cout << '<' << endl;
	}
	else {
		cout << '=' << endl;
	}
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N = int(readline())
P = tuple(map(int,readline().split()))
Q = tuple(map(int,readline().split()))

import itertools
a = 0
b = 0
cnt = 0
for perm in itertools.permutations(range(1, N + 1)):
  cnt += 1
  if perm == P:
    a = cnt
  if perm == Q:
    b = cnt
    
print(abs(a - b))    

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORR(x, arr) for(auto& x:arr)
#define ITR(x, c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int x = 1;
	FOR(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0) x *= 2;
	}
	cout << pow(3, n)-x << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a[5];
  rep(i,5){
    cin>>a[i];
    if(a[i]==0){
      cout<<i+1<<endl;
    }
  }
  
  

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int c=0;
 int main()
 {
 	int n;
 	cin>>n;
 	int a[n],b[n],ans=0;
 	for(int i=0;i<n;i++)
 	{
 		cin>>a[i];
 	}
 	for(int i=0;i<n;i++)
 	{
 		b[i]=INT_MAX;
 	}
 	if(n==1)
    {
      cout<<0<<endl;
      return 0;
    }
 	b[0]=0;
 	b[1]=abs(a[1]-a[0]);
 	for(int i=2;i<n;i++)
 	{
 		b[i]=min((b[i-1]+abs(a[i-1]-a[i])),(b[i-2]+abs(a[i-2]-a[i])));
 	}
 	cout<<b[n-1]<<endl;
   return 0;
 }


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

int main() {
  int n, tmp, fn;
  std::string yes = "Yes\n";
  std::string no = "No\n";
  
  std::cin >> n;
  tmp = n;
  fn = 0;
  
  while (tmp > 0) {
    fn += tmp % 10;
    tmp = tmp / 10;
  }

  if (n % fn == 0) {
    std::cout << yes;
  } else {
    std::cout << no;
  }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n, k;
  cin >> n >> k;

  double ans = 0;

  rep(i, n) {
    if (i+1 >= k) ans += 1;
    else {
//      cerr << 1/pow(2, ceil(log2((double)k/(i+1)))) << endl;
      ans += 1/pow(2, ceil(log2((double)k/(i+1))));
    }
  }

  printf("%1.12lf\n", ans/n);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

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

    ll res = 1;
    bool zero = false;
    bool overflow = false;
    rep(i, 0, N)
    {
        ll now;
        cin >> now;
        if (now == 0) zero = true;

        // cout << ((double) now > (double)1000000000000000000L / res) << endl;
        if (res < 0 or (double) now > (double)1000000000000000000L / res)
            overflow = true;
        res *= now;
        if (res > 1000000000000000000L)
            overflow= true;
    }

    if (zero)
        cout << 0 << endl;
    else if (overflow)
        cout << -1 << endl;
    else
        cout << res << endl;

    return 0;
}


Measured memory_bytes: 3620
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
m = map(int, read().split())
G = [[] for _ in range(N + 1)]
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)

comp = [0] * (N + 1)
comp_size = [0] * (N + 1)
is_bipartite = [1] * (N + 1)
color = [0] * (N + 1)

for r in range(1, N + 1):
    if comp[r]:
        continue
    comp[r] = r
    comp_size[r] = 1
    stack = [r]
    while stack:
        v = stack.pop()
        for w in G[v]:
            if comp[w]:
                if color[v] == color[w]:
                    is_bipartite[r] = 0
                continue
            comp[w] = r
            comp_size[r] += 1
            color[w] = 1 ^ color[v]
            stack.append(w)

a, b, c = 0, 0, 0  # point,odd,even
for r in range(1, N + 1):
    if r != comp[r]:
        continue
    if comp_size[r] == 1:
        a += 1
    elif is_bipartite[r]:
        c += 1
    else:
        b += 1

x = 2 * a * N - a * a + b * b + 2 * b * c + 2 * c * c
print(x)

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




int a[100000];
int b[100000];
int c[100000];

int main(void){
    int n;
    int i;
    unsigned long long answer = 0;
    int ai, ci;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%d", &b[i]);
    }
    for (i = 0; i < n; i++){
        scanf("%d", &c[i]);
    }

    sort(a, a+n);
    sort(c, c+n);

    
    for (i = 0; i < n; i++){
        ai = lower_bound(a, a+n, b[i]) - a;
        ci = upper_bound(c, c+n, b[i]) - c;
        answer += (unsigned long long)(ai)*(n-ci);
        
    }

    printf("%lld\n", answer);
    return 0;
}


Measured memory_bytes: 1408
import numpy as np
n, d = map(int, input().split())
mat = np.zeros((n, d), "int64")
for index in range(n):
    pos = list(map(int, input().split()))
    for val_index in range(len(pos)):
        mat[index, val_index] = pos[val_index]

count = 0
for i_index in range(n-1):
    i_pos = mat[i_index]
    for j_index in range(i_index+1, n):
        j_pos = mat[j_index]
        sa = j_pos - i_pos
        sa_jijou = sa * sa
        dist_square = np.sum(sa_jijou)
        m = int(dist_square ** 0.5)
        if abs(m * m - dist_square) < 1e-6:
            count += 1
print(count)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W;
    cin >> H >> W;
    if(H % 3 == 0 || W % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = numeric_limits<ll>::max();
    rep2(i, 1, H) {
        ll a = i * W;
        ll h = H - i;
        ll b1 = h / 2 * W;
        ll c1 = (h - h / 2) * W;
        ll b2 = (W / 2) * h;
        ll c2 = (W - W / 2) * h;
        ans = min({ans, max({a, b1, c1}) - min({a, b1, c1}), max({a, b2, c2}) - min({a, b2, c2})});
    }
    swap(H, W);
    rep2(i, 1, H) {
        ll a = i * W;
        ll h = H - i;
        ll b1 = h / 2 * W;
        ll c1 = (h - h / 2) * W;
        ll b2 = (W / 2) * h;
        ll c2 = (W - W / 2) * h;
        ans = min({ans, max({a, b1, c1}) - min({a, b1, c1}), max({a, b2, c2}) - min({a, b2, c2})});
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int test(int n) {
    vector<int> as(n);
    iota(as.begin(), as.end(), 1);
    int ret = 0;
    do {
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp += i % as[i];
        }
        ret = max(ret, tmp);
    } while (next_permutation(as.begin(), as.end()));
    return ret;
}

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

//    int n;
//    cin >> n;

//    for (int i = 0; i < 10; i++) {
//        cout << i << ": " << test(i) << endl;
//    }

    int n;
    cin >> n;
    cout << 1ll * n * (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
// GRID-1 number of ways if certain cells are blocked
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int H,W; cin>>H>>W;
	vector<vector<int> > dp( H , vector<int> (W, 0));
	for(int i=0;i<H;i++)
	{
		for(int j=0;j<W;j++)
		{	
			char c; cin>>c;
			if(c=='#') dp[i][j]=-1; //blocked
			
		}
	}
	if(dp[0][0]==-1){cout<<"0";}
	
	for(int i=0;i<W;i++) 
	{
		if(dp[0][i]==-1) break;
		dp[0][i]=1;
	}
	
	for(int i=0;i<H;i++) 
	{
		if(dp[i][0]==-1) break;
		dp[i][0]=1;
	}
	for(int i=1;i<H;i++)
	{
		for(int j=1;j<W;j++)
		{
			if(dp[i][j]==-1){dp[i][j]=0;continue; } 
			if(dp[i][j-1]!=-1) dp[i][j]=dp[i][j-1]%1000000007;
			if(dp[i-1][j]!=-1) dp[i][j]=(dp[i][j]+dp[i-1][j])%1000000007;
		}
	}
	
	
	cout<<(dp[H-1][W-1]);
}

Measured memory_bytes: 4224
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}
ll dp[100010][2];

int main(void){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    
    
    
    
    dp[2][0] = gcd(A.at(0), A.at(1));
    dp[2][1] = max(A.at(0), A.at(1));
    for(int i = 3; i <= N; i++){
        dp[i][0] = gcd(dp[i-1][0], A.at(i-1));
        dp[i][1] = max(dp[i-1][0],  gcd(dp[i-1][1], A.at(i-1)));
    }
    
    
    ll ans = max(dp[N][0], dp[N][1]);
    
    dp[2][0] = gcd(A.at(0), A.at(1));
    dp[2][1] = min(A.at(0), A.at(1));
    for(int i = 3; i <= N; i++){
        dp[i][0] = gcd(dp[i-1][0], A.at(i-1));
        dp[i][1] = max(dp[i-1][0],  gcd(dp[i-1][1], A.at(i-1)));
    }
    
    ll ans2 = max(dp[N][0], dp[N][1]);
    ans = max(ans, ans2);
    cout << ans << endl;
    
}

Measured memory_bytes: 2560
#include <set>
#include <string>
#include <iostream>
using namespace std;
int H, W, vis[22][22][22][22], dp[22][22][22][22]; string s[22];
int rec(int x1, int y1, int x2, int y2) {
	if (x1 == x2 || y1 == y2) return 0;
	if (vis[x1][y1][x2][y2]) return dp[x1][y1][x2][y2];
	set<int> s_;
	for (int i = y1; i < y2; i++) {
		for (int j = x1; j < x2; j++) {
			if (s[i][j] == 'X') continue;
			int res1 = rec(x1, y1, j, i);
			int res2 = rec(x1, i + 1, j, y2);
			int res3 = rec(j + 1, y1, x2, i);
			int res4 = rec(j + 1, i + 1, x2, y2);
			int res5 = res1 ^ res2 ^ res3 ^ res4;
			s_.insert(res5);
		}
	}
	vis[x1][y1][x2][y2] = true;
	int ret = 0;
	while (s_.count(ret)) ret++;
	return dp[x1][y1][x2][y2] = ret;
}
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> s[i];
	int ret = rec(0, 0, W, H);
	if (ret > 0) cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

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

void print_vec(vector<int> vec) {
    for(auto x: vec) cout << x << endl;
}

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

int main() {
    int A,B,K; cin >> A >> B >> K;
    vector<int> div;
    int g = gcd(A,B);
    for(int i = 1; i * i <= g; i++) {
        if(g%i == 0) {
            div.push_back(i);
            if(i != g/i)
                div.push_back(g/i);
        }
    }
    sort(div.begin(),div.end());
    reverse(div.begin(),div.end());
    //print_vec(div);
    cout << div.at(K-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin >> a >> b;
	a = a+b;
	if(a & 1) cout << "IMPOSSIBLE\n";
	else cout << a/2 << '\n';
	return 0;
} 

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

using namespace std;

typedef long long ll;

int n, k;

set<int> d;

void input() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for(int i = 0, tmp; i < k; ++i){
		cin >> tmp;
		d.insert(tmp);
	}
}

bool check(int to_c){
	while(to_c > 0){
		if(d.find(to_c % 10) != d.end()){
			return false;
		}
		to_c /= 10;
	}
	return true;
}

void solve() {
	for(int i = n; ; ++i){
		if(check(i)){
			cout << i;
			break;
		}
	}
}

int main() {
	input();
	solve();

	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
multiset<int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>x, M.insert(x);
	
	int ret=0;
	while(M.size()) {
		x=*M.rbegin();
		M.erase(M.find(x));
		
		for(int i=32;i>=0;i--) {
			ll v=(1LL<<i)-x;
			if(M.count(v)) {
				ret++;
				M.erase(M.find(v));
				break;
			}
		}
		
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
    int A, N;
    cin >> N >> A;

    if (N <= A) {
        cout << "Yes" << endl;
    } else {
        int c = N % 500;
        if (c <= A) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
	int k, s;
	cin >> k >> s;
	int ans=0;
	//if (k*3>s) {cout << 0;return 0; }
	for (int i=0; i<=k; i++) {
		for (int j=0; j<=k; j++) {
			if (s-i-j>=0 and s-i-j<=k) ans++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
   

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

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >>N;
    int ans = 0;
    int i = 1;
    while(N>=ans){
         ans = i *i;
         i++;
    }
    i = i-2;
    ans = i *i;
    cout << ans << endl;

    return 0;
}

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

int main() {
    int a, b, c; cin >>a >>b >>c;
    string ret = "NO";
    for (int i = 0; i < b; i++) {
        if ( (a*i) % b == c ) {ret = "YES"; break;}
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

x1, y1, x2, y2 = map(int, readline().split())
dx, dy = x2 - x1, y2 - y1

x3, y3 = x1 + dx - dy, y1 + dy + dx
x4, y4 = x1 - dy, y1 + dx

print(x3, y3, x4, y4)


Measured memory_bytes: 3064
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

void solve();

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

void solve(){
    ll A,B,C,K;cin>>A>>B>>C>>K;

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

ll modpow(ll x, ll n, ll k){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % k;
        mul = mul * mul % k;
        n /= 2;
    }
    return res;
}


int main(){
    ll k;
    cin >> k;
    ll now = 0;
    rep(i, 2000010){
        now += 7 * modpow(10, i, k);
        now %= k;
        if (now%k == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

using namespace std;

int main(){
  string S, T, tmp;
  bool flag = false;
  
  cin >> S >> T;
  
  for (int i=0; i < S.size(); i++){
    S = S.back() + S.substr(0, S.size() - 1);
    if (S == T){
      flag = true;
      break;
    }
  }
  
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    operation, target = map(int, input().split())
    count = [0] * (10 ** 5 + 1)
    for _ in range(operation):
        a, b = map(int, input().split())
        count[a] += b
    for i in range(1, 10 ** 5 + 2):
        if target <= count[i]:
            print(i)
            break
        else:
            target -= count[i]


if __name__ == '__main__':
    main()



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

int main() {
  int h,w,k;
  cin>>h>>w>>k;
  vector<vector<int>> s(h, vector<int>(w));
  rep(i, h) {
    rep(j, w) {
      char c;
      cin>>c;
      if (c=='#') s[i][j]=k--;
    }
  }
  for (int i=0;i<h;i++) {
    bool frag=true;
    int tmp=-1;
    for (int j=0;j<w;j++) {
      if (frag&&s[i][j]!=0) {
        frag=false;
        tmp=s[i][j];
      }
      else if (!frag&&s[i][j]==0) s[i][j]=tmp;
      else if (!frag&&s[i][j]!=0) tmp=s[i][j];
    }
  }
  for (int i=0;i<h;i++) {
    bool frag=true;
    int tmp=-1;
    for (int j=w-1;j>=0;j--) {
      if (frag&&s[i][j]!=0) {
        frag=false;
        tmp=s[i][j];
      }
      else if (!frag&&s[i][j]==0) s[i][j]=tmp;
      else if (!frag&&s[i][j]!=0) tmp=s[i][j];
    }
  }
  for (int i=1;i<h;i++) {
    bool tmp=true;
    for (int j=0;j<w;j++) {
      if (s[i][j]!=0) tmp=false;
    }
    if (tmp) {
      rep(j, w) s[i][j]=s[i-1][j];
    }
  }
  for (int i=h-2;i>=0;i--) {
    bool tmp=true;
    for (int j=0;j<w;j++) {
      if (s[i][j]!=0) tmp=false;
    }
    if (tmp) {
      rep(j, w) s[i][j]=s[i+1][j];
    }
  }
  rep(i,h) {
    rep(j,w) {
      if (j) cout<<" ";
      cout<<s[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

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

int main(){
int n;
cin>>n;
int a[n+1];
rep(i,n){
  cin>>a[i+1];}
int lite=1,count=0;
while(lite!=2){
  count++;
lite=a[lite];
if(count>100007){
  cout<<-1<<endl;
  return 0;
}
}

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


Measured memory_bytes: 768
n = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(j+1, n):
      if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
        m = max(L[i], L[j], L[k])
        if m == L[i] and L[i] < L[j] + L[k]:
          ans += 1
        elif m == L[j] and L[j] < L[i] + L[k]:
          ans += 1
        elif m == L[k] and L[k] < L[j] + L[i]:
          ans += 1
print(ans)

Measured memory_bytes: 9152