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

using namespace std;

#define sp << " " <<
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define int long long
#define double long double
#define INF 1e18
#define PI 3.14159265359

int power(int p,int y)
{
    int res=1;
    p=p%mod;
    while(y>0)
    {
        if(y&1)
            res=(res*p)%mod;
        y=y>>1;
        p=(p*p)%mod;
    }
    return res;
}

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

int dice()
{
    uniform_int_distribution<int> uid(0,1);//specify l and r.
    return uid(rng) ;
}

int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int dp = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          dp = dp * 10 + cc - '0';
          cc = getc(stdin);
       }
      return dp;
}

inline void print(int n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[20];
    buf[19] = '\n';
    int i = 18;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}

int n;

vector<vector<int>> mat_mul(vector<vector<int>> a,vector<vector<int>> b)
{
	vector<vector<int>> t(n,vector<int>(n,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				t[i][j]+=((a[i][k]*b[k][j])%mod);
				t[i][j]%=mod;
			}
		}
	}
	return t;
}

vector<vector<int>> pow_mat(vector<vector<int>> mat_a,int p)
{
	if(p==1)
        return mat_a;
	vector<vector<int>> temp=pow_mat(mat_a,p/2);
	vector<vector<int>> res=mat_mul(temp,temp);
	if(p&1)
        res=mat_mul(res,mat_a);
	return res;
}
*/

int d[105][100013],p[105][100013];

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin >> a[i];
	d[0][0]=1;
	for(int i=1;i<=n;i++)
    {
		p[i-1][0]=1;
		for(int j=1;j<=k;j++)
			p[i-1][j]=(p[i-1][j-1]+d[i-1][j])%mod;
		for(int j=0;j<=k;j++)
			d[i][j]=(p[i-1][j]-p[i-1][j-min(j,a[i])-1]+mod)%mod;
	}
	cout << d[n][k] << endl;
}


Measured memory_bytes: 160000
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	string ret = "No";
	if(N[0] == N[2])
		ret = "Yes";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        int[][] array = new int[n][2];
        for (int i = 0; i < n; i++) {
            array[i][0] = sc.nextInt();
            array[i][1] = sc.nextInt();
        }
        Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));    // foo[][0]で
        
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (m <= array[i][1]) {
                ans += (long)array[i][0] * m;
                break;
            } else {
                ans += (long)array[i][0] * array[i][1];
                m -= array[i][1];
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 92836
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

struct Info{
	Info(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}

	int to,cost;
};

void func(int num_ticket,int num_town,int E,int start,int goal){

	int limit,tmp;

	limit = pow(2,num_ticket);

	double dp[limit][num_town+1];

	for(int i = 0; i < limit; i++){
		for(int k = 1; k <= num_town; k++)dp[i][k] = (double)BIG_NUM;
	}

	vector<Info> V[num_town+1];

	int ticketTable[num_ticket];

	for(int i = 0; i < num_ticket; i++){
		scanf("%d",&ticketTable[i]);
	}

	int from,to,cost;

	for(int i = 0; i < E; i++){
		scanf("%d %d %d",&from,&to,&cost);
		V[from].push_back(Info(to,cost));
		V[to].push_back(Info(from,cost));
	}

	dp[0][start] = 0.0;

	int count;

	while(true){
		count = 0;

		for(int state = 0; state < limit;state++){
			for(int town = 1;town <= num_town; town++){
				if(dp[state][town] != (double)BIG_NUM){
					for(int k = 0; k < num_ticket;k++){
						if(state & (1 << k)){
							//Do nothing
						}else{

							for(int a = 0; a < V[town].size();a++){
								tmp = state + pow(2,k);
								if(dp[tmp][V[town][a].to] > dp[state][town] + (double)V[town][a].cost/(double)ticketTable[k]){
									dp[tmp][V[town][a].to] = dp[state][town] + (double)V[town][a].cost/(double)ticketTable[k];
									count++;
								}
							}
						}
					}
				}
			}
		}

		if(count == 0)break;
	}

	double minimum = (double)BIG_NUM;

	for(int i = 0; i < limit; i++){
		minimum = min(minimum,dp[i][goal]);
	}

	if(minimum > 1500000000.0){
		printf("Impossible\n");
	}else{
		printf("%.3lf\n",minimum);
	}
}

int main(){

	int num_ticket,num_town,E,start,goal;
	while(true){
		scanf("%d %d %d %d %d",&num_ticket,&num_town,&E,&start,&goal);
		if(num_ticket == 0 && num_town == 0 && E == 0 && start == 0 && goal == 0)break;

		func(num_ticket,num_town,E,start,goal);
	}

	return 0;
}

Measured memory_bytes: 2916
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	vector<pair<int, int> > cans(n);
	int a, b;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		cans[i] = {a, b};
	}

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

	long long money = 0;
	int curr_cans = 0;
	int i = 0;
	while (i < n && m) {
		curr_cans = min(m, cans[i].second);
		money += (long long) curr_cans * cans[i].first;
		m -= curr_cans;
		++i;
	}

	cout << money << "\n";

	return 0;

}

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

int main()
{
  char a[3][3];
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  cout << a[0][0] << a[1][1] << a[2][2] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int sum = 0;
        int ans[] = new int[N];
        for(int a=0;a<N;a++)
        {
            ans[a] = 0;
        }
        for(int i=0;i<K;i++)
        {
            int d = sc.nextInt();
            for(int j=0;j<d;j++)
            {
                int A = sc.nextInt();
                if(ans[A-1]==0)
                {
                    ans[A-1] = A;
                }
            }
        }
        for(int b=0;b<N;b++)
        {
            if(ans[b]==0)
            {
                sum++;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 46504
#include <iostream>

using namespace std;

int H, W;
string field[55];

int main() {
  
  cin >> H >> W;
  cin.ignore();
  
  for(int i=0; i<H; i++) {
    getline(cin, field[i]);
  }
  
  int dp[55][55] = {};
  
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      if(i == 0) {
	if(j == 0) dp[0][0] = 0;
	else dp[i][j] += dp[i][j-1] + (field[i][j] - '0');
      }
      else if(j == 0) {
	dp[i][j] += dp[i-1][j] + (field[i][j] - '0');
      }
      else {
	dp[i][j] += min(dp[i-1][j], dp[i][j-1]) + (field[i][j] - '0');
      }
    }
  }
  
  cout << dp[H-1][W-1] << endl;
  
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int l,r;
    cin>>l>>r;
    std::deque<long long int> deq;
    for (long long int i=2019;i<=3000000000;i+=2019) {
        deq.emplace_back(i);
    }
    auto itr=lower_bound(deq.begin(),deq.end(),l);
    long long int ans=100000000;
    if (r<*itr) {
        for (long long int j=l;j<r;j++) {
            for (long long int k=l+1;k<=r;k++) {
                if (ans>(j*k)%2019) {
                    ans=(j*k)%2019;
                }
            }
        }
        cout<<ans<<endl;
    } else {
        cout<<0<<endl;
    }
}


Measured memory_bytes: 12432
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  constexpr int mod = 1e9 + 7;
  int n; cin >> n;
  string s; cin >> s;

  vector<int> mp(26, 0);
  REP(i, n) mp[s[i] - 'a']++;

  ll ans = 1LL;
  for(const int& x: mp){
    if(x > 0) (ans *= (x + 1)) %= mod;
  }

  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
"""
Created on Thu Sep  3 21:04:57 2020

@author: liang
"""
from operator import add

#import numpy as np
N, M, X = map(int, input().split())

#A = [np.array(list(map(int, input().split()))[1:]) for _ in range(N)]
A = [list(map(int, input().split())) for _ in range(N)]
ans = 10**7
for i in range(2**N):
    C_list = list()
    for j in range(N):
        if i>>j&1 == 1:
            C_list.append(j)
    #tmp = np.array( [0]*M )
    tmp = [0]*(M+1)
    for i in C_list:
        tmp = list(map(add, A[i], tmp))
    if all([ i >= X for i in tmp[1:]]) and tmp[0] < ans :
        ans = tmp[0]
    #print(tmp)
if ans == 10**7:
    ans = -1
print(ans)

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

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



if (a<=b)
{	for (int i = 1; i < stoi(b); ++i)
	{
	a=a+a[0];
	}
	cout << a << endl;
}
else
	{	for (int i = 1; i < stoi(a); ++i)
	{
	b=b+b[0];
	}
	cout << b<< endl;
}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5, m = 1e9 + 7;
int h, w, dg[1000][1000];
char g[1000][1000];
int main()
{
    cin >> h >> w;
    for(int i=0; i<h; ++i)
        for(int j=0; j<w; ++j)
            cin >> g[i][j];
    for(int i=0; i<w; ++i){
        if( g[0][i] == '#' )
            break;
        dg[0][i] = 1;
    }
    for(int i=0; i<h; ++i){
        if( g[i][0] == '#' )
            break;
        dg[i][0] = 1;
    }
    for(int i=1; i<h; ++i)
        for(int j=1; j<w; ++j){
            dg[i][j] = (dg[i-1][j] + dg[i][j-1]) < m ? (dg[i-1][j] + dg[i][j-1]) : (dg[i-1][j] + dg[i][j-1] - m);
            if( g[i][j] == '#' )
                dg[i][j] = 0;
        }
    cout << dg[h-1][w-1];
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int , int>
#define vi vector<int>
#define inf 1e18 //(10^18
#define pqmax priority_queue<int>
#define mii map<int , int>
#define ps(x, y) fixed<<setprecision(y)<<x
// double ans = 1.012345668992
//cout<<ps(ans , 6)
// ans = 1.012345 // 6 decimal places
#define pqmin priority_queue<int , vi , greater<int> >
#define mk(arr , n , type) type *arr = new type[n];
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
// 48->11000(4) (returns no. of zeros after first one)
#define mod 1000000007 //1e9 +7
#define w(t) int t; cin>>t;while(t--)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//shuffle(arr , arr +n , rng)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>pbds;
//pbds s;
//s.order_of_key(4);
//*s.find_by_order(4);
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);


    int n ;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    map<char , int>m;
    for (int i = 0; i < n; i++) {
        m[s[i]]++;
    }
    int r = m['R'];
    int g = m['G'];
    int b = m['B'];
    count = r * g * b;
    for (int i = 0; i <= (n - 3) / 2; i++) {

        for (int j = 0; j + 2 * i + 2 < n; j++) {


            if (s[j] != s[j + 1 + i] && s[j] != s[j + 2 * i + 2] && s[j + i + 1] != s[j + i * 2 + 2])
                count--;

        }
    }
    cout << count << "\n";
    return 0;


}





Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
 string s;
  cin >> s;
	string arr[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
  for (int i = 0;i < 7; i++)
    if (s==arr[i])
      cout << 7-i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=2E5;
typedef pair<int,int> Pair;

int main(){
    int N;
    int prevt,t,prevx,x,prevy,y;
    cin >> N;
    string ans = "Yes";
    prevt=0;
    prevx=0;
    prevy=0;
    for(int i=0;i<N;i++){
        cin >> t >> x >> y;
        x-=prevx;
        y-=prevy;
        t-=prevt;
        if(abs(x)+abs(y)<=t && abs(x+y)%2==t%2){
            prevx=x;
            prevy=y;
            prevt=t;
        }else{
            ans="No";
            break;
        }

    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
module Main where
--import Debug.Trace
import Data.List
import Data.Char
import Data.Array
import Data.Maybe
import Data.Ord
import Control.Monad

solve :: [(Int, [Double])] -> [Double]
solve [] = []
solve ((n,x):xs)= sd 0 0 x : solve xs where
    sd x1 x2 [] = sqrt (x2/n' - (x1/n')^2)
    sd x1 x2 (d:ds) = sd (x1+d) (x2+d*d) ds
    n' = realToFrac n 

readLine:: IO [Double]
readLine = fmap (map read . words) getLine

readUntil :: (Int -> Bool) -> IO [(Int, [Double])]
readUntil eof = iter where
    iter = do
        n <- readLn
        if eof n then return []
                 else do
                    a <- readLine
                    fmap ((n, a):) iter
            
eof :: Int -> Bool
eof s = s == 0

main :: IO() 
main = do
    l   <- readUntil eof
    mapM_ print (solve l)



Measured memory_bytes: 5004
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 100000
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
int m,n,row,col;
int ara[303];
double memo[303][303][303];
double dp(int one,int two ,int three)
{
  if(one == 0 && two == 0 && three == 0)return 0.0;
  if(memo[one][two][three]!=-1.0)return memo[one][two][three];
  double p = (double)n / (double)(one+two+three);
  //cout << p << endl;
  if(one!=0)p = p + dp(one-1,two,three)*((double)one/(double(one+two+three)));
  if(two!=0)p = p + dp(one+1,two-1,three)*((double)two/(double)(one+two+three));
  if(three!=0)p = p + dp(one,two+1,three-1)*((double)three/(double)(one+two+three));
  memo[one][two][three] = p;
  return p;
}
void solve()
{
  scanf("%d",&n);
  int one=0,two=0,three=0;
  for(int w=0;w<n;w++)
  {
    scanf("%d",&ara[w]);
    if(ara[w]==1)one++;
    else if(ara[w]==2)two++;
    else three++;
  }
  for(int w=0;w<303;w++)
  {
    for(int q=0;q<303;q++)
    {
      for(int r=0;r<303;r++)memo[w][q][r]=-1.0;
    }
  }
  printf("%.15lf\n",dp(one,two,three));

}
void test()
{
  int t;
  //scanf("%d",&t);
   t = 1;
  for(int test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 217600
n = int(input())
a = list(map(int,input().split()))

sums = [0]
sum = 0
for i in range(n):
    sum += a[i]
    sums.append(sum)


ans = 10**15
for i in range(1,n):
    k = abs(sums[i]-(sum-sums[i]))
    ans = min(k,ans)

print(ans)


Measured memory_bytes: 87120
n = int(input())
dp = [2**i if i % 2 == 0 else -2**i for i in range(32) ]

if n < 0 :
    plus_minus = 1
elif n > 0:
    plus_minus = 0
else:
    print(0)
    exit()

a = 0
for i in range(plus_minus,32,2):
    if abs(dp[i]) + abs(a) > abs(n):break
    a += dp[i]
s = "1"

if plus_minus == 1:
    b = dp[i]
    for j in range(i-1,-1,-1):
        if j % 2 == 0:
            if (b + dp[j]) + a <= n:
                s += "1"
                b += dp[j]
            else: s += "0"
        else:
            a -= dp[j]
            if b + a > n:
                s += "1"
                b += dp[j]
            else:
                s += "0"

else:
    b = dp[i]
    for j in range(i-1,-1,-1):
        if j % 2 == 1:
            if (b + dp[j]) + a >= n:
                s += "1"
                b += dp[j]
            else: s += "0"
        else:
            a -= dp[j]
            if b + a < n:
                s += "1"
                b += dp[j]
            else:
                s += "0"
print(s)

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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  int t = 0;
  for(int i = l ;i <= r;i++){
  if(i % d == 0 ){
    t++;
  }

  }
  cout << t << endl;


}

  



  

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

struct CumulativeSum{
    vector<int> data;
    CumulativeSum(int sz) : data(sz, 0) {};
    void add(int k, int x){
        data[k] += x;
    }
    void build(){
        for(int i = 1; i < data.size(); i++){
            data[i] += data[i - 1];
        }
    }
    int query(int k){
        if(k < 0) return 0;
        return (data[min(k, (int)data.size() - 1)]);
    }
    int query(int l, int r){
        return query(r - 1) - query(l - 1);
    }
};

signed main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    CumulativeSum cs(n);
    rep(i, 0, n - 1){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            cs.add(i, 1);
        }
    }
    cs.build();
    while(q--){
        int l, r;
        cin >> l >> r;
        l--; r--;
        cout << cs.query(l, r) << endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

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



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int k,a,b;
  scanf("%d",&k);
  scanf("%d",&a);
  scanf("%d",&b);
  
  if((a+k-1)/k*k<=b){
    printf("OK");
  }else{
    printf("NG");
  }
  return(0);
}

Measured memory_bytes: 1732
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        int n=ni();
        int R=ni();
        if(n>=10)
            pn(R);
        else
            pn(R+100*(10-n));
    }

    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

map<ll,ll> M;

int main(){
  ll N,A[200007],ans[200007];
  cin >> N;
  rep(i,N){
    cin >> A[i];
  }
  if(N%2==0){
    rrep(i,N/2){
      ll K=N/2-i;
      ans[i]=A[K*2-1];
    }
    Rep(i,N/2,N){
      ll K=i-N/2;
      ans[i]=A[K*2];
    }
  }
  else{
    rrep(i,(N+1)/2){
      ll K=(N+1)/2-i;
      ans[i]=A[K*2-2];
    }
    Rep(i,(N+1)/2,N){
      ll K=i-(N+1)/2;
      ans[i]=A[K*2+1];
    }
  }
  rep(i,N){
    cout << ans[i];
    if(i!=N-1){
      cout << " " ;
    }
  }
  cout << endl; 
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll t1,t2;
  t1=(a/c)*c+c;
  if(a%c==0)t1=a;
  t2=(b/c)*c;
  if(t1>t2)cout<<0<<endl;
  if(t1==t2)cout<<1<<endl;
  if(t1<t2)cout<<(t2-t1)/c+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n;
ll a[maxx];

int main() {
	while(cin >> n && n) {
		ll ans = 0;
		memset(a, 0, sizeof(a));
		for(int i = 1; i <= n; i++) cin >> a[i];
		sort(a + 1, a + 1 + n);
		int l = 1, r = n;
		ans = a[n] - a[1];
		for(int i = 2; i <= n / 2; i++) {
			int dd = a[n - i + 1] - a[l];
			int pp = a[r] - a[i];
			ans += dd + pp;
			l++;
			r--;
		}
		if(n & 1) {
			int x = abs(a[n / 2 + 1] - a[r]);
			int y = abs(a[n / 2 + 1] - a[l]);
			ans += max(x, y);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
M = int(input())
DC = [list(map(int,input().split())) for _ in [0]*M]

ans = 0
res = []
for d,c in DC:
    while c>0:
        if c%2==1:
            res.append(d)
            c -=1
        d *= 2
        if d>=10:
            d = d//10 + d%10
            ans += c
            c//=2
        else:
            ans += c//2
            c//=2

tmp = 0
for r in res:
    ans += 1
    tmp += r
    if tmp >= 10:
        tmp -=9
        ans += 1
ans -=1
print(ans)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b>=c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  } 
  return 0;
}

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

int main(void) {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H ==0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i + j) % 2 == 0)
					cout << "#";
				else
					cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Problem
{
	static readonly int Inf = 1073741789;
	private int N;
	private IEnumerable<int> items;
	public Problem()
	{
		var sc = new Scan();
		N = sc.ReadInt();
		items = Func.Range(0, N).Select(x => sc.ReadInt());
	}
	private int[] memo;
	public void Solve()
	{
		memo = new int[N];
		for (var n = 0; n < N; n++) memo[n] = Inf;
		foreach (var item in items) memo[Func.FirstBinary(0, N, x => item <= memo[x])] = item;
		Console.WriteLine(Func.FirstBinary(0, N, x => memo[x] == Inf));
	}
}
class Program
{
	static void Main() { new Problem().Solve(); }
}
class Scan
{
	private TextReader file;
	public Scan() { file = Console.In; }
	public int ReadInt() { return int.Parse(file.ReadLine()); }
}
static class Func
{
	public static long FirstBinary(long min, long max, Predicate<long> pred)
	{
		var left = min;
		var right = max;
		while (left < right)
		{
			var mid = (left + right) >> 1;
			if (pred(mid)) right = mid;
			else left = mid + 1;
		}
		return left;
	}
	public static IEnumerable<int> Range(int min, int max) { for (var i = min; i < max; i++) yield return i; }
}

Measured memory_bytes: 10220
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int res = min(b, d) - max(a, c);
    if (res > 0) cout << res << endl;
    else cout << 0 << endl;
}


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

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

char s[100004];
int c[100000];
int f[100000];

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

    scanf("%s", s);
    int n = strlen(s);

    int lr = 0;
    for (int i = 0; i < n; i++)
        if (s[i] == 'R')
            lr = i;
        else
            c[i] = i-lr;

    for (int i = n-1; i >= 0; i--)
        if (s[i] == 'L')
            lr = i;
        else
            c[i] = lr-i;

    memset(f, 0, sizeof(f));
    for (int i = 0; i < n; i++) {
        int d = c[i] - (c[i]%2 ? 1 : 0);
        int p = (s[i] == 'R' ? 1 : -1);
        f[i+p*d]++;
    }

    for (int i = 0; i < n; i++)
        printf("%d%c", f[i], (i == n-1 ? '\n' : ' '));

    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//=================

	ll N, K, S;
	cin >> N >> K >> S;

	vll ans(N);

	if (S == 1000000000) {
		for (int i = 0; i < K; i++) {
			ans[i] = S;
		}
		for (int i = K; i < N; i++) {
			ans[i] = 1000000000-1;
		}
		for (int i = 0; i < N; i++) {
			cout << ans[i] << " ";
		}
		return 0;
	}









	for (int i = 0; i < K; i++) {
		ans[i] = S;
	}
	for (int i = K; i < N; i++) {
		ans[i] = 1000000000;
	}
	for (int i = 0; i < N; i++) {
		cout << ans[i] << " ";
	}






}


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

int gcd(int a, int b);

int main()
{
	int a, b;

	while (cin >> a >> b, cin.eof() != true){
		cout << gcd(a, b) << " " << a / gcd(a, b) * b << endl;
	}

	return (0);
}

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

Measured memory_bytes: 1160
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < 2; i++) {
            int[] l = new int[10];
            for (int j = 0; j < 10; j++) {
                l[j] = sc.nextInt();
            }
            Arrays.sort(l);
            System.out.print(l[7] + l[8] + l[9]+(i==0?" ":"\n"));
        }
    }
}


Measured memory_bytes: 26200
//２つの整数 a, b を読み込んで、a と b の大小関係を出力するプログラム
#include <stdio.h>

#define MAX_STRING_SIZE 8
#define COUNT_OF_INPUT 3

int main(void)
{
    //変数定義
    int iInputA;
    int iInputB;

    //変数初期化
    iInputA = 0;
    iInputB = 0;
    char szBLargeASmall[MAX_STRING_SIZE] = "a < b";
    char szAlargeBSmall[MAX_STRING_SIZE] = "a > b";
    char szAEqualB[MAX_STRING_SIZE] = "a == b";
    
        scanf("%d %d",&iInputA, &iInputB);
        if (iInputA < iInputB)
        {
            printf("%s\n",szBLargeASmall);
        }
        else if (iInputA > iInputB)
        {
            printf("%s\n",szAlargeBSmall);           
        }
        else if (iInputA == iInputB)
        {
            printf("%s\n",szAEqualB);           
        }       
        else
        {
            //何もしない
        }
        
 
    return 0;
}


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

#define int long long 

signed main()
{
    int k,n;
    cin >> k >> n;
    int l = max(n-k+1,-1000000LL),r = min(n+k-1,1000000LL);
    for(int i = l ; i <= r; ++i)
    {
        cout << i << ' ';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
 
int main() {
    string s;
    cin >> s;
    int n = s.length();
    int m = 7;
    REP(i,m){
        int j = m - i;
        string t = s.substr(0, i);
        t += s.substr(n - j, j);
        if (t == "keyence"){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

const int MAXN = 5e5;
int N;
int A[MAXN];

bool isGood(int D) {
	assert(D > 0);
	int L = 0;
	vector<pair<int, int>> cur;
	for (int i = 0; i < N; i++) {
		int a = A[i];
		if (a > L) {
			cur.emplace_back(a-L, 0);
			L = a;
		} else {
			// first we pop cur all the way down
			while (L > a) {
				int d = min(cur.back().first, L-a);
				cur.back().first -= d;
				if (cur.back().first == 0) cur.pop_back();
				L -= d;
			}

			assert(a == L);
			while (!cur.empty() && cur.back().second == D-1) {
				L -= cur.back().first;
				cur.pop_back();
			}
			if (cur.empty()) {
				return false;
			}
			assert(cur.back().second < D-1);
			if (cur.back().first > 1) {
				cur.back().first --;
				cur.emplace_back(1, cur.back().second);
			}
			assert(cur.back().first == 1);
			assert(cur.back().second < D-1);
			cur.back().second++;
			if (a > L) {
				cur.emplace_back(a-L, 0);
				L = a;
			}
		}
	}

	return true;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	int mi = 0, ma = N+1;
	while (ma - mi > 1) {
		int md = (mi + ma) / 2;
		if (isGood(md)) {
			ma = md;
		} else {
			mi = md;
		}
	}
	cout << ma << '\n';

	return 0;
}


Measured memory_bytes: 4692
N ,K = map(int,input().split())
ans = N
while (1):
    # x > Kの時
    if ans > K:
        if abs(ans - K) > ans:
            break
        else:
            ans = ans % K
    # x < Kの時
    elif ans <= K:
        if abs(ans - K) > ans:
            break
        else:
            ans = abs(ans - K)
print(ans)

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

const int MAX = 2000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int X,Y;
    cin >> X >> Y;
    COMinit();

    if((X+Y)%3!=0) cout << 0 << endl;
    else cout << COM((X+Y)/3,X-(X+Y)/3) << endl;
}

Measured memory_bytes: 47104
N = int(input())
K = int(input())
X = [(int(j), i+1) for i, j in enumerate(input().split())]
A = [(0, a) for a in range(N+1)]
B = [(K, b) for b in range(N+1)]
cost = 0

for i,x_i in enumerate(X):
	cost += min(abs(x_i[0] - A[i][0])*2, abs(x_i[0] - B[i][0])*2)

print(cost)


Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>

using namespace std;

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

int main(){
    int a, b;
    cin >> a >> b;
    int n;
    if(b/100>0){
        n = 1000*a+b;
    }else if(b/10>0){
        n = 100*a+b;
    }else{
        n = 10*a+b;
    }

    bool flag=false;

    REP(i,n){
        if(i*i==n){
            flag=true;
        }else if(i*i>n){
            break;
        }
    }
    if(flag){
        cout << "Yes";
    }else{
        cout << "No";
    }

}

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

s=len(S)
t=len(T)
dp=[[0 for i in range(s+1)] for j in range(t+1)]


for i in range(1,t+1):
  for j in range(1,s+1):
    if S[j-1]==T[i-1]:
      dp[i][j]=dp[i-1][j-1]+1
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j-1])
  
arr=[]
while(i>0 and j>0):
  if S[j-1]==T[i-1]:
    arr+=[j-1]
    j-=1
    i-=1
  else:
    if dp[i-1][j]>dp[i][j-1]:
      i-=1
    else:
      j-=1
arr.sort()
for i in arr:
  print(S[i],end="")


Measured memory_bytes: 153860
// Crt. 2019-12-06  20:33:58
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;
typedef long long ll;
const int Mod = 1e9 + 7;

int n, m, f[N], sum[N];
ll A, B, s[N], p[N];

int main() {
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> A >> B;

    for (int i = 1; i <= n; ++i)
        scanf("%lld", s + i);

    if (A < B) swap(A, B);

    for (int i = 2; i < n; ++i)
        if (s[i + 1] - s[i - 1] < B) return puts("0"), 0;

    for (int i = 1; i < n; ++i)
        if (s[i + 1] - s[i] < B) p[++m] = i;


    s[++n] = 4e18;
    f[0] = sum[0] = 1;

    for (int i = 1, posl = 0; i <= n; ++i) {
        int posr = upper_bound(s + 1, s + n + 1, s[i] - A) - s - 1;
        //cout << i << " " << posl << " " << posr << "  ";

        if (posr >= posl)
            f[i] = (sum[posr] + Mod - (posl ? sum[posl - 1] : 0)) % Mod;
        sum[i] = (sum[i - 1] + f[i]) % Mod;

        if (i > 1 && s[i] - s[i - 1] < B) posl = i - 1;

        //cout << f[i] << " " << sum[i] << endl;
    }

    cout << f[n] << endl;

    return 0;
}


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

using namespace std;
using ll = long long;

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


void solve(long long N){
  vector<ll> v(N+1);
  vector<pair<ll, ll>> ans;

  if(N%2==0) {
    for(ll i=1; i<=N/2; i++) {
      v[i] = N-i+1;
      v[N-i+1] = i;
    }
  } else {

    for(ll i=1; i<=N/2; i++) {
      v[i] = N-i;
      v[N-i] = i;
    }
    v[N] = 0;
  }
  for(ll i=1; i<=N; i++) {
    for(ll j=i+1; j<=N; j++) {
      if(j==v[i]) continue;
      ans.push_back(make_pair(i, j));
    }
  }
  std::cout << ans.size() << std::endl;
  for(auto p: ans) {
    std::cout << p.first <<" "<<p.second << std::endl;
  }

  
  
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	long value;
	long type;
} S_DATA;

int cmpAscVal(const void * n1, const void * n2)
{
	if (((S_DATA *)n1)->value > ((S_DATA *)n2)->value)
	{
		return 1;
	}
	else if (((S_DATA *)n1)->value < ((S_DATA *)n2)->value)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  S_DATA pair_count[n*2];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
    pair_count[i].value = i+1+a[i];
    pair_count[i].type = 0;
    pair_count[i+n].value = i+1-a[i];
    pair_count[i+n].type = 1;
  }
  qsort(pair_count, n*2, sizeof(S_DATA), cmpAscVal);
  long count0 = 0;
  long count1 = 0;
  long pairs = 0;
  for (long i = 0; i < n*2; i++) {
    if (i != 0 && pair_count[i].value != pair_count[i-1].value) {
      pairs += count0*count1;
      count0 = 0;
      count1 = 0;
    }
    if (pair_count[i].type == 0) {
      count0++;
    } else {
      count1++;
    }
  }
  pairs += count0*count1;
  printf("%ld\n", pairs);

  return 0;
}

Measured memory_bytes: 15508
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

ll dp[100005][4];
int main(){
    string S; cin>>S;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<S.length();++i){
        for(int j=0;j<4;++j){
            if(S[i]!='?') (dp[i+1][j]+=dp[i][j])%=MOD;
            else (dp[i+1][j]+=dp[i][j]*3%MOD)%=MOD;
        }
        if(S[i]=='A'||S[i]=='?') (dp[i+1][1]+=dp[i][0])%=MOD;
        if(S[i]=='B'||S[i]=='?') (dp[i+1][2]+=dp[i][1])%=MOD;
        if(S[i]=='C'||S[i]=='?') (dp[i+1][3]+=dp[i][2])%=MOD;
    }
    cout<<dp[S.length()][3]<<endl;
    return 0;
}



Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll N,a;
    vector<ll> A;
    cin >> N;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    
    ll All = 0;
    REP(i,N){
        All = (All ^ A[i]);
    }
    
    REP(i,N){
        ll Ans = All ^ A[i];
        cout << Ans;
        if(i!=N-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 5296
const t={input:require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/),n:(arg:number=0):any=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.n())}return a}else{const a=t.input[0];t.input.shift();return Number(a)}},s:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.s())}return a}else{const a=t.input[0];t.input.shift();return String(a)}},c:(arg:number=0):string|string[]=>{if(arg){const a=[];for(let i=0;i<arg;i++){a.push(t.c())}return a}else{let a=t.input[0].split('');const b=a[0];a.shift();if(a.length>0){t.input[0]=a.join('')}else{t.input.shift()}return String(b)}},o:(...arg)=>{console.log(...arg)},abs:(a)=>{return Math.abs(a)},min:(...a)=>{return Math.min(...a)},max:(...a)=>{return Math.max(...a)},floor:(a)=>{return Math.floor(a)},asc:(ar:number[])=>{return ar.sort((a,b)=>{return a-b})},desc:(ar:number[])=>{return ar.sort((a,b)=>{return b-a})},sw:(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]}};
const main=()=>{
  let [x,a,b] = t.n(3)
  a-=x;
  b-=x;
  t.o(t.abs(a)<t.abs(b)?'A':'B')
}
main()

Measured memory_bytes: 7372
#include<iostream>
using namespace std;
enum POSITION{CLOCKWISE, COUNTER_CLOCKWISE, ONLINE_BACK,
              ONLINE_FRONT, ON_SEGMENT};
struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double get_cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double get_dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2){}
};
POSITION get_position(Point p, Segment s){
    Vector base = s.p2 - s.p1;
    Vector obj  = p    - s.p1;
    double cross = get_cross(base, obj);
    if (cross >  1e-10) return CLOCKWISE;
    if (cross < -1e-10) return COUNTER_CLOCKWISE;
    if (get_dot(base, obj) < 0) return ONLINE_BACK;
    if (get_dot(base, base) < get_dot(obj, obj)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool is_intersection(Segment s1, Segment s2){
    POSITION s2p1_s1 = get_position(s2.p1, s1);
    POSITION s2p2_s1 = get_position(s2.p2, s1);
    POSITION s1p1_s2 = get_position(s1.p1, s2);
    POSITION s1p2_s2 = get_position(s1.p2, s2);
    if (s2p1_s1 == ON_SEGMENT || s2p2_s1 == ON_SEGMENT) return true;
    if (s1p1_s2 == ON_SEGMENT || s1p2_s2 == ON_SEGMENT) return true;
    if (s2p1_s1 == ONLINE_FRONT) {
        if (s2p2_s1 == ONLINE_BACK) return true;
        return false;
    }
    if (s2p1_s1 == ONLINE_BACK) {
        if (s2p2_s1 == ONLINE_FRONT) return true;
        return false;
    }
    if (s2p1_s1 == CLOCKWISE) {
        if (s2p2_s1 != COUNTER_CLOCKWISE) return false;
        if (s1p1_s2 == s1p2_s2) return false;
        return true;
    }
    if (s2p1_s1 == COUNTER_CLOCKWISE) {
        if (s2p2_s1 != CLOCKWISE) return false;
        if (s1p1_s2 == s1p2_s2) return false;
        return true;
    }
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3;
        cin >> x_p0 >> y_p0 >> x_p1 >> y_p1;
        cin >> x_p2 >> y_p2 >> x_p3 >> y_p3;
        Point p0(x_p0, y_p0);
        Point p1(x_p1, y_p1);
        Point p2(x_p2, y_p2);
        Point p3(x_p3, y_p3);
        Segment s1(p0, p1);
        Segment s2(p2, p3);
        int ans = 0;
        if (is_intersection(s1, s2)) ans = 1;
        cout << ans << endl;
    }
    return 0;
}



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

INF = 10 ** 9

dp = [INF] * (N + 1)
dp[0] = 0

for i in range(1, N + 1):
    dp[i] = dp[i - 1] + 1
    
    tmp = 6
    while i - tmp >= 0:
        dp[i] = min(dp[i], dp[i - tmp] + 1)
        tmp *= 6
    
    tmp = 9
    while i - tmp >= 0:
        dp[i] = min(dp[i], dp[i - tmp] + 1)
        tmp *= 9

# print (dp)
print (dp[N])

Measured memory_bytes: 3828
(let* ((x 1000)
       (y 0)
       (n (read))
       (a (make-array (list n))))
  (loop :for i :from 0 :to (1- n)
        :do (setf (aref a i) (read)))
  ;;
  (loop :for i :from 0 :to (- n 2)
        :for today := (aref a i)
        :for tomorrow := (aref a (1+ i))
        :if (< today tomorrow)
        :do (let ((d (floor (/ x (aref a i)))))
              (incf y d)
              (decf x (* d today)))
        :if (> today tomorrow)
        :do (progn
              (incf x (* y today)))
              (setf y 0))
  (when (/= y 0)
    (incf x (* y (aref a (1- n))))
    (setf y 0))
  (format t "~A~%" x))


Measured memory_bytes: 24720