akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

const int NMAX=1e4;
string s[NMAX];

int n,compteur[3],total=0;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		cin >> s[i];
	}
	
	for(int i=0;i<n;i++){
		
		int sz=s[i].size();
		
		for(int j=0;j<sz-1;j++){
			if(s[i][j]=='A' && s[i][j+1]=='B') total++;
		}
		
		if(s[i][0]=='B' && s[i][sz-1]=='A') compteur[0]++;
		else if(s[i][0]=='B') compteur[1]++;
		else if(s[i][sz-1]=='A') compteur[2]++;
	}
	if(compteur[0]>0 && compteur[1]>0){
		total++;
		compteur[1]--;
	}
	if(compteur[0]>0 && compteur[2]>0){
		total++;
		compteur[2]--;
	}
	if(compteur[0]>0) total+=compteur[0]-1;
	total+=min(compteur[1],compteur[2]);
	cout << total << '\n';
	
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    
    if (n==1){
      cout << m <<endl;
      exit(0);
    }
    for (int i=m/n;i>=1; i--){
        if( m%i==0&&n<=m/i){
            cout << i <<endl;
            exit(0);
          
        }
    }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(k)]
dp = [0 for i in range(n+1)]
mod = 998244353
lr.sort()
a = [0]*(n+1)
dp[0]=1; a[0]=1
for i in range(1,n+1):
    for l, r in lr:
        if i-l<0: continue
        elif i-l>=0 and i-r-1<0: dp[i]+=a[i-l]
        else: dp[i]+=a[i-l]-a[i-r-1]
    dp[i]%=mod
    a[i]=a[i-1]+dp[i]
    a[i]%=mod
print(dp[n-1]%mod)

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=1;
    for(int i=1; i<n; i++)
    {
        if(s[i]!=s[i-1])
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 512
using System.Linq; 
using static System.Console;
public static class Program {
  public static void Main(){
    var strs = ReadLine().Split(' ');
    var k = int.Parse(strs[1]);
    var values = ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x);
    var value = values.Take(k).Sum();
    WriteLine(value.ToString());
  }
}

Measured memory_bytes: 28728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
using P = pair <int,int>; //to, cost
using WeightedGraph = vector<vector <P>>; //to cost
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    cout<<(n+m-1)/m<<endl;
}

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

int main(){
	LL n;
	cin >> n;
	LL a[n];
	LL sum = 0;
	vector<int> d;
	vector<int> e;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++){
		sum ^= a[i];
		//cout << (a[i] & -a[i]) << endl;
		d.push_back(2*(a[i] & -a[i]) - 1);
		e.push_back((a[i] & -a[i]));
		//cout << (2*(a[i] & -a[i]) - 1) << endl;
	}
	LL ans = 0;
	sort(d.begin(), d.end());
	reverse(d.begin(), d.end());
	sort(e.begin(), e.end());
	reverse(e.begin(), e.end());
	//cout << sum << endl;
	for(int i = 0; i < d.size(); i++){
		//cout << d[i] << " " << e[i] << endl;
		if(sum & e[i]){
			sum ^= d[i];
			ans++;
		}
	}
	if(sum != 0){
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
}


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

int main() {
   int N, X, Y;
   cin >> N >> X >> Y;
   vector<int> v(N);
   for (int i = 0; i < N; i++) cin >> v[i];

   if (N >= 2) {
      cout << max( abs(v[N-1]-Y), abs(v[N-2]-v[N-1]) ) << endl;
   } else {
      cout << abs(v[0] - Y) << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> a;
	for (int i = 0; i < n; ++ i) {
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	LL l = 2, r = 1e18, ansl = -1;
	while (l <= r) {
		LL mid = (l + r) / 2;
		LL tmp = mid;
		for (int x : a) {
			tmp = tmp / x * x;
		}
		if (tmp >= 2) {
			if (tmp == 2) ansl = mid;
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	l = 2, r = 1e18; LL ansr = -1;
	while (l <= r) {
		LL mid = (l + r) / 2;
		LL tmp = mid;
		for (int x : a) {
			tmp = tmp / x * x;
		}
		if (tmp <= 2) {
			if (tmp == 2) ansr = mid;
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	if (ansl == -1) puts("-1"); else {
		printf("%lld %lld\n", ansl, ansr);
	}
}


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

int main() {
    vector<int> vec(10);
    for (int i=0;i<10;i++){
        cin>>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    cout<<vec.at(0)<<endl;
    cout<<vec.at(1)<<endl;
    cout<<vec.at(2)<<endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

ll N, a[100010];

ll solve(ll s){
    ll sum = a[0] + s, ans = abs(s);
    if(sum == 0) return LONG_LONG_MAX;
    FOR(i, 1, N){
        if(sum * (sum + a[i]) < 0){
            sum += a[i];
        }else{
            if(sum < 0){
                ans += 1 - (sum + a[i]);
                sum = 1;
            }else if(sum > 0){
                ans += 1 + (sum + a[i]);
                sum = -1;
            }
        }
    }
    return ans;
}

signed main(){
    cin >> N;
    REP(i, N) cin >> a[i];
    if(a[0] > 0){
        PRINT(min(solve(0), solve(-1 - a[0])));
    }else if(a[0] < 0){
        PRINT(min(solve(0), solve(1 - a[0])));
    }else{
        PRINT(min(solve(1), solve(-1)));
    }
    return 0;
}  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i = x; i < (int)(n); i++)
#define rep_ll(i,x,n) for(ll i = x; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0}; const int dy[] = {0, -1, 0, 1};
ll mod = 1000000007;
int main(){
    int a, b;
    cin >> a >> b;
    int aa=a+b;
    int ab=a-b;
    int bb=a*b;
    int ans=max(aa, ab);
    ans=max(ans, bb);
    cout << ans;
}

Measured memory_bytes: 3596
//51
#include<iostream>
#include<map>
#include<string>

using namespace std;

struct Cmp{
  bool operator()(string a,string b)const{
    if(a.size()!=b.size()){
      return a.size()<b.size();
    }else{
      return a<b;
    }
  }
};

int main(){
  int n;
  cin>>n;
  map<string,int,Cmp> m;
  while(n--){
    string k;
    int v;
    cin>>k>>v;
    m[k]+=v;
  }
  for(map<string,int,Cmp>::iterator it=m.begin();it!=m.end();it++){
    cout<<it->first<<' '<<it->second<<endl;
  }
  return 0;
}

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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto4
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); VI(as ,n);
  ll ans = 0;
  vector<int> v(n, n), is(n, n);
  vector<vector<int>> vv;
  REP(i, 20){
    int cnt = 1;
    vv.PB({n, n});
    REP(j, n, 0){
      if (((as[j] >> i) & 1) == 1){
        is[j] = min(is[j], vv[i][cnt]);
        vv[i].PB(j);
        cnt++;
      } else {
        is[j] = min(is[j], vv[i][cnt - 1]);
      }
    }
  }
  REP(i, n){
    ans += is[i] - i;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 10872
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

S = input()
N = len(S)

dp = [[0, 0] for _ in range(N+1)]
dp[1][0] = 1

for i in range(2, N+1):
	if S[i-1] != S[i-2]:
		dp[i][0] = dp[i-1][0] + 1

	dp[i][0] = max(dp[i][0], dp[i-1][1] + 1)
	dp[i][1] = dp[i-2][0] + 1

print(dp[-1][0])

Measured memory_bytes: 40784
main=do
 n<-getLine
 k<-readLn
 print$f n k
f n k
 |k==0=1
 |null n=0
 |head n=='0'=f(tail n)k
 |otherwise=(f(tail n)(k-1))+(f s(k-1))*(l-1)+f s k
  where s=map(const '9')$tail n
        l=subtract 48$fromEnum$head n

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	vector<char> s(3);
	rep(i, 3) {
		cin >> s[i];
	}
	int a_count = 0;
	int b_count = 0;
	int c_count = 0;
	rep(i, 3) {
		if (s[i] == 'a') {a_count++;}
		if (s[i] == 'b') {b_count++;}
		if (s[i] == 'c') {c_count++;}
	}
	if (a_count > 0 && b_count > 0 && c_count > 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

//BFS解答
int main(){
    int n, m; cin >> n >> m;
    vector<P> edge(m);

    rep(i,m){
        cin >> edge[i].first >> edge[i].second;
        edge[i].first--; edge[i].second--;
    }

    int ans = 0;
    rep(_,m){
        bool jud = false;
        vector<vector<int>> g(n, vector<int> (n,1002003004));
        rep(i,m){
            g[edge[i].first][edge[i].second] = 1;
            g[edge[i].second][edge[i].first] = 1;
        }
        g[edge[_].first][edge[_].second] = 1002003004;
        g[edge[_].second][edge[_].first] = 1002003004;

        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++)g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
            }
        }

        rep(i,n){
            rep(j,n){
                if(i == j) continue;
                if(g[i][j] == 1002003004){
                    jud = true;
                }
            }
        }

        g[edge[_].first][edge[_].second] = 1;
        g[edge[_].second][edge[_].first] = 1;
        if(jud)  ans++;
    }

    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  int I = 1;
  for (int i = 0; i < N; i++) {
    if (2 * I <= I + K)
      I *= 2;
    else
      I += K;
  }
  cout << I << endl;
}


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

#define dk23      ios_base :: sync_with_stdio(false);
#define inp       freopen("input.txt","r",stdin);
#define ll        long long

int main()
{
    dk23

    int k,n,i;
    cin>>k>>n;
    vector<int>vec(n);

    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());

    int dif=k-(vec[n-1]-vec[0]);

    for(i=1;i<n;i++){
        if(vec[i]-vec[i-1]>dif){
            dif=vec[i]-vec[i-1];
        }
    }

    cout<<k-dif<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define ceil(a, b) a / b + !!(a % b)
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

using P = complex<double>;
struct S { P p1, p2; };
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
const double eps = 1e-8;

double norm(P a) { return real(a) * real(a) + imag(a) * imag(a); }
double abs(P a) { return sqrt(norm(a)); }

int main() {
    double x1, y1, r1, x2, y2, r2;
    cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
    
    P p0 = P(x1, y1), p1 = P(x2, y2);
    
    if (abs(max(r1, r2) - min(r1, r2) - abs(p0 - p1)) < eps) cout << 1 << endl; // 内接
    else if (max(r1, r2) - min(r1, r2) - abs(p0 - p1) > eps) cout << 0 << endl; // 内包
    else if (abs(p0 - p1) < r1 + r2) cout << 2 << endl; // 交わる
    else if (abs(p0 - p1) == r1 + r2) cout << 3 << endl; // 外接
    else if (abs(p0 - p1) > r1 + r2) cout << 4 << endl; // 離れてる
    
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long inf = 1000000001; // const 書き換え禁止

int main(void){
    char s;
   cin >> s;

   if (isupper(s))
   {
       cout << 'A' << endl;
   }
   else
   {
       cout << 'a' << endl;
   }

   return 0;

}

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

int a[200005];
int b[200005];

int main()
{
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i){
        cin >> a[i];
    }
    sort(a, a + m);
    for(int i = 0; i < m - 1; ++i){
        b[i] = a[i + 1] - a[i];
    }

    sort(b, b + m);
    reverse(b, b + m);

    int sum = 0;
    for(int i = 0; i < n - 1; ++i){
        sum += b[i];
    }

    cout << a[m - 1] - a[0] - sum << "\n";
    return 0;
}


Measured memory_bytes: 1024
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;

const real eps = 1e-5;
void main() {
	int n = to!int(readln().chomp());
	while(n != 0) {
		Complex!real[] centor;
		for(int i; i < n; ++i){
			auto s = readln().strip().split(",");
			centor ~= complex(to!real(s[0]), to!real(s[1]));
		}
		Complex!real[] cross;
		for(int i; i < n; ++i){
			for(int j = i+1; j < n; ++j){
				if((centor[i]-centor[j]).abs()-2 < eps){
					auto m = (centor[i]+centor[j])/2;
					auto d = std.complex.expi((m-centor[i]).arg()+PI_2)*sqrt(1-pow((m-centor[i]).abs(),2));
					cross ~= m+d;
					cross ~= m-d;
				}
			}
		}
		int ans = 1;
		foreach(Complex!real c; cross) {
			int sum = 0;
			for(int i; i < n; ++i) {
				if((c-centor[i]).abs()-1 < eps)
					++sum;
			}
			ans = max(ans, sum);
		}
		writeln(ans);
		n = to!int(readln().chomp());
	}
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int gcd(int n, int m) {
	if(n < m) swap(n, m);
	if(n % m == 0) return m;
	return gcd(m, n % m);
}

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

int main() {
	int N; cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<int> left(N), right(N);
	for(int i = 0; i < N; i++) {
		if(i == 0) {
			left[0] = A[0];
			continue;
		}
		left[i] = gcd(left[i - 1], A[i]);
	}
	for(int i = N - 1; i >= 0; i--) {
		if(i == N - 1) {
			right[N - 1] = A[N - 1];
			continue;
		}
		right[i] = gcd(right[i + 1], A[i]);
	}
	int M = 0; 
	for(int i = 0; i < N; i++) {
		int G;
		if(i == 0) G = right[1];
		else if(i == N - 1) G = left[N - 2];
		else G = gcd(left[i - 1], right[i + 1]);
		M = max(M, G);
	}
	cout << M << endl;
	return 0;
}


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

int main() {
    int n;

    while (true) {
        cin >> n;
        if (!n) break;
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        for (int i = 1; i < n-1; ++i) {
            sum += a[i];
        }
        cout << sum/(n-2) << endl;
    }
}

Measured memory_bytes: 3044
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+5;
void FAST(){ios::sync_with_stdio(false);cin.tie(0);}
const ll mod =  1e9+7;

int n, m, k;
int a[N], b[N];
int ans;

void solve()
{
    scanf("%d%d%d", &k, &n, &m);
    if(n>m) swap(n, m);
    ans = (m/k*k);
    if(ans>=n&&ans<=m) puts("OK");
    else puts("NG");
}


int main()
{

//    int _; scanf("%d", &_); while(_--)
//    while(~scanf("%d", &n))
//    while(scanf("%d", &n)&&n)
    solve();
    return 0;
}


Measured memory_bytes: 3768
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	int n;
	int dp[64];
	dp[0] = 1; dp[1] = 1;

	cin >> n;
	for (int i = 2; i <= n; ++i) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <stdlib.h>
int compare ( const void *pa, const void *pb ) {
    const int *a = *(const int **)pa;
    const int *b = *(const int **)pb;
    if(a[0] == b[0])
        return a[1] - b[1];
    else
        return a[0] - b[0];
}

int main(){
  int *n = malloc(sizeof(int)), *m = malloc(sizeof(int));
  scanf("%d%d", n, m);

  int **s = malloc((*n) * sizeof(int *));
	for(int i = 0; i < *n; ++i){
    s[i] = malloc(2 * sizeof(int));
    scanf("%d%d", &s[i][0], &s[i][1]);
  }

  int **c = malloc((*m) * sizeof(int *));
  for(int i = 0; i < (*m); ++i){
    c[i] = malloc(2 * sizeof(int));
    scanf("%d%d", &c[i][0], &c[i][1]);
  }

  for(int j = 0; j < (*n); ++j){
    int **manhattan = malloc(*m * sizeof(int *));
    for(int i = 0; i < *m; ++i){
        manhattan[i] = malloc(2 * sizeof(int));
        manhattan[i][0] = abs(s[j][0] - c[i][0]) + abs(s[j][1] - c[i][1]);
        manhattan[i][1] = i+1;
    }

    qsort(manhattan,(*m),sizeof(manhattan[0]),compare);
    printf("%d\n", manhattan[0][1]);

    for(int i = 0; i < (*m); ++i) free(manhattan[i]);
    free(manhattan);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

template <typename T = long long>
struct BinaryIndexedTree_RangeAdd {
  vector<T> dat1;
  vector<T> dat2;
  BinaryIndexedTree_RangeAdd(int n) : dat1(n + 1, 0), dat2(n + 1, 0) {}
  void add_range(int l, int r, T w) {  // add w [l,r)
    for (int k = l + 1; k < (int)dat1.size(); k += k & -k) dat1[k] -= w * l;
    for (int k = r + 1; k < (int)dat1.size(); k += k & -k) dat1[k] += w * r;
    for (int k = l + 1; k < (int)dat2.size(); k += k & -k) dat2[k] += w;
    for (int k = r + 1; k < (int)dat2.size(); k += k & -k) dat2[k] -= w;
  }
  T sum(int x) {  // sum [0,x)
    T s = 0;
    for (int k = x; k > 0; k &= k - 1) s += dat1[k];
    for (int k = x; k > 0; k &= k - 1) s += dat2[k] * x;
    return s;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, D, A;
  cin >> N >> D >> A;
  BinaryIndexedTree_RangeAdd<long long> bit(N);
  vector<pair<long long, long long> > XH(N);
  for (int i = 0; i < N; i++) {
    cin >> XH[i].first >> XH[i].second;
  }
  sort(XH.begin(), XH.end());
  for (int i = 0; i < N; i++) {
    bit.add_range(i, i + 1, XH[i].second);
  }
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long tmp = bit.sum(i + 1) - bit.sum(i);
    if (tmp <= 0) continue;
    long long count = (tmp - 1) / A + 1;
    ans += count;
    int j = lower_bound(
                XH.begin(), XH.end(),
                pair<long long, long long>(XH[i].first + 2 * D + 1, -INT_MAX))
            - XH.begin();
    bit.add_range(i, j, -count * A);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    string s; cin >> s;

    ll ans = 0;
    int n  = s.size();


    vector<string> vs;
    for(int bit = 0; bit < (1<<(n-1)); bit++){
        vs.clear();
        string temp;
        for(int i=0; i<n-1; i++){
            temp += s[i];
            if(bit & (1<<i)){
                vs.push_back(temp);
                temp = "";
            }

            if(i == n-2){
                temp += s[i+1];
                vs.push_back(temp);
                temp = "";
            }
        }
        // cout << "i: " << bit << endl;
        // for(auto x : vs){
        //     cout << x << " ";
        // }
        // cout << endl;
        if(n == 1){
            vs.push_back(s.substr(0,1));
        }

        vector<ll> vnum;
        for(auto x : vs){
            vnum.push_back(stoll(x));
        }

        ans += accumulate(vnum.begin(), vnum.end(), 0LL);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#define LL long long
#define mk make_pair
#define pb push_back
#define pii pair<int, int>
#define ArrayDebug(a, l, r) for(int i = l; i <= r; ++i) printf("%d%c", a[i], (i==r)?'\n':' ')
const int maxn = 2e1+7;
const LL mod = 998244353;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int a[4][4], x;
int n;
int b[maxn], num[200];
int color[4][4];

int main()
{
    bool flag = false;
    for(int i = 1; i <= 3; ++i)
    for(int j = 1; j <= 3; ++j) {
        scanf("%d", &a[i][j]);
        num[a[i][j]]++;
    }
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &b[i]);
        for(int k = 1; k <= 3; ++k)
        for(int j = 1; j <= 3; ++j)
        if(a[k][j] == b[i])
            color[k][j] = 1;
    }
    for(int i = 1; i <= 3; ++i) {
        int j;
        for(j = 1; j <= 3; ++j) {
            if(!color[i][j]) break;
        }
        if(j > 3) {
            flag = true;
            break;
        }
    }
    for(int i = 1; i <= 3; ++i) {
        int j;
        for(j = 1; j <= 3; ++j) {
            if(!color[j][i]) break;
        }
        if(j > 3) {
            flag = true;
            break;
        }
    }
    if(color[1][1] && color[2][2] && color[3][3]) flag = true;
    if(color[1][3] && color[2][2] && color[3][1]) flag = true;
    if(flag) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 888
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define A (0)
#define O (1)
#define X (2)
#define PRINT_FLAG(x) for(int i = 0; i < 4; i++)printf("%d", ((x) >> i) & 1); puts("");

typedef struct tree {
	int point;
	unsigned int flag;
	struct tree *right;
	struct tree *left;
} TREE;

int input_tree(TREE *root, char str[], int i);
int set_flag(TREE *root, int point, unsigned int flag);
int make_num(int depth, int num, int max_depth, TREE *root);
unsigned int check_tree(TREE *root, int *mode_list, bool flag);


int input_count;
int ans;
int leaf_count;

int main(void)
{
	TREE root;
	char str[100];
	
	while (1){
		leaf_count = 0;
		ans = 0;
		root.right = root.left = NULL;
		input_count = 0;
		
		fgets(str, 100, stdin);
		if (str[0] == 'E'){
			break;
		}
		
		input_tree(&root, str, 0);
		scanf("%d", &input_count);
		if (input_count == 0){
			continue;
		}
		for (int i = 0; i < input_count; i++){
			unsigned flag = 0;
			for (int j = 0; j < 4; j++){
				unsigned int flag_;
				scanf("%u", &flag_);
				
				flag |= flag_ << j;
			}
			
			set_flag(&root, i, flag);
		}
		
		make_num(0, 0, leaf_count - 1, &root);
		
		printf("%d\n", ans);
		
	}
	return (0);
}

int input_tree(TREE *root, char str[], int i)
{
	while (1){
		if (str[i] == '\0'){
			return (i);
		}
		
		if (str[i] == '('){
			root->right = (TREE *)malloc(sizeof(TREE));
			root->left = (TREE *)malloc(sizeof(TREE));
			
			root->right->right = root->right->left = root->left->right = root->left->left = NULL;
			i = input_tree(root->left, str, i + 1);
			i = input_tree(root->right, str, i + 1);
			return (i);
		}
		if (str[i] >= '1' && str[i] <= '9'){
			leaf_count++;
			root->point = str[i] - '0' - 1;
			return (i);
		}
		i++;
	}
}

int make_num(int depth, int num, int max_depth, TREE *root)
{
	if (depth == max_depth){
		bool flag = false;
		
		if (check_tree(root, &num, flag) == 0xf){
			ans++;
		}
		return (0);
	}
	
	for (int i = A; i <= X; i++){
		int temp = num * 10;
		temp += i;
		make_num(depth + 1, temp, max_depth, root);
	}
	
	return (0);
}

unsigned int check_tree(TREE *root, int *mode_list, bool flag)
{
	unsigned int ans_flag;
	
	if (root->left == NULL){
		return (root->flag);
	}
	else {
		unsigned int flag1 = check_tree(root->left, mode_list, flag);
		unsigned int flag2 = check_tree(root->right, mode_list, flag);
		
		if (flag)printf("%d\n", *mode_list % 10);
		switch (*mode_list % 10){
		  case 0:
		  	ans_flag = (flag1 & flag2);
			break;
		  case 1:
		  	ans_flag = (flag1 | flag2);
			break;
		  case 2:
		  	ans_flag = (flag1 ^ flag2);
			break;
		}
		*mode_list /= 10;
	}
	
	if (flag){
		PRINT_FLAG(ans_flag);
	}
	
	return (ans_flag);
}

int set_flag(TREE *root, int point, unsigned int flag)
{
	if (root == NULL){
		return (0);
	}
	set_flag(root->left, point, flag);
	set_flag(root->right, point, flag);
	
	
	if (root->point == point){
		root->flag = flag;
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int n,m;
    cin>>n>>m;
    vector<long long> x(n),y(n),z(n),sum(n);
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i];
    long long ans=0;

    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                for(int l=0;l<n;l++)sum[l]=x[l]*pow(-1,i)+y[l]*pow(-1,j)+z[l]*pow(-1,k);
                sort(sum.begin(),sum.end(),greater<long long>());
                long long tmp=0;
                for(int p=0;p<m;p++)tmp+=sum[p];
                ans=max(ans,tmp);
            }
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int f(vs s, int t){
    int i;
    rep(i,s[t].size())if(s[t][i]!='.')break;
    if(isdigit(s[t][i])) return s[t][i] - '0';

    if(s[t][i] == '+'){
        int ret = 0;
        int j = t+1;
        while(s.size() > j && s[j].size() > i+1){
            if(s[j][i+1] != '.'){
                ret += f(s, j);
            }
            j++;
        }
        return ret;
    }else{
        int ret = 1;
        int j = t+1;
        while(s.size() > j && s[j].size() > i+1){
            if(s[j][i+1] != '.'){
                ret *= f(s, j);
            }
            j++;
        }
        return ret;
    }
}

int main(void) {
    int i,j;
    int n;
    while(cin >> n, n){
        vs s(n);
        rep(i,n) cin >> s[i];
        cout << f(s, 0) << endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, N) for (ll i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int main()
{
    int n;
    while (cin >> n, n)
    {
        vector<string> s(n);
        rep(i, n) cin >> s[i];
        int al[26] = {}, v[26] = {}, cnt = 0;
        bool Top[26] = {};
        rep(i, 26) al[i] = -1;
        rep(i, n)
        {
            if (s[i].size() != 1)
                Top[s[i][0] - 'A'] = true;
            int tmp = 1;
            for (int j = s[i].size() - 1; j >= 0; j--)
            {
                if (al[s[i][j] - 'A'] == -1)
                    al[s[i][j] - 'A'] = cnt++;
                if (i != n - 1)
                    v[s[i][j] - 'A'] += tmp;
                else
                    v[s[i][j] - 'A'] -= tmp;
                tmp *= 10;
            }
        }
        int ans = 0;
        vector<int> perm(10);
        rep(i, 10) perm[i] = i;
        do
        {
            vector<int> tmp;
            for (int i = cnt; i < 10; i++)
                tmp.push_back(perm[i]);
            reverse(ALL(tmp));
            for (int i = cnt; i < 10; i++)
                perm[i] = tmp[i - cnt];
            bool f = false;
            int sum = 0;
            rep(i, 26)
            {
                if (al[i] == -1)
                    continue;
                int a = perm[al[i]];
                if (Top[i] && a == 0)
                {
                    f = true;
                    break;
                }
                sum += a * v[i];
            }
            if (!f && sum == 0)
                ans++;

        } while (next_permutation(ALL(perm)));
        cout << ans << endl;
    }
}



Measured memory_bytes: 3212
#include<stdio.h>

int main(void) {

	double r, are, circ;

	scanf("%lf", &r);

	are = r*r*3.141592653589;
	
	circ = 2 * r*3.141592653589;

	printf("%f %f\n", are, circ);

	
	return(0);

}


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

namespace D2019PC2
{
    class B
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] X = new int[N];
            int[] Y = new int[N];
            for (int i = 0; i < N; i++)
            {
                int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                X[i] = input[0];
                Y[i] = input[1];
            }

            Dictionary<string, int> dict = new Dictionary<string, int>();
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < N; j++)
                {
                    if (i != j)
                    {
                        string xy = (X[j] - X[i]).ToString() + (Y[j] - Y[i]).ToString();
                        if (!dict.ContainsKey(xy)) { dict.Add(xy, 1); }
                        else dict[xy]++;
                    }
                }
            }

            int res = int.MaxValue;

            if (N == 1) { Console.WriteLine(1); return; }

            foreach (var i in dict)
            {
                res = Math.Min(res, N - i.Value);
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long
#define MAX 200005
#define MOD 1000000007
using namespace std;

ll modpow(ll a, ll b)
{
    if (b == 0) return 1;
    ll u = modpow(a, b / 2);
    u = (u * u)%MOD;
    if (b%2) u = (a * u)%MOD;
    return u;
}

int n;
vector<int> ad[MAX];
ll ans[MAX], sz[MAX];

void dfs(int s, int f)
{
    sz[s] = 1;
    for (auto nd:ad[s]) {
        if (nd != f) {
            dfs(nd, s);
            sz[s] += sz[nd];
        }
    }
    ans[1] = ans[1] * modpow(sz[s], MOD - 2)%MOD;
}

void dfs2(int s, int f)
{
    for (auto nd:ad[s]) {
        if (nd != f){
            ans[nd] = (ans[s] * sz[nd])%MOD * modpow(n - sz[nd], MOD - 2)%MOD;
            dfs2(nd, s);
        }
    }
}

int main()
{
    cin >> n;
    int a, b;
    ans[1] = 1;
    for (int i = 2; i <= n; i++) ans[1] = (ans[1]%MOD) * (i%MOD) % MOD;
    for (int i = 1; i <= n - 1; i++) {
        cin >> a >> b;
        ad[a].push_back(b);
        ad[b].push_back(a);
    }
    dfs(1, -1);
    dfs2(1, -1);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << "\n";
    }
}


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

using namespace std;

int main()
{
    long long int h1,h2,m1,m2,k,i;
    cin>>h1>>m1>>h2>>m2>>k;
    if(h2>=h1)
    {
        i=(h2-h1)*60+m2-m1;
        if(i>=k)
            cout<<i-k;
        else
            cout<<"0";
    }
    else
    {
        i=(24-h1)*60-m1+h2*60+m2;
        if(i>=k)
            cout<<i-k;
        else
            cout<<"0";
    }



return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,m;
    cin >> n>>m;
    if(n == 1 && m == 1)cout << 1 << endl;
    else if(n == 1)cout << m-2 << endl;
    else if(m == 1)cout << n-2 << endl;
    else cout << (n-2)*(m-2) << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
lists1=sorted(list(map(int,input().split())))+[10**9+1]

lists2=sorted(list(map(int,input().split())))+[10**9+2]
lists3=sorted(list(map(int,input().split())))+[10**9+3]
lists_small=[0]*(n+1)
lists_big=[0]*(n+1)

numbers=0
for x in range(n):
    while lists1[numbers]<lists2[x]:
        numbers+=1
    lists_small[x]=numbers


numberss=0
for y in range(n):
    while lists3[numberss]<=lists2[y]:
        numberss+=1
    changes=n-numberss
    lists_big[y]=changes



ans=0
for xy in range(n):
    ans+=lists_big[xy]*lists_small[xy]
print(ans)

Measured memory_bytes: 23672
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    int n,m;
    cin>>n>>m;
    vector<int>d(m+1);
    for(int i=1;i<=m;i++)
        cin>>d[i];
    int dp[21][50001];
    for(int i=0;i<=m;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]=0;
    for(int i=1;i<=n;i++)
        dp[0][i]=999999;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){

            if(j>=d[i])
                dp[i][j]=min(dp[i-1][j],dp[i][j-d[i]]+1);
            else
                dp[i][j]=dp[i-1][j];
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[m][n]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




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

using namespace std;
using ll = long long;

int main() {
    ll n, x; cin >> n >> x;
    ll a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    ll ans = 0;
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }

    for (int i = 1; i < n; i++) {
        ll s = a[i - 1] + a[i];
        if (s <= x) continue;
        ll d = s - x;
        a[i] -= d;
        ans += d;
    }

    cout << ans << endl;
}

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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator++() noexcept
    {
        val++;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp operator++(int) noexcept
    {
        Fp temp = *this;
        ++*this;
        return temp;
    }
    constexpr Fp &operator--() noexcept
    {
        val--;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp operator--(int) noexcept
    {
        Fp temp = *this;
        --*this;
        return temp;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
};

template <int MOD>
constexpr Fp<MOD> powmod(const Fp<MOD> &a, long long n) noexcept
{
    if (n == 0)
        return 1;
    if (n % 2 == 1)
        return a * powmod(a, n - 1);
    Fp<MOD> pwmd = powmod(a, n / 2);
    return pwmd * pwmd;
}

using mint = Fp<1000000007>;

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

    // 10^n - 2*9^n + 8^n
    mint ans = powmod((mint)10, n) - (mint)2 * powmod((mint)9, n) + powmod((mint)8, n);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3672
def main():
    N, X = map(int, input().split())

    m = []
    for i in range(N):
        m.append(int(input()))

    m.sort()

    ans = 0
    for i in m:
        if X - i < 0:
            print(ans)
            return
        X -= i
        ans += 1

    ans += X // m[0]
    print(ans)

main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  for(auto&& e: s) 
  {
    cin>>e;
  }
  sort(s.begin(), s.end());
  for(auto&& e: s) 
  {
    cout<<e;
  }
  cout<<endl;
}

Measured memory_bytes: 3620
main :: IO ()
main = interact $ format . solve . parse

parse :: String -> (Int, Int)
parse input = (h, a) where
    [h, a] = map read . words . head . lines $ input

solve :: (Int, Int) -> Int
solve (h, a) = - ((-h) `div` a)

format :: Int -> String
format = (++ "\n") . show


Measured memory_bytes: 508
def main():
    N = int(input())
    ans = "No"
    for i in range(1, 10):
        x = N // i
        y = N % i
        if 0 < x < 10 and y == 0:
            ans = "Yes"
            break
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A+B>C+D) cout << "Left\n";
    else if (A+B==C+D) cout << "Balanced\n";
    else cout << "Right\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string a,b,c; cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<'\n';
	return 0;
}















Measured memory_bytes: 256
while(true) do
  set = gets()
  if (set.nil? or set == "\n" or set == "\n\r") then break end
  a, b = set.split().map{|x| x.to_i}
  yakusu = Array.new()

  (2..9).each do |n|
    while(true) do
      if a % n != 0 || b % n != 0 then
        break
      end
      yakusu.push(n)
      a = a / n
      b = b / n
    end
  end
  saidai = 1
  yakusu.each do |y|
    saidai = saidai * y
  end
  puts "#{saidai} #{saidai * a * b}"
end

Measured memory_bytes: 6104