akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      h: usize,
      w: usize,
      n: usize,
      ab: [(usize, usize); n]
   }

   let mut map = BTreeMap::new();
   for &(a, b) in ab.iter() {
      for &da in [1, 0, !0].iter() {
         let a = a + da;
         if a <= 1 || a >= h {
            continue;
         }
         for &db in [1, 0, !0].iter() {
            let b = b + db;
            if b <= 1 || b >= w {
               continue;
            }
            map.entry((a, b)).and_modify(|v| *v += 1).or_insert(1);
         }
      }
   }
   let mut ans = vec![0; 10];
   ans[0] = (h-2) * (w-2) - map.len();
   for (_, &v) in map.iter() {
      ans[v] += 1;
   }
   for a in ans {
      println!("{}", a);
   }
}


Measured memory_bytes: 51640
#include <stdio.h>
int main(void){
	int n, m, lmax = 0, rmin = 10000000;
	scanf("%d %d", &n, &m);getchar();
	for(int i = 0; i < m; i++){
		int l, r;
		scanf("%d %d", &l, &r);getchar();
		if(l > lmax){
			lmax = l;
		}
		if(r < rmin){
			rmin = r;
		}
	}
  	if(rmin - lmax >= 0){
		printf("%d\n", rmin - lmax + 1);
    }else{
    	printf("%d\n", 0);
    }
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,e=0,c,b[1000000]={};
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>c;
    if(c>100000) e++;
    else b[c]++;
  }
  for(int i=1;i<=100000;i++){
    if(b[i]>i) e=e+b[i]-i;
    if(b[i]<i) e=e+b[i];
  }
  cout<<e<<"\n";
}
      


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

const int mod = 1000000007;
// const int mod = 998244353;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    mint ans = 10;
    ans = ans.pow(N);
    mint n9 = 9;
    n9 = n9.pow(N);
    mint n8 = 8;
    n8 = n8.pow(N);
    ans = ans - n9 * 2 + n8;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void tr_vc(vector<int> &tsx, vector<int> &tsy, string s, int n){
	rep(i, n){
		if(s[i] == 'L'){
			tsx.at(i) = -1;
			tsy.at(i) = 0;
		}else if(s[i] == 'R'){
			tsx.at(i) = 1;
			tsy.at(i) = 0;
		}else if(s[i] == 'U'){
			tsx.at(i) = 0;
			tsy.at(i) = -1;
		}else{
			tsx.at(i) = 0;
			tsy.at(i) = 1;
		}
	}
}

bool fc(vector<int> &s, vector<int> &t, int p, int li, int n){
	int li0 = 1, limx = li;
	rrep(i, n){
		// cerr << t.at(i) << " " << s.at(i) << " ";
		if(t.at(i) == -1){
			limx = min(li, limx+1);
		}else if(t.at(i) == 1){
			li0 = max(1, li0-1);
		}

		if(s.at(i) == -1){
			li0++;
		}else if(s.at(i) == 1){
			limx--;
		}
		if(limx < li0) return true;
		// cerr << li0 << " " << limx << " " << p << endl;
	}
	if(p < li0 || limx < p) return true;
	return false;
}

int main(){
	int h, w, n;
	cin >> h >> w >> n;
	int py, px;
	cin >> py >> px;
	string s, t;
	cin>> s >> t;
	vector<int> tsx(n), tsy(n), ttx(n), tty(n);
	tr_vc(tsx, tsy, s, n);
	tr_vc(ttx, tty, t, n);
	bool ans;
	ans = fc(tsx, ttx, px, w, n);
	// cerr << endl;
	ans = ans || fc(tsy, tty, py, h, n);
	if(ans) cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 4104
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std; 
struct interval
{
	int l, r; 
	inline bool operator <(const interval &a) const
	{
		if (l == a.l)
			return r > a.r; 
		return l < a.l; 
	}
} arr[200005]; 
int mn[400005], b[200005], pre[200005], n; 
void modify(int pos, int x)
{
	pos += n + 1; 
	for (mn[pos] = min(mn[pos], x); pos; pos >>= 1)
		mn[pos >> 1] = min(mn[pos], mn[pos ^ 1]); 
}
int query(int l, int r)
{
	r++; 
	int ans = 1e9; 
	for (l += n + 1, r += n + 1; l < r; l >>= 1, r >>= 1)
	{
		if (l & 1)
			ans = min(ans, mn[l++]); 
		if (r & 1)
			ans = min(ans, mn[--r]); 
	}
	return ans; 
}
int main()
{
	// freopen("ARC085-F.in", "r", stdin); 
	scanf("%d", &n); 
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", b + i); 
		pre[i] = pre[i - 1] + !b[i]; 
	}
	int q; 
	scanf("%d", &q); 
	for (int i = 0; i < q; i++)
		scanf("%d%d", &arr[i].l, &arr[i].r); 
	sort(arr, arr + q); 
	memset(mn, 0x3f, sizeof(mn)); 
	int idx = 0, ans = 0; 
	for (int i = 1; i <= n; i++)
	{
		while (idx < q && arr[idx].l == i)
		{
			int res = pre[arr[idx].r] + min(query(i, arr[idx].r), ans - pre[i - 1]); 
			modify(arr[idx].r, res - pre[arr[idx].r]); 
			idx++; 
		}
		ans = min(ans + b[i], query(i, i) + pre[i]); 
	}
	printf("%d\n", ans);
	return 0; 
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define MAX_N 2001
#define MOD   (1000000007)

static int64_t C[MAX_N][MAX_N];
void init(void) {
  C[0][0] = 1;
  for(int i = 0; i < (MAX_N-1); i++) {
    for(int j = 0; j <= i; j++) {
      C[i+1][j]   = (C[i+1][j] + C[i][j]) % MOD;
      C[i+1][j+1] = (C[i+1][j+1] + C[i][j]) % MOD;
    }
  }
}

int64_t comb(int n, int k) {
  //printf("n=%d, k=%d C[%d][%d]=%ld\n", n, k, n-1, k-1, C[n-1][k-1]);
  if(n < k) return 0;
  if(n == 0 && k == 0) return 1;
  if(k < 1) return 0;
  return C[n-1][k-1];
}

int main(void) {
  init();
  int N, K;
  scanf("%d%d", &N, &K);
  
  for(int i = 1; i <= K; i++) {
    // blue balls are divided by i red balls.
    int64_t blue = comb(K, i);
    int64_t red  = 0;
    {
      red += comb(N-K, i-1);
      red += comb(N-K, i);
      red += comb(N-K, i);
      red += comb(N-K, i+1);
    }
    red %= MOD;
    int64_t ans = (blue * red) % MOD;
    printf("%ld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 29952
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=2e5+7;
int a[N],b[N],n;
int main(){
	scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
	int p=n;
	for(int i=1,j=n;i<=j;i++,j--){
		b[i]=a[p--];
		if(i<j)b[j]=a[p--];
	}
	rep(i,1,n)printf("%d ",b[i]);
}

Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0242
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = RInt();
                if (n == 0) break;

                Dictionary<string, int> dic = new Dictionary<string, int>();
                for (int i = 0; i < n; i++)
                {
                    string[] vs = RArSt();
                    for (int j = 0; j < vs.Length; j++)
                    {
                        if (!dic.ContainsKey(vs[j])) dic.Add(vs[j], 0);
                        dic[vs[j]]++;
                    }
                }
                string target = RSt();
                var res = dic.Where(x => x.Key.Substring(0, 1) == target);
                Console.WriteLine(res.Count() == 0 ? "NA"
                                                    : WAr(res.OrderByDescending(x => x.Value)
                                                             .ThenBy(x => x.Key)
                                                             .Take(Math.Min(res.Count(), 5))
                                                             .Select(x=>x.Key)));
            }

        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

int main(){
  int N;
  long long count=0;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    count+=A.at(i)/2;
    int B=A.at(i)%2;
    if(B==1 && i!=N-1 && A.at(i+1)!=0){
      A.at(i+1)--;
      count++;
    }
  }
  cout << count << endl;
} 

Measured memory_bytes: 3732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int treats[] = new int[N];
		for(int k = 0 ; k < K ; ++k){
			int d = sc.nextInt();
			for(int i = 0 ; i < d ; ++i){
				int a = sc.nextInt();
				treats[a - 1]++;
			}
		}
		int ret = 0;
		for(int t : treats){
			if(t == 0){
				++ret;
			}
		}
		System.out.println(ret);
	}
}


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

int main() {
	long long int n,k,sum=0;
	cin>>n>>k;
	long long int arr[n];
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
sort(arr,arr+n);
for(int i=0;i<=n-1-k;i++)
{
    sum=sum+arr[i];
}
cout<<sum;

	return 0;
}

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

int main(void){
   ll n,k;cin>>n>>k;
   ll res=0;
   for(ll x=k;x<=n+1;x++){
       //最小値は0~x-1までの和
       ll mini=x*(x-1)/2;
       //最大値はn~n-x+1までの和
       ll maxi=(2*n-x+1)*x/2;
       ll buf=maxi-mini+1;
       res+=buf;
       res%=mod;
       //cout<<buf<<endl;
   }
   cout<<res<<endl;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int recur(int n)
{
	if (n <= 1)
		return 0;
	else if (n <= 3)
		return 1;
	else
		return recur(n / 3 + (n % 3 != 0)) + 1;
}
int main()
{
	int n;
	cin >> n;
	printf("%d\n", recur(n));
}

Measured memory_bytes: 0
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)
var sc *bufio.Scanner
func nextStr() string {
    sc.Scan()
    return sc.Text()
}
func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}
const MOD = 998244353
func powInt(x, y int) int {
    ret := 1
    for i := 0; i < y; i++ {
        ret *= x
        ret %= MOD
    }
    return ret
}
func main() {
    sc = bufio.NewScanner(os.Stdin)
    sc.Buffer(make([]byte, 0), 1000000001*3)
    sc.Split(bufio.ScanWords)
    n := nextInt()
    depth := make([]int, n)
    d := nextInt()
    if d != 0 {
        fmt.Println(0)
        return
    }
    depth[d]++
    for i := 1; i < n; i++ {
        d := nextInt()
        depth[d]++
    }
    if depth[0] > 1 {
        fmt.Println(0)
        return
    }
    ans := 1
    dPrev := 1
    for _, d := range depth {
        switch {
        case d == 0:
            dPrev = 0
            continue
        case dPrev == 0:
            fmt.Println(0)
            return
        default:
            ans *= powInt(dPrev, d)
            ans %= MOD
            dPrev = d
        }
    }
    fmt.Println(ans)
}

Measured memory_bytes: 1920
#include <stdio.h>
#define N 100
static const int  INFTY = (1<<21);
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,m[N][N];
void dijkstra(void);
int main()
{
  int i,j,a,b,c,d;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  m[i][j]=INFTY;
	}
    }
     
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d%d",&c,&d);
      m[a][c] =d;
    }
  }
  dijkstra();
  return 0;
}

void dijkstra(){
  int min,i,j,u;
  int d[N],color[N];

  for(i=0;i<n;i++)
    {
      d[i]=INFTY;
      color[i] =WHITE;
    }
  d[0] =0;
  color[i] =GRAY;
  while (1)
    {

      min =INFTY;
      u=-1;
      for(i=0;i<n;i++)
	{
	  if(min> d[i] && color[i]!=BLACK )
	    {
	      u=i;
	      min =d[i];

	    }
	}
      if(u==-1) break;
      color[u] =BLACK;

      for(j=0;j<n;j++)
	{
	  if(color[j]!=BLACK && m[u][j] !=INFTY)
	    {
	      if(d[j] >d[u] +m[u][j])
		{
		  d[j] =d[u]+m[u][j];
		  color[j] =GRAY;
		}
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      printf("%d ",i);
      if(d[i]==INFTY) printf("-1");
      else printf("%d",d[i]);
      printf("\n");
    }
}



Measured memory_bytes: 1996
def solve():
    N = int(input())
    C = list(input())

    right = N-1
    left = 0

    cnt = 0
    while left < right:
        while left < N and C[left] == 'R':
            left += 1

        while right >= 0 and C[right] == 'W':
            right -= 1
        
        if left >= right:
            break
        
        C[left], C[right] = C[right], C[left]
        cnt += 1
    
    print(min(cnt,C.count("R"), C.count("W")))
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 77696
import java.util.*;
public class Main{
    public  static void main(String[] args){
    new Main().run();
    }
    Scanner kbd = new Scanner(System.in);
    int n, p;
 
    void run(){
    boolean[] prime = new boolean[1000000];
    setP(prime);
 
    while(kbd.hasNext()){
        n = kbd.nextInt();
        p = kbd.nextInt();
        if(n!=-1 && p!=-1){
        solve(prime);
        }
    }
    }
 
    void solve(boolean[] prime){
    int[] sum = new int[100000];
    Arrays.fill(sum, Integer.MAX_VALUE);
    setSum(sum, prime); 
    Arrays.sort(sum);
    /*
    int i=0;
    while(i<(a+p-1)){
        System.out.println(i+" "+sum[i]);
        i++;
    }
    */
    System.out.println(sum[p-1]);
    }
 
    void setP(boolean[] prime){
    int i, j, k=0;
    Arrays.fill(prime, true);
    prime[0] = false;
    prime[1] = false;
    for(i=2; i<prime.length; i++){
        for(j=i+i; j<prime.length; j+=i){
        if(prime[i]) prime[j] = false;
        }
    }
    }
 
    void setSum(int[]sum, boolean[] prime){
    int i=0, j=0, a=0, b;
    for(a=n+1; a<n+300 && i<sum.length; a++){
        b = a;
        for(; b<n+300 && i<sum.length; b++){
        if(prime[a] && prime[b]){
            sum[i] = a+b;
            //System.out.println("* "+pp[a]+" "+pp[b]+" "+sum[i]);
            i++;
        }
        }
    }
    }
}

Measured memory_bytes: 156964
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int a;
    cin >> a;
    printf("%d:%d:%d\n",a/3600,a%3600/60,a%3600%60);
}


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

int main() {
    int n;
    int a[101];
    cin >> n;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n,greater<int>());
    int alice = 0;
    int bob = 0;
    for(int i=0;i<n;i++){
        if(i%2==0)alice += a[i];
        else bob += a[i];
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





int N, M;
int WA[105000];
bool AC[105000];
 
void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for(int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int A[3] = {0};

int solve() {
  sort(A, A + 3);
  return abs(A[2] - A[0]);
}

int main() {
  for(int i = 0; i < 3; i++) cin >> A[i];
  printf("%d\n", solve());
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a%3==0)
    {
        cout<<"Possible"<<endl;
    }
    else
    if(b%3==0)
    {
        cout<<"Possible"<<endl;
    }
    else
    if((a+b)%3==0){
        cout<<"Possible"<<endl;
    }
    else
    {
        cout<<"Impossible"<<endl;
    }
}

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

int n, k, a[200000];

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = k; i < n; i++) {
        if (a[i] > a[i - k]) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;

int main()
{
  int a,b;
  cin >> a >> b;
  if(a <= 9 && b <= 9){
    cout << a *b << endl;
  }
  else {
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,y=LI()

  for i in range(n+1):
    for j in range(n-i+1):

      sm=i*10000+j*5000+(n-i-j)*1000

      if sm>y:
        break

      if sm==y:
        return str(i)+' '+str(j)+' '+str(n-i-j)

  return '-1 -1 -1'

print(main())


Measured memory_bytes: 5412
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
using namespace std;
//_____
#define pb emplace_back
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define err(...) fprintf(stderr, __VA_ARGS__)
#define show(x) cerr << #x << ':' << (x) << endl
#define outl(x) cout << (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
#define let const auto
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int y, int x, int H, int W){return(y>=0 && x>=0 && y<H && x<W);}
const int dx[] = {1, 0, -1, 0,  1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1,  -1, 1, 1, -1};
#define INF  0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3fLL
#define NIL -1
//_______
typedef pair<int,int> pii;
typedef pair<ll, int> pli;

int N, M;
vector <pii> G[100010];
ll mcos[100010];

void dijkstra(let s)
{
   priority_queue < pli, vector<pli>, greater<pli> >pq;
   pq.emplace( pii(0,s) );
   memset( mcos, 0x3f, sizeof(mcos) );
   mcos[s] = 0;

   while (!pq.empty()) {
      let tmp = pq.top(); pq.pop();
      if(mcos[tmp.se] < tmp.fi)continue;
      for( let &x: G[tmp.se] ) {
         let nc = x.fi + tmp.fi;
         let nxt = x.se;
         if( chmin(mcos[nxt], nc) ) pq.emplace( pii(nc,nxt) );
      }
   }
   return ;
}

signed main()
{
   FAST();
   int r;
   cin >> N >> M >> r;
   while (M--) {
      int s, t, c;
      cin >> s >> t >> c;
      G[s].pb( pii(c,t) );
   }
   dijkstra(r);

   rep(i, N) {
      if (mcos[i] == LINF) outl("INF");
      else outl(mcos[i]);
   }
}




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


int main(){
  int ans;
  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0) ans = i+1;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3588
#include <iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int quick_pow(int a,int b)
{
    int r=1,base=a;
    while(b)
    {
        if(b&1)
        r*=base;
        base*=base;
        b>>=1;
    }
    return r;
}
int main()
{
    ll x,y;
    scanf("%lld%lld",&x,&y);
    ll len=0;
    while(x<=y)
    {
        len++;
        x*=2;
    }
    cout<<len<<endl;
    return 0;
}


Measured memory_bytes: 256
// glory be to the sky
#include<bits/stdc++.h> 


using namespace std;
	
typedef long long ll;  

int sz1[200005], sz2[200005], idx[200005], idx2[200005], cnt[200005], curr = 0, curr2 = 0;
bool vis[200005], vis2[200005];
vector<int> X[200005], Y[200005];
vector<int> adj[200005], adj2[200005];
void dfs2(int c) {
	if (vis2[c]) return;
	++sz2[curr2];
	X[curr2].push_back(c);
	vis2[c] = true;
	idx2[c] = curr2;
	for (auto &x: adj2[c]) dfs2(x);
}
void dfs(int c) {
	if (vis[c]) return;
	++sz1[curr];
	Y[curr].push_back(c);
	vis[c] = true;
	idx[c] = curr;
	for (auto &x: adj[c]) dfs(x);
}
map<pair<int, int> , int> gt;
map<int, int> MM; 
int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, K, L;

	cin >> N >> K >> L;  
	int n = N;
	int a, b;
	for (int i = 0; i < K; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 0; i < L; i++) {
		cin >> a >> b;
		adj2[a].push_back(b);
		adj2[b].push_back(a);
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) { 
			dfs(i);
			curr++;
		}
		if (!vis2[i]) {
			dfs2(i);
			curr2++;
		}
	} 
	for (int i = 1; i <= n; i++) {
		gt[make_pair(idx[i], idx2[i])]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << gt[make_pair(idx[i], idx2[i])] << " ";
	}
	return 0;	
}

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

s = n*(n+1) / 2

f = n // 3
b = n // 5
fb = n // 15

a = int(s - 3 *f*(f+1)//2 - 5 *b*(b+1)//2 + 15 *fb*(fb+1)//2)
print(a)

Measured memory_bytes: 9176
#include <iostream>
using namespace std;
int main(){
	int n,k,p;
	cin>>n;
	for(int i=0 ; i<n ; i++ ){
		cin>>k>>p;
		int x=k%p;
		if(x==0)
			cout<<p<<endl;
		else
			cout<<x<<endl;
	}
}

Measured memory_bytes: 3040
import collections
import sys
input = sys.stdin.readline

N = int(input())
# o(10**5 * 10**2 = 10**7)
list =  [''.join(sorted(list(input().strip("\n")))) for i in range(N)]
# o(10**5 * log(10**5) = 10**7)
list.sort()

c = collections.Counter(list)
c = c.most_common()
ans = 0
for i,v in c:
    ans += v*(v-1)//2

print(ans)

Measured memory_bytes: 69592
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=200010;
int n,k;
int a[maxn];
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=k+1;i<=n;i++){
		if(a[i-k]<a[i])cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}


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


template<class T> bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}

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

    vector<long long> h(N+2);
    vector<long long> dp(N+2, LLONG_MAX);

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

    dp[0] = 0;

    for(int i=0;i<N-1;i++){
        chmin(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        chmin(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }

    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1792
import heapq

N = int(input())
As  = [int(x) for x in input().rstrip().split()]

#N~2N要素まで、左に関して最大のN個、右に関して最小のN個をとってきたときの和を求める
#これはヒープで実装すれば簡単

left_sum_list = [0 for i in range(N+1)]
right_sum_list = [0 for i in range(N+1)]

left_heap = As[:N]
right_heap = As[2*N:]
right_heap = [-1*x for x in right_heap]

heapq.heapify(left_heap)
heapq.heapify(right_heap)

left_sum_list[0] =sum(left_heap)
right_sum_list[N] =-1*sum(right_heap)


for i in range(0,N):
    temp1 = heapq.heappushpop(left_heap, As[N+i])
    left_sum_list[i+1] = left_sum_list[i]+As[N+i]-temp1

    temp2 = heapq.heappushpop(right_heap, -1*As[2*N-i-1])
    right_sum_list[N-i-1] = right_sum_list[N-i]+(As[2*N-i-1])-(-1*temp2)

max_val = -10**23

for i in range(N+1):
    new_val = left_sum_list[i]-right_sum_list[i]
    if new_val>max_val:
        max_val = new_val

print(max_val)







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


int main(){
	string s;
	cin>>s;
	int a[501010]={};
	ll c=0,r=0,z=0;
	bool f=1;
	rep(i,s.size()){
		if(f){
			if(s[i]=='<'){
				//cout<<i<<endl;
				a[i]=0;
				repr(j,i){
					if(j>0)
					if(s[j-1]=='<'){
						if(a[j]<i-j)a[j]=i-j;
						break;}
					a[j]=i-j;
				}
				f=0;
				r=1;
				a[i+1]=r;
			}else{

			}
		}else{
			r++;
			a[i+1]=r;
			if(s[i]=='>'){
				f=1;
			}else{
				
			}
		}
	}
	if(f){
				repr(j,s.size()+1){
					if(j>0)
					if(s[j-1]=='<'){
						if(a[j]<s.size()-j)a[j]=s.size()-j;
						break;};
					a[j]=s.size()-j;
					//cout<<j+1<<s.size()-j<<endl;
				}
				f=0;
			
		}
	rep(i,s.size()+1){
		//cout<<i<<","<<a[i]<<endl;;
		c+=a[i];
	}
	cout<<c<<endl;
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll MOD = (ll)1e9 + 7;

ll f(ll n) {
	ld a = (sqrtl(24*n+1)-1)/6;
	return ll(a);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout.precision(20);
    cout << fixed;

	ll n,k;
	cin>>n>>k;
	vll A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	vll mxH(n);
	while(k--){
		ll x,y;		cin>>x>>y; x--,y--;
		mxH[x]=max(mxH[x],A[y]);
		mxH[y]=max(mxH[y],A[x]);	
	}
	ll ans=0;
	for(int i=0;i<n;i++)
		ans+=(A[i]>mxH[i]);
	cout<<ans<<"\n";
}


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

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

#define INF 1000000000

using namespace std;

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    double Hx = A * sin(2.0 * M_PI * (H + M/60.0) / 12.0);
    double Hy = A * cos(2.0 * M_PI * (H + M/60.0) / 12.0);

    double Mx = B * sin(2.0 * M_PI * M / 60.0);
    double My = B * cos(2.0 * M_PI * M / 60.0);

    double dist = sqrt((Hx - Mx) * (Hx - Mx) + (Hy - My) * (Hy - My));

    printf("%.10f\n", dist);

    return 0;
}


Measured memory_bytes: 4028
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 2000;
const int INF = (1<<30);
struct edge{
	int to; edge *nxt;
}edges[2*MAXN + 5], *adj[MAXN + 5], *ecnt=&edges[0];
void addedge(int u, int v) {
	edge *p = (++ecnt);
	p->to = v, p->nxt = adj[u], adj[u] = p;
	p = (++ecnt);
	p->to = u, p->nxt = adj[v], adj[v] = p;
}
int a[MAXN + 5], N;
int f[MAXN + 5], s[MAXN + 5];
void dfs(int x, int fa) {
	s[x] = a[x], f[x] = 0;
	for(edge *p=adj[x];p;p=p->nxt) {
		if( p->to == fa ) continue;
		dfs(p->to, x), s[x] += s[p->to];
		f[x] += f[p->to] + s[p->to];
	}
}
int get(int x, int fa) {
	int mx = 0;
	for(edge *p=adj[x];p;p=p->nxt) {
		if( p->to == fa ) continue;
		if( mx == 0 || f[p->to] > f[mx] ) mx = p->to;
	}
	if( mx == 0 ) return 0;
	int k = get(mx, x) + s[mx];
	if( f[x] - f[mx] - s[mx] >= k ) return f[x] & 1;
	else return k - (f[x] - f[mx] - s[mx]);
}
char S[MAXN + 5];
int main() {
	scanf("%d%s", &N, S + 1);
	for(int i=1;i<=N;i++) a[i] = S[i] - '0';
	for(int i=1;i<N;i++) {
		int u, v; scanf("%d%d", &u, &v);
		addedge(u, v);
	}
	int ans = INF;
	for(int j=1;j<=N;j++) {
		dfs(j, 0);
		if( get(j, 0) == 0 )
			ans = min(ans, f[j]/2);
	}
	if( ans == INF ) printf("-1\n");
	else printf("%d\n", ans);
}
//

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n;
  cin >> n;
  for (int a = 1; a <= 3500; ++a) {
    for (int b = 1; b <= 3500; ++b) {
      if (4*a*b-n*(a+b) > 0) {
        if (n*a*b % (4*a*b-n*(a+b)) == 0) {
          cout << a << " " << b << " " << n*a*b / (4*a*b-n*(a+b)) << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max(a+b-n,0);
  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

n=int(input())
a,b,c=map(int,input().split())
for _ in range(n-1):
    a1, b1, c1 = map(int, input().split())
    a,b,c=a1+max(b,c),b1+max(a,c),c1+max(a,b)
print(max(a,b,c))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int Q,H,S,D,N;
  cin>>Q>>H>>S>>D>>N;
  int q,h,s,d;
  q=Q*8;
  h=H*4;
  s=S*2;
  d=D;
  vector<int>a(4);
  a[0]=q;
  a[1]=h;
  a[2]=s;
  a[3]=d;
  sort(a.begin(),a.end());
  pair<int,char> num[4];
  for(int i=0;i<4;i++){
    if(a[i]==q)
      num[i]=make_pair(q/2,'q');
    else if(a[i]==h)
      num[i]=make_pair(h/2,'h');
    else if(a[i]==s)
      num[i]=make_pair(s/2,'s');
    else if(a[i]==d)
      num[i]=make_pair(d,'d');
  }
  //  for(int i=0;i<4;i++)
  //cout<<(long long)num[i].first*N<<endl;
  long long ans=0;
  for(int i=0;i<4;i++){
    if(num[i].second!='d'){
      ans+=(long long)num[i].first*N;
      N=0;
    }else{
      ans+=(long long)D*(N/2);
      N=N%2;
    }
    if(N==0)
      break;
  }
  cout<<(long long)ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,K;
char buf[105];
ll dp[105][2][4];

int main(){

	scanf("%s",buf);
	scanf("%d",&K);

	for(N = 0; buf[N] != '\0'; N++);

	for(int i = 0; i <= N; i++){
		for(int k = 0; k < 2; k++){
			for(int a = 0; a <= K; a++){
				dp[i][k][a] = 0;
			}
		}
	}

	//dp[桁][先頭からNと一致しているか][非0の数] = 場合の数

	dp[0][true][1] = 1; //先頭は非0
	dp[0][false][1] = (buf[0]-'0')-1;
	dp[0][false][0] = 1;

	for(int i = 1; i < N; i++){

		//true→true
		for(int k = 1; k <= K; k++){

			if(buf[i] != '0'){

				dp[i][true][k] += dp[i-1][true][k-1];
			}else{ //buf[i] == '0'

				dp[i][true][k] += dp[i-1][true][k];
			}
			//printf("dp[true][%d]:%lld\n",k,dp[i][true][k]);
		}
		//true→false
		for(int k = 1; k <= K; k++){

			if(buf[i] == '0'){

				//true→falseへは移れない

			}else{ //buf[i] > '0'

				dp[i][false][k] += dp[i-1][true][k]; //この桁を0にする
				dp[i][false][k] += dp[i-1][true][k-1]*(ll)((buf[i]-'0')-1); //この桁を1～(buf[i]-'0'-1)にする
			}
			//printf("dp[false][%d]:%lld\n",k,dp[i][false][k]);
		}

		//false→false
		for(int k = 0; k <= K; k++){

			//この桁を0にする
			dp[i][false][k] += dp[i-1][false][k];
			if(k == 0)continue;
			//この桁を1～9にする
			dp[i][false][k] += dp[i-1][false][k-1]*9;
			//printf("dp[false][%d]:%lld\n",k,dp[i][false][k]);
		}
	}

	printf("%lld",dp[N-1][true][K]+dp[N-1][false][K]);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	bool turn = false;
	while(a > 0 && c > 0){
		if(!turn) c -= b;
		else a -= d;
		turn = !turn;
	}
	isYes(a > 0);
}


Measured memory_bytes: 3632
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from heapq import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(n):
	ans = 0
	for i in range(1,n+1):
		if(i%3 == 0 == i%5):
			# print(i)
			x = 1
		elif(i%3 == 0):
			# print(i)
			z = 1
		elif(i%5 == 0):
			# print(i)
			z = 1
		else:
			ans += i
	return ans
	

N = int(stdin.readline())
ans = solve(N)
print(ans)


Measured memory_bytes: 77724
#include <stdio.h>

int main(){
	unsigned int i,h;
	int n;
	unsigned int a[100002];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%u",a+i);
	}
	h=a[0];
	for(i=1;i<n;i++){
		h^=a[i];
	}
	if(h==0x0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

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

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

int main() {
  int a,b,k;
  cin >> k >> a >> b;
  if(a%k == 0) cout << "OK" << endl;
  else if((a/k+1)*k <= b) cout << "OK" << endl;
  else if(a == b && a%k == 0) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int n=s.size()-1;
  if(s[n]=='s'){
    cout<<s<<"es"<<endl;
  }else{
    cout<<s<<"s"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		// input
		int num = scan.nextInt();
		int otoshidama = scan.nextInt();
		
		// search
		boolean flag = false;
		loop: for(int i = 0; i <= num; i++){
			for(int j = 0; j <= num - i; j++){
				if(10000 * i + 5000 * j + 1000 * (num - i - j) == otoshidama){
					System.out.println(i + " " + j + " " + (num - i - j));
					flag = true;
					break loop;
				}
			}
		}
		
		// answer
		if(!flag){
			System.out.println("-1 -1 -1");
		}
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var p = Input();
		
		var k = p[0].ToLong();
		var n = p[1].ToInt();
		var a = Input().ToInt();
		
		long max = DpInf;
		for(int i = 0; i < n; i++)
		{
			var r = a[(i+1)%n];
			var l = a[(i+n-1)%n];
			
			long d = 0;
			if(r < a[i])	//今よりも次が小さい
			{
				d = k - (r+k-a[i]);
			}
			else
			{
				d = k - (r - a[i]);
			}
			long d1 = 0;
			
			if(l < a[i])
			{
				d1 =k - (a[i]-l);
				
				
			}
			else
			{
				d1 = k - (a[i] + k - l);
			
			}
			max = Math.Min(max, Math.Min(d, d1));
		}
		
		Console.WriteLine(max);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 34652
import           Control.Monad
import           Data.Array
import qualified Data.ByteString.Char8         as BS
import           Data.List
import           Data.Maybe
import           Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main :: IO ()
main = do
  (a : p : _) <- readInts
  print $ solve a p

solve :: Integral a => a -> a -> a
solve a p = (a * 3 + p) `div` 2


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

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

    int dp[N];
    memset(dp, 100000, sizeof(dp));
    int a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        //cout << a[i] << "\n";
    }
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i-1] + abs(a[i] - a[i - 1]), dp[i-2] + abs(a[i] - a[i - 2]));
    }
    /* cout << "\n";
    for (int i = 0; i < N; i++)
    {
        cout << dp[i] << "\n";
    } */
    cout << dp[N - 1];
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], W = l[1];

            var weight = new long[N];
            var cost = new long[N];

            for (var i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                weight[i] = tmp[0];
                cost[i] = tmp[1];
            }

            var sol = new Solve(N, W, weight, cost);
            Console.WriteLine(sol.Execute());
        }
    }

    class Solve
    {
        public int N { get; set; }
        public int W { get; set; }
        public long[] weight { get; set; }
        public long[] cost { get; set; }
        public long[,] dp { get; set; }
        public int max { get; set; }

        public Solve(int N, int W, long[] weight, long[] cost)
        {
            this.N = N;
            this.W = W;
            this.weight = weight;
            this.cost = cost;
            max = 100010;
            dp = new long[N + 10, max];
            for (var i = 0; i < N + 10; i++)
                for (var j = 0; j < 100010; j++)
                    dp[i, j] = int.MaxValue;
            dp[0, 0] = 0;
        }

        public long Execute()
        {
            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < max; j++)
                {
                    if (j - cost[i] >= 0)
                        dp[i + 1, j] = Math.Min(dp[i, j - cost[i]] + weight[i], dp[i+1, j]);
                    dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i, j]);
                }
            }

            var ret = 0L;
            for (var i = 0; i < max; i++)
            {
                if (dp[N, i] <= W) ret = i;
            }
            return ret;
        }
    }
}


Measured memory_bytes: 98272
#include <iostream>
using namespace std;
int main() {
	int N, Y;
	int A, B, C;
	int i, j, k;
	int flg = 0;

	cin >> N >> Y;

	for (i = 0;i <= N && flg == 0;i++) {
		for (j = 0;j <= N && flg == 0;j++) {
			k = N - i - j;
			if (k>=0&&(i * 10000 + j * 5000 + k * 1000 == Y)) {
				A = i;
				B = j;
				C = k;
				flg = 1;
			}
		}
	}
	if (flg == 1) {
		cout << A << " " << B << " " << C << endl;
	}
	else {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}
}

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

typedef long long ll;
ll t,n,i,j,a,b;
string s1;
int main() {
   cin>>s1;
   ll s=0;
   for(i=0;i<s1.length();i++)
   {   
       string x="";
       x+=s1[i];
       s+=stoi(x);
   }
   if(s%9)
   cout<<"No";
   else
   cout<<"Yes";
	
	return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lli long long
#define REP(i,a,b) for (int i = a; i < b; i++)
#define test int t; cin>>t; while(t--)
using namespace std;

int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   // test
    {
        string s;
        cin>>s;
        lli sum=0;
        for(auto x:s)
        sum+=(x-'0');
     //   cout<<sum;
        if(sum%9)
        cout<<"No";
        else
        cout<<"Yes";
    }
    return 0;
}

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

using namespace std;

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

	string s;
	cin >> s;

	int res = 0;

	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') res++;
	}

	cout << res;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def gcd(m, n):
    while n:
        m, n = n, m % n
    return m

def solve():
    MOD = 10**9 + 7

    N, Q = map(int, readline().split())
    *P, = map(int, readline().split())
    S = [0]*N
    K = [0]*N
    used = [0]*N
    for i in range(N):
        if used[i]:
            continue
        vs = [i]
        s = i+1
        used[i] = 1
        v = P[i]-1
        while v != i:
            vs.append(v)
            s += v+1
            used[v] = 1
            v = P[v]-1
        l = len(vs)
        for v in vs:
            S[v] = s
            K[v] = l % MOD
    N0 = 2**(N-1).bit_length()
    S0 = [0]*(2*N0)
    K0 = [1]*(2*N0)
    for i in range(N):
        S0[N0-1+i] = S[i]
        K0[N0-1+i] = K[i]
    def calc(k0, k1, s0, s1):
        g = gcd(k0, k1)
        return k0 // g * k1, ((s0*k1 + s1*k0) // g) % MOD

    for i in range(N0-2, -1, -1):
        K0[i], S0[i] = calc(K0[2*i+1], K0[2*i+2], S0[2*i+1], S0[2*i+2])

    def query(l, r):
        L = l + N0; R = r + N0
        k = 1
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                k, s = calc(k, K0[R-1], s, S0[R-1])

            if L & 1:
                k, s = calc(k, K0[L-1], s, S0[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

    for i in range(Q):
        l, r = map(int, readline().split())
        write("%d\n" % query(l-1, r))
solve()


Measured memory_bytes: 22660
O=list(map(int, input().split()))
N = O[0]
M = O[1]

H=list(map(int, input().split()))

L=[]
E=[]
for i in range(N):
    L.append(1)
    E.append(1)

for i in range(M):
    AB=list(map(int, input().split()))
    E[AB[0]-1]=0
    E[AB[1]-1]=0
    if H[AB[0]-1]>H[AB[1]-1]:
        L[AB[1]-1]=0
    elif H[AB[0]-1]<H[AB[1]-1]:
        L[AB[0]-1]=0
    else:
       L[AB[0]-1]=0
       L[AB[1]-1]=0
  
sumx=0
for i in range(N):
    sumx+=L[i]

print(sumx)

Measured memory_bytes: 20164
import sys

n, = [int(x) for x in input().strip().split(" ")]
n = int(n)

As = []
for line in sys.stdin:
    a, = line.strip().split(" ")
    As.append(int(a))
#print(As)

if As[0] != 0:
    print(-1)
    sys.exit()

result = 0
for i in range(n):
    k = n-1-i
    As[k]
    if As[k] > k:
        print(-1)
        sys.exit()
    if k == n-1:
        result += As[k]
    else:
        if As[k] > As[k+1]:
            result += As[k]
        if As[k] == As[k+1]:
            result += As[k]
        if As[k] + 1 < As[k+1]:
            print(-1)
            sys.exit()
#    print(result)
print(result)


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

using namespace std;


int main()
{
	int A;
	cin >> A;
	int f, b;
	f = A / 100; b = A % 100;
	if (f <= 12 && f >= 1) {
		if (b < 1 || b>12)
			cout << "MMYY" << endl;
		else
			cout << "AMBIGUOUS" << endl;
	}
	else if (b <= 12 && b >= 1) {
		if (f < 1 || f>12)
			cout << "YYMM" << endl;
		else
			cout << "AMBIGUOUS" << endl;
	}
	else
		cout << "NA" << endl;
	return 0;
}


Measured memory_bytes: 256