akhauriyash/Code-Regression huggingface dataset:
/*
	ABC 059
	A - Three-letter acronym
*/
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; scanf("%d",&x);
#define lint(x) long long x; scanf("%lld",&x);
#define vint(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define vlint(v,n) vector<lint> v(n); rep(i,n) scanf("%lld", &v[i]);
#define double(x) double x; scanf("%lf",&x);
#define vdouble(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define string(x) string x; cin >> x;

int main()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	const int upper = 32;

	/*transform(s1.begin(), s1.end(), s1.begin(), toupper);
	transform(s2.begin(), s2.end(), s2.begin(), toupper);
	transform(s3.begin(), s3.end(), s3.begin(), toupper);*/

	s1[0] -= upper;
	s2[0] -= upper;
	s3[0] -= upper;

	cout << s1[0] << s2[0] << s3[0] << endl;
	//cout << toupper(s1[0]) << toupper(s2[0]) << toupper(s3[0]) << endl;
	return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    int ma = 0, mi = 1e9 + 10;
    // maが最大値、miが最小値
    
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        
        // 最大値、最小値を更新
        ma = max(ma, A);
        mi = min(mi, A);
    }
    cout << ma - mi << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num1 = scanner.nextInt();
		int num2 = scanner.nextInt();
		System.out.println(String.format("%s %s %.5f", num1 / num2,
				num1 % num2, (double) num1 / num2));
	}
}

Measured memory_bytes: 17380
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

bool ccc(char c)
{
	if('a'<=c&&c<='z')
	{
		return true;
	}
	return false;
}

bool ch(string c)
{
	int cc=0;
	if(c[0]!='A')return false;
	if(!ccc(c[1]))return false;
	for(int i=2;i<c.length()-1;i++)
	{
		if(c[i]=='C')
		{
			cc++;
		}
		else if(!ccc(c[i]))
		{
			return false;
		}
	}
	if(cc!=1)return false;
	if(!ccc(c[c.length()-1]))
	{
		return false;
	}
	return true;
}

int main()
{
	string s;
	cin>>s;
	cout<<(ch(s)?"AC":"WA")<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    long double r;
    cin >> r;

    cout << r * 2 * pi << endl;

    return 0;
}


Measured memory_bytes: 3808
use proconio::input;
use proconio::marker::Chars;

fn main() {
  input! {
  	mut n: Chars,
  }
  
  n.reverse();
  
  let mut ans = "hon";
  if n[0] == '3' {
  	ans = "bon";
  }
  else if n[0] == '0' || n[0] == '1' || n[0] == '6' || n[0] == '8' {
    ans = "pon";
  }
  
  println!("{}", ans);
}

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

using namespace std;
#define ll long long int

int main()
{
    string S;
    cin >> S;

    int t = 0;

    for (int i = 0; i < S.length(); i++)
    {
        t += S[i] - '0';
    }
       
     int N = stoi(S);
    if (N % t == 0)
        cout << "Yes";
    else
        cout << "No";


    return 0;
}


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

struct Edge {
  int to, id;
  Edge(int to, int id): to(to), id(id) {}
};

vector<vector<Edge>> G;
vector<int> es;

bool dfs(int v, int g, int p) {
  if (v == g) return true;
  for (Edge e : G.at(v)) {
    if (e.to == p) continue;
    if (dfs(e.to, g, v)) {
      es.push_back(e.id);
      return true;
    }
  }
  return false;
}

int main() {
  int N, M;
  cin >> N;
  G.resize(N);

  rep(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;

    G.at(a).emplace_back(b, i);
    G.at(b).emplace_back(a, i);
  }

  cin >> M;
  vector<ll> eset(M);
  rep(i, M) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    es.clear();
    dfs(u, v, -1);
    for (int e : es) {
      eset.at(i) |= 1ll << e;
    }
  }

  ll ans = 0;
  rep(i, 1 << M) { // パスの全組み合わせについて列挙
    ll mask = 0;
    rep(j, M) {
      if (i >> j & 1) mask |= eset.at(j); // maskで1が立っているものは、使用される辺のidと対応
    }
    int white = __builtin_popcountll(mask); // 白にすべき辺の本数
    ll now = 1ll << (N - 1 - white); // 2^(N - 1 - white)
    if (__builtin_popcountll(i) % 2 == 0) {
      ans += now;
    } else {
      ans -= now;
    }
  }
  cout << ans << endl;
  return 0;
}

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

long gcc(long a,long b);

int main(void){
  long a,b,c,d,e,countc,countd,counte,sum,gc;
  char str[1000],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a=atol(p);
  p=strtok(NULL," \n");
  b=atol(p);
  p=strtok(NULL," \n");
  c=atol(p);
  p=strtok(NULL," \n");
  d=atol(p);
  e=c*d/gcc(c,d);
  
  countc=b/c-(a-1)/c;
  countd=b/d-(a-1)/d;
  counte=b/e-(a-1)/e;
  
  
  sum=b-a+1-countc-countd+counte;
  
  printf("%ld\n",sum);
  
  
  return 0;
}


long gcc(long a,long b){
  if(b==0) return a;
  return gcc(b,a%b);
}

Measured memory_bytes: 128
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


### BIT binary
def init(bit, values):
    for i,v in enumerate(values):
        add(bit,i+1,v)
#a1 ~ aiまでの和 O(logn)
def query(bit,i):
    res = 0
    while i > 0:
        res += bit[i]
        i -= i&(-i)
    return res

#ai += x(logN)
def add(bit,i,x):
    if i==0:
        raise RuntimeError
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return

n = int(input())
xy = [tuple(map(int, input().split())) for _ in range(n)]
from bisect import bisect_left
def press(l):
    # xs[inds[i]]==l[i]となる
    xs = sorted(set(l))
    inds = [None] * len(l)
    for i,item in enumerate(l):
        inds[i] = bisect_left(xs, item)
    return xs, inds
_, indx = press([item[0] for item in xy])
_, indy = press([item[1] for item in xy])
xy = list(zip(indx, indy))
xy.sort()
M = 998244353
# ans = (pow(2, n, M) * n) % M
pows = [0]*(n+1)
v = 1
for i in range(n+1):
    pows[i] = v-1
    v *= 2
    v %= M
ans = (pows[n]*n) % M
bit = [0]*(n+1)
for i,(x,y) in enumerate(xy):
    ans -= pows[i] + pows[n-i-1]
    ans += pows[query(bit, y+1)] + pows[i - query(bit, y+1)]
    add(bit, y+1, 1)
    ans %= M
from operator import itemgetter
xy.sort(key=itemgetter(1))
bit = [0]*(n+1)
for i,(x,y) in enumerate(xy):
    ans -= pows[i] + pows[n-i-1]
    ans += pows[i - query(bit, x+1)]
    add(bit, x+1, 1)
    ans %= M
bit = [0]*(n+1)
for i in range(n-1, -1, -1):
    x,y = xy[i]
    ans += pows[(n-1-i) - query(bit, x+1)]
    add(bit, x+1, 1)
    ans %= M
print(ans%M)

Measured memory_bytes: 160696
a = [0]*3
a[0],a[1],a[2],n = map(int,input().split())
a.sort()
cnt = 0
for i in range(n//a[2]+1):
    for j in range((n-i*a[2])//a[1]+1):
        d = n-a[2]*i-a[1]*j
        if d%a[0] == 0 and d >= 0:
            cnt += 1
print(cnt)


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


long long int dfs(int len,long long int tar,bool start){
	if(len==0)
		return tar==0;
	else if(len==1)
		return tar==0?(10-start):0;
	long long int tmp=1;
	for(int i=1;i<len;i++)
		tmp=tmp*10;
	tmp-=1;
	long long int res=0;
	for(int i=-9;i<=9;i++){
		if((tar-tmp*i)%10==0){
			res+=dfs(len-2,(tar-tmp*i)/10,false)*(10-abs(i)-(start&&i>=0));
		}
	}
	return res;
}

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

	long long int d;
	cin>>d;
	long long int ans=0;
	for(int i=1;i<=19;i++)
		ans+=dfs(i,d,true);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
n= int(input())-1
 
alp=list([
    "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"
          ])
 
answer=""
while True:
    answer=alp[n%26]+answer
    if n<26:
        break
    n=n//26-1
 
print(answer)

Measured memory_bytes: 9220
#include<stdio.h>

int n,m;

void proc(){
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)
      printf("%c",(i==0||i==n-1||(j==0||j==m-1))?'#':'.');
    printf("\n");
  }
  printf("\n");
}

int main(){
  while(true){
    scanf("%d%d", &n, &m);
    if(!n&&!m)return 0;
    proc();
  }
}

Measured memory_bytes: 1000
#include <iostream>                                             
using namespace std;                                            
                                                                
int main(void) {                                                
  int a, b, c;                                                  
  cin >> a >> b >> c;                                           
  if (a<b && b<c) {                                             
    cout << "Yes" << endl;                                      
  } else {                                                      
    cout << "No" << endl;                                       
  }                                                             
  return 0;                                                     
}                                                               
                                    

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    string S1,S2;
    cin >> N >> S1 >> S2;
    ll ans = 1;
    int idx = 0, pre;
    if(S1[0] == S2[0]){
        ans = 3;
        idx = 1;
        pre = 0;
    }else{
        ans = 6;
        idx = 2;
        pre = 1;
    }
    for(;idx < N;){
        if(S1[idx] == S2[idx]){
            if(!pre)ans *= 2;
            idx++;
            pre = 0;
        }else{
            if(!pre)ans *= 2;
            else ans *= 3;
            idx+=2;
            pre = 1;
        }
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int XA,YB,YC,YD,P,X,Y;
	scanf("%d",&XA);
	scanf("%d",&YB);
	scanf("%d",&YC);
	scanf("%d",&YD);
	scanf("%d",&P);
	X=XA*P;
	if(YC<P){
		Y=P-YC;
		Y=Y*YD;
	}
	Y=Y+YB;
	if(X>Y){
		printf("%d\n",Y);
	}
	else{
		printf("%d\n",X);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
const int N=4007,M=200007,P=1000000007;
int f[N][N],g[N][N],a[M],b[M];
int read(){int x;scanf("%d",&x);return x;}
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
int main()
{
    int n=read(),ans=0;g[0][0]=1;
    for(int i=1;i<=n;++i) a[i]=read(),b[i]=read(),++f[2000-a[i]][2000-b[i]];
    for(int i=0;i<=4000;++i) for(int j=0;j<=4000;++j) inc(g[i][j],i? g[i-1][j]:0),inc(g[i][j],j? g[i][j-1]:0),inc(f[i][j],i? f[i-1][j]:0),inc(f[i][j],j? f[i][j-1]:0);
    for(int i=1;i<=n;++i) inc(ans,f[2000+a[i]][2000+b[i]]),inc(ans,P-g[a[i]*2][b[i]*2]);
    printf("%d",(int)(ans*500000004ll%P));
}


Measured memory_bytes: 127104
s = gets.chomp
length = s.size
ans = 'No'

def kaibun(word)
    (word.size/2).times do |i|
        if word[i] != word[word.size-1-i]
            return false
        end
    end
    true
end


if kaibun(s) && kaibun(s[0...((s.size-1)/2)]) && kaibun(s[((s.size+2)/2)..-1])
    ans = 'Yes'
end
puts ans

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_H = 10;
const int MAX_W = 10;
int m[MAX_H][MAX_W];
int x, y ,s;
int cnt = MAX_H * MAX_W;
int mx;

inline bool check(int x, int y){ return 0 <= x && x < MAX_H && 0 <= y && y < MAX_W; }

void dfs(int x, int y)
{
  maxup(mx, m[x][y]);
  m[x][y] = 0;
  cnt -= 1;
  erep(dx, -1, 1) erep(dy, -1, 1) if(check(x+dx, y+dy)) if(m[x+dx][y+dy]) dfs(x+dx, y+dy);
}

int main()
{
  while(~scanf("%d,%d,%d", &x, &y, &s)){
    m[x][y] += 1;
    if(s%2){
      int d = s/2 + 1;
      int dx[] = {-d, 0, d, 0};
      int dy[] = {0, -d, 0, d};
      rep(i, 4) if(check(x+dx[i], y+dy[i])) m[x+dx[i]][y+dy[i]] += 1;
    }
    if(s-1){
      erep(i, -1, 1) erep(j, -1, 1) if(i || j) if(check(x+i, y+j)) m[x+i][y+j] += 1;
    }
  }

  rep(i, MAX_H) rep(j, MAX_W) if(m[i][j]) dfs(i, j);

  cout << cnt << endl << mx << endl;

  return 0;
}

Measured memory_bytes: 1208
N = int(input())
L = list(map(int, input().split()))
color = [0 for i in range(9)]
minmum = 0
maximum = 0
for i in range(N):
    if L[i] < 400:
        color[0] += 1
    elif 400<= L[i] < 800:
        color[1] += 1
    elif 800 <= L[i] < 1200:
        color[2] += 1
    elif 1200 <= L[i] < 1600:
        color[3] += 1
    elif 1600 <= L[i] < 2000:
        color[4] += 1
    elif 2000 <= L[i] < 2400:
        color[5] += 1
    elif 2400 <= L[i] < 2800:
        color[6] += 1
    elif 2800 <= L[i] < 3200:
        color[7] += 1
    else:
        color[8] += 1

for i in range(8):
    if color[i] != 0:
        minmum += 1
        maximum += 1
        
if minmum == 0:
    minmum += 1

maximum += color[8]
print(str(minmum) + ' ' + str(maximum))

Measured memory_bytes: 3064
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
    int keep = 0, cnt1 = 0, cnt2 = 0;
    cin >> N;
    string s;
    cin >> s;
    rep(i, N){
        if(s[i] == '(') {
            keep++;
        }
        else {
            if(keep != 0) keep--;
            else cnt1++;
        }
    }
    rep(i, cnt1){
        cout << '(';
    }
    cout << s;
    rep(i, keep){
        cout << ')';
    }
}


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

using namespace std;

int main() {
    string s;
    int ans=0;
    while (true) {
        getline(cin, s);
        if (s == "0") break;
        for (int i = 0; i < s.length(); ++i) {
            ans += s[i] - 48;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}


Measured memory_bytes: 3168
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long int;
#define limit 100001
using edge = struct{int to; ll cost;};
vector<edge> tree[limit];
ll dist[limit];
void dfs(int v, int p, ll d){
    dist[v] = d;
    for(auto &a : tree[v]){
        if(a.to==p) continue;
        dfs(a.to, v, d + a.cost);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    dfs(K, -1, 0);
    for(int i = 0; i < Q; i++){
        int x, y;
        cin >> x >> y;
        cout << dist[x-1]+dist[y-1] << "\n";
    }
    return 0;
}

Measured memory_bytes: 14336
#include <stdio.h>
 
int main() {
    int a, b; 
	int totalSum = 0;
	int n;
    scanf("%d %d %d", &n, &a, &b);
    for (int i = 1 ; i <= n; i++) {
        int temp = i, digitSum = 0;
        while (temp != 0) {
            digitSum += (temp % 10);
            temp /= 10;
        }
        if (digitSum >= a && digitSum <= b) {
            totalSum += i;
        }
    }
    printf("%d", totalSum);
    return 0;
}

Measured memory_bytes: 1696
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N, K;
  cin >> N >> K;
  if (K > 1)
    cout << N-K << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

namespace Atcoder_program_test_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int N, D;
            string[] str = Console.ReadLine().Split(' ');
            N = int.Parse(str[0]);
            D = int.Parse(str[1]);
            if (N % (D * 2 + 1) == 0)
            {
                Console.Write(N / (D * 2 + 1));
            }
            else
            {
                Console.Write(N / (D * 2 + 1) + 1);
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#define NMAX (200000)
using namespace std;

int main(void) {
	
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int sum;
	
	if(A+B <= 2*C) {
		sum = A*X+B*Y;
	} else {
		if(X<Y)
			if(B > 2*C)
				sum = Y * 2 * C;
			else
				sum = X * 2 * C + (Y - X) * B;
		else
			if(A > 2*C)
				sum = X * 2 * C;
			else
				sum = Y * 2 * C + (X - Y) * A;
	
	}
	cout << sum << endl;
	

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	
	public static void main(String args[]) {
		//宣言
		//int x[]=new int[2000];
		int y[]=new int[2000];
		String[] strs = new String[2000];
		char[] word = new char[2000];
		sc = new Scanner(System.in);
		int i=1;
		int j=0;
		int sum=0;
		//入力
		//System.out.println("Please input x below");
		for(;;) {
			//x[i]=sc.nextInt();
			strs[i]=sc.next();
			if(strs[i].equals("0")) {
				break;
			}
			i++;	
		}
		//出力
		i=1;
		for(;;) {
			if(strs[i].equals("0")) {
				break;
			}
			for(j=0;j<strs[i].length();j++) {
				word[j]=strs[i].charAt(j);
				y[j]=Character.getNumericValue(word[j]);
				sum+=y[j];
			}
			System.out.println(sum);
			i++;
			sum=0;
		}
	}
}



Measured memory_bytes: 26340
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 500;
bool dp[N][N];

int main() {
  // for (int k = 0; k < N; ++k) {
  //   for (int i = 0; i < N && i <= k; ++i) {
  //     int j = k - i;
  //     for (int x = 1; x * 2 <= i; ++x) {
  //       dp[k][i] |= !dp[k - x][i - 2 * x];
  //     }
  //     for (int x = 1; x * 2 <= j; ++x) {
  //       dp[k][i] |= !dp[k - x][i + x];
  //     }
  //   }
  // }
  // for (int k = 0; k < N; ++k) {
  //   for (int i = 0; i <= k; ++i) {
  //     int j = k - i;
  //     if (i <= j) trace(i, j, dp[k][i]);
  //   }
  // }
  int64 a, b;
  cin >> a >> b;
  if (abs(a - b) >= 2) {
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		ArrayList<Integer> arr = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);

		int a;
		while((a = sc.nextInt()) != 0) {
			arr.add(a);
		}

		for(int i = 0; i < arr.size(); i++) {
			System.out.println("Case " + (i+1) + ": " + arr.get(i));
		}
	}

}



Measured memory_bytes: 43616
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        ok = True
        for k in range(M):
           for l in range(M):
               if A[i + k][j + l] != B[k][l]:
                   ok = False
                   break
           if not ok:
               break
        if ok:
            print('Yes')
            exit()
print('No')


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

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	if( a >= 1 && a <= 9 && b <= 9 && b >= 1)
	 cout<<a*b<<endl;
	 else
	 cout<<-1<<endl;
	return 0;
}




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

int main(){
  int x; cin >>x;
  int cnt = 1;
  ll sum = 0;
  while(sum<x){
    sum += cnt;
    cnt++;
  }
  cout << cnt-1 << endl;
  return 0; 
}

Measured memory_bytes: 3632
num = int(input())

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

val2 = [int(x) for x in range(min(val), max(val))]


array = []
for i in val2:
    res = 0
    for j in val:
        res += pow(abs(i - j), 2)
    array.append(res)
print(min(array) if len(array) != 0 else 0)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef pair<int,int> pint;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int N,M;
int a[60],b[60];
map<int,int>mp;

int main() {
	
	cin>>N>>M;
	Rep(i,M) {
		cin>>a[i]>>b[i];
		mp[a[i]]++;
		mp[b[i]]++;
	}
	int ans=0;
	Rep(i,50){
		Rep(j,N+1){
			if(mp[j]==1){
				mp[j]--;
				Rep(k,M){
					if(a[k]==j){
						mp[b[k]]--;
						b[k]=-1;
						ans++;
					}
					if(b[k]==j){
						mp[a[k]]--;
						a[k]=-1;
						ans++;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	

	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int N;
  cin >> N;
  priority_queue<double, vector<double>, greater<double>> x;
  for(int i = 0; i < N; i++){
    double a;
    cin >> a;
    x.push(a);
  }
  while(x.size() > 1){
    double a = x.top();
    x.pop();
    double b = x.top();
    x.pop();
    x.push((a + b) / 2);
  }
  cout << x.top() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prime[10000001];
int main() {
    for(long long int i=2;i<3162;i++)if(!prime[i])for(long long int j=i*2;j<10000001;j+=i)prime[j]=1;
    int n;
    while(cin>>n,n){
        for(;;n--){
            if(!prime[n]&&!prime[n-2]&&!prime[n-6]&&!prime[n-8]){
                cout<<n<<endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 10924
#include<iostream>
using namespace std;
int main()
{
    int N, M, A_i;
    cin >> N >> M;
    int days = 0;
    while(cin>>A_i){
        days += A_i;
    }
    if (N - days < 0) {
        cout << "-1" << endl;
    } else {
        cout << N-days << endl;
    }
    return 0;
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;

int gcd(int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve() {
    int n, x;
    cin >> n >> x;
    int y;
    int res = 0;
    for (int i = 0; i < n; ++i) {
        cin >> y;
        res = gcd(res, abs(x - y));
    }
    cout << res << endl;
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
def d():
    from collections import deque
    S = deque(str(input()))
    Q = int(input())
    rvs = False

    for i in range(Q):
        q = list(input().split())

        if q[0] == '1':
            rvs = not rvs
        elif q[0] == '2':
            if q[1] == '1':
                if rvs:
                    S.append(q[2])
                else:
                    S.appendleft(q[2])
            elif q[1] == '2':
                if rvs:
                    S.appendleft(q[2])
                else:
                    S.append(q[2])
            else:
                raise ValueError(
                    'F({}) is {}, which is invalid!'.format(i, q[1]))
        else:
            raise ValueError('T({}) is {}, which is invalid!'.format(i, q[0]))

    if rvs:
        ans = list(S)[::-1]
    else:
        ans = list(S)
    print(''.join(ans))


##########
if __name__ == "__main__":
    d()


Measured memory_bytes: 10100
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

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

const string t = "CODEFESTIVAL2016";


int main()
{
	ios_base::sync_with_stdio(0);
	string s; cin >> s;

	int res = 0;
	rep (i, s.length()){
		res += (int)(s[i] != t[i]);
	} // end rep
	
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if (b+c==a||a+c==b||a+b==c){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int> > id(N+1);
    vector<int> p(M),y(M);
    for(int i = 0; i < M ; i++){
        cin >> p[i] >> y[i];
        id[p[i]].push_back(y[i]);
    }
    for(int i = 1; i <= N; i++){
        sort(id[i].begin(),id[i].end());
    }
    for(int i = 0; i < M; i++){
        int num = lower_bound(id[p[i]].begin(),id[p[i]].end(),y[i]) - id[p[i]].begin()+1;
        printf("%012lld\n",(ll)p[i]*1000000 + num);
    }

    return 0;
}

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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}
template<typename T> inline T dmax(T x, T y){return x > y ? x : y;}
template<typename T> inline T dmin(T x, T y){return x < y ? x : y;}

const int MAXN = 305;
const int oo = 0x3f3f3f3f;

int mod;

inline int add(int a, int b){a += b; return a >= mod ? a - mod : a;}
inline int pop(int a, int b){a -= b; return a < 0 ? a + mod : a;}
inline int mul(int a, int b){return (ll)a * b % mod;}

int C[MAXN][MAXN], N, K, f[MAXN][MAXN], g[MAXN]; 

int main(){
#ifdef cydiater
	freopen("input.in", "r", stdin);
#endif
	scanf("%d%d%d", &N, &K, &mod);
	up (i, 0, N) {
		C[i][0] = 1;
		up (j, 1, i) C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
	}
	down (i, K, 0) {
		up (j, 1, N + 1) g[j] = 0;
		up (j, i + 1, K) up (k, 1, N + 1) cadd(g[k], f[j][k]);
		f[i][1] = 1;
		up (j, 1, N + 1) up (k, 1, N + 1 - j) 
			cadd(f[i][j + k], mul(f[i][j], mul(g[k], C[j + k - 2][k - 1])));
	}
	printf("%d\n", f[0][N + 1]);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;

  Int ans = 0;
  for(Int i=K;i<=N+1;i++){
    Int l = (0 + 0 + i - 1) * i / 2;
    Int r = (N + N - i + 1) * i / 2;
    ans += r - l + 1;
    ans %= mod;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> K(N);
	vector<vector<int>> A(N);
	int tmp_cin;
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) {
			cin >> tmp_cin;
			A[i].push_back(tmp_cin);
		}
		sort(A[i].begin(), A[i].end());
	}

	vector<int> before_A = A[0];
	vector<int> after_A(0);
	for (int i = 1; i < N; i++) {
		for (int j : before_A) {
			if (find(A[i].begin(), A[i].end(), j) != A[i].end()) {
				after_A.push_back(j);
			}
		}
		before_A = after_A;
		after_A.clear();
	}

	cout << before_A.size();
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int mod=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	int n,p,cnt=0;
	cin>>n;
	bool f=false;
	rep(i,0,n){
		cin>>p;
		if(!f&&p==i+1){cnt++;f=true;}
		else f=false;
	}
	print(cnt);
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
} 

int q[N];
int mp[1000005];
bool mp1[1000005];
int main(){
    int n;
    n=read();
    rep(i,1,n){
        q[i]=read();
        mp[q[i]]++;
        mp1[q[i]]=1;
    }
    int ans=0;
    rep(i,1,1e6){
        for(int j=1;j<=1e6/i;++j){
            if(mp[i*j]!=0){
                mp[i*j]--;
                if(mp[i]!=0)mp1[i*j]=0;
                mp[i*j]++;
            }
        }
    }
    rep(i,1,n){
        if(mp1[q[i]])ans++;
    }
    cout<<ans;
    return 0;
}
/*
 */

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

int main() {

  int N, r, l, sum=0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> r >> l;
    sum += l - r + 1;
  }
  
  cout << sum << endl;

}

Measured memory_bytes: 3576
N, u, v = map(int, input().split())
u -= 1
v -= 1

e_list = [[] for _ in range(N)]

for _ in range(N - 1):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	e_list[a].append(b)
	e_list[b].append(a)

def calc_depth_table(v):
	queue = [[v, None, 0]]
	depth_table = [0] * N
	depth_table[v] = 0
	
	while queue:
		cur, pre, depth = queue.pop()
		depth += 1
		for n in e_list[cur]:
			if n != pre:
				queue.append([n, cur, depth])
				depth_table[n] = depth
	return depth_table

def calc_depth_table2(depth_from_v, u):
	queue = [[u, None, 0, depth_from_v[u], u]]
	depth_table = [0] * N
	depth_table[u] = (0, depth_from_v[u], u)
	
	while queue:
		cur, pre, depth, min_depth_from_v, min_depth_point = queue.pop()
		depth += 1
		for n in e_list[cur]:
			if n != pre:
				depth2 = depth_from_v[n]
				if min_depth_from_v > depth2:
					new_min_depth = depth2
					new_min_depth_point = n
				else:
					new_min_depth = min_depth_from_v
					new_min_depth_point = min_depth_point
				queue.append([n, cur, depth, new_min_depth, new_min_depth_point])
				depth_table[n] = (depth, new_min_depth, new_min_depth_point)
	return depth_table

depth_from_v = calc_depth_table(v)
depth_from_u = calc_depth_table2(depth_from_v, u)

#print(depth_from_v)
#print(depth_from_u)

max_count = 0
for i in range(N):
	a_dist = depth_from_v[i]
	t_dist, a_hit_dist, hit_pos = depth_from_u[i]
	t_hit_dist = depth_from_u[hit_pos][0]
	
#	print(t_hit_dist, a_hit_dist)
	if t_hit_dist < a_hit_dist:
#		print(t_hit_dist, a_hit_dist)
#		if (a_hit_dist - t_hit_dist) % 2 == 1:
		if max_count < a_dist - 1:
			max_count = a_dist - 1
#			else:
#				

print(max_count)


Measured memory_bytes: 35888
#include <cstdio>

int main(){
	int n, ans;
	while(scanf("%d", &n),n){
		ans = 100000000;
		for(int i = 0; i <= 25; i++){
			for(int j = 0; j <= 20; j++){
				for(int k = 0; k <= 10; k++){
					if(i*200+j*300+k*500==n){
						int tmp;
						tmp = i*380+j*550+k*850-(i/5)*5*380*20/100-(j/4)*4*550*15/100-(k/3)*850*3*12/100;
						if(ans > tmp) ans = tmp;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1028
/*
[abc135] E - Golf
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int K;
int X, Y;
vector<pii> ans;

bool solve() {
    int xs = 1, ys = 1;
    if (X < 0) {
        X = -X;
        xs = -1;
    }
    if (Y < 0) {
        Y = -Y;
        ys = -1;
    }
    bool swapped = false;
    if (X < Y) {
        swap(X, Y);
        swapped = true;
    }

    if (K % 2 == 0 && (X + Y) % 2 == 1) {
        return false;
    }

    if (X + Y < K && (X + Y) % 2 == 1) {
        ans.push_back({X, -K + X});
        ans.push_back({(K + 3 * X - Y) / 2, (-K + X + Y) / 2});
        ans.push_back({X, Y});
    } else if (X + Y == K) {
        ans.push_back({X, Y});
    } else {
        int n = (X + Y < K && (X + Y) % 2 == 0) ? 2 : ((X + Y + K - 1) / K);
        if ((K * n - X - Y) % 2 == 1) {
            n++;
        }
        int x = (-K * (n - 2) + X + Y) / 2, y = (-K * n + X + Y) / 2;
        for (int i = 0; i < n; i++) {
            ans.push_back({x, y});
            int dx = min(X - x, K);
            x += dx;
            y += K - dx;
        }
    }

    for (auto &p : ans) {
        if (swapped) {
            swap(p.first, p.second);
        }
        p.first *= xs, p.second *= ys;
        cerr << p.first << " " << p.second << endl;
    }

    return true;
}

int main() {
    cin >> K;
    cin >> X >> Y;

    if (!solve()) {
        cout << -1 << endl;
        return 0;
    }

    cout << ans.size() << endl;
    for (auto &p : ans) {
        cout << p.first << " " << p.second << endl;
    }

    return 0;
}


Measured memory_bytes: 3952
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const size_t INF=1uLL<<57;

size_t unbounded_knapsack(vector<size_t> w, vector<size_t> v, size_t c) {
    vector<size_t> dp(c+1);
    size_t n=w.size();
    for (size_t i=0; i<n; ++i)
        for (size_t j=w[i]; j<=c; ++j)
            if (dp[j] < dp[j-w[i]] + v[i])
                dp[j] = dp[j-w[i]] + v[i];

    return dp[c];
}

int main() {
    size_t N, W;
    scanf("%zu %zu", &N, &W);

    vector<size_t> v(N), w(N);
    for (size_t i=0; i<N; ++i)
        scanf("%zu %zu", &v[i], &w[i]);

    printf("%zu\n", unbounded_knapsack(w, v, W));
    return 0;
}

Measured memory_bytes: 2820
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=200005;
int n,tp1,tp2,T,ans,f[35];
pii a[N],q1[N],q2[N];
bool cmp1(pii x,pii y){
	return x.se<y.se;
}
bool cmp2(pii x,pii y){
	return 1ll*x.se*(y.fi-1)<1ll*y.se*(x.fi-1);
}
int main(){
	scanf("%d%d",&n,&T);
	For(i,1,n){
		scanf("%d%d",&a[i].fi,&a[i].se);
		a[i].se+=++a[i].fi;
	}
	For(i,1,n){
		if (a[i].fi!=1) q2[++tp2]=a[i];
		if (a[i].fi==1) q1[++tp1]=a[i];
	}
	sort(q1+1,q1+tp1+1,cmp1);
	sort(q2+1,q2+tp2+1,cmp2);
	f[0]=0;
	For(i,1,30) f[i]=T+1;
	For(i,1,tp2) Rep(j,30,1)
		f[j]=min(1ll*f[j],f[j-1]*1ll*q2[i].fi+q2[i].se);
	For(j,0,30) if (f[j]<=T){
		int sum=j,rem=T-f[j];
		For(j,1,tp1) if (rem>=q1[j].se)
			rem-=q1[j].se,sum++;
		ans=max(ans,sum);
	}
	printf("%d\n",ans);
} 
/*
T->(Ai+1)T+Bi
*/


Measured memory_bytes: 4480
# coding: utf-8
# Your code here!
N = int(input())

list = [input() for i in range(N)]

AC = int(0)
TLE = int(0)
WA = int(0)
RE = int(0)

for i in range(N):
    if list[i] == "AC":
        AC = AC + 1
    elif list[i] == "TLE":
        TLE = TLE + 1
    elif list[i] == "WA":
        WA = WA + 1
    else:
        RE = RE + 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 16320
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int x = in.nextInt();
			int y = in.nextInt();
			if(x + y == 0)break;
			if(x < y){
				System.out.println(x + " " + y);
			}else{
				System.out.println(y + " " + x);
			}
		}
	}
}

Measured memory_bytes: 27224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define cs cout << "Case " << ++xx << ": "
#define cS printf("Case %lld:\n",++xx)
#define bitoff(val,pos) val & ~(1ll<<pos)
#define biton(val,pos) val | (1ll<<pos)
#define bittgl(val,pos) val ^ (1ll<<pos)
#define bitchk(val,pos) (bool)(val & (1ll<<pos))
#define odevn(val,pos) (bool)(val & (1ll<<pos))
#define bitcnt(val) __builtin_popcount(val)zz
#define pi acos(-1ll)
#define flot(ds) cout << setprecision(ds) << fixed;
ll drcx[] = {0, 0, -1, 1, 1, 1, -1, -1};
ll drcy[] = {1, -1, 0, 0, 1, -1, 1, -1};
ll xx,fr[300009];
struct strk
{
    ll id1,id2;
} str[300009];
ll bgmod(ll v1, ll v2, ll md)
{
    ll res = 1;
    v1 = v1 % md;
    while (v2 > 0)
    {
        if (v2 & 1)
            res = (res * v1) % md;
        v2 = v2 >> 1;
        v1 = (v1 * v1) % md;
    }
    return res;
}
int main()
{
    ll n;
    cin>>n;
    string st="";
    while(n!=0)
    {
        ll rem=(n%26);
        if(rem==0)
        
            rem=26;
        
        st+=char(rem+96);
        n-=rem;
        n/=26;
    }
    reverse(st.begin(),st.end());
    cout<<st<<endl;
    return 0;
}


Measured memory_bytes: 3624
#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()
using namespace std;
typedef long long ll;

int main() {
  string s,t;
  cin >> s >> t;
  if (s.length()>=1 && s.length()<=10 && t.length() == s.length() + 1 && t.substr(0,s.length())==s) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std; 

string S;
ll cnt, a;

int main() {
	cin >> S;
	for (int i = 0; i < S.size() - 1; ++i) {
		if (S[i] == 'A') {
			++a;
		}
		else if (S[i] == 'B'&&S[i + 1] == 'C') {
			cnt += a;
			++i;
		}
		else a = 0;
	}
	cout << cnt << endl;
}

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

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())
S = input()
K = int(input())

c = S[K - 1]

ans = ""
for a in S:
    ans += c if a == c else '*'


print(ans)


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

int main() {
int N, K, sum = 0;
  cin >> N >> K;
  for (int i =0; i < N; i++) {
    int a;
    cin >> a;
    int b, c;
    c = max( K - a, a - K);
    b = min( 2 * a, 2 * c);
	sum += b;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
X,K,D=map(int,input().split())
a=abs(X)//D
b=abs(X)-a*D
if K<a:
  print(abs(X)-K*D)
else:
  if (K-a)%2==0:
    print(b)
  else:
    print(min(abs(b-D),abs(b+D)))

Measured memory_bytes: 9136
#include <stdio.h>

int main(void){
  int k,n;
  int longn = 0;
  scanf("%d",&k);
  scanf("%d",&n);
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d ",&a[i]);
    if((i == n - 1) && (longn < (k - a[n-1] + a[0]))){
      longn = k -a[n-1] + a[0];
    }
    else if((a[i] - a[i-1])> longn && i > 0){
      longn = a[i] - a[i-1];
    }
  }
  printf("%d\n",k - longn);
  return 0;
}


Measured memory_bytes: 2500
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct unionfind{
  int par[100010]; // 親ノード  必要に応じて要素数を変えよう
  int rank[100010]; // ランク　必要に応じて要素数を変えよう
  unionfind(int n){
    init(n);
  }
  void init(int n){
    for(int i=0;i<=n;i++){
      par[i]=i;
      rank[i]=1;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      return par[x] = root(par[x]);
    }
  }
  int size(int x){
    return rank[root(x)];
  }
  bool same(int x,int y) {
    return root(x) == root(y);
  }
  void unite(int x,int y) {
    x=root(x);
    y=root(y);
    if(x==y){
      return;
    }
    if(rank[x]<rank[y]){
      swap(x,y);
    }
    rank[x]=rank[x]+rank[y];
    par[y]=x;
  }
};
int main(){
  int ans=0,n,m,a[55],b[55],i,j;
  cin >> n >> m;
  for(i=0;i<m;i++){
    cin >> a[i] >> b[i];
  }
  for(i=0;i<m;i++){
    unionfind tree(n+10);
    for(j=0;j<m;j++){
      if(i==j){
        continue;
      }
      tree.unite(a[j],b[j]);
    }
    if(!tree.same(a[i],b[i])){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	string a,b;
	cin >> a >> b;
	if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256