akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 18;
int N;
int A[1 << MAX_N];
std::vector<int> bits_num[MAX_N];

std::vector<int> choose_idx[1 << MAX_N];

bool has_bit(int x, int loc) {
    return (x >> loc) & 1;
}

int bit_count(int x) {
    int ret = 0;
    for (int i = 0; i < MAX_N; i++) {
        if (has_bit(x, i)) {
            ret++;
        }
    }
    return ret;
}
 
int main(int argc, char **argv) {
    std::cin >> N;

    int pow_max = (1 << N);

    for (int i = 0; i < pow_max; i++) {
        std::cin >> A[i];
    }

    for (int i = 0; i < pow_max; i++) {
        bits_num[bit_count(i)].push_back(i);
    }

    for (int i = 1; i < pow_max; i++) {
        choose_idx[i].push_back(0);
        choose_idx[i].push_back(i);
        std::sort(choose_idx[i].begin(), choose_idx[i].end(),
            [](const int& a, const int& b) { return A[a] > A[b]; }
        );
    }

    for (int bn = 1; bn < N; bn++) {
        for (int orig : bits_num[bn]) {
            for (int add : bits_num[1]) {
                int next = orig | add;
                choose_idx[next].push_back(choose_idx[orig][0]);
                choose_idx[next].push_back(choose_idx[orig][1]);

                std::sort(choose_idx[next].begin(), choose_idx[next].end(),
                    [](const int& a, const int& b) { return A[a] > A[b]; }
                );
                std::unique(choose_idx[next].begin(), choose_idx[next].end());
                choose_idx[next].resize(2);
            }
        }
    }

    int ret = 0;
    for (int i = 1; i < pow_max; i++) {
        ret = std::max(ret, A[choose_idx[i][0]] + A[choose_idx[i][1]]);
        std::cout << ret << std::endl;
    }

    return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> a(n), b(n), c(m), d(m);
	rep(i,n) cin >> a[i] >> b[i];
	rep(i,m) cin >> c[i] >> d[i];
	rep(i,n){
		int id = -1;
		ll dist = 1e18;
		rep(j,m){
			if(abs(a[i]-c[j]) + abs(b[i]-d[j]) < dist){
				id = j+1;
				dist = abs(a[i]-c[j]) + abs(b[i]-d[j]);
			}
		}
		cout << id << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, k);
    for(;k--;){
      int2(a, b);
      --a; --b;
      a = min(a, n - 1 - a);
      b = min(b, n - 1 - b);
      int tmp = min(a, b) % 3;
      pri(tmp + 1);
    }

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3216
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			if (N == 0 && M == 0) break;
			int[] T = new int[N + M + 1];
			for (int i = 0; i < N; ++i) {
				T[i] = sc.nextInt();
			}
			for (int i = 0; i < M; ++i) {
				T[N + i] = sc.nextInt();
			}
			Arrays.sort(T);
			int ans = 0;
			for (int i = 0; i < T.length - 1; ++i) {
				ans = Math.max(ans, T[i + 1] - T[i]);
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 13000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayDeque;

public class Main{

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        ArrayDeque<Integer> stack = new ArrayDeque<Integer>();
        String[] t = br.readLine().split(" ");
        for(int i = 0; i < t.length; i++){
            if( t[i].equals("+") || t[i].equals("-") || t[i].equals("*") ){
                int ope1 = stack.pop();
                int ope2 = stack.pop();
                if(t[i].equals("+") ){
                    stack.push(ope1 + ope2);
                }else if(t[i].equals("-") ){
                    stack.push(ope2 - ope1);
                }else if(t[i].equals("*") ){
                    stack.push(ope1 * ope2);
                }
            }else{
                //int ope = Integer.parseInt(t[i]);                                    
                stack.push(Integer.parseInt(t[i]));
            }
        }
        //int ans = stack.pop();                                                       
        System.out.println(stack.pop());
    }

}

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N;
str S;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> N >> S;
	if (N % 2) {
		cout << "No";
	} else {
		S.substr(0, N / 2) == S.substr(N / 2, N / 2) ? cout << "Yes" : cout << "No";
	}
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 256
# AtCoder Beginner Contest 130
# B - Bounding
import bisect

N,X=map(int,input().split())
L=list(map(int,input().split()))

accumu_L=[0]

for i in range (N):
    accumu_L.append(accumu_L[-1]+L[i])

# print(accumu_L)

print(bisect.bisect_right(accumu_L,X))

Measured memory_bytes: 8992
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let v:Vec<i64> = (0..n).map(|_| read()).collect();

    let mut dp = vec![std::i64::MAX; n+2];
    dp[0] = 0;
    for i in 1..n {
        dp[i] = min(dp[i], dp[i-1] + (v[i] - v[i-1]).abs());
        if i > 1 {
            dp[i] = min(dp[i], dp[i-2] + (v[i] - v[i-2]).abs());
        }
    }
    println!("{}", dp[n-1]);
}

Measured memory_bytes: 3480
#include <iostream>
using namespace std;
int main(){

  int n,a[100],result=0,i,j;

  cin>>n;
  for(i=0;i<n;i++) cin>>a[i];

  for(i=0;i<n-1;i++){
    int now,minnum=101;
    for(j=i;j<n;j++) if(minnum>a[j]){
        now=j;
        minnum=a[j];
      }
    if(i!=now){
      swap(a[i],a[now]);
      result++;
    }
  }
  for(i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl;

  cout<<result<<endl;
  return 0;
}



Measured memory_bytes: 3088
def main():
    l, r = map(int, input().split())
    if l + 2019 <= r:
        print(0)
    else:
        ans = float("inf")
        for i in range(l, r + 1):
            for j in range(i + 1, r + 1):
                ans = min(ans, (i * j) % 2019)
        print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
import java.util.Scanner;

class Main {

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

			for (int i=0; i<s.length(); i++) {
				int a = s.charAt(i);
				if ((a>=65) && (a<=90)) {
					a += 32;
					System.out.print(Character.toChars(a));
				}
				else if ((a>=97) && (a<=122)) {
					a -= 32;
					System.out.print(Character.toChars(a));
				} else System.out.print(s.charAt(i));
			}
			System.out.print("\n");
		}
	}
}



Measured memory_bytes: 26912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long n, k;
long long a[200005], f[200005];
long long ans = 0;
#define int long long


long long temp[200005];

bool check(long long x) {
    for (ll i = 1; i <= n; i++)
        temp[i] = x / f[i];
    sort(temp + 1, temp + 1 + n);
    long long qaq = 0;
    for (long long i = n; i >= 1; i--)
        qaq += max(0ll, a[i] - temp[i]);
    return qaq <= k;
}

signed main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    for (int i = 1; i <= n; i++)
        scanf("%lld", &f[i]);
    sort(a + 1, a + n + 1);
    sort(f + 1, f + n + 1);
    long long l = 0, r = 1e12;

    while (l <= r) {
        long long mid = (l + r) >> 1;
        if (check(mid))
            ans = mid, r = mid - 1;
        else
            l = mid + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define modulo N
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000005



int main(){
	
	int N;
	cin>>N;
	
	vector<int> n(3);
	cin>>n[0]>>n[1]>>n[2];
	
	vector<string> S(N);
	for(int i=0;i<N;i++)cin>>S[i];
	
	string ans = "";
	
	for(int i=0;i<N;i++){
		pair<int,int> p;
		if(S[i]=="AB")p={0,1};
		else if(S[i]=="BC")p={1,2};
		else p={0,2};
		
		if(n[p.first]==0&&n[p.second]==0){
			cout<<"No"<<endl;
			return 0;
		}
		
		if(n[p.first]==1&&n[p.second]==1){
			if(i==N-1||(S[i+1][0]!=S[i][0]&&S[i+1][1]!=S[i][0])){
				n[p.first]--;
				n[p.second]++;
				ans+=S[i][1];
			}
			else{
				n[p.first]++;
				n[p.second]--;
				ans+=S[i][0];
			}
		}
		else{
			if(n[p.first]>=n[p.second]){
				ans+=S[i][1];
				n[p.first]--;
				n[p.second]++;
			}
			else{
				ans+=S[i][0];
				n[p.first]++;
				n[p.second]--;
			}
		}
	}
	
	cout<<"Yes"<<endl;
	for(int i=0;i<N;i++)cout<<ans[i]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 6696
function main(input) {
    const r =input.split('').some((v,i) => (v === 'R' && (i+1) % 2 === 0) || (v === 'L' && (i+1) % 2 !== 0));
    console.log(r ? "No" : "Yes");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
import sys
n,m = map(int, input().split())
if n > m:
    print(0)
    sys.exit(0)
a = list(map(int, input().split()))
a.sort()
b = list()
for i in range(m-1):
    b.append(a[i+1]-a[i])
b.sort()
b.reverse()
ans = a[m-1] - a[0]
for i in range(n-1):
    ans -= b[i]
print(ans)

Measured memory_bytes: 13968
import Data.List

isLeg :: Int -> Int -> Int -> Int
isLeg x y legs
  | 2 * x + 4 * y == legs = x + y
  | otherwise = 0

legCount :: Int -> Int -> Int
legCount animals legs =
    sum $ map (\x -> isLeg x (animals - x) legs) [0..animals]

main = do
    [b,c] <- map read . words <$> getLine
    let l = legCount b c
    putStrLn $ if l > 0 then "Yes" else "No"


Measured memory_bytes: 3784
#include <stdio.h>

int h[100];
int count = 0;

void func(int l, int r)
{
    int i, j, min = 100;

    if (l == r)
    {
        count += h[l];
        return;
    }
    for (i = l; i <= r; i++)
    {
        if (min > h[i])
            min = h[i];
    }
    count += min;
    for (i = l; i <= r; i++)
    {
        h[i] -= min;
    }
    for (i = l; i <= r; i++)
    {
        if (h[i] != 0)
        {
            for (j = i; j <= r; j++)
            {
                if (h[j + 1] == 0)
                {
                    func(i, j);
                    i = j;
                    break;
                }
            }
        }
    }
}

int main()
{
    int n, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &h[i]);
    func(0, n - 1);
    printf("%d\n", count);
}

Measured memory_bytes: 128
#include <stdio.h>

int a, b;

bool is(int n) {
    int sum=0;
    while(n) {
        sum+=(n%10);
        n/=10;
    }
    if(a<=sum && sum<=b) return true;
    else return false;
}

int main(void) {
    int n, sum=0;
    scanf("%d%d%d", &n, &a, &b);
    
    for(int i=1; i<=n; i++) {
        if(is(i)) {
            sum+=i;
        }
    }
    
    printf("%d", sum);
    
    return 0;
}

Measured memory_bytes: 128
#include <iomanip>
#include <iostream>

using namespace std;
// clang-format off
using i64 = int64_t;
using i32 = int32_t;
#define all(x) x.begin(), x.end()
#define int i64
template <class T, typename U> constexpr inline bool exist(const T &s, const U &e) { return s.find(e) != s.end(); }
template <class T> constexpr inline i32 SZ(const T &x) { return x.size(); }
template <class T> constexpr inline bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> constexpr inline bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
const char el = '\n'; const i32 MOD = 1e9 + 7, INF = 0x3f3f3f3f; const i64 INFLL = ((i64)INF << 32) | INF;

#ifdef LOCAL // debugging swiss knife
template <typename Ostream, typename Cont> enable_if_t<is_same<Ostream, ostream>::value, Ostream &> operator<<(Ostream &os, const Cont &v) { os << "{"; for (const auto &x : v) os << x << ", "; return os << "}"; }
template <typename Ostream, typename... Ts> Ostream &operator<<(Ostream &os, const pair<Ts...> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class... Args> void dbg_out(Args... args) { ((std::cerr << "\033[32m" << args << "\033[37m, "), ...); }
#define dbg(...) cerr << "\033[1;31m" << __LINE__ << ": [" << #__VA_ARGS__ << "]\033[37m  = ", dbg_out(__VA_ARGS__), cerr << "\033[0m" << endl;
#else
#define dbg(...) ;
#endif
// clang-format on
////////////////////////////////// TEMPLATE ENDS /////////////////////////////////

int32_t main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(13), cerr << fixed << setprecision(3);

    int n;
    cin >> n;
    int ans = n * (n + 1) / 2;
    for (i64 i = 1; i < n; ++i) {
        ans += i * (i + 1) / 2;
        int l, r;
        cin >> l >> r;
        if (l > r) swap(l, r);
        ans -= l * (n + 1 - r);
    }
    cout << ans << el;

    return 0;
}

Measured memory_bytes: 3176
H,W = list(map(int,input().split()))

s = [input() for i in range(H)]

e_list = [[] for i in range(H*W)]

count = 0
for i in range(H):
    for j in range(W):
        if s[i][j]==".":
            if i!=H-1:
                if s[i+1][j]==".":
                    e_list[i*W+j].append((i+1)*W+j)
                    e_list[(i+1)*W+j].append(i*W+j)
            if j!=W-1:
                if s[i][j+1]==".":
                    e_list[i*W+j].append(i*W+j+1)
                    e_list[i*W+j+1].append(i*W+j)
            count+=1

vi = 0 #時と場合によってここを変える
from collections import deque
Q = deque([vi])
N=H*W
checked_list = [False for i in range(N)]
checked_list[vi]=True
min_path_list = [10**27 for i in range(N)] #問題によりここを変える
min_path_list[vi] = 0
while len(Q)>0:
    v = Q.pop()
    for v1 in e_list[v]:
        if not checked_list[v1]:
            checked_list[v1]=True
            Q.appendleft(v1)
            min_path_list[v1]=min(min_path_list[v1],min_path_list[v]+1) #問題によりここを変える
if min_path_list[H*W-1]<10**9:
    print(count-(1+min_path_list[H*W-1]))
else:
    print(-1)


Measured memory_bytes: 3952
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int N,H,count=0,maxH=0;
  scanf("%d\n",&N);
  while (N > 0) {
    scanf("%d",&H);
    if (maxH <= H) {
      maxH = H;
      count++;
    }
    N--;
  }

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


Measured memory_bytes: 128
//TYPE
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>

using namespace std;
typedef long long ll;
#define cls(x) memset(x,0,sizeof(x))


const int INF = 0x3f3f3f3f;
const int SZ = 100;

int main() {
  vector<int> a(5);
  int small = -1;
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  for(auto n : a) {
    if(n % 10 == 0) continue;
    if(small == -1) {
      small = n;
    } else if(small % 10 > n % 10) {
      small = n;
    }
  }
  int total = 0;
  for(auto n : a) {
    if(n % 10 == 0) {
      total += n;
    } else {
      total += (n / 10 + 1) * 10;
    }
  }
  if(small != -1) {
    total = total - (10 - small % 10);
  }
  cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
# Solution to this problem using memoization
# https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_10_B

import math

# Optimal cost of multiplying A_1 A_2 ... A_j
def cost(i, j):
    if (i, j) in cost_dict.keys():
        return cost_dict[(i, j)]
    elif i == j:
        cost_dict[(i, j)] = 0
    else:
        mincost = math.inf
        for k in range(i, j):
            estimate = cost(i, k) + cost(k + 1, j) + dims[i - 1] * dims[k] * dims[j]
            mincost = min(estimate, mincost)
        cost_dict[(i, j)] = mincost
    return cost_dict[(i, j)]


if __name__ == '__main__':
    # Number of matrices
    n = int(input())
    # A dictionary to store costs
    cost_dict = dict()
    # Take input dimensions
    dims = []
    for _ in range(n - 1):
        first = int(input().split()[0])
        dims.append(first)
    dims.extend(list(map(int, input().split())))
    # Calculate the optimal cost
    print(cost(1, n))


Measured memory_bytes: 6228
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

auto start = chrono::system_clock::now();

inline double get_time() {
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    double msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    return msec;
}

int D;
vector<int> c(26);
vector<vector<int>> s;

inline int compute_score(const vector<int>& out) {
    int score = 0;
    vector<int> last(26, -1);
    rep(d, sz(out)) {
        score += s[d][out[d]];
        last[out[d]] = d;
        rep(i, 26) score -= c[i] * (d - last[i]);
    }
    return score;
}

inline int evaluate(const vector<int>& out, int k) {
    int score = 0;
    vector<int> last(26, -1);
    rep(d, sz(out)) {
        score += s[d][out[d]];
        last[out[d]] = d;
        rep(i, 26) score -= c[i] * (d - last[i]);
    }
    for (int d = sz(out); d < min(sz(out) + k, D); ++d) {
        rep(i, 26) score -= c[i] * (d - last[i]);
    }
    return score;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> D;
    rep(i, 26) cin >> c[i];
    s.resize(D, vector<int>(26));
    rep(i, D) rep(j, 26) cin >> s[i][j];

    vector<int> best_out;
    int best_score = numeric_limits<int>::lowest();
    
    rep(k, 27) {
        vector<int> out;
        rep(_, D) {
            int max_score = numeric_limits<int>::lowest();
            int best_i = 0;
            rep(i, 26) {
                out.push_back(i);
                int score = evaluate(out, k);
                if (chmax(max_score, score)) best_i = i;
                out.pop_back();
            }
            out.push_back(best_i);
        }
        int total_score = compute_score(out);
        if (chmax(best_score, total_score)) best_out = out;
    }

    rep(d, D) cout << best_out[d] + 1 << endl;
    
    // random_device rnd;
    // mt19937 mt(rnd());
    // uniform_int_distribution<> rand_d(0, D-1);
    // uniform_int_distribution<> rand_t(0, 25);
    // int to_d = rand_d(mt);
    // int to_t = rand_t(mt);
    
}


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

int main () {
  int N, M;
  cin >> N;
  vector<int> ANS(N+M);
  
  vector<string> Blue(N);  
  for (int i = 0; i < N; i++){
    string b;
    cin >> b;
    Blue.at(i) = b;
  }
  
  cin >> M;
  vector<string> Red(M);  
  for (int i = 0; i < M; i++){
    string r;
    cin >> r;
    Red.at(i) = r;
  }
  
  for (int i = 0; i < N; i++) {
    int ans;
    ans = 0;
    string test;
    test = Blue.at(i);
    
    for (int j = 0; j < N; j++) {
      if (test == Blue.at(j)) {
        ans++;
      }
    }
    for (int k = 0; k < M; k++) {
      if (test == Red.at(k)) {
        ans--;
      }
    }
    ANS.at(i) = ans;
  }
  
  for (int i = 0; i < M; i++) {
    int ans;
    ans = 0;
    string test;
    test = Red.at(i);
    
    for (int j = 0; j < N; j++) {
      if (test == Blue.at(j)) {
        ans++;
      }
    }
    for (int k = 0; k < M; k++) {
      if (test == Red.at(k)) {
        ans--;
      }
    }
    ANS.at(N+i+1) = ans;
  }
  int max = 0;
  for (int i = 0; i < N + M; i++) {
    if (max < ANS.at(i)) {
      max = ANS.at(i);
    }
  }
  cout << max << endl;
}

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

int main() {

  int r,d,x;
  cin >> r >> d >> x;
  
  rep(i,10) {
    cout << r*x - d << endl;
    x = r*x - d;
  }
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

const lint mod=1e9+7;

lint dp[100010][2];
vector<vector<int>> edge(100010);

lint rec(int n,int s,int p)
{
	if(dp[n][s]!=0)
		return dp[n][s];
	
	if(edge[n].size()==1 && edge[n][0]==p)
	{
		dp[n][0]=1;
		dp[n][1]=1;
		return dp[n][s];
	}

	lint ret=1;
	//black
	for(auto&& i:edge[n])
	{
		if(i==p)
			continue;
		lint tmp=rec(i,0,n);
		if(tmp!=0)
		{
			ret*=tmp;
			ret%=mod;
		}
	}
	dp[n][1]=ret;
	//white
	ret=1;
	for(auto&& i:edge[n])
	{
		if(i==p)
			continue;
		lint tmp=rec(i,0,n)+rec(i,1,n);
		tmp%=mod;
		if(tmp!=0)
		{
			ret*=tmp;
			ret%=mod;
		}
	}

	dp[n][0]=ret;
	return dp[n][s];
}

int main()
{
	int N;

	cin >> N;
	
	for(int i=0;i<N-1;i++)
	{
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}

	cout << (rec(0,0,0)+rec(0,1,0))%mod << endl;
	return 0;
}


Measured memory_bytes: 14208
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int a[100000];
int d[100000];
int p[100000];
vector <int> v[100000];
vector <int> w[100000];

void dfs(int x, int y) {
    int i;
    
    a[x] = y;
    
    for (i = 0; i < v[x].size(); i++) dfs(v[x][i], y + 1);
}

int main() {
    int n, k, ans = 0, i;
    vector <pair<int, int> > w;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        x--;
        
        if (i == 0) {
            if (x != 0) ans++;
        } else {
            v[x].push_back(i);
            p[i] = x;
        }
    }
    
    dfs(0, 0);
    
    for (i = 1; i < n; i++) w.push_back(make_pair(a[i], i));
    
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    
    for (i = 0; i < w.size(); i++) {
        int x = w[i].second;
        
        if (d[x] + 1 == k) {
            if (p[x] != 0) ans++;
        } else {
            d[p[x]] = max(d[p[x]], d[x] + 1);
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 14836
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	int n;
	int c[22];
	int v[22];
	cin >> n;
	int ans = 0;
	rep(i, 0, n) cin >> v[i];
	rep(i, 0, n) cin >> c[i];
	rep(i, 0, n) {
		if (v[i] - c[i] > 0) ans += v[i] - c[i];
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using boost::multiprecision::cpp_int;
using namespace std;
#define ll long long int
#define F first
#define S second
//#define endl "\n"
//#define nl cout<<endl;
#define pb push_back
#define ull unsigned long long 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 100000007
#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 
bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
    return false;
}
bool cmp(int n, pair<int, int> const& p)
{
    return (p.first < n);
}
//me
ll const mod = 1e9+7;//998244353;
ll const inf = 1e18;
ll const maxn = 2e5+1;

ll const dx[] = {1,-1,0,0};
ll const dy[] = {0,0,1,-1};
ll vis[51][51];
ll dis[51][51];

bool legal(ll a,ll b, ll x, ll y)
{
     return ( (a>=0&&a<x) && (b>=0&&b<y) );
}
void solve()
{    

     ll h,w; cin >> h >> w;
     string s[h]; f(i,0,h) cin >> s[i];

     ll black = 0;
     f(i,0,h) f(j,0,w) if(s[i][j]=='#') black++;
     if(s[0][0]=='#'){
          cout << -1 ;
          return;
     }
     queue<pair<ll,ll>> q;
     q.push({0,0});
     vis[0][0]=1;

     while(!q.empty()){

          ll curX = q.front().F;
          ll curY = q.front().S;
          q.pop();

          f(i,0,4){
               ll chX = curX+dx[i]; 
               ll chY = curY+dy[i];
               if(legal(chX,chY,h,w) && s[chX][chY]=='.'&&vis[chX][chY]==0 ){
                    vis[chX][chY]=1;
                    dis[chX][chY] = dis[curX][curY]+1;
                    q.push({chX, chY});
               } 
          }
     }

     if(dis[h-1][w-1]==0){
          cout << -1 ;
          return;
     }

     cout << h*w - (black+dis[h-1][w-1]+1);
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/ 
          
          ll t;
          /**/t=1;
          /*/cin>>t;/**/
          f(testcases,0,t){
               //cout << "Case #" <<testcases+1<<": ";
               solve();
          }
 
 
    return 0;
}

Measured memory_bytes: 3616
using System;

namespace dwacon6th_prelims
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] songs = new string[n];
            int[] lens = new int[n];

            for(int i = 0; i < n; i++){
                var spl = Console.ReadLine().Split(' ');
                songs[i] = spl[0];
                lens[i] = int.Parse(spl[1]);
            }
            string last = Console.ReadLine();

            int index = 0;
            while(songs[index] != last){
                index++;
            }
            index++;

            int total = 0;
            for(; index < n; index++){
                total += lens[index];
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 11092
// IlyM

#include <bits/stdc++.h>

#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=2e5+5,mod=987654321;
int n,b,K=1;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>b>>n;
	while (b--) K*=100;
	int r=0;
	for (int i=1;i<=n;i++) {
		r+=K;
		if (i%100==0) { n++; }
	}
	cout<<r;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int ans = 0;
    for (int e = 1 << 29; e > 0; e >>= 1) {
        long long c = 0;
        if (n % 2 != 0) {
            int s = 0, t = 0;
            for (int i = 0; i < n; i++) {
                if (a[i] & e) c++;
                if (b[i] & e) c++;
            }
        }
        // count carries
        for (int i = 0; i < n; i++) { a[i] &= e-1; b[i] &= e-1; }
        sort(a, a+n); sort(b, b+n);
        for (int i = 0, j = n-1; i < n; i++) {
            if (a[i] + b[n-1] < e) continue;
            while (j >= 0 && a[i] + b[j] >= e) j--;
            j++;
            c += n - j;
        }
        if (c % 2 != 0) ans += e;
    }
    cout << ans << endl;
}


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

int n, m, q;
ll ans = 0;

struct Quad{
	int a, b, c, d;
	Quad(int _a, int _b, int _c, int _d):a(_a), b(_b), c(_c), d(_d){}
};

bool comp(Quad x, Quad y){
	return x.a < y.a;
}

void checasol( vi &vec, vector<Quad> &vq){
	ll res = 0;
	for(Quad q : vq){
		if(vec[q.b] - vec[q.a] == q.c){
			res += q.d;
		}
	}
	ans = max(ans, res);
}

void rec(int i, vector<Quad> &vq, vi &vec){
	if(i == n+1){
		checasol(vec, vq);
		return;
	}
	for(int j = vec.back(); j <= m; j++){
		vec.pb(j);
		rec(i+1,vq,vec);
		vec.pop_back();
	}
}

int main(){
	scanf("%d %d %d", &n, &m, &q);
	vector<Quad> vq;
	for(int i = 0; i < q; i++){
		int a, b, c, d;
		scanf("%d %d %d %d", &a, &b, &c, &d);
		vq.pb(Quad(a,b,c,d));
	}
	vi vec;
	vec.pb(1);
	rec(1, vq, vec);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

template<typename T>
vector<T> all_divisor_catch(T x) {
  vector<T> v;
  for (T i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      v.eb(i);
      v.eb(x / i);
    }
  }
  sort(all(v));
  v.erase(unique(all(v)), v.end());
  return v;
}

void solve() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  cin >> a;
  ll g = a[0];
  rep3(i, 1, n) g = gcd(g, a[i]);
  ll sum = accumulate(all(a), 0LL); // sum 一定
  auto v = all_divisor_catch(sum);
  for (int i = sz(v) - 1; i >= 0; --i) {
    vector<ll> v2(n);
    rep(j, n) v2[j] = a[j] % v[i];
    sort(all(v2), greater<ll>());
    while (sz(v2) && v2.back() == 0) v2.pop_back();
    sort(all(v2));
    // cout << v[i] << "  " << v2 << endl;
    ll ans = INF;
    ll sum2 = 0;
    rep(j, sz(v2)) { // 前半いくつかを下げる
      sum2 += v2[j];
      ll sum3 = 0;
      rep3(k, j + 1, sz(v2)) {
        sum3 += v[i] - v2[k];
      }
      // cout << sum2 << " " << sum3 << endl;
      chmin(ans, max(sum2, sum3));
    }
    if (ans <= k) {
      cout << max(g, v[i]) << endl;
      return;
    }
  }
  cout << 1 << endl;
}


Measured memory_bytes: 256
from queue import Queue

H, W = [int(i) for i in input().split()]
C = [list(input()) for i in range(H)]

dcount = -1
for h in range(H):
    for w in range(W):
        if C[h][w] == '.':
            dcount += 1

INF = 10 ** 6
D = [[INF] * W for i in range(H)]
D[0][0] = 0
q = Queue()
q.put((0, 0))

while q.qsize() > 0:
    h, w = q.get()
    if (h, w) == (H-1, W-1):
        break
    for dh, dw in zip((-1, 1, 0, 0), (0, 0, -1, 1)):
        if 0 <= h+dh < H and 0 <= w+dw < W and C[h+dh][w+dw] == '.' and D[h+dh][w+dw] == INF:
            D[h+dh][w+dw] = D[h][w] + 1
            q.put((h+dh, w+dw))

print(dcount - D[H-1][W-1] if D[H-1][W-1] != INF else -1)

Measured memory_bytes: 3952
//This Code was made by Chinese_zjc_.
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<bitset>
#include<cmath>
#include<queue>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<time.h>
// #include<windows.h>
#define int long long
#define PI 3.14159265358979323
#define INF 0x3fffffffffffffff
using namespace std;
int n,q,a,b,ans;
struct segtree{
    int v[800005];
    #define lson (now<<1)
    #define rson (now<<1|1)
    #define lmid ((l+r)>>1)
    #define rmid (lmid+1)
    void push_down(int now)
    {
        v[lson]=min(v[now],v[lson]);
        v[rson]=min(v[now],v[rson]);
        v[now]=INF;
    }
    void change(int L,int R,int V,int now=1,int l=1,int r=n)
    {
        if(r<L||R<l)
        {
            return;
        }
        if(L<=l&&r<=R)
        {
            v[now]=min(V,v[now]);
            return;
        }
        change(L,R,V,lson,l,lmid);
        change(L,R,V,rson,rmid,r);
    }
    int query(int V,int now=1,int l=1,int r=n)
    {
        if(r<V||V<l)
        {
            return INF;
        }
        if(l==r)
        {
            return v[now];
        }
        push_down(now);
        return min(query(V,lson,l,lmid),query(V,rson,rmid,r));
    }
    void build(int now=1,int l=1,int r=n)
    {
        if(l==r)
        {
            v[now]=n;
            return;
        }
        v[now]=INF;
        build(lson,l,lmid);
        build(rson,rmid,r);
    }
}column,row;
signed main()
{
    ios::sync_with_stdio(false);
    cin>>n>>q;
    column.build();
    row.build();
    for(int i=1;i<=q;++i)
    {
        cin>>a>>b;
        if(a==1)
        {
            int v=column.query(b);
            if(v==1)
            {
                continue;
            }
            ans+=v-2;
            row.change(1,v,b);
            column.change(b,b,1);
        }
        if(a==2)
        {
            int v=row.query(b);
            if(v==1)
            {
                continue;
            }
            ans+=v-2;
            column.change(1,v,b);
            row.change(b,b,1);
        }
    }
    cout<<(n-2)*(n-2)-ans<<endl;
    return 0;
}

Measured memory_bytes: 11852
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll x;
    cin >> x;
    ll d11 = x/11;
    ll m11 = x%11;
    ll ad = 0;
    if(m11==0) ad=0;
    else if(m11<=6) ad=1;
    else ad=2;

    cout << 2*d11 + ad << endl;

}


Measured memory_bytes: 3584
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

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

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

typedef pair<int, int> P;

class CGeTAC {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, Q;
        in >> N >> Q;
        string S;
        in >> S;

        vector<int> sum(N + 1);
        FOR(i, 1, N - 1) {
            if (S[i] == 'C' && S[i - 1] == 'A') {
                sum[i + 1] = sum[i] + 1;
            } else {
                sum[i + 1] = sum[i];
            }
        }

        while (Q--) {
            int l, r;
            in >> l >> r;
            int res = sum[r] - sum[l - 1];
            if (l > 1 && S[l-1] == 'C' && S[l-2] == 'A') {
                res--;
            }
            out << res << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CGeTAC solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
	int N;
	bool flag = true;
	
	int *x, *y, *t;
	x = new int[100000];
	y = new int[100000];
	t = new int[100000];
	
	cin >> N;
	t[0] = x[0] = y[0] = 0;
	for (int i = 0; i < N; i++) {
		cin >> t[i+1] >> x[i+1] >> y[i+1];
	}

	for (int i = 0; i < N; i++) {
		int dt = t[i+1] - t[i];
		int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < dist) {
			flag = false;
		}
		if (dt % 2 != dist % 2) {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	delete[] x, y, t;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int n, a, b, c, ab;
    cin >> n;
    long long int ans = 0;
    for (int i = 1; i < n; i++)
    {
        ab = n - i;
        int sq = sqrt(ab);
        for (int j = 1; j <= sq; j++)
        {
            if (ab % j == 0)
            {
                ans++;
                if (ab != j * j)
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3684
var lines: string[] = [];
var reader: any = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on("line", function(line: string) {
  lines.push(line);
});

reader.on("close", function() {

  console.log(lines[0][0] + lines[1][1] + lines[2][2]);
});


Measured memory_bytes: 7500
from sys import stdin
from sys import setrecursionlimit

setrecursionlimit(10 ** 7)

n,k = map(int,stdin.readline().rstrip().split())
se = set()
for i in range(k):
    d = int(stdin.readline().rstrip())
    a = list(map(int,stdin.readline().rstrip().split()))
    for j in a:
        se.add(j)

print(n-len(se))

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::cout << N * N * N << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[110][110];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll a, b;
	cin >> a >> b >> n;
	ll x = min(n, b - 1);
	cout << ((a * x) / b) << endl;
}

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

int main()
{
    int x, y;
    bool can = false;
    cin >> x >> y;
    rep(i,100) {
        rep(j,100) {
            if (i * 2 + j * 4 == y && i + j == x) can = true;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3620
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		int dp[ ] = new int[31];
		dp[0] = 1;
		
		for(int i = 0; i < 31;i++){
			for(int ni = i-3; ni < i; ni++){
				if(ni < 0){
					continue;
				}
				dp[i] += dp[ni];
			}
		}
		
		
		for(;;){
			int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			System.out.println(((dp[n]-1)/3650) + 1);
			
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    ll M = 1e18;
    ll ans = 1;
    cin >> N;
    vector<ll> a(N);
    cin >> a;
    sort(ALL(a));
    if (a[0] == 0) {
        cout << 0 << endl;
        return 0;
    }
    REP(i, N) {
        if (a[i] > M / ans) {
            cout << -1 << endl;
            return 0;
        } else {
            ans *= a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052