akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

string s, t;

int main(){
    ios::sync_with_stdio(0);
	
	cin >> s >> t;
    
    string temp;
    for (int i = 0; i < s.size(); i++){
    	temp = s.substr(i, s.size()) + s.substr(0, i);
    	if(temp == t){
    		cout << "Yes"; return 0;
		}
	}
	cout << "No";
    
    return 0;
}





Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
signed main(){
	int a, b, c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust"<<endl;
	else
		cout<<"win"<<endl;


	return 0;
}

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

int main() {
	int a[3][3];
	int n, b[10];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++)
			cin >> a[i][j];
	}
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++)
				if (a[i][j] == b[k])
					a[i][j] = 0;
		}
	}
	if (a[0][0] == 0 && a[0][1] == 0 && a[0][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[1][0] == 0 && a[1][1] == 0 && a[1][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[2][0] == 0 && a[2][1] == 0 && a[2][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][0] == 0 && a[1][0] == 0 && a[2][0] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][1] == 0 && a[1][1] == 0 && a[2][1] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][2] == 0 && a[1][2] == 0 && a[2][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1, 0);
  for(int i = 0; i < n; ++i)
  {
    cin >> a[i];
  }

  for(int i = 0; i < k; ++i)
  {
    vector<int> next_a(n + 1, 0);
    for(int j = 0; j < n; ++j)
    {
      next_a[ max(0, j - a[j]) ]++;
      next_a[ min(n, j + a[j] + 1) ]--;
    }
    int max_cd_num = 0;
    for(int j = 0; j < n; ++j)
    {
      next_a[j + 1] += next_a[j];
      max_cd_num += (next_a[j] == n);
    }
    a = next_a;
    if (max_cd_num >= n) break;
  }

  for(int i = 0; i < n; ++i) cout << a[i] << " ";


}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main(){
const int MAX_N=500;
long long int n,m,l,a[MAX_N][MAX_N],b[MAX_N][MAX_N],Ans[MAX_N][MAX_N];
memset(Ans,0,sizeof(Ans));
cin>>n>>m>>l;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=m;i++){
for(int j=1;j<=l;j++){
cin>>b[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=l;j++){
for(int k=1;k<=m;k++){
Ans[i][j] += a[i][k]*b[k][j];
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=l;j++){
if(l==j){
cout<<Ans[i][j]<<endl;
}
else{
cout<<Ans[i][j]<<' ';
}
}
}
return 0;
}

Measured memory_bytes: 6984
#include <bits/stdc++.h>
#define lol long long
using namespace std;
int a[100010];
int b[100010];
signed main(){
  int A,B,M,x,y,c,ans=0,mina=100010,minb=100010;
  cin>>A>>B>>M;
  for(int i=1;i<=A;i++){
    cin>>a[i];
    if(a[i]<mina) mina=a[i];
  }
  for(int i=1;i<=B;i++){
    cin>>b[i];
    if(b[i]<minb) minb=b[i];
  }
  ans=mina+minb;
  for(int i=0;i<M;i++){
    cin>>x>>y>>c;
    if(ans>a[x]+b[y]-c) ans=a[x]+b[y]-c;
  }
  cout<<ans<<"\n";
  return(0);
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<iterator>
#include<string>
#include<queue>
#include<algorithm>
#include<string.h>
#include<map>
using namespace std;
#define MP make_pair
#define F first
#define S second
#define LL long long
#define INF	int(1e9)
typedef pair<LL, LL> P;
typedef pair<P, P> PP;
int n, a[100000], rep[100000], cnt, pre, ans = 0;
vector<int> vec;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	pre = a[0];
	a[0] = 1;
	cnt = 1;
	for (int i = 1; i < n; i++)
	{
		if (a[i] == pre)
		{
			if (a[i] != cnt)
				a[i] = cnt;
		}
		else {
			pre = a[i];
			cnt++;
			if (a[i] != cnt)
				a[i] = cnt;
		}
	}

	for (int i = 0; i < n; i++)
	{
		rep[a[i]]++;
	}
	for (int i = 1; i < 100000; i++)
	{
		if (rep[i] / 3)
		{
			while (rep[i] -= 2) 
			{
				if (rep[i] - 2 <= 0)
				{
					break;
				}
			}
		}
		if (!rep[i])
			break;
	}
	for (int i = 1; i < 100000; i++)
	{
		if (rep[i] == 2) {
			vec.push_back(i);
		}
		if (!rep[i])
			break;
		else
			ans += rep[i];
	}

	ans -= vec.size();
	if (vec.size() % 2)
		ans--;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
static const int DIAGONAL = 1;
static const int LEFT = 2;
static const int TOP = 3;

int main(){

  string s;
  string t;

  cin >> s >> t;

  int s_len = s.length();
  int t_len = t.length();
  int dp[s_len + 1][t_len + 1][2];
  for (int i = 0; i < s_len + 1; i++) {
    for (int j = 0; j < t_len + 1; j++) {
      dp[i][j][0] = 0;
      dp[i][j][1] = 0;
    }
  }

  for (int i = 1; i < s_len + 1; i++) {
    for (int j = 1; j < t_len + 1; j++) {
      if (s[i-1] == t[j-1]){
        dp[i][j][0] = dp[i - 1][j - 1][0] + 1;
        dp[i][j][1] = DIAGONAL;
      } else if((dp[i - 1][j][0] == 0) && (dp[i][j-1][0] == 0)){
        dp[i][j][0] = 0;
        continue;
      } else if (dp[i - 1][j][0] >= dp[i][j - 1][0]){
        dp[i][j][0] = dp[i - 1][j][0];
        dp[i][j][1] = LEFT;
      } else {
        dp[i][j][0] = dp[i][j - 1][0];
        dp[i][j][1] = TOP;
      }
    }
  }

  //最長共通文字列の再構成
  int i = s_len;
  int j = t_len;
  string y = "";
  while (i > 0 && j > 0) {
    if (dp[i][j][1] == DIAGONAL){
      y+= s[i-1];
      i--;
      j--;
    } else if (dp[i][j][1] == LEFT){
      i--;
    } else if (dp[i][j][1] == TOP){
      j--;
    } else {
      break;
    }
  }

  string x = "";
  for (int i = y.length()-1; i >= 0; i--) {
    x += y[i];
  }
  cout << x << endl;
}

Measured memory_bytes: 70656
#include <iostream>

using namespace std;

int n;

int s(int x)
{
	int ret = 0;
	for(;x;x/=10) ret += x%10;
	return ret;
}

int main(void)
{
	cin >> n;
	if(n % s(n) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[5][5];
bool U[5][5];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3) {
        REP(j, 3) {
            cin >> A[i][j];
        }
    }
    memset(U, 0, sizeof(U));
    ll N;
    cin >> N;
    REP(i, N) {
        ll n;
        cin >> n;
        REP(a, 3) {
            REP(b, 3) {
                if (A[a][b] == n)
                    U[a][b] = true;
            }
        }
    }

    bool e = (U[0][0] & U[1][1] & U[2][2]) || (U[2][0] & U[1][1] & U[0][2]);
    REP(i, 3) {
        e |= U[i][0] & U[i][1] & U[i][2];
        e |= U[0][i] & U[1][i] & U[2][i];
    }
    if (e)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                       
                                                                                                                          
using namespace std;                                                                                                      
                                                                                                                          
int main() {                                                                                                              
  int a, b, c, d, n, count;                                                                                               
                                                                                                                          
  while (cin >> n) {                                                                                                      
    count = 0;                                                                                                            
    for (a = 0; a < 10; a++) {                                                                                            
      for (b = 0; b < 10; b++) {                                                                                          
        for (c = 0; c < 10; c++) {                                                                                        
          for (d = 0; d < 10; d++) {                                                                                      
            if (a + b + c + d == n) {                                                                                     
              count += 1;                                                                                                 
            }                                                                                                             
          }                                                                                                               
        }                                                                                                                 
      }                                                                                                                   
    }                                                                                                                     
    cout << count << endl;                                                                                                
  }                                                                                                                       
} 

Measured memory_bytes: 0
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
s = STR()
i = 0
ans = 0
while i < n - 2:
    if s[i:i + 3] == 'ABC':
        ans += 1
        i += 3
    else:
        i += 1
print(ans)

Measured memory_bytes: 59500
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int recur(int st,int w,vector<vector<int>>&dp,vector<vector<int>>&val){
    if(st<0) return 0;
    int &ret=dp[st][w];
    if(ret!=-1) return ret;
    ret=recur(st-1,w,dp,val);
    if(w>=val[st][0]) ret=max(ret,val[st][1]+recur(st-1,w-val[st][0],dp,val));
    return ret;
}

signed main(){
    int i,n,k,j,w; scanf("%lld%lld",&n,&w);
    vector<vector<int>> val(n,vector<int>(2)),dp(n,vector<int>(w+1,-1));
    for(i=0;i<n;++i) 
        for(j=0;j<2;++j)
            scanf("%lld",&val[i][j]);
    cout<<recur(n-1,w,dp,val)<<endl;
    return 0;
}

Measured memory_bytes: 82220
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = MAP()
friend = [LIST() for i in range(M)]
block = [LIST() for i in range(K)]

tree = UnionFind(N)

straight_friend = defaultdict(list)
straight_block = defaultdict(list)

for a, b in friend:
    tree.union(a-1, b-1)
    straight_friend[a-1].append(b-1)
    straight_friend[b-1].append(a-1)

for c, d in block:
    straight_block[c-1].append(d-1)
    straight_block[d-1].append(c-1)

for i in range(N):
    # print(tree.members(i))
    # print(straight_block[i])
    # print(straight_friend[i])
    exclude = 0
    for b in straight_block[i]:
        if tree.same(i, b):
            exclude += 1
    ans = tree.size(i)- exclude - len(straight_friend[i]) - 1
    # print(ans)
    # ans = ans - len(straight_friend[i]) - 1
    print(ans, end=" ")

print()
    

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

int main()
{
	string s;
	cin >> s;
	int n = stoi(s);
	int sn = 0;
	for( int i=0; i < s.length(); i++ ) {
		sn += s[i]-'0';
	}
	if( (n % sn)==0 ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
  int q, h, s, d; cin >> d >> s >> h >> q;
  int n; cin >> n;
  int mincost = h;
  mincost = min(mincost, 2 * s);
  mincost = min(mincost, 4 * d);
  mincost = min(mincost, s + 2 * d);

  long long res = 0;
  if (n % 2 != 0)
  res += mincost;

  res += min((long long)n / 2 * q, (long long)(n - n % 2) * mincost);

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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 MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int dw[8] = { 0,1,1,1,0,-1,-1,-1 };
int dh[8] = { 1,1,0,-1,-1,-1,0,1 };
void bfs(int sh, int sw, vector<vector<int>>& a) {
	queue<pair<int, int>> q;
	a[sh][sw] = 0;
	int H = a.size();
	int W = a[0].size();
	q.emplace(sh, sw);
	while (!q.empty()) {
		int h, w; tie(h, w) = q.front();
		q.pop();
		for (int i = 0; i < 8; i++) {
			int nh = h + dh[i];
			int nw = w + dw[i];
			if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
			if (a[nh][nw] == 0) continue;
			a[nh][nw] = 0;
			q.emplace(nh, nw);
		}
	}
}

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

	while (1) {
		int W, H; scanf("%d %d", &W, &H);
		if (W == 0 && H == 0) break;
		int res = 0;
		vector<vector<int>> a(H, vector<int>(W)); for (ll i = 0; i < H; i++) for (ll j = 0; j < W; j++) scanf("%d", &a[i][j]);
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (a[i][j]) {
					res++;
					bfs(i, j, a);
				}
			}
		}
		printf("%d\n", res);
	}
	return 0;
}



Measured memory_bytes: 3284
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

H, W = list(map(int, sys.stdin.readline().split()))
S = np.array([sys.stdin.readline().rstrip().split() for _ in range(H)])
[h], [w] = np.where(S == 'snuke')

print(string.ascii_uppercase[w] + str(h + 1))


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

using namespace std;
typedef pair<int, int> P;

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

  for(int i = 0; i < s.length(); i++){
    if(i > s.length() - i - 1)  break;
    if(s[i] != s[s.length()-i-1]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Endl endl
typedef long long ll;
const int MAXN = (int)1e5 + 5;
const int MOD = 2019;
ll l, r, ans;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> l >> r)
	{
		if (r - l < 2019)
		{
			ll mi = INT_MAX;
			for (ll i = l; i < r; ++i)
				for (ll j = l + 1; j <= r; ++j)
					mi = min(mi, (i*j) % MOD);
			cout << mi << endl;
		}
		else
			cout << 0 << endl;
	}
}
/*
2020 2040
4 5
*/

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

// コンテスト中のみ
#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

/* compress
	(X1,Y1),(X2,Y2)という二点で表されるもの（長方形や直線など）について、行か列の片方（X1とX2 or Y1とY2）を座標圧縮する（副作用）
	返り値: ソートされ重複要素を除いた値
	計算量: O(n log n)
*/
template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2) {
	vector<T> vals;
	int N = (int)C1.size();
	for (int i = 0; i < N; i++) {
		for (T d = 0; d <= 1; d++) {  // for (T d = 0; d <= 0; d++) でも良い
			T tc1 = C1[i] + d;
			T tc2 = C2[i] + d;
			vals.push_back(tc1);
			vals.push_back(tc2);
		}
	}
	// ソート
	sort(vals.begin(), vals.end());
	// 隣り合う重複を削除(unique), 末端のゴミを削除(erase)
	vals.erase(unique(vals.begin(), vals.end()), vals.end());
	for (int i = 0; i < N; i++) {
		C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
		C2[i] = lower_bound(vals.begin(), vals.end(), C2[i]) - vals.begin();
	}
	return vals;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int r, c; cin >> r >> c;
	int n; cin >> n;
	vector<int> a(r), b(c);
	vector<int> x(n), y(n);
	rep(i, n) {
		cin >> x[i] >> y[i]; x[i]--; y[i]--;
		a[x[i]]++; b[y[i]]++;
	}
	vector<int> tmpa(r), tmpb(c);
	rep(i, r) {
		tmpa[i] = a[i];
	}
	rep(i, c) {
		tmpb[i] = b[i];
	}
	
	sort(a.begin(), a.end()); sort(b.begin(), b.end());
	
	int L = -1, R = 1000010;
	while (R - L > 1) {
		int mid = (L + R) / 2;
		int now = 0;
		rep(i, r) {
			now += c - (lower_bound(b.begin(), b.end(), mid - a[i]) - b.begin());
		}
		rep(i, n) {
			if (tmpa[x[i]] + tmpb[y[i]] == mid)now--;
		}
		
		if (now > 0)L = mid;
		else R = mid;
	}
	cout << L << endl;
	
	return 0;
}

Measured memory_bytes: 17196
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
  b.append(b[-1]+a[i])
c = []
for i in range(n-k+1):
  c.append(b[i+k]-b[i])
#print(b)
#print(c)
print((max(c)+k)/2)

Measured memory_bytes: 25060
# coding: utf-8

S = [0,0,0,0,0]
S[0] = int(input())
S[1] = int(input())
S[2] = int(input())
S[3] = int(input())
S[4] = int(input())

K = int(input())
ans = 'Yay!'

if K < (S[4] - S[0]):
    ans = ':('

print(ans)

Measured memory_bytes: 38384
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long int
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

using namespace std;

void solve()
{
   ll n;
   cin >> n;
   map<int,int>mp;
   ll sum = 0;
   for(int i=0;i<n;i++)
   {
      ll x;
      cin >> x;
      mp[x]++;
      sum += x;
   }

   int q;
   cin >> q;
   for(int i=0;i<q;i++)
   {
      int a , b;
      cin >> a >> b;
      mp[b] += mp[a];
      sum +=(mp[a]*(b-a));
      mp[a] = 0;
      cout << sum << endl;
   }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();

}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}
    

Measured memory_bytes: 3596
import sys
import bisect
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    UV = [[int(x) for x in input().split()] for _ in range(N - 1)]

    T = [[] for j in range(N + 1)]

    for u, v in UV:
        T[u].append(v)
        T[v].append(u)

    s = collections.deque()

    lis = []
    s.append([1, lis])

    ans = [0] * (N + 1)
    memo = [[] for j in range(N + 1)]

    while s:
        c = s[-1]
        ci = c[0]

        # lis処理
        if ans[ci] == 0:
            if len(lis) == 0:
                lis.append(A[ci - 1])
                memo[ci].append(-1)
            else:
                if lis[-1] < A[ci - 1]:
                    lis.append(A[ci - 1])
                    memo[ci].append(-1)
                else:
                    i = bisect.bisect_left(lis, A[ci - 1])
                    memo[ci].append(i)
                    memo[ci].append(lis[i])
                    lis[i] = A[ci - 1]

            ans[ci] = len(lis)

        if len(T[ci]) >= 1:
            n = T[ci].pop()
            if ans[n] != 0:
                continue
            s.append([n, lis])
            continue

        if memo[ci][0] == -1:
            if len(lis) >= 1:
                lis.pop()
        else:
            lis[memo[ci][0]] = memo[ci][1]

        s.pop()

    for i in range(1, N + 1):
        print(ans[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 186124
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int r, c, n, a[10005], ans[N][N];
int main()
{
	int i, j, x, y;
//	freopen ("input.txt", "r", stdin);
	cin >> r >> c;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
	}
	x = 1;
	y = 1;
	for (i = 1; i <= n; i++) {
		for (j = 0; j < a[i]; j++) {
			ans[x][y] = i;
			if (x % 2 == 1) {
				y++;
				if (y > c) {
					x++;
					y = c;
				}
			} else {
				y--;
				if (y < 1) {
					x++;
					y = 1;
				}
			}
		}
	}
	for (i = 1; i <= r; i++) {
		for (j = 1; j <= c; j++) {
			printf("%d ", ans[i][j]);
		}
		printf("\n");
	}
    return 0;
}


Measured memory_bytes: 384
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n, W; cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  vector<vector<ll>> dp(2, vector<ll>(W+1, 0));
  rep(i, n) {
    dp[i+1&1].assign(W+1, 0);
    rep(j, W+1) {
      chmax(dp[i+1&1][j], dp[i&1][j]);
      ll nj = j + w[i];
      if (nj <= W) {
        chmax(dp[i+1&1][nj], dp[i&1][j]+v[i]);
      }
    }
  }
  ll ans = 0;
  rep(j, W+1) chmax(ans, dp[n&1][j]);
  cout << ans << endl;
}


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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N;
    std::cin >> N;

    vector<int> L(N);
    REP(i, N) {
        std::cin >> L[i];
    }

    SORT(L);

    if(L.back() < accumulate(L.begin(), L.begin() + L.size() - 1, 0)) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;

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 N,K;

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

  map<int, int> mp;
  priority_queue<int, vector<int>, greater<int>> pq;
  rep(i,N) {
    int a;
    cin >> a;
    mp[a]++;
  }

  if (mp.size() <= K) {
    cout << 0 << endl;
    return 0;
  }


  int sum = 0;
  int b = mp.size() - K;
  vector<int> v;
  for(auto iter = mp.begin(); iter != mp.end(); iter++){
    v.push_back(iter->second);
  }
  sort(v.begin(),v.end());
  int ans = 0;
  rep(i,b){
    ans += v[i];
  }
  cout << ans << endl;




	return 0;
}



Measured memory_bytes: 13604
/*** keep hungry and calm CoolGuang!***/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include<stdio.h>
#include<queue>
#include<algorithm>
#include<string.h>
#include<iostream>
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pp;
const ll INF=1e16;
const int maxn=2e6+6;
const int mod=1000000007;
const double eps=1e-3;
inline bool read(ll &num)
{char in;bool IsN=false;
in=getchar();if(in==EOF) return false;while(in!='-'&&(in<'0'||in>'9')) in=getchar();if(in=='-'){ IsN=true;num=0;}else num=in-'0';while(in=getchar(),in>='0'&&in<='9'){num*=10,num+=in-'0';}if(IsN) num=-num;return true;}
ll n,m,p;
struct dsu{int pre[maxn];void inint(){for(int i=1;i<=n;i++) pre[i]=i;}int Find(int x){return x==pre[x]?x:pre[x]=Find(pre[x]);}void Merge(int x,int y){int dx=Find(x),dy=Find(y);if(dx!=dy) pre[dx]=dy;}};
ll num[maxn];
/***
题意:问0-n中有多少个二进制相邻位是1的总数,比如7=111 7的贡献就是2,问0-n的总贡献.
分析:首先我们可以知道需要保留前一位是否为1,随后我们需要增加一维保留当前 相邻位有多少了,比如0 1 1 1和1 1 1 1,因为0 1 1 1已经将dp[2][1]保留为11,但是1 1 1 1搜到2应该2,但他直接return 1,所以会出错.所以我们在加一维保留 贡献已经贡献了多少即可:
***/
ll dp[1005][15][2][2];
ll a[1005];
ll dfs(int pos,int pre,bool lead,bool staus,bool limit)
{
    ll sum=0;
    if(!pos){
        if(staus) return 1;
        return 0;
    }
    if(!limit&&dp[pos][pre][staus][lead]!=-1) return dp[pos][pre][staus][lead];
    int up=(limit?a[pos]:9);
    for(int i=0;i<=up;i++){
        if(lead) sum+=dfs(pos-1,i,i==0,i==0?false:true,limit&&i==up);
        else sum+=dfs(pos-1,i,lead,abs(i-pre)<=1&&staus,limit&&i==up);
    }
    if(!limit) dp[pos][pre][staus][lead]=sum;
    return sum;
}
ll solve(ll x)
{
    ll cnt=0;
    while(x)
    {
        a[++cnt]=x%10;
        x/=10;
    }
    return dfs(cnt,0,1,0,1);
}
int main()
{
    memset(dp,-1,sizeof(dp));
    ll ans=-1;
    //debug(solve(23));
    read(n);
    ll l=1,r=INF;
    while(l<=r){
        ll mid=(l+r)/2;
        if(solve(mid)>=n){
            r=mid-1;
            ans=mid;
        }
        else l=mid+1;
    }
    printf("%lld\n",ans);
    //printf("%d\n",cnt);
    return 0;
}
/***
6
0 0 0 0 0 0
0 2 3 1
0 3 4 1
0 1 5 1
1 0 1 0
1 0 2 0
1 0 4 0
***/


Measured memory_bytes: 768
#include<stdio.h>
int main() 
{
	int A,B,C;
	scanf("%d%d%d",&A,&B,&C);
	if(A==5&&B==5&&C==7||A==5&&B==7&&C==5||A==7&&B==5&&C==5)
	printf("YES");
	else
	printf("NO");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int main(){
    int n,m,A[200001];
    cin>>n;
    rep(i,n) cin>>A[i];
    sort(A,A+n);
    vector<P> ans;
    rep(i,n-2){
        if(A[i+1]>=0) ans.push_back(P(A[0],A[i+1])),A[0]-=A[i+1];
        else ans.push_back(P(A[n-1],A[i+1])),A[n-1]-=A[i+1];
    }
    ans.push_back(P(A[n-1],A[0]));
    m=A[n-1]-A[0];
    cout<<m<<endl;
    rep(i,n-1) cout<<ans[i].first<<" "<<ans[i].second<<endl;
}

Measured memory_bytes: 3188
/* ABC156_B
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>


int main(void){
    int n,base_num;
    double ans = 0;

    scanf("%d %d",&n,&base_num);
    
    ans = log(n)/log(base_num);
    printf("%d",(int)ans+1); /*型キャスト*/

    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        // 上下左右
        int[] dx = new int[]{1, 0, -1, 0};
        int[] dy = new int[]{0, 1, 0, -1};
        
        char[][] board = new char[h][w];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++) {
                board[i][j] = str.charAt(j);
            }
        }
        
        int max = 0;
        // スタート地点の全探索(BFS)
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (board[i][j] != '.') continue;
                
                // 毎回初期化
                boolean[][] visited = new boolean[h][w];
                
                // [x, y]型のキューを作成しスタート地点を挿入
                Queue<int[]> que = new ArrayDeque<int[]>();
                que.add(new int[]{i, j});
                
                visited[i][j] = true;
                
                // スタート地点からの各点までの最短距離を計算
                int[][] dist = new int[h][w];
                while (!que.isEmpty()) {
                    int[] cur = que.poll();
                    int x = cur[0];
                    int y = cur[1];
                    
                    // 移動可能なら現在地までの距離+1を代入
                    for (int k = 0; k < 4; k++) {
                        int nx = x + dx[k];
                        int ny = y + dy[k];
                        
                        if (0 <= nx && nx < h && 0 <= ny && ny < w &&
                            board[nx][ny] == '.' && !visited[nx][ny]) {
                            que.add(new int[]{nx, ny});
                            visited[nx][ny] = true;
                            
                            dist[nx][ny] = dist[x][y] + 1;
                        }
                    }
                }
                
                // スタート地点から最も遠い点との距離を更新する
                for (int[] di : dist) {
                    for (int d : di) {
                        max = Math.max(max, d);
                    }
                }
                
            }
        }
        
        System.out.println(max);
    }
}


Measured memory_bytes: 25204
a=[int(input()) for _ in range(5)]
ar=[[i,a[i]%10] for i in range(5)]
ar.sort(key=lambda x:x[1])
i=0
while ar[i][1]==0:
    i+=1
    if i==4:
        break
k=ar[i][0]
time=0
for i in range(5):
    if i!=k:
        time+=a[i]
        if a[i]%10!=0:
            time+=10-a[i]%10
time+=a[k]
print(time)


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

void random(int s) {
  int x;
  for(int i = 0; i < 10; ++i) {
	if(i == 0) {
	  x = (s * s / 100) % 10000;
	}
	else {
	  x = (x * x / 100) % 10000;
	}
	cout << x << endl;
  }
}
int main() {
  int n;
  int s[10];
  cin >> n;

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

  for(int i = 0; i < n; ++i) {
	cout << "Case " << i + 1 << ":" << endl;
	random(s[i]);
  }
}

Measured memory_bytes: 3108
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}

mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;

int n, W;
ll dp[100005];

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

    cin >> n >> W;

    for (int i = 1; i <= n; i++) {
        int w, v;
        cin >> w >> v;

        for (int j = W; j >= w; j--)
            umax(dp[j], dp[j - w] + v);
    }

    cout << *max_element(dp, dp + W + 1) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int i;
    int x;
    
    for(i=0;i<10000;i++)
    {
        scanf("%d",&x);
        
        if(x!=0)
        {
            printf("Case %d: %d\n",i+1,x);
        }
        else
        {
            return 0;;
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
	char s[5];
	scanf("%s", s);
	char c;
	int i;
	for (i = 0; i < 3; i++)
	{
		if (s[i] > s[i + 1])
		{
			c = s[i];
			s[i] = s[i + 1];
			s[i + 1] = c;
			if (i > 0)
				i -= 2;
		}
	}
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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

vector<vector<ll>> table;
vector<ll> A,B;
ll dp(ll n,ll k){
  if(k<=0) return 0;
  if(n<0) return INF;
  if(table.at(n).at(k)<INF) return table.at(n).at(k);
  
  table.at(n).at(k)--;
  chmin(table.at(n).at(k),dp(n-1,k));
  if(dp(n-1,k-1)+A.at(n)<=B.at(n)) chmin(table.at(n).at(k),dp(n-1,k-1)+A.at(n));
  
  return table.at(n).at(k);
}

int main()
{
  ll N; cin>>N;
  vector<pair<ll,ll>> vec(N); rep(i,N) cin>>vec.at(i).second>>vec.at(i).first;
  sort(vec.begin(),vec.end());
  
  A=vector<ll>(N),B=vector<ll>(N); rep(i,N) tie(B.at(i),A.at(i))=vec.at(i);
  
  table=vector<vector<ll>>(N,vector<ll>(N+1,INF));
  rep(i,N+1){
    if(dp(N-1,i)>1000000) {cout<<i-1<<endl; return 0;}
  }
  cout<<N<<endl;
  /*
  rep(i,N){
    rep(j,N+1){
      if(j!=0) cout<<" ";
      if(table.at(i).at(j)>1000000) cout<<"INF";
      else cout<<table.at(i).at(j);
    }
    cout<<endl;
  }
  */
  
  return 0;
}



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

n = int(input())

r = ''

def to_moji(x: int):
    if x == 0:
        x = 26
    return chr(96 + x)

def devide(x, moji):
    a = x // 26
    b = x % 26

    if b == 0:
        a -= 1

    if a < 1:
        moji = to_moji(b) + moji
        return moji
    elif 1 <= a and a <= 26:
        moji = to_moji(b) + moji
        moji = to_moji(a) + moji
        return moji
    else:
        moji = to_moji(b) + moji
        return devide(a, moji)

print(devide(n, r))


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


int main()
{
	int N = 0;
	cin >> N;
	vector<long long int> A(N + 1, 0);

	vector<int> pushX;
	vector<int> pushedY;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	int absmax = 1;
	for (int i = 1; i <= N; i++) {
		if (abs(A[absmax]) <= abs(A[i])) absmax = i;
	}

	if (A[absmax] > 0) {
		for (int i = 1; i <= N - 1; i++) {
			while (A[i] > A[i + 1]) {
				A[i + 1] += A[absmax];
				pushX.push_back(absmax);
				pushedY.push_back(i + 1);
			}
			if (A[absmax] < A[i + 1]) absmax = i + 1;
		}
	}
	else if(A[absmax] < 0) {
		for (int i = N; i > 1; i--) {
			while (A[i - 1] > A[i]) {
				A[i - 1] += A[absmax];
				pushX.push_back(absmax);
				pushedY.push_back(i - 1);
			}
			if (A[absmax] > A[i - 1]) absmax = i - 1;
		}
	}
	else {
		cout << 0 << endl;
		return 0;
	}

	cout << pushX.size() << endl;
	for (int i = 0; i < pushX.size(); i++) {
		cout << pushX[i] << " " << pushedY[i] << endl;
	}

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    ll a, b, x;
    cin >> a >> b >> x;
    if(a % x == 0){
        cout << b / x - a / x + 1 << endl;
    }
    else{
        cout << b / x - a / x << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 2000

int A[N];

int solve(int i,int m,int n){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  res = solve(i + 1,m,n) || solve(i+1,m-A[i],n);
  return res;
}

int main(){
  int i,n,q,m,S[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    S[i]=0;
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m,n)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}



Measured memory_bytes: 2108
length = int(input())
nums = []
def num_to_abc(n):
    return chr(ord("a") + n)

def f(level,already):
    if level >= length:
        nums.append(already)
        return
    else:
        for i in range(0, max(already) + 2):
            f(level + 1, already + [i])

f(1,[0])
for n in nums:
    print("".join(list(map(num_to_abc, n))))

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
long long n, i, rmin, rmax, bmin, bmax, a[200100], b[200100], ans;
vector <pair <long long, long long> > v;
int main()
{


    cin >> n;

    for(i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    rmin = INT_MAX; bmin = INT_MAX;
    rmax = 0; bmax = 0;
    for(i = 0; i < n; ++i)
    {
        if(a[i] > b[i])
            swap(a[i], b[i]);
        v.push_back(make_pair(a[i], b[i]));
        rmin = min(rmin, a[i]);
        rmax = max(rmax, a[i]);
        bmax = max(bmax, b[i]);
        bmin = min(bmin, b[i]);
    }
    ans = (rmax - rmin) * (bmax - bmin);
    sort(v.begin(), v.end());
    rmax = bmax;
    bmin = INT_MAX; bmax = 0;
    set <pair <long long, long long> > st;
    set <pair <long long, long long> > :: iterator i1, i2;
    for(i = 0; i < v.size(); ++i)
        st.insert(v[i]);
    bmin = v[0].first; bmax = v.back().first;
    ans = min(ans, (bmax - bmin) * (rmax - rmin));
    for(i = 0; i < v.size(); ++i)
    {
        st.erase(v[i]);
        st.insert(make_pair(v[i].second, v[i].first));
        i1 = st.begin(); i2 = st.end(); i2--;
        bmin = (i1 -> first); bmax = (i2 -> first);
        ans = min(ans, (rmax - rmin) * (bmax - bmin));
    }
    cout << ans;

return 0;
}


Measured memory_bytes: 19948
S = input()
T = input()

S_d = dict()
T_d = dict()
for i in range(len(S)):
    S_d.setdefault(S[i], T[i])
    if S_d[S[i]] != T[i]:
        print('No')
        exit(0)
    T_d.setdefault(T[i], S[i])
    if T_d[T[i]] != S[i]:
        print('No')
        exit(0)
print('Yes')


Measured memory_bytes: 9492
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n; cin >> n;
    vi p(n);
    for(auto& e : p) cin >> e, e--;

    vll a(n), b(n);
    rep(i, n){
        a[i] = (i + 1) * n * 2 + 5;
        b[i] = (i + 1) * n * 2 + 5;
    }
    sort(_all(b), greater<ll>());

    ll cur = a[p[0]] + b[p[0]];
    rep(j, 1, n){
        int i = p[j];
        cur++;
        ll diff = cur - (a[i] + b[i]);
        if(diff < 0){
            a[i] -= diff;
        }
        else {
            a[i] += diff;
        }
    }

    rep(i, n) cout << (i == 0 ? "":" ") << a[i]; cout << endl;
    rep(i, n) cout << (i == 0 ? "":" ") << b[i]; cout << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }

const int MAX_LEN = 50;
char O[MAX_LEN + 1];
char E[MAX_LEN + 1];

void _main() {
  cin >> O >> E;
  rep(i, 0, MAX_LEN) {
    cout << O[i];
    if (E[i] == '\0') break;
    else              cout << E[i];

    if (O[i+1] == '\0') break;
  }
  cout << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
        int k,n;
        scanf("%d %d",&k,&n);
        int a[k];
        for(int i=0; i<n; i++){
                scanf("%d",&a[i]);
        }
        int max=a[1]-a[0];
        for(int i=2; i<n; i++){
                max=fmax(max,a[i]-a[i-1]);
        }
        max=fmax(max,a[0]-a[n-1]+k);
        printf("%d\n",k-max);

        return 0;
}

Measured memory_bytes: 2816