akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>

using namespace std;

const string right_hand = "yuiop hjkl nm";

int main() {
  bool last_right = false, not_first = false;
  int cnt = 0, c;
  while ((c=getchar()) != '#') {
    if (c == '\n') {
      printf("%d\n", cnt);
      last_right = false;
      not_first = false;
      cnt = 0;
    } else {
      bool right = (right_hand.find((char)c) != string::npos);
      if (right != last_right && not_first) cnt++;
      last_right = right;
      not_first = true;
    }
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  int ans = 0;
  
  for(int i=1;i<=N;i++){
    ans = 0;
    for(int a=1;a<sqrt(N);a++){
      for(int b=1;b<=min(a, int(sqrt(i - a*a)));b++){
        for(int c=1;c<=min(b, int(sqrt(i - a*a - b*b)));c++){
          if(a*a + b*b + c*c + a*b + b*c + c*a == i){
              if(a != b && b != c && c != a) ans += 6;
              else if((a == b && a != c) || (b == c && b != a) || (c == a && c != b)) ans += 3;
              else ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3688
N = int(input())
a = [int(input()) for i in range(N)]
A = max(a)
b = sorted(a)[-2]
if a.count(A) > 1:
    for i in range(len(a)):
        print(A)
else:
    for i in range(len(a)):
        if a[i] == A:
            print(b)
        else:
            print(A)

Measured memory_bytes: 13404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int W, H, X, Y;
    cin >> W >> H >> X >> Y;
    double ans = (double)W * H / 2;
    int num = (W == X * 2 && H == Y * 2) ? 1 : 0;
    printf("%.10f %d\n", ans, num);
}

Measured memory_bytes: 256
def is_prime(x):
    if x == 1:
        return(False)
    y = 2
    while y*y <= x:
        if x%y == 0:
            return(False)
        y += 1
    return(True)

n = int(input())
while True:
  if is_prime(n):
    print(n)
    quit()
  n += 1

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    long double ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans += (double)1 / a[i];
    }
    cout << fixed << setprecision(10) << (double)1 / ans << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, 60) {
        ll x = 0;
        rep(j, n) if (a[j]>>i&1) ++x;
        ll now = x * ( n - x ) % mod;
        rep(j, i) now = now * 2 % mod;
        ans += now;
        ans %= mod;
     }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int rate = 0;
  if(a <= 10){
    rate = b + 100 * (10 - a);
  }
  else{
    rate = b;
  }
  cout << rate << endl;
  return 0;
}

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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n];
    ll sum = 0;
    rep(i, 0, n) {
        cin >> a[i];
        sum += (ll)a[i];
    }
    int ans[n] = {};
    ans[0] = sum;
    for (int i = 1; i <= n - 2; i += 2) {
        ans[0] -= 2 * a[i];
    }
    rep(i, 1, n) {
        ans[i] = 2 * (a[i - 1] - ans[i - 1] / 2);
    }
    rep(i, 0, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int f(int x){
	if(x==0) return 0;else return x%10+f(x/10);
}
int main(){
	int n;cin>>n;
	if(n%f(n)) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	
	int c;
	int d;
	scanf("%d %d",&a,&b);
	c = a * b;
	d = (a * 2) + ( b * 2 );
	printf("%d %d\n",c,d);
	return 0;
}

Measured memory_bytes: 596
import collections
def main():
  n = int(input())
  a = list(map(int,input().split()))
  ans=sum(a)
  counter = collections.Counter(a)
  q = int(input())
  for _ in range(q):
    b, c = map(int, input().split())
    num=counter[b]
    counter[b]=0
    counter[c]+=num
    ans+=(c-b)*num
    print(ans)
main()

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

ll mod = 1000000007;
ll ans = 1<<29;

int main() {
    int x;
    cin >> x;
    if(x>=1200) cout << "ARC" << endl;
    else cout << "ABC" <<endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
c=0
f=[99999999999]*(n)
f[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            f[j]=min(f[j],f[i]+abs(a[i]-a[j]))
print(f[n-1])

Measured memory_bytes: 84312
#include <bits/stdc++.h>
#include <string> 
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mid 2019
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fr(i,a,n) for(i=a;i<n;i++)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define ub upper_bound
#define lb lower_bound
//#define map map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define bs binary_search
#define qll queue<ll>
#define sll set<ll>
 
 
int main()
{
    fastio;
    ll i,count=0,sum=0;
    

    string s,str;
    char c;
    cin>>s;
    ll ans=1;
    ll x=0;
    ll arr[mid]={0};
    arr[0]++;
    for(i=s.length()-1;i>=0;i--)
    {
        x = s[i]-'0';
        sum=(sum%mid + (x*ans)%mid)%mid;
        ans=(ans*10)%mid;
        arr[sum]++;
    }
    ans=0;
    for(i=0;i<mid;i++)
    ans = ans +  arr[i]*(arr[i]-1)/2;
    
    cout<<ans<<endl;
      
       
       
        
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define dint __int128
#define ll long long
#define fup(i,a,b) for(int i=a;i<=b;++i)
#define upf(i,a,b) for(int i=a;i<b;++i)
#define fdn(i,a,b) for(int i=a;i>=b;++i)
#define dnf(i,a,b) for(int i=a;i>b;++i)
#define hh putchar(10)
#define kg putchar(32)
inline ll read(){ll x,f=1;char a;while((a=getchar())<48||a>57)if(a=='-')f=-1;
for(x=a^48;(a=getchar())>47&&a<58;x=(x<<3)+(x<<1)+(a^48));return f*x;}

void Main()
{
    int n;
    cin>>n;
    int a,ans=0;
    fup(i,1,n)cin>>a,ans+=(a-1);
    cout<<ans;
}
int main()
{
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int  swp, cup[3] = {1};
    char a, b;
    
    while(scanf("%c,%c", &a, &b) != EOF){
        swp = cup[a - 'A'];
        cup[a - 'A'] = cup[b - 'A'];
        cup[b - 'A'] = swp;
    }
    
    for(a = 0; a < 3; a++)
        if(cup[a]) printf("%c\n", a + 'A');
    
    return 0;
}

Measured memory_bytes: 544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll ans=a[0];
  ll cnt=n-2;
  for(ll i=1;i<1+cnt/2;i++) {
    ans+=2*a[i];
  }
  if(cnt%2) {
    ans+=a[(cnt+1)/2];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4836
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	r := n / 2
	if n%2 != 0 {
		r++
	}
	fmt.Println(r)
}


Measured memory_bytes: 640
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        a: [usize; n],
    }
    let mut dicts = HashMap::new();
    for a_ in a {
        *dicts.entry(a_).or_insert(0) += 1;
    }
    let mut vec: Vec<_> = dicts.iter().collect();
    vec.sort_by(|a, b| b.1.cmp(a.1).reverse());

    let mut ans = 0;
    if vec.len() <= k {
        println!("0");
        return;
    } else {
        for i in 0..(vec.len() - k) {
            ans += *vec[i].1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 17172
#include <iostream> 
#include <vector>
#include <algorithm>
#include <cmath>
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define debug freopen("input", "r", stdin);freopen("output", "w", stdout)
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef unsigned long long ll;
int const MOD = 1e9+7;
using namespace std;

bool ispal(string s){
    string cp = s;
    reverse(all(cp));
    if(cp == s) return true;
    return false;
}

int main(){
    string s;
    cin >> s;
    string a(s.begin(), s.begin()+(s.size()/2));
    string b(s.begin()+((s.size()+2)/2), s.end());
    if( ispal(s) && ispal(a) && ispal(b) )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main(){

  int a,b,c,r,x,y,flag;

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

  if(a == b){
    printf("%d\n",a);
    return 0;
  }
  else if(a > b){
    flag = 0;
    c = b;
  }
  else{
    c = a;
    flag = 1;
  }
  
  if(flag == 0) r = a % b;
  if(flag == 1) r = b % a;

  while(1){
    x = c % r;
    if(x == 0) break;
    c = r;
    r = x;
    // printf("%d %d %d\n",x,c,r);
  }

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

  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

struct edge {
	int to;
	ll cap;
	unsigned rev;
};

int N, a, Rank[102],iter[102];
ll res;
vector<edge>vec[102];

void bfs() {
	memset(Rank, -1, sizeof Rank);
	Rank[0] = 0;
	queue<int>q;
	q.push(0);
	while (!q.empty()) {
		int t = q.front();
		q.pop();
		for (auto i : vec[t]) {
			if (i.cap && Rank[i.to] == -1) {
				Rank[i.to] = Rank[t] + 1;
				q.push(i.to);
			}
		}
	}
}

ll dfs(int x, ll s) {
	if (x == N + 1)return s;
	for (; iter[x] < vec[x].size(); ++iter[x]) {
		if (vec[x][iter[x]].cap&&Rank[vec[x][iter[x]].to] == Rank[x] + 1) {
			ll l = dfs(vec[x][iter[x]].to, min(s, vec[x][iter[x]].cap));
			if (l) {
				vec[x][iter[x]].cap -= l;
				vec[vec[x][iter[x]].to][vec[x][iter[x]].rev].cap += l;
				return l;
			}
		}
	}
	return 0;
}

ll MaxFlow() {
	ll flow = 0;
	while (true) {
		bfs();
		if (Rank[N + 1] == -1) {
			return flow;
		}
		memset(iter, 0, sizeof iter);
		ll f;
		while ((f = dfs(0, 0xE869120E869120))) {
			flow += f;
		}
	}
}


void addedge(int from, int to, ll cap) {
	vec[from].push_back({ to,cap,vec[to].size() });
	vec[to].push_back({ from,0,vec[from].size() - 1 });
}

int main(){
	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> a;
		if (a > 0) {
			addedge(i, N + 1, a);
			res += a;
		}
		else {
			addedge(0, i, -a);
		}
		for (int j = i + i; j <= N; j += i) {
			addedge(i, j, 0xE869120E869120);
		}
	}
	cout << res - MaxFlow() << endl;
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
import  sys

if b-a>=b and b>=0:
    print('Zero')
    sys.exit()

if a>0:
    print('Positive')
else:
    if len(range(a,b+1))%2==0:
       print('Positive')
    else:
        print('Negative')


Measured memory_bytes: 61908
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int >
#define F first
#define S second
#define mod 1000000007
///cout <<"Case #"<<it<<": ";
using namespace std;

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

    ll ans=0; int n; cin >> n; int arr[n+1]; int vis[n+1]={0};
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        if(arr[i]<i){
            ans+=(ll)vis[i-arr[i]];

        }
        if((ll)i+arr[i]<(ll)n){
            vis[i+arr[i]]+=1;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 5212
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
n,m,k=reads()
N = n-1 # N は必要分だけ用意する
mod =  998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)

mod=998244353
numbers=[m]
for i in range(n-1):
  numbers.append(numbers[i]*(m-1)%mod)
ans=0
for i in range(k+1):
  ans+=numbers[n-i-1]*cmb(n-1,i)
ans%=mod
#print(numbers)
print(ans)


Measured memory_bytes: 126624
import sys
a, b, c = map(int, input().split())
k = int(input())
for i in range(k):    
    if b >= c:
        c *= 2
    elif a >= b:
        b *= 2
    else:
        print('Yes')
        sys.exit()
if a < b < c:
    print('Yes')
else:
    print('No')

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

int main(){
  int n,k;
  ll sum=0,work;
  cin >> n >>k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end());
  rep(i,n-k) sum+=a[i];
  cout << sum << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#define MAX 1000001
#define NUM 100
int main()
{
  int flag[MAX];
  int q,n[NUM];
  int temp;
  int i,j;
  int result;
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&n[i]);
      for(j=0;j<MAX;j++) flag[j]=0;
      for(result=0;n[i]>9;result++)
	{
	  temp=(n[i]%10)*(n[i]/10);
	  for(j=100;j<=n[i];j*=10)
	    {
	      if((n[i]%j)*(n[i]/j)>temp) temp=(n[i]%j)*(n[i]/j);
	    }
	  n[i]=temp;
	  //printf("temp: %d\n",n[i]);
	  if(flag[n[i]]==1)
	    {
	      result=-1;
	      break;
	    }
	  else flag[n[i]]=1;
	}
      printf("%d\n",result);
    }
  return 0;
}

Measured memory_bytes: 5700
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N,W; cin >> N >> W;
    ll w[105],v[105];
    rep(i,0,N) cin >> w[i] >> v[i];
    ll dp[105][100100];
    Fill(dp, 1001001001);
    reps(i,0,N) dp[i][0] = 0;
    rep(i,0,N){
        reps(value,0,100100){
            if(value - v[i] >= 0){
                chmin(dp[i+1][value], dp[i][value-v[i]] + w[i]);
            }
            chmin(dp[i+1][value], dp[i][value]);
        }
    }

    ll ans = 0;
    rep(value,0,100100){
        if(dp[N][value] <= W) ans = value;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 85716
#include<cstdio>
#include<map>
#include<set>
#include<iostream>
#include<algorithm> 
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], n; 
int main() {
	while(~scanf("%d",&n)) {
		int x = 0, y = 0;
		for(int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
			if(a[i] & 1) x++;
			else y++;
		}
		if(1 & x) puts("NO");
		else puts("YES");
	}
	return 0; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,x,y;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)//不用绕，使出吃奶的劲儿都到不了
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)//如果最优路径与时间的积偶不一，一定到不了
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)//同理
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0; lli k = 0ll, g = 0ll;
	cin >> n >> k;
	vector<lli> a(n);
	cin >> a[0]; g = a[0];
	for (int i = 1; i < n; ++i)
	{
		cin >> a[i];
		g = __gcd(g, a[i]);
	}
	if (k % g == 0 && k <= *max_element(a.begin(), a.end()))
		cout << "POSSIBLE";
	else
		cout << "IMPOSSIBLE";
	cout << endl;
}

Measured memory_bytes: 3984
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <climits>

using namespace std;

map <string, int> memo;
string start, goal;
vector <string> a, b;
int ans;

string msed(string s, string a, string b) {
  string ret = "";
  int n = a.size();
  int p = 0;
  for (int i = 0; i < (int)s.size()-n+1; i++) {
    if (s.substr(i, n) == a) {
      ret += b;
      p = i+n;
      i += n-1;
    }else {
      ret += s[i];
      p = i+1;
    }
  }
  for (; p < s.size(); p++) ret += s[p];
  return ret;
}

void rec(string s, int cnt) {
  if (s.size() > goal.size()) return;
  if (cnt > 5) return;
  memo[s] = cnt;
  // if (s == goal) {
  //   cout << s << endl;
  //   cout << cnt << endl;
  // }
  // for (int i = 0; i < cnt; i++) cout << " ";
  // cout << s << endl;
  // cout << s << " " << cnt << " " << memo.size() << endl;
  // if (s == "aadeeeec") cout << s << " " << cnt << endl;
  for (int i = 0; i < a.size(); i++) {
    string ns = msed(s, a[i], b[i]);
    if (ns != s) rec(ns, cnt+1);
  }
}

void rev(string s, int cnt) {
  if (s.size() < start.size()) return;
  if (cnt > 5) return;
  if (memo.find(s) != memo.end()) {
    ans = min(ans, memo[s]+cnt);
  }
  if (s.size() == start.size()) return;
  // if (s == "adeeeeeec") cout << s << " " << cnt << endl;
  // cout << s << endl;
  for (int i = 0; i < b.size(); i++) {
    string ns = msed(s, b[i], a[i]);
    // if (ns == "adeeeeeec") cout << ns << " " << cnt << endl;
    if (ns != s) {
      string ts = msed(ns, a[i], b[i]);
      // if (ns == "adeeeeeec") cout << ts << endl;
      if (s == ts) rev(ns, cnt+1);
    }
  }
}

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    map<string, int> empmap;
    memo = empmap;
    vector<string> empvec;
    a = empvec;
    b = empvec;
    ans = INT_MAX;
    for (int i = 0; i < n; i++) {
      string t1, t2;
      cin >> t1 >> t2;
      a.push_back(t1);
      b.push_back(t2);
    }
    cin >> start >> goal;
    // cout << "ok0" << endl;
    rec(start, 0);
    // cout << "ok1" << endl;
    rev(goal, 0);
    // cout << "ok2" << endl;
    if (ans == INT_MAX) {
      cout << -1 << endl;
    }else {
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int n,id[N];
LL d[N],size[N];
vector <int> e[N];
map <LL,int> Map,My;
int depth[N];
void dfs(int x,int d){
	depth[x]=d;
	for (auto y : e[x])
		dfs(y,d+1);
}
bool check(int x,LL v){
	if (v!=d[x])
		return 0;
	for (auto y : e[x])
		if (!check(y,v-size[y]+(n-size[y])))
			return 0;
	return 1;
}
bool check(){
	dfs(1,0);
	LL v=0;
	for (int i=1;i<=n;i++)
		v+=depth[i];
	return check(1,v);
}
int main(){
	scanf("%d",&n);
	My.clear();
	for (int i=1;i<=n;i++)
		scanf("%lld",&d[i]),My[d[i]]=i;
	sort(d+1,d+n+1);
	for (int i=1;i<=n;i++)
		e[i].clear();
	Map.clear();
	for (int i=1;i<=n;i++)
		Map[d[i]]=i,size[i]=1;
	for (int i=n;i>1;i--){
		LL tmp=d[i]-n+size[i]*2;
		int fa=Map[tmp];
		if (!fa)
			return puts("-1"),0;
		e[fa].push_back(i);
		size[fa]+=size[i];
	}
	if (!check())
		return puts("-1"),0;
	for (int i=1;i<=n;i++)
		for (auto j : e[i])
			printf("%d %d\n",My[d[i]],My[d[j]]);
	return 0;
}

Measured memory_bytes: 23680
#include"bits/stdc++.h"
using namespace std;int main(){string s;while(getline(cin,s)){string c;for(auto i:s)c+=i==' '?"101":i=='\''?"000000":i==','?"000011":i=='-'?"10010001":i=='.'?"010001":i=='?'?"000001":i=='A'?"100101":i=='B'?"10011010":i=='C'?"0101":i=='D'?"0001":i=='E'?"110":i=='F'?"01001":i=='G'?"10011011":i=='H'?"010000":i=='I'?"0111":i=='J'?"10011000":i=='K'?"0110":i=='L'?"00100":i=='M'?"10011001":i=='N'?"10011110":i=='O'?"00101":i=='P'?"111":i=='Q'?"10011111":i=='R'?"1000":i=='S'?"00110":i=='T'?"00111":i=='U'?"10011100":i=='V'?"10011101":i=='W'?"000010":i=='X'?"10010010":i=='Y'?"10010011":"10010000";for(int j=0,k=c.length();j<(5-k%5)%5;++j)c+='0';for(int j=0;j<c.length();j+=5){int b=(c[j]-'0')*16+(c[j+1]-'0')*8+(c[j+2]-'0')*4+(c[j+3]-'0')*2+(c[j+4]-'0');cout<<(b<26?(char)('A'+b):" .,-'?"[b-26]);}cout<<endl;}}


Measured memory_bytes: 2996
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<cstdint>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;

template<ll mod> class modint{
public:
  ll val=0;
  constexpr modint(ll x=0) noexcept : val(x%mod){
    while(x<0)x+=mod;
  }
  constexpr ll getmod(){return mod;}
  constexpr ll getvalue(){return val;}
  constexpr const ll &value() const noexcept {return val;}
  constexpr modint operator+(const modint &r) const noexcept{return modint(*this)+=r;}
  constexpr modint operator-(const modint &r) const noexcept{return modint(*this)-=r;}
  constexpr modint operator*(const modint &r) const noexcept{return modint(*this)*=r;}
  constexpr modint operator/(const modint &r) const noexcept{return modint(*this)/=r;}
  constexpr modint& operator+=(const modint &r) noexcept{
    val += r.val;
    if(val >= mod){
      val -= mod;
    }
    return *this;
  }
  constexpr modint& operator-=(const modint &r) noexcept{
    if(val < r.val){
      val += mod;
    }
    val -= r.val;
    return *this;
  }
  constexpr modint& operator*=(const modint &r) noexcept{
    val = val * r.val % mod;
    return *this;
  }
  constexpr modint& operator/=(const modint &r) noexcept{
    ll a=r.val,b=MOD,u=1,v=0;
    while (b) {
      ll t = a/b;
      a -= t*b;swap(a,b);
      u -= t*v;swap(u,v);
    }
    val = val * u % MOD;
    if(val < 0)val += MOD;
    return *this;
  }
  constexpr bool operator == (const modint& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator < (const modint& r) const noexcept {
    return this->val < r.val;
  }
  constexpr bool operator != (const modint& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const modint<mod>& x) noexcept {
    return os << x.val;
  }
  friend constexpr modint<mod> modpow(const modint<mod> &a,ll n) noexcept {
    if(n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if(n & 1) t = t * a;
    return t;
  }
};

using mint = modint<1000000007>;

//n個の場合のlcmも2個で比べて順に適用していくだけ
signed main(){
  int n;cin >> n;
  vector<ll> a(n);for(int i=0;i<n;i++){cin >> a[i];}
  vector< map<mint,int> > prime_factors(n);
  for(int i=0;i<n;i++){
    for(int j=2;j<=1000;j++){
      while(a[i]%j==0){prime_factors[i][mint(j)]++;a[i]/=j;}
    }
    if(a[i]!=1) prime_factors[i][mint(a[i])]=1;
  }
  map<mint,int> lcm_all;
  for(ll i=0;i<n;i++){
    map<mint,int> now=prime_factors[i];
    for(auto& now_sub : now){
      lcm_all[now_sub.first]=max(now_sub.second,lcm_all[now_sub.first]);
    }
  }
  mint lcm_ans=mint(1);
  for(auto& lcm_all_sub : lcm_all){
    lcm_ans*=modpow(lcm_all_sub.first,lcm_all_sub.second);
  }
  mint cnt=0;
  for(int i=0;i<n;i++){
    mint cnt_sub=lcm_ans;
    map<mint,int> now=prime_factors[i];
    for(auto& now_sub : now){
      cnt_sub/=modpow(now_sub.first,now_sub.second);
    }
    cnt+=cnt_sub;
  }
  cout << cnt << endl;
}


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

// http://www.prefield.com/algorithm/misc/dice.html
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
public:
	dice(int top,int front,int right,int left,int back,int bottom) {
		id[TOP] = top; id[FRONT] = front; id[RIGHT] = right;
		id[LEFT] = left; id[BACK] = back; id[BOTTOM] = bottom;
	}
	int& operator[] (FACE f) { return id[f]; }
	const int& operator[] (FACE f) const { return id[f]; }
	bool operator==(const dice &b) const {
		const dice &a = *this;
		return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
			a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
			 a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
	}
	void roll_north() { roll(TOP, FRONT, BOTTOM, BACK); }
	void roll_south() { roll(TOP, BACK, BOTTOM, FRONT); }
	void roll_east() { roll(TOP, LEFT, BOTTOM, RIGHT); }
	void roll_west() { roll(TOP, RIGHT, BOTTOM, LEFT); }
	void roll_right() { roll(FRONT, LEFT, BACK, RIGHT); }
	void roll_left() { roll(FRONT, RIGHT, BACK, LEFT); }
	vector<dice> all_rolls(){
		vector<dice> ret;
		for (int k = 0; k < 6; (k&1?roll_east():roll_north()),++k)
			for (int i = 0; i < 4; roll_right(), ++i)
				ret.push_back(*this);
		return ret;
	}
private:
	void roll(FACE a, FACE b, FACE c, FACE d){
		int tmp = id[a];
		id[a] = id[b]; id[b] = id[c];
		id[c] = id[d]; id[d] = tmp;
	}
	int id[6];
};

int main(){
	int d[6];
	for(int i=0;i<6;i++)cin>>d[i];
	dice di(d[0],d[1],d[2],d[3],d[4],d[5]);
	vector<dice> v=di.all_rolls();
	int n,x,y;
	for(cin>>n;n--;){
		cin>>x>>y;
		for(int i=0;i<v.size();i++){
			if(v[i][TOP]==x&&v[i][FRONT]==y){
				cout<<v[i][RIGHT]<<endl;
			}
		}
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int n,k;
    cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    cout << n-(k-1)*1-1 << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
        "math"
)

func main() {
        var n, x int
        fmt.Scan(&n, &x)
        min := math.MaxInt32
        for i := 0; i < n; i++ {
                var tmp int
                fmt.Scan(&tmp)
                x -= tmp
                if tmp < min {
                        min = tmp
                }
        }
        fmt.Printf("%d\n", n+x/min)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define fr(i,a,b) for(ll i=(a);i<(b);i++)
#define frd(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl "\n"
#define inf ((long long) 1e18 + 10)
#define ve vector<ll>
using namespace std;


int main() {
        std::ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
        int n;
        cin>>n;
        unordered_map<string,int> mp;
        string temp;
        rep(i,n){
                cin>>temp;
                mp[temp] += 1;
        }
        cout<<mp.size()<<endl;
        return 0;
}



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

int main() {
    int n; cin >> n;
    string taro, hanako;
    int tp = 0, hp = 0;
    for (int i = 0; i < n; i++) {
        cin >> taro >> hanako;
        if (taro > hanako) tp += 3;
        else if (taro < hanako) hp += 3;
        else if (taro == hanako) {
            hp++;
            tp++;
        }
    }
    cout << tp << ' ' << hp << endl;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    int n;
        cin >> n;
    int dt=0, x=0, y=0, t, pos=0;
    string ans="Yes";
        for(int i=0; i<n; i++){
            cin >> t >> x >> y;
            dt = t-dt;
            pos = abs(pos - (x+y));
            if((dt-pos)%2!=0 || dt<pos) ans = "No";
            
        }
        cout << ans << endl;
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<bool>> lights(M, vector<bool>(N, false));
    for (int i = 0; i < M; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int s; cin >> s; s--;
            lights[i][s] = true;
        }
    }
    int ans = 0;
    vector<int> p(M);
    for (int i = 0; i < M; i++) cin >> p[i];
    for (int i = 0; i < 1<<N; i++) {
        vector<int> onoff(N);
        bool f = true;
        for (int j = 0; j < N; j++) {
            onoff[j] = (1 & i>>j);;
        }
        for (int j = 0; j < M; j++) {
            int t = 0;
            for (int k = 0; k < N; k++) {
                if (onoff[k] && lights[j][k]) t++;
            }
            if (t % 2 != p[j]) f = false;
        }
        if (f) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001
#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;


int main(void){
  long double N,D;
  cin >> N >> D;
  int cnt = 0;
  for(int i =0;i  < N; i++){
    long double X,Y;
    cin >> X >> Y;
    long double dis = sqrt(X*X + Y*Y);
    if(dis <= D){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<bool> moved(n,false);
    vector<int> op(m);
    for (int i = 0; i < m; ++i) {
        cin>>op[m-1-i];
        --op[m-1-i];
    }
    vector<int> ans;
    for (int i = 0; i < m; ++i) {
        if(moved[op[i]])continue;
        moved[op[i]]=true;
        ans.push_back(op[i]);
    }
    for (int j = 0; j < n; ++j) {
        if(!moved[j])ans.push_back(j);
    }
    for (int i = 0; i < n; ++i) {
        cout<<ans[i]+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
// input vector
template<typename T>
void invec(vector<T> &A){for(T& a : A) cin >> a;}


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

int X, Y, Z, K; cin >> X >> Y >> Z >> K;
VI A(X), B(Y), C(Z);  
invec(A);
invec(B);
invec(C);

VI D;
rep(x, 0, X) rep(y, 0, Y)
    D.push_back(A[x] + B[y]);
sort(ALL(D), greater<i64>());

VI ans;
rep(k, 0, min(K, X*Y)) rep(z, 0, Z)
    ans.push_back(D[k] + C[z]);
sort(ALL(ans), greater<i64>());

rep(i, 0, K)
    cout << ans[i] << "\n";

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  ans += min(a+b, 2*c) * min(x, y);
  ans += (x < y ? min(b, 2*c)*(y-x) : min(a, 2*c)*(x-y));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		int[][] a = new int[m][n];
		for(int i = 0; i < m; i++){
			b[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[j][i] = sc.nextInt();
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++){
			int sum = 0;
			for(int j = 0; j < m; j++){
				sum += a[j][i]*b[j];
			}
			sum += c;
			if(sum > 0)ans++;
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 24276
import numpy as np
a, b, c = map(int, input().split())
li = np.array([])

m = max(a, b, c)
if abs(a-m) != 0:
    li = np.append(li, abs(a-m))
if abs(b-m) != 0:
    li = np.append(li, abs(b-m))
if abs(c-m) != 0:
    li = np.append(li, abs(c-m))

if sum(li) % 2 == 0:
    print(int(sum(li)/2))
else:
    print(int((sum(li)+1)/2+1))


Measured memory_bytes: 21552
#include<stdio.h>
int main(void){
	int turn,i,myten=0,yourten=0,t,ch=0;
	char my[101],your[101];
	scanf("%d",&turn);
	for(i=0;i<turn;i++){
		scanf("%100s %100s",my,your);
		for(t=0;ch==0;t++){
		if(my[t]>your[t]){
			myten+=3;
			ch++;
		}else if(my[t]<your[t]){
			yourten+=3;
			ch++;
		}else if(my[t]=='\0'&&your[t]=='\0'){
			myten+=1;
			yourten+=1;
			ch++;
		}
		}
		
	ch=0;
}
	printf("%d %d\n",myten,yourten);
	return 0;
}

Measured memory_bytes: 2700
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
    const int MAX = 1'000'100;
    int N;
	vector<int> table;
	vector<int> x;
	vector<int> A;
    bool flag = false;
    int GCD = 0;
    
    cin>>N;
    
    table.resize(MAX);
    x.resize(MAX);
    A.resize(N);
    
    table[1] = table[0] = 1;
    
    for(int i = 2; i < table.size(); i++){
        
        if(table[i]) continue;
        
        table[i] = 1;
        
        for(int j = i * 2; j < table.size(); j += i){
            table[j] = j/i;
        }
    }
    // for(int i = 0; i < 100; i++){
        // cout<<i<<" table "<<table[i]<<endl; 
    // }
    
    for(int i = 0; i < N; i++){
        cin>>A[i];
        
        GCD = __gcd(GCD, A[i]);
    }
    
    for(int i = 0; i < N; i++){
        int a = A[i];
        vector<int> hoge;
        
        // cout<<"A = "<<a<<endl; cout<<"i = "<<i<<endl;
        
        for(;;){
            if(a == 1) break;
            if(a == 0) break;
            if(a/table[a] == 1) break;
            
            // cout<<"[] "<<a/table[a]<<endl;
            
            if(x[a/table[a]]) {
                flag = true;
                // cout<<"Flag"<<" "<<a - table[a]<<" "<<x[a - table[a]]<<endl;
            }
            // cout<<"a = "<<a<<" "<<table[a]<<endl;
            // cout<<a - table[a]<<endl;
            // x[a - table[a]]++;
            
            hoge.push_back(a/table[a]);
            
            // cout<<"X = "<<x[a - table[a]]<<" <> "<<a - table[a]<<endl;
            a = table[a];
        }
        
        for(int j = 0; j < hoge.size(); j++){
            x[hoge[j]]++;
        }
        
        if(flag) break;
    }
    
    // cout<<"GCD = "<<GCD<<endl;
    
    if(flag == true && GCD == 1) cout<<"setwise coprime"<<endl;
    else if(flag == false)cout<<"pairwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
	
	return 0;
}

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

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

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

const int MAX = 1e5 + 10;
int N;
PII range[MAX];

int main(void) {
    cin >> N;
    REP(i, N) {
        int l, x;
        cin >> x >> l;
        range[i].first = x - l;
        range[i].second = x + l;
    }

    sort(range, range + N, [](const PII &l, const PII &r) {
        return l.second < r.second;
    });

    int tmp = -INF;
    int cnt = 0;
    REP(i, N) {
        if (tmp <= range[i].first) {
            cnt++;
            tmp = range[i].second;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int reach[3];
long ans = 1e16;
void dfs(int n, int i, vi &l, vvi &pos){
  if(i == n){
    long cost = 0;
    rep(j,3){
      if(reach[j] < pos.at(j).size() || pos.at(j).size() == 0) return;
      cost += (pos.at(j).size() - 1)*10;
      long sum = 0;
      for(long x : pos.at(j)){
        sum += x;
      }
      cost += abs(reach[j] - sum);
    }
    ans = min(ans, cost);
    return;
  }
  rep(j,4){
    pos.at(j).push_back(l.at(i));
    dfs(n,i+1,l,pos);
    pos.at(j).pop_back();
  }
}

int main(){
  int n;
  cin >> n;
  rep(i,3) cin >> reach[i];
  vi l(n);
  vvi pos(4);
  rep(i,n) cin >> l.at(i);
  dfs(n,0,l,pos);
  cout << ans << endl;
}

Measured memory_bytes: 256
N,C = map(int,input().split())
ps = [[] for i in range(C)]
for i in range(N):
    s,t,c = map(int,input().split())
    ps[c-1].append((s,t))

MAX_N = 10**5+3
imos = [0] * MAX_N
for c in range(C):
    ps[c].sort()
    cont = False
    for i,(s,t) in enumerate(ps[c]):
        if not cont:
            imos[s-1] += 1
        if i < len(ps[c])-1 and t == ps[c][i+1][0]:
            cont = True
        else:
            imos[t] -= 1
            cont = False

ans = t = 0
for a in imos:
    t += a
    ans = max(ans, t)
print(ans)


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (auto& x : a) {
		cin >> x;
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if ((i + 1) % 2 != 0 && a[i] % 2 != 0) {
			++ans;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 20
#define LL long long
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
LL i,k,lim,D,ans;
LL _10[N];
LL Abs(LL x){return x>0?x:-x;}
LL dg(LL w,LL d){
	if(!w)return (d==0);else
	if(w==1)return d?0:10;
	LL x=(d%10)==0?0:10-d%10;
	LL j=(d%10)==0?10:d%10;
	if(w==k)j--;
	return dg(w-2,Abs(d-x*_10[w]+x)/10)*j;
}
int main(){
	scanf("%lld",&D);lim=log10(D)+1;
	_10[1]=1;fo(i,2,19)_10[i]=_10[i-1]*10;
	fo(i,lim,lim*2)k=i,ans+=dg(i,D);
	printf("%lld",ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int D;
	cin >> D;
	vector<int> c(26);
	for (int i = 0 ; i < 26 ; i++) {
		cin >> c[i];
	}
	vector<vector<int>> s(D, vector<int>(26));
	for (int i = 0 ; i < D ; i++) {
		for (int j = 0 ; j < 26 ; j++) {
			cin >> s[i][j];
		}
	}
	vector<int> l(26);
	ll score = 0;
	vector<int> malus = c;
	for (int d = 0 ; d < D ; d++) {
		int choice = 0;
		int best = 0;
		for (int i = 0 ; i < 26 ; i++) {
			int dm = d + i - l[i] + s[d][i];
			if (dm > best) {
				best = dm;
				choice = i;
			}
		}
		l[choice] = d + 1;
		score += s[d][choice];
		for (int i = 0 ; i < 26 ; i++) {
			score -= c[i] * (d + 1 - l[i]);
		}
		cout << choice + 1 << "\n";
	}
	cerr << max(ll(1e6) + score, 0LL) << endl;
	return 0;
}


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

typedef long long int ll;
typedef long double ld;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define MOD (ll)(1e9 + 7)
#define vi vector<int>
#define vii vector<vector<int> >
#define vl vector<ll>
#define vll vector<vector<ll> >
#define vc(T, nm) vector<T> nm
#define pb push_back
#define popb pop_back
#define si set<int>
#define sl set<ll>
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define ins insert
#define ers erase
#define endl "\n"
#define mul(a, b) ((a % MOD) * (b % MOD)) % MOD
#define adr(a, b) ((a % MOD) + (b % MOD)) % MOD
#define FORA(x, s, e, inc) for(ll x = s; x != e; x += inc)
#define ROFA(x, s, e, inc) for(ll x = s; x != e; x -= inc)
#define FOR(x, s, e) FORA(x, s, e, 1)
#define ROF(x, s, e) ROFA(x, s, e, 1)
#define loop(x, n) FOR(x, 0, n)
#define rd1(t, a) 					t a; cin >> a;
#define rd2(t, a, b) 				rd1(t, a); rd1(t, b); 
#define rd3(t, a, b, c) 			rd2(t, a, b); rd1(t, c);
#define rd4(t, a, b, c, d) 			rd3(t, a, b, c); rd1(t, d);
#define rd5(t, a, b, c, d, e) 		rd4(t, a, b, c, d); rd1(t, e);
#define rd6(t, a, b, c, d, e, f) 	rd5(t, a, b, c, d, e); rd1(t, f);
#define rdA(t, nm, len)				t nm[len]; loop(i, len) {cin >> nm[i];}
#ifdef DEBUG
	#define deb(v) cout << endl << #v << ": " << v << endl
	#define db1(v) cout << endl << #v << ": " << "[ "; for(auto x: v) {cout << x << " ";}; cout << "]" << endl;
	#define db2(v) cout << endl << #v << ": " << endl; for(auto r: v) {cout << "[ "; for(auto x: r) {cout << x << " ";}; cout << "]" << endl;};
	#define dbl cout << "-------------------------------" << endl
#else
	#define deb(v)
	#define db1(v)
	#define db2(v)
	#define dbl
#endif

void solve() {
    rd1(ll, n);
    vl A(n);
    FOR(i, 0, n)
        cin >> A[i];
    
    vector<int> vis(1000004, 0);
    
    FOR(i, 0, n)
        vis[A[i]]++;
    if(n == 1) {
        cout << 1;
        return;
    }
    if(vis[1] == 1) {
        cout << 1;
        return;
    }
    if(vis[1] > 1) {
        cout << 0;
        return;
    }
    int ct = 0;
    FOR(i, 0, n) {
        int nm = A[i];
        int flag = 0;
        int snm = nm;
        for(int j = 2; j * j <= snm + 1; j++) {
            if(nm % j == 0) {
                if(vis[nm/j] != 0 or vis[j] != 0) {
                    flag = 1;
                    break;
                }
            }
        }
        if(vis[nm] > 1)
            flag = 1;
        if(flag == 0)
            ct++;
    }
    
    cout << ct;
    
    
	
}

int main() {
	
	fastio;

//  	rd1(ll, t);
	ll t = 1;

    while(t--) {
        solve();
    }
    
	return 0;
}

Measured memory_bytes: 8716