akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int n, m, i, j;
  char c[128], ch[128], a;

  while(1){
    scanf("%d",&n);
    if(n == 0) break;
    for(i = 0 ; i < n ; i++){
      scanf(" %c %c ",&c[i],&ch[i]);
    }
    scanf("%d",&m);
    for(i = 0 ; i < m ; i++){
      scanf(" %c ",&a);
      for(j = 0 ; j < n ; j++){
	if(a == c[j]){
	  a = ch[j];
	  break;
	}
      }
      printf("%c",a);
    }
    printf("\n");
  }

  return 0;

}

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

int main() {
  int n,l;
  cin>>n>>l;
  vector<string>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3600
var c = 0;

(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var A = p.shift().split(' ').map(Number);

    //var count = 0;
    //var max = -Infinity;
    //for (var i = 0; i < A.length; i++) {
    //    max = Math.max(max, A[i]);
    //    if (A[i] < max) {
    //        count++;
    //    }
    //}
    mergeSort(A, 0, A.length);
    console.log(c);
    //console.log(A);
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function mergeSort(array, left, right) {
    if (left + 1 < right) {
        var mid = Math.floor((left + right) / 2);
        mergeSort(array, left, mid);
        mergeSort(array, mid, right);
        mergeSortSub(array, left, mid, right);
    }

    function mergeSortSub(array, left, mid, right) {
        var n1 = mid - left;
        var n2 = right - mid;
        var leftArray = [];
        var rightArray = [];
        for (var i = 0; i < n1; i++) {
            leftArray.push(array[left + i]);
        }
        for (var i = 0; i < n2; i++) {
            rightArray.push(array[mid + i]);
        }
        leftArray.push(Infinity);
        rightArray.push(Infinity);
        var i = j = 0;
        for (var k = left; k < right; k++) {
            if (leftArray[i] <= rightArray[j]) {
                array[k] = leftArray[i];
                i++;
            } else {
                c += (leftArray.length - 1  - i);
                array[k] = rightArray[j];
                j++;
            }
        }
        //console.log(array);
    }
}

Measured memory_bytes: 46196
from collections import deque
n = int(input())
tree = [[] for _ in range(n)]
for _i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

visit = [-1 for _ in range(n)]
f, s = 0, 0
f_q = deque([0])
s_q = deque([n-1])

while f_q or s_q:
    g = []
    while f_q:
        p = f_q.popleft()
        for i in tree[p]:
            if visit[i] < 0:
                f += 1
                g.append(i)
                visit[i] = 0
    f_q = deque(g)

    g = []
    while s_q:
        p = s_q.popleft()
        for i in tree[p]:
            if visit[i] < 0:
                s += 1
                g.append(i)
                visit[i] = 0
    s_q = deque(g)
if f > s:
    print("Fennec")
else:
    print("Snuke")

Measured memory_bytes: 62752
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

char numToChar(int num) {
    return 'a' + num;
}

int main() {
    long long N;

    cin >> N;

    string ans = "";

    // 文字数計算
    while(N > 0) {
        N -= 1;
        ans += numToChar(N % 26);
        N /= 26;
    }

    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>

using namespace std;

struct node
{
    int s;
    int x,y;
};

int dir[][2] = {0,1,1,0,0,-1,-1,0};
int vis[1010][1010];
int n,m,k,sx[20],sy[20];

char map[1010][1010];

int bfs(int x,int y,int ex,int ey)
{
    queue<node> q;
    node a,b,d;
    a.x = x;
    a.y = y;
    a.s = 0;
    vis[x][y] = 1;
    q.push(a);
    while(!q.empty())
    {
        b = q.front();
        q.pop();
        if(b.x == ex && b.y == ey)
           {
                return b.s;
           }
        for(int i = 0; i < 4; i++)
        {
            d.x = b.x + dir[i][0];
            d.y = b.y + dir[i][1];
            if(d.x >= 0 && d.x < n && d.y >= 0 && d.y < m && vis[d.x][d.y] == 0)
            {
                if(map[d.x][d.y] >= '1' && map[d.x][d.y] <= '9' || map[d.x][d.y] == '.')
                {
                    vis[d.x][d.y] = 1;
                    d.s = b.s + 1;
                    q.push(d);
                }
            }
        }
    }
}

int main()
{
    while(~scanf("%d%d%d",&n,&m,&k))
    {
        int i,j,t;

        for(i = 0; i < n; i++)
        {
            scanf("%s",map[i]);
            for(j = 0; j < m; j++)
                if(map[i][j] == 'S')
                {
                    sx[0] = i;
                    sy[0] = j;
                    map[i][j] = '.';
                }
        }
        for(i = 0; i < n; i++)
            for(j = 0; j < m; j++)
                if(map[i][j] >= '1' && map[i][j] <= '9')
                {
                    sx[map[i][j]-'0'] = i;
                    sy[map[i][j]-'0'] = j;
                }
        int ans = 0;
        for(i = 1; i <= k; i++)
        {
            memset(vis,0,sizeof(vis));
            ans += bfs(sx[i-1],sy[i-1],sx[i],sy[i]);
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 7788
#![allow(dead_code)]
use std::cmp;
use std::collections::*;

pub struct Scanner {
    bytes: Vec<u8>,
    begin: usize,
    end: usize,
}

impl Scanner {
    pub fn new() -> Self {
        let mut buffer: Vec<u8> = Vec::new();
        std::io::Read::read_to_end(&mut std::io::stdin(), &mut buffer).unwrap();
        let end = Scanner::step_item(&buffer, 0);
        Scanner {
            bytes: buffer,
            begin: 0,
            end: end,
        }
    }
    pub fn next<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let s: &str = unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
        let ret: T = s.parse::<T>().unwrap();
        self.begin = Scanner::step_whitespace(&self.bytes, self.end);
        self.end = Scanner::step_item(&self.bytes, self.begin);
        ret
    }
    pub fn next_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
    pub fn next_chars(&mut self) -> Vec<char> {
        let s: String = self.next();
        s.chars().collect::<Vec<char>>()
    }
    fn step_whitespace(s: &Vec<u8>, idx: usize) -> usize {
        let mut r = idx;
        while r < s.len() && (s[r] == b' ' || s[r] == b'\n' || s[r] == b'\r') {
            r += 1;
        }
        r
    }
    fn step_item(s: &Vec<u8>, idx: usize) -> usize {
        let mut r = idx;
        while r < s.len() && s[r] != b' ' && s[r] != b'\n' && s[r] != b'\r' {
            r += 1;
        }
        r
    }
}

fn lower_bound<T: std::cmp::Ord>(v: &Vec<T>, val: &T) -> usize {
    let mut lb: isize = -1;
    let mut ub: isize = v.len() as isize;
    while ub - lb > 1 {
        let mid = (lb + ub) / 2;
        if *val <= v[mid as usize] {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    return ub as usize;
}

fn dfs(
    u: usize,
    p: usize,
    dp: &mut Vec<i32>,
    ans: &mut Vec<usize>,
    a: &Vec<i32>,
    edge: &Vec<Vec<usize>>,
) {
    let idx = lower_bound(dp, &a[u]);
    let prev = dp[idx];
    dp[idx] = a[u];
    ans[u] = lower_bound(dp, &i32::max_value());

    for v in &edge[u] {
        if *v == p {
            continue;
        }
        dfs(*v, u, dp, ans, a, edge);
    }
    dp[idx] = prev;
}

fn main() {
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let a: Vec<i32> = scan.next_vec(n);
    let mut edge: Vec<Vec<usize>> = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let u: usize = scan.next();
        let v: usize = scan.next();
        let (u, v) = (u - 1, v - 1);
        edge[u].push(v);
        edge[v].push(u);
    }
    let mut dp: Vec<i32> = vec![i32::max_value(); n];
    let mut ans: Vec<usize> = vec![0; n];
    dfs(0, 0, &mut dp, &mut ans, &a, &edge);
    for x in ans {
        println!("{}", x);
    }
}


Measured memory_bytes: 36364
from collections import Counter

N = int(input())
D = list(map(int, input().split()))
if D[0] != 0:
    print(0)
    exit()
D.sort()
count = Counter(D)
if count[0] != 1:
    print(0)
    exit()
ans = 1
for i in range(1, D[-1] + 1):
    if i not in count:
        print(0)
        exit()
    ans *= count[i-1] ** count[i]
print(ans % 998244353)


Measured memory_bytes: 19936
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string S;
  cin >> S;
  bool a = true;
  bool b = true;
  if (S[0]!='0' && S[0]!='1') {
    a = false;
  }
  if (S[0]=='1') {
    if (S[1]!='0' && S[1]!='1' && S[2]!='2') {
      a = false;
    }
  }
  if (S[0]=='0' && S[1]=='0') {
    a = false;
  }

  if (S[2]!='0' && S[2]!='1') {
    b = false;
  }
  if (S[2]=='1') {
    if (S[3]!='0' && S[3]!='1' && S[3]!='2') {
      b = false;
    }
  }
  if (S[2]=='0' && S[3]=='0') {
    b = false;
  }
  
  if (a && b) {
    cout << "AMBIGUOUS" << endl;
  } else if (a) {
    cout << "MMYY" << endl;
  } else if (b) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import itertools
A=[0,0,0]
N,A[0],A[1],A[2]=map(int,input().split())
l=[int(input()) for i in range(N)]
ans=10**15
for seq in itertools.product(range(4),repeat=N):
    X=[0,0,0]
    Y=[0,0,0]
    for i in range(N):
        if seq[i]!=3:
            X[seq[i]]+=l[i]
            Y[seq[i]]+=1
    if Y[0]*Y[1]*Y[2]==0:
        continue
    MP=(sum(Y)-3)*10
    for i in range(3):
        MP+=abs(X[i]-A[i])
    if MP<ans:
        ans=MP
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
#define mp make_pair
using namespace std;
ll getma(ll x, ll y){
	if(y<=x){
		return x*y;
	}
	else{
		if( (x+y)%2 == 0){
			return (x+y)*(x+y)/4;
		}
		else{
			return (x+y-1)*(x+y+1)/4;
		}
	}
}
ll solve(ll a, ll b){
	if(a>b) return solve(b,a);
	ll ans = 0;
	ans += a-1;
	ll lef = 0, rig = b;
	while(rig-lef>1){
		ll mid = (rig+lef)/2;
		if( getma(a+1,mid) < a*b){
			lef = mid;
		}
		else{
			rig = mid;
		}
	}
	ans += lef;
	return ans;
}
int main(){
	ll q;
	cin>>q;
	for(int i=0;i<q;i++){
		ll a,b;
		cin>>a>>b;
		cout<<solve(a,b)<<endl;
	}
	return 0;
}

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

const int mod = 1e9 +7;
const int maxn = 2e5 +7;
int main()
{
    

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int tt=1, n, m, k, x, y, u, v, id=1, i, j=0, sum; 
    //cin>>tt; 
 
    int ans = 0;
    while(tt--) {
        string s; cin>>s;
        n = s.length();
        for(i=0; i<n; i++) {
            j=0;
            while(i<n && s[i] == 'R')   i++, j++;
            ans = max(ans, j);
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    string s[3];
    rep(i,3){
        cin >> s[i] ;
    }

    cout << s[0][0] << s[1][1] << s[2][2] << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
int A[2000001],B[2000001],C[10001];
int main()
{
  int i,j,n=0;
  int k=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
      C[A[i]]++;
      if(k<A[i]) k=A[i];
      // printf("%d ",A[i]);
    }
  for(i=0;i<=k;i++)
    {
      C[i]=C[i]+C[i-1];
    }
  for(j=n;j>=0;j--)
    {     
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
  for(i=1;i<n+1;i++)
    {
      if(i!=n)printf("%d ",B[i]);
      else  printf("%d\n",B[i]);
    }
  return 0;
}

Measured memory_bytes: 16264
#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 MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;

    int ans = a;
    if(a > b)
        ans--;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 200005
using namespace std;
typedef long long ll;
const int mod=924844033;
struct edge{
	int k,next;
}e[N<<1];
int n,home[N],cnt=-1;
ll f[N],inv[N],num[N];
ll quick_pow(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1) ans=ans*a%mod;
	return ans;
}
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
int siz[N],m;
void dft(ll *a,int sig){
	for(int i=0;i<m;i++){
		int p=0,g=m>>1,j=i;
		while(g) p=p<<1|(j&1),g>>=1,j>>=1;
		if(p<i) swap(a[p],a[i]);
	}
	ll w,wn;
	for(int b=2;b<=m;b<<=1){
		wn=quick_pow(5,sig==1?(mod-1)/b:mod-1-(mod-1)/b);
		int half=b>>1;
		for(int i=0;i<m;i+=b){
			w=1;
			for(int j=0;j<half;j++){
				ll u=a[i+j],v=a[i+j+half]*w%mod;
				a[i+j]=(u+v)%mod;
				a[i+j+half]=(u-v)%mod;
				w=w*wn%mod;
			}
		}
	}
	ll inv=quick_pow(m,mod-2);
	if(sig==-1) for(int i=0;i<m;i++) a[i]=a[i]*inv%mod;
}
void dfs(int k,int F){
	siz[k]=1;
	for(int i=home[k];~i;i=e[i].next){
		if(e[i].k!=F){
			dfs(e[i].k,k);
			siz[k]+=siz[e[i].k];
		}
	}
	num[siz[k]]--;
	num[n-siz[k]]--;
}
ll a[N<<2],b[N<<2];
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	f[0]=inv[0]=1;
	for(int i=1;i<=n;i++) f[i]=f[i-1]*i%mod,inv[i]=quick_pow(f[i],mod-2);
	dfs(1,0);
	m=1;
	while(m<=n+n) m<<=1;
	num[n]=n;
	b[0]=1;
	for(int i=1;i<=n;i++) a[n-i]=num[i]*f[i]%mod,b[i]=inv[i];
	dft(a,1);
	dft(b,1);
	for(int i=0;i<m;i++) a[i]=a[i]*b[i]%mod;
	dft(a,-1);
	for(int i=1;i<=n;i++) printf("%lld\n",(a[n-i]+mod)*inv[i]%mod);
	return 0;
}

Measured memory_bytes: 32000
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e14+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

bool solve(void){
	int i,j,n,w,wa=0;cin>>n>>w;
	llint ans=0;
	vector<int>dp(w+1);dp[0]=1;
	vector<int>wei(n);
	for(i=0;i<n;i++){cin>>wei[i];wa+=wei[i];}
	SO(wei);REV(wei);
	if(wa<=w){cout<<1<<endl;return false;}
	for(i=0;i<n;i++){
		wa-=wei[i];
		for(j=max(0,w-wa-wei[i]+1);j<=w-wa;j++){ans+=dp[j];}
		for(j=w;j>=wei[i];j--){dp[j]+=dp[j-wei[i]];dp[j]%=mod;}
	}
	cout<<ans%mod<<endl;
	return false;
}
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	while(solve()){}
	return 0;
}



Measured memory_bytes: 3196
def f(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x
n = int(input())    
ans = [0 for i in range(n+1)]

for i in range(1,100):
    for j in range(1,100):
        for k in range(1,100):
            now = f(i,j,k)
            if 1 <= now <= n:
                ans[now] += 1
for i in range(1,n+1):
    print(ans[i])

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

int main()
{
char g1,g2,g3,g4,g5,g6;
cin>>g1>>g2>>g3;
cin>>g4>>g5>>g6;
if(g2==g5&&g1==g6&&g3==g4)
       cout<<"YES";
else
       cout<<"NO";

    return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[0] == S[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);
  std::vector< std::pair<int, int> > A;
  A.reserve(N);
  for (int i = 0; i < N; ++i) {
    int t;
    scanf("%d", &t);
    A.push_back(std::make_pair(t, i+1));
  }
  std::sort(A.begin(), A.end());
  printf("%d", A[0].second);
  for (int i = 1; i < N; ++i) {
    printf(" %d", A[i].second);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 1536
n = int(input())
a = []

for i in range(n):
    a.append(int(input()))
    
a_copy = list(a)
a.sort(reverse=True)

max_1 = a[0]
max_count = a.count(max_1)

for i in a:
    if i < max_1:
        max_2 = i
        break
        
for a in a_copy:
    if a == max_1 and max_count == 1:
        print(max_2)
    else:
        print(max_1)

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

int main(){
    string n; cin >> n;
    int d = n[n.size()-1] - '0';
    if(d==0 || d==1 || d==6 || d==8) cout << "pon" << endl;
    else if(d==3) cout << "bon" << endl;
    else cout << "hon" << endl;


}

Measured memory_bytes: 3596
program answer
  implicit none

  integer(8) :: N, M, i, ans, ba
  integer(8), allocatable :: p(:), T(:), un(:)
  character(2), allocatable :: S(:)
  read(*,*) N, M
  allocate(p(M))
  allocate(S(M))
  allocate(T(N))
  allocate(un(N))
  do i = 1, M
     read(*,*) p(i), S(i)
  end do

  T=0
  un=0
  ans=0
  ba=0
  do i = 1, M
     if(T(p(i))==0.and.S(i)=='WA') then
         un(p(i))=un(p(i))+1 
     else if(T(p(i))==0.and.S(i)=='AC') then
           ba=ba+un(p(i))
           T(p(i))=1
           ans=ans+1
     end if
  end do

  write(*,*) ans, ba

  deallocate(p, T, un, S)
  
  stop
 end program answer


Measured memory_bytes: 4920
import numpy as np

n, k = map(int,input().split())
h = list(map(int,input().split()))

h = np.array(h)
dp = np.zeros(n, dtype=int)

for i in range(1,n):
    m = max(0,i-k)
    dp[i] = min(dp[m:i] + np.abs(h[i] - h[m:i]))
print(dp[n-1])

Measured memory_bytes: 22840
<?php

fscanf(STDIN, "%d %d %d %d ", $a, $b, $c, $d);

if (abs($b - $a) <= abs($d) && abs($c - $b) <= abs($d) || abs($c - $a) <= abs($d)) {
    echo "Yes";
} else {
    echo "No";
}



?>

Measured memory_bytes: 16068
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move





int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif
 ll  a,b,c,d;
  cin>>a>>b>>c>>d;
  if(c>d)
  {
      swap(c,d);
  }
  if(a>b)
  {
      swap(a,b);
  }
  ll ans1=a*c;
  ll ans2=b*d;
  ll ans3=a*d;
  ll ans4=b*c;
  ll anss=max(ans3,ans4);
  ll anss1=max(ans1,ans2);
  ll ans=max(anss1,anss);
  if(ans<0)
  {
      if(b>=0 && a<0)
      {
          cout<<0<<endl;
      }
      else if(c<=0 && d>=0)
      {
          cout<<0<<endl;
      }
      else
      {
          cout<<ans<<endl;
      }
      return 0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int n,k;
    cin>>n>>k;
    int h[n];
    
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    
    sort(h, h+n);
    
    n = max(0, n-k);
    
    long long d = accumulate(h, h+n, 0LL);
    cout << d << "\n";
    
    return 0;
}

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

int main() {
  int K, X;
  cin >> K >> X;
  if (500*K>=X) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3548
#include<stdio.h>
int main(void)
{
	int n, x, i,l,cnt=0;
	scanf("%d%d", &n, &x);
	for (i = 1;i <= n;i++) {
		scanf("%d",&l);
		cnt += l;
		if (cnt > x)
			break;
	}
	printf("%d", i);
	return 0;
}

Measured memory_bytes: 128
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n,m;
	cin >> n >> m;
	vector<vector<ll> > status(n,vector<ll>(8,0));
	vector<ll> a(3);
	rep(i,0,n){
		cin >> a[0] >> a[1] >> a[2];
		rep(j,0,8){//枚举8种状态 (+-)a[0](+-)a[1](+-)a[2]
			ll sum = 0;
			int sta = j;
			rep(k,0,3){
				if(sta&1){//取正数的状态 
					sum += a[k];
				}else{//取正数的状态 
					sum -= a[k]; 
				}
				sta >>= 1; 
			}
			status[i][j] = sum;
		}
	}
	//对每一种状态(0~7)排序后取最后M个数之和
	//最后的结果为这8个数中的最大值
	ll ans = 0;
	rep(i,0,8){
		vector<ll> cur;
		rep(j,0,n)cur.pb(status[j][i]);
		sort(all(cur));
		ll sum = 0;
		for(int j=n-1;j>=n-m;j--){
			sum += cur[j];
		}
		ans = max(ans,sum);
	} 
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

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

    int M=0;
    int N=0;
    for(int i=0;i<S.length();i++){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T') N++;
        else N =0;
        M = max(M,N);    
    }
    cout << M << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<int>> switches(m);
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    scanf("%d", &k);
    for (int j = 0; j < k; j++) {
      int x;
      scanf("%d", &x);
      x--;
      switches[i].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &p[i]);
  }
  int ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    int cur = 1;
    for (int i = 0; i < m; i++) {
      int x = 0;
      for (int j = 0; j < (int) switches[i].size(); j++) {
        x += ((mask >> switches[i][j]) & 1);
      }
      cur &= (p[i] == (x % 2));
    }
    ans += cur;
  }
  printf("%d\n", ans);
  return 0;
}

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

public class Program
{

    public void Proc()
    {
        Dictionary<int, int> grp = new Dictionary<int, int>();
        grp.Add(2, 1);
        new int[] { 4, 6, 9, 11 }.ToList().ForEach(a => grp.Add(a, 2));
        for (int i = 1; i <= 12; i++) {
            if(grp.ContainsKey(i)) {
                continue;
            }
            grp.Add(i, 3);
        }
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        string ans = "No";
        if(grp[inpt[0]] == grp[inpt[1]]) {
            ans = "Yes";
        }
        Console.WriteLine(ans);
    }


	public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"


1 3

";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
	long long x = T1 * (A1-B1);
	long long y = T2 * (A2-B2) + x;
	if (y == 0) {
		cout << "infinity" << endl;
		return 0;
	}
	if (y < 0) {
		x = -x;
		y = -y;
	}
	if (x >= 0) {
		cout << 0 << endl;
		return 0;
	}
	long long r = 1 + (-x / y) * 2;
	if (-x % y == 0) -- r;
	cout << r << endl;
	//cerr << x << endl;
	//cerr << y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int hp,HP;
int h,w;
string mp[101];
int dmg[1<<8];
string seq;
int P,p[12];

void Max(int &a,int b){a=max(a,b);}

void Go(int &x,int &y,char ch){
  if(ch=='U') y--;
  if(ch=='D') y++;
  if(ch=='L') x--;
  if(ch=='R') x++;
}

int dp[1010][1<<12];
void update(int idx,int bit,int hp,int dmg,int i){
  Max(dp[i][bit],hp-dmg);
  if(idx==P||hp-dmg>0) return;
  update(idx+1,bit,hp,dmg,i);
  if(bit>>idx&1)return;
  update(idx+1,bit|(1<<idx),min(HP,hp+p[idx]),dmg,i);
}


bool DP(){
  int x = 0,y = 0,size=seq.size();
  memset(dp,0,sizeof(dp));
  dp[0][0] = hp;
  for(int i=0;i<size;i++){ 
    Go(x,y,seq[i]);
    for(int bit=0;bit<(1<<P);bit++)
      if(dp[i][bit])update(0,bit,dp[i][bit],dmg[mp[y][x]],i+1);
  }

  for(int i=0;i<(1<<P);i++) if(dp[size][i])return 1;
  return 0;
}


int main(){
  int cnt=0;
  while(1){
    cnt++;
    cin>>hp>>HP;
    if(!hp&&!HP) return 0;
    cin>>h>>w;
    for(int i=0;i<h;i++)cin>>mp[i];

    int Alpha;
    cin>>Alpha;
    for(int i=0,cost;i<Alpha;i++){
      char ch;
      cin>>ch>>cost;
      dmg[ch] = cost;
    }
    
    int s;
    cin>>s;
    seq.clear();
    for(int i=0,num;i<s;i++){
      char ch;
      cin>>ch>>num;
      seq+=string(num,ch);
    }

    cin>>P;
    for(int i=0;i<P;i++)cin>>p[i];
    cout<<(DP()? "YES":"NO")<<endl;
  }
  return 0;
}

Measured memory_bytes: 19404
import java.util.*;

public class Main {

    static int n;
    static int m;
    static int q;

    static int array[];
    static int ABCD[][];

    static int max = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();

        ABCD = new int[q][4];

        for (int i = 0; i < q; i++) {
            ABCD[i][0] = sc.nextInt();
            ABCD[i][1] = sc.nextInt();
            ABCD[i][2] = sc.nextInt();
            ABCD[i][3] = sc.nextInt();
        }

        array = new int [n];

        dfs(0, 1);

        System.out.println(max);

        sc.close();
    }

    public static void dfs(int depth, int min) {
        for (int i = min; i < m + 1; i++) {
            array[depth] = i;
            if (depth + 1 == n) {
                int value = 0;
                for (int j = 0; j < q; j++) {
                    if (array[ABCD[j][1] - 1] - array[ABCD[j][0] - 1] == ABCD[j][2]) {
                        value += ABCD[j][3];
                    }
                }
                if (value > max) {
                    max = value;
                }
            } else {
                dfs(depth + 1, i);
            }
        }
    }

}

Measured memory_bytes: 37144
s = input()
t = input()
q = int(input())

sa_pre = [s[i] == "A" for i in range(len(s))]
ta_pre = [t[i] == "A" for i in range(len(t))]

sa = [0, sa_pre[0]]
ta = [0, ta_pre[0]]

for i in range(1, len(s)):
	sa.append(sa[-1] + sa_pre[i])

for i in range(1, len(t)):
	ta.append(ta[-1] + ta_pre[i])

def check(a, b, c, d):
	xa = sa[b] - sa[a - 1]
	ya = ta[d] - ta[c - 1]
	if (2 * xa - (b - a + 1)) % 3 == (2 * ya - (d - c + 1)) % 3:
		print("YES")
		return
	else:
		print("NO")
		return

for _ in range(q):
	a, b, c, d = map(int, input().split())
	check(a, b, c, d)

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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int a , b , c;
        cin >> a >> b >> c;
        cout << max( 0 , -( a - b - c ) ) << endl;
        return 0;
}










Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;

int main()
{
	cin >> n;
	cout << n * 800 - (n / 15) * 200 << endl;

	return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    import math
    K = int(readline().strip().decode())
    cnt = 0
    for a in range(1,K+1):
        for b in range(1,K+1):
            for c in range(1,K+1):
                tmp = math.gcd(b, c)
                g = math.gcd(a, tmp)
                cnt += g
    print(cnt)
    return

if __name__ == '__main__':
    main()



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

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

long long lcm(long long a, long long b){
   return a * b / gcd(a, b);
}

int main() {
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ansB = b - b/c - b/d + b/lcm(c,d);
    long long ansA = (a-1) - (a-1)/c - (a-1)/d + (a-1)/lcm(c,d);
    cout << ansB - ansA << endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	a, b, k := readInt(), readInt(), readInt()

	if k < a {
		fmt.Println(a-k, b)
	} else {
		fmt.Println(0, max(0, b-(k-a)))
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,x;
	long[] a;
	long ans;
    public void solve() {
    	N = nextInt();
    	x = nextInt();
    	ans = 0;

    	a = new long[N];
    	for(int i = 0;i < N;i++){
    		a[i] = nextInt();
    	}

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

    		long diff = (long)a[i - 1] + a[i] - x;

    		if(diff > 0){

    			ans += diff;

    			long min = Math.min(diff, a[i]);

    			diff -= min;
    			a[i] -= min;

    			if(diff > 0){
    				a[i - 1] -= diff;
    			}
    		}
    	}

    	out.println(ans);
    }

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int check(ll n, ll x, ll y) {
    ll bunshi = n * x * y;
    ll bunbo = x * y * 4 - n * (y + x);
    if (bunbo == 0) return -1;
    if (bunshi % bunbo != 0) return -1;
    ll ans = bunshi / bunbo;
    if (ans <= 0) return -1;
    return ans;
}

void test(double n, double x, double y, double now) {
    cout << (4 / n) << endl;
    cout << (1 / x) + (1 / y) + (1 / now) << endl;
}

int main() {

    ll n;
    cin >> n;

    for (ll x = 1; x <= 3500; x++) {
        for (ll y = 1; y <= 3500; y++) {
            ll now = check(n, x, y);
            if (now == -1) continue;
            printf("%d %d %d\n", x, y, now);
//            test(n, x, y, now);
            ret();
        }
    }


}

Measured memory_bytes: 384
#UnionFindクラス
class UnionFind:
    def __init__(self,n):
        self.par =  [i for i in range(n)]
        self.rank = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # xとyの根を結合させる
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y: return
        if self.rank[x] < self.rank[y]:
            x, y = y, x
        self.rank[x] += self.rank[y]
        self.par[y] = x

    # x,yの根が同じかどうかを返す（根が同じ:True、根が異なる:False）
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    # xが含まれる木の要素数を返す
    def size(self, x):
        return self.rank[self.find(x)]
    
n,m = map(int,input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(m)]
uf = UnionFind(n)
accm = []
for ai,bi in reversed(ab):
    if uf.is_same(ai,bi):
        accm.append(0)
    else:
        accm.append(uf.size(ai)*uf.size(bi))
    uf.union(ai,bi)

accm = accm[::-1]
for i in range(1,len(accm)):
    accm[i] += accm[i-1]
for a in accm:
    print(a)



Measured memory_bytes: 26784
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, q;
    cin >> n;

    vector<int> s(n);
    rep(i, n) cin >> s[i];

    cin >> q;
    vector<int> t(q);
    rep(i, q) cin >> t[i];
    
    int ans = 0;
    rep(i, q) {
        if (t[i] == *lower_bound(s.begin(), s.end(), t[i])) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3292
gets.to_i.times do
  gx,gy = gets.split(" ").map{|s| s.to_i}
  ngx,ngy = [],[]
  gets.to_i.times do
    a = gets.split(" ").map{|s| s.to_i}
    if a[0] == a[2]
      ngy << [a[0],[a[1],a[3]].max]
    else
      ngx << [[a[0],a[2]].max,a[1]]
    end
  end
    
  ptn = Array.new(gy+1){Array.new(gx+1)}
  ptn[0][0] = 1

  for x in 1..gx
    ptn[0][x] = (ngx.include?([x,0]) ? 0 : ptn[0][x-1])
  end
  for y in 1..gy
    ptn[y][0] = (ngy.include?([0,y]) ? 0 : ptn[y-1][0])
    for x in 1..gx
      ptn[y][x] = (ngx.include?([x,y]) ? 0 : ptn[y][x-1]) + (ngy.include?([x,y]) ? 0 : ptn[y-1][x])
    end
  end

  puts (ptn[gy][gx] == 0 ? "Miserable Hokusai!" : ptn[gy][gx])
end

Measured memory_bytes: 8792
#include <stdio.h>

int main(void)
{
    int n;
    int i, j;
    char suit[1];
    int rank;
    int cards[4][14];

    for (i = 0; i < 4; i++){
        cards[i][0] = 1;
        for (j = 1; j < 14; j++){
            cards[i][j] = 0;
        }
    }

    scanf("%d", &n);

    for (i = 1; i <= n; i++){
        scanf("%s %d", suit, &rank);
        switch(suit[0]){
            case 'S':
                cards[0][rank] = 1;
                break;
            case 'H':
                cards[1][rank] = 1;
                break;
            case 'C':
                cards[2][rank] = 1;
                break;
            case 'D':
                cards[3][rank] = 1;
                break;
            default:
                printf("ERROR!\n");
                break;
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[0][j] == 0){
            printf("S %d\n", j);
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[1][j] == 0){
            printf("H %d\n", j);
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[2][j] == 0){
            printf("C %d\n", j);
        }
    }

    for (j = 1; j < 14; j++){
        if (cards[3][j] == 0){
            printf("D %d\n", j);
        }
    }

    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(void){
  int X = 0;
  int count = 0;
  scanf("%d\n",&X );

  count += (X / 500)*1000;
  X = (X % 500);
  count += (X / 5)*5;
  printf("%d\n",count );
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(void){
    long long int n,s = 0,a[1000],b[1000];
    long long int i;
    scanf("%lld",&n);
    for (i = 0; i<n-1; i++){
        scanf("%lld", &b[i]);
    }
    
    for(i = 0; i<n; i++){
        if(i>=n-1){
            a[i]=b[i-1];
        }else if(i==0){
            a[i]=b[0];
        }else if (b[i]<b[i-1]){
            a[i]=b[i];
        }else{
            a[i]=b[i-1];
        }
        //printf("%d\n",a[i]);
    }
    for(i = 0; i<n; i++){
        s=a[i]+s;
    }
    printf("%lld",s);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {


    public static void main(String[] args) {


        Scanner scan = new Scanner(System.in);
        double A=scan.nextInt();
        double B=scan.nextInt();
        double H=scan.nextInt();
        double M=scan.nextInt();

        double L=Math.sqrt(Math.pow(A,2)+Math.pow(B,2)-2*A*B*Math.cos(Math.toRadians(M*5.5-H*30)));
        System.out.println(L);
    }
    }





Measured memory_bytes: 27184
#include<bits/stdc++.h>
using namespace std;
int oya[51],a[10000000],b[10000000],len[51],hs[51];
int main(void)
{
	int n,m,i,j,l,k,x,y,cnt,flg,s;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++) scanf("%d %d",&a[i],&b[i]);
	cnt=0;
	for(i=0;i<m;i++){
		flg=0;
		for(j=1;j<=n;j++){
			oya[j]=j; len[j]=1;
		}
		for(j=0;j<m;j++){
			if(i!=j){
				x=a[j];
				while(x!=oya[x]) x=oya[x];
				y=b[j];
				while(y!=oya[y]) y=oya[y];
				if(x!=y){
					if(len[x]>len[y]) oya[y]=x;
					else if(len[x]<len[y]) oya[x]=y;
					else oya[y]=x,len[x]++;
				}
			}
		}
		for(j=1;j<=n;j++){
			s=j;
			while(s!=oya[s]){
				s=oya[s];
			}
			hs[j]=s;
		}/*
		for(j=1;j<=n;j++) printf("%d ",oya[j]);
		cout<<endl;*/
		for(j=1;j<n;j++) if(hs[j]!=s) flg=1;
		if(flg==1) cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin>>n;
    vector<ll> m(5);
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='M') m[0]++;
        if(s[0]=='A') m[1]++;
        if(s[0]=='R') m[2]++;
        if(s[0]=='C') m[3]++;
        if(s[0]=='H') m[4]++;
    }
    ll ans=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++) ans+=m[i]*m[j]*m[k];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3536
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	int n,ans=0;
	cin>>n;
	for(int i=0;i<n;i++) {
		cin>>s[i];
	}
	for(int i=0;i<n-2;i++) {
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++; 
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm> // sort(ALL())
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue> // push(), front(), pop() 先入れ先出し
#include<map> // 連想配列 map<string, int>
#include<iomanip>
#include<set>
#include<utility>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b);  i++)
#define REP(i, n)    for(int i=0;   i<(n);  i++)
#define REP1(i, n)   for(int i=1;   i<=(n); i++)
#define pb push_back
#define mp make_pair
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define EPS 1e-7
#define ALL(obj) (obj).begin(), (obj).end()
#define MAX_INDEX(arg) distance(arg.begin(), max_element(arg.begin(), arg.end()))
using ul    = unsigned long;
using ll    = long long;
using ld    = long double;
using vint  = vector<int>;
using vll   = vector<ll>;
using pint  = pair<int, int>;
using pll   = pair<ll, ll>;
using vpint = vector<pint>;
using vpll  = vector<pll>;
const int INF = (int)1e9 + 1;
const int MOD = (int)1e9 + 7;
#define INT(argu) (int)(argu+EPS)

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

  int n;
  scan(n);
  n /= 2;
  vint a(100002), b(100002);
  int x, y;
  REP(i, n){
    cin >> x >> y;
    a[x]++; b[y]++;
  }

  vint::iterator itrmaxa = max_element(ALL(a));
  vint::iterator itrmaxb = max_element(ALL(b));
  bool find_2_a = find(next(itrmaxa), a.end(), *itrmaxa) != a.end();
  bool find_2_b = find(next(itrmaxb), b.end(), *itrmaxb) != b.end();
  if( !find_2_a && !find_2_b && (distance(a.begin(), itrmaxa) == distance(b.begin(), itrmaxb)) ){
    sort(ALL(a)); sort(ALL(b));
    cout << n*2 - max( *(prev(a.end(),2)) + b.back(), a.back() + *(prev(b.end(),2)) ) << endl;
  }else{
    cout << n*2 - *itrmaxa - *itrmaxb << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    sunuke = [0] * n
    for _ in range(k):
        d = int(input())
        a = tuple(map(int, input().split()))
        for ae in a:
            sunuke[ae-1] += 1

    r = sunuke.count(0)
    print(r)

if __name__ == '__main__':
    main()


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


int main(){
    int k, s, cnt = 0;
    cin >> k >> s;

    for(int x = 0; x < k+1; x++){
        for(int y = 0; y < k+1; y++){
                if(x+y <= s && s <= x+y+k) cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main() {
    int N, M;
    cin >> N;
    map<string, int> s;
    string temp;
    REP(i, N) {
        cin >> temp;
        s[temp]++;
    }
    cin >> M;
    string t[M];
    REP(i, M) {
        cin >> t[i];
        if (s[t[i]] != 0) s[t[i]]--;
    }
    int ans = 0;
    EACH(i, s) ans = max(ans, i.second);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256