akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

#define int long long
int N, M;
int P[100100];
int A[100100];
int B[100100];
int C[100100];

int visit[100100];

signed main() {
  cin >> N >> M;
  for (int i=0; i<M;   i++) cin >> P[i];
  for (int i=0; i<N-1; i++) cin >> A[i] >> B[i] >> C[i];

  for (int i=1; i<M; i++) {
    int from = P[i-1]-1;
    int to   = P[i]-1;
    //for (int j=min(from, to); j<max(from, to); j++) visit[j]++;
    visit[min(from, to)]++;
    visit[max(from, to)]--;
  }

  int ans = 0;
  int t = 0;
  for (int i=0; i<N-1; i++) {
    t += visit[i];
    if (t != 0) ans += min(t*A[i], C[i] + t*B[i]);
  }
  cout << ans << "\n";
  return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  ll a,b,k; cin>>a>>b>>k;
  ll take = min(k,a);
  a-=take;
  k-=take;
  take = min(k,b);
  b-=take;
  cout<<a<<" "<<b<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>

using namespace std;

int main()
{
    string S;
    while (cin >> S, S != "#") {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--; c--; d--;
        char field[9][9];
        int H = 0, W = 0;
        for (int i = 0; i < (int)S.size(); i++) {
            if (S[i] == '/') {
                H++;
                W = 0;
                continue;
            }
            if (isdigit(S[i])) {
                for (int j = 0; j < (S[i] - '0'); j++) {
                    field[H][W + j] = '.';     
                }
                W += (S[i] - '0');
            } else {
                field[H][W] = 'b';
                W++;
            }
        }
        
        field[a][b] = '.';
        field[c][d] = 'b';
        
        H++;
        string res;
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; ) {
                if (field[i][j] == 'b') {
                    res += 'b';
                    j++;
                } else {
                    int cnt = 0;
                    while (j < W && field[i][j] == '.') {
                        j++;
                        cnt++;
                    }
                    res += (cnt + '0');
                }
            }
            if (i != H - 1) res += '/';
        }
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 3132
use std::io;

fn input() -> (i32, char, i32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: char = iter.next().unwrap().chars().nth(0).unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    (a, b, c)
}

fn main() {
    loop {
        let (a, b, c) = input();
        if b=='?' { break; }
        if b=='+' {
            println!("{}", a+c);
        }
        if b=='-' {
            println!("{}", a-c);
        }
        if b=='*' {
            println!("{}", a*c);
        }
        if b=='/' {
            println!("{}", a/c);
        }
    }
}


Measured memory_bytes: 5028
#include <stdio.h>
 
int main(void) {
    int a,b;
    char op;
    
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        //???????????其
        if(op=='?') break;
        else if(op=='+') printf("%d\n", a+b);
        else if(op=='-') printf("%d\n", a-b);
        else if(op=='*') printf("%d\n", a*b);
        else printf("%d\n", a/b);        
    }
    
    return 0;
}

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

int main(){
	int *a;
	int i, s0 = 0, s1 = 0, s2 = 0, N;
	a = (int *)malloc(100000 * sizeof(int));

	scanf("%d", &N);
	for(i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		if(a[i] % 4 == 0) {
			s2 += 1;
		}
		else if(a[i] % 2 == 0) {
			s1 += 1;
		}
		else {
			s0 += 1;
		}
	}

	if((s2 >= s0) || ((s2 + 1 == s0) && s1 == 0)) {
		printf("Yes");
	}

	else {
		printf("No");
	}
		

	free(a);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i = 0; i < n; ++i)
  {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int sum = accumulate(l.begin(), l.end(), 0);
  cout << (l.back() * 2 < sum ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<math.h>
long int f(long int a,long int b){return a<b?a:f(a/b,b)+a%b;}
int main(){
  long int n,s,i,j;
  scanf("%ld%ld",&n,&s);
  if(n==s){printf("%ld",n+1);return 0;}
  if(n<s){printf("-1");return 0;}
  for(i=2;i<=sqrt(n);i++)if(f(n,i)==s){printf("%ld",i);return 0;}
  for(i=sqrt(n);i>0;i--){if((n-s)/i&&f(n,(n-s)/i+1)==s){printf("%ld",(n-s)/i+1);return 0;}}
  printf("-1");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (ll i = (ll)(start); i < (ll)(n); ++i)
static const ll INFTY = 1L << 62L;
void solver(ll *a, ll n)
{
    ll ans = a[0];
    rep(i, 1, n) ans = gcd(ans, a[i]);
    if (ans != 1)
    {
        cout << "not coprime\n";
        return;
    }
    ll m = 0;
    rep(i, 0, n) m = max(m, a[i]);
    ll v[m + 1] = {};
    rep(i, 0, n)
    {
        if (a[i] == 1)
            continue;
        if (v[a[i]] == 1)
        {
            cout << "setwise coprime\n";
            return;
        }
        v[a[i]] = 1;
    }
    rep(i, 2, m + 1)
    {
        ll c = 0;
        for (ll j = i; j <= m; j += i)
        {
            c += v[j];
            if (c > 1)
            {
                cout << "setwise coprime\n";
                return;
            }
        }
    }
    cout << "pairwise coprime\n";
    return;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    solver(a, n);
}

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

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

typedef std::pair<ll, ll> pi;

using namespace std;

int gcd(int a,int b) {
    if (a%b==0) return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll a,b,c,d; cin >> a >> b >> c >> d;

    ll ans1 = (b/c) - ((a-1) / c);
    ll ans2 = (b/d) - ((a-1) / d);
    ll tmp = c*d/gcd(d,c);
    ll ans3 = (b/tmp) - ((a-1) / tmp);

    cout << b-a+1-(ans1+ans2-ans3) << endl;

    return 0;
}


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

public class Main {
  private static int solve(int n, int[] as) {
    int count = 0;
    for (int a : as) {
      while (a % 2 == 0) {
        count++;
        a /= 2;
      }
    }
    return count;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int[] as = reader.nextInt(n);
    out.println(solve(n, as));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 25428
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	string s; cin >> s;
	ll n = s.size();
	if(s[0]=='1' && s[n-2]=='1' && s[n-1]=='0'){
		ll now = 0;
		ll move = 1;
		ll put = n;
		vpl ans;
		REP(i,1,n/2+1){
			if(s[i] != s[n-2-i]){
				puts("-1");
				return 0;
			}
			if(s[i-1] == '1'){
				put--;
				ans.emplace_back(put,put+1);
				REP(j,now,i-2){
					ans.emplace_back(put,move);
					move++;
				}
				now = i-1;
			}
		}
		REP(i,move,put+1) ans.emplace_back(0,i);
		for(auto i : ans){
			if(i.second == n) continue;
			print2(i.first+1, i.second+1);
		}
	}else{
		puts("-1");
	}
}

Measured memory_bytes: 3056
N = int(input())
S = [i for i in input().split()]

ct = 0
if 'P' in S:
    ct += 1
if 'W' in S:
    ct += 1
if 'G' in S:
    ct += 1
if 'Y' in S:
    ct += 1

if ct == 3:
    print('Three')
else:
    print('Four')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

namespace {

	int cnt;
	void InsertionSort(vector<int>& A, int g)
	{
		for (int i = g; i < A.size(); ++i)
		{
			int v = A[i];
			int j = i - g;

			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}

			A[j + g] = v;
		}
	}

	void ShellSort(vector<int>& A)
	{
		cnt = 0;
		vector<int> G;
		for (int i = 1; i <= A.size(); i = 3 * i + 1)
			G.push_back(i);
		reverse(G.begin(), G.end());

		for (auto i : G)
			InsertionSort(A, i);

		cout << G.size() << endl;
		cout << G[0];
		for (auto it = G.begin() + 1; it != G.end(); ++it)
			cout << ' ' << *it;
		cout << endl;
		cout << cnt << endl;
		for (auto i : A)
			cout << i << endl;
	}
}

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

	int n;
	cin >> n;

	vector<int> A(n);
	for (int i = 0; i < n; ++i)
		cin >> A[i];

	ShellSort(A);

	return 0;
}

Measured memory_bytes: 6736
#include<stdio.h>
int main(){
  int N,i,j,temp,cout=0;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N-1;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	temp=A[j-1];
	A[j-1]=A[j];
	A[j]=temp;
	cout++;
      }
    }
  }
  printf("%d",A[0]);
  for(i=1;i<N;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  printf("%d\n",cout);
  return 0;
}



Measured memory_bytes: 2128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var dict = new Dictionary<string, int>();
            var max = 0;
            for (var i = 0; i < N; i++)
            {
                var S = Scanner.Scan<string>();
                if (!dict.ContainsKey(S)) dict[S] = 0;
                dict[S]++;
                max = Math.Max(max, dict[S]);
            }
            foreach (var s in dict.Where(x => x.Value == max).OrderBy(x => x.Key))
            {
                Console.WriteLine(s.Key);
            }
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 57384
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
const int MOD = 1e9+7;

int exgcd(int a,int b,int &x,int &y){
	while(b){
		int t{a/b};
		swap(a-=t*b, b);
		swap(x-=t*y, y);
	}
	return a;
}
int exgcd(int a,int b){
	int x{1},y{0};
	return exgcd(a,b,x,y);
}
int inverse(int a,int mod){
	int x{1},y{0};
	exgcd(a,mod,x,y);
	return (x%mod+mod)%mod;
}

int main(){
	const int bit = 60;
	int n; cin>>n;
	ll cnt{};
	vector<int> sum(bit);
	vector<bitset<bit>> a(n);
	for(int i=0; i<n; i++){
		ll b; cin >> b;
		a.at(i) = bitset<bit>(b);
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<bit; j++){
			if(a.at(i).test(j)) sum.at(j)++;
		}
	}
	for(int i=0; i<n; i++){
		ll p{1};
		for(int j=0; j<bit; j++){
			if(a.at(i).test(j)) {
				(cnt += (n-sum.at(j)) * p) %= MOD;
			}
			else {
				(cnt += (sum.at(j)) * p) %= MOD;
			}
			p<<=1;
			p %= MOD;
		}
	}
	cout << (cnt*inverse(2,MOD))%MOD << endl;
	
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int h[101];
int main(){
	int ans=0;
	cin>>N;
	REP(i,N){
		cin>>h[i];
	}
	
	REP(k,100001){
		bool check=false;
		REP(i,N){
			if(check==true){
				if(h[i]>0){
					h[i]--;
				}else{
					check=false;
				}
			}else{
				if(h[i]>0){
					h[i]--;
					ans++;
					check=true;
				}
			}
		}
	}
	
	cout<<ans<<endl;
}

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

int main() {
  ll x,k,d;cin>>x>>k>>d;
  x=abs(x);
  if(k<=x/d)cout<<x-k*d<<endl;
  else {
    if((k-x/d)%2==0)cout<<x-x/d*d<<endl;
    else cout<<d-(x-x/d*d)<<endl;
  }
}

Measured memory_bytes: 3616
high,wide = gets.chomp.split(" ").map{|x| x.to_i}
semi_map = Array.new.map!{Array.new}
(high).times do 
semi_map.push(gets.chomp.split(//).map{|x|x.to_i})
end
(high).times do |h|
  (wide).times do |w|
    if h>0 && w>0 
      semi_map[h][w] +=  semi_map[h-1][w] < semi_map[h][w-1] ? semi_map[h-1][w]: semi_map[h][w-1]
    elsif h>0 || w>0
      semi_map[h][w] += h>0 ? semi_map[h-1][w]: semi_map[h][w-1]
    end   
 end  
end
p semi_map[high-1][wide-1]

Measured memory_bytes: 6120
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N],b[N],ct;
pair<int,int> c[N];
int main()
{
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
	{
	  cin>>a[i]>>b[i];
	  c[i]=make_pair(b[i],a[i]);
    }
	sort(c,c+n);
	for (int i=0;i<n;i++)
	{
		if (c[i].first-c[i].second<ct) {
		puts("No");exit(0);}
		else ct+=c[i].second;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 3456
import Data.Char (digitToInt)

main :: IO ()
main = print . solve . map (fromIntegral . digitToInt) =<< getLine

solve :: [Integer] -> Integer
solve xs = sum [ 2 ^ (max (i - 1) (length xs - 2 - j)) * 10 ^ j * x | (i, x) <- zip [1..] xs, j <- [0 .. length xs - i] ]


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

int main(){
    using namespace std;
    // input
    size_t n;
    cin >> n;
    
    // process
    unsigned long ans{0};
    for(unsigned long i = 0, a; i < n; ++i, ++ans){
        cin >> a;
        for(unsigned long j = 2; j * j <= a; ++j)if(a % j == 0){
            --ans;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3080
n = int(input()) 
D = [int(i) for i in input().split()] 


if len(D) & 2 == 1: ans = 0
else:


    D = sorted(D)

    a = D[int(len(D)/2) - 1]
    b = D[int(len(D)/2)]

    ans = b - a


print(ans)

Measured memory_bytes: 14428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class Program
{

    static void Main()
    {
        var sc = new Scanner();
        int n = sc.Int();
        Console.WriteLine(800 * n - 200 * (n / 15));

    }
}
static class Extentions
{
    public static IEnumerable<T> Outpuut<T>(this IEnumerable<T> source)
    {
        foreach (var item in source)
        {
            Console.WriteLine(item);
        }
        return source;
    }
    public static T Print<T>(this T obj)
    {
        Console.WriteLine(obj);
        return obj;
    }
}
public class Scanner
{
    public Scanner()
    {
        byte[] inputBuffer = new byte[1024];
        System.IO.Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new System.IO.StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
    }
    string[] buffer = new string[0];
    int index = 0;
    public char[] SplitChars { get; set; }
    public string String()
    {
        if (index < buffer.Length) return buffer[index++];
        string line = "";
        while (line == "") line = Console.ReadLine();
        if (line == null) return null;
        buffer = line.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
        index = 0;
        return buffer[index++];
    }
    public string[] StringArray(int count) { return NextArray(count, x => x); }
    public void Skip(int count) { for (int i = 0; i < count; i++) String(); }
    public T Next<T>(Func<string, T> parser) { return parser(String()); }
    public T[] NextArray<T>(int count, Func<string, T> parser)
    {
        var arr = new T[count];
        for (int i = 0; i < count; i++) arr[i] = Next(parser);
        return arr;
    }
    public int Int() { return Next(int.Parse); }
    public int[] IntArray(int count) { return NextArray(count, int.Parse); }
    public double Double() { return Next(double.Parse); }
    public double[] DoubleArray(int count) { return NextArray(count, double.Parse); }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define int ll
using namespace std;
ll c[55],f[250050],sz[55],fa[55];
struct node{
	ll cost,value,count;
	node(ll cost=0,ll value=0,ll count=0){this->cost=cost,this->value=value,this->count=count;}
	inline friend bool operator < (const node a,const node b){return a.cost*b.value<b.cost*a.value;}
}cs[555];
signed main(){
	ll n,x,d,ans=0;cin>>n>>x>>d;cin>>c[1];sz[1]=1;
	for(int i=2;i<=n;++i) cin>>c[i]>>fa[i],sz[i]=1;
	for(int i=n;i;--i) c[fa[i]]+=c[i],sz[fa[i]]+=sz[i];memset(f,0x3f,sizeof f);f[0]=0;
	for(int i=1;i<=n;++i){
		int T=min(n,d);if(i==1) T=n;
		for(int bit=1;bit<=T;T-=bit,bit<<=1) for(int j=n*n*n;j>=bit*sz[i];--j) f[j]=min(f[j],f[j-bit*sz[i]]+bit*c[i]);//bit>>=1;
		for(int j=n*n*n;j>=T*sz[i];--j) f[j]=min(f[j],f[j-T*sz[i]]+T*c[i]);
		if(i==1) cs[i]=node(c[i],sz[i],1e9);
		else cs[i]=node(c[i],sz[i],max(0ll,d-n));
	}
	sort(cs+1,cs+n+1);
	for(int has=0;has<=n*n*n;++has)if(f[has]<=x){
		int las=x-f[has],res=has;
		for(int i=1;i<=n;++i){
			int now=min(cs[i].count,las/cs[i].cost);
			res+=now*cs[i].value;las-=now*cs[i].cost;
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5588
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    if(n<1200)
        cout<<"ABC";
    else if(n>=1200&&n<2800)
        cout<<"ARC";
    else if(n>=2800)
        cout<<"AGC";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int64_t
#define ar array
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (n); ++i) 
using namespace std;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), cnt(1e6+5);
    forn(i,n){
        cin>>a[i];
        cnt[a[i]]++;
    }
    int ans=0;
    forn(i,n){
        cnt[a[i]]--;
        bool fl=false;
        for(int j=1;j*j<=a[i];++j){
            if(a[i]%j==0){
                fl|=cnt[j];
                fl|=cnt[a[i]/j];
            }
        }
        ans+=!fl;
        cnt[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 7956
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    LL n;
    LL k;
    LL tmp;
    int ans;

    cin >> n >> k;
    ans=1;
    tmp=1;
    while(true){
        tmp*=k;
        if(tmp>n){
            break;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,flg(0);
  cin >> n >> m;
  vector<int>a(n),s(m),c(m);
  for(int i = 0;i<n;i++){
    a.at(i) = -1;
  }
  for(int i = 0;i<m;i++){
    cin >> s.at(i) >> c.at(i);
    if(a.at(s.at(i)-1) == -1){
      a.at(s.at(i)-1) = c.at(i);
    }else if(a.at(s.at(i)-1) != c.at(i)){
      flg = 1;
    }
  }
  if(a.at(0) == -1 && n > 1)a.at(0) = 1;
  if(flg == 1 || (a.at(0) == 0 && n != 1)){
    cout << -1 << endl;
  }else{
    for(int i = 0;i<n;i++){
      if(a.at(i) == -1)a.at(i) = 0;
        cout << a.at(i);
    }
    cout << endl;
  }

}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

namespace io {
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  const int SIZE = (1 << 21) + 1;
  char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
  inline char getc () {return (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++);}
  inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
  inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
  template<class T>
  inline void read(T &x) {
    char ch; int f = 1;
    x = 0;
    while(isspace(ch = getc()));
    if(ch == '-') ch = getc(), f = -1;
    do x = x * 10 + ch - '0'; while(isdigit(ch = getc()));
    x *= f;
  }
  template<class T, class ...Args>
  inline void read(T &x, Args&... args) {read(x); read(args...);}
  template<class T>
  inline void write(T x) {
    static char stk[128];
    int top = 0;
    if(x == 0) {putc('0'); return;}
    if(x < 0) putc('-'), x = -x;
    while(x) stk[top++] = x % 10, x /= 10;
    while(top) putc(stk[--top] + '0');
  }
  template<class T, class ...Args>
  inline void write(T x, Args... args) {write(x); putc(' '); write(args...);}
  inline void space() {putc(' ');}
  inline void endl() {putc('\n');}
  struct _flush {~_flush() {flush();}} __flush;
};
using io::read; using io::write; using io::flush; using io::space; using io::endl; using io::getc; using io::putc;

const int M = 1000000007;

struct pt {
  ll x, y;
  pt() {}
  pt(ll _x, ll _y) : x(_x), y(_y) {}
};
vector<pt> ex[90];
ll fib[90];

void pre() {
  ex[1].emplace_back(1, 2);
  fib[0] = fib[1] = 1;
  for (int i = 2; i <= 88; ++i) fib[i] = fib[i - 1] + fib[i - 2];
  for (int i = 2; i <= 87; ++i) {
    ex[i].emplace_back(fib[i + 1], fib[i + 1] + fib[i - 1]);
    for (auto p : ex[i - 1])
      ex[i].emplace_back(p.y, p.x + p.y);
    ex[i - 1].emplace_back(fib[i - 1], fib[i + 1]);
  }
}
void work1() {
  int T;
  read(T);
  while (T--) {
    ll x, y;
    read(x, y);
    if (x > y) swap(x, y);
    if (x == 1) {
      write(1, y % M), endl();
      continue;
    }
    if (x == 2 && y == 2) {
      write(1, 4), endl();
      continue;
    }
    int res = 0;
    ll cnt = 0;
    for (int i = 1; i <= 87; ++i)
      if (fib[i] <= x && fib[i + 1] <= y)
        res = i;
      else break;
    for (auto p : ex[res - 1]) {
      if (y >= p.x && x >= p.y) cnt += (y - p.x) / p.y, cnt %= M;
      if (x >= p.x && y >= p.y) cnt += (x - p.x) / p.y, cnt %= M;
    }
    write(res, cnt), endl();
  }
}

int main() {
  // File("4371");
  pre();
  work1();
  return 0;
}

Measured memory_bytes: 8560
#include <stdio.h>
#include <iostream>
#define Re register int
#define mod int(1e9+7)

int N,A[22][22],f[22][1<<21];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
inline int Count(int x)
{
	int ret=0;
	while (x) ret+=x&1,x>>=1;
	return ret;
}
int main(int argc, char const *argv[])
{
	read(N); int lim=(1<<N)-1; f[0][0]=1;
	for (Re i=1; i<=N; ++i)
		for (Re j=1; j<=N; ++j)
			read(A[i][j]);
	for (Re i=1; i<=N; ++i)
		for (Re S=0; S<=lim; ++S) if (Count(S)==i)
			for (Re j=1; j<=N; ++j)
				if (S&(1<<(j-1))&&A[i][j])
					(f[i][S]+=f[i-1][S^(1<<(j-1))])%=mod;
	printf("%d\n",f[N][lim]);
	return 0;
}

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


def lucas(n):
    L0 = 2
    L1 = 1
    if n == 0:
        return L0
    if n == 1:
        return L1
    for _ in range(n-1):
        L0, L1 = L1, L0+L1
    return L1

print(lucas(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, pair<ll, ll> > p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<char> c(N);

    int cw = 0;
    int cr = 0;

    for(int i = 0; i < N; i++) {
        cin >> c[i];
        if(c[i] == 'W') {
            cw++;
        } else {
            cr++;
        }
    }

    vector<int> w(N);
    vector<int> r(N);

    int count = 0;

    for(int i = 0; i < N; i++) {
        if(c[i] == 'W') {
            count++;
        }
        w[i] = count;
    }

    count = 0;

    for(int i = N - 2; i >= 0; i--) {
        if(c[i + 1] == 'R') {
            count++;
        }
        r[i] = count;
    }

    int ans = min(cw, cr);

    for(int i = 0; i < N - 1; i++) {
        ans = min(ans, max(w[i], r[i]));
    }

    cout << ans << endl;
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int n;
  if (a+b>c){
    n = c+b;
  }else{
    if(a+b<c){
    	n = a+b+b+1;
    }else{
      n= a+b+b;
    }
  }
  
  cout << n << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int c=0,v=0;
    cin>>s;
    int l = s.size();
    for(int i=0;i<l;i++)
    {
       // cout<<s[i];
        if(s[i]=='R')
            c++;
        else
        {

            c=0;
        }
        v=max(v,c);
    }

        cout<<v<<endl;
    //cout<<l<<endl;
    return 0;
}


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

using namespace std;

int main()
{
    long long  n,a,b,max,min;
    cin>>n>>a>>b;
    max=a+(n-1)*b;
    min=(n-1)*a+b;
    cout<<(max<min?0:(max-min+1))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <stdlib.h>

using namespace std;

int main(){
	string strN;
	getline(cin, strN);
	int N = atoi(strN.c_str());

	string input;
	getline(cin, input);

	vector<int> A;

	istringstream iss(input);
	string strCard;
	while(getline(iss,strCard,' ')){
		A.push_back(atoi(strCard.c_str()));
	}

	for (int i = 1; i <= N; i++){
		for (int n = 0; n < N; n++){
			cout << A[n];
			if (n != N-1){
				cout << " ";
			}
		}

		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3168
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, k, q;
  readf("%s %s %s\n", &n, &k, &q);

  auto score = new int[](n);
  score[] = k - q;

  foreach (_; 0..q) {
    auto a = readln.chomp.to!int - 1;
    score[a]++;
  }

  foreach (i; 0..n) {
    if (score[i] > 0) {
      writeln("Yes");
    } else {
      writeln("No");
    }
  }
}


Measured memory_bytes: 2684
#085_C
n,y=map(int,input().split())
for a in range(0,n+1):
    mon=y-10000*a
    cnt=n-a
    
    if (mon-1000*cnt)%4000==0 and (5000*cnt-mon)%4000==0:
        b=(mon-1000*cnt)//4000
        c=(5000*cnt-mon)//4000
        
        if 0<=b<=n and 0<=c<=n:
            print(a,b,c)
            exit()

print(-1,-1,-1)

Measured memory_bytes: 3060
#include <cstdio>
typedef long long lld;
const int MAXN = 3e5+5;
int C[MAXN];
lld D[MAXN];
lld pre[MAXN];  // PSA of C ordered by D.
int F[MAXN];
int A, N;

void init() {
    for (int i = 0; i <= N; ++i) {
        C[i] = 0;
        D[i] = 0;
        pre[i] = 0;
    }
}

int main() {
    scanf("%d", &N);
    init();
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &A);
        ++C[A];
    }
    for (int i = 1; i <= N; ++i) {
        ++D[C[i]];
    }
    for (int i = 1; i <= N; ++i) {
        pre[i] = 1LL * i * D[i] + pre[i-1];
        D[i] += D[i-1];
    }
    F[0] = N;
    for (int i = 1; i <= N; ++i) {
        F[i] = (pre[i] + i * (D[N] - D[i])) / i;
    }
    int K = N;
    int t = 1;
    while (K >= 0) {
        while ((t <= N) && (F[K] >= t)) {
            printf("%d\n", K);
            ++t;
        }
        --K;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
const ll MOD = 998244353;
using ld = long double;
const ld EPS = 1e-9;
const ld PI = 3.141592653589793;
const int maxn = 1e6 + 1;
using pt = array<int, 2>;
int t[maxn];

int main() {
#ifdef zxc
//    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    freopen("green.in", "r", stdin);
    //    freopen("green.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
    int n;
    cin >> n;
    int l;
    cin >> l;
    for (int i = 1; i <= n; ++i) {
        cin >> t[i];
    }
    ld ans_x = 0;
    ld ans_y = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (j != i + 1) {
                ld ang = ((ld) (t[i]) + t[j]) * PI / l;
                ang += PI;
                ld x = cos(ang);
                ld y = sin(ang);
                ans_x += x * (j - i - 1);
                ans_y += y * (j - i - 1);
            }
            if (j != n || i != 1) {
                int cnt = i + n - j - 1;
                ld ang = ((ld) (t[i]) + t[j]) * PI / l;
                ld x = cos(ang);
                ld y = sin(ang);
                ans_x += x * cnt;
                ans_y += y * cnt;
            }
        }
    }
    ans_x /= n;
    ans_x /= n - 1;
    ans_x /= n - 2;
    ans_x *= 6;
    ans_y /= n;
    ans_y /= n - 1;
    ans_y /= n - 2;
    ans_y *= 6;
    cout << ans_x << " " << ans_y << endl;
}

Measured memory_bytes: 384
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
template<typename T> inline void in(T &e){cin>>e;}
template<typename T> inline void out(T e){cout<<e<<endl;}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

const int MAX_V=100010;

int Q,K;

struct edge{
    int to;
    int cost;
};

int V; //頂点数
vector<edge>G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
    priority_queue<pint,vector<pint>,greater<pint> > que;
    fill(d,d+V,INF);
    d[s]=0;

    que.push(pint(0,s));

    while(!que.empty()){
        pint p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pint(d[e.to],e.to));
            }
        }
    }
}

signed main(){
    io();
    in(V);
    int a,b,c;
    rep(i,V-1){
        scanf("%lld %lld %lld", &a,&b,&c);
        a--; b--;
        edge e={b,c};
        G[a].push_back(e);
        e.to=a;
        G[b].push_back(e);
    }
    scanf("%lld %lld", &Q,&K);
    K--;
    dijkstra(K);

    int x,y;
    rep(i,Q){
        scanf("%lld %lld", &x,&y);
        x--;y--;
        out(d[x]+d[y]);
    }

    return 0;
}


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

#define MAX_ 1000010

using namespace std;

int nml[MAX_];
int kisu[MAX_];

int main(int argc, char const *argv[])
{
	int n;
	vector<int> vn;
	vector<int> vk;

	for(int i1=0;i1<MAX_;i1++){
		nml[i1]=0;
		kisu[i1]=0;
	}

	for(int i=1;;i++){
		int p=(i*(i+1)*(i+2))/6;
		if(p>MAX_) break;

		vn.push_back(p);
		if(p%2==1) {
			vk.push_back(p);
		}
	}

	nml[0]=0;
	kisu[0]=0;
	for(int i1=1;i1<MAX_;i1++){
		int i2=0;
		int min = 10;
		while(i1-vn[i2]>=0 && i2<vn.size()){
			if(min>nml[i1-vn[i2]]){
				min=nml[i1-vn[i2]];
			}
			i2++;
		}
		nml[i1]=min+1;

		i2=0;
		min=2000000;
		while(i1-vk[i2]>=0 && i2<vk.size()){
			if(min>kisu[i1-vk[i2]]){
				min=kisu[i1-vk[i2]];
			}
			i2++;
		}
		kisu[i1]=min+1;
	}

	while(1){
		cin>>n;
		if(n==0) break;

		cout<<nml[n]<<" "<<kisu[n]<<endl;

	}
	return 0;
}

Measured memory_bytes: 9032
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include <numeric>

int main() {
	usize H, W, h, w;
	std::cin >> H >> W >> h >> w;
	std::cout << (H - h)*(W - w) << std::endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
w=list(map(int, input().split()))

m=abs(sum(w[0:1])-sum(w[1:n]))
for i in range(1,n):
    _m = abs(sum(w[0:i])-sum(w[i:n]))
    if m > _m:
        m = _m

print(m)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int n, m;
    cin >> n >> m;
    int k;
    cin >> k;
    bool ok = false;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int black = m * i + n * j - 2 * i * j;
            if (black == k) {
                ok = true;
                break;
            }
        }
    }
    if (ok)
        cout << "Yes"
             << "\n";
    else
        cout << "No"
             << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

const int Mod = 1e9 + 7, MaxN = 100005;

int n, a[MaxN], vis[MaxN];
long long fact[MaxN], rfact[MaxN];

long long quickPow(long long a, int b) {
    long long res = 1;
    for (; b; b >>= 1, a = a * a % Mod) 
        if (b & 1) res = res * a % Mod;
    return res;
}

long long C(int n, int m) {
    if (n < 0 || m < 0) return 0;
    if (n < m) return 0;
    return fact[n] * rfact[m] % Mod * rfact[n - m] % Mod;
}

int main() {
    scanf("%d", &n);
    fact[0] = rfact[0] = 1LL;
    for (int i = 1; i < MaxN; i++)
        fact[i] = fact[i - 1] * i % Mod;
    for (int i = 1; i < MaxN; i++)
        rfact[i] = quickPow(fact[i], Mod - 2);
    int p[2];
    for (int i = 1; i <= n + 1; i++) {
        scanf("%d", a + i);
        if (vis[a[i]]) p[0] = vis[a[i]], p[1] = i;
        vis[a[i]] = i;
    }
    int tot = p[0] + n - p[1];
    for (int i = 1; i <= n + 1; i++) {
        long long ans = C(n + 1, i), cur = C(tot, i - 1);
        ans = ((ans - cur) % Mod + Mod) % Mod;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3584
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

vector<bool> isp(300000, true);

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

    for (int i = 2; i < 300000; ++i) {
        if (!isp[i]) continue;
        if (i % 7 != 1 && i % 7 != 6) {isp[i] = false; continue;}
        for (int k = i * 2; k < 300000; k += i) isp[k] = false;
    }
    isp[0] = false;
    isp[1] = false;
    vector<int> p;
    REP(i, isp.size()) {
        if (isp[i]) p.push_back(i);
    }
    while(1) {
        int v;
        cin >> v;
        if (v == 1) break;
        cout << v << ":";
        for(auto pi : p) {
            if (v % pi == 0) cout << " " << pi;
        }
        cout << endl;
    }
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x;
  cin >> x;
  
  int ans = 0, now = 0;
  while (true) {
    now += x;
    ans++;
    if (now % 360 == 0) break;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 3560
import java.util.*;

class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		//5桁回文数→  1桁目=5桁目 かつ 2桁目=4桁目
		
		int count = 0 ;
		for(int i = A ; i <= B ;i ++){
			if( i/10000 == ( i % 10 ) && ( i /1000 ) % 10 == ( i /10 ) % 10 ){
				
				count ++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n), c(n);
    rep(i,n){
        int k;
        cin>>k;
        a.at(i)=k;
        c.at(i)=k;
    }
    
    sort(all(c));
    reverse(all(c));
    int first=c.at(0),second=c.at(1);
    
    rep(i,n){
        if(first==second) cout<<first<<endl;
        else if(a.at(i)==first) cout<<second<<endl;
        else cout<<first<<endl;
    }
   
    
}


Measured memory_bytes: 3200
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	var c [10][10]int
	for k := 1; k <= n; k++ {
		digit := calDigit(k)
		a := k%10
		b := k/int(math.Pow(float64(10), float64(digit)))
		c[a][b]++
	}
	count := 0
	for i := 0; i <= 9; i++ {
		for j := 0; j <= 9; j++ {
			count += c[i][j] * c[j][i]
		}
	}
	fmt.Println(count)
}

func calDigit(num int) int {
	i := 0
	for num >= 10 {
		num /= 10
		i++
	}
	return i
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}
	bool hh = false;
	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			for (int k = 0; k <= 100; k++) {
				int b11, b12, b13, b21, b22, b23, b31, b32, b33;
				b11 = c[0][0] - i;
				b12 = c[0][1] - i;
				b13 = c[0][2] - i;
				b21 = c[1][0] - j;
				b22 = c[1][1] - j;
				b23 = c[1][2] - j;
				b31 = c[2][0] - k;
				b32 = c[2][1] - k;
				b33 = c[2][2] - k;
				if (b11 == b21&&b11 == b31&&b12 == b22&&b12 == b32&&b13 == b23&&b13 == b33) {
					hh = true;
				}
			}
		}
	}
	if (hh) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
long k,n;
cin >> k >> n;
vector<long long> a(n);
for(int i=0;i<n;i++){
    cin >> a[i];}
long long ans=0;
for(int i=0;i<n-1;i++){
    ans=max(ans,a[i+1]-a[i]);
}
ans=max(ans,k-a[n-1]+a[0]);
cout << k-ans;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#include<algorithm>

using namespace std;
typedef long long ll;

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(n, 0);
    REP(i, n) cin>>  p[i];

    bool exit = true;

    FOR(i, 0, 200){
        REP(j, n){
            if (p[j] == x-i){
                exit = false;
                break;
            }
        }
        if (exit){
            cout << x-i << endl; 
            return 0;
        }
        
        exit = true;

        REP(k, n){
            if (p[k] == x+i){
                exit = false;
                break;
            }
        }
        if (exit){
            cout << x+i << endl; 
            return 0;
        }
        exit = true;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int X,N;
  cin >> X >> N;
  vi p(N);
  rep(i,N) cin >> p[i];
  sort(p.begin(),p.end());
  
  int ans=0;
  rep2(i,1,102) {
    if(!binary_search(p.begin(),p.end(),i)) {
      if(abs(X-ans)>abs(X-i)) ans=i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604