akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	vi a(3);
	rep(i, 3) cin >> a[i];
	sort(all(a));
	int k;
	cin >> k;
	int sum = a[0] + a[1];
	while(k--) a[2] *= 2;
	sum += a[2];
	cout << sum << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

using namespace std;

int main() {
    int N, N1, N2;
    cin >> N;
    int ans = 0;
    for (int N1 = 1; N1 < N; N1++) {
        N2 = N - N1;
        if (N1 >= N2) {
            break;
        }
        ans++;
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {
  string a, b, c; cin >> a >> b >> c;
  char A = a[0] - 'a' + 'A';
  char B = b[0] - 'a' + 'A';
  char C = c[0] - 'a' + 'A';
  cout << A << B << C << endl;
}

Measured memory_bytes: 256
import static java.lang.System.out;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Arrays;
import java.util.stream.Collectors;

class Main {
  public static void main(String...args) throws Exception {
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

    List<Integer> list = stdin.lines()
      .flatMap(
        v -> Arrays.asList(v.split(" ")).stream())
      .mapToInt(Integer::parseInt)
      .boxed()
      .collect(Collectors.toList());

    int area = list.stream()
      .mapToInt(Integer::intValue)
      .reduce(1, (a,b) -> a * b );

    int perimeter = list.stream()
      .mapToInt(Integer::intValue)
      .sum() * 2;

    out.printf("%d %d\n", area, perimeter);

  }
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	string S;
	cin >>S;
	sort(S.begin(), S.end());
	for (int i=1; i<S.size(); i++)
		if (S.at(i)==S.at(i-1)) {
			cout <<"no" <<endl;
			return 0;
		}
	cout <<"yes" <<endl;
	return 0;
}



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

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  vector<vector<char>> b(h+2, vector<char>(w+2));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a.at(i).at(j);
    }
  }
  for(int i=0;i<h+2;i++){
    if(i == 0 || i == h+1){
      for(int j=0;j<w+2;j++){
        b.at(i).at(j) = '#';
      }
    }
    else {
      for(int j=1;j<w+1;j++){
        b.at(i).at(j) = a.at(i-1).at(j-1);
      }
      b.at(i).at(0) = '#';
      b.at(i).at(w+1) = '#';
    }
  }
  
  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      cout << b.at(i).at(j);
    }
    cout << endl;
  }
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N;
    Scd(N);
    vector<pair<string,pair<int,int> > > s(N);
    Rep(i,N){
        cin >> s[i].first;
        Scd(s[i].second.first );
        s[i].second.first *= -1;
        s[i].second.second = i+1;
    }

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

    Rep(i,N){
        printf ("%d\n", s[i].second.second );
    }

    return 0;
}



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

using namespace std;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s = '#' + s + '#';
    bool gyaku = a < b == c < d;
    for (int i = max(a, b); i <= min(c, d); i++) {
        if (s[i - 1] == '.' &&
            s[i] == '.' &&
            s[i + 1] == '.')
            gyaku = true;
    }

    bool can = true;
    for (int i = a; i < c; i++) {
        if (s[i] == '#' && s[i + 1] == '#')
            can = false;
    }
    for (int i = b; i < d; i++) {
        if (s[i] == '#' && s[i + 1] == '#')
            can = false;
    }
    cout << (can && gyaku ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 772
#include <iostream>
using namespace std;
int main(){
    int n, x[109], sum = 0, ans1, ans2;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> x[i], sum += x[i];
    for(int i = 1; i <= n; i++) ans1 += (x[i]-sum/n)*(x[i]-sum/n);
    for(int i = 1; i <= n; i++) ans2 += (x[i]-(sum/n+1))*(x[i]-(sum/n+1));
    if(ans1 < ans2) cout << ans1;
    else cout << ans2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
  
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
  
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
const int N = 100000;
 
int main() {
    int m, a, b;
    VL d(N,1), primes;
    FOR(x,2,N-1){
        if (!d[x]) continue;
        primes.push_back(x);
        int i = 2*x;
        while (i < N) {
            d[i] = 0;
            i += x;
        }
    }
    while (cin >> m >> a >> b && m) {
        int ans = 0;
        int p, q;
        for (int i = 0; primes[i] <= m/2; i++) {
            for (int j = i; primes[i]*primes[j] <= m && a*primes[j] <= b*primes[i]; j++){
                if (primes[i]*primes[j] > ans){
                    ans = primes[i]*primes[j];
                    p = primes[i];
                    q = primes[j];
                }
            }
        }
        cout << p << " " << q << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3744
#include <cstdio>

using namespace std;

int main()
{
  long long a, b;
  char op;

  scanf("%lld %c %lld", &a, &op, &b);
  if (op == '+') {
    printf("%lld\n", a+b);
  } else if (op == '-') {
    printf("%lld\n", a-b);
  }
  return 0;
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
vector < pair < int, int > > g[N];
int u[N];
int c[N];
int cur;

void dfs (int v, int id = 0) {
	u[v] = 1;
	set < int > s;

	if (id)
		s.insert(c[id]);
			
	int now = 1;
	for (auto to : g[v]) if (!u[to.F]) {
		if (now == c[id]) now++;

		c[to.S] = now++;
		dfs(to.F, to.S);
		
	}
	
}  

int main () {
   SpeedForce;
	cin >> n;
	for (int i = 1; i < n; i ++)  {
		int l, r;
		cin >> l >> r;
		g[l].pb({r, i});
		g[r].pb({l, i});
	}
	dfs(1);

	cout << *max_element(c + 1, c + n) << '\n';
	for (int i = 1; i < n; i ++)
		cout << c[i] << '\n';
   return Accepted;
}

// B...a

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, n);
    VEC(int, a, n);
    sort(ALL(a));
    reverse(ALL(a));
    int al = 0, bo = 0;
    RREP(i, n){
        (i % 2 ? bo : al) += a[i];
    }
    OUTL(al - bo);
RET;}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	//static int[] dp;
	static void Main(string[] args)
	{
			// 入力フェーズ
			//int N = Int32.Parse(Console.ReadLine());
			string[] input = Console.ReadLine().Split(' '); // N,K
			int N = Int32.Parse(input[0]);
			int K = Int32.Parse(input[1]);

			// a1,a2,...aNを読み込む
			input = Console.ReadLine().Split(' ');
			int[] array = new int[N];
			for(int i=0; i<N; i++)
			{
				array[i] = Int32.Parse(input[i]);
			}

			int[] dp = new int[K+1]; // dpテーブル
			// i個石がある時に先手が勝てる場合は1, 負ける場合は0
			dp[0] = 0; // 初期値

			for(int i=0; i<=K; i++)
			{
				// 先手が負ける状態に出来れば＝後手になれれば勝てるから
				// 負け確定したところからajを配る
				if(dp[i] == 0)
				{
					for(int j=0; j<N; j++)
					{
						if(i+array[j]<=K)
						{
							// Kに収まることをチェック
							dp[i+array[j]] = 1;
						}
					}
				}
			}

			if(dp[K] == 0)
				Console.WriteLine("Second");
			else
				Console.WriteLine("First");
    }
}


Measured memory_bytes: 13132
n, yen = map(int, input().strip().split())

y_minus_1000n = yen - 1000 * n
x_max = yen // 10000

d = [-1, -1, -1]
for x in range(x_max + 1):
    temp = y_minus_1000n - 9000 * x
    if temp % 4000:
        continue
    y = temp / 4000
    z = n - x - y
    if x >= 0 and y >= 0 and z >= 0:
        d[0] = x
        d[1] = y
        d[2] = z
        break

print(' '.join([str(int(x)) for x in d]))


Measured memory_bytes: 3064
//
//  main.cpp
//  競技20190629

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <regex> //正規表現
#include <map>
#include <set>
#include <cassert> //assart
using namespace std;
#define ll long long int
#define FOR(i,min,max) for(int i=(min);i<(max);i++)
#define FOReq(i,min,max) for(int i=(min);i<=(max);i++)
#define FORREV(i,max,min) for(int i=(max)-1;i>=(min);i--)
const int  MOD=1000000007;
const int  INF=2000000000;
const int INF2=  10000000;
const double  Micro=1e-5;

int UnUsedVariable(){
    if(INF || Micro || MOD || INF2){;}
    return 0;
}

#define pf printf
#define sf scanf
#define inarray(array,min,max) FOR(i,min,max){in(array[i]);}
#define inarrayW(arrayA,arrayB,min,max) FOR(i,min,max){in(arrayA[i]);in(arrayB[i]);}
inline int isEven(int x){return x%2==0;}
inline int isOdd (int x){return x%2==1;}
#define br printf("\n");
#define OutputAndReturn(x) {cout<<(x)<<endl;return 0;}

ll printintN(ll array[],const int num){
    for(int i=0;i<num;i++){printf("%lld ",array[i]);}
    br;
    return 0;
}


//#define int long long int

/*
 1.困った時こそ冷静に問題文を見直す！制約条件を見ろ！乱択アルゴリズムとかO(N^3)とか！
 2.一度に大量のことをやろうとしない。デバッグしやすいように細かく！
 3.プログラミングは半分数学だし、もう半分は数学ではない！
 4.できない問題はできない！！！！！
 */

int tekitou(){
    int n,l;
    cin>>n>>l;
    int sum=0;
    FOR(i, l, l+n){sum+=i;}
    //cout<<"sum is "<<sum;br;
    if(l<=0 and n>abs(l))OutputAndReturn(sum);
    if(l<0)OutputAndReturn(sum-(l+n-1));
    if(l>0)OutputAndReturn(sum-l);
    assert(0);
    
    
    
    
    return 0;
}
signed main(){
    assert(1);
    tekitou();
    //Ap();
    //Bp();
    //Cp();
    //Dp();
    //Ep();
    //Fp();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;

  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
using namespace std;
#define MAX 100005
#define MOD 998244353
#define EPS 0.0000000001
#define INF 1000000000000000
long long segment_tree[MAX*4],d[MAX];
void build(int index,int l,int r)
{
    if(l==r)
    {
        segment_tree[index]=INF;
        d[l]=INF;
        return;
    }
    int m=(l+r)/2;
    build(index*2,l,m);
    build(index*2+1,m+1,r);
    segment_tree[index]=INF;
}
void update(int index,int l,int r,int L,int R,long long val)
{
    if(l>R||r<L) return;
    if(L<=l&&r<=R)
    {
        segment_tree[index]=min(segment_tree[index],val);
        return;
    }
    int m=(l+r)/2;
    update(index*2,l,m,L,R,val);
    update(index*2+1,m+1,r,L,R,val);
}
long long query(int index,int l,int r,int ind,long long val=INF)
{
    segment_tree[index]=min(segment_tree[index],val);
    if(ind<l||ind>r) return INF;
    if(l==r)
    {
        return segment_tree[index];
    }
    int m=(l+r)/2;
    long long first=query(index*2,l,m,ind,segment_tree[index]);
    long long second=query(index*2+1,m+1,r,ind,segment_tree[index]);
    return min(first,second);
}
vector<pair<int,long long> > V[MAX];
int main()
{
    int N,M,i,j;
    pair<int,long long> p;
    scanf("%d %d",&N,&M);
    build(1,0,N-1);
    update(1,0,N-1,0,0,0);
    for(i=0;i<M;i++)
    {
        scanf("%d %d %lld",&j,&p.first,&p.second);
        j--;
        p.first--;
        V[j].push_back(p);
    }
    for(i=0;i<N;i++)
    {
        d[i]=query(1,0,N-1,i);
        for(j=0;j<V[i].size();j++)
        {
            update(1,0,N-1,i,V[i][j].first,d[i]+V[i][j].second);
        }
    }
    if(d[N-1]>=INF)
    {
        printf("-1");
    }
    else
    {
        printf("%lld",d[N-1]);
    }
    return 0;
}


Measured memory_bytes: 9472
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    vector<int> niz(n), res(n);
    for (int i = 0; i < n; i++)
        cin >> niz[i];

    for (int i = 0; i < n; i++)
    {
        res[niz[i] - 1] = i + 1;
    }
    for (auto x : res)
        cout << x << " ";
}

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

int n;
int v[101];
int minvalue = 1e9, minnum = 0, maxvalue = -1;

bool solve(){
	cin >> n;
	for(int i=0; i<n; ++i){
		int a;
		cin >> a;
		if(minvalue > a){
			minvalue = a;
			minnum = 1;
		}else if(minvalue == a){
			minnum++;
		}
		maxvalue = max(maxvalue, a);
		++v[a];
	}
	if(minnum >= 3) return false;
	if(minnum == 2){
		if(maxvalue > 2*minvalue-1) return false;
		for(int i=minvalue+1; i<=2*minvalue-1; ++i)
			if(v[i] < 2)
				return false;
	}else{
		if(maxvalue > 2*minvalue) return false;
		for(int i=minvalue+1; i<=2*minvalue; ++i)
			if(v[i] < 2)
				return false;
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	if(solve()) cout << "Possible\n";
	else cout << "Impossible\n";
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  d := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&d[i])
  }
  for i := 0; i < n-1; i++ {d[i+1] += d[i]}
  res := 0
  for i := n-1; i > 0; i-- {
    res += (d[i] - d[i-1]) * d[i-1]
  }
  fmt.Println(res)
}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

ll k;

P calc(ll x, ll y) {
  if (x < 0) {
    P ans = calc(-x, y);
    ans.first *= -1;
    return ans;
  }
  if (y < 0) {
    P ans = calc(x, -y);
    ans.second *= -1;
    return ans;
  }
  if (y > x) {
    P ans = calc(y, x);
    swap(ans.first, ans.second);
    return ans;
  }

  ll d = abs(x) + abs(y);
  ll nx = x, ny = y;

  ll sp = d % k;
  if (sp == 0) {
    ny = max(0ll, y - k);
    ll kk = k - abs(ny - y);
    nx -= kk;
  } else if (k % 2 == 0 || sp % 2 == 1) {
    if (d < k) {
      if (sp % 2 == 1) {
        nx += k;
      } else {
        sp = k - sp;
        ny += sp;
        nx -= (k - sp) / 2;
        ny += (k - sp) / 2;
      }
    } else {
      nx -= sp;
      nx -= (k - sp) / 2;
      ny += (k - sp) / 2;
    }
  } else {
    sp = k - sp;
    ny += sp;
    nx -= (k - sp) / 2;
    ny += (k - sp) / 2;
  }
  return make_pair(nx, ny);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll x, y;
  cin >> k >> x >> y;

  if ((abs(x) + abs(y)) % 2 == 1 && k % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  vector<P> ans;
  ans.emplace_back(x, y);
  while (x || y) {
    auto np = calc(x, y);
    // update
    x = np.first;
    y = np.second;
    ans.emplace_back(x, y);
  }

  reverse(all(ans));
  cout << ans.size() - 1 << endl;
  for (auto it : ans) {
    if (it.first == 0 && it.second == 0)
      continue;
    cout << it.first << " " << it.second << endl;
  }

  return 0;
}


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

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

int main(){
  int a,b;
  cin >> a >> b;

  cout << max(a+b, max(a-b, a*b));
}

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

using namespace std;
using ll = long long;

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

int main() {
  int n;
  cin >> n;
  vector<mint> as(n);
  vector<mint> sums(n);
  mint a;
  rep(i, n) {
    cin >> a;
    as[i] = a;
    if (i == 0) {
      sums[i] = a;
    } else {
      sums[i] = sums[i - 1] + a;
    }
  }
  mint sum = 0;
  rep(i, n) { sum += as[i] * (sums[n - 1] - sums[i]); }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int w, h, xs, ys, xg, yg, n, c, d, x, y, b[101][101];
int dx[] = {0, -1, 0, 1}, dy[] = {-1, 0, 1, 0};

bool dfs(int x, int y){
    int nx, ny;
    b[x][y] = 0;
    if(x == xg && y == yg) return true;
    bool r = 0;
    rep(i, 4){
        nx = x + dx[i]; ny = y + dy[i];
        if(nx > 0 && nx <= h && ny > 0 && ny <= w && b[nx][ny]==c)r=r||dfs(nx, ny);
    }
    return r;
}

int main(){
    while(cin >> w >> h, w||h){
        memset(b, 0, sizeof(b));
        cin >> ys >> xs >> yg >> xg >> n;
        rep(i,n){
            int c, d, x, y;
            cin >> c >> d >> y >> x;
            rep(j, (d?4:2)) rep(k, (d?2:4)) b[x + j][y + k] = c;
        }
        c = b[xs][ys];

        if(c > 0 && dfs(xs, ys)) cout << "OK" << endl;
        else cout << "NG" << endl;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void solve()
{ll t,n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
  cin>>n;k=2;
  vector<ll> v(n+1,0),dp(n+1,INT_MAX);
  for(ll i=1;i<=n;i++)
  cin>>v[i];
  dp[0]=0;
  dp[1]=0;
  
  		for(ll j=1;j<=n;j++)
  		{
  			for(ll r=1;r<=k&&(j-r)>=1;r++)
  			dp[j]=min(dp[j],dp[j-r]+abs(v[j]-v[j-r]));
		}
  
  cout<<dp[n]<<" ";

}

int main()
{

ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

#include "atcoder/all"

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef modint1000000007 mint;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll K;
    cin >> K;
    rep(0, i, K)
    {
        cout << "ACL";
    }
    cout << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main() {
  cin.sync_with_stdio(false);
  int n, m, t;
  cin >> n >> m >> t;
  int v[t + 1];
  memset(v, 0, sizeof(v));
  rep(i, n) {
    int a;
    cin >> a;
    v[max(0, a - m)]++;
    v[min(t, a + m)]--;
  }
  int ans = 0;
  repl(i, 1, t + 1) {
    v[i] += v[i - 1];
    if (v[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int count_2(int x) {
  int ans = 0;
  while(x % 2 == 0) {
    ans++;
    x /= 2;
  }
  return ans;
}
int power_2(int x) {
  if(x == 0) {
    return 1;
  }
  else {
  	int ans = 1;
  	for(int i = 0; i < x; i++) {
      ans *= 2;
    }
    return ans;
  }
}
int main() {
  int N;
  cin >> N;
  int num = 0;
  for(int i = 1; i <= N; i++) {
    if(count_2(i) > num) {
      num = count_2(i);
    }
  }
  cout << power_2(num) << endl;
}

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

double abso(double x)
{
	if(x<0)return -x;
	return x;
}
int main()
{
	int N,T,A;
	int H[1010]={};
	double Min=1e9;
	int ans=1;
	
	cin >> N >> T >> A;
	for(int i=1;i<=N;i++)
	{
		cin >> H[i];
	}
	Min=abso(A-(T-H[1]*0.006));
	for(int i=1;i<=N;i++)
	{
		//cout << Min << ",";
		//cout << abso(A-(T-H[i]*0.006)) << endl;
		if(abso(A-(T-H[i]*0.006))<Min)
		{
			ans=i;
			Min=abso(A-(T-H[i]*0.006));
		}
	}
	cout << ans << endl;
	return 0;
}


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

int n, k; 
long long ans = 1, st[400009], md = 1000000007;
vector<int> v[100009];

void init(int tn, int s, int e)
{
	if (s == e) st[tn] = s;
	else {
		int m = (s + e) / 2;
		init(tn * 2, s, m); init(tn * 2 + 1, m + 1, e);
		st[tn] = (st[tn * 2] * st[tn * 2 + 1]) % md;
	}
}

long long qry(int tn, int s, int e, int ts, int te)
{
	if (e < ts || te < s) return 1LL;
	if (ts <= s && e <= te) return st[tn];
	int m = (s + e) / 2;
	return (qry(tn * 2, s, m, ts, te) * qry(tn * 2 + 1, m + 1, e, ts, te)) % md;
}

void dfs(int hn, int p) 
{
	int c = 0;
	for (int i = 0; i < v[hn].size(); i++) {
		int tn = v[hn][i];
		if (tn == p) continue;
		c++; dfs(tn, hn);
	}
	int r = 0;
	if (p != -1) r = 2;
	else c++;
	if (c + r > k) ans = 0;
	else {
		if (c <= 0) return;
		int t = k - r;
		ans = (ans * qry(1, 1, k, t - c + 1, t)) % md;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 1; i < n; i++) {
		int a, b; cin >> a >> b;
		v[a].push_back(b); v[b].push_back(a);
	}
	init(1, 1, k);
	dfs(1, -1);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;



int main() {
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    int p2=1<<m;
    
    cout<<((1900*m +100*(n-m))*p2);
    
    return 0;
    
}

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

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

	for(int i = 0; i < n; i++){
		cin >> s;
		cout << "Case " << i+1 << ":" << endl;
		for(int i = 0; i < 10; i++){
			s *= s;
			s /= 100;
			s %= 10000;
			cout << s << endl;
		}
	}

}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    constexpr int64_t mod = 1000000000 + 7;

    int64_t n; cin >> n;
    if (n < 2) {
        cout << 0 << endl;
        return 0;
    }

    int64_t a = 1, b = 1, c = 1;
    for (int i = 0; i < n; ++i) a = (a * 10) % mod;
    for (int i = 0; i < n; ++i) b = (b * 9) % mod;
    for (int i = 0; i < n; ++i) c = (c * 8) % mod;

    int64_t ans = a - 2 * b;
    while (ans < 0) ans += mod;
    ans = (ans + c) % mod;

    cout << ans << endl;
}



Measured memory_bytes: 3576
#include <cstdio>
#include <utility>
#include <algorithm>

using namespace std;

char peek(){
    auto c=getchar();
    ungetc(c,stdin);
    return c;
}

pair<int,int> foldor();

pair<int,int> foldand();

pair<int,int> foldbase();

pair<int,int> foldor(){
    auto res=foldand();
    while (peek()=='|'){
        getchar();
        auto temp=foldand();
        auto trueCost=min(res.first,res.second+temp.first);
        auto falseCost=res.second+temp.second;
        res=pair<int,int>(trueCost,falseCost);
    }

    return res;
}

pair<int,int> foldand(){
    auto res=foldbase();
    while (peek()=='&'){
        getchar();
        auto temp=foldbase();
        auto trueCost=res.first+temp.first;
        auto falseCost=min(res.second,res.first+temp.second);
        res=pair<int,int>(trueCost,falseCost);
    }

    return res;
}

pair<int,int> foldbase(){
    if (peek()=='('){
        getchar();
        auto temp=foldor();
        getchar();
        return temp;
    }
    getchar();
    return pair<int,int>(1,1);
}


int main(){

    auto res=foldor();

    printf("%d %d\n",res.second,res.first);

    return 0;
}


Measured memory_bytes: 2700
#include <cstdio>
#include <bitset>
std::bitset<405> mask[405];
int x[100005], y[100005];
bool die[405];
int main()
{
	// freopen("AGC016-E.in", "r", stdin);
	int n, m, ans = 0;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d", x + i, y + i);
		x[i]--;
		y[i]--;
	}
	for (int i = 0; i < n; i++)
	{
		mask[i][i] = 1;
		for (int j = m - 1; j >= 0; j--)
		{
			if (mask[i][x[j]] && mask[i][y[j]])
				die[i] = true;
			else if (mask[i][x[j]])
				mask[i][y[j]] = true;
			else if (mask[i][y[j]])
				mask[i][x[j]] = true;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
			ans += !die[i] && !die[j] && !(mask[i] & mask[j]).count();
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
N=int(input())
a=list(map(int,input().split()))
s=[a[0]]
for i in range(1,N):
    s.append(s[i-1]+a[i])
tmp=s[-1]
ans=int(10e+9)
for i in range(N-1):
    ans=min(ans,abs((tmp-s[i]*2)))
print(ans)

Measured memory_bytes: 24812
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,g,b,n;
    cin>>r>>g>>b>>n;
    ll dp[3001]={0};
    dp[0]=1;
    for(int i=r;i<=n;i+=r){
        dp[i]+=dp[i-r];
    }
    for(int i=g;i<=n;i++){
        dp[i]+=dp[i-g];
    }
    for(int i=b;i<=n;i++){
        dp[i]+=dp[i-b];
    }
    cout << dp[n]<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main{ 	
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int a[]=new int[N];
		for(int i=0;i<a.length;i++){
			a[i]=sc.nextInt();
		}
		for(int j=0;j<a.length-1;j++){
			for(int i=1;i<a.length;i++){
				if(a[i-1]>a[i]){
					int tmp=a[i];
					a[i]=a[i-1];
					a[i-1]=tmp;
				}
			}
		}
		int count=0;
		for(int i=0;i<a.length;i++){
			x-=a[i];
			if(x<0){
				break;
			}
			count++;	
		}
		if(x>0){
			count--;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22228
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=17;
const int M=(1<<15)+2;
int dp[M][N],E[N][N],sum[M],all,n,m;

template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}

inline void addedge(int u=0,int v=0,int w=0)
{IN(u),IN(v),IN(w),--u,--v,all+=w,E[u][v]=E[v][u]=w;}
int main() {
    IN(n),IN(m);
    for(int i=1;i<=m;++i) addedge();
    int lim=1<<n;
    for(int S=1;S<lim;++S)
        for(int i=0;i<n;++i) if(S&(1<<i))
            for(int j=i+1;j<n;++j) if(S&(1<<j))
                sum[S]+=E[i][j];
    for(int S=0;S<lim;++S) for(int t=0;t<n;++t) dp[S][t]=-1e9;
    dp[1][0]=0;
    for(int S=1;S<lim;++S) for(int t=0;t<n;++t) if(S&(1<<t)) {
        for(int u=0;u<n;++u) if(!(S&(1<<u))&&E[t][u])
            dp[S|(1<<u)][u]=max(dp[S|(1<<u)][u],dp[S][t]+E[t][u]);
        int P=(lim-1)^S;
        for(int T=P;T;T=(T-1)&P)
            dp[S|T][t]=max(dp[S|T][t],dp[S][t]+sum[T|(1<<t)]);
    }
    printf("%d\n",all-dp[lim-1][n-1]);
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1 << 30;

using P = pair<int,int>;


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int pos, hoge = 0;
    rep(i,n) if(chmax(hoge,abs(a[i]))) pos = i;
    if(hoge == 0) {cout << 0 << endl; return 0;}

    vector<P> res;
    if(a[pos] > 0) {
        rep(i,n) {
            if(i == 0) res.emplace_back(i,pos);
            else res.emplace_back(i,i-1);
        }
    } else {
        drep(i,n) {
            if(i == n-1) res.emplace_back(i,pos);
            else res.emplace_back(i,i+1);
        }
    }

    cout << 2*n << endl;
    for(auto [s,t] : res) {
        rep(j,2) cout << t+1 << " " << s+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int digit = n.length();
        long ans = 0;
        char[] a = n.toCharArray();
        int[] ai = new int[digit+1];
        for(int i = 0; i < digit; i++){
            ai[i] = a[digit-1-i] -48;
        }
        for(int i = 0; i < digit; i++){
            if(ai[i] < 5){
                ans += ai[i];
            }else if(ai[i] == 5){
                if(ai[i+1] < 5) {
					ans += ai[i];
				} else {
					ans += 10 - ai[i];
					ai[i+1]++;
				}
            }else{
                ans += 10-ai[i];
                ai[i+1]++;
            }
        }
        System.out.println(ans+ai[digit]);
    }
}

Measured memory_bytes: 40764
import sys
input = sys.stdin.readline
from itertools import product

def main():
    abcd = input()
    a = abcd[0]
    b = abcd[1]
    c = abcd[2]
    d = abcd[3]

    p = product(('+','-'), repeat = 3)
    for ep in p:
        siki = "".join([a,ep[0],b,ep[1],c,ep[2],d])
        if eval(siki) == 7:
            r = siki + "=7"
            print(r)
            sys.exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val strings = mutableMapOf<String, Int>()
    val n = readLine()!!.toInt()
    repeat(n) {
        val s = readLine()!!
        if (s in strings) strings[s] = strings[s]!! + 1 else strings[s] = 1
    }
    val m = readLine()!!.toInt()
    repeat(m) {
        val s = readLine()!!
        if (s in strings) strings[s] = strings[s]!! - 1
    }
    println(Math.max(0, strings.values.max()!!))
}


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

typedef long long ll;
const ll N = 4e5 + 77;
const ll inf = 1e18;

int main()
{
  ll n, a[N], ans = 1;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%lld", a + i);
    if (a[i] == 0)
      ans = 0;
  }
  for (int i = 0; i < n; i++)
  {
    if (a[i] == 0)
      continue;
    if (ans > inf / a[i])
    {
      ans = -1;
      break;
    }
    ans = ans * a[i];
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 4612
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	int[][] h = new int[2][];
	int[][] r = new int[2][];
	int[][] hr;

	void solve() {
		int n = sc.nextInt();
		if (n == 0) return;
		h[0] = new int[n];
		r[0] = new int[n];
		for (int i = 0; i < n; i++) {
			h[0][i] = sc.nextInt();
			r[0][i] = sc.nextInt();
		}
		int m = sc.nextInt();
		h[1] = new int[m];
		r[1] = new int[m];
		for (int i = 0; i < m; i++) {
			h[1][i] = sc.nextInt();
			r[1][i] = sc.nextInt();
		}

		hr = new int[n + m][2];
		for (int i = 0; i < n + m; i++) {
			hr[i][0] = i < n ? h[0][i] : h[1][i-n];
			hr[i][1] = i < n ? r[0][i] : r[1][i-n];
		}

		Arrays.sort(hr, new Comparator<int[]>(){
			public int compare(int[] a, int[] b){
				if (a[0] != b[0]) return a[0] - b[0];
				return a[1] - b[1];
			}
		});

		int[] dp = new int[hr.length];

		dp[0] = 1;
		for (int i = 1; i < hr.length; i++) {
			for (int j = 0; j < i; j++) {
				if (hr[j][0] < hr[i][0] && hr[j][1] < hr[i][1])
					dp[i] = Math.max(dp[i], 1 + dp[j]);
			}
		}
		int res = 0;
		for (int i = 0; i < hr.length; i++) {
			res = Math.max(res, dp[i]);
		}
		out.println(res);
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		for (;sc.hasNext();) {
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 19848
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

int main() {
    ll n, m;
    cin >> n >> m;    
    
    vvl G(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    // BFS。計算量はO(V+E)
    vl dist(n, -1);  // dist[v] : 頂点svから頂点vへの最短距離(-1のとき未訪問)
    queue<ll> Q;
    const ll sv = 0;  // BFSを始める頂点
    dist[sv] = 0;
    Q.push(sv);
    while(!Q.empty()) {
        ll v = Q.front();  Q.pop();
        for(ll u : G[v]) {
            if(dist[u] == -1) {
                dist[u] = dist[v] + 1;
                Q.push(u);
            }
        }
    }

    if(dist[n-1] == 2) {
        out("POSSIBLE");
    }
    else {
        out("IMPOSSIBLE");
    }

    re0;
}

Measured memory_bytes: 18224
import java.util.Scanner;

public class Main {
	static boolean[] acFlag;
	static int[] waAry;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		acFlag = new boolean[n];
		waAry = new int[n];
		int m = sc.nextInt();
		for(int i = 0; i < m; i++){
			int num = sc.nextInt() - 1;
			String s = sc.next();
			if(! acFlag[num]){
				if("AC".equals(s)){
					acFlag[num] = true;
				}else{
					waAry[num]++;
				}
			}
		}
		int acNum = 0;
		int waNum = 0;
		for(int i = 0; i < n; i++){
			if(acFlag[i]){
				acNum++;
				waNum += waAry[i];
			}
		}
		System.out.println(acNum + " " + waNum);
	}
}


Measured memory_bytes: 65772
def each_digit_sum(num):
    sum_list = [int(x) for x in list(str(num))]
    min_sum = 0
    for y in sum_list:
         min_sum = min_sum + y
    return min_sum


sum = int(input())
ans = 0
for i in range(1,sum):
    A = i
    B = sum - i
    tmp_ans = each_digit_sum(A)+each_digit_sum(B)
    if(ans == 0 or tmp_ans<ans):
        ans = tmp_ans
print(ans)

Measured memory_bytes: 3064
N=int(input())

red=[]
for _ in range(N):
    a,b=map(int,input().split())
    red.append([a,b])
red.sort(key=lambda x:x[1])
red.sort(key=lambda x:x[0])

blue=[]
for _ in range(N):
    c,d=map(int,input().split())
    blue.append([c,d])
blue.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])


ans=0
for i in range(N):
    mx,log=0,-1
    for j in range(N):
        #print(i,blue[i],red[j])
        if blue[i][0]<=red[j][0]:
            continue                    
        if blue[i][1]>red[j][1]:
            mx=max(red[j][1],mx)
            if mx==red[j][1]:
                log=j
    if log!=-1:
        red[log]=[10**9,10**9]
        ans+=1        
        


#print(red)
#print(blue)
print(ans)

Measured memory_bytes: 3064
import math
q=int(input())

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime=[0]*(10**5+1)
prime_lst=get_sieve_of_eratosthenes(10**5)
for i in prime_lst:
    prime[i]+=1

a=[0]*(10**5+1)
for i in range(3,10**5+1):
    if prime[i]==1 and prime[(i+1)//2]==1:
        a[i]+=1

for i in range(1,10**5+1):
    a[i]=a[i-1]+a[i] 

for i in range(q):
    l,r=map(int,input().split())
    print(a[r]-a[l-1])

Measured memory_bytes: 14100
# coding: utf-8


def main():
    S = input()
    N = len(S)
    ans = 0
    if N == 1:
        ans = int(S)
    else:
        if S[1:] == "9" * (N - 1):
            ans += 1
        ans += int(S[0]) - 1
        ans += 9 * (N - 1)

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string S;
    cin>>S;
    ll pasos = 0;
    for(int i = 0;i<S.size()-1;i++){
        if(S[i] == 'B'){
            int W = S.find('W',i);
            if(W >i && W<2*S.size()){
                pasos += W - i;
                swap(S[i],S[W]);
            }
        }
    }
    cout<<pasos<<"\n";


    return 0;
}


Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
const int N=5005,mod=1e9+7;
typedef long long ll;
int n,m,dp[N][N];
int main()
{
    //int p[N];p[0]=1;for(int i=1;i<N;i++) p[i]=(p[i-1]<<1)%mod;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++) dp[0][i]=1;
    for(int i=1;i<=n;i++)
        for(int j=1,sum=0;j<=m;j++)
    {
        dp[i][j]=(dp[i][j]+(ll)dp[i-1][j]*(j+1)+sum)%mod;
        sum=(sum*2%mod+(ll)dp[i-1][j]*j)%mod;
        //dp[i][j]=(dp[i][j]+(ll)(dp[i][j-1]-(ll)dp[i-1][j-1]*j%mod+mod)%mod*2%mod+(ll)dp[i-1][j-1]*(j-1))%mod;
        /*
        for(int k=2;k<=j;k++)
            dp[i][j]=(dp[i][j]+(ll)dp[i-1][j-k+1]*(j-k+1)%mod*p[k-2]%mod)%mod;
        */
    }
    printf("%d\n",dp[n][m]);
}


Measured memory_bytes: 101516
#include <iostream>

using namespace std;

int main() {
	char C1[4];
	char C2[4];
	cin >> C1[1] >> C1[2] >> C1[3];
	cin >> C2[1] >> C2[2] >> C2[3];
	if ((C1[1] == C2[3]) && (C1[2] == C2[2]) && (C1[3] == C2[1])) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

bool n, s, e, w;

void solve();

int main() {
   solve();
   return 0;
}

void solve() {
	n = false;
	s = n;	e = n;	w = n;
	char buf;
	while (cin >> buf) {
		n = n || (buf == 'N');
		s = s || (buf == 'S');
		w = w || (buf == 'W');
		e = e || (buf == 'E');
		//cout << buf << ":" << n << s << w << e << endl;
	}
	cout << ((!(n^s))&&(!(e^w)) ? "Yes" : "No") << endl;
}

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

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

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll d,n,m;
ll st[100010];
ll cus[10010];

int main()
{while(1){
	ll ans=0;
	cin>>d;
	if(!d) return 0;
	cin>>n>>m;
	st[0]=0;
	rep1(i,n-1) cin>>st[i];
	st[n]=d;
	sort(st,st+n+1);
	rep(i,m){
		cin>>cus[i];
		ans+=min(*lower_bound(st,st+n+1,cus[i])-cus[i] , cus[i] - *(lower_bound(st,st+n+1,cus[i])-1) );
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 3892