akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int

int main()
{
	string arr;
	cin>>arr;
	int l,i;
	l=arr.length();
	int f=0,num=0;
	for(i=0;i<l/2;i++)
	{
		if(arr[i]==arr[l-i-1])
			num++;
	}
	if(num!=l/2)
		f=1;
   // 
	int n=(l-1)/2;
	num=0;
	for(i=0;i<n/2;i++)
	{
		if(arr[i]==arr[n-1-i])
               num++;
	}
	if(num!=n/2)
		f=1;
//cout<<f;
	n=(l+3)/2;
	num=0;
//	cout<<n;
	for(i=n-1;i<(l+n-1)/2;i++)
	{
         if(arr[i]==arr[l-1-i])
         	num++;
	}
	
	int z=(l-n+1)/2;
	//if(z==0)
	//	z++;
//	cout<<z;
    if(num!=z)
    	f=1;
    if(f==0)
    	cout<<"Yes";
    else
    	cout<<"No";
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

//三色の選び方：最大30*29*28なので前探査すると間に合う？
//Dに対してすべてを確認していく方法を取ると当然間に合わないので
//最初Cで塗られているマスが何個あるかを列挙しておいて，そこから別の色に変化させたときのコストを計算する

int main() {

    ll N, C;
    cin >> N >> C;

    ll D[35][35];
    ll grid[505][505];
    //初期化
    ll mod012[3][35];
    //mod0 1 2のときどの色がどれだけ分布しているか
    for(ll i = 0; i < 3; i++){
        for(ll j = 0; j < 30; j++){
            mod012[i][j] = 0;
        }
    }

    for(ll i = 1; i <= C; i++){
        for(ll j = 1; j <= C; j ++){
            cin >> D[i][j];
        }
    }

    for(ll i = 0; i < N; i++){
        for(ll j = 0; j < N; j ++){
            cin >> grid[i][j];
            mod012[(i+j)%3][grid[i][j]]++;
        }
    }

    ll ans = INF;
    for(ll i = 1; i <= C; i++){
        for(ll j = 1; j <= C; j++){
            if(i == j) continue;
            for(ll k = 1; k <= C; k++){
                ll t_ans = 0;
                if(j == k || i == k) continue;
                //cout << i << " " << j << " " << k << endl;

                //modで0のところをすべて色iに
                for(ll h = 1; h <= C; h++){
                    t_ans += mod012[0][h] * D[h][i];
                }

                //modで1のところをすべて色jに
                for(ll h = 1; h <= C; h++){
                    t_ans += mod012[1][h] * D[h][j];
                }

                //modで2のところをすべて色k
                for(ll h = 1; h <= C; h++){
                    t_ans += mod012[2][h] * D[h][k];
                }
                //cout << t_ans << endl;
                ans = min(t_ans, ans);
            }
        }        
    }

    cout << ans << endl;


}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] str = new int[N];
		long total = 0;
		long ans = Long.MAX_VALUE;
		long temp = 0;

		for( int i = 0; i < N; i++){
			str[i] = scan.nextInt();
			total = total + str[i];
		}
		for(int i = 0; i < N; i++){
			temp = temp + str[i];
			if(i+1<N){
				ans = Math.min(ans, Math.abs(total-temp*2));
			}
		}
		System.out.println(ans);

	}
}

Measured memory_bytes: 65180
def checkEven(lst):
    for i in range(len(lst)):
        if lst[i]%2 != 0:
            ans = False
            break
    else:
        ans = True
    return(ans)

n = int(input())
lst = list(map(int, input().split()))
cnt = 0
while checkEven(lst) == True:
    cnt += 1
    lst = [lst[i]*0.5 for i in range(n)]
print(cnt)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int popcount(T n) { return n ? 1 + popcount(n & (n - 1)) : 0; }
#endif
#ifdef __GNUC__
template <class T> int popcount(T n);
template <> int popcount(unsigned int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(int n) { return n ? __builtin_popcount(n) : 0; }
template <> int popcount(unsigned long long n) { return n ? __builtin_popcountll(n) : 0; }
template <> int popcount(long long n) { return n ? __builtin_popcountll(n) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CL(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


struct Hero
{
	int p, t, r;
	Hero(int p, int t, int r)
		: p(p), t(t), r(r) { }
	bool operator<(const Hero& obj) const { return t > obj.t; }
};
int main()
{
	ios::sync_with_stdio(false);

	int n, m, l, k, a, h;
	while (cin >> n >> m >> l >> k >> a >> h, n)
	{
		bool ice[128];
		CL(ice, 0);
		while (l--)
		{
			int t;
			cin >> t;
			ice[t] = true;
		}

		vector<pint> edge[128];
		while (k--)
		{
			int x, y, t;
			cin >> x >> y >> t;
			edge[x].push_back(pint(y, t));
			edge[y].push_back(pint(x, t));
		}

		static int dp[128][128];
		const int INF = 1 << 28;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j <= m; ++j)
				dp[i][j] = INF;

		priority_queue<Hero> q;
		dp[a][m] = 0;
		q.push(Hero(a, 0, m));
		while (!q.empty())
		{
			Hero cur = q.top(); q.pop();
			if (cur.t > dp[cur.p][cur.r])
				continue;

			if (ice[cur.p])
			{
				for (int t = cur.t + 1, r = cur.r + 1; r <= m; ++t, ++r)
				{
					if (t < dp[cur.p][r])
					{
						dp[cur.p][r] = t;
						q.push(Hero(cur.p, t, r));
					}
				}
			}

			for (int i = 0; i < edge[cur.p].size(); ++i)
			{
				pint& hoge = edge[cur.p][i];
				int to = hoge.first, cost = hoge.second;
				int nt = cur.t + cost, nr = cur.r - cost;
				if (nr >= 0 && nt < dp[to][nr])
				{
					dp[to][nr] = nt;
					q.push(Hero(to, nt, nr));
				}
			}
		}

		int res = INF;
		for (int i = 0; i <= m; ++i)
			min_swap(res, dp[h][i]);
		if (res != INF)
			cout << res << endl;
		else
			cout << "Help!" << endl;
	}
}

Measured memory_bytes: 1236
def main():
    import heapq

    x, y, z, k, *abc = map(int, open(0).read().split())
    a = sorted(abc[:x], reverse=True)
    b = sorted(abc[x:x + y], reverse=True)
    c = sorted(abc[x + y:], reverse=True)
    s = set()

    h = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]
    heapq.heapify(h)
    num = []
    for _ in range(k):
        p, i, j, k = heapq.heappop(h)
        num.append(-p)
        for p, q, r in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
            p, q, r = min(i + p, x - 1), min(j + q, y - 1), min(k + r, z - 1)
            if (p, q, r) not in s:
                s.add((p, q, r))
                v = - (a[p] + b[q] + c[r])
                heapq.heappush(h, (v, p, q, r))

    ans = '\n'.join(map(str, num))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5308
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'


signed main() {
    fio();
    ll n, k;
    cin >> n >> k;
    ll mi = INF;
    rep (i, 10000) {
        chmin(mi, n);
        n = abs(n - k);
    }
    n = n % k;
    rep (i, 10000) {
        chmin(mi, n);
        n = abs(n - k);
    }
    cout << mi << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main()
{
    ll n;
    cin>>n;
    ll ans = (n/500)*1000;
    ll ans1 = ((n%500)/5)*5;
    cout<<ans+ans1;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

        Scanner s = new Scanner(System.in);

        while(true){
            int n =  s.nextInt();

            if(n == 0) break;

            int a = 0;
            int b = 0;

            for(int i = 0; i < n; i++){
                int cardA = s.nextInt();
                int cardB = s.nextInt();

                if (cardA > cardB){
                    a += cardA + cardB;
                } else if(cardB > cardA) {
                    b += cardA + cardB;
                } else {
                    a += cardA;
                    b += cardB;
                }
            }

            System.out.println( a + " " + b);
        }

    }

}

Measured memory_bytes: 51612
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp1[101][101010];
ll dp2[101][101010];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int m = sqrt(n);
    vector<ll> cnt;
    int tmp = m;
    for (int i = m; i >= 1; i--)
    {
        cnt.push_back(n / i - tmp);
        tmp = n / i;
    }
    for (int i = 0; i < m; i++)
    {
        dp1[0][i] = 1;
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < m; j++)
        {
            // m以下
            dp1[i + 1][j] = (dp1[i][m - 1] + dp2[i][m - 1 - j]) % MOD;
            if (j != 0)
            {
                (dp1[i + 1][j] += dp1[i + 1][j - 1]) %= MOD;
            }
            // mより大きい
            dp2[i + 1][j] = dp1[i][m - 1 - j] * cnt[j] % MOD;
            if (j != 0)
            {
                (dp2[i + 1][j] += dp2[i + 1][j - 1]) %= MOD;
            }
        }
    }
    ll ans = dp1[k][m - 1] + dp2[k][m - 1];
    ans %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 157308
import java.util.Scanner;

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

        while(true) {
            int n = sc.nextInt();
            if(n == 0) {
                break;
            }

            double[] score = new double[n];

            double sum = 0.0;
            for(int i=0; i<n; i++) {
                score[i] = sc.nextDouble();
                sum += score[i];
            }

            double avg = sum / n;

            double nSum = 0.0;
            for(int i=0; i<n; i++) {
                nSum += Math.pow(score[i]-avg, 2);
            }

            double tmp = nSum / n;
            System.out.println(String.format("%.9f",Math.sqrt(tmp)));
        }
        sc.close();
    }
}



Measured memory_bytes: 39164
# ABC099 C - Strange Bank 
N = int(input())
 
ans = N
for i in range(N+1):
    count = 0
    t = i
    while t:
        count += t%6
        t //= 6
    t = N-i
    while t:
        count += t%9
        t //= 9
    ans = min(ans, count)
print(ans)

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

using namespace std;

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

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

	string S; cin >> S;
	
	int res = 0;
	rep (i, (int)S.length()){
		if (S[i] == '+'){
			++res;
		}else{
			--res;
		} // end if
	} // end rep

	cout << res << endl;
	
	return 0;
}

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

int main(void){
    //input
    char S[3];
    scanf("%s",S);
    char T[3];
    scanf("%s",T);

    //calu
    int count = 0;
    for(int i = 0;i < 3; i++){
        if(strncmp(&S[i],&T[i],1)==0){
            count++;
        }
    }

    //output
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
if __name__ == '__main__':

    x,k,d = map(int,input().split())

    #マイナス座標はプラスに変換する
    x = abs(x)

    #総移動回数でどこまで行くか？
    tmp1 = x - k * d

    ans = 0
    if 0 <= tmp1:
        #残りがないのでその地点が最終値
        ans = tmp1
    else:
        #残りを正確に計算
        tmp = x // d
        #残り距離
        x -= tmp * d
        #残り回数
        k -= tmp

        if k%2 == 1:
            ans = abs(x-d)
        else:
            ans = x
    print(ans)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll P = 1e9+7;
const ll N = 1e6+7;


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

	ll t=1;
	// cin>>t;

	while(t--){
		ll n;
		cin>>n;

		vector<ll> dp(n+1);
		dp[0] = 0, dp[1] = 0, dp[2] = 0, dp[3] = 1;

		for(ll i=4;i<=n;++i) dp[i] = (dp[i-1] + dp[i-3])%P;

		cout<<dp[n]<<"\n";

	}	

	return 0;
}	


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define rep(i,N) for(int i=0;i<N;i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1e9+7;

int main() {
  ll M;
  cin >> M;
  
  ll answer = 24 + (24 - M);
  
  cout << answer << endl;
  return 0;
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
   int N;
   cin >> N;
   vector<int> p(N);
   FORV(a, p)
   {
      cin >> a;
   }
   int ans = 0;
   REP(i, 1, N - 2)
   {
      if ((p[i] - p[i - 1]) * (p[i + 1] - p[i]) > 0)
         ans++;
   }
   cout << ans << endl;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 256
import numpy as np
N,M,C = map(int,input().split())
b_list = np.array(list(map(int,input().split())))

ans = 0
for i in range(N):
    a_list = np.array(list(map(int,input().split())))
    s = sum(a_list*b_list)+C
    if s > 0:
        ans += 1
print(ans)

Measured memory_bytes: 12508
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let read_ints n = Array.init n (fun _ -> read_int ())

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let rec pow2 n = if n <= 0 then 1 else 2 * pow2 (n-1)

let inf = 202020202020

let () =
  let [|n; m; r|] = read_ints 3 in
  let rs = read_ints r |> Array.map (fun x -> x - 1) in
  let graph = Array.init n @@ fun _ -> Array.make n inf in
  for_iter_ 0 m (fun _ ->
    let [|a; b; c|] = read_ints 3 in
    graph.(a-1).(b-1) <- c;
    graph.(b-1).(a-1) <- c);

  for_iter_ 0 n (fun i -> graph.(i).(i) <- 0);
  for_iter_ 0 n (fun l -> for_iter_ 0 n @@ fun j -> for_iter_ 0 n @@ fun k ->
    graph.(j).(k) <- min graph.(j).(k) @@ graph.(j).(l) + graph.(l).(k));

  let rgraph = Array.init r @@ fun _ -> Array.make r inf in
  for_iter_ 0 r (fun j ->
    for_iter_ 0 r (fun k -> rgraph.(j).(k) <- graph.(rs.(j)).(rs.(k))));

  let lim = pow2 r in
  let memo = Array.init r @@ fun _ -> Array.make lim inf in
  for_iter_ 0 r (fun j -> memo.(j).(pow2 j) <- 0);

  for_iter_ 0 lim (fun n ->
    for_iter_ 0 r (fun j ->
      if n land pow2 j > 0 then
        let n' = n lxor pow2 j in
        for_iter_ 0 r (fun k ->
          let b = pow2 k in
          if n' land b > 0 then
            memo.(j).(n) <- min memo.(j).(n) (memo.(k).(n') + rgraph.(k).(j)))));

  for_iter 0 r (fun i -> memo.(i).(lim - 1))
  |> List.fold_left min inf
  |> printf "%d\n"


Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
using namespace std;
main(){
	int a[3],n;
	cin>>n;
	while(--n+1){
		for(int i=0;i<=2;++i){
			cin>>a[i];
		}
		sort(a,a+3);
		if (a[2]*a[2]==a[0]*a[0]+a[1]*a[1])cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

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

int main( void )
{
	float a,b,c,d,e,f;
	while( scanf( "%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f ) )
	{
		if( feof( stdin ) ) break;
		float det = 1.0f / ( a*e - b*d );
		float x = det * ( e*c - b*f );
		float y = det * ( -c*d + a*f );
		if( fabs( x ) < 0.001f ) x = 0.0f;
		if( fabs( y ) < 0.001f ) y = 0.0f;
		printf( "%.3f %.3f\n", x, y );
	}
	return 0;
}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
#define ci const int&
using namespace std;
int n,e[510][510],len,p;
int p2(int x){
	int tmp=1;
	while(!(x&1))++tmp,x>>=1;
	return tmp;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=(n>>1);++i)for(int j=1;j<=n;++j)e[j][(j+i-1)%n+1]=p2((j-1)^((j+i-1)%n));
	for(int i=1;i<=n;++i)for(int j=i+1;j<=n;++j)printf("%d%c",max(e[i][j],e[j][i])," \n"[j==n]);
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll h,w,n;
ll x,y;
char s[2][200010];
int main(){
	scanf("%lld%lld%lld%lld%lld",&h,&w,&n,&x,&y);
	scanf(" %s %s",s[0],s[1]);
	ll l=0,r=w,u=0,d=h;
	for(int i=n-1;i>=0;i--){
		if(s[1][i]=='U')d=min(d+1,h);
		if(s[1][i]=='D')u=max(u-1,0);
		if(s[1][i]=='L')r=min(r+1,w);
		if(s[1][i]=='R')l=max(l-1,0);
		if(s[0][i]=='U')u++;
		if(s[0][i]=='D')d--;
		if(s[0][i]=='L')l++;
		if(s[0][i]=='R')r--;
		if(u>=d||l>=r){puts("NO");return 0;}
//		printf("%d %d %d %d\n",u,d,l,r);
	}
	if(u<x&&x<=d&&l<y&&y<=r){puts("YES");return 0;}	
	puts("NO");
}

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

int main(){
  int W,a,b;
  cin>>W>>a>>b;
  if(a+W<=b||b+W<=a){
    if(a+W<=b){
    cout<<abs(b-(a+W))<<endl;
    }else{
      cout<<abs(a-(b+W))<<endl;
    }
  }else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll A,B,goukei=0;
    cin >> A >> B;
    int hako;

    hako = B - A;

    for(int i = 1;i <= hako;i++)
        goukei += i;
    
    cout << goukei - B << endl;
}

Measured memory_bytes: 3540
import sys
input = sys.stdin.readline

import copy

def main(): 

    a=[int(input()) for _ in range(6)]
    Flag = True
    for i in range(5):
        for j in range(5):
            if abs(a[i]-a[j]) > a[5]:
                Flag = False
                break
        if not(Flag):
            break
    if Flag:
        print("Yay!")
    else:
        print(":(")
    



if __name__ == "__main__":
    main()
    

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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<ll> A; 
vector<ll> S;

ll comb(int n, int k) {
    return long(n) * long(n - 1) / long(k);
}

ll solve() {
    ll res = 0;
    int i = 0;
    for (; i < (int) S.size();) {
        int j = i + 1;
        for (; j < (int) S.size() && S[j] == S[i]; j++) {}
        if (j - i > 1) {
            res += comb(j - i, 2);
        }
        i = j;
    }
    return res;
}

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

    A.resize(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    S.resize(N + 1);
    S[0] = 0;
    for (int i = 1; i <= N; i++) {
        S[i] = S[i - 1] + A[i];
    }
    sort(S.begin(), S.end());

    cout << solve() << endl;

    return 0;
}


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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}
    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;
typedef vector<Point> Polygon;

int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};

Point crosspointSS(const Segment &a,const Segment &b){
    Vector va = a.t-a.s, vb = b.t-b.s;
    double d = cross(vb,va);
    if(abs(d) < EPS) return b.s;
    return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}

typedef Segment Line;

#define prev(G,i) (G[(i-1+G.size())%G.size()])
#define curr(G,i) (G[i%G.size()])
#define next(G,i) (G[(i+1)%G.size()])

Polygon convex_cut(const Polygon &pg,const Line &l){
    Polygon res;
    for(int i = 0 ; i < (int)pg.size() ; i++){
        Point cp = curr(pg,i), np = next(pg,i);
        if(ccw(l.s,l.t,cp) != -1) res.push_back(cp);
        if(ccw(l.s,l.t,cp)*ccw(l.s,l.t,np) < 0){
            res.push_back(crosspointSS(Line(cp,np),l));
        }
    }
    return res;
}

double getArea(const Polygon &p){
    int N = p.size();
    double res = 0;
    for(int i = 1 ; i < N+1 ; i++){
        res += (p[i%N].x-p[i-1].x)*(p[i%N].y+p[i-1].y);
    }
    res /= 2.0;
    return abs(res);
}

int main(){
    int N,Q;
    cin >> N;
    Polygon pg(N);
    for(int i = 0 ; i < N ; i++){
        cin >> pg[i].x >> pg[i].y;
    }
    Line l;
    cin >> Q;
    while(Q--){
        cin >> l.s.x >> l.s.y >> l.t.x >> l.t.y;
        printf("%.12f\n",getArea(convex_cut(pg,l)));
    }
    return 0;
}

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

int main() {
  int N = 8672, A = 300 ;
  cin >> N >> A ;
  if(A >= (N%500) ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 
      
}


Measured memory_bytes: 256
X, N = map(int, input().split())
if N > 0:
    P = set(map(int, input().split()))
else:
    P = set()

d = 0
while True:
    for sign in [-1, 1]:
        cand = X + sign * d
        if cand not in P:
            print(cand)
            exit()
    d += 1



Measured memory_bytes: 9144
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int const N = 1e5 + 5;
const int INF = -1e15;

int32_t main(){
    int n, W;
    cin >> n >> W;
    
    vector<int> dp(W + 1, INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        int w, v;
        cin >> w >> v;
        
        for(int j = W; j >= w; j--){
            dp[j] = max(dp[j], dp[j - w] + v);
        }
    }
    
    int res = 0;
    for(int i = 1; i <= W; i++) res = max(res, dp[i]);
    cout << res << endl;
}




Measured memory_bytes: 1024
# coding: utf-8
card = [[0 for i in range(13)] for i in range(4)]
m=['S','H','C','D']

n=int(input())

for i in range(n):
    mark,num=(i for i in input().split())
    num=int(num)
    if mark=='S':
       card[0][num-1]=1
    elif mark=='H':
       card[1][num-1]=1
    elif mark=='C':
       card[2][num-1]=1
    elif mark=='D':
       card[3][num-1]=1

for i in range(4):
    for j in range(13):
        if card[i][j]==0:
            print("{} {}".format(m[i],j+1))


Measured memory_bytes: 5612
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

ll func(int a, int b, int c) {
    return  __gcd(__gcd(a, b),c);
}
int main(void) {
    int k; cin >> k;
    ll ans = 0;
    for(int a = 1; a <= k; a++)
    for(int b = 1; b <= k; b++)
    for(int c = 1; c <= k; c++) {
        ans += func(a,b,c);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
static const int inf = 1 << 30;

bool isKaibun(int num) {
  string s = to_string(num);
  if (s[0] != s[4])
    return false;
  if (s[1] != s[3])
    return false;
  return true;
}
int main(void) {
  int A, B;
  cin >> A >> B;
  int cnt = 0;
  for (int i = A; i <= B; i++) {
    if (isKaibun(i))
      cnt++;
  }

  cout << cnt << endl;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int p = 998244353;
const int maxn = 300050;

ll n, a, b, k, ans, fac[maxn], inv[maxn];

ll C(ll n, ll m)
{
	return (fac[n]*inv[m]%p)*inv[n-m]%p;
}
ll qpow(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans * a % p;
		b >>= 1; a = a*a%p;
	}
	return ans;
}
int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	cin >> n >> a >> b >> k;
	fac[0] = 1; fo(i,1,n) fac[i] = fac[i-1] * i % p;
	inv[n] = qpow(fac[n], p-2);
	fd(i,n-1,0) inv[i] = inv[i+1] * (i+1) % p;
	for(ll n1 = 0; n1 <= n; n1 ++)
	{
		if(k - n1 * a < 0) continue;
		if((k - n1 * a) % b != 0) continue;
		ll n2 = (k - n1 * a ) / b;
		if(n1 <= n && n2 <= n)
			ans = (ans + C(n,n1) * C(n,n2)) % p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n; cin >> n; int a[n];
	Rep(i, n) cin >> a[i];
	int ans = 0;
	Rep(i, 30){
		bool flag = true;
		Rep(j, n){
			if(a[j] % 2 == 0){
				a[j] /= 2;
			}else{
				flag = false; break;
			}
		}
		if(flag) ans += 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N[4];

int main(){
	for(int i = 0; i < 4; i++) scanf("%d", &N[i]);
	sort(N, N + 4);
	if(N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    char[] S = scanner.next().toCharArray();
    long M = 1_000_000_007;
    HashMap<Character, Integer> freq = new HashMap<>();
    long res = 0;
    for (char ch : S) {
      long c = 1;
      for (Map.Entry<Character, Integer> e : freq.entrySet()) {
        if (e.getKey() != ch) {
          c *= e.getValue() + 1;
          c %= M;
        }
      }
      res += c;
      if (res >= M) res -= M;
      freq.put(ch, freq.getOrDefault(ch, 0) + 1);
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 32620
package main

import "fmt"

func main() {
	var i1 string
	m := make(map[string]string)

	m["A"] = "T"
	m["G"] = "C"
	m["T"] = "A"
	m["C"] = "G"

	fmt.Scan(&i1)

	fmt.Print(m[i1])
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  cout<<N*(N-1)/2<<endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        int x = 0;
        for(int &it : a){
            cin >> it;
            x ^= it;
        }
        for(int i = 0; i < n; i++){
            cout << (x ^ a[i]) << ' ';
        }
        cout << '\n';
    }
}

Measured memory_bytes: 35848
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9+7;

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

  string s; cin >> s;
  int n = s.size();
  unordered_map<char, int> mp;
  rep(i, n) {
    mp[s.at(i)]++;
    if (mp[s.at(i)] > 1) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L0 = 2;
    long L1 = 1;
    int n = sc.nextInt();
    long sum = L1;
    for(int i = 2; i <= n; i++){
      sum = L0 + L1;
      L0 = L1;
      L1 = sum;
    }
    System.out.println(sum);
  }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=(n)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
   
    int n;
    cin >> n;
    vi l(2*n);
    rep(i,2*n){
        cin >> l[i];
    }

    sort(all(l));

    int ans=0;
    rep(i,n)ans+=l[2*i];

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

Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int a[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	int ret=0;
	for(int at=0,to=at;at<n;at=to) {
		bool inc=false,dec=false;
		for(++to;to<n;++to) if(a[to]==a[to-1]) continue; else if(a[to]>a[to-1]) { if(dec) break; else inc=true; } else if(a[to]<a[to-1]) { if(inc) break; else dec=true; } else assert(false);
		++ret;
	}
	printf("%d\n",ret);
}

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


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	ll mod=1000000007;
	ll n,m;
	cin>>n>>m;
	char a[n][m];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	ll dp[n][m];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			//cout<<dp[i][j]<<endl;
			if(a[i-1][j]!='#' && i-1>=0){
				dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
			}
			if(a[i][j-1]!='#' && j-1>=0){
				dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
			//cout<<dp[i][j]<<endl;
		}
	}
	cout<<dp[n-1][m-1]%mod<<endl;
	return 0;
}

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

bool prime(int n){
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  double sqrtn = sqrt(n);
  for (int i = 3; i <= sqrtn; i += 2){
    if (n % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
  int n, judge = 0;
  cin >> n;
  n -= 1;
  while(judge == 0){
    n++;
    if(prime(n)){
      judge++;
    }
  }
  cout << n << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pll, int > a, pair < pll, int > b)//true for a before b
{
	ll val = a.F.F*b.F.S - a.F.S*b.F.F;
	if(val >= 0LL)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 8000;

int func(int a, int k)
{
	if(a < k)
		return 0;
	if(a % k == 0)
		return (a/k);
	int x = (a/k)+1;
	int l = (a/k)*k;
	int r = max((a-l)/x,1);
	return func(a-r*x,k);
}

void solve()
{
	int n, i, ans = 0, a, k;
	cin >> n;
	fo(i,1,n+1)
	{
		cin >> a >> k;
		ans ^= func(a,k);
	}
	if(ans == 0)
		cout << "Aoki";
	else
		cout << "Takahashi";
	return;
}

int main()
{
	sws;
	// clock_t clk;
	// clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1;
	// cin >> t;
	while(t--)
		solve();
	// Code ends here

	// clk = clock() - clk;
	// cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	ld d;
	cin >> d;
	cout << fixed << setprecision(10);
	int cnt = 0;
	zip(i, 0, n)
	{
		ld x, y;
		cin >> x >> y;

		ld a = sqrt(x * x + y * y);
		debug(a);
		if (sqrt(x * x + y * y) <= d)
			cnt++;
	}
	cout << cnt << en;


	return 0;
}



Measured memory_bytes: 3872
c11, c12, c13 = gets.chomp.split.map(&:to_i)
c21, c22, c23 = gets.chomp.split.map(&:to_i)
c31, c32, c33 = gets.chomp.split.map(&:to_i)

# c11 - c12 = c21 - c22 = c31 - c32
# c12 - c13 = c22 - c23 = c32 - c33

exist = true
exist = false unless c11 - c12 == c21 - c22
exist = false unless c21 - c22 == c31 - c32
exist = false unless c12 - c13 == c22 - c23
exist = false unless c22 - c23 == c32 - c33

puts exist ? "Yes" : "No"


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

int main(){
    double a,b;
    double h,m;
    cin >> a >> b >> h >> m;
    double n = 60.0*h+m;
    double x0,x1,y0,y1;
    x0 = a*cos(-2*M_PI*(n/720.0));
    y0 = a*sin(-2*M_PI*(n/720.0));
    x1 = b*cos(-2*M_PI*(m/60.0));
    y1 = b*sin(-2*M_PI*(m/60.0));
    cout << setprecision(20) << sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)) << endl;
    return 0;
} 


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

int main(){
    char c; int cnt = 0, maxcnt = 0;
    for (int i = 0; i < 3; ++i){
        scanf(" %c", &c);
        if (c == 'R') ++cnt;
        else cnt = 0;
        maxcnt = max(cnt, maxcnt);
    }
    printf("%d", maxcnt);
}


Measured memory_bytes: 3824
#include"bits/stdc++.h"
using namespace std ;

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

#define bug( x ) cerr << #x << '=' << x << '\n' ;


long long H,W;





int main(){

	IOS

	cin >> H >> W ;

	
	if(H == 1 || W == 1 )cout<<"1\n";

	else cout << (H*W+1)/2 << '\n' ;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        for (int i = 0; i < e.length(); i++) {
            System.out.print(o.charAt(i));
            System.out.print(e.charAt(i));
        }

        if (o.length() != e.length()) System.out.print(o.charAt(o.length()-1));
    }
}


Measured memory_bytes: 21844
# -*- coding utf-8 -*-
import numpy as np

N, D = map(int, input().split())
X = np.array([list(map(int, input().split())) for _ in range(N)])

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        dist = np.sqrt(np.power(X[i] - X[j], 2).sum())
        if dist.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 12980
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int D, G; 
    cin >> D >> G;
    vector<int> p(D), c(D);
    
    for(int i=0; i<D; i++){
        cin >> p.at(i) >> c.at(i); 
    }
    
    int answer = 1000000;
    
    
    for (int tmp = 0; tmp < 1024; tmp++) {
            bitset<10> s(tmp);
            int cost=0;
            int nokori=G; 
            
            for(int i=0; i<D; i++){
                if(s.test(i)){
                     cost+= p.at(i);
                     nokori= nokori - (i+1) * 100 * p.at(i) - c.at(i);
                     //cout<< tmp <<" "<<100*(i+1)<<" "<<p.at(i)<<endl; 
                }
                
            }
            
            for(int i=D-1; i>=0; i--){
                if(s.test(i)==0){
                    if(nokori>0){
                        int num;
                        if( nokori%(100*(i+1)) ==0 ){
                            num = nokori/(100*(i+1));
                        }else{
                            num = nokori/(100*(i+1)) +1; 
                        } 
                        
                        cost = cost + min( num , p.at(i)-1 );
                        nokori = nokori - min( num , p.at(i)-1 ) * 100 * (i+1);
                        //cout<<tmp<<" "<<100*(i+1)<<" "<< min( num , p.at(i)-1 ) <<endl;  
                    } 
                }
            }
            
            if(nokori<=0) answer = min( answer, cost ); 
            
    }
    
    cout<< answer << endl; 

    
}


Measured memory_bytes: 256