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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);


    int x;
    cin >>x;

    if(x<1200) cout << "ABC" << endl;
    else cout <<"ARC" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){b++;return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
    laz.assign(2*n-1,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(int len,int k){
    if(laz[k]==ei) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=ei;
  }
  T update(int a,int b,E x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(int a,int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(int a,int b){
    return query(a,b,0,0,n);
  }
  void update(int k,T x){
    query(k,k+1);//evaluate
    k+=n-1;
    dat[k]=x;
    while(k){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
};
//END CUT HERE
signed main(){
  int n,q;
  cin>>n>>q;
  SegmentTree<Int,Int> ch(n,
			  [](Int a,Int b){return a+b;},
			  [](Int a,Int b){return a+b;},
			  [](Int a,Int b){return a+b;},
			  0,0,
			  [](Int a,Int b){return a*b;});
  ch.build(n,vector<Int>(n,0));
  for(int i=0;i<q;i++){
    int c,s,t,x;
    cin>>c;
    if(c){
      cin>>s>>t;
      cout<<ch.query(s-1,t)<<endl;
    }else{
      cin>>s>>t>>x;
      ch.update(s-1,t,x);
    }
  }
}

/*
  verified on 2018/03/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_G&lang=jp
*/



Measured memory_bytes: 7580
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long A = sc.nextLong();
        double B = sc.nextDouble();

        System.out.println(solve(A, B));
    }

    private static String solve(long A, double B) {
        BigDecimal b = BigDecimal.valueOf(A);
        b = b.multiply(BigDecimal.valueOf(B));


        return b.setScale(0, RoundingMode.DOWN).toString();
    }
}

Measured memory_bytes: 37532
def get_sex(i):
    print(i, flush=True)
    return input()


def solve(N):
    if N <= 19:
        for i in range(N):
            print(i, flush=True)
            s = input()
            if s == 'Vacant':
                exit()

    low_sex = get_sex(0)
    if low_sex == 'Vacant':
        exit()
    high_sex = get_sex(N - 1)
    if high_sex == 'Vacant':
        exit()

    high, low = N - 1, 0
    while high > low:
        mid = (high + low) // 2
        mid_sex = get_sex(mid)
        if mid_sex == 'Vacant':
            exit()

        if (mid - low) % 2 == 1:
            if mid_sex != low_sex:
                low = mid
                low_sex = mid_sex
            else:
                high = mid
                high_sex = mid_sex
        else:
            if mid_sex != low_sex:
                high = mid
                high_sex = mid_sex
            else:
                low = mid
                low_sex = mid_sex


if __name__ == '__main__':
    solve(int(input()))

Measured memory_bytes: 9228
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nw = Input.ar;
        var wv = Input.twodim(nw[0]);
        var mValue = wv.Max(ar => ar[1]) * nw[0];
        var dp = new long[nw[0] + 1, mValue + 1];
        for (var i = 0; i <= nw[0]; i++)
            for (var j = 1; j <= mValue; j++)
                dp[i, j] = nw[1] + 1;
        for (var i = 1; i <= nw[0]; i++)
            for (var j = 0; j <= mValue; j++)
                if (j - wv[i - 1][1] >= 0)
                    dp[i, j] = Min(dp[i - 1, j], dp[i - 1, j - wv[i - 1][1]] + wv[i - 1][0]);
                else dp[i, j] = dp[i - 1, j];
        var res = 0;
        for (var i = 0; i <= mValue; i++)
            if (dp[nw[0], i] <= nw[1]) res = i;
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 92128
#include <cstdio>



int main(){
  int n,m,ans=0;
  
  int A[100000];
  scanf("%d",&n);
  
  for(int i=0;i<n;i++)
    scanf("%d",A+i);
  
  scanf("%d",&m);
  
  for(int i=0;i<m;i++){
    int a;
    scanf("%d",&a);

    for(int j=0;j<n;j++){
      if(A[j]==a){
        ans++;
        break;
      }
    }

  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 2996
#!/usr/bin/python
# coding: utf-8

def maze(string, h):
    return string[h:] + string[:h]

while True:
    string = raw_input()
    if string == "-":
        break

    m = int(raw_input())
    for i in range(m):
        h = int(raw_input())
        string = maze(string, h)
        #print "h: {}, string: {}".format(h, string)
    print string

Measured memory_bytes: 6392
import java.io.*;
import java.math.BigInteger;
import java.util.*;

class Main {
	
	public static int maxCalc (int[] nums) {
		
		int max = Integer.MIN_VALUE;
		int sum = 0;
		
		// どこから取り始めるか
		for (int i = 0; i < nums.length; i++) {
			sum = 0;
			for (int j = i; j < nums.length; j++) {
				sum += nums[j];
				max = Math.max(max, sum);
			}
			
		}
		
		return max;
		
	}
	
	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		while (true) {
			
			int n = Integer.parseInt(br.readLine());
			if (n == 0) break;
			int[] nums = new int[n];
			for (int i = 0; i < n; i++)
				nums[i] = Integer.parseInt(br.readLine());
			ans.add(maxCalc(nums));
			
		}
		
		for (int a : ans) {
			System.out.println(a);
		}
		
	}

}

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

ll N, A[10];

int main(void) {
  cin >> N;
  REP(i, 0, N) cin >> A[i];

  ll ans = 1;
  REP(i, 0, N) {
    if(A[i] % 2 == 0) {
      ans *= 2;
    }
  }
  cout << pow(3, N) - ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}
vl fact(1e6+1,1),inv(1e6+1,1);
void solve()
{
    ll x,y;
    cin>>x>>y;
    if(x>y) swap(x,y);
    fact[0]=1;
    for(ll i=1;i<=1e6;i++) {
        fact[i]=(fact[i-1]*i)%mod;
        inv[i]=power(fact[i],mod-2,mod);
    }

    if((x+y)%3==0 && 2*x>=y) {
        ll n = (x+y)/3;
        ll m = y-(x+y)/3;
        ll ans = (fact[n]*inv[m])%mod;
        ans*=inv[n-m];
        ans%=mod;
        cout<<ans;
    }
    else {
        cout<<0;
    }
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 16000
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        boolean flag = false;
        while(n!=0){
            if(n%10==7)flag = true;
            n = n/10;
        }
        String ans = (flag)?"Yes":"No";
        System.out.println(ans);
    }
}


Measured memory_bytes: 35828
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[1010][1010];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	char a;
	cin >> a;
	if (a - 'a' < 0) {
		puts("A");
	}
	else {
		puts("a");
	}
	return 0;
}


Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC129_1
{
    class A
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            Console.WriteLine(a[0] + a[1]);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
int main()
{
    lli n,i,j,k,d=0;
    cin>>n;
    lli a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&(a[i]+a[j])>a[k])
                d++;
            }
        }
    }
    cout<<d;
    return 0;
}

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


int main(void) {

	// 1_4-C Simple Calculator

	int a,b;
	char op;
	int ans;
	
	scanf("%d %c %d",&a,&op,&b);
	
	while(op != '?'){
		if(op=='+'){
			ans = a+b; 
		}else if(op=='-'){
			ans = a-b;
		}else if(op=='*'){
			ans = a*b;
		}else if(op=='/'){	
			ans = a/b;
		}
		printf("%d\n",ans);
		scanf("%d %c %d",&a,&op,&b);
	}
        return 0;
}

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

int main() {
	int cou = 0;
	char prew[4], weth[4];

	cin >> prew >> weth;

	for (int i = 0; i < 3; ++i)
		if (prew[i] == weth[i])
			cou++;

	cout << cou << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n,d,x,a[100],s;
  int i,j;

  scanf("%d",&n);
  scanf("%d%d",&d,&x);

  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  s = 0;

  for(i=0;i<n;i++)
    for(j=1;j<=d;j=j+a[i]){
        s++;
     }
   printf("%d\n",s+x);
   return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll gcd(ll a, ll b) {
  if(a < b)
    gcd(b, a);
  ll r;
  while((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll a, b, c, d, l;
  cin >> a >> b >> c >> d;
  l = lcm(c, d);
  a--;
  cout << b - a - ((b / c + b / d - b / l) - (a / c + a / d - a / l)) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-05-17 21:00:50 +0900
# LastModified: 2020-05-17 21:04:35 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    n = input()
    hon_list = [2,4,5,7,9]
    pon_list = [0,1,6,8]
    bon_list = [3]
    n_last = int(n[-1])
    if n_last in hon_list:
        print("hon")
        return 
    elif n_last in pon_list:
        print("pon")
        return 
    else:
        print("bon")

if __name__ == "__main__":
    main()


Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i= x;i<n;i++)

int main()
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll i = 1;
   bool ans = true;
   while(true){
       if(i%2 == 1){
           c  = c-b;
       }
       else{
           a =  a-d;
       }
    //    cout<<a<<" "<<c<<endl;
       if(a<=0){
           ans = false; 
           break;
       }
       if(c<=0){
           ans = true;
           break;
       }
       i++;
   }

   cout<<(ans?"Yes":"No");
}

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

int main(){
  int A,B,K;
  vector<int> V;
  cin >> A >> B >> K;
  int ans = 0;
  int M = min(A,B);
  for(int i=1;i<=M;i++){
    if((A%i==0)&&(B%i==0)){
      ans++;
      V.push_back(i);
    }
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  cout << V[K-1] << endl;
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a[100005],i,num=0;
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    if(n&1) {printf("0\n");return 0;}
    sort(a,a+n);
    int t=n/2;
    printf("%d\n",a[t]-a[t-1]);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    int ans=0;
    rep(i,n)rep(j,n){
        if(i>=j)continue;
        ans += d[i]*d[j];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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


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

int main() {
 int x , a , b ;
 cin >> x >> a >> b ;
  a = max(x,a) - min(x,a);
  b = max(x,b) - min(x,b);
  if(a>b)
    cout << "B" ;
  else 
    cout << "A" ;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}


int main() {
	int N; cin >> N;
	V<int> A(N); REP(i, N) cin >> A[i];
	int ans = 1,cnt = 1;
	REP(i, N) ans *= 3;
	REP(i, N) cnt *= (A[i] % 2 ? 1 : 2);
	cout << ans - cnt << endl;



	return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, m := nextInt(), nextInt()
	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
	}
	b := make([]int, m)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			a[i][j] = nextInt()
		}
	}
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		ans := 0
		for j := 0; j < m; j++ {
			ans += a[i][j] * b[j]
		}
		fmt.Println(ans)
	}
}



Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

const double EPS = 1e-10;

int main(){
  int p, q;
  while(cin >> p >> q && p + q > 0){
    string str;
    vector<int> R(p+1, 0), C(p+1, 0), S(p+1, 0), P(p, 0);;
    REP(i, p){
      cin >> str;
      for(P[i] = 0; P[i] < (int)str.size() && str[P[i]] == '.'; P[i]++); 
      R[i+1] = R[i] + count(ALL(str), '(') - count(ALL(str), ')');
      C[i+1] = C[i] + count(ALL(str), '{') - count(ALL(str), '}');
      S[i+1] = S[i] + count(ALL(str), '[') - count(ALL(str), ']');
    }
    vector<int> vr, vc, vs;
    REP2(r, 1, 21)REP2(c, 1, 21)REP2(s, 1, 21){
      bool valid = true;
      REP(i, p) if(R[i] * r + C[i] * c + S[i] * s != P[i]) valid = false;
      if(valid){
        vr.push_back(r);
        vc.push_back(c);
        vs.push_back(s);
      }
    }

    int r = 0, c = 0, s = 0;
    REP(i, q){
      cin >> str;
      vector<int> paren;
      REP(j, vr.size()){
        paren.PB(r * vr[j] + c * vc[j] + s * vs[j]);
        
      }
      sort(ALL(paren));
      paren.erase(unique(ALL(paren)), paren.end());

      cout << ((int)paren.size() == 1 ? *paren.begin() : -1) << (i == q-1? '\n':' ');
                   
      r += count(ALL(str), '(') - count(ALL(str), ')');
      c += count(ALL(str), '{') - count(ALL(str), '}');
      s += count(ALL(str), '[') - count(ALL(str), ']');
    }
  }
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a[10],k;
  for(int i=0;i<5;i++) cin>>a[i];
  sort(a,a +5);
  cin>>k;
  if(a[4]-a[0]<=k) cout<<"Yay!"<<'\n';
  else cout<<":("<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> A(n, k);
    vector<int> B(n);

    for(int i=0; i<q; i++){
        int tmp;
        cin >> tmp;
        B[tmp-1]++;
    }

    for(int i=0; i<n; i++){
        A[i]-=q;
        A[i]+=B[i];
        if(A[i]<=0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1408
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1127
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

class UnionFind:
    def __init__(self, n):
        # 初期状態は全要素が根なので、親は自分自身
        self.par = [i for i in range(n+1)]
        # 集団の要素数(size)を格納する(初期は全て1)
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        # 根までたどったらその番号を返す
        if self.par[x] == x:
            return x
        # 根でないなら親の要素で再検索
        else:
            # 検索過程で親を書き換える(圧縮経路)
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        # サイズを比較し、小さい方を大きい方に繋げる
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def is_same(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c
    

def Kruskal(V, Edges):
    """
    E: E[i] = (from, to, weight)として辺を格納したリスト
    """
    # 重みでソートする
    Edges.sort(key=lambda x: x[2])

    uf = UnionFind(V)
    weight = 0
    for s, t, w in Edges:
    	# s, tが連結なら閉路を作ってしまう。
    	if uf.is_same(s, t):
        	    continue
    	# s, tを繋げても閉路にならないとき
    	else:
        	weight += w
        	uf.unite(s, t)

    return weight


def main():
    ans = []
    #with open("AOJ\\in.txt", "r") as f:

    while True:
        n = int(readline())
        if n == 0:
            break
            
        xyzr = [tuple(map(float, readline().split()))for _ in range(n)]
        E = []
        for i in range(n-1):
            x_i, y_i, z_i, r_i = xyzr[i]
            for j in range(i+1,n):
                x_j, y_j, z_j, r_j = xyzr[j]
                d = sqrt((x_i - x_j)**2 + (y_i - y_j)**2 + (z_i - z_j)**2)
                length = max(d - (r_i + r_j), 0.0)
                E.append((i, j, length))

        # クラスカル法
        weight = Kruskal(n, E)
        ans.append(weight)

    print("\n".join("{:.3f}".format(i) for i in ans))


if __name__ == "__main__":
    main()


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

long long a[51];
long long p[51];

long long f(int N, long long X) {
  if(X==1) return ((N==0)? 1: 0);
  else if(1<X && X<=1+a[N-1]) return f(N-1,X-1);
  else if(X==2+a[N-1]) return p[N-1]+1;
  else if(2+a[N-1]<X && X<=2+2*a[N-1]) return p[N-1]+1+f(N-1,X-2-a[N-1]);
  else return 2*p[N-1]+1;

}

int main() {
  int N;
  long long X;
  cin >> N >> X;

  a[0]=1;
  p[0]=1;
  for(int i=1; i<51; i++) {
    a[i]=2*a[i-1]+3;
    p[i]=2*p[i-1]+1;
  }

  cout << f(N, X) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int X = sc.nextInt();
	int A = sc.nextInt();
	int B = sc.nextInt();

	X = X - A;
	while(X>=B){
	    X = X - B;
	}
	System.out.println(X);
    }
}


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

int main(){
  int n,i,j,kotae=9,keta,ue,sita,x;
  cin>>n;
  keta=log10(n)+1;
  if(keta==1){
    cout<<n;
    return 0;
  }
  for(i=10;i<=n;i++){
    keta=log10(i)+1;
    ue=i/pow(10,keta-1);
    sita=i%10;
    if(sita==0){
    }else if(ue<sita){
      for(j=0;j<=keta-3;j++){
        kotae+=pow(10,j)*2;
      }
    }else if(ue>sita){
      for(j=0;j<=keta-2;j++){
        kotae+=pow(10,j)*2;
      }
    }else{
      kotae+=2;
      for(j=0;j<=keta-3;j++){
        kotae+=pow(10,j)*2;
      }
      x=i-ue*pow(10,keta-1);
      x/=10;
      kotae+=x*2+1;
    }
  }
  cout<<kotae;
}

Measured memory_bytes: 256
from itertools import accumulate as ac

N, M = map(int, input().split())


array = [0] * (N + 2) # 最初と最後に 0 を入れるので、サイズを2だけ大きくする。
def imosu(array):
    for _ in range(M):
        l, r = map(int, input().split())
        array[l] += 1
        array[r+1] -= 1
    return list(ac(array))
ans_lst = imosu(array)
print(ans_lst.count(M))

Measured memory_bytes: 8116
#include <bits/stdc++.h>
using namespace std;
using large = long long;

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

    if (k <= 9) {
        cout << k;
        return 0;
    }

    auto prev = vector<large>();
    for (int i = 1; i <= 9; ++i)
        prev.push_back(i);
    auto s = vector<large>();
    cerr << k << endl;

    large ans = 0;
    k -= 9; // 1-digit
    for (;;) {
        s.clear();
        for (auto p : prev) {
            int d = p % 10;
            if (d - 1 >= 0)
                s.push_back(p * 10 + (d - 1));

            s.push_back(p * 10 + d);

            if (d + 1 <= 9)
                s.push_back(p * 10 + (d + 1));
        }

        if (k <= s.size()) {
            ans = s[k - 1];
            break;
        }

        k -= s.size();
        swap(s, prev);
        cerr << k << endl;
    }

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


Measured memory_bytes: 1884
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 1000000007;
// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,m;
  cin>>n>>m;
  vecll comb(40);
  comb[0] = 1;
  REP(i,35) {
    comb[i+1] = comb[i] * (n-i) % MOD * inv(i+1, MOD) % MOD;
  }
  set<ll> d;
  for (ll i=1; i*i <= m; ++i) {
    if (m % i == 0) {
      d.insert(i);
      d.insert(m/i);
    }
  }
  vector v(ALL(d));
  ll len = size(v);
  vector dp(31, vecll(len, 0));
  dp[0].back() = 1;
  REP(i,30) {
    REP(j,len) {
      FOR(k,1,j+1) {
        if (v[j] % v[k] != 0) continue;
        ll num = v[j]/v[k];
        ll idx = lower_bound(ALL(v), num) - begin(v);
        dp[i+1][idx] += dp[i][j];
        dp[i+1][idx] %= MOD;
      }
    }
  }
  ll ans = 0;
  REP(i,31) {
    ans += dp[i][0] * comb[i] % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


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

int depth(string line) {
    int ret = 0;
    while(line[ret] == '.') ret++;
    return ret;
}

int main() {
    while(true) {
        int n; cin >> n;
        if (n == 0) break;
        vector< pair<int, string> > posts;
        int max_d = 0;
        for (int i = 0; i < n; i++) {
            string line; cin >> line;
            int d = depth(line);
            if (d > max_d) max_d = d;
            posts.push_back(make_pair(d, line));
        }
        vector<int> bars(max_d + 1);
        for (int i = n-1; i >= 1; i--) {
            auto& post = posts[i];
            if (post.first-1 >= 0) bars[post.first-1] = 0;
            for (int i = 0; i < post.first-1; i++) {
                if (bars[i]) post.second[i] = '|';
                else         post.second[i] = ' ';

            }
            if (post.first-1 >= 0) {
                post.second[post.first-1] = '+';
                if (post.first < posts[i-1].first) bars[post.first-1] = 1;
            }
        }
        for (int i = 0; i < n; i++) cout << posts[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 3672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {

	class Vertex {
		int id;
		List<Integer> vertices = new ArrayList<>();
		int dist = Integer.MAX_VALUE;
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Vertex[] vertices = new Vertex[n];
		for (int i = 0; i < n; i++) {
			vertices[i] = new Vertex();
			StringTokenizer st = new StringTokenizer(reader.readLine());
			vertices[i].id = Integer.parseInt(st.nextToken());
			int k = Integer.parseInt(st.nextToken());
			for (int j = 0; j < k; j++) {
				vertices[i].vertices.add(Integer.parseInt(st.nextToken()));
			}
		}
		reader.close();
		
		bfs(vertices);
		
		for (int i = 0; i < n; i++) {
			Vertex v = vertices[i];
			System.out.println(v.id + " " + (v.dist==Integer.MAX_VALUE?-1:v.dist));
		}
	}

	private void bfs(Vertex[] vertices) {
		Queue<int[]> queue = new LinkedList<>();
		queue.add(new int[] {vertices[0].id, 0});
		while (!queue.isEmpty()) {
			int[] cur = queue.poll();
			Vertex vertex = vertices[cur[0]-1];
			int dist = cur[1];
			vertex.dist = Math.min(vertex.dist, dist);
			for (Integer id : vertex.vertices) {
				if (vertices[id-1].dist == Integer.MAX_VALUE) {
					queue.add(new int[] {id, dist + 1});
				}
			}
		}
	}
}



Measured memory_bytes: 40028
#include<iostream>
#include<queue>
#include<cmath>
#include<cstdio>
using namespace std;

#define N 100
#define MAX (1<<21)

typedef pair<double,int> PI;
#define MP make_pair

double d[N];
double cost[N][N];
int hantei[N];

void prim(int n){
  priority_queue<PI,vector<PI>,greater<PI> > Q;
  for(int i=0;i<n;i++){d[i] = MAX;hantei[i]=0;}
  Q.push(MP(0,0) );
  d[0]=0;
  while(!Q.empty()){
    int now = Q.top().second;
    Q.pop();
    hantei[now]=1;

    for(int i=0;i<n;i++){
      if (i == now || hantei[i]==1)continue;
      if (cost[now][i] < d[i]){
        //cout << now<<" to " << i <<" "<<cost[now][i] << endl;
        d[i]=cost[now][i];
        Q.push(make_pair(cost[now][i],i));
      }
    }  
  }//while end
  



}




int main(){
  while(1){
    int n;
    double in[100][4];
    cin >> n;
    if (n ==0)break;
    for(int i=0;i<n;i++)
      cin >> in[i][0] >> in[i][1] >> in[i][2] >> in[i][3];
    
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if (i == j){cost[i][j]=MAX;continue;}
        double distance = sqrt( pow(in[i][0]-in[j][0],2)+pow(in[i][1]-in[j][1],2)+pow(in[i][2]-in[j][2],2));
        //cout << distance << endl;
        if ( distance > in[i][3]+in[j][3])cost[i][j] = distance - (in[i][3]+in[j][3]);
        else if (distance <= in[i][3]+in[j][3])cost[i][j] = 0;
      }
    }



    
    prim(n);
    double total = 0;
    for(int i=0;i<n;i++){total+= d[i];}
    printf("%.3lf\n",total);


  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  ll L, R;
  IN(L,R);
  ll i_max = min(L+2019, R+1);
  ll ans = 2019;
  FOR(i,L,i_max){
    ll j_max = min(i+2019+1, R+1);
    FOR(j,i+1,j_max){
      ans = min(ans, (i*j)%2019);
    }
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	int i;
	int flg;
	flg=0;
	cin>>s;
	for(i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1])	flg=1;
	}
	if(flg==1)	cout<<"Bad"<<endl;
	else		cout<<"Good"<<endl;
	return 0;
}

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

using namespace std;

string s;
int n;
const long long MOD = 1e9 + 7;
vector<vector<long long>> ans;
int main()
{
    cin >> s;
    n = s.size();
    reverse(s.begin(), s.end());
    ans.assign(n, vector<long long>(13, 0));
    int cur = 1;
    for(int i = 0; i < n; ++i)
    {
        if(s[i] == '?')
        {
            for(int j = 0; j < 10; ++j)
            {
                ans[i][(cur * j)%13]++;
            }   
        }
        else
        {
            ans[i][(((int)s[i] - '0') * cur)%13]++;
        }
        cur *= 10;
        cur %= 13;
    }
    // for(auto i : ans)
    // {
    //     for(auto j : i)
    //     {
    //         cout << j << " ";
    //     }
    //     cout << "\n";
    // }
    vector<long long> res = ans[0];
    for(int i = 1; i < (int)ans.size(); ++i)
    {
        vector<long long> tmp (13, 0);
        for(int j = 0; j < 13; ++j)
        {
            for(int k = 0; k < 13; ++k)
            {
                int c = (k + j)%13;
                tmp[c] += ans[i][j] * res[k];
                tmp[c] %= MOD;
            }
        }
        res = tmp;
    }
    // for(auto i : res) cout << i << " ";
    // cout << "\n";
    cout << res[5];
}



Measured memory_bytes: 13568
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int64_t n, m;
  cin >> n >> m;

  if(m < n) swap(n, m);

  if(n + 1 < m)
    cout << 0;
  else
  {
    const int64_t mod = 1000000007;
    int64_t out = 1;
    for(int64_t i = 1; i < n + 1; ++i)
      out = (out * i) % mod;

    for(int64_t i = 1; i < m + 1; ++i)
      out = (out * i) % mod;

    if(n == m) out = (out * 2) % mod;
    cout << out;
  }

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    n,d = map(int, input().split())
    cnt = 0
    for i in range(n):
        x,y = map(int, input().split())
        if (x**2+y**2)**(1/2)<=d:
            cnt += 1
    print(cnt)







if __name__=="__main__":
    main()


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

//typedef
//------------------------------------------
typedef int64_t LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = M_PI;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
LL gcd(LL a, LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a, LL b) { return a/gcd(a,b)*b;}

//main code
int main(int argc, char *argv[])
{
	int n;
	cin >> n;
	cout << n/2 - !(n&1) << endl;
	return 0;
}



Measured memory_bytes: 256
using namespace std;

#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

typedef pair<int, int> ii;
typedef vector<int> vi;

int a, b, c;

signed main() {
  scanf("%d%d%d", &a, &b, &c);
  if (c == 0 || a == c || b == c || a + b >= c) {
    printf("Yes\n");
  }
  else printf("No\n");

}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>

int main(){
  long long int N;
  long long int v_tmp;
  std::priority_queue<double, std::vector<double>, std::greater<double> > que;
  
  scanf("%lld", &N);
  
  for(int i = 0; i < N; i++){
    scanf("%lld", &v_tmp);
    que.push((double)v_tmp);
    std::cerr << v_tmp << std::endl;
  }
  
  // synthesize ingredients
  
  double v1, v2;
  for(int i = 0; i < N-1; i++){
    v1 = que.top();
    que.pop();
    v2 = que.top();
    que.pop();
    
    std::cerr << "i: " << i << " v1: " << v1 << " v2: " << v2 << std::endl;
    
    que.push((v1+v2)/2.0);
  }
  
  std::cerr << "Answer: " << std::endl;
  std::cout << que.top();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int n, p[MAX];

VI check() {
    VI v;
    REP(i, n) if (p[i] == i) v.EB(i);
    return v;
}

int main(void) {
    cin >> n;
    REP(i, n) {
        cin >> p[i];
        p[i]--;
    }
    VI v = check();
    if (v.size() <= 1) {
        cout << v.size() << endl;
        return 0;
    }
    int cnt = 0;
    REP(i, v.size()) {
        if (i + 1 != v.size() && abs(v[i] - v[i + 1]) == 1) {
            i++;
        }
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1276