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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    char a; cin >> a;
    if(a - 'A' > 25){
        cout << "a" << endl;
    }else{
        cout << "A" << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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


using namespace std;


int maxN=2e5+5;
int n,k;
vector<int>a(maxN);

bool isValid(int mid){
    int kk = 0; 
    if(mid==0)
        return false;
    for(int i=0;i<n;i++){
        if(a[i]<=mid)
            continue;
        int t=a[i]/mid;
        kk += t; ////t ta cut korsi ei log ke
    }
    return (kk<=k);///kk<=k hole EI MID or largest log value possibel
}
void solve(){
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int lo=0,hi=1e9+5;
    while(lo<=hi){
        int mid=(lo+hi)/2; 
        if(isValid(mid)){
            hi=mid-1;
        }
        else{
            lo = mid+1; 
        }
            
    }
    cout<<lo<<"\n"; 
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve(); 
    return 0;
}


Measured memory_bytes: 3872
import java.util.*;
import java.io.*;
import java.math.*;
import java.util.stream.*;

class Main {

    static Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(System.out);
    

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

       int n = sc.nextInt();
       List<Long> al = new ArrayList<>();
       Map<Long, Long> hash = new HashMap<>();
       long add = 0;
       
       for(int i = 0; i < n; ++i) {
            long x = sc.nextLong();
            al.add(x);
            add += x;
            long num = hash.getOrDefault(x, 0l) + 1l;
            hash.put(x, num);
       }
       
       int q = sc.nextInt();
       while(q-- > 0) {
           
           long b = sc.nextLong();
           long c = sc.nextLong();
           long sum = 0;
       
            long get = hash.getOrDefault(b, 0l);
            long temp = get * b;
            add -= temp;
            add += get * c;
            hash.remove(b);
            hash.put(c, hash.getOrDefault(c, 0l) + get);
            
            out.println(add);
       }

        out.flush();
        out.close();
        sc.close();
    }

    static final int MOD = (int) 1e9 + 7;
    static final double PI = 3.14159265358979323846;

    // takes array input
    public static Integer[] init(int n) {

        Integer[] arr = new Integer[n];

        for (int i = 0; i < n; ++i)
            arr[i] = sc.nextInt();

        return arr;
    }

    // finds GCD of two number
    public static int gcd(int a, int b) {

        if (a == 0) {
            return b;
        }

        return gcd(b % a, a);
    }

    // checks whether a number is prime or not
    public static boolean prime(int n) {

        if (n < 2)
            return false;

        for (int i = 2; i * i <= n; ++i)
            if (n % i == 0)
                return false;

        return true;
    }
}


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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

 int s, w; cin >> s >> w;
 if (s > w) {cout << "safe";}
  else {cout << "unsafe";}

	return 0;
}



Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            long ans = 1000;
            for (int i = 0; i < n - 1; i++) {
                long kabu = 0;
                if (a[i] < a[i + 1]) kabu = ans / a[i];
                ans += (a[i + 1] - a[i]) * kabu;
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 35692
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().split()]
ans = 0
for i in range(1, N + 1):
    i = str(i)
    total = 0
    for j in i:
        total += int(j)
    if A <= total <= B:
        ans += int(i)
print(ans)

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

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

    int buf = 0;
    int i = 0;
    while((int)n.length() > i){
        int num = stoi(n.substr(i,1));
        //cout << num << endl;
        buf += num;
        i++;
    }
    if(buf%9==0) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int i, j, w, h, n, l, m, a, b, cnt = 0;
    char str1[100][100] = { 0 };
    int str2[100][100] = { 0 };
    scanf("%d %d", &h, &w);
    for (i = 0; i < h; i++) {
        scanf("%s", str1[i]);
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (str1[i][j] == 'c') {
                str2[i][j] = 0;

            }
            else if (str1[i][j == '.']) {
                str2[i][j] = -1;
            }

        }
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (str1[i][j] == 'c') {
                for (a = j; a < w; a++) {
                    str2[i][a] = cnt;
                    cnt++;

                }
                cnt = 0;
            }
        }
    }
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if(j!=0){

                printf(" ");
               

            }
            printf("%d", str2[i][j]);
            }

        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2780
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define int long long
using namespace std;
int n,l,sum,A[505],mn=inf,gg;
main(){
	scanf("%lld %lld",&n,&l);
	for(int i=1;i<=n;i++){
		A[i]=i+l-1;
		sum+=A[i];
	}
	for(int i=1;i<=n;i++){
		int tut=sum-A[i];
		if(mn>abs(tut-sum)){
			mn=abs(tut-sum);
			gg=i;
		}
	}
	printf("%lld\n",sum-A[gg]);
	return 0;
}




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

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

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_131
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            long[] abcd = ReadLongs();
            long a = abcd[0];
            long b = abcd[1];
            long c = abcd[2];
            long d = abcd[3];

            long lcm = LCM(c, d);
            long res = b / c - (a - 1) / c;
            res += b / d - (a - 1) / d;
            res -= b / lcm - (a - 1) / lcm;
            WriteLine(b - a + 1 - res);
        }

        static long GCD(long a, long b)
        {
            if (b > a)
            {
                long temp = b;
                b = a;
                a = temp;
            }
            long c = b;
            do
            {
                c = a % b;
                a = b;
                b = c;
            } while (c > 0);
            return a;
        }

        static long LCM(long a, long b)
        {
            long c = GCD(a, b);
            return a * b / c;
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int solve() {

  string s, t;
  cin >> s >> t;

  // dp[i][j] := s_1,...s_i と t_1,...t_j に対するLCSの長さ
  // s[i] == t[j] なら dp[i-1][j-1] + 1
  // s[i] != t[j] なら max( dp[i-1][j], dp[i][j-1] )
  int dp[s.size()+1][t.size()+1];
  fill(dp[0], dp[s.size()+1], 0);
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j < t.size(); j++) {
      if( s[i] == t[j] ) {
        dp[i+1][j+1] = dp[i][j] + 1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
      }
    }
  }

  return dp[s.size()][t.size()];


}


int main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  for(int i = 0; i < N; i++) {
    cout << solve() << "\n";
  }


  return 0;
}

Measured memory_bytes: 7000
def antena(k,p,q):
    if((p-q) >k):
        return False
    else:
        return True

x = [0 for i in range(6)]
for i in range(6):
    x[i] = int(input())

for i in range(5):
    for j in range(5):
        if(not antena(x[i],x[j],x[5])):
            print(":(")
            exit()

print("Yay!")

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

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

    int bitsum = 0;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        bitsum = bitsum ^ tmp;
    }

    if (bitsum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int INF = 1e9 + 7;

int n, ans = INF;
char dat[300005];

int main()
{
	int cur = 0;
	scanf("%d%s", &n, &dat);
	for(int i = 1; i < n; i ++) if(dat[i] == 'E') cur ++;
	ans = cur;
	for(int i = 1; i < n; i ++) {
		cur -= (dat[i] == 'E');
		cur += (dat[i - 1] == 'W');
		ans = min(ans, cur);
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  int n,x;
  cin>>n;
  for(int i=1;i<n+1;i++){
    if(i%3==0)cout<<" "<<i;
    else if(i%10==3)cout<<" "<<i;
    else{
      for(x=i;x!=0;x/=10){
	if(x%10==3){
	  cout<<" "<<i;
	  break;
	}
      }
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1168
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]

print(ans)

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

int main(){
  int64_t x,y;
  cin >> x >> y;
  int64_t z=1;
  for(int i=1; i<=100000; i++){
    if(x%i==0&&y%i==0) z=i;
  }
  cout << x/z*y << endl;
}

Measured memory_bytes: 256
// ConsoleApplication.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdio.h"
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_set>
#include <functional>

using namespace std;

bool canGenerateNum(const vector<int>& vec, const int number)
{
	function<bool(const vector<int>& v, const int index, const int num)> canGenerateNumImpl = [&](const vector<int>& v, const int index, const int num) {
		if (num == 0)return true;
		if (num < 0 || index == v.size())return false;
		return canGenerateNumImpl(v, index + 1, num) || canGenerateNumImpl(v, index + 1, num - v.at(index));
	};
	return canGenerateNumImpl(vec, 0, number);
}

int main()
{
	int n;
	cin >> n;
	vector<int> ary(n);
	for (auto& i : ary)cin >> i;

	int q;
	cin >> q;
	vector<int> num(q);
	for (auto& i : num)cin >> i;

	for (const auto& i : num){
		cout << (canGenerateNum(ary, i) ? "yes" : "no") << endl;
	}


	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define pi (double)acos(-1)
using namespace std;
set<long long> s;
vector<int> v;

void solve()
{
    int inp;
    cin>>inp;
    int a=inp%100;
    int b=inp/100;
    if(a<=12&&a>0)
    {
        if(b<=12&&b>0)
            cout<<"AMBIGUOUS";
        else
            cout<<"YYMM";
    }
    else if(b<=12&&b>0)
        cout<<"MMYY";
    else
        cout<<"NA";
    return;
}
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--) {solve();}
	return 0;
}


Measured memory_bytes: 384
n = int(input())

c = 0
t = n
while t // 10 != 0:
    c += 1
    t = t // 10

ans = 0
if c == 0:
    ans = n
elif c == 1:
    ans = 9
elif c == 2:
    ans = n - 99 + 9
elif c == 3:
    ans = 909
elif c == 4:
    ans = n - 9999 + 909
else:
    ans = 90909

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>

using namespace std;

int main(void){
    stack<int> s1;
    stack<pair<int,int> > s2;
    char ch;
    int sum=0;
    for(int i=0;cin>>ch;++i){
        if(ch == '\\') s1.push(i);
    else if(ch == '/' && s1.size()>0){
        int j=s1.top();s1.pop();
        sum += i-j;
        int a = i-j;
        while(s2.size()>0 && s2.top().first>j){
            a += s2.top().second;
            s2.pop();
        }
        s2.push(make_pair(j,a));
    }
    }
    
    vector<int> ans;
    while(s2.size()>0){
        ans.push_back(s2.top().second);
        s2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout<<sum<<endl;
    cout<<ans.size();
    for(int i=0;i<ans.size();++i){
        cout<<" ";
        cout<<ans[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3256
// LOVED IT

#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
    
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// struct chash { int operator()(int x) const { return x ^ RANDOM; }};
// cc_hash_table<int, int, hash<int>> cnt;

const int MAXN = 305;
int dp[MAXN][MAXN][MAXN];
const int MOD = 998244353;
string s; int k,n,m;
vector<int> one_cnt;

int rec(int idx,int carry,int step){
    if(step < 0) return 0;

    if(idx == -1) return (carry == 0);
    
    int &ans = dp[idx][carry][step];
    if(ans != -1) return ans;
    ans = 0;

    int total_ones_here = one_cnt[idx] + carry;

    FOR(how_many_here,0,total_ones_here){
        int to_go_head = total_ones_here - how_many_here;
        int steps_here = max(0LL,to_go_head - carry);
        ans = (ans + rec(idx-1,to_go_head,step-steps_here))%MOD;
    }
    return ans;
}

void solve(){
    MINUS(dp);
    cin>>s>>k; n = sz(s); k = min(k,n);

    int cnt = 0;
    for(char c:s){
        if(c == '0'){
            one_cnt.push_back(cnt);
            cnt = 0;
        }else cnt++;
    }
    if(cnt) one_cnt.push_back(cnt);
    m = sz(one_cnt);

    cout<<rec(m-1,0,k)<<endl;
}
    
signed main(){
    
    FastRead;     
    
    int t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
    




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

string s;

int main(void){
	cin >> s;
	int n = s.size();
	bool ans = false;
	rep(i, n){
		rep(j, n){
			if(j < i) continue;
			if(s.substr(0, i)+s.substr(j) == "keyence") ans = true;
		}
	}
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
 public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int q = sc.nextInt();
        
        for (int i = 0; i < q; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            long r = (long) Math.sqrt(a * b);
            long r2 = a*b / r;
            long ans = f(a, b, r, r2) + f(a, b, r2, r);
            ans /= 2;
            System.out.println(ans);
        }
    }
    
    static long f(long a, long b, long r, long r2) {
        long ans;
        
        if (r * r2 == a * b) {
            ans = (r-1) * 2;
        } else {
            ans = r + r2 - 1;
        }
        if (a < r) {
            ans--;
        }
        if (b < r2) {
            ans--;
        }
        if ((a == r || b == r) && !(r * r2 == a * b)) {
            ans--;
        }
        return ans;
    }
}


Measured memory_bytes: 21204
a,b,c,d =input().split()
if int(a)==int(b) and int(c)==int(d) : print("yes")
elif int(c)==int(b) and int(a)==int(d) : print("yes")
elif int(c)==int(a) and int(b)==int(d) : print("yes")
else : print("no")


Measured memory_bytes: 5596
a = int(input())
t = 0
x = 0
y = 0
count = 0
for i in range(a):
    l = list(map(int,input().split(" ")))
    if (l[0] - t) >= (abs(l[1]-x) + abs(l[2]-y)):
        if ((abs(l[1]-x)+abs(l[2]-y)) - (l[0] - t)) % 2 == 0:
            count += 1
    t = l[0]
    x = l[1]
    y = l[2]
if count == a:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<PP,vector<PP>,greater<PP>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
//const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
ll ans=0,t=1,mod,di;
ll fac(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b&1)return (a*fac(a,b-1))%mod;
    return (fac(a,b/2)*fac(a,b/2))%mod;
}
ll f(ll n){
    if(n==0)return 0;
    if(n&1)return (f(n-1)*(t%mod)+1)%mod;
    else return (f(n/2)+f(n/2)*fac((t%mod),n/2))%mod;
}
ll g(ll n){
    if(n==0)return 0;
    if(n&1)return (g(n-1)*(t%mod)+di%mod*(n-1))%mod;
    return (g(n/2)+(g(n/2)*fac((t%mod),n/2))%mod+(di%mod*(n/2)%mod*f(n/2))%mod)%mod;
}

int main(){
    ll length,shokou;cin>>length>>shokou>>di>>mod;
    ll last=shokou+di*(length-1);
    REP(i,1,19){
        t*=10;
        if(shokou>=t)continue;
        if(last<t/10)continue;
        ll nshokou,nlength,nlast;
        if(shokou>=t/10)nshokou=shokou;
        else {
            nshokou=((t/10-shokou-1)/di+1)*di+shokou;
            chmin(nshokou,last);
        }
        if(t>last)nlast=last;
        else nlast=((t-shokou-1)/di)*di+shokou;
        nlength=(nlast-nshokou)/di+1;
        ans=((ans*fac(t,nlength))%mod+((nshokou%mod)*f(nlength))%mod+g(nlength)%mod)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#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;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b)
#define mins(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    int n;cin>>n;
    vc<vc<pi>> edge(n+1);
    int a,b;
    rep(i,n-1){
        cin>>a>>b;
        edge[a].emplace_back(b,i);
        edge[b].emplace_back(a,i);
    }

    int k=0;
    repa(i,1,n+1){
        if(k<edge[i].size())
            k=edge[i].size();
    }

    vi ans(n-1,-1);

    queue<pi> que;
    que.emplace(1,0);

    while(!que.empty()){
        pi e=que.front();que.pop();
        rep(i,edge[e.first].size()){
            if(ans[edge[e.first][i].second]!=-1)continue;
            e.second++;
            ans[edge[e.first][i].second]=e.second%k;
            que.emplace(edge[e.first][i].first,e.second);
        }
    }

    cout<<k<<endl;
    rep(i,n-1){
        cout<<ans[i]+1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<vector>
#include<cstdlib>
#include<algorithm>

using namespace std;

const long long INF = 1LL << 60;

template<typename T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}

template<typename T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

long long a[1000000][3];
long long dp[1000000][3];

int main() {
	int n;
	cin >> n;
	
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 3;j++) {
			cin >> a[i][j];
		}
	}

	
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < 3;j++) {
			for (int k = 0;k < 3;k++) {
				if (j == k)continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	long long res = 0;
	for (int j = 0; j < 3; ++j) chmax(res, dp[n][j]);
	cout << res << endl;
}



Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;
using P = pair<int, int>;
 
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> p(n);
    vector<int> idx(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
        idx[i] = i;
    }
    int c = 0;
    double sum = 0;
    do
    {
        ++c;
        for (int i = 1; i < n; ++i) {
            sum += sqrt((p[idx[i]].first - p[idx[i - 1]].first) * (p[idx[i]].first - p[idx[i - 1]].first) + (p[idx[i]].second - p[idx[i - 1]].second) * (p[idx[i]].second - p[idx[i - 1]].second));
        }
    } while (next_permutation(idx.begin(), idx.end()));
    cout << setprecision(14) << sum / c << '\n';
    return 0;
}


Measured memory_bytes: 256
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    ans = 0
    for i in range(N):
        l, r = get_next_ints()
        ans += r-l+1
    print(ans)
solve()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	static final int INF = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[100001];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		for(int i = 0 ; i < n ; i++) b[a[i]]++;
		long ans = 1;
		boolean ok = true;
		if(n % 2 == 0) {
			for(int i = 0 ; i < n / 2 ; i++) {
				if(b[2 * i + 1] != 2) ok = false;
			}
		} else {
			for(int i = 0 ; i < n / 2 ; i++) {
				if(i == 0) {
					if(b[0] != 1) ok = false;
				} else {
					if(b[2 * i] != 2) ok = false;
				}
			}
		}
		if(ok) {
			for(int i = 0 ; i < n / 2 ; i++) {
				ans = ans * 2 % INF;
			}
		} else {
			ans = 0;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50752
#include<iostream>
using namespace std;
static const int N = 100;
void trace(int A[], int n){
    for(int i = 0; i < n; i++){
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}
void SelectionSort(int A[], int n){
    int i,j,minj,cnt=0,tmp;
    for(i = 0; i < n-1; i++){
        minj = i;
        for(j = i; j < n; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[i] != A[minj]){
            cnt++;
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
        }
    }
    trace(A,n);
    cout << cnt << endl;
}
int main(){
    int n;
    int A[N+1];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    SelectionSort(A,n);
}

Measured memory_bytes: 3108
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
vector<pair<int,int> >g[1100];
int s[10];
int t[10];
int dist[15][15];
int pt[15];
int ijk[1100];
int v[1100];
int c;
void calc(int a){
	for(int i=0;i<1100;i++){
		ijk[i]=99999999;
		v[i]=0;
	}
	ijk[pt[a]]=0;
	priority_queue<pair<int,int> > Q;
	Q.push(make_pair(0,pt[a]));
	while(Q.size()){
		int cost=-Q.top().first;
		int at=Q.top().second;
		Q.pop();
		if(v[at])continue;
		v[at]=1;
		for(int i=0;i<g[at].size();i++){
			if(!v[g[at][i].first]&&ijk[g[at][i].first]>cost+g[at][i].second){
				ijk[g[at][i].first]=cost+g[at][i].second;
				Q.push(make_pair(-ijk[g[at][i].first],g[at][i].first));
			}
		}
	}
	for(int i=0;i<c*2+1;i++)dist[a][i]=ijk[pt[i]];
}
int dp[1000][20];
int pow3[10];
int main(){
	int a,b,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);d--;
	for(int i=0;i<b;i++){
		int p,q,r;
		scanf("%d%d%d",&p,&q,&r);
		p--;q--;
		g[p].push_back(make_pair(q,r));
		g[q].push_back(make_pair(p,r));
	}
	for(int i=0;i<c;i++){
		scanf("%d%d",s+i,t+i);
		s[i]--;t[i]--;
		pt[i*2]=s[i];
		pt[i*2+1]=t[i];
	}
	pt[c*2]=d;
	for(int i=0;i<c*2+1;i++){
		calc(i);
	}
	pow3[0]=1;
	for(int i=1;i<10;i++)pow3[i]=pow3[i-1]*3;
	for(int i=0;i<1000;i++)for(int j=0;j<20;j++){
		dp[i][j]=99999999;
	}
	dp[0][c*2]=0;
	for(int i=0;i<pow3[c];i++){
		for(int j=0;j<c*2+1;j++){
			for(int k=0;k<c;k++){
				if(i%pow3[k+1]/pow3[k]==2)continue;
				if(i%pow3[k+1]/pow3[k]==1){
					dp[i+pow3[k]][k*2+1]=min(dp[i][j]+dist[j][k*2+1],dp[i+pow3[k]][k*2+1]);
				}else{
					dp[i+pow3[k]][k*2]=min(dp[i][j]+dist[j][k*2],dp[i+pow3[k]][k*2]);
				}
			}
		}
	}
	int ret=99999999;
	for(int i=0;i<c*2+1;i++)ret=min(ret,dp[pow3[c]-1][i]);
	if(ret>88888888)printf("Cannot deliver\n");
	else printf("%d\n",ret);
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  
  cin >> a.at(0) >> b.at(0)  >> c.at(0);
  for(int i=1;i < n;i++){
    int x,y,z;
    cin >> x >> y >> z;
    a.at(i) = x + max(b.at(i-1),c.at(i-1));
    b.at(i) = y + max(a.at(i-1),c.at(i-1));
    c.at(i) = z + max(a.at(i-1),b.at(i-1));
  }
  
  cout << max(a.at(n-1),max(b.at(n-1),c.at(n-1))) << endl;
}

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

from collections import Counter

c = Counter(a)
d = c.most_common()

if len(d) <= k:
    print(0)

else:
    ans = 0
    while len(d) > k:
        item = d.pop()
        ans += item[1]
    print(ans)


Measured memory_bytes: 40220
use std::io;
use std::cmp::min;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let a = v[1];
	let b = v[2];
	println!("{}", min(a*n, b));
}

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

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

class _0107
{
    public static void Main()
    {
        int n;
        double[] g = new double[3];
        double r;
        string[] bar;
        while (true)
        {
            bar = Console.ReadLine().Split();
            if (bar[0] == "0" && bar[1] == "0" && bar[2] == "0") break;
            g[0] = double.Parse(bar[0]) / 2;
            g[1] = double.Parse(bar[1]) / 2;
            g[2] = double.Parse(bar[2]) / 2;
            Array.Sort(g);
            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                r = double.Parse(Console.ReadLine());
                Console.WriteLine((Math.Sqrt(g[0] * g[0] + g[1] * g[1]) < r) ? "OK" : "NA");
            }
        }
    }
}

Measured memory_bytes: 5732
n = int(input())
s = input()
k = int(input())

a = s[k-1]
li = []
s2 = ''

for i in range(n):
    if s[i] != a:
        li.append(i)

for i in range(n):
    if i in li:
        s2 = s2 + '*'
    else:
        s2 = s2 + s[i]

print(s2)


Measured memory_bytes: 3060
N, D = map(int, input().split(" "))
X = [list(map(int, input().split(" "))) for _ in range(N)]

count = 0
for i in range(N):
    for j in range(i+1, N):
        m = sum((y-z)**2 for y, z in zip(X[i], X[j]))**(1/2)
        # print(i, j, m)
        if m % 1 == 0:
            count += 1

print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	int n, k; string s;
	cin >> n >> s >> k;
	rep(i, n)if (s[i] != s[k - 1])s[i] = '*';
	co(s);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    string s, t;
    cin >> s >> t;
    ll result = 0;
    for0(i, s.length()){
        if (s[i] != t[i]) {
            ++result;
        }
    }
    cout << result << "\n";


    return 0;
}


Measured memory_bytes: 3776
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val n  = sc.nextInt
  val tl = List.fill(n)(sc.nextInt)
  val m  = sc.nextInt
  val cl = List.fill(m)((sc.nextInt, sc.nextInt))

  val nSum = tl.sum

  val ress = cl.map{case (p,x) => nSum - tl(p - 1) + x}

  ress.foreach(println)
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

bool same(vi x, vi y)
{
    REP(i, x.size())
    {
        if(x[i] != y[i]) return false;
    }
    return true;
}

void solve()
{
    int N; cin >> N;
    vi P(N), Q(N), n(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> Q[i];
    REP(i, N) n[i] = i+1;
    int i = 1;
    int a, b;
    do
    {
        i++;
        if(same(n, P)) a = i;
        if(same(n, Q)) b = i;
    } while(next_permutation(ALL(n)));
    cout << abs(a - b) << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  cout << (n-1)*n/2 << endk;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
  int x,y;
  while(1){
  scanf("%d %d",&x,&y);
  if(x==0&&y==0){
    break;
  }
  if(x<y){
    printf("%d %d\n",x,y);
  }
  if(y<x){
    printf("%d %d\n",y,x);
  }
  if(y==x){
    printf("%d %d\n",x,y);
  }
  }
  return 0;
}


Measured memory_bytes: 2028
/* 
 * Project: AtCoder Beginners Contest 095 B - Bitter Alchemy
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/12
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;

int n, x;
int m[1000];

void solve() {

    sort(m, m+n);
    int last = x - accumulate(m, m+n, 0);
    int count = n;
    for (;last>=m[0];count++) {
        last -= m[0];
    }
    printf("%d\n", count);

}

int main() {

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

    solve();

}

Measured memory_bytes: 256
n, m = map(int, input().split())
 
forbidden = []
for i in range(m):
  forbidden.append(int(input()))
forbidden = set(forbidden) 
ans = [0]*(n+1)
ans[0] = 1
if 1 not in forbidden:
  ans[1] = 1
for i in range(2,n+1):
  if i not in forbidden:
    ans[i] += ans[i - 1] + ans[i - 2]
    ans[i] %= 1000000007
print(ans[-1])

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

int main(void)
{

    int N,H,W,cnt = 0,x0,x1,y0,y1,a,xi,yi,ans;
    cin >> W >> H >> N;

    x0 = 0;
    y0 = 0;
    x1 = W;
    y1 = H;

    rep(i, N){
        cin >> xi >> yi >> a;

        
        switch (a)
        {
        case 1:
            x0 = max(xi,x0);
            break;
        
        case 2:
            x1 = min(xi,x1);
            break;

        case 3:
            y0 = max(yi,y0);
            break; 
        default:
            y1 = min(yi,y1);
            break;
        }
    }

    ans = (x1-x0)*(y1-y0);

    if(x1-x0 < 0 || y1-y0 < 0)
        ans = 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

typedef long long ll;

typedef pair<ll, ll>P;
map<P, ll>memo;

ll sum(ll N, ll X){
    //if(X==0LL)cout<<N<<" "<<X<<" "<<0<<endl;
    //else if(N==0LL)cout<<N<<" "<<X<<" "<<1<<endl;
    //else if(X==1LL)cout<<N<<" "<<X<<" "<<0<<endl;
    if(memo.count(P(N, X)))return memo[P(N, X)];
    if(X==0LL)return 0LL;
    if(N==0LL)return 1LL;
    if(X==1LL)return 0LL;
    ll lstlen = 1LL;
    for(ll i = 1LL;i<N;i++)lstlen = 3LL + lstlen + lstlen;
    ll tmp = 0LL;
    if(X <= 1LL){
        tmp = 0LL;
    }
    else if(X <= 1LL + lstlen){
        tmp += sum(N - 1LL, X - 1LL);
    }
    else if(X <= 1LL + lstlen + 1LL){
        tmp = sum(N - 1LL, lstlen) + 1LL;
    }
    else if(X <= 1LL + lstlen + 1LL + lstlen){
        tmp = sum(N - 1LL, lstlen) + 1LL + sum(N - 1LL, X - 1LL - lstlen - 1LL);
    }
    else{
        tmp = sum(N - 1LL, lstlen) + 1LL + sum(N - 1LL, lstlen);
    }

    //cout<<N<<" "<<X<<" "<<tmp<<endl;
    memo[P(N, X)] = tmp;
    return tmp;
}

int main(){

    ll N, X;
    cin>>N >> X;
    cout<<sum(N, X)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

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

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	string a, b;
	cin >> a >> b;
	
	ll ans = 0;
	
	for(int i = 0; i < 3; i++)
		if(a[i] == b[i])
			ans++;
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N;
        HashMap<Integer, Integer> mp;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            mp = new HashMap<>();
            for (int i = 0; i < N; i++) {
                int a = in.nextInt();
                mp.putIfAbsent(a, 0);
                mp.put(a, mp.get(a) + 1);
            }

            int dup = 0;
            for (Map.Entry<Integer, Integer> e : mp.entrySet()) {
                if (e.getValue() > 1) {
                    dup += e.getValue() - 1;
                }
            }

            int ans = 0;
            if (dup % 2 == 0) {
                ans = N - dup;
            } else {
                ans = N - dup - 1;
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

int main()
{
	int n, r, p, c;
	while (true) {
		cin >> n >> r;

		if (n == 0 && r == 0) {
			break;
		}
		vector<int> cards;
		for (int i = 1; i <= n; i++) {
			cards.push_back(i);
		}

		for (; r > 0; r--) {
			cin >> p >> c;

			p = n - p - c + 1;
			for (; c > 0; c--) {
				cards.push_back(cards[p]);
				cards.erase(cards.begin() + p);
			}
		}
		cout << cards.back() << '\n';
	}
	return 0;
}

Measured memory_bytes: 1220
package main

import (
	"fmt"
	"math/big"
	"strconv"
	"strings"
)

func main() {
	var A string
	var s string
	fmt.Scanf("%s %s", &A, &s)
	ss := strings.Split(s, ".")
	b0, _ := strconv.ParseInt(ss[0], 10, 64)
	b1, _ := strconv.ParseInt(ss[1], 10, 64)
	b := b0*100 + b1
	a := new(big.Int)
	a.SetString(A, 10)
	ans := a.Mul(a, big.NewInt(b))

	ans.Div(ans, big.NewInt(100))
	fmt.Println(ans)
}


Measured memory_bytes: 1960
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    if ((A+B)%2) cout << "IMPOSSIBLE" << endl;
    else cout << (A+B)/2 << endl;
    return 0;
}




Measured memory_bytes: 256