akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <algorithm>
#define il inline
#define rgi register int
#define sp putchar(' ')
#define el putchar('\n')
using namespace std;
il int ri()
{
	register int o1=0;
	register bool o2=0;
	register char o3;
	while(!isdigit(o3=getchar()))
		o2|=o3=='-';
	while(isdigit(o3))
		o1=(o1<<1)+(o1<<3)+(o3^48),o3=getchar();
	return o2?-o1:o1;
}
il void wi(int o1)
{
	if(o1<0)
		putchar('-'),o1=-o1;
	rgi o2=o1/10;
	if(o2)
		wi(o2);
	putchar((o1-(o2<<1)-(o2<<3))^48);
}
const int maxn=1e5+5;
int n,ans[maxn];
struct node
{
	int id,w;
}a[maxn];
il bool cmp(node p,node q)
{
	return p.w<q.w;
}
signed main()
{
	n=ri();
	for(rgi i=1;i<=n;++i)
		a[i].w=ri(),a[i].id=i;
	sort(a+1,a+n+1,cmp);
	for(rgi i=1;i<=n;++i)
		wi(a[i].id),sp;
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template <typename T>
struct UnionFind {
  std::vector<T> par, rank, sz;
  UnionFind(T n) : par(n), rank(n, 0), sz(n, 1) {
    for (T i = 0; i < n; i++) par[i] = i;
  }
  void init(T n) {
    par.resize(n);
    rank.resize(n);
    sz.resize(n);
    for (T i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      sz[i] = 1;
    }
  }

  int root(T x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool is_same(T x, T y) { return root(x) == root(y); }

  int size(T x) { return sz[root(x)]; }

  bool unite(T x, T y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;

    if (rank[x] < rank[y]) std::swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    sz[x] += sz[y];
    return true;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind u(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    u.unite(a, b);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, u.size(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 5632
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;


int MOD=1000000007;

int main(void){
    long long N,ans=0;
    cin >> N;
    long long B[N+10];
    B[0]=0; B[N]=0;
    for(int i=1; i<=N-1; i++) cin >> B[i];
    for(int i=1; i<N-1; i++){
        ans+=min(B[i],B[i+1]);
    }
    ans+=B[1]; ans+=B[N-1];
    cout << ans << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int n;
    cin >> n;
    int ans[n+1];
    vector<pair<int,int>> seq(n);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        seq[i] = make_pair(a,i);
    }
    sort(seq.begin(),seq.end(),greater<>());
    int left = seq[n/2-1].first;
    int right = seq[n/2].first;
    for(int i = 0; i < n; i++){
        if(i < n / 2){
            ans[seq[i].second + 1] = right;
        }
        else{
            ans[seq[i].second + 1] = left;
        }   
    }
    for(int i = 1; i <= n; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4480
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>

#include <sstream>
#include <iostream>

using namespace std;
typedef long long llint;
const llint inf = 1000000000000000000LL;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

llint calc(llint a, llint b) {
  if (b == 0) return 0;
  if (a < b) return calc(b, a);

  llint d = a / b;
  llint r = a % b;

  if (r == 0) return (2 * d - 1) * b;

  return 2 * d * b + calc(b, r);
}

int main(void) 
{
  llint N, X;
  scanf("%lld%lld", &N, &X);
  printf("%lld\n", N + calc(X, N - X));

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long read(){
    long long ret=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-f;ch=getchar();}
    while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
    return ret*f;
}
int main(){
//	ios::sync_with_stdio(false);
    int a,b,c;
	a=read();b=read();c=read();
	a-=b;
	c-=a;
	if(c>=0)
	cout<<c<<endl; 
	else puts("0");
}


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

int main(){
  long long int N;
  std::cin >> N;
  
  std::map<long long int, long long int> D;
  
  long long int x {N};
  long long int y {2};
  while (y*y <= x){
    while (x % y == 0){
      D[y]++;
      x /= y;
    }
    y++;
  }
  if (x > 1) D[x]++;
  
  long long res {0};
  
  for (auto&& p : D){
    auto v {p.second};
    
    long long int i {1};
    long long int c {0};
    v--;
    while (v >= 0){
      c++;
      i++;
      v -= i;
    }
    res += c;
  }
  std::cout << res << std::endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long

int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    ll ans = 0;
    priority_queue<ll> PQ;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        PQ.push(A[i]);
    }
    for (int i = 0; i < M;i++)
    {
        ll pre = PQ.top();
        PQ.pop();
        pre = pre / 2;
        PQ.push(pre);
    }
    while(!PQ.empty()){
        ans += PQ.top();
        PQ.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define ps(s)     for(auto i:s){cout<<i<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll arr[n];for(int i=0;i<n;i++){cin>>arr[i];}
	for(int i=n-1;i>=1;i--){
		if(arr[i-1]>arr[i]){
			arr[i-1]-=1;
		}
		if(arr[i-1]>arr[i]){cout<<"No";return;}
	}
	cout<<"Yes";
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}

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

list<int> ans;
int n;
int x;

int main()
{
	scanf("%d" , &n);
	bool flag = 0;
	if(n & 1)
		flag = 0;
	else
		flag = 1;
	for(int i = 1 ; i <= n ; ++i)
	{
		scanf("%d" , &x);
		if(flag)
		{
			ans.push_back(x);
			flag = !flag;
			//printf("flag1:%d" , flag);
		}
		else
		{
			ans.push_front(x);
			flag = !flag;
			//printf("flag2:%d" , flag);
		}
	}

	for(auto t:ans)
	{
		printf("%d " , t);
	}
}



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

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

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

    // start
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ((abs(b - a) <= d && abs(c - b) <= d) || abs(c - a) <= d ? "Yes" : "No") << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from random import randrange
from itertools import accumulate
from bisect import bisect_left
import time
#%%code

def calc(LIST):
    ans=0
    last=[0]*26
    for i in range(len(LIST)):
        a=i+1 #day a0
        x=LIST[i]-1
        #increase
        ans+=S[i][x]
        #decrease
        last[x]=a#update
        temp=0
        for j in range(26):
            temp+=C[j]*(a-last[j])
        #print(ans,temp,"deb")
        ans-=temp
        #print(ans)

    return ans

def answerer(c):
    """
    #方針その１
    最初にですが乱択をします。ただし、Cの値に応じてあたりやすさをでかくします
    """
    acc=list(accumulate(c))
    ret=[]
    for d in range(D):
        temp=randrange(acc[-1]) 
        s=bisect_left(acc,temp)
        if s<0:s=0
        elif s>25:s=25
        ret.append(s+1)
        #print(s+1)
    return ret

def resolve():
    global D,C,S
    #input of prob.A
    D,=pin()
    C=[*pin()]#0-indexed
    S=[[*pin()]for i in range(D)]
    answerer(C)


    #print(acc)
    start=time.time()
    max_score=0-max(C)*365*26
    king=[1]*365
    while(time.time()-start<1.8):
        temp=answerer(C)
        challenge=calc(temp)
        if challenge>max_score:
            max_score=challenge
            king=temp[:]
    print(*king,sep="\n")

#%%submit!
resolve()


Measured memory_bytes: 86644
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;

ll N;
//約数の列挙O(√n)
vector<P> divisor(ll n){
    vector<P> res(0);
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back({n/i, i});
        }
    }
    return res;
}
void solve(){
    cin >> N;
    ll res = 0;
    vector<P> list = divisor(N);
    for(int i = 0; i < list.size(); i++){
        ll f = list.at(i).first, s = list.at(i).second;
        if(f-1 > s)res += f - 1;
    }
    cout << res << endl;
}


int main(void){
    solve();
}

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


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

W, H, x, y = MAP()

if x == W / 2 and y == H / 2:
    print(W * H / 2, 1)
    
else:
    print(W * H / 2, 0)
    


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

long long int N, a[364364], i;
vector<long long> b, c;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i)scanf("%lld", a + i);
    for(i = 0; i < N; ++i){
        if(i % 2){
            b.push_back(a[i]);
        }else{
            c.push_back(a[i]);
        }
    }
    if(N % 2){
        for(auto beg = c.rbegin(), edn = c.rend(); beg != edn; ++beg){
            cout << *beg << " ";
        }
        for(auto beg = b.begin(), edn = b.end(); beg != edn; ++beg){
            cout << *beg << " ";
        }
    }else{
        for(auto beg = b.rbegin(), edn = b.rend(); beg != edn; ++beg){
            cout << *beg << " ";
        }
        for(auto beg = c.begin(), edn = c.end(); beg != edn; ++beg){
            cout << *beg << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 5484
#include <iostream>

using namespace std;

int main ( void )
{
	const int dx[] = { 0, 1 }, dy[] = { 1, 0 };
	int a, b, m[16][16];

	while ( cin >> a >> b, a | b )
	{
		int n;
		cin >> n;

		for (int i = 0; i < b; ++i)
			for (int j = 0; j < a; ++j)
				m[i][j] = 0;

		m[0][0] = 1;

		for (int i = 0, x, y; i < n; ++i)
		{
			cin >> x >> y;
			m[y-1][x-1] = -1;
		}

		for (int y = 0; y < b; ++y)
			for (int x = 0; x < a; ++x)
				if ( m[y][x] > 0 )
				{
					for (int d = 0, mx, my; d < 2; ++d)
					{
						mx = x + dx[d];
						my = y + dy[d];
						if ( mx < a && my < b && m[my][mx] != -1 )
							m[my][mx] += m[y][x];
					}
				}
		cout << m[b-1][a-1] << endl;
	}
	return 0;
}

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

const int MAXN = 100;

int b[MAXN];

int solve(int n) {
  int res = b[0] + b[n - 2];
  for (int i = 1; i < n - 1; ++i) {
    res += std::min(b[i - 1], b[i]);
  }
  return res;
}

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n - 1; ++i) std::cin >> b[i];
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 384
L,R=map(int,input().split())
if R-L>=2019:
    print(0)
else:
    num=2018
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            num=min((i*j)%2019,num)
            if num==0:
                print(num)
                exit()
    print(num)


Measured memory_bytes: 38896
#include<iostream>

using namespace std;

int main() {
    int n, x;

    while (1) {

        int cnt = 0;

        cin >> n >> x;

        if (n == 0 && x == 0) {
            break;
        }

        for (int i = 1; i <= n - 2; i++) {
            for (int j = i + 1; j <= n - 1; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) {
                        cnt++;
                    }
                }
            }
        }

        cout << cnt << endl;

    }

    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
using namespace std;
vector <int> ve[10];
int n,m,sum;
vector <int> k;
bool used[10];
void dfs(int x){
	used[x]=true;
	k.push_back(x);
	if (k.size()==n) sum++; 
	for (int i=0;i<ve[x].size();i++) if (!used[ve[x][i]]) dfs(ve[x][i]);
	k.pop_back(); 
	used[x]=false;
}
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		ve[a].push_back(b);
		ve[b].push_back(a);  
	}
	dfs(1);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	sort.Ints(ar)
	result := 0
	for _, v := range ar {
		if v <= x {
			result++
			x -= v
		}
	}
	if result == n && 0 < x {
		result--
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

vector<int> graph[250000];
bool besucht[250000];
ll query[250000];
ll res[250000];

void dfs( int p, ll sum ){
	if( besucht[p] ) return;
	besucht[p] = true;
	res[p] = sum;
	for( auto next : graph[p] ){
		dfs( next, sum+query[next] );
	}
}

int main(){
	int n, q; cin >> n >> q;
	for( int i = 0; i < n-1; ++i ){
		int a, b; cin >> a >> b; --a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	for( int i = 0; i < q; ++i ){
		int p; ll x; cin >> p >> x;
		query[p-1] += x;
	}
	dfs(0, query[0]);
	for( int i = 0; i < n; ++i ){
		cout << res[i] << ' ';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 28348
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int Min=b-a,Max=b+a;
    Min++;
    for(int i=Min;i<Max;i++)
    {
        cout<<i<<" ";
    }
    return 0;
}


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

int main(){

  int n, a[100], maxn=-100, minn=100, ans=1000000;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    maxn=max(maxn, a[i]);
    minn=min(minn, a[i]);
  }

  for(int i=minn;i<=maxn;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      sum+=(a[j]-i)*(a[j]-i);
    }
    ans=min(ans, sum);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
"""
// Author : snape_here - Susanta Mukherjee
     
"""
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
 
import math

mod=1000000007 

def main():

    s=si()
    if s.count('A') and s.count('B'):
        print("Yes")
    else:
        print("No")

# region fastio#
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# endregion
 
 
if __name__ == "__main__":
    #read()
    main() 
#Comment read()

Measured memory_bytes: 29292
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD 998244353
typedef long long int lli;

int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    int ans = (d2 == 1) ? 1 : 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define M 1000000007
#define N 51
using namespace std;

ll n,k,ans,a[N][N],b[N][N],c[N][N];

void mul(ll m1[N][N],ll m2[N][N],ll t[N][N])
{
    memset(t,0,N*N*sizeof(ll));
    FOR(i,0,n) FOR(j,0,n) FOR(k,0,n) t[i][j]=(t[i][j]+m1[i][k]*m2[k][j])%M;
}

int main()
{
    cin>>n>>k; FOR(i,0,n) FOR(j,0,n) cin>>a[i][j];
    FOR(i,0,N) c[i][i]=1;
    while(k)
    {
        if(k&1) 
        {
            mul(a,c,b);
            FOR(i,0,N) FOR(j,0,N) c[i][j]=b[i][j];
        }
        mul(a,a,b);
        FOR(i,0,N) FOR(j,0,N) a[i][j]=b[i][j];
        k>>=1;
    }
    FOR(i,0,n) FOR(j,0,n) ans=(ans+c[i][j])%M;
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = [0]*n
    B = [0]*n
    for i in range(n):
        a,b = map(int,input().split())
        A[i] = a
        B[i] = b
    A.sort()
    B.sort()
    if n%2 == 0:
        m1 = (A[n//2-1]+A[n//2])/2
        m2 = (B[n//2-1]+B[n//2])/2
        print(int(2*(m2-m1))+1)
    else:
        print(B[(n+1)//2-1]-A[(n+1)//2-1]+1)    
main()

Measured memory_bytes: 25476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    ll x;
    cin >> x;
    
    ll a, b;
    for(a=200; a>-200; a--){
        for(b=-200; b<200; b++){
        	if(((a*a*a*a*a)-(b*b*b*b*b)) == x){
              cout << a << " " << b;
              return 0;
            }
        }
    }
    
    return 0;
}

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

int main()
{
  int n, k; cin >> n >> k;
  ll ans = 0;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(All(v), greater<int>());
  rep(i, k) ans += v[i];
  cout << ans << endl;
  system("pause");
}

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

int main()
{
    int n,k,q;
    cin>>n>>k>>q;
    int a[n]={0};
    for(int i=0; i<q; i++)
    {
        int b;
        cin>>b;
        a[b-1]++;
    }
    for(int i=0; i<n; i++)
    {
        a[i]-=(q-k);
        if(a[i]<=0) cout<<"No\n";
        else cout<<"Yes\n";
    }
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1005;
int X,Y,Z,K;
ll A[maxn],B[maxn],C[maxn];
priority_queue<ll>Q;
int main(){
	cin>>X>>Y>>Z>>K;
	for(int i=0;i<X;i++)cin>>A[i];
	for(int i=0;i<Y;i++)cin>>B[i];
	for(int i=0;i<Z;i++)cin>>C[i];
	sort(A,A+X,greater<ll>());
	sort(B,B+Y,greater<ll>());
	sort(C,C+Z,greater<ll>());
	for(int x=0;x<X;x++)
		for(int y=0;y<Y;y++){
			if((x+1)*(y+1)-1>=K)break;
			for(int z=0;z<Z;z++){
				if((x+1)*(y+1)*(z+1)-1>=K)break;
				ll tmp=A[x]+B[y]+C[z];
				Q.push(tmp);
			}
		}
	for(int i=0;i<K;i++){
		cout<<Q.top()<<endl;
		Q.pop();
	}
	return 0;
} 

Measured memory_bytes: 1400
#include<stdio.h>
int main(void)
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	if (B + C - A <= 0)
	
		printf("0");
	else
	{

	
		printf("%d", B + C - A);
	}



	
	return 0;
	



}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	int a,b;cin>>a>>b;
    if(a<=b)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

 
    
        






Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int, int>;

int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  long long m=b/x-a/x;
  if (a==a/x*x) {m++;}
  cout << m << endl;
}

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int k;
	cin >> k;
	string res;
	for (int i = 0; i < k; ++i) {
		res += "ACL";
	}
	cout << res;
	return 0;
}

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

int n,m;
int main(){
	while(cin >> n >> m && n>0){
		vector<int> C;
		int P[m+5][n+5] = {0};
		for(int i=0;i<m;i++){
			int c;
			cin >> c;
			C.push_back(c);
		}
		sort(C.begin(),C.end());
		for(int i=0;i<m;i++){
			for(int j=0;j<n+1;j++){
				if(i==0){
					P[i][j] = j;
				}else if(C[i]>j){
					P[i][j] = P[i-1][j];
				}else{
					P[i][j] = min(P[i][j-C[i]]+1 , min(P[i-1][j-C[i]]+1,P[i-1][j]));
				}
			}
		}
		cout << P[m-1][n] << endl;
	}
}

#if 0
???????????????30????¨?????????????????????????????????£?????????????£???§???????????????????????£??????(C[i]<j??¨??????????????????)
#endif

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

int main() {
  int64_t N;
  cin >> N;
  vector<char> s;
  s = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
  
  string name = "";
  
  while(N > 0){
    N -= 1;
    int n = N % 26;
    name.push_back(s.at(n));
    N /= 26;
  }
  reverse(name.begin(), name.end());

  cout << name;
}

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

int main(){
    string s;
    cin >> s;
    string t;
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='B'){
            int t=i-1;
            while(t>=0){
                if(s.at(t)=='0'||s.at(t)=='1'){
                    s.at(t)='3';
                    break;
                }
                t--;
            }
        }
    }
    for(int i=0;i<s.size();i++){
        if(s.at(i)!='3'&&s.at(i)!='B')
        t+=s.at(i);
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# https://qiita.com/e869120/items/eb50fdaece12be418faa
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_A&lang=ja


def main():
    n = int(input().strip())
    print(fib(n))


def fib(n):
    dp = [1] * (n + 1)
    for i in range(2, n + 1):
        dp[i] = dp[i - 1] + dp[i - 2]
    return dp[n]


if __name__ == '__main__':
    main()



Measured memory_bytes: 5604
import sys
from functools import reduce
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def comb(x):
    a = 1
    for i in range(1, x+1):
        a *= i
    return a//2


def main():
    N = int(input())
    M = {}
    for _ in range(N):
        s = ''.join(sorted(input()))
        if (s in M.keys()):
            M[s] += 1
            continue
        M[s] = 1

    print(sum([m*(m-1)//2 for m in M.values()]))


if __name__ == "__main__":
    main()


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

using namespace std;

int main(){

	int x,n;
    cin >> x >> n ;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i] ;
	}
    if(n==0){
        cout << x << endl; 
        return 0;
    }
    int p,m;
    int pf,mf;
    for(int i=0;i<n+1;i++){
        m=x-i;
        p=x+i;
        mf=0;
        pf=0;
        for(int j=0;j<n;j++){
            if(m==a[j]){
                mf=1;
            }
            if(p==a[j]){
                pf=1;
            }
        }
        if(mf==0){
            cout << m << endl; 
            return 0;
        }
        if(pf==0){
            cout << p << endl; 
            return 0;
        }
    }
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
#define pi 3.141592653589793238462643383279
int main(){
  int a,b,h,m;
  double radh,radm,rad,c,r;
  
  scanf("%d %d %d %d",&a,&b,&h,&m);
  radm=6.0*m;
  radh=30.0*h+0.5*m;
  rad=radm-radh;
  if(rad<0){rad=-rad;}
  r=rad*pi/180.0;
  c=sqrt(a*a+b*b-2*a*b*cos(r));
  printf("%.20f\n",c);
}

Measured memory_bytes: 2600
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>

#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;


int main() {
	int N, A, B;
	cin >> N >> A >> B;
	long long ans = 0;
	for (int i = 1; i <= N; i++) {
		int x=0,y=i;
		while(y>0){
			x += y % 10;
			y /= 10;
		}
		if (x >= A && x <= B) {
			ans += i;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int P = 1000000007;

char s[300010];

int norm(int x) { return x >= P ? x - P : x; }

void add(int& x, int y) {
  if ((x += y) >= P)
    x -= P;
}

void sub(int& x, int y) {
  if ((x -= y) < 0)
    x += P;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> (s + 1);
  int n = strlen(s + 1);
  s[0] = '1';
  s[n + 1] = '1';
  vector<int> dp(6);
  dp[0] = 1;
  for (int i = 0; i <= n + 1; ++i) {
    vector<int> newDp(6);
    if (s[i] != '1') {
      for (int j = 0; j < 6; ++j)
        add(newDp[j % 3], dp[j]);
    }
    if (s[i] != '0') {
      for (int j = 0; j < 6; ++j)
        add(newDp[j % 3 + 3], dp[j]);
      if (i & 1) {
        sub(newDp[3], dp[3]);
        add(newDp[4], dp[3]);
      } else {
        sub(newDp[4], dp[4]);
        add(newDp[5], dp[4]);
      }
    }
    dp = newDp;
  }
  cout << dp[5] << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


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

using namespace std;

int main() {
	string inStr, buf;
	int cnt =0;
	while(cin>>inStr, !cin.eof()) {
		buf = inStr;
		reverse(inStr.begin(), inStr.end());
		if(buf == inStr) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 1196
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int n, int[] a) {
    auto costs = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6];

    auto dp = new int[n + 1];
    foreach (e; a) {
        int cost = costs[e]; // 数字 e に必要な本数
        if (cost > n) continue;

        dp[cost] = max(dp[cost], 1);
        for (int i = 1; i <= n - cost; i++) {
            if (dp[i] == 0) continue;
            dp[i + cost] = max(dp[i + cost], dp[i] + 1);
        }
    }

    // 桁の大きなマッチ棒から試す
    a.sort!"a > b";
    int[] ans;
    int rest = n;
    foreach (e; a) {
        // 数字 e を作るのに必要な本数
        int cost = costs[e];

        // 数字 e を作成しても最適解を維持しているか
        while (cost <= rest && dp[rest - cost] == dp[rest] - 1) {
            if (dp[rest - cost] == 0 && rest - cost > 0) break; // マッチ棒を余すのはだめ
            ans ~= e;
            rest -= cost;
        }
    }

    writeln(ans.map!(text).join);
}

void main() {
    int n, m; scan(n, m);
    auto a = readints;
    calc(n, a);
}


Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int N,M,X,Y; cin>>N>>M>>X>>Y;
  vector<int>vecX(N);
  vector<int>vecY(M);
  for(int i=0;i<N;i++){
    cin>>vecX[i];
  }
  for(int i=0;i<M;i++){
    cin>>vecY[i];
  }
  
  //compute
  sort(vecX.begin(),vecX.end());
  reverse(vecX.begin(),vecX.end());
  
  sort(vecY.begin(),vecY.end());
  //output
  if(vecY[0]-vecX[0]>0 && X<vecY[0] && vecX[0]<Y){
    cout<<"No"<<" "<<"War"<<endl;
  }else{
    cout<<"War"<<endl;
  }
}
  



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int F[105][10];
    REP(i,N) REP(j,10)
    {
        cin >> F[i][j];
    }
    int P[105][11];
    REP(i,N) REP(j,11)
    {
        cin >> P[i][j];
    }
    LL ans = -LINF;

    for(int i = 1; i < (1 << 10); i++)
    {
        LL profit = 0;
        REP(j,N)
        {
            int x = 0;
            REP(k,10)
            {
                if(F[j][k] == 1 && ((i >> k) & 1) == 1) x++;
            }
            profit += P[j][x];
        }
        if(profit > ans) {
            dump(profit)
            dump(i)
            ans = profit;
        }
    }
    cout << ans << endl;




}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int l[] = new int[n];
		for(int i=0;i<n;i++) {
			l[i] = scan.nextInt();
		}
		int ans = 0;
		
		Arrays.sort(l);
		for(int i=0;i<n;i++) {
			for(int j=i;j<n;j++) {
				if(l[i] != l[j]) {
					for(int k=j;k<n;k++) {
						if(l[j] != l[k]) {
							int oppai = l[j] - l[i];
							int boin = l[j] + l[i];
							oppai = Math.abs(oppai);
							if(oppai < l[k] && l[k] < boin) {
								
								ans++;
							}
						}
					}
				}
			}
		}
		
		System.out.println(ans);
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 





Measured memory_bytes: 35936
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl r,d,x;
    cin >> r >> d >> x;
    rep(i,10){
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split(" "))

ptn = 0

if a==b and a==c:
	print(1)
	ptn = 1

if a==b and a!=c:
	if a < c:
		print(1)
		ptn=2
	else:
		print(0)
		ptn=2

cnt = 0

for i in range(a,b+1):
	if c%i == 0:
		cnt += 1

if ptn != 1 and ptn != 2:
	print(cnt)

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

//fenwick_tree
template <class T>
struct fenwick_tree {
	vector<T> x;
	fenwick_tree(int n) : x(n, 0) { }
	T sum(int i, int j) {//両端を含む
		if (i == 0) {
			T S = 0;
			for (j; j >= 0; j = (j & (j + 1)) - 1) S += x[j];
			return S;
		} else return sum(0, j) - sum(0, i-1);
	}
	void add(int k, T a) {
		for (; k < x.size(); k |= k+1) x[k] += a;
	}
};

int main(void){

	int W,H;
	cin >> W >> H;

	vector<tuple<int,int,int>> p;
	fenwick_tree<int> yoko(W+1),tate(H+1);
	int cntYoko = 0, cntTate = 0;

	for(int i=0;i<W;i++){
		int pp;cin >> pp;
		p.emplace_back( pp, 0, i);
	}
	for(int i=0;i<H;i++){
		int qq;cin >> qq;
		p.emplace_back( qq, 1, i);
	}

	sort(p.begin(),p.end());

	long long ret = 0;
	for(int i=0;i<p.size();i++){
		int cost, pq, id;
		tie(cost, pq, id) = p[i];

		if(!pq){
			cntYoko++;
			ret += (long long)cost * (H + 1 - cntTate);
			// cerr << cost * (H - cntTate) << endl;
		}else{
			cntTate++;
			ret += (long long)cost * (W + 1 - cntYoko);
			// cerr << cost * (W - cntYoko) << endl;
		}
	}
	cout << ret << endl;


	return 0;
}

Measured memory_bytes: 4340
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=600+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n,D1,D2;
void input()
{
	n=read<int>(),D1=read<int>(),D2=read<int>();
}
int cl[N][N];
void solve(int d)
{
	int num=0;
	while(d&&d%4==0)d/=4,num++;
	if(d&1)
	{
		For(i,0,n*2-1)For(j,0,n*2-1)if(((i>>num)+(j>>num))&1)cl[i][j]=1;
	}
	else
	{
		For(i,0,n*2-1)For(j,0,n*2-1)if((i>>num)&1)cl[i][j]=1;
	}
}
void work()
{
	solve(D1);
	solve(D2);
	int k=0;
	For(i,0,n*2-1)For(j,0,n*2-1)
	{
		if(!cl[i][j])
		{
			printf("%d %d\n",i,j);
			if(++k==n*n)return;
			//cerr<<k<<endl;
		}
	}
}
int main()
{

	input();
	work();
	return 0;
}


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


bool dudeney(int y,int a,int n){
  int x = 1;
  for(int i = 0; i < n; i++){
    x *= ( y + a );
  }

  int z=0;
  while(x > 0){ 
    z += (x % 10);
    x /= 10;
  }

  if(z == y) return true;
  return false;
}

int main(){
 
  int a,n,m;
  cin >> a >> n >> m;

  int ymax = (int)pow( (double)m , 1.0/n ) - a;

  int ans = 0;
  for(int y = 1; y <= ymax; y++)
    if( dudeney(y,a,n) ) ans++;
  cout << ans << endl;

}



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

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

typedef long long ll;

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");} 

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

const int INF = 0x3f3f3f3f;

int main(){
    IOS;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<ll> dp(n,INF);
    dp[0] = 0;
    for(ll i=1; i<n; i++){
        for(ll j=1; j<k+1; j++){
            if(i-j >= 0){
                dp[i] = min(dp[i], (dp[i-j])+abs(a[i-j]-a[i]));
            }
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 4732
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n,w;
	cin>>n>>w;
	
	vector<int> val(n),wt(n);
	
	for(int i=0;i<n;i++)
	{
		cin>>wt[i]>>val[i];
	}
	
	vector<vector<long long int> > knap(n+1,vector<long long int>(w+1));
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(wt[i-1] <= j)
			{
				knap[i][j]=max(knap[i-1][j],val[i-1]+knap[i-1][j-wt[i-1]]);
			}
			else
			knap[i][j]=knap[i-1][j];
		}
	}
	
	cout<<knap[n][w];
	
	return 0;
}


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

int N,len1,len2;
string seq1,seq2;
int dp[1000+10][1000+10];

int main() {
	cin >> N;
	for (int M=0; M<N; M++){
		cin >> seq1 >> seq2;
		len1 = seq1.length();
		len2 = seq2.length();
		for (int i=1; i<=len1; i++){
			for (int j=1; j<=len2; j++){
				if (seq1[i-1] == seq2[j-1]){
					dp[i][j] = dp[i-1][j-1] + 1;
				}else if (dp[i][j-1] > dp[i-1][j]){
					dp[i][j] = dp[i][j-1];
				}else{
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		cout << dp[len1][len2] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 7116
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define Nmax 100005

int main()
{
    int N, K;
    cin >> N >> K;
    int temp;
    double a[Nmax];
    for (int i = 1; i <= N; i++)
    {
        temp = i;
        a[i] = (double)1 / N;
        while (temp < K)
        {
            a[i] *= 1 / 2.0;
            temp *= 2;
        }
    }
    double ans;
    for (int i = 1; i <= N; i++)
    {
        ans += a[i];
    }
    //ans /= N;
    printf("%.12lf\n", ans);
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

template <typename T>
std::map<T, int> Factorize(T x) {
  std::map<T, int> m;
  for (T i = 2; i * i <= x;) {
    if (x % i == 0) {
      m[i]++;
      x /= i;
    } else {
      ++i;
    }
  }
  if (x > 1) m[x]++;
  return m;
}

int main() {
  in(int, n);
  map<int, int> fs;
  for (int i = 2; i <= n; ++i) {
    for (auto [k, v] : Factorize(i)) fs[k] += v;
  }
  // 3 * 5 * 5
  // 15 * 5
  // 3 * 25
  // 75
  vector<int> cand = {3, 5, 15, 25, 75};
  map<int, int> m;
  for (auto [_, v] : fs) {
    for (int c : cand) {
      if (v >= c - 1) {
        m[c]++;
      }
    }
  }
  int ans = 0;
  if (m[5] >= 2 && m[3] >= 3) ans += m[5] * (m[5] - 1) / 2 * (m[3] - 2);
  if (m[15] >= 1 && m[5] >= 2) ans += m[15] * (m[5] - 1);
  if (m[25] >= 1 && m[3] >= 2) ans += m[25] * (m[3] - 1);
  if (m[75] >= 1) ans += m[75];
  out(ans);
}


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

using namespace std;

#define fi first
#define se second
#define asmax(a,b) a = max(a, b)

int n, a[1 << 18], ans = 0;
pair<int, int> dp[2][1 << 18];

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < (1 << n); ++i) {
        cin >> a[i];
        dp[0][i] = { a[i], i };
        dp[1][i] = { 0, 0 };
    }

    for (int i = 0; i < n; ++i) {
        for (int mask = 0; mask < (1 << n); ++mask) {
            if( (mask >> i) & 1) {
                asmax(dp[1][mask], dp[1][mask ^ (1 << i)]);
                if(dp[0][mask] < dp[0][mask ^ (1 << i)]) asmax(dp[1][mask], dp[0][mask]);
                else if(dp[0][mask] > dp[0][mask ^ (1 << i)]) asmax(dp[1][mask], dp[0][mask ^ (1 << i)]);
                asmax(dp[0][mask], dp[0][mask ^ (1 << i)]);
            }
        }
    }

    for (int i = 1; i < (1 << n); ++i) {
        ans = max(ans, dp[0][i].fi + dp[1][i].fi);
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 8192
N, A, B = map(int, input().split())

N_str = str(N)
result = 0
for n in range(1, N + 1):
  sum_N = 0
  for s in str(n):
    sum_N += int(s)
  
  if (A <= sum_N and sum_N <= B):
    result += n

print(result)

Measured memory_bytes: 39792
n , m = map(int, input().split())
e = 0
d = []
for i in range(1, n + 1):
  l = list(map(int, input().split()))
  for a in range(l[0]):
    b = l[a + 1]
    d.append(b)
for j in range(1, m + 1):
  c = 0
  for k in d:
    if k == j:
      c += 1
  if c == n:
    e += 1
print(e)

Measured memory_bytes: 9204