akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

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

    for (int i = 1; i <= n; i++) {
        int ans = 0;

        for (int j = 1; j < sqrt(i); j++) {
            for (int k = 1; k < sqrt(i); k++) {
                int ok = 1, ng = sqrt(i) + 1;
                while (ng - ok > 1) {
                    int mid = (ok + ng) / 2;
                    if (j * j + k * k + mid * mid + j * k + j * mid + k * mid <= i)
                        ok = mid;
                    else
                        ng = mid;
                }
                if (j * j + k * k + ok * ok + j * k + j * ok + k * ok == i) {
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

inline int read() {
  int ret, cc, sign = 1;
  while (!isdigit(cc = getchar()))
    sign = cc == '-' ? -1 : sign;
  ret = cc - 48;
  while (isdigit(cc = getchar()))
    ret = cc - 48 + ret * 10;
  return ret * sign;
}

const int MAXN = 200010;
std::pair<int, int> A[MAXN];
int n;

int main() {
  n = read();
  for (int i = 1; i <= n; ++i) 
    A[i].second = read(), A[i].first = read();
  long long cur = 0;
  std::sort(A + 1, A + n + 1);
  for (int i = 1; i <= n; ++i) {
    if ((cur += A[i].second) > A[i].first) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 3000;
double dp[mxn][mxn];
bool c[mxn][mxn];
int n;
double p[mxn];

double f(int i,int j)
{
	if(c[i][j])
		return dp[i][j];
	if(i == 0 && j == 0)
		dp[i][j] = 1;
	else if(i == 0)
		dp[i][j] = (1 - p[i + j]) * f(i,j - 1);
	else if(j == 0)
		dp[i][j] = p[i + j] * f(i - 1,j);
	else
		dp[i][j] = p[i + j] * f(i - 1,j) + (1 - p[i + j]) * f(i,j - 1);
	c[i][j] = 1;
	return dp[i][j];
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	FOR(i,1,n)
		cin >> p[i];
	int k = (n + 1) / 2;
	double ans = 0;
	memset(c,0,sizeof(c));
	FOR(count,k,n)
		ans += f(count,n - count);
	cout << fixed << setprecision(12) << ans;	

	return 0;
}

Measured memory_bytes: 51052
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{
    lint n;
    scanf("%lld", &n);

    std::vector<lint> b(n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%lld", &b[i]);
    }

    std::vector<lint> ans;

    for (int i = 0; i < n; ++i)
    {
        lint insert_point = b[i] - 1;
        if (insert_point > ans.size())
        {
            printf("-1");
            return 0;
        }

        ans.insert(ans.begin() + insert_point, b[i]);
    }

    for (int i = 0; i < n; ++i)
    {
        printf("%lld\n", ans[i]);
    }

    return 0;
}


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

import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main{

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			BigInteger[] d = new BigInteger[n], v = new BigInteger[n];
			d[0] = new BigInteger(sc.next()); v[0] = new BigInteger(sc.next());
			
			BigInteger div = gcd(d[0], v[0]);
			d[0] = d[0].divide(div); v[0] = v[0].divide(div);
			
			BigInteger nume = new BigInteger("" + d[0]), deno = new BigInteger("" + v[0]);
			for(int i=1;i<n;i++) {
				d[i] = new BigInteger(sc.next()); v[i] = new BigInteger(sc.next());
				div = gcd(d[i], v[i]);
				d[i] = d[i].divide(div); v[i] = v[i].divide(div);
				nume = lcm(nume, d[i]);
				deno = gcd(deno, v[i]);
			}
			for(int i=0;i<n;i++) {
				System.out.println(nume.divide(d[i]).multiply(v[i]).divide(deno) );				
			}
		}
	}
	
	BigInteger lcm(BigInteger x, BigInteger y) {
		return x.divide(gcd(x, y)).multiply(y);
	}
	
	BigInteger gcd(BigInteger x, BigInteger y) {
		if(y.equals(new BigInteger("0"))) return x;
		return gcd(y, x.divideAndRemainder(y)[1]);
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 55092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0028
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> input = Console.ReadLine().Split(' ').ToList();
            var wordList = input.GroupBy(i => i);
            string modeWord = "";
            int wordCount = 0;
            foreach (var word in wordList)
            {
                if (wordCount < word.Count())
                {
                    wordCount = word.Count();
                    modeWord = word.Key;
                }
            }
            string longestWord = "";
            int wordLengthMax = 0;
            foreach (var word in input)
            {
                if (wordLengthMax < word.Length)
                {
                    wordLengthMax = word.Length;
                    longestWord = word;
                }
            }
            Console.WriteLine(modeWord + " " + longestWord);
        }
    }
}



Measured memory_bytes: 16176
a,b,c = map(int,input().split())
sur = []
check = True
i = 1
while check:
	if (a*i)%b not in sur:
		sur.append((a*i)%b)
		i += 1
	else:
		check = False

if c in sur:
	print('YES')
else:
	print('NO')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int n; cin >> n;
    ll ans = 0;
    repr(i,1,n+1){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n 
	ll c=0;
	vector<ll>x; ll i;
    while (n % 2 == 0)  
    {  
        //cout << 2 << " ";
		c++;  
        n = n/2;  
    } 
	if(c>0) 
    x.push_back(c);
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for ( i = 3; i <= sqrt(n); i = i + 2)  
    {  
    c=0;
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            //cout << i << " ";  
            n = n/i;  
            c++;
        }
		if(c>0)
		x.push_back(c);  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)
	{
		//cout << n << " "; 
		x.push_back(1);
	  }  
	  
	  
	  ll j;ll ans=0;
	  for(i=0;i<x.size();i++)
	  {
	  	ll j;
        for(j=1;;j++)
        {
        	if(((j*(j+1))/2)>x[i])
        	{
        		break;
			}
		}
		ans+=j-1;
	  }
	  cout<<ans<<endl;
         
}  

using namespace std;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);ll n;
    cin>>n;
    if(n==1)
    cout<<0<<endl;
    else
    primeFactors(n);
    return 0;
}
    


Measured memory_bytes: 3676
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6 9
0 1 1
0 2 3
1 2 1
1 3 7
2 4 1
1 4 3
3 4 1
3 5 1
4 5 6

output:
5
"""

import sys
from operator import attrgetter
from collections import namedtuple


class UnionFind(object):
    __slots__ = ('size', 'tree_height_rank', 'ancestors')

    def __init__(self, size):
        self.size = int(size)
        self.tree_height_rank = [0] * self.size
        self.ancestors = [i for i in range(self.size)]

    def _find(self, x):
        if x != self.ancestors[x]:
            self.ancestors[x] = self._find(self.ancestors[x])
        return self.ancestors[x]

    def same(self, x, y):
        return self._find(x) == self._find(y)

    def _link(self, x, y):
        if self.tree_height_rank[x] > self.tree_height_rank[y]:
            self.ancestors[y] = x
        else:
            self.ancestors[x] = y
            if self.tree_height_rank[x] == self.tree_height_rank[y]:
                self.tree_height_rank[y] += 1

    def union(self, x, y):
        self._link(self._find(x), self._find(y))


def graph_Kruskal():
    total_cost = 0
    # sort edge_table by edge's weight
    edge_table.sort(key=attrgetter('cost'))
    # MST--> E = V + 1
    case = UnionFind(size=vertices + 1)
    for edge in edge_table:
        if not case.same(edge.source, edge.target):
            total_cost += edge.cost
            case.union(edge.source, edge.target)

    return total_cost


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    Edge = namedtuple('Edge', 'source target cost')
    edge_table = [Edge(source=int(s), target=int(t), cost=int(c)) for s, t, c in v_info]
    print(graph_Kruskal())

Measured memory_bytes: 34708
#include <iostream>
 
using namespace std;
 
int main (void) {
 
  int masu[1001] = {0};
  int m, n;
  int s, now = 1;
  int count = 0;
  int update = 0;
   
  while(1) {
    update = 0;
    now = 1;
    for (int i = 0; i < 1001; i++) masu[i]=0;
 
    cin >> n >> m;
    if(n == 0 && m == 0) break;
 
    //cout << "n: "<< n << " m: " << m << endl;
    for(int i = 1; i <= n; i++) {
      //cout << "i: " << i << endl;
      cin >> masu[i];
    }
     
    int j;
    for(j = 1; j <= m; j++) {
      cin >> s;
      now += s;
      now += masu[now];
      if(now < 0) now = 0;
      if(now > 1000) now = 1000;
       
      if (n <= now && update == 0) {
    update = 1;
    count = j;
      }
      //cout << "j: " << j << endl;
    }
     
    cout << count << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<memory>
using namespace std;

typedef struct Node {
    int key;
    Node *parent, *left, *right;
} Node;

Node *NIL, *root;

void inorder(Node *u) {
    if (u==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while (x!=NIL) {
        y=x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y==NIL) root = z;
    else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

Node *find(int k) {
    Node *x = root;
    while (x!=NIL) {
        if (x->key == k) return x;
        if (x->key > k) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return NIL;
}

int main() {
    int i, n, x;
    Node *t;
    string com;

    scanf("%d", &n);
    for (i=0; i<n; i++) {
        cin >> com;
        if (com=="insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com=="find") {
            scanf("%d", &x);
            t = find(x);
            if (t!=NIL) printf("yes\n");
            else printf("no\n");
        } else if (com=="print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22068
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
 char c;
 cin>>c;
 c++;
 cout<<c<<endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n,m;
	cin>>n>>m;
	ll ar[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>ar[i];
		sum+=ar[i];
	}
	sort(ar,ar+n,greater<ll>());
	if(4*m*ar[m-1]<sum)
		cout<<"No";
	else
		cout<<"Yes";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t M1, D1, M2, D2;

    scanf("%jd%jd", &M1, &D1);
    scanf("%jd%jd", &M2, &D2);

    if (D2 == 1)
        puts("1");
    else
        puts("0");

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int v;
  cin >> v;
  for (int i = 1; i <= 50000; ++i)
    if (i * 108 / 100 == v) {
      cout << i;
      return 0;
    }
  cout << ":(";

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
const ll N=200005, inf=hell;
inline ll add(ll x,ll y){x+=y;return x%hell;}
ll tr[4*N];
ll combine(ll x,ll y){return max(x,y);}
void update(ll node,ll l,ll r,ll idx,ll val){
	if(l==r){
		tr[node]=val;
		return;
	}
	ll mid=(l+r)/2;
	if(l<=idx and idx<=mid)update(node<<1,l,mid,idx,val);
	else
		update(node<<1|1,mid+1,r,idx,val);
	tr[node]=combine(tr[node<<1],tr[node<<1|1]);
}
ll query(ll node,ll l, ll r,ll a,ll b){
	if(l>r || b<l || r<a)return -inf;
	if(a<=l and r<=b)return tr[node];
	ll mid=(l+r)/2;
	return combine(query(node<<1,l,mid,a,b),query(node<<1|1,mid+1,r,a,b));
}
void solve(){
	ll n, x, d;
	cin>>n;
	vector<pp> v;
	vector<ll> lft(n+5,0), dp(n+5,0);
	dp[n]=1;
	rep(i,0,n){
		cin>>x>>d;
		v.pb({x,d});
	}
	sort(all(v));
	for(ll i=n-1;i>=0;i--){
		update(1,0,n,i,i);
		ll idx=lower_bound(all(v),make_pair(v[i].fi+v[i].se,0LL))-v.begin();
		if(idx>i)idx--;
		ll maxi=query(1,0,n,i,idx);
		update(1,0,n,i,maxi);
		lft[i]=maxi;
		dp[i]=add(dp[lft[i]+1],dp[i+1]);
	}
	cout<<dp[0];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


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

int main()
{
	int a,b;
	cin >>a>>b;
	int minn=0x3f3f3f3f;
	for(int i=1;i<=2500;i++)
	{
		int x=i*0.08,y=i*0.1;
		if(x==a&&y==b) minn=min(minn,i);
	}
	if(minn==0x3f3f3f3f) cout <<-1<<endl;
	else cout <<minn<<endl; 
}

Measured memory_bytes: 256
A,B,C,D,E,F = gets.split.map(&:to_i)
ret = [100, 0]
0.step(F, 100*A) do |a|
    0.step(F-a, 100*B) do |b|
        next if a == 0 && b == 0
        0.step(F-a-b, C) do |c|
            0.step(F-a-b-c, D) do |d|
                total = a + b + c + d
                sugar = c + d
                if total <= F && sugar.fdiv(total) <= E.fdiv(100+E)
                    ret[0], ret[1] = total, sugar if sugar.fdiv(total) >= ret[1].fdiv(ret[0])
                end
            end
        end
    end
end
puts "#{ret[0]} #{ret[1]}"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

map<int,int> c;
int n, ans;

int main()
{
	read(n);
	for(;n--;){
		int a; read(a); ++c[a];
	}
	for(auto tmp:c){
		int x, y; tie(x, y) = tmp;
		if(x > y) ans += y;
		else ans += y-x;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int N, K;
	cin >> N >> K;

	if (N % K == 0) cout << 0;
	else cout << 1;
	cout << endl;
	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
w_dic = {}
for i in range(n):
  w, w_t = map(int, input().split())
  if w_t <= t:
    w_dic[i+1] = w
if w_dic:
  print(min(w_dic.values()))
else:
  print("TLE")
    

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


int main() {
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) cin >> A[i];
	int fu = 0;
	int saishou = 1e9;
	ll goukei = 0;
	rep(i, N) {
		if (A[i] < 0) {
			fu++;
			A[i] = -A[i];
		}
		goukei += A[i];
		saishou = min(saishou, A[i]);
	}

	if (fu % 2) {
		goukei -= saishou * 2;
	}

	co(goukei);

	Would you please return 0;
}

Measured memory_bytes: 640
class Node:
    def __init__(self, val=None, prev=None, next=None):
        self.val = val
        self.prev = prev
        self.next = next

class DoublyLinkedList():
    def __init__(self):
        self.end = Node(val='END', prev=None, next=None)
        self.cur = self.end

    def insert(self, x):
        new_node = Node(val=x, prev=self.cur.prev, next=self.cur)
        if self.cur.prev != None: self.cur.prev.next = new_node
        self.cur.prev = new_node
        self.cur = new_node

    def move(self, d):
        if d > 0:
            for i in range(d):
                if self.cur.next == None: break
                self.cur = self.cur.next
        elif d < 0:
            for i in range(abs(d)):
                if self.cur.prev == None: break
                self.cur = self.cur.prev

    def erase(self):
        if self.cur == self.end: return
        if self.cur.prev != None: self.cur.prev.next = self.cur.next
        self.cur.next.prev = self.cur.prev
        self.cur = self.cur.next

    def print_elements(self):
        node_list = []
        crnode = self.end
        while True:
            if crnode.prev == None: break
            node_list.append(crnode.prev.val)
            crnode = crnode.prev
        for i in range(len(node_list)-1, -1, -1):
            print(node_list[i])

dll = DoublyLinkedList()
q = int(input())
for i in range(q):
    op = list(map(int, input().split(' ')))
    if op[0] == 0:
        dll.insert(op[1])
    elif op[0] == 1:
        dll.move(op[1])
    elif op[0] == 2:
        dll.erase()

dll.print_elements()



Measured memory_bytes: 92972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < 3; ++i)
    {
        if (s[i] == s[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{ 
ll n;
cin >> n; 
ll t[n]={};
rep(i,n) {
    cin >> t [i];
}
ll count=0;
ll min=1100000000;
rep(i,n) {
    if(t[i]<0)count++;
}
if(count%2){
    rep(i,n){
        ans+=abs(t[i]);
        if(min>abs(t[i]))min=abs(t[i]);
    }
    ans=ans-2*min;
}
else{
    rep(i,n){
        ans+=abs(t[i]);
    }
}

cout << ans << endl;
return 0;
} 

Measured memory_bytes: 1152
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        FastReader in = new FastReader();
        test a=new test();
        a.solve(in,out);
        out.close();
    }
}

class test {
    public void solve(FastReader in, PrintWriter out){
        int n=in.nextInt();
        int a[]=new int[n+1];
        int c=0;
        for(int i=1;i<=n;i++){
            a[i]=in.nextInt();
            if(i%2==1 && a[i]%2==1){
                c++;
            }
        }
        out.println(c);
    }
}

class FastReader{
    BufferedReader br;
    StringTokenizer st;

    public FastReader(){
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next(){
        while(st==null || !st.hasMoreElements()){
            try{
                st=new StringTokenizer(br.readLine());
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

    double nextDouble(){
        return Double.parseDouble(next());
    }
    String nextLine(){
        String str="";
        try{
            str=br.readLine();
        }
        catch(IOException e){
            e.printStackTrace();
        }
        return str;
    }
}

Measured memory_bytes: 32968
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

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

  int num_r = count(s.begin(), s.end(), 'R');
  int num_b = count(s.begin(), s.end(), 'B');

  if (num_r > num_b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long 
#define inf 1000000007

int main () {
  string h;
  cin >> h;
  string sub;
  int ans = -1;
  int answer = 0;
  int s;
  int ss = 753;
  int sss;
  for (int i = 0; i < h.size() - 2; i++) {
    sub = h.substr(i, 3);    
    s = stoi(sub);
    if (ss > s) {
      sss = ss - s;    
    }
    else {
      sss = s - ss;  
    }
    if (sss < ans || ans == -1) {
      ans = sss;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer;

        tokenizer = new StringTokenizer(reader.readLine());
        int N = Integer.parseInt(tokenizer.nextToken());
        int K = Integer.parseInt(tokenizer.nextToken());

        tokenizer = new StringTokenizer(reader.readLine());
        int i = 0;
        int[] arr = new int[N];

        while (tokenizer.hasMoreTokens()) {
            arr[i] = Integer.parseInt(tokenizer.nextToken());
            i++;
        }

        int[] cost = new int[N];

        cost[N-1] = 0;
        cost[N-2] = Math.abs(arr[N-2] - arr[N-1]);
        int leap;
        for (int j=N-3; j>=0; j--) {
            cost[j] = Integer.MAX_VALUE;

            for (int k=1; k <= K; k++){
                if (k + j > N-1){
                    break;
                }
                cost[j] = Math.min(cost[j+k] + Math.abs(arr[j] - arr[j+k]), cost[j]);
            }
        }

        System.out.println(cost[0]);
    }
}


Measured memory_bytes: 34332
#include<stdio.h>

int main(void){
  int answer_t[256];
  int answer_h[256];
  int k;
  int a;
  for(k=0;k>=0;k++){
    int n,m;
    int i,j;
    int total_t = 0,total_h = 0;
    int ans_t = -1,ans_h;
    int tmp;
    int cmp;
    scanf("%d%d",&n,&m);
    if(n == 0 && m == 0)break;
    int taro[n];
    int hanako[m];
    for(i=0;i<n;i++){
      scanf("%d",&taro[i]);
      total_t += taro[i];
    }
    for(i=0;i<m;i++){
      scanf("%d",&hanako[i]);
      total_h += hanako[i];
    }
    cmp = total_t - total_h;
    if(cmp % 2 == 1 || cmp % 2 == -1){
      ans_t = -1;
    } 
    else if(cmp >= 0){
      for(i=0;i<m;i++){
	for(j=i;j<m;j++){
	  if(hanako[i]>hanako[j]){
	    tmp = hanako[i];
	    hanako[i] = hanako[j];
	    hanako[j] = tmp;
	  }
	}
      }
      for(i=0;i<m;i++){
	for(j=0;j<n;j++){
	  if(hanako[i] + cmp/2 == taro[j]){
	    ans_t = taro[j];
	    ans_h = hanako[i];
	  }
	  if(ans_t != -1)break;
	}
	if(ans_t != -1)break;
      }
    }
    else if(cmp < 0){
      cmp = cmp * -1;
      for(i=0;i<n;i++){
	for(j=i;j<n;j++){
	  if(taro[i] > taro[j]){
	    tmp = taro[i];
	    taro[i] = taro[j];
	    taro[j] = tmp;
	  }
	}
      }
      for(i=0;i<n;i++){
	for(j=0;j<m;j++){
	  if(taro[i] + cmp/2 == hanako[j]){
	    ans_t = taro[i];
	    ans_h = hanako[j];
	  }
	  if(ans_t != -1)break;
	}
	if(ans_t != -1)break;
      }
    }
    answer_t[k] = ans_t;
    answer_h[k] = ans_h;
  }
  for(a=0;a<k;a++){
    if(answer_t[a] == -1){
      printf("-1\n");
    }
    else{
      printf("%d %d\n",answer_t[a],answer_h[a]);
    }
  }
  return 0;
}
  

Measured memory_bytes: 612
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
const int N=42;
const ll mod=1e9+7;
int n,X,Y,Z,endd,anss;
ll ans=1,dp[N][1<<17];
int main()
{
	//freopen("Iroha and Haiku.in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d%d%d",&n,&X,&Y,&Z);
	anss=(1<<X+Y+Z-1)|(1<<Y+Z-1)|(1<<Z-1);
	endd=(1<<X+Y+Z)-1;
	dp[0][0]=1;
	for(RG int i=1;i<=n;i++)
	{
		(ans*=10)%=mod;
		for(RG int j=0;j<=endd;j++)
		{
			if(!dp[i-1][j]) continue;
			for(RG int k=1;k<=10;k++)
			{
				int tt=(j<<k)|(1<<k-1); tt&=endd;
				if((tt&anss)!=anss) (dp[i][tt]+=dp[i-1][j])%=mod;
			}
//			if(i==n && (j&anss)!=anss) (sum+=dp[i][j])%=mod;
		}
	}
	for(RG int i=0;i<=endd;i++) ans=(ans-dp[n][i]+mod)%mod;
	printf("%lld\n",ans);
//	printf("%d",(ans-sum+mod)%mod);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 41216
fun main(args: Array<String>){
    val (N, P) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toInt() % 2 }

    val dp = Array(N+1){ LongArray(2) }
    dp[0][0] = 1L
    dp[0][1] = 0L
    for(i in 1..N){
        if(A[i-1] == 0){
            dp[i][0] = dp[i - 1][0] * 2
            dp[i][1] = dp[i - 1][1] * 2
        }else{
            dp[i][0] = dp[i - 1][0] + dp[i - 1][1]
            dp[i][1] = dp[i - 1][0] + dp[i - 1][1]
        }
    }
    println(dp[N][P])
}

Measured memory_bytes: 37740
import java.util.*;

public class Main{
   public static void main(String[] args) {
	  Scanner sc =new Scanner(System.in);
	  int a[]=new int[4];
	  int b[]=new int[4];
	  while(sc.hasNext()){
	for(int i=0; i<4; i++) a[i] =sc.nextInt();
	for(int i=0; i<4; i++) b[i] =sc.nextInt();
	int hit=0,blow=0;
	for(int i=0; i<4; i++) if(b[i]==a[i])hit++;
	for(int i=0; i<4; i++){
		for(int j=0; j<4; j++){
		   if(a[i]==b[j]) blow++;
		}
	}
	blow -=hit;
System.out.println(hit+" "+blow);
	  }
   }
   }

Measured memory_bytes: 18128
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    string S;
    cin >> S;
    string ans = "AKIHABARA";
    bool flag = false;
    for (int bit = 0; bit < (1 << S.length()+1); bit++)
    {
        string a = "";
        REP(j, S.length()+1) {
            if(bit & (1<<j)) {
                a += "A";
            }
            if(j!= S.length()) {
                a += S.at(j);
            }
        }
        // cout << a << endl;
        if (a == ans)
        {
            flag = true;
        }
    }
    cout << (flag ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
  list($n, $m) = explode(" ", trim(fgets(STDIN)));

  $s = [];
  for ($i=0; $i<$n; $i++) {
    list($s[]) = explode(" ", trim(fgets(STDIN)));
  }

  $t = [];
  for ($i=0; $i<$m; $i++) {
    list($t[]) = explode(" ", trim(fgets(STDIN)));
  }

  $sa = $n-$m;
  for ($i=0; $i<=$sa; $i++) {
    for ($j=0; $j<=$sa; $j++) {
      $icchi = true;
      for ($k=0; $k<$m; $k++) {
        for ($l=0; $l<$m; $l++) {
          if($t[$k][$l] != $s[$k+$i][$l+$j]){
//            echo $t[$k][$l]." ".$s[$k+$i][$l+$j]." ".$k." ".$l." ".$i." ".$j.PHP_EOL;
            $icchi = false;
          }
        }
      }
      if($icchi){
        echo "Yes";
        exit;
      }
    }
  }

  echo "No";

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

typedef long long ll;
const int N = 2020;

int n, m, ans, up[N][N], down[N][N], _left[N][N], _right[N][N];
string s[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		s[i] = "#" + s[i] + "#";
	}
	string bad;
	for (int i = 0; i <= m + 1; i++)
		bad.push_back('#');
	s[0] = s[n + 1] = bad;
	
	for (int i = 0; i <= n + 1; i++)
		for (int j = 0; j <= m + 1; j++)
			if(s[i][j] == '#')
				_left[i][j] = _right[i][j] = j, up[i][j] = down[i][j] = i;
	
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if(s[i][j] != '#') {
				_left[i][j] = _left[i][j - 1];
				up[i][j] = up[i - 1][j];
				
			}
	for (int i = n; i; i--)
		for (int j = m; j; j--)
			if(s[i][j] != '#') {
				_right[i][j] = _right[i][j + 1];
				down[i][j] = (s[i + 1][j] == '#'? i + 1: down[i + 1][j]);
				ans = max(ans, _right[i][j] - _left[i][j] - 1 + down[i][j] - up[i][j] - 1 - 1);
			}
	cout << ans;
	return 0;
}

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

void Main() {
    // input
    int S, W;
    cin >> S >> W;


    // translate


    // output
    if (W >= S) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
void marmot0814() {
    int n, k; cin >> n >> k;
    vector<int> arr(n);
    for (auto &v : arr)
        cin >> v;
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 1 ; i < n ; i++) {
        for (int j = 1 ; j <= k ; j++) {
            if (i - j < 0)
                break;
            dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
        }
    }
    cout << dp[n - 1] << '\n';
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t = 1, kase = 0; // cin >> t;
    while (t--) {
        // cout << "Case #" << ++kase << ":";
        marmot0814();
    }
}

Measured memory_bytes: 3972
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
map<string,int> tmp;
//int cc=0;
//#define edg(a,b) ((abs((a)-(b))==1))
int ask(string s)
{
	int r=0;
	for(int i=0;i<s.size();i++) r+=(s[i]=='1');
	if(r<=1) return 0;
	if(tmp.count(s)) return tmp[s];
	/*
	++cc; vi rp;
	for(int i=0;i<s.size();i++)
		if(s[i]=='1') rp.pb(i);
	if(rp.size()==2)
	return tmp[s]=edg(rp[0],rp[1]);
	if(rp.size()!=3) throw "RE";
	bool a=edg(rp[0],rp[1]),b=edg(rp[0],rp[2]),
	c=edg(rp[1],rp[2]);
	return tmp[s]=a+b+c;*/
	cout<<"? "<<s<<endl;
	int x; cin>>x; return tmp[s]=x;
}
int n,ff[SZ]; vector<int> vs[SZ],rs;
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
void uni(int a,int b)
{int ga=gf(a),gb=gf(b);if(ga^gb)ff[ga]=gb;}
int cnt()
{
	int ans=0; rs.clear();
	for(int i=1;i<=n;i++) vs[i].clear();
	for(int i=1;i<=n;i++)
	{
		vs[gf(i)].pb(i);
		if(gf(i)==i);else continue;
		++ans; rs.pb(i);
	}
	random_shuffle(rs.begin(),rs.end());
	for(int i=1;i<=n;i++)
		random_shuffle(vs[i].begin(),vs[i].end());
	return ans;
}
const int B=11;
vector<pii> es;
int ds[SZ];
bool cmp(int a,int b) {return ds[a]<ds[b];}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) vs[i].pb(i);
	for(int i=2;i<=n;i++)
	{
		vector<int> vs;
		for(int j=1;j<i;j++) vs.pb(j);
		sort(vs.begin(),vs.end(),cmp);
		vector<int> rs;
		for(int r=0;r<B;r++)
			for(int j=r;j<vs.size();j+=B) rs.pb(vs[j]);
		for(int j=0;j<rs.size();j+=B)
		{
			string s; s.resize(n);
			for(int i=0;i<n;i++) s[i]='0';
			for(int k=0;k<B&&j+k<rs.size();++k)
				s[rs[j+k]-1]='1';
			int a=ask(s); s[i-1]='1';
			int b=ask(s);
			if(a==b) continue;
			for(int k=0;k<B&&j+k<rs.size();++k)
			{
				for(int i=0;i<n;i++) s[i]='0';
				s[rs[j+k]-1]=s[i-1]='1';
				if(ask(s)==1)
					es.pb(pii(rs[j+k],i)),++ds[i];
			}
		}
	}
	cout<<"!";
	for(auto r:es) printf(" (%d,%d)",r.fi-1,r.se-1);
	puts("");
	//cerr<<cc<<"\n";
}


Measured memory_bytes: 19028
using System;

class Program
{
    public static void Main()
    {
        int taro = 0, hanako = 0;
        int n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; ++i)
        {
            string[] card = Console.ReadLine().Split(' ');
            int comp = string.Compare(card[0], card[1]);
            if (comp > 0) taro += 3;
            else if (comp < 0) hanako += 3;
            else
            {
                ++taro;
                ++hanako;
            }
        }
        Console.WriteLine("{0} {1}", taro, hanako);
    }
}


Measured memory_bytes: 16684
from collections import deque

k = int(input())
lunlun = []
q = deque([1,2,3,4,5,6,7,8,9])
while len(lunlun) <= k:
    first = q.popleft()
    lunlun.append(first)
    if first%10-1 >= 0:
        q.append(first*10 + (first%10-1))
    q.append(first*10 + first%10)
    if first%10+1 <= 9:
        q.append(10*first + (first%10+1))
print(lunlun[k-1])

Measured memory_bytes: 16596
#include<stdio.h>

int main(){
	int a,b,c,d;
	int e,f,x,y;
	int map[17][17];
	
	while(1){
	for(y=0;y<=16;y++){          
		for(x=0;x<=16;x++){
			map[x][y]=0;
		}
	}
	map[1][1]=1;
	scanf("%d %d",&a,&b);
	if(a==0 && b==0)break;
	scanf("%d",&c);
	for(d=0;d<c;d++){
		scanf("%d %d",&e,&f);
		map[e][f]=-1;	
	}
	for(y=1;y<=b;y++){          
		for(x=1;x<=a;x++){
			if(map[x][y]>-1){
				if(map[x-1][y]>0)map[x][y]+=map[x-1][y];
				if(map[x][y-1]>0)map[x][y]+=map[x][y-1];
			}
		}
	}
	printf("%d\n",map[a][b]);
	}
	return 0;
} 

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    cout << (A - 1) * (B - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
using namespace std;

int n,x;

bool isprime(long long x){
	if(x == 2) return true;
	if(x < 2 || x%2 == 0) return false;
	int i = 3;
	while(i*i<=x){
		if(x%i==0) return false;
		i += 2;
	}
	return true;
}

int main(){
	cin >> n;
	int count = 0;
	for(int i=0;i<n;i++){
		cin >> x;
		if(isprime(x)) count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3080
#include <stdio.h>

int gcd(int a, int b);

int main(void)
{
	double a, b, c, d, e, f;
	double x, y;
	
	while (scanf("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &e, &f) != EOF){
		y = (c * d - f * a) / (b * d - e * a);
		x = (c - b * y) / a;
		printf("%.3lf %.3lf\n", x, y);
	}
	
	return (0);
}

Measured memory_bytes: 652
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static long[] h = new long[100010];
	public static long[] dp = new long[100010];
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		IntStream.range(0, N).forEach((i) -> h[i] = in.nextLong()); 
		IntStream.range(0, 100010).forEach((i) -> dp[i] = Long.MAX_VALUE);
		
		// solve1(N);
		solve2(N);
	}
	
	private static void solve2(int N) {
		System.out.println(rec(N - 1));
	}
	
	private static long rec(int i) {
		if (dp[i] < Long.MAX_VALUE) return dp[i];
		if (i == 0) return 0;
		
		long cal1 = rec(i - 1) + Math.abs(h[i] - h[i - 1]);
		long cal2 = (i > 1) ? rec(i - 2) + Math.abs(h[i] - h[i - 2]) : Long.MAX_VALUE;
		long res = Math.min(cal1, cal2);
		
		return dp[i] = res;
	}
	
}


Measured memory_bytes: 72908
package main

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

var (
	N int
	A [3][3]int
	C [3][3]int
)

func main() {
	readVariables()
	for i := 0; i < N; i++ {
		call(nextInt())
	}
	answer := "No"
	for i := 0; i < 3; i++ {
		if row(i) {
			answer = "Yes"
		}
		if col(i) {
			answer = "Yes"
		}
	}
	if dg() {
		answer = "Yes"
	}
	fmt.Println(answer)
}

func row(i int) bool {
	cnt := 0
	for j := 0; j < 3; j++ {
		cnt += C[i][j]
	}
	return cnt == 3
}

func col(j int) bool {
	cnt := 0
	for i := 0; i < 3; i++ {
		cnt += C[i][j]
	}
	return cnt == 3
}

func dg() bool {
	x, y := 0, 0
	for i := 0; i < 3; i++ {
		x += C[i][i]
		y += C[i][2-i]
	}
	return x == 3 || y == 3
}

func call(b int) {
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if A[i][j] == b {
				C[i][j] = 1
			}
		}
	}
}

func readVariables() {
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			A[i][j] = nextInt()
		}
	}
	N = nextInt()
}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 640
import sys

N, H = [int(x) for x in sys.stdin.readline().strip().split()]
AB = [tuple(int(x) for x in sys.stdin.readline().strip().split()) for i in range(N)]
AB.sort(key=lambda x:(-x[0],x[1]))

p = AB[0][0]
qs = [AB[j][1] for j in range(N) if AB[j][1] > p]
qs.sort(key=lambda x:-x)
r = 0
for i in range(len(qs)):
    if H <= 0:
        break
    H -= qs[i]
    r += 1

if H > 0:
    r = r + (H + (p - 1)) // p

print(r)


Measured memory_bytes: 28264
#include <stdio.h>

int main(void)
{
    char c;
    int nj, ni, no;
    int level;
    int max_level;
    
    max_level = 0;
    nj = ni = no = 0;
    while (scanf("%c", &c) != EOF){
//printf("<%d %d %d>", nj, no, ni);
        if (nj == 0){
            if (c == 'J'){
                nj = 1;
            }
        }
        else if (no == 0){
            if (c == 'J'){
                nj++;
            }
            else if (c == 'O'){
                no = 1;
            }
            else {
                nj = 0;
            }
        }
        else if (ni == 0){
            if (c == 'J'){
                nj = 1;
                no = 0;
            }
            else if (c == 'O'){
                no++;
            }
            else if (c == 'I'){
                ni = 1;
            }
            else {
                nj = no = 0;
            }
        }
        else {
            if (c == 'I'){
                ni++;
            }
            else {
                if (ni >= no && nj >= no){
                    if (max_level < no){
                        max_level = no;
                    }
                }
                nj = no = ni = 0;
                if (c == 'J'){
                    nj = 1;
                }
            }
 
        }
    }
    if (nj >= no && ni >= no){
        if (max_level < no){
            max_level = no;
        }
    }

    printf("%d\n", max_level);
    
    return (0);
}

Measured memory_bytes: 540