akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();


    public void Solve() {
        long x = sc.nextLong();
        long div = x / 11;
        long mod = x % 11;
        long ans = div * 2;
        if (mod == 0) {
            
        } else if (mod <= 6) {
            ans += 1;
        } else {
            ans += 2;
        }
        WriteLine(ans);
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {

        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 11220
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(void){
	int a,b,N,s,f,ans=0;
	cin>>a>>b>>N;
	for(int i=0;i<N;i++)
	{
		cin>>s>>f;
		if(a<=s&&s<b)
		{
			ans=1;
		}
		if(a<f&&f<=b)
		{
			ans=1;
		}
		if(s<=a&&a<f)
		{
			ans=1;
		}
		if(s<b&&b<=f)
		{
			ans=1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int ma = A[0];
    ll g = A[0];
    rep(i, N) {
        chmax(ma, A[i]);
        g = gcd(g, A[i]);
    }

    if (K <= ma && K % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

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

const ll N = 1e5+5, INF = 1e9+8;
ll n, k;
ll d[N], dp[N];

int main(){
	cin >> n >> k;
	for(ll i = 0; i < N; i++) d[i] = dp[i] = INF;
	for(ll i = 0; i < n; i++) cin >> d[i];
	dp[n-1] = 0;
	for(ll i = n-2; i >= 0; i--)
		for(ll j = 1; j <= k; j++)
			dp[i] = min(dp[i], dp[i+j]+abs(d[i]-d[i+j]));
	cout << dp[0] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#define maxx 600

int main(void)
{
  int i, j, k, l, m;
  int d;
  int area;

  while (scanf("%d", &d) != EOF){
    area = 0;
    for (i = 0; i < maxx; i+=d){
      area += d * pow(i,2);
    }
    printf("%d\n", area);
  }

  return 0;
}

Measured memory_bytes: 596
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc=new Scanner(System.in);
		int t=1;//sc.nextInt();
		while(t-->0) {
			int d=sc.nextInt();
			int time=sc.nextInt();
			int s=sc.nextInt();
			if(s*time>=d) System.out.println("Yes");
			else System.out.println("No");
		}
	}
}
class Reader{
	BufferedReader reader;
	Reader(){
		reader=new BufferedReader(new InputStreamReader(System.in));
	}
	int nextInt() throws IOException{
		String in=reader.readLine().trim();
		return Integer.parseInt(in);
	}
	long nextLong() throws IOException{
		String in=reader.readLine().trim();
		return Long.parseLong(in);
	}
	String next() throws IOException{
		return reader.readLine().trim();
	}
	String[] stringArray() throws IOException{
		return reader.readLine().trim().split("\\s+");
	}
	int[] intArray() throws IOException{
		String[] inp=this.stringArray();
		int[] arr=new int[inp.length];
		int i=0;
		for(String s:inp) {
			arr[i++]=Integer.parseInt(s);
		}
		return arr;
	}
}
class Solution {
    public int maxEnvelopes(int[][] envel) {
        int n=envel.length;
        if(n==0) return 0;
        env[] arr=new env[n];
        for(int i=0;i<n;i++){
            arr[i]=new env(envel[i][0],envel[i][1]);
        }
        //[[4,5],[4,6],[6,7],[2,3],[1,1]]
        Arrays.sort(arr);
        int[] dp=new int[n];
        int size=0;
        for(int i=0;i<n;i++){
            int left = 0, right = size, middle = 0;     // right = size
            while(left < right) {
                middle = left + (right - left) / 2;
                if(dp[middle] < arr[i].w) left = middle + 1;
                else right = middle;
            }
            
            // left is the right position to 'replace' in dp array
            dp[left] = arr[i].w;
            if(left == size) size++;
        }
        return size;
    }
}
class env implements Comparable<env>{
    int l,w;
    env(int l,int w){
        this.l=l;this.w=w;
    }
    public int compareTo(env other){
        if(this.l!=other.l) return Integer.compare(this.l,other.l);
        return Integer.compare(other.w,this.w);
    }
}


Measured memory_bytes: 35664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

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

  if(a.size()==2) {
  cout << a << endl;
  }
  
  else {
  cout << a[2] << a[1] << a[0] << endl;
  }
  
}


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

int main() {
  int N;
  cin >> N;
  string ans = "Three";
  for (int i=0; i<N; i++) {
    char c;
    cin >> c;
    if (c == 'Y')
      ans = "Four";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d", $n);
$to = array_fill(0, $n, []);
$cost = array_fill(0, $n, []);
for ($i = 0; $i < $n - 1; ++$i) {
    fscanf(STDIN, "%d %d %d", $u, $v, $w);
    --$u;
    --$v;
    $to[$u][] = $v;
    $to[$v][] = $u;
    $cost[$u][] = $w;
    $cost[$v][] = $w;
}

// bfs
$ans = array_fill(0, $n, -1);
$q = new SplQueue();

$q->enqueue(0);
$ans[0] = 0;
while (!$q->isEmpty()) {
    $v = $q->dequeue();

    for ($i = 0; $i < count($to[$v]); ++$i) {
        $u = $to[$v][$i];
        $w = $cost[$v][$i];

        if ($ans[$u] !== -1) continue;

        $ans[$u] = ($ans[$v] + $w) % 2;
        $q->enqueue($u);
    }
}

echo implode(' ', $ans);


Measured memory_bytes: 92920
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

int main() {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";

    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != t[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <limits>
#include <string>
#include <stack>
#include <queue>

#define INT_MAX 2147483647
#define INT_MIN -2147483647

#define NUM 10000
#define INVALID_IDX -1
using namespace std;

vector<int> pre, in, post;
int pos = 0;

void traverse(int l, int r)
{
	if (l >= r) return;

	int rootVal = pre[pos++];
	int rootPos = distance(in.begin(), find(in.begin(), in.end(), rootVal));

	traverse(l, rootPos);
	traverse(rootPos+1, r);

	post.push_back(rootVal);
}

void solve()
{
	pos = 0;
	traverse(0, pre.size());

	for (int i = 0; i < post.size() - 1; ++i)
	{
		cout << post[i] << " ";
	}
	if (!post.empty()) cout << post.back();
        cout << endl;
}


int main()
{
	int num;
	cin >> num;
	pre.resize(num);
	in.resize(num);
	
	for (int i = 0; i < num; ++i) cin >> pre[i];
	for (int i = 0; i < num; ++i) cin >> in[i];

	solve();

	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>

int main(){
int H,W;
while(true){
std::cin>>H>>W;
if(H==0&&W==0)break;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
    if(i==0||i==H-1||j==0||j==W-1){
    std::cout<<"#";
    }else std::cout<<".";
}
std::cout<<std::endl;
}
std::cout<<std::endl;
}
return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main(){

	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;

	string u="";

	rep (i, n) {
		u += s[i];
		u += t[i];
	}

	cout << u<< endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  int64_t sum = 0;
  vector<int> a(N + 2);
  rep(i, N) cin >> a[i + 1];
  rep(i, N + 1) {
    sum += abs(a[i + 1] - a[i]);
  }
  rep(i, N) {
    cout << (sum - abs(a[i + 1] - a[i]) - abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i])) << "\n";
  }
}


Measured memory_bytes: 1664
# -*- coding: utf-8 -*-

from collections import defaultdict
from math import sqrt

# 素因数分解
def fact_prime(num):
    d = defaultdict(int)
    # 終点はルート切り捨て+1
    end = int(sqrt(num)) + 1
    for i in range(2, end+1):
        cnt = 0
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

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

if N == 1:
    print(P)
    exit()
l = sorted(fact_prime(P).items(), reverse=True)
ans = 1
for k, v in l:
    if v >= N:
        ans *= k ** (v // N)
print(ans)


Measured memory_bytes: 3316
#include<stdio.h>

int main(void){
int A,B,i,total;

scanf("%d %d",&A,&B);

for(i=0;i<2;i++){
  if(A>B){
    total = total + A;
    A = A - 1;
  }else{
    total = total + B;
    B = B - 1;
  }
}
printf("%d",total);
return 0;
}


Measured memory_bytes: 128
l, r = map(int, input().split())
mod = 2019
if l//mod < r//mod:
  print(0)
  exit()
l %= mod
r %= mod
m = mod-1
for i in range(l, r+1):
  for j in range(i+1, r+1):
    m = min(m, (i * j) % mod)
print(m)


Measured memory_bytes: 3060
from functools import lru_cache

def solve(N, A, B, C, D):
    @lru_cache(None)
    def f(N):
        if N == 0:
            return 0
        if N == 1:
            return D
        ret = D * N
        q, r = divmod(N, 2)
        if r == 0:
            ret = min(ret, f(q) + A)
        else:
            ret = min(ret, f(q) + A + D, f(q + 1) + A + D)
        q, r = divmod(N, 3)
        if r == 0:
            ret = min(ret, f(q) + B)
        else:
            ret = min(ret, f(q) + B + D*r, f(q + 1) + B + D*(3-r))
        q, r = divmod(N, 5)
        if r == 0:
            ret = min(ret, f(q) + C)
        else:
            ret = min(ret, f(q) + C + D*r, f(q + 1) + C + D*(5-r))
        return ret

    return f(N)

T = int(input())
for _ in range(T):
    N, A, B, C, D = map(int, input().split())
    print(solve(N, A, B, C, D))


Measured memory_bytes: 20600
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		IntSummaryStatistics o=IntStream.range(0,s.nextInt()).map(i->s.nextInt())
			.summaryStatistics();
		System.out.println(o.getSum()-o.getMax()/2);
	}
}


Measured memory_bytes: 26964
#include <stdio.h>

int main(void){
  int n,m;
  int i,j;
  int k;
  while(scanf("%d %d",&n,&m)!=EOF){
    if(n==0&&m==0) break;
    else{
      int p[n];
      for(i=0;i<n;i++) p[i]=0;
      j=0;
      for(i=1;i<n;i++){
	k=0; 
	while(k<m){
	  if(j==n) j=0;
	  if(p[j]==0) k++; 
	  j++;
	}
	p[j-1]=i;
	//printf("%d\n",j-1);
      }
      for(i=0;i<n;i++){
	if(p[i]==0){
	  printf("%d\n",i+1);
	  break;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std; 

typedef struct _city_res{
 string name;
 int number;
  // 演算子オーバーロードで比較関数を定義
 bool operator<(const _city_res & another) const {
  if(name != another.name)return name < another.name; 
  else return number >another.number;
 } 
}city_res;

int main(void){
 int N;
 city_res a;
 vector<city_res>A; 
 vector<city_res>B;
 
 cin>>N; 
 for(int i=0; i<N; i++){
  cin>>a.name>>a.number;
  A.push_back(a);
  B.push_back(a);
 }
 

 sort(B.begin(),B.end());
 for(int i=0; i<N; i++)
  for(int j=0; j<N; j++){
   if(A[j].name==B[i].name && A[j].number==B[i].number)cout<<j+1<<endl;
  }
 return 0;
}

Measured memory_bytes: 256
// #define CPP_IO

#pragma region

#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxheap = priority_queue<T>;

#define f first
#define s second

#ifdef LOCAL
#define debug cout
#define debugf(format, ...) printf(format, ##__VA_ARGS__)
#else
#define debug \
    if (0) cout
#define debugf(format, ...) 42
#endif

#define DUMP(a) debug << #a " = " << (a) << "\n";
#define DUMP2(a, b) debug << #a " = " << (a) << " " #b " = " << (b) << "\n";
#define DUMP3(a, b, c) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << "\n";
#define DUMP4(a, b, c, d) debug << #a " = " << (a) << " " #b " = " << (b) << " " #c " = " << (c) << " " #d " = " << (d) << "\n";

template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[ ";
    for (auto e : v) os << e << " ";
    return os << "]";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, set<T, V> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V, typename S>
ostream& operator<<(ostream& os, map<T, V, S> v) {
    os << "{ ";
    for (auto e : v) os << e << " ";
    return os << "}";
}

template <typename T, typename V>
ostream& operator<<(ostream& os, pair<T, V> x) {
    return os << "( " << x.first << ", " << x.second << " )";
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& e : v) is >> e;
    return is;
}

template <typename T, typename V>
istream& operator>>(istream& is, pair<T, V>& x) {
    return is >> x.first >> x.second;
}

void solve();

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#else
#ifdef CPP_IO
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
#endif
    solve();
}

#pragma endregion

void solve() {
    int numR, numC, n;
    int startR, startC;
    string s, t;
    cin >> numR >> numC >> n >> startR >> startC >> s >> t;
    int L = startC, R = startC, U = startR, D = startR;
    for (int i = 0; i < n; ++i) {
        // printf("i = %d L = %d R = %d U = %d D = %d\n", i, L, R, U, D);
        if (s[i] == 'U') {
            --U;
        } else if (s[i] == 'D') {
            ++D;
        } else if (s[i] == 'L') {
            --L;
        } else {
            ++R;
        }
        if (U < 1 || D > numR || L < 1 || R > numC) {
            cout << "NO\n";
            return;
        }
        if (t[i] == 'U') {
            --D;
        } else if (t[i] == 'D') {
            ++U;
        } else if (t[i] == 'L') {
            --R;
        } else {
            ++L;
        }
        if (U < 1) U = 1;
        if (U > numR) U = numR;
        if (D < 1) D = 1;
        if (D > numR) D = numR;
        if (L < 1) L = 1;
        if (L > numC) L = numC;
        if (R < 1) R = 1;
        if (R > numC) R = numC;
    }
    cout << "YES\n";
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define li long int
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y>
#define qq(x) queue<x>
#define pqq(x) priority_queue<x> 
#define search(x,y,z) binary_search(x,y,z)
#define pi(x,y) pair<x,y>
#define forf(i,x,y) for(ll i=x;i<y;i++)
#define forl(i,x,y) for(ll i=x-1;i>=y;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define pp push
#define po pop
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define vp(x,y) vec(pi(x,y) )
#define vv(x) vector<vector<x> >
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{
	fastio;
	/*#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif*/
	
	int n;
	cin>>n;
	int arr[n];
	mpp(int,int) evn,odd;
	mpp(int,int)::iterator it;
	forf(i,0,n)
	{	cin>>arr[i];
		if(i%2==0)
			evn[arr[i]]++;
		else
			odd[arr[i]]++;
	}
	int c=arr[0];
	forf(i,1,n)
	{	if(c==arr[i])
			continue;
		else
		{	c=-1;
			break;
		}
	}
	if(c!=-1)
	{	cout<<n/2;
		return 0;
	}
	st(pi(int,int) ) s1,s2;
	st(pi(int,int) )::iterator iz;
	for(it=evn.begin();it!=evn.end();it++)
		s1.insert(mp(it->second,it->first));
	for(it=odd.begin();it!=odd.end();it++)
		s2.insert(mp(it->second,it->first));
	pi(int,int) p1,p2,q1,q2;
	iz=s1.end();
	iz--;
	p1=*iz;
	iz--;
	p2=*iz;
	iz=s2.end();
	iz--;
	q1=*iz;
	iz--;
	q2=*iz;
	//cout<<p1.first<<" "<<q1.first<<endl;
	if(p1.second!=q1.second)
		cout<<(n-p1.first-q1.first);
	else
	{	if(p1.first+q2.first>p2.first+q1.first)
			cout<<(n-p1.first-q2.first);
		else
			cout<<(n-p2.first-q1.first);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> height(N);
  
  for (int i = 0; i < N; i++) {
    cin >> height.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
     bool flag = true;
    for (int j = 0; j < i; j++) {
      if (height.at(j) > height.at(i)) {
        flag = false;
      }
    }
    if (flag) {
        count++;
      }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split(' '))
r1='R'*(tx-sx)
r2='U'*(ty-sy)
r3='L'*(tx-sx)
r4='D'*(ty-sy)
r=r1+r2+r3+r4+'D'+r1+'RU'+r2+'L'+'U'+r3+'LD'+r4+'R'
print(r)

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

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

Measured memory_bytes: 3784
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    num_list = i_list()

    for i in range(5):
        if num_list[i] == 0:
            print(i+1)
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 72696
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(0);

	int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t1 = h1 * 60 + m1;
	int t2 = h2 * 60 + m2;

	cout << t2 - t1 - k << endl;

	return 0;
}

Measured memory_bytes: 3148
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    if I() >= 30:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

int x[5];
int main() {
    for (int i=0; i<5; ++i) cin >> x[i];
    for (int i=0; i<5; ++i) {
        if (x[i] == 0) cout << i+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int N,M;
char S[5009];
vector<int> ans;

void Z_algorithm(char *S,const int S_len,int *ret){
    //Sを0番目からとt番目から同時に見ていった時に、接頭辞が何文字一致しているか
    ret[0]=S_len;
    int i=1,j=0;
    while(i<S_len){
        while(i+j<S_len && S[j]==S[i+j])j++;
        ret[i]=j;
        if(j==0){++i;continue;}
        int k=1;
        while(i+k<S_len&&k+ret[k]<j){
            ret[i+k] = ret[k];
            k++;
        }
        i+=k;j-=k;
    }
}
signed main(){
    scanf("%lld",&N);
    scanf("%s",S);
    int ans=0;
    for(int i=0;i<N;i++){
        int Z_ret[N];
        Z_algorithm(S+i,N-i,Z_ret);
        for(int j=1;j<N-i;j++){
            //printf(Z_ret[j])
            ans=max(ans,min(j,Z_ret[j]));
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h)
    cin >> a.at(i);
  rep(i,h){
    rep(j,w){
      if(a.at(i).at(j)=='#')continue;
      int ans=0;
      for(int l=-1;l<2;l++){
        for(int k=-1;k<2;k++){
          int nh=i+l;
          int nw=j+k;
          if(0<=nh&&nh<h&&0<=nw&&nw<w&&a.at(nh).at(nw)=='#')ans++;
        }
      }
      a.at(i).at(j)=ans+'0';
    }
  }
  rep(i,h)
    cout << a.at(i) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i64 n,m;
    scanf("%lli%*c%lli%*c",&n,&m);
    i64 full=0LL;
    i64 max=0LL;
    for(i64 i=0LL;i<m;++i){
        i64 a,b;
        scanf("%lli%*c%lli%*c",&a,&b);
        if(a<b){
            i64 c=(b-a)/2LL;
            full+=c;
            if(c>max) max=c;
        }
    }
    printf("%lli\n",full-max);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N, M;
    cin >> N >> M;
    map<ll, int, greater<ll>> data;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        if (data.count(a)) {
            data[a]++;
        }
        else {
            data[a] = 1;
        }
    }
    for (int i = 0; i < M; i++) {
        int b;
        ll c;
        cin >> b >> c;
        if (data.count(c)) {
            data[c] += b;
        }
        else {
            data[c] = b;
        }
    }
    ll ans = 0;
    for (pair<ll, int> p : data) {
        ll key = p.first;
        int value = p.second;
        if (value >= N) {
            ans += key * N;
            break;
        }
        else {
            ans += key * value;
        }
        N -= value;
    }
    cout << ans << endl;
}


Measured memory_bytes: 15992
import numpy as np

h, w = map(int,input().split())
grid = np.array([list(input()) for _ in range(h)], dtype="U1") # ここ最大の学びだ

row = []
col = []

for i in range(h):
    if (grid[i] != ".").any():
        row.append(i)

trans_grid = np.transpose(grid)

for i in range(w):
    if (trans_grid[i] != ".").any():
        col.append(i)

G = grid[row][:,col] # ここも学び。colに指定されているとこだけだす　https://qiita.com/supersaiakujin/items/d63c73bb7b5aac43898a

for g in G:
    print("".join(g))

Measured memory_bytes: 12540
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

map<ll,ll> m;

void solve(ll N){
    bool ok=false;
    for(int i = 2; i*i <= N; i++){
        if(N % i == 0){
            ok =true;
            while(N%i == 0){
                N/=i;
                m[i]++;
            }
        }
    }
    m[N]++;
}


int main(){
    ll N,ans = 1;
    cin>>N;
    rep(i,2,N+1){
        solve(i);
    }
    rep(i,2,1001){
        ans *= (m[i]+1);
        ans%=MOD;
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <iterator>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;




int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a*3+b)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]

#全てのsについて、S内の個数とT内の個数を出す
#S-Tが最も大きいものをメモしていき、最大値をansにする
ans = 0
scnt = 0
tcnt = 0
for s in S:
  scnt = 0 #再初期化
  tcnt = 0 #再初期化
  for tmps in S:
    if s == tmps: scnt += 1
  for t in T:
    if t == s: tcnt += 1
  ans = max(ans, scnt - tcnt)
  
print(max(0, ans))

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int a, b, c, k;

    scanf("%d %d %d %d", &a, &b, &c, &k);

    int sum = 0;
    if(a < k){
        sum += a;
        if(k - (a + b) > 0){
            sum += -1 * (k - (a + b));
        }
    }else{
        sum = k;
    }

    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 1708
#include <stdio.h>
int main(void){
    int a,b,c,x,i=0;
    scanf("%d %d %d",&a,&b,&c);
    for(x=a;x<=b;x++){
    if(c%x==0){
        i=i+1;
    }
    }
    printf("%d\n",i);
return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int w, h, n;
    cin >> w >> h >> n;
    vector<vector<bool>> f(w, vector<bool>(h));
    rep(i, n) {
        int x, y, a;
        cin >> x >> y >> a;
        rep(i, w) rep(j, h) {
            if (a==1 && i<x) f[i][j] = true;
            if (a==2 && i>=x) f[i][j] = true;
            if (a==3 && j<y) f[i][j] = true;
            if (a==4 && j>=y) f[i][j] = true;
        }
    }
    int ans = 0;
    rep(i, w) rep(j, h) {
        if (!f[i][j]) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

min_i = 1
min_j = N

for i in range(2, int(N**0.5)+1):
    if N%i==0:
        j = N / i
        
        if i + j < min_i + min_j:
            min_i = i
            min_j = j
            
print(int(min_i+min_j-2))

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if(s[i]=='A'){
            if(s[i+1]=='B'&&s[i+2]=='C'){
                ans++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	
	string s;
	cin >> s;
	int l = s.length();
	int i;
	int count = 0;
	for (i = 0; i < l / 2; i++)
	{
		//cout << s[i] << " " << s[l - i - 1] << endl;
		if (s[i] != s[l - i - 1])
			count++;
	}
	cout << count;

}









Measured memory_bytes: 3612
//参考：http://ehafib.hatenablog.com/entry/2015/12/23/164517
//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);

  ll n, m;
	cin >> n >> m;
  ll h[n];
  FOR(i, 0, n-1) {
    ll t;
    cin >> t;
    h[i] = t;
  }

  bool hboo[n];
  FOR(i, 0, n-1) {
    hboo[i] = true;
  }
  ll num = n;
  FOR(i, 1, m) {
    ll at, bt;
    cin >> at >> bt;
    if ((h[at-1] >= h[bt-1]) && hboo[bt-1]) {
      hboo[bt-1] = false;
      num--;
    }
    if ((h[at-1] <= h[bt-1]) && hboo[at-1]) {
      hboo[at-1] = false;
      num--;
    }
  }
	cout << num << "\n";
}


Measured memory_bytes: 4072
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int R;
    cin >> R;
    if (R >= 1200)
    {
        if (R >= 2800)
        {
            cout << "AGC" << endl;
        }
        else
        {
            cout << "ARC" << endl;
        }
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
data = [26 ** x for x in range(1, 12)]

d = 0
r = 0
for i in range(len(data)):
    if n <= d + data[i]:
        r = i+1
        n -= (d + 1)
        break
    
    d += data[i]

kurai = [26 **  x for x in range(r)][::-1]
ans = [0] * r
for i in range(r):
    ans[i]= min(n // kurai[i], 25)
    n -= kurai[i] * ans[i]

alpha = [chr(i) for i in range(97, 97+26)] 
ans = [alpha[a] for a in ans]
print("".join(ans))

Measured memory_bytes: 9212
#include <vector>
    #include <list>
    #include <map>
    #include <set>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <bitset>
    #include <algorithm>
    #include <functional>
    #include <numeric>
    #include <utility>
    #include <sstream>
    #include <iostream>
    #include <iomanip>
    #include <cstdio>
    #include <cmath>
    #include <cstdlib>
    #include <ctime>
    #include <string>
    #include <climits>
    #include <tuple>
    using namespace std;
    typedef long long ll;
    typedef pair<int,int> P;
    typedef tuple< int,int,int > T;
    int main(){
      ll x[3];
      cin>>x[0]>>x[1]>>x[2];
      sort(x,x+3);
      int k;
      cin>>k;
      for(int i=0;i<k;i++)x[2]*=2LL;
      cout<<x[0]+x[1]+x[2]<<endl;
    }

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC161
{
    class Program
    {
        static void Main(string[] args)
        {
            //b();
            c();
        }

        public static void b()
        {
            int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = nm[0], m = nm[1];
            int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            double asum = a.Sum(), b = 4 * m;
            int sum = 0;
            double min = Math.Floor(asum / b);
            for(int i = 0; i < n; i++)
            {
                if (a[i] > min)
                    sum++;
            }
            if (sum >= m) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }

        public static void c()
        {
            long[] nk = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nk[0], k = nk[1];
            long min = n;
            if (n % k == 0) 
            {
                Console.WriteLine(0);
                return;
            }
            else 
            {
                n %= k;
            }
            bool flg = true;
            while(flg)
            {
                long a = Math.Abs(n - k);
                if(min > a)
                {
                    min = a;
                    n = a;
                }
                else
                {
                    flg = false;
                }
            }
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long n,m,x,y;
long long ans=0;
int main()
{
	scanf("%lld%lld%lld",&n,&m,&x);
	if(n>1&&x>=m||n==1&&m==x)
	{
		printf("%lld",(n-2)*(x-m)+1);
		return 0;
	}
	printf("0\n");
	return 0;
}

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

int main () {
  int N ;
  cin >> N ;
  bool ans = true ;
    int t =0, x=0, y=0 ;
  for(int i = 0 ; i < N ; i++ ){
    int t1 = t , x1 = x , y1 = y ;
    cin >> t >> x >> y ;
    if((x-x1+y-y1)>(t-t1)) ans = false ;
    if(t%2==0){
      if((x+y)%2==1) ans = false ;
    } else {
      if((x+y)%2==0) ans = false ;
    }
    
  }
  if(ans) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

  int N,T;
  cin >> N >> T;

  int min = INT_MAX;
  int n,t;
  rep(i,N) {
    cin >> n >> t;
    if(t <= T) {
      min = std::min(min,n);
    }
  }

  if(min == INT_MAX) 
    cout << "TLE" << endl;
  else
    cout << min << endl;


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}
/*

*/




Measured memory_bytes: 504
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  if(S=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
}


Measured memory_bytes: 3640
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int n, a, b;
int main() {
	cin >> n >> a >> b;
	cout << min(a*n, b) << endl;
}

Measured memory_bytes: 256
def m():
    n,p=map(int,input().split())
    now=0
    s=input()
    if p==2 or p==5:
        ans=0
        for i in range(n):
            if int(s[i])%p:continue
            ans+=i+1
    else:
        table=[0]*p
        table[0]=1
        c=1
        for i in range(n-1,-1,-1):
            now=(now+c*int(s[i]))%p
            c=10*c%p
            table[now]+=1
        ans=sum(j*(j-1)//2 for j in table)

    print(ans)
if __name__ == "__main__":
    m()
    

Measured memory_bytes: 9452
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 1010
string s,t;
ll dp[N][N];
int main(){
    cin>>s>>t;
    int n=s.size(),m=t.size();
    lol(j,m+1)dp[0][j]=0;dp[0][0]=1;
    for(int i=1;i<=n;i++){
	lol(j,m+1){
	    dp[i][j]=dp[i-1][j];
	    if(s[i-1]==t[j-1]){
		dp[i][j]+=dp[i-1][j-1];
		dp[i][j]%=mod;
	    }
	}
    }
    cout<<dp[n][m]<<endl;
    return 0;
}



Measured memory_bytes: 11056
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
// URLD
long double dx[4]={0,1,-1,0};
long double dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

long double f(long double x,long double y){
    return x*x+y*y;
}

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

    
   int n;
   cin>>n;
   array<long double,3> a[n];
   for(int i=0;i<n;i++){
       long double x,y;
       cin>>x>>y;
       a[i] = {atan2(y,x),x,y};
   }
   sort(a,a+n);
   int r = 0;
   long double x=0,y=0;
   long double ans = 0;
   long double now = 0;
   for(int i=0;i<n;i++){
       chmax(r,i);
       while(r<n+i && f(x+a[r%n][1],y+a[r%n][2]) > now){
           x += a[r%n][1];
           y += a[r%n][2];
           now = f(x,y);
           chmax(ans,now);
           r++;
       }
       chmax(ans,f(x,y));
       x -= a[i][1];
       y -= a[i][2];
       now = f(x,y);
   }
   x=0,y=0,now=0,r=0;
   for(int i=0;i<n;i++){
       x=0,y=0;
       for(int j=i;j<n+i;j++){
           x += a[j%n][1];
           y += a[j%n][2];
           chmax(ans,f(x,y));
       }
   }
   x =0, y =0 ;
   for(int i=0;i<n;i++){
       x=0,y=0;
       for(int j=i;j<n+i;j++){
           if(now > f(a[j%n][1]+x,a[j%n][2]+y))continue;
           x += a[j%n][1];
           y += a[j%n][2];
           chmax(ans,f(x,y));
       }
   }
   cout << sqrt(ans) << endl;

}


Measured memory_bytes: 3900