akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
map<pair<int, int>, int> gmemo;
int gcd(int a, int b) {
	if (gmemo[{a, b}] != 0) return gmemo[{a, b}];
	if (gmemo[{b, a}] != 0) return gmemo[{b, a}];
	if (a % b == 0)
		return gmemo[{a, b}] = b;
	else
		return gmemo[{a, b}] = gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
bool prime(int a) {
	if (a == 1) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
signed main() {
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(void)
{
  int N,x=0,max=0,i;
  char S[101];
  scanf("%d",&N);
  scanf("%s",S);

  for(i=0;i<N;i++){
    if(S[i]=='I'){
      x++;
      if(max<x){
	max=x;
      }
    } else if(S[i]=='D'){
      x--;
    }
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<math.h>
#include<vector>
#include <queue>
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
using namespace std;
typedef vector<vector<char>> field_t;

typedef pair<int, int> point_t;



int main()
{
    int N;
    cin >> N; 
	cout<<2*N*M_PI<<endl;
    
}

Measured memory_bytes: 3784
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

string slice_vec(string s, int start, int end = 0)
{
    if (end == 0)
        end = s.size();
    string res = "";
    for (int i = start; i < end; i++)
    {
        if (start > end)
        {
            return "error";
        }
        res.push_back(s[i]);
    }
    return res;
}

int main()
{
    string S;
    cin >> S;
    int index = 0;
    while (index < S.size())
    {
        if (slice_vec(S, index, index + 7) == "dreamer" && S[index + 7] != 'a')
        {
            index += 7;
        }
        else if (slice_vec(S, index, index + 5) == "dream")
        {
            index += 5;
        }
        else if (slice_vec(S, index, index + 6) == "eraser")
        {
            index += 6;
        }
        else if (slice_vec(S, index, index + 5) == "erase")
        {
            index += 5;
        }
        else
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

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

         var a = Console.ReadLine().Split(' ').ToList().Select( x => double.Parse(x) );

         var result = 1 / a.Sum( x => 1 / x );

         Console.WriteLine(result);
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n,i;cin >>n>>i;
   cout <<n-i+1<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  int ans = 999999999;
  for(int i=0; i<n-k+1; i++){
    ans = min(h.at(i+k-1)-h.at(i),ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
var i,t,n:byte;
    a:string;
begin
        readln(n);
        read(a);
        if n mod 2<>0 then begin write('No');
        Exit;
        end
        else
        for i:=1 to n div 2 do
        if a[i]=a[i+(n div 2)] then inc(t);
        if t=n div 2  then write('Yes') else write('No');
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 1e5+1;
int n, m, p[N], c[N], d[N];
pii y[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, m){
    cin >> p[i];
    int _y;
    cin >> _y;
    y[i] = mp(_y, i);
  }
  sort(y, y+m);
  FOR(i, 0, m) c[y[i].se] = ++d[p[y[i].se]];
  FOR(i, 0, m) printf("%06d%06d\n", p[i], c[i]);
  return 0;
}

Measured memory_bytes: 3456
n = int(input())
def CountingSort(A, B, k):
    C = [0] * (k + 1)
    for j in range(n):
        C[A[j]] += 1
    C[0] -= 1
    for i in range(1, k + 1):
        C[i] += C[i - 1]
    for j in range(n - 1, -1, -1):
        B[C[A[j]]] = A[j]
        C[A[j]] -= 1
A = list(map(int, input().split()))
B = [0] * n
CountingSort(A, B, max(A))
print(*B)



Measured memory_bytes: 224376
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

template<class T> struct factorizaion {
    using NP = pair<T,int>;
    T n;
    explicit factorizaion(T n):n(n) {
        assert(n > 0);
    }
    vector<NP> factorlist() {
        if(n == 1) return {};
        T nn = n;
        vector<NP> ret;
        T i = 2;
        while (i*i <= n) {
            if(nn%i == 0) {
                nn /= i;
                if(!ret.empty() && ret[ret.size()-1].first == i) ret[ret.size()-1].second++;
                else ret.emplace_back(i,1);
            } else i++;
        }
        if(nn != 1) ret.emplace_back(nn,1);
        return ret;
    }
    bool isprime() {
        auto v = factorlist();
        return v.size() == 1 && v[0].second == 1;
    }
    int divisor() {
        int ret = 1;
        vector<NP> fl = this->factorlist();
        for(auto p : fl) {
            ret *= p.second+1;
        }
        return ret;
    };
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll ans = 1;
    ans += factorizaion<ll>(n-1).divisor()-1;
    for(ll i = 2; i*i <= n; i++) {
        if((n-1)%i == 0) continue;
        ll nn = n;
        while(nn%i == 0) {
            nn /= i;
        }
        if(nn%i == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
m, n = gets.split.map(&:to_i)
a = 1000000007
def comp_mod_exp(b, e, m)
  return 1 if e == 0
  ans = comp_mod_exp(b, e / 2, m)
  ans = (ans * ans) % m
  ans = (ans * b) % m if e % 2 == 1
  return ans
end
puts comp_mod_exp(m, n, a)


Measured memory_bytes: 6860
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
 
int main(){
  long n,sum[4]={0},max_;
  int x[100],y[100];
  double D[4];
   
  cin >>n;
  for(int i=0;i<n;i++)cin >>x[i];
  for(int i=0;i<n;i++)cin >>y[i];
   
  for(int i=0;i<n;i++){
    if(x[i]-y[i]!=0) max_=max(x[i]-y[i],y[i]-x[i]);
    else max_=0;
    sum[0]+=max_;   
    sum[1]+=max_*max_;
    sum[2]+=max_*max_*max_;
    sum[3]=max(sum[3],max_);
 
  D[0]=sum[0];
  D[1]=(double)sqrt((double)sum[1]);
  D[2]=(double)pow((double)sum[2],1.0/3.0);
  D[3]=(double)sum[3];}
   
  printf("%.6f\n",D[0]);
  printf("%.6f\n",D[1]);
  printf("%.6f\n",D[2]);
  printf("%.6f\n",D[3]);
 
 return 0;
}

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

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            var (animalCount, legCount) = IOUtils.Read2Ints();

            // var tsuruCount = ((decimal)legCount - 4 * (decimal)animalCount) / (-2);
            // if (tsuruCount % 1 == 0 && tsuruCount >= 0) {
            //     System.Console.WriteLine("Yes");
            // } else {
            //     System.Console.WriteLine("No");
            // }

            var kame = (legCount - (2 * animalCount)) / (decimal)2;
            if (kame % 1 == 0 && kame >= 0 && kame <= animalCount) {
                System.Console.WriteLine("Yes");
            } else {
                System.Console.WriteLine("No");
            }

        }
    }
    
    static class IOUtils
    {
        public static (int a, int b) Read2Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1]);
        }
        public static (int a, int b, int c) Read3Ints()
        {
            var vals = ReadInts();
            return (vals[0], vals[1], vals[2]);
        }
        public static IEnumerable<int[]> ReadIntLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadInts();
            }
        }
        public static IEnumerable<long[]> ReadLongLines(int count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return ReadLongs();
            }
        }
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


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

void buildFail(const string& t, vector<int>& fail) {
    int m = t.size();
    fail.resize(m + 1);
    int j = -1;
    fail[0] = -1;
    for(int i = 1; i <= m; ++i) {
        while(j >= 0 && t[j] != t[i - 1]) j = fail[j];
        fail[i] = ++j;
    }
}

void match(const string& s, const string& t, vector<int>& res) {
    vector<int> fail;
    buildFail(t, fail);
    int n = s.size(), m = t.size();
    for(int i = 0, k = 0; i < n; ++i) {
        while(k >= 0 && t[k] != s[i]) k = fail[k];
        ++k;
        if(k >= m) {
            res.emplace_back(i - m + 1);
            k = fail[k];
        }
    }
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    vector<int> res;
    match(s, t, res);
    for(int x : res)
        cout << x << '\n';
    return 0;
}

Measured memory_bytes: 8816
#include <cstdio>
#include <vector>
#define ri register int
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=1e5+5,M=2e5+5;
int tot,head[N],nxt[M],adj[M],deg[N],vis[M],ans[M],tmp,a[M],b[M],tag[N],q[M],sum[N];
inline void addedge(ri x,ri y){
	nxt[++tot]=head[x];
	adj[head[x]=tot]=y;
}
inline void dfs(ri x){
	ri i;
	while(i=head[x])
		if(!vis[i])
			vis[i]=vis[i^1]=1,
			dfs(adj[i]),
			ans[++tmp]=i&1?-i/2:i/2; 
		else
			head[x]=nxt[i];
}
inline void dfs2(ri x){
	ri i;
	while(i=head[x])
		if(!vis[i])
			vis[i]=1,
			dfs2(adj[i]),
			ans[++tmp]=i-1;
		else
			head[x]=nxt[i];
}
int main(){
	ri n,m,i,cnt,s,t,r;
	gi(n);gi(m);
	tot=1;
	for(i=1;i<=m;++i)
		gi(a[i]),gi(b[i]),
		addedge(a[i],b[i]),
		addedge(b[i],a[i]),
		++deg[a[i]],++deg[b[i]];
	for(i=1;i<=n;++i)
		if(deg[i]&1) return puts("No"),0;
	for(i=1;i<=n;++i)
		if(head[i]){
			dfs(i);
			break;
		}
//	for(i=tmp;i;--i)
//		if(ans[i]>0)
//			printf("%d %d\n",a[ans[i]],b[ans[i]]);
//		else
//			printf("%d %d\n",b[-ans[i]],a[-ans[i]]);
	for(i=tmp;i;--i)
		if(ans[i]>0)
			++tag[a[ans[i]]];
		else
			++tag[b[-ans[i]]];
	cnt=s=t=0;
	for(i=1;i<=n;++i){
		if(tag[i]>=3) return puts("Yes"),0;
		if(tag[i]==2){
			++cnt;
			if(!s) s=i;
			else t=i;
		}
	}
	if(cnt>2)
		puts("Yes");
	else if(cnt==2){
		if(ans[tmp]>0)
			q[r=1]=a[ans[tmp]];
		else
			q[r=1]=b[-ans[tmp]];
		for(i=tmp;i;--i)
			if(ans[i]>0)
				q[++r]=b[ans[i]];
			else
				q[++r]=a[-ans[i]];
		std::vector<int> pos;
	//	printf("check %d %d\n",s,t);
	//	for(i=1;i<=r;++i) printf("%d ",q[i]);
	//	puts("");
		for(i=1;i<=r;++i){
			if(q[i]==s)
				pos.push_back(i);
			sum[i]=sum[i-1]+(q[i]==t);
		}
	//	for(i=1;i<=r;++i) printf("%d ",sum[i]);
	//	puts("");
		if(sum[pos[0]]+sum[r]-sum[pos[1]]==0||sum[pos[1]]-sum[pos[0]]==0)
			puts("Yes");
		else
			puts("No");
	}
	else puts("No");
	return 0;
}

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

uint64_t g(uint64_t n){
    if(n == 0) return 0;
    else if(n%2 != 0) return (n+1)%4/2;
    else return (n%4/2)^n;
}

int main() {
    uint64_t a,b; cin >> a >> b;
    uint64_t ans = a^g(a)^g(b);
    cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin
from functools import reduce
# バージョン 3.4.X 以前
import fractions
# バージョン 3.4.X より 後
# import math

input = stdin.readline

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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(reduce(fractions.gcd, xn))
    return


main()


Measured memory_bytes: 16224
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  
using namespace std;
int main() {
	string s;
	int n;
	char a;
	cin >> n >> s;
	for (int i = 0; i < s.length(); ++i) {
		a = s[i] + n;
		if (a > 90)a = a - 26;
		cout << a;
	}
	cout << endl;
}

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


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int a[]=new int[n+1];
        int b[]=new int[n+1];
        int Alice=0;
        int Bob=0;
        for(int i=1;i<=n;i++){
            a[i]=sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=n;i>=1;i--){
            b[n-i+1]=a[i];
        }
        for(int i=1;i<=n;i++){
            if(i%2==1){
                Alice+=b[i];
            }
            else{
                Bob+=b[i];
            }
        }
        System.out.println(Alice-Bob);
    }
    
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    // 整数の入力
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>

int main(){
	int n, m;
	std::cin >> n >> m;
	std::vector<std::pair<int, int> > island(m);
	for(int i = 0; i < m; i++){
		std::cin >> island[i].first >> island[i].second;
	}

	std::sort(island.begin(), island.end());
	std::vector<bool> v(n + 1, false);
	for(int i = 0; i < m; i++){
		if(island[i].first == 1){
			v[island[i].second] = true;
		}else break;
	}

	bool ok = false;
	for(int i = 0; i < m; i++){
		if(island[i].second == n){
			if(v[island[i].first])ok = true;
		}

		if(ok)break;
	}

	std::cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << std::endl;

}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
    vector<ll> x,y;
    for(int i=0;i<f;i++){
        for(int j=0;j<f;j++){
            ll xsum=100*a*i+100*b*j;
            if(xsum<=f) x.push_back(xsum);
        }
    }
    for(int i=0;i<f;i++){
        for(int j=0;j<f;j++){
            ll ysum=c*i+d*j;
            if(ysum<=f) y.push_back(ysum);
        }
    }
    double dmax=0;//濃度
    ll wmax,smax;
    for(int i=0;i<(int)x.size();i++){
        for(int j=0;j<(int)y.size();j++){
            if(x[i]+y[j]>f || x[i]+y[j]==0) continue;
            if((double)(100.0*y[j]/(x[i]+y[j]))>=dmax && e*x[i]>=100*y[j]){
                wmax=x[i];
                smax=y[j];
                dmax=(100.0*y[j]/(x[i]+y[j]));
            }
        }
    }
    cout<<wmax+smax<<" "<<smax<<endl;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


int main() {
	int H, W, D;
	cin >> H >> W >> D;
	int A[300][300];
	pair<int,int> B[301 * 301];
	int C[301 * 301];
	int i, j;
	rep(i, 0, H)rep(j, 0, W) {
		cin >> A[i][j];
		B[A[i][j]].first = i;
		B[A[i][j]].second = j;
	}

	int Q;
	int LL[100000];
	int RR[100000];
	cin >> Q;
	rep(i, 0, Q) {
		cin >> LL[i] >> RR[i];

	}
	rep(i, 0, D) {

		long long ans = 0;
		int L = i+1;
		C[L] = 0;
		while (L <= H*W-D) {
			int p = L + D;
			ans += abs(B[p].first - B[L].first) + abs(B[p].second - B[L].second);
			L = p;
			C[L] = ans;
		}
	}
	rep(i, 0, Q) {
		int L = LL[i], R = RR[i];
		cout << C[R] - C[L] << endl;

	}
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

#include<stdlib.h>


#include<string.h>


int main(void){


char num_str[1002];


int num;


long sum=0;


int i;


char tmp;


while(1){


fgets(num_str,sizeof(num_str),stdin);


if(num_str[0]=='0')break;


for(i=0;i<strlen(num_str)-1;i++){


tmp=num_str[i];


num=atoi(&tmp);


sum=sum+num;


}


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


sum=0;


memset(num_str,1002,0);


}


return 0;


}

Measured memory_bytes: 528
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  ll n,x,m;
  cin>>n>>x>>m;
  
  int a=-1,b=n;
  vector<int> A(m+1),B(m+3);
  ll t=x;
  A[1]=t;
  B[t]=1;
  for(int i=2;i<=n;i++){
    t=t*t%m;
    if(B[t]==0){
      A[i]=t;
      B[t]=i;
    }
    else{
      a=B[t];
      b=i-1;
      break;
    }
  }
  
  ll c=b-a+1;
  ll d=(n-a+1)/c-1;
  ll sum=0;
  for(int i=1;i<=b;i++) sum+=A[i];
  if(a!=-1) for(int i=a;i<=b;i++) sum+=d*A[i];
  ll e=n-b-((n-a+1)/c-1)*c;
  if(a!=-1) for(int i=0;i<e;i++) sum+=A[a+i];
  
  cout<<sum<<endl;
  
  return 0; 
}

Measured memory_bytes: 4044
j,a['   '],s,z=1e6;main(i){for(;++i<998;)for(j=i*i;a[j]=j<z;j+=i);for(i=1;++i<z||~scanf(s="%d\n",&j)&&printf(s,a[j]);a[i]=s+=!a[i]);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
ll invmod(ll a, ll p)
{ // a^-1 mod p
    ll b = p, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= p;
    if (u < 0)
        u += p;
    return u;
}
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum=0;
    REP(i,n){
        cin >> a[i];
        sum+=a[i];
        sum%=MOD;
    }
    ll ans=0;
    REP(i,n){
        ans = (ans + (a[i] * (sum + MOD - a[i]) % MOD) % MOD) % MOD;
    }
    ans=ans*invmod(2,MOD)%MOD;
    ans%=MOD;
    cout << ans << endl;
}


Measured memory_bytes: 4832
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  vector<int> vec;
  for(int i = 0; i < n; i++){
    int l;
    cin >> l;
    vec.pb(l);
  }
  sort(vec.begin(), vec.end());
  int res = 0;
  for(int i = 0; i < k; i++){
    res += vec[n - i - 1];
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main() {
    int r, c;
    cin >> r >> c;
    vector<vector<int>> vec(r+1, vector<int>(c+1));
    for(int i = 0; i < r; i ++){
        for(int j = 0; j < c; j++){
            cin >> vec.at(i).at(j);
            vec.at(r).at(c) += vec.at(i).at(j);
        }
    }
    for(int i = 0; i < r; i ++){
        for(int j = 0; j < c; j++){
            vec.at(i).at(c) += vec.at(i).at(j);
        }
    }
    for(int i = 0; i < c; i ++){
        for(int j = 0; j < r; j++){
            vec.at(r).at(i) += vec.at(j).at(i);
        }
    }
    for(int i = 0; i <= r; i ++){
        for(int j = 0; j <= c; j++){
            cout  << vec.at(i).at(j);
            if(j == c){
                break;
            }
            cout << " ";
        }
        cout << endl;
    }
    
    
}


Measured memory_bytes: 3192
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  std::string S;
  std::cin >> S;
  const i64 N = S.size();

  for (i64 i = 0; i <= (N - 1) / 2 - 1 - i; ++i) {
    if (S[i] != S[(N - 1) / 2 - 1 - i]) goto FAILED;
    if (S[(N - 1) / 2 - 1 - i] != S[(N + 3) / 2 - 1 + i]) goto FAILED;
    if (S[(N + 3) / 2 - 1 + i] != S[N - 1 - i]) goto FAILED;
  }

  std::cout << "Yes" << std::endl;
  return 0;

FAILED:
  std::cout << "No" << std::endl;
  return 0;
}

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

int main() {
  int N;
  int K;
  cin >> N >> K;
  
  vector<int> a(N);
  for(int i=0; i<N; ++i) {
    cin >> a[i];
  }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
  int ans=0;
  for(int i=0; i<K; ++i) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}
    
  

Measured memory_bytes: 3600
#include <stdio.h>

int main(void) {
	char ary[101]; scanf("%s",ary);
	int i = 0;
	while (ary[i]!='\0') {
		if (i % 2 == 0) {
			if (ary[i] == 'L') {
				printf("No\n");
				break;
			}
		} else {
			if (ary[i] == 'R') {
				printf("No\n");
				break;
			}
		}
		i++;
	}
	if (ary[i]=='\0') printf("Yes");
	
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, A;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> A;

  int ans = N * N - A;

  cout << ans << endl;

  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<vector<int> > A(N,vector<int>(2));
  rep(i,N){
    cin >> A.at(i).at(0);
    A.at(i).at(1) = i + 1;
  }
  sort(A.begin(), A.end());
  rep(i,N) cout << A.at(i).at(1) << " ";
  cout << endl;
}

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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#define co(n) cout << (n) << endl;
#define cn(n) cin >> n;
#define all(x) (x).begin(), (x).end()

int main(){
  int a,b;cn(a)cn(b)
  for( int i=1; i<4; ++i ){
    if (i!=a&&i!=b){
      cout << i << endl;
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int winner(vector<int> &v) {
  int n = v.size();
  int count, winner;
  count = winner = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] > 0) {
      count++;
      winner = i;
    }
  }
  if (count != 1) return -1;
  return winner;
}

int main() {
  while (true) {
    int n, p;
    cin >> n >> p;
    if (n == 0) break;
    vector<int> v(n,0);
    int res, index = 0;
    while (true) {
      if (p > 0) {
	v[index]++;
	p--;
      } else {
	p += v[index];
	v[index] = 0;
      }
      if (p == 0 and (res = winner(v)) != -1) {
	break;
      }
      index = (index+1) % n;
    }
    cout << res << endl;
  }
}

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



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

    if (input.find("RRR") != string::npos) cout << "3" << endl;
    else if (input.find("RR") != string::npos) cout << "2" << endl;
    else if (input.find("R") != string::npos) cout << "1" << endl;
    else cout << "0" << endl;
}

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

def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    #print(2**(k-1))
    if (k>50):
        ans = [n]*n
        print(*ans)
        exit()
    #print(tnp)
    for i in range(k):
        b = [0]*n
        for i in range(n):
            l = i-a[i]
            r = i+a[i]
            #print(l,r)
            b[max(l,0)] += 1
            if (r<n-1):
                b[r+1] -= 1
            #print(b)
    
        for i in range(1,n):
            b[i] = b[i-1] + b[i]
        a = b
        
    print(*b)
    
    
if __name__=="__main__":
    main()
        

Measured memory_bytes: 126892
N, M = gets.split.map(&:to_i)
t = M * 1900 + (N - M) * 100

# p * t*1 + (1-p)*p * t*2 + (1-p)^2*p * t*3
#  \sum((1-p)^(i-1)*p * t*i)
# = t*p*\sum((1-p)^(i-1)*i)
# = t/(2^M) * \sum((1/(2^M))^(i-1)*i)
# = t/(2^M) * \sum(i/(2^(M*(i-1))))
# = t/(2^M) * (2^M) * 1/(2^M) * \sum(i/(2^(M*(i-1))))
# = t * \sum(i/(2^(M*i)))
# = t * (2^M) * \sum(i/(2^i))
# = t*(2^M)

p t * (2**M)


Measured memory_bytes: 3836
//??????????????§
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Queue[LEN];
int head,tail,n;

void enqueue(P x)
{
  Queue[tail] = x;
  tail = (tail + 1)%LEN;
}

P dequeue()
{
  P x= Queue[head];
  head = (head + 1)%LEN;
  return x;
}

int minimum(int x,int y){
  return x<y ? x: y;
}
int main()
{
  int laps =0;
  int c,i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Queue[i].name);
    scanf("%d",&Queue[i].t);
  }
  head =1;
  tail = n +1;
  while(head != tail)
    {
      u=dequeue();
      c=minimum(q,u.t);
      u.t-=c;
      laps+=c;
      if(u.t >0)enqueue(u);
      else{
	printf("%s %d\n",u.name,laps);
      }
    }
  return 0;
}

Measured memory_bytes: 10756
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        
        String ans = "";
        if(a < 0 && b >= 0) {
            ans = "Zero";
        }
        else if(a >= 0 && b >= 0) {
            if(a == 0 || b == 0) ans = "Zero";
            else ans = "Positive";
        }
        else {
            ans = ((b - a + 1) % 2 == 0) ? "Positive" : "Negative";
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35764
N ,M = map(int, input().split())
H = [int(i) for i in input().split()]
X = []
cnt = 0

for i in range(M):
    A = [int(i) for i in input().split()]
    if H[A[0] - 1] < H[A[1] - 1]:
        X.append(A[0])
    elif H[A[0] - 1] > H[A[1] - 1]:
        X.append(A[1])
    else:
        X.append(A[0])
        X.append(A[1])
        
print(N - len(set(X)))

Measured memory_bytes: 20120
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int A = one.get(0);
      int B = one.get(1);
      int C = one.get(2);
      myout((A + B >= C) ? "Yes" : "No");
	}
	//Method addition frame start

  
  
	//Method addition frame end
}


Measured memory_bytes: 32972
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int r;
    cin >> r;
    cout << 3 * r * r;
    }

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

int main() {
    long long N;
    cin >> N;
    vector <long long> A(N);
    for (long long i=0; i<N; i++) cin >> A.at(i);
    long long ans=0;
    for (long long i=1; i<N; i++) {
        if (A.at(i-1)-A.at(i)>0) {
            ans += A.at(i-1)-A.at(i);
            A.at(i)+=(A.at(i-1)-A.at(i));
        }
    }
    cout << ans;
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
template <typename Int, Int MOD, int N>
struct comb_util {
	std::array<Int, N + 1> fc, ifc;

	comb_util() {
		fc[0] = 1;
		for (int i = 1; i <= N; i++) fc[i] = fc[i - 1] * i % MOD;
		ifc[N] = inv(fc[N]);
		for (int i = N - 1; i >= 0; i--) ifc[i] = ifc[i + 1] * (i + 1) % MOD;
	}

	Int fact(Int n) { return fc[n]; }

	Int inv_fact(Int n) { return ifc[n]; }

	Int inv(Int n) { return pow(n, MOD - 2); }

	Int pow(Int n, Int a) {
		Int res = 1, exp = n;
		for (; a; a /= 2) {
			if (a & 1) res = res * exp % MOD;
			exp = exp * exp % MOD;
		}
		return res;
	}

	Int perm(Int n, Int r) {
		if (r < 0 || n < r)
			return 0;
		else
			return fc[n] * ifc[n - r] % MOD;
	}

	Int binom(Int n, Int r) {
		if (n < 0 || r < 0 || n < r) return 0;
		return fc[n] * ifc[r] % MOD * ifc[n - r] % MOD;
	}

	Int homo(Int n, Int r) {
		if (n < 0 || r < 0) return 0;
		return r == 0 ? 1 : binom(n + r - 1, r);
	}
};

using comb = comb_util<long long, 1000000007, 300000>;
comb cb;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	if (M == 1) {
		cout << 1 << endl;
		return 0;
	}
	map<int, int> mp;
	map<int, int> nmp;
	mp[M] = 1;
	int res = 0;
	
	vector<int> x;
	for (int i = 1; i*i <= M; i++) {
		if (M % i == 0) {
			x.push_back(i);
			if (i*i < M)x.push_back(M / i);
		}
	}
	sort(x.begin(), x.end());
	for (int i = 0; i < N; i++) {
		nmp.clear();
		for (auto m : mp) {
			if (m.first == 1)continue;
			for (auto k : x) {
				if (k*k > m.first)break;
				if (m.first%k == 0) {
					
					if (k == 1) {
						//cerr << i << " " << m.second << endl;
						res = (res + ((m.second*cb.binom(N, i + 1)) % MOD)) % MOD;
					}
					else {
						nmp[k] = (nmp[k] + m.second) % MOD;
						if (k*k < m.first)nmp[m.first / k] = (nmp[m.first / k] + m.second) % MOD;
					}
				}
			}
		}
		swap(mp, nmp);
	}
	cout << res << endl;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int32_t main()
{
	fast;
	string s;cin>>s;
	if(s[s.size()-1]=='s')
	{
		s+="es";
		cout<<s<<endl;
	}
	else
	{
		s+="s";
		cout<<s<<endl;
	}
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a;
// scanf("%d", &a);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

void	FFF(const string pre, const char maxc, const int n, vector<string> &S) {
	if (0==n) {
		S.push_back(pre);
		return;
	}
	char cc='a';
	while (maxc-cc>=0) {
		string pre1=pre;
		pre1 +=cc;
		if (cc==maxc)
			FFF(pre1, maxc+1, n-1, S);
		else
			FFF(pre1, maxc, n-1, S);
		cc+=1;
	}
	return;
}

int	main() {
	int N;
	cin >>N;
	vector<string> S;
	FFF("", 'a', N, S);
	//Sort(S);
	for (int i=0; i<S.size(); i++)
		cout <<S.at(i) <<endl;
	return 0;
}



Measured memory_bytes: 7796
#include <stdio.h>

int     main(void)
{
    int n;
    
    n = 0;
    scanf("%d",&n);
    if (65 <= n && n <= 90)
        printf("1\n");
    else if (97 <= n && n <= 122)
        printf("2\n");
    else
        printf("0\n");
    return (0);
}


Measured memory_bytes: 2148
#include <stdio.h>

int main(void)
{
	int i, j, a[3];

	scanf("%d %d %d", &a[0], &a[1], &a[2]);

	for(i = 0; i < 2; i++){
		for(j = 2; j > i; j--)
		{
			if(a[j-1] > a[j]){
			int temp = a[j];
			a[j] = a[j-1];
			a[j-1] = temp;
			}
		}
	}

	printf("%d %d %d\n", a[0], a[1], a[2]);
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n;

int main() {
	
	FAST;
	
	cin >> n;
	vector <intt> l(n + 1);
	for (int i = 1; i <= n; i ++) cin >> l[i];
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		for (int j = i + 1; j <= n; j ++) {
			for (int k = j + 1; k <= n; k ++) {
				if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k]) {
					intt sum = (l[i] + l[j] + l[k]);
					if (sum > 1LL * 2 * l[i] && sum > 1LL * 2 * l[j] && sum > 1LL * 2 * l[k]) ans ++;
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[110];
int main()
{
    while(scanf("%s",a)!=EOF)
    {
    a[0]='2';
    a[1]='0';
    a[2]='1';
    a[3]='8';
    printf("%s\n",a);
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int main()
{
    int R,G,B,n,r=0,g=0,b=0,ans=0;
    scanf("%d%d%d%d",&R,&G,&B,&n);
    for(r=0; r*R<=n; r++) {
        for(g=0; r*R+g*G<=n; g++) {
            if((n-r*R-g*G)%B == 0) {
                ans++;
            }
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    int res=0;
    if ((A+B) <= 2*C){
	res=A*X+B*Y;
    } else {
	res+=2*C*min(X,Y);
	if (X > Y){
	    if (A > 2*C){
		res+=2*C*(X-Y);
	    } else {
		res+=A*(X-Y);
	    }
	} else {
	    if (B > 2*C){
		res+=2*C*(Y-X);
	    } else {
		res+=B*(Y-X);
	    }
	}
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
sg = [[-1 for i in range(N)] for j in range(N)]
for i in range(N):
  M = int(input())
  for j in range(M):
    x, y = map(int, input().split())
    sg[i][x-1] = y
X = 2**N
H = []
for i in range(X):
  L = []
  for j in range(N):
    L.append(i%2)
    i //= 2
  mj = 0
  for j in range(N):
    if L[j] == 1:
      for k in range(N):
        if j != k and (sg[j][k] == 0 and L[k] == 1 or sg[j][k] == 1 and L[k] == 0):
          mj += 1
          break
    if mj >= 1:
      break
  if mj >= 1:
    H.append(0)
  else:
    H.append(sum(L))
print(max(H))

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int n, m, q;
vector<int> a, b, c, d;

int dfs(vector<int> A, int new_n) {
    A.push_back(new_n);

    if (A.size() == n) {
        int sum = 0;
        rep(0, q) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                sum += d[i];
            }
        }
        return sum;
    }

    int before = A.size() - 1;
    int ret = 0;
    for (int i = A[before]; i <= m; i++) {
        ret = max(ret, dfs(A, i));
    }

    return ret;
}

void solve() {
    cin >> n >> m >> q;

    int ai, bi, ci, di;
    rep(0, q) {
        cin >> ai >> bi >> ci >> di;
        a.push_back(ai-1);
        b.push_back(bi-1);
        c.push_back(ci);
        d.push_back(di);
    }

    int ans = 0;
    vector<int> empty;
    for (int i = 1; i <= m; i++) {
        ans = max(ans, dfs(empty, i));
    }

    cout << ans << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int s;
  cin >> s;
  int n = s % 100, m = s / 100;
  if(0 < n && n < 13) {
    if(0 < m && m <13)
      cout << "AMBIGUOUS";
    else cout << "YYMM";
  }
  else {
    if(0 < m && m <13)
      cout << "MMYY";
    else cout << "NA";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

void solve() {
    LL a, b, k; cin >> a >> b >> k;
    if (k <= a) {
        a -= k;
    } else {
        k -= a;
        a = 0;
        b -= min(b, k);
    }
    cout << a << " " << b << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // int t;cin >> t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256