akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,n;
	cin>>n;
	int a[n];
	int first=0,second=0;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	for(i=n-1;i>0;i--){
		if(a[i]==a[i-1]){
			if(first==0){
				first=a[i];
			}
			else{
				second=a[i];
				break;
			}
			i--;
		}
	}
	
	cout<<(ll)first*second<<endl;
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 640
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <vector>
# include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include <iostream>
using namespace std;
const int N=10;
int i,j;
int main()
{

    char a[N][N];
    for(i=1; i<3; i++)
    {
        for(j=1; j<4; j++)
        {
            scanf("%c",&a[i][j]);
        }
        getchar();
    }
    if(a[1][1]==a[2][3]&&a[1][2]==a[2][2]&&a[1][3]==a[2][1])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");

    }



    return 0;
}

Measured memory_bytes: 256
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/PCK/Prelim/0362?year=2017

#include <bits/stdc++.h>

using namespace std;

bool solve(const vector<int> &vt) {
    int cur = 0;
    for (int i = 0; i < vt.size(); ++i) {
        if (cur < i) return false;
        cur = max(cur, vt[i] + i);
    }
    return true;
}

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

    vector<int> fwd;//行き
    for (int i = 0; i < n; ++i) {
        int t;
        cin >> t;
        fwd.emplace_back(t / 10);//いくつ先のトランポリンまで行けるか
    }

    vector<int> bwd;//帰り
    bwd = fwd;
    reverse(bwd.begin(), bwd.end());

    if (solve(fwd) && solve(bwd)) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
    return 0;
}

/*
 * 距離が短いトランポリンも一応踏んで
 * cur = max(cur, vt[i] + i)
 * で現在位置を更新していく。
 *
 */


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a <= c && c <= b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    char N;
    cin >> N;
    char ans ='A';
    if(N>='a' && N <='z'){
      ans = 'a';
    }
    printl(ans);
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n,a,b;
	vector<int> array;
	
	cin>>n;
	
	for(int i=0;i<n;++i)
	{
		cin>>a;
		array.push_back(a);	
	}
	
	int flag=1,count=0;
	
	while(flag)
	{
	flag = 0;
	int k = 0;	
	for( ; k < n-1 ; ++k )
	{
		if( array[k] > array[k+1] )
		{
			int temp=0;
			temp = array[k];
			array[k] = array[k+1];
			array[k+1] = temp;
			count++; 
			flag=1;
		}
	}
		
	}
	
	for(int i=0;i<n;++i)
	{
		if(i<n-1)
		cout<<array[i]<<" ";
		else
		cout<<array[i]<<endl;

	 } 
	 cout<<count<<endl; 
	return 0;
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cout << setprecision(10) << fixed;
	int n;
	cin >> n;
	long long mn1 = INT64_MAX, mx1 = INT64_MIN, mn2 = INT64_MAX, mx2 = INT64_MIN;
	for (int i = 0; i < n; ++i)
	{
		long long a, b;
		cin >> a >> b;
		mx1 = max(a + b, mx1);
		mn1 = min(a + b, mn1);
		mn2 = min(a - b, mn2);
		mx2 = max(a - b, mx2);
	}
	cout << max((mx1 - mn1), (mx2 - mn2)) << '\n';
}

Measured memory_bytes: 3628
class Vector:

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def move(self, offset):
        self.x += offset[0]
        self.y += offset[1]

    def move_offset(self, offset, multiple=1):
        x = self.x + offset[0] * multiple
        y = self.y + offset[1] * multiple
        return Vector(x, y)


class Pattern:
    NOTHING = " "
    EXIST = "#"
    SENTINEL = "?"

    MOVE = [
        [[-1, -1], [-1, +0], [-1, +1]],
        [[-1, +1], [-0, +1], [+1, +1]],
        [[+1, +1], [+1, +0], [+1, -1]],
        [[+1, -1], [+0, -1], [-1, -1]],
    ]

    @classmethod
    def create_area(cls, size):
        area = [[cls.SENTINEL] * 2 + [cls.NOTHING] * size + [cls.SENTINEL] * 2 for _ in range(size)]
        tmp = [[cls.SENTINEL] * size + [cls.SENTINEL] * 2 * 2]
        area = tmp * 2 + area + tmp * 2
        return area

    @classmethod
    def even_spiral_pattern(cls, area, point):
        move_index = 0
        area[point.x][point.y] = cls.EXIST

        while True:

            left, center, right = cls.MOVE[move_index]
            end1, end2 = point.move_offset(left), point.move_offset(right)
            offset, offset2 = point.move_offset(center), point.move_offset(center, 2)

            if area[end1.x][end1.y] == cls.EXIST or area[end2.x][end2.y] == cls.EXIST:
                return area
            elif area[offset.x][offset.y] == cls.NOTHING and area[offset2.x][offset2.y] != cls.EXIST:
                point.move(center)
                area[point.x][point.y] = cls.EXIST
            else:
                move_index += 1
                move_index %= 4

    @classmethod
    def odd_spiral_pattern(cls, area, point):
        move_index = 0
        is_end = False
        area[point.x][point.y] = cls.EXIST

        while True:

            left, center, right = cls.MOVE[move_index]
            offset, offset2 = point.move_offset(center), point.move_offset(center, 2)

            if area[offset.x][offset.y] == cls.NOTHING and area[offset2.x][offset2.y] != cls.EXIST:
                point.move(center)
                area[point.x][point.y] = cls.EXIST
                is_end = False
            else:
                if is_end:
                    return area
                else:
                    is_end = True

                move_index += 1
                move_index %= 4

    @classmethod
    def formater(cls, area):
        output = ["".join(item[2:-2]) for item in area[2:-2]]
        output = "\n".join(output)
        return output

    @classmethod
    def solve(cls, size):
        area = cls.create_area(size)
        point = Vector(size - 1 + 2, 2)

        if size % 2 == 0:
            result = cls.even_spiral_pattern(area, point)
        else:
            result = cls.odd_spiral_pattern(area, point)

        return cls.formater(result)


sizes = [int(input()) for _ in range(int(input()))]
results = [Pattern.solve(num) for num in sizes]
print("\n\n".join(results))



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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

void dec(map<long long, long long, greater<ll>> &ma, long long a) {
    ma[a]--;
    if (ma[a] == 0) {
        ma.erase(a);
    }
}

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    map<ll, ll, greater<ll> > ma;
    for (int i = 0; i < N; ++i) ma[a[i]]++;

    ll ans = 0;
    for (int i = 0; i < N && !ma.empty(); ++i) {
        ll val = ma.begin()->first;
        dec(ma, val);
        ll po = 1;
        while (po <= val) po *= 2;
        ll rem = po - val;
        if (ma.count(rem)) {
            ++ans;
            dec(ma, rem);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >>n;


  ll ans=0;
  map<pair<int,int>, ll> pa;
  rep1(i,n){
    int a=i;
    int pw=-1;
    while(a>0){
      a/=10;
      pw++;
    }
    int tt = i%10;
    int tb = i/pow(10,pw);
    if(tb==0 || tt ==0) continue;
    //    cout << tt << " "<< tb << endl;
    //    if(tt<tb) swap(tt,tb);
    pa[mp(tb,tt)]++;    
  }
  for(auto i:pa){
    //        cout << i.first.first << " " << i.first.second << " " <<i.second << endl;
    if(i.first.first==i.first.second) ans += i.second*(i.second);
    else{
      ll tmp = pa[mp(i.first.second,i.first.first)];
      ans += i.second*tmp;
    }
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main implements Runnable{
    
    private void solve()throws IOException{
        int n=nextInt();
        int k=nextInt();
        int s=nextInt();
        if(s==(int)(1e9))
        {
            for(int i=1;i<=k;i++)
                out.print(s+" ");
            for(int i=1;i<=n-k;i++)
                out.print(1+" ");
        }
        else
        {
            for(int i=1;i<=k;i++)
                out.print(s+" ");
            for(int i=1;i<=n-k;i++)
                out.print((int)(1e9)+" ");
        }
    }

     
    ///////////////////////////////////////////////////////////

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 35504
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	
	int n,m;
	cin >> n >> m;
	vll a(n);
	rep(i,n)cin >> a[i];
	int cnt = 0;
	rep(i,n){
		cnt += a[i];
	}
	int cnt2 = 0;
	rep(i,n){
		if(a[i]*4*m >= cnt)cnt2++;
	}
	if(cnt2 >= m)cout << "Yes" << endl;
	else cout << "No" << endl;


	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc161.contest.atcoder.jp/tasks/abc161_b

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int m = s.nextInt();
		System.out.println(((n)*(n-1))/2 + ((m)*(m-1))/2);
	}
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a,b,c;
  scanf("%ld %ld %ld",&a,&b,&c);
  if (a<b&&c<b) {
    printf("%d",a+c);
  }else if(b<a&&c<a){
    printf("%d\n",b+c);
  }else{
    printf("%d\n",a+b);
  }

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
    #define il inline
    #define vd void
    typedef long long ll;
    il ll gi(){
    	ll x=0,f=1;
    	char ch=getchar();
    	while(!isdigit(ch))f^=ch=='-',ch=getchar();
    	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    	return f?x:-x;
    }
    int n,p[200010];
    int f[2][200010],ismx[200010];
    struct segtree{
    #define mid ((l+r)>>1)
    	int rt[200010],ls[6000010],rs[6000010],mx[6000010],cnt;
    	il vd update(int&x,int l,int r,const int&p,const int&d){
    		++cnt;ls[cnt]=ls[x],rs[cnt]=rs[x],mx[cnt]=mx[x];x=cnt;
    		if(l==r){mx[x]=d;return;}
    		if(d>mx[x])mx[x]=d;
    		if(p<=mid)update(ls[x],l,mid,p,d);
    		else update(rs[x],mid+1,r,p,d);
    	}
    	il int query(int x,int l,int r,const int&L){
    		if(L<=l)return mx[x];
    		if(L<=mid)return std::max(query(ls[x],l,mid,L),query(rs[x],mid+1,r,L));
    		else return query(rs[x],mid+1,r,L);
    	}
    #undef mid
    }T0,T1;
    char ans1[200010],ans2[200010];
    il int Query(int c,int l,int p){
    	if(l>n)return c?-1e9:0;
    	if(!c)return T0.query(T0.rt[l],1,n,p);
    	else return T1.query(T1.rt[l],1,n,p);
    }
    int main(){
    #ifdef XZZSB
    	freopen("in.in","r",stdin);
    	freopen("out.out","w",stdout);
    #endif
    	n=gi();
    	for(int i=1;i<=n;++i)p[i]=gi();
    	int la1=0,lb1=0,la2=0,lb2=0,mxa1=0,mxa2=0,mxb1=0,mxb2=0,rest=0;
    	for(int i=1,mx=0;i<=n;++i)if(p[i]>mx)mx=p[i],ismx[i]=1,++rest;
    	memset(T1.mx,-63,sizeof T1.mx);
    	for(int i=n;i;--i){
    		T0.rt[i]=T0.rt[i+1];T1.rt[i]=T1.rt[i+1];
    		if(ismx[i])f[0][i]=T0.query(T0.rt[i],1,n,p[i])+2,f[1][i]=T1.query(T1.rt[i],1,n,p[i])+2;
    		else f[0][i]=T1.query(T1.rt[i],1,n,p[i])+1,f[1][i]=T0.query(T0.rt[i],1,n,p[i])+1;
    		T0.update(T0.rt[i],1,n,p[i],f[0][i]);T1.update(T1.rt[i],1,n,p[i],f[1][i]);
    	}
    	auto adda1=[&](int x){if(x>mxa1)++la1,mxa1=x;};
    	auto adda2=[&](int x){if(x>mxa2)++la2,mxa2=x;};
    	auto addb1=[&](int x){if(x>mxb1)++lb1,mxb1=x;};
    	auto addb2=[&](int x){if(x>mxb2)++lb2,mxb2=x;};
    	for(int i=1;i<=n;++i){
    		int c=la1+rest-lb1+(p[i]>mxa1)-ismx[i];
    		if(c>=0&&Query(c&1,i+1,mxb1)>=c)ans1[i]='0',adda1(p[i]);
    		else ans1[i]='1',addb1(p[i]);
    		c=la2+rest-lb2-(p[i]>mxb2)-ismx[i];
    		if(c>=0&&Query(c&1,i+1,std::max(p[i],mxb2))>=c)ans2[i]='0',addb2(p[i]);
    		else ans2[i]='1',adda2(p[i]);
    		if(ismx[i])--rest;
    	}
    	if(la1==lb1&&la2==lb2){
    		if(strcmp(ans1+1,ans2+1)<0)printf("%s",ans1+1);
    		else printf("%s",ans2+1);
    	}else if(la1==lb1)printf("%s",ans1+1);
    	else if(la2==lb2)printf("%s",ans2+1);
    	else puts("-1");
    	return 0;
    }
     

Measured memory_bytes: 111360
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=ja
from bisect import bisect_left
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())

    LIS = [A[0]]
    for a in A:
        if a > LIS[-1]:
            LIS.append(a)
        else:
            LIS[bisect_left(LIS, a)] = a

    ans = len(LIS)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,A;
  cin >> N >> A;
  vi x(N);
  int X = -INF;
  rep(i,N) {
    cin >> x[i];
    X = max(X,x[i]);
    x[i] -= A;
  }

  vl dp(2*N*X,0);
  dp[N*X] = 1;
  rep(i,N) {
    vl dp2(2*N*X,0);
    int c = x[i];
    rep(j,2*N*X) {
      dp2[j] = dp[j-c]+dp[j];
    }
    dp = dp2;
  }
  cout << dp[N*X]-1 << endl;
  return 0;
}

Measured memory_bytes: 384
from fractions import gcd
k=int(input())
l=[]
dp=[[0]*(k+1) for i in range(k+1)]

for i in range(1,k+1):
    for j in range(1,k+1):
        dp[i][j]=gcd(i,j)
        l.append(gcd(i,j))
sum=0
for x in range(1,k+1):
    for y in range(len(l)):
        sum += int(dp[l[y]][x])
print(sum)

Measured memory_bytes: 11164
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, a, b) = (v[0], v[1], v[2]);
    let set_num = n / (a + b);
    let res = (n - set_num * (a + b));
    println!("{}", set_num * a + min(a, res));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
	int a, b;
	char x;
	
	scanf("%d %d", &a, &b);

	while(a--){
		scanf(" %c", &x);
		if(x < '0' || x > '9'){
			printf("No");
			return 0;
		}
	}
	scanf(" %c", &x);
	if(x != '-'){
		printf("No");
		return 0;
	}
	while(b--){
		scanf(" %c", &x);
		if(x < '0' || x > '9'){
			printf("No");
			return 0;
		}
	}
	
	printf("Yes");
	
	return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;


int main() {
    Int n;
    cin >> n;
    vector<Int> a(n), p(n), q(n);
    for (Int i = 1; i <= n; i++) {
        a[i - 1] = i;
    }
    for (Int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (Int i = 0; i < n; i++) {
        cin >> q[i];
    }
    Int c, d;
    c = d = -1;
    Int cnt = 0;
    while (next_permutation(all(a))) {
        bool check = true;
        for (Int i = 0; i < n; i++) {
            if (a[i] != p[i]) {
                check = false;
            }
        }
        if (check) {
            c = cnt;
        }
        check = true;
        for (Int i = 0; i < n; i++) {
            if (a[i] != q[i]) {
                check = false;
            }
        }
        if (check) {
            d = cnt;
        }
        cnt++;
    }   

    dump(abs(c - d));
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0 for j in range(2)] for i in range(M)]

for i in range(M):
    X,L=map(int,input().split())
    S[i][0]=X
    S[i][1]=L


T=sorted(S,key=lambda x:x[1])
#U=sorted(T,key=lambda x:x[1])



count=1
last=T[0][1]
#print(T)
for i in range(1,M):
    if T[i][0]>=last:
        count+=1
        last=T[i][1]
print(count)



Measured memory_bytes: 27892
s = input()

lst = ['dreameraser', 'dreamerase', 'dreamer', 'dream', 'eraser', 'erase']
while s:
  flag = 0
  for elem in lst:
    if elem in s:
      s = s.replace(elem, '')
      flag = 1
      break
  if flag == 0:
    print('NO')
    quit()
print('YES')

Measured memory_bytes: 3188
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextIntSlice(size int) []int {
	re := make([]int, size)
	for i := 0; i < size; i++ {
		re[i] = nextInt()
	}
	return re
}

func main() {
	//sc.Split(bufio.ScanWords)
	s := nextLine()

	for i := 1; i < len(s); i++ {
		t := s[0 : len(s)-i]
		if len(t)%2 != 0 {
			continue
		}
		u := t[0 : len(t)/2]
		if t == strings.Repeat(u, 2) {
			fmt.Println(len(t))
			return
		}
	}
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin>>s;

    int l=s.length();

    int a=INF;
    int z=0;
    rep(i,l){
        if(s[i] == 'A')chmin(a,i);
        if(s[i] == 'Z')chmax(z,i);
    }

    cout<< z-a+1 <<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 640
def main():
    import sys
    input = sys.stdin.readline

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

    inf = float("inf")
    dp = [inf]*N

    dp[0] = 0

    for i in range(N-1):
        for j in range(1, min(K+1, (N-i))):
            dp[i+j] = min(dp[i+j], abs(H[i+j]-H[i]) + dp[i])
    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 54876
#include<bits/stdc++.h>
using namespace std;
int n;
int h[100005];
long long dp[100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    for(int i=0;i<n;i++)
    {
        dp[i]=999999999999999;
    }
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<i+3;j++)
        {
            dp[j]=min(dp[i]+abs(h[j]-h[i]),dp[j]);
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1408
N=input()
W=[]
for i in range(N):
    a=raw_input()
    if i==0:
        W.append(a)
        continue
    if a not in W and a[0]==W[-1][-1]:
        W.append(a)
    else:
        print "No"
        break
if len(W)==N:
    print "Yes"
        

Measured memory_bytes: 2568
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    a[i] = temp;
  }

  sort(a.begin(), a.end());
  int sum = 0;
  for(int i = 0; i < n-1; i++){
    sum += a[i];
  }

  if(sum > a[n-1]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 13;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    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 {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= 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 {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    int L = S.size();

    vector<vector<ll> > dp(L + 1, vector<ll>(mod));
    dp[0][0] = 1;

    for (int i = 0; i < L; i++) {
        mint pow10 = 10;
        ll n = L - 1 - i;
        pow10 = pow10.pow(n);
        for (int j = 0; j < mod; j++) {
            for (int k = 0; k <= 9; k++) {
                if (S[i] != '?' && (S[i] - '0') != k) continue;
                mint r = (mint)k * pow10;
                dp[i+1][(j+r.x) % mod] += dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[L][5] % MOD << '\n';
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int w,a,b;
	cin >> w >> a >> b;
	int ret;
	if (a==b) {
		cout << 0 << "\n";
		return 0;
	}
	if (a<b) {
		ret = b - (a+w);
		if (ret<=0) {
			cout << 0 << "\n";
		} else {
			cout << ret << "\n";
		}
		return 0;
	}
	if (a>b) {
		ret = a - (b+w);
		if (ret<=0) {
			cout << 0 << "\n";
		} else {
			cout << ret << "\n";
		}
		return 0;
	}
}


Measured memory_bytes: 256
// Example program
#include <iostream>
#include <vector>
using namespace std;

vector<int> id;
vector<long long> sz;

int find(int x) {
	if (x == id[x])
		return x;
	return id[x] = find(id[x]);
}

void connect(int x, int y) {
	x = find(x);
	y = find(y);
	if (x != y) {
		id[x] = y;
		sz[y] += sz[x];
	}
}

long long helper(int n) {
	vector<long long> temp;
	for (int i = 1; i <= n; ++i) {
		if (i == find(i)) {
			temp.push_back(sz[i]);	
		}
	}
	long long ret = 0, tempc = 0;
	for (int i = 0; i < temp.size(); ++i) {
		ret += tempc * temp[i];		
		tempc += temp[i];		
	}
	return ret;
}

int main()
{
	int n, m;
	cin >> n >> m;
	id.resize(n + 1);
	sz.resize(n + 1);
	for (int i = 1; i <= n; ++i) {
		id[i] = i;
		sz[i] = 1;
	}
	vector<int> a(m);
	vector<int> b(m);
	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
	}
	vector<long long> ans(m);
	ans[m - 1] = helper(n);
	for (int i = m - 1; i >= 1; --i) {
		int x = find(a[i]);
		int y = find(b[i]);
		if (x == y) {
			ans[i - 1] = ans[i];	
		} else {
			ans[i - 1] = ans[i] -  sz[x] * sz[y];
			id[x] = y;
			sz[y] += sz[x];
		}
	}
	for (int i = 0; i < m; ++i) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 4196
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <bits/stdc++.h>

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


const int N = 105;
const int W = 1e5+1;
int dp[N][W], v[N], w[N];


class DKnapsack1 {
public:
    int n, weight;

	int rec(int i, int remain) {
        if(i == n) return 0;
        if(dp[i][remain] != -1) return dp[i][remain];
        int res = rec(i+1, remain);
        if(w[i] <= remain) res = max(res, v[i] + rec(i+1, remain - w[i]));
        return dp[i][remain] = res;
	}

    void solve(std::istream& in, std::ostream& out) {
        in >> n >> weight;
        for(int i = 0; i < n; ++i) in >> w[i] >> v[i];
        memset(dp, -1, sizeof dp);
        out << rec(0, weight);
	}
};


int32_t main() {
	DKnapsack1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 82304
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

const int MAXN = 55;

int n,a[MAXN];

int main()
{
    cin >> n;
    for (int i=1; i<=n; i++) scanf("%d",&a[i]);

    int diff(0);
    for (int i=1; i<=n; i++)
        if (a[i] != i) diff++;
    if (diff > 2) cout << "NO"; else cout << "YES";

    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

signed main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int A=in(),B=in();
	
	printf("%d %d %.6lf\n",A/B,A%B,(double)A/(double)B);
	return 0;
}



Measured memory_bytes: 3144
#include<stdio.h>
#include<stdlib.h>


int Merge(int,int,int);
void MergeSort(int,int);

int A[500000],L[500000],R[500000];
int c=0;
int INFTY=1000000000;

int Merge(int left, int mid, int right){
  int i,k,n1,n2,j;

n1 = mid - left;
 for(i=0;i<n1;i++){
   L[i]=A[left+i];
 }
 L[n1]=INFTY;

n2 = right - mid;

 for(i=0;i<n2;i++){
   R[i] = A[mid + i];
 }
 R[n2]=INFTY;
  

 i=0;
 j=0;
 for( k = left;k< right;k++){
   c++; 
  if(L[i] <= R[j]){
     A[k] = L[i];
     i = i + 1;
   }
  else{
    A[k] = R[j];
	 j = j + 1;
       }
 }

}
   void MergeSort(int left, int right){
     int mid;
     if( left+1 < right){
   mid = (left + right)/2;
   MergeSort( left, mid);
     MergeSort( mid, right);
     Merge( left, mid, right);
     }}

   int main(){
     int i;
     int n;
 
     scanf("%d", &n);
     for(i=0;i<n;i++){
	 scanf("%d", &A[i]);
       }
 
     MergeSort(0, n);
 
     for(i=0;i<n-1;i++){       
	 printf("%ld ", A[i]);
       }
     printf("%d\n", A[n-1]);
     printf("%d\n",c);
 
     return 0;
   }

Measured memory_bytes: 5484
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>

#define rep(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second

using namespace std;

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

int main() {

    int n, m;
    scanf("%d %d", &n , &m);

    int ave = m/n;

    while (ave > 0) {
        if ((m % ave) == 0 && (m/ave) >= n ) {
            printf("%d\n", ave);
            return 0;
        } else {
            ave--;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ten(long long x)
{
    long long res=0;
    while(x>0)
    {
        res+=x%10;
        x/=10;
    }
    return res;
}
long long num[1000000];
int main()
{
   int n;
   while(~scanf("%d",&n))
  {
      long long ans=0,temp=1;
      for(int i = 1;i<=n;i++)
      {

          long long n1=ans+temp*10;
          long long n2=ans+temp;//cout<<n1<<" "<<n2<<endl;
          if(n1*ten(n2)<=n2*ten(n1))
          {
              ans=n1;temp*=10;
          }
          else
          {
              ans=n2;
          }
          printf("%lld\n",ans);
      }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
const int maxn = 1e6+5;

struct Node {
	int to, next;
	ll w;
}edge[maxn<<1];
int head[maxn], cnt;
ll dis[maxn];
ll dist[maxn];
bool vis[maxn];

void init(int n) {
	cnt = 0;
	memset(dis, INF, sizeof(dis));
	memset(head, -1, sizeof(head));
}

void addEdge(int from, int to, ll w) {
	edge[cnt].to = to;
	edge[cnt].w = w;
	edge[cnt].next = head[from];
	head[from] = cnt++;
}

void spfa(int s) {
    dis[s] = 0;
    queue<int> q;
    q.push(s);
	vis[s] = 1;
	while (!q.empty()) {
		
		int num = q.front(); q.pop();
		vis[num] = 0;
		for (int i = head[num]; i != -1; i = edge[i].next) {
			Node e = edge[i];
			if (dis[e.to] > dis[num] + e.w) {
				dis[e.to] = dis[num] + e.w;
				if (!vis[e.to]) {
					vis[e.to] = 1;
					q.push(e.to);
				}
			}
		}
	}
}

int main(void) {
    int t;
    scanf("%d", &t);
    init(t);
    for (int i = 0; i < t-1; i++) {
        int v, u, w;
        scanf("%d %d %d", &u, &v, &w);
        addEdge(u, v, w);
        addEdge(v, u, w);
    }
    
    int q, k;
    scanf("%d %d", &q, &k);
    spfa(k);
    for (int i = 0; i < q; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        printf("%lld\n", dis[u]+dis[v]);
    }
    
}

Measured memory_bytes: 18304
l = [int(x) for x in input().split(' ')]
n,k = l
h = []

for i in range(n):
	h += [int(input())]
h.sort()

i,j = 0,k-1

r = float('inf')
while j < len(h):
	mn,mx=h[i],h[j]
	r = min(r, mx-mn)
	i,j=i+1,j+1

print(r)


Measured memory_bytes: 7444
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int A[200000];
    long sum[200000];
    long ans = 0;
    cin >> N;
    cin >> A[0];
    sum[0] = A[0];
    for(int i = 1; i < N; i++){
        cin >> A[i];
        sum[i] = sum[i-1] + A[i];
    }
    
    sort(sum, sum+N);
    if(sum[0] == 0) ans++;
    long tmp = sum[0];
    long cnt = 1;
    
    for(int i = 1; i < N; i++){
        if(sum[i] == 0) ans++;
        if(tmp == sum[i]){
            cnt++;
        }else{
            ans += cnt*(cnt-1)/2;
            cnt = 1;
            tmp = sum[i];
        }
    }
    
    ans += cnt*(cnt-1)/2;
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

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


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

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

	int ans = 1;
	for (int i = n; i <= m / 2; ++i) {
		if (m%i == 0) {
			ans = m / i;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int a; 
    scanf("%d", &a);
    
    if(a<1200)
    {
        printf("ABC");
    }
    
    else if(a>=1200 and a<2800)
    {
        printf("ARC");
    }
    
    else
    {
        printf("AGC");
    }
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    bool ans = false;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(n==i*j) ans = true;
        }
    }
    if(ans)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	ll sum = 0;
	rep(i, n) sum += a[i];
	ll tmp = 0;
	ll ans = linf;
	rep(i, n - 1) {
		tmp += a[i];
		sum -= a[i];
		mins(ans, abs(tmp - sum));
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;


ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

int main(){
    cin>>N;
    vec c(N);
    rep(i,N) cin>>c[i];
    sort(ALL(c));
    reverse(ALL(c));
    ll ans = 0;
    rep(i,N){
        (ans += ((i + 2) * c[i])%MOD)%=MOD;
    }
    (ans *= fastpow(2, N * 2 - 2))%=MOD;
    cout<<ans<<endl;
}

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

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
  ll n, m;
  cin >> n >> m;

  if (n > 2 && m > 2) {
    cout << (n - 2) * (m - 2) << endl;
  } else {
    if (n == 1 && m == 1) {
      cout << 1 << endl;
    } else if (n == 1) {
      cout << m - 2 << endl;
    } else {
      cout << n - 2 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int t = sc.nextInt();
            if(t==0) break;
            int n = sc.nextInt();
            int cnt = 0;
            for(int i=0; i<n; i++){
                int s = sc.nextInt(), f = sc.nextInt();
                cnt += f-s;
            }
            if(cnt >= t) {
                System.out.println("OK");
            }else{
                System.out.println(t-cnt);
            }
        }
    }

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

Measured memory_bytes: 23584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) int(x.size())

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double PI=3.14159265358979323846;

int mod = 1e9+7;
int INF = 1e9+7;
// const long long INF = 1LL<<60;


int main(){
  int N;
  cin >> N;
  map<int, int> mp;
  rep(i, N){
    int a;
    cin >> a;
    mp[a]++;
  }

  vector<P> vect;
  for(P p: mp){
    vect.push_back(p);
  }
  sort(vect.begin(), vect.end());

  bool ok = false;

  // Length = 1
  if(sz(vect)==1) if(vect[0].first == 0) ok = true;
  // Length = 2
  if(sz(vect)==2){
    int cnt_0 = vect[0].second;
    int cnt_1 = vect[1].second;
    if(2*cnt_0==cnt_1 && vect[0].first==0) ok = true;
    if(cnt_0==2*cnt_1 && vect[1].first==0) ok = true;
  }
  // Length = 3
  if(sz(vect)==3){
    if(vect[0].second*3==N && vect[1].second*3==N && vect[2].second*3==N){
      int x = vect[0].first;
      int y = vect[1].first;
      int z = vect[2].first;
      if(x == (y^z) && y==(x^z) && z==(x^y)) ok = true;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4988
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

signed main(void)
{
  int x, y, z;
  cin >> x >> y >> z;

  int ans;
  REP(i, 100000) {
    if(i*y + (i+1)*z <= x) ans = i;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
v = list(map(int, input().split()))

vo=[]
ve=[]
i = 0
while i < n/2:
  ve.append(v[2*i])
  vo.append(v[2*i+1])
  i += 1
cve = collections.Counter(ve).most_common(2)
cvo = collections.Counter(vo).most_common(2)
ans = 0
if cve[0][0] == cvo[0][0]:
  if len(cve) == 1 and len(cvo) == 1:
    print(int(n/2))
  elif len(cve) == 1:
    print(int(n/2 - cvo[1][1]))
  elif len(cvo) == 1:
    print(int(n/2 - cve[1][1]))
  else:
    print(min(n-cvo[0][1]-cve[1][1], n-cvo[1][1]-cve[0][1]))
else:
  print(n - cve[0][1] - cvo[0][1])


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

using namespace std;

bitset<4000010>b;
int N,A[2010];

int main()
{
	b.reset();
	b.set(0);
	scanf("%d",&N);
	int S = 0;
	for (int i=1;i<=N;i++)scanf("%d",&A[i]),b |= (b << A[i]),S += A[i];
	for (int i=(S + 1) / 2; i <= S; i++)
		if (b[i]){
			printf("%d\n",i);
			break;
		}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long sumA = 0, sumB = 0;
  long ng = 0;
  vector<long> ok, a(N), b(N);
  for(int i = 0; i < N; i++)cin >> a.at(i);
  for(int i = 0; i < N; i++)cin >> b.at(i);
  for(int i = 0; i < N; i++){
    sumA += a.at(i);
    sumB += b.at(i);
    if(a.at(i) >= b.at(i)){
      ok.push_back(a.at(i) - b.at(i));
    } else {
      ng += b.at(i) - a.at(i);
    }
  }
  if(sumA < sumB){
    cout << -1 << endl;
    return 0;
  } else if(ng == 0){
    cout << 0 << endl;
    return 0;
  }
  sort(ok.begin(), ok.end());
  long co = 0;
  for(int i = ok.size() - 1; i >= 0; i--){
    co += ok.at(i);
    if(ng <= co){
      cout << N - i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 2936
X = int(input())
A = int(input())
B = int(input())
ans = 0
remain = X - A
for i in range(100000):
  if (remain - B) < 0:
    ans = remain
    break
  elif (remain - B) == 0:
    ans = 0
    break
  else:
    remain -= B
print(ans)

Measured memory_bytes: 3060