akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

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

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

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

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

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

int main() {
    string s;
    cin >> s;
    int k;
    cin >> k;
    set<string> used;
    PQ_ASK q;

    auto insert = [&](string t) {
        if (used.find(t) == used.end()) {
            q.push(t);
            used.insert(t);
        }
    };

    for (int i = 0; i < s.size(); i++) {
        insert(s.substr(i, 1));
    }

    int c = 0;
    while (c != k - 1) {
        string t = q.top();
        c++;
        q.pop();
        for (int i = 0; i + t.size() < s.size(); i++) {
            if (s.substr(i, t.size()) == t) {
                string n = s.substr(i, t.size() + 1);
                insert(n);
            }
        }
    }

    cout << q.top() << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

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

    long double a,b,x;
    long double PI = acosl(-1);

    cin>>a>>b>>x;

    long double tot = a*a*b;

    if(x*2>=tot){
        long double cur = tot-x;
        cur/=(a*a*a);
        cur*=2.0;
        long double ans = atanl(cur);
        ans*=180.0;
        ans/=PI;
        cout<<fixed;
        cout.precision(15);
        cout<<ans<<"\n";
    }
    else {
        long double cur = a*b*b;
        cur/=2.0;
        cur/=x;
        long double ans = atanl(cur);
        ans*=180.0;
        ans/=PI;
        cout<<fixed;
        cout.precision(15);
        cout<<ans<<"\n";
    }


    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N, K;
	cin >> N >> K;
	
	int sum[300000] = {};
	
	for(int i = 0; i < N; i++){
		int num;
		cin >> num;
		sum[num - 1]--;
	}
	
	vector<int> v;
	
	for(int i = 0; i < N; i++){
		v.push_back(sum[i]);
	}
	
	sort(v.begin(), v.end());
	
	for(int i = 0; i < K; i++){
		N += v[i];
	}
	
	cout << N << endl;
	
	return 0;
}

Measured memory_bytes: 2552
package main

import "fmt"

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

func main() {
	var x int
	fmt.Scan(&x)

	for i := 0; i <= 100000; i++ {
		a5 := i * i * i * i * i
		b5 := a5 - x
		for j := 0; j*j*j*j*j <= abs(b5); j++ {
			if j*j*j*j*j == abs(b5) {
				if b5 > 0 {
					fmt.Println(i, j)
				} else {
					fmt.Println(i, -j)
				}
				return
			}
		}
	}

	for i := 0; i <= 100000; i++ {
		a5 := -i * i * i * i * i
		b5 := a5 - x
		for j := 0; j*j*j*j*j <= abs(b5); j++ {
			if j*j*j*j*j == abs(b5) {
				if b5 > 0 {
					fmt.Println(-i, j)
				} else {
					fmt.Println(-i, -j)
				}
				return
			}
		}
	}
}


Measured memory_bytes: 1816
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=1e6+10,inf=1e9+7;
typedef long long ll;
ll h,w,node[maxn],n,a,b,cnt=0,zero,ans[15];
int main(){
    scanf("%lld%lld%lld",&h,&w,&n);
    zero=(h-2)*(w-2);
    while(n--){
        scanf("%lld%lld",&a,&b);
        for (int i=-2;i<=0;i++){
            for (int j=-2;j<=0;j++){
                if(a+i>=1 && a+i <=h-2 && b+j>=1 &&b+j <=w-2){
                    node[cnt++]=inf*(a+i)+(b+j);
                }
            }
        }
    }
    sort(node,node+cnt);
    for (int i=0,tmp=1;i<cnt;i++){
        if(node[i]==node[i+1]) tmp++;
        else ans[tmp]++,zero--,tmp=1;
    }
    printf("%lld\n",zero);
    for (int i=1;i<10;i++)
        printf("%lld\n",ans[i]);
    return 0;
}

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

vector<int> pd(int x){
  vector<int> p(11);
  for(int i=0;i<11;i++){
    p[i]=x%2;
    x/=2;
  }
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<vector<int>> F(N,vector<int>(10,0));
  vector<vector<int>> P(N,vector<int>(11,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++)
      cin>>F[i][j];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++)
      cin>>P[i][j];
  }
  vector<int> X;
  int l,cnt,ans;
  for(int i=1;i<1024;i++){
    cnt=0;
    X=pd(i);
    for(int j=0;j<N;j++){
      l=0;
      for(int k=0;k<10;k++){
        if(X[k]&F[j][k])
          l++;
      }
      cnt+=P[j][l];
    }
    if(i>1) ans=max(cnt,ans);
    else ans=cnt;
  }
  cout<<ans<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i=0; i<N; i++) {
  	cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int red=0;
  for (int i=0; i<N-1; i++){
  	if (d.at(i) == d.at(i+1)) {
    	red++;
    }
  }
  
  cout << N - red << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += v[i] * v[j];
        }
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> k(m);
    rep(i, m){
        int l;
        cin >> l;
        rep(j, l){
            int x;
            cin >> x;
            k[i].push_back(x);
        }
    }
    vector<int> p(m);
    rep(i, m) cin >> p[i];

    int ans = 0;
    rep(i, 1<<n){
        bool f = 1;
        rep(j, m){
            int tmp = 0;
            repe(x, k[j]){
                if(i & (1<<(x-1))) tmp++;
            }
            if(tmp % 2 != p[j]){
                f = 0;
                break;
            }
        }
        if(f) ans++;
    }
    cout << ans << endl;

}


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


public class Main {
	private	static	BufferedReader		br      = null;
	private	static	ArrayList<Integer>	prime   = null;
	private	static	ArrayList<Integer>	sum     = null;
	private	static	ArrayList<Integer>	borders = null;

	static {
		br      = new BufferedReader(new InputStreamReader(System.in));
		prime   = new ArrayList<Integer>();
		sum     = new ArrayList<Integer>();
		borders = new ArrayList<Integer>();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	nLen;
		parseBorder();
		createPrimeList();

		nLen = borders.size();
		for (int nLoop = 0; nLoop < nLen; nLoop++) {
			System.out.println(sum.get(borders.get(nLoop) - 1));
		}
	}

	private static void parseBorder() {
		int	nNum = 0;
		while((nNum = parseNum()) != 0) {
			borders.add(nNum);
		}
	}

	private static int parseNum() {
		int		num    = 0;
		String	strNum = parseStdin();

		if (strNum != null) {
			num = Integer.parseInt(strNum);
		}

		return num;
	}

	private static String parseStdin() {
		String	strNum = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					strNum = line;
				}
			}
		}
		catch (IOException e) {}

		return strNum;
	}

	private static void createPrimeList() {
		boolean		bLoop  = true;
		boolean		bPrime = true;
		int			nPrime = 0;
		int			nSum   = 0;
		Object[]	aWork  = borders.toArray();

		Arrays.sort(aWork);
		prime.add(2);
		sum.add(2);
		for(int nNum = 3; bLoop; nNum += 2) {
			bPrime = true;

			for (int nLoop = 0; nLoop < prime.size(); nLoop++) {
				nPrime = prime.get(nLoop);
				if (nPrime <= (int)Math.sqrt((double)nNum)) {
					if (nNum % nPrime == 0) {
						bPrime = false;
						break;
					}
				}
				else {
					break;
				}
			}

			if (bPrime) {
				nSum = sum.get(sum.size() - 1);
				prime.add(nNum);
				sum.add(nSum + nNum);
				bLoop = prime.size() < (Integer)aWork[aWork.length - 1];
			}
		}
	}
}

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

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

  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }

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

Measured memory_bytes: 3580
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    string S;
    cin >> S;
    if (S == "Sunny") cout << "Cloudy" << endl;
    else if (S == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<math.h> 
#include <algorithm>
#include<cstdio>
#include <map>
#include<vector>

using namespace std;  


const int MAXN=110;
int a[MAXN],N;
double _time[11000],b,r,v,e,f,dp[MAXN];
void init()
{
 int x,nx,j;
 double temp;
 _time[0]=0.0;
 for(x=1;x<=10000;x++)
	 _time[x]=0.0;
 for(x=1;x<=10000;x++)
 {
  nx=x-1;
  if(nx>=r)
  temp=1.0/(v-e*(nx-r));
  else
	  temp=1.0/(v-f*(r-nx));
  _time[x]=_time[x-1]+temp;
  
 }
}
void work()
{
 int i,j;

 for(i=1;i<=N;i++)
 {double temp=_time[a[i]];
  for(j=1;j<i;j++)
  {
	temp=min(temp,dp[j]+_time[a[i]-a[j]]+b);
  }
  dp[i]=temp;
 }
}
int main()
{
  int i,j;
 
  while(cin>>N,N)
  {
   for(i=1;i<=N;i++)
	   cin>>a[i];
   cin>>b>>r>>v>>e>>f;
     init();
   work();
   printf("%.4lf\n",dp[N]);
  }

}

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

int main(){
  int H, A;
  cin >> H >> A;
  int ans = (H+A-1)/A;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;//这题范围到了三个10^9,合起来可能有10^18,一定要开long long
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)//本题精华之特判,n=1的时候最大数和最小数必须一致,因为只有一个数,其他的时候就只要满足a>=b即可
        cout<<(n-2)*(b-a)+1<<endl;//按照(n-2)*(a-b)+1的思路打的代码,其实我也想到了(笑)
    else
        cout<<0<<endl; 
 } 

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

int main() {
  string str;
  cin >> str;
  int num = 0;
  num = num * 10 + str[2] - '0';
  num = num * 10 + str[3] - '0';
  int num1 = 0;
  num1 = num1 * 10 + str[0] - '0';
  num1 = num1 * 10 + str[1] - '0';
  if (num >= 1 && num <= 12) {
    if (num1 >= 1 && num1 <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "YYMM" << endl;
    }
  } else if (num1 >= 1 && num1 <= 12) {
    if (num >= 1 && num <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  } else {
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

const int maxN = 511;
const int defX[4] = {-1, 1, 0, 0};
const int defY[4] = {0, 0, -1, 1};

int n;
int cost[maxN][maxN], dist[maxN][maxN];
queue< pair<int, int> > Q;
int answer;

void move(int x, int y) {
  dist[x][y]--;
  cost[x][y] = 0;
  answer += dist[x][y];
  Q.push(mp(x, y));

  /*
  cerr << dist[x][y] << '\n';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      cerr << dist[i][j] << ' ';
    cerr << '\n';
  }
  */

  while (!Q.empty()) {
    x = Q.front().first;
    y = Q.front().second;
    Q.pop();

    for (int i = 0; i < 4; i++) {
      int xx = x + defX[i];
      int yy = y + defY[i];

      if (xx < 0 || xx >= n) continue;
      if (yy < 0 || yy >= n) continue;
      if (dist[xx][yy] > dist[x][y] + cost[xx][yy]) {
        dist[xx][yy] = dist[x][y] + cost[xx][yy];
        Q.push(mp(xx, yy));
      }
    }
  }
}

int main()
{
  //freopen("test.in", "r", stdin);

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cost[i][j] = 1;
      dist[i][j] = min(min(i + 1, j + 1),
                       min(n - i, n - j));
    }
  }

  for (int i = 0; i < n * n; i++) {
    int x;

    scanf("%d", &x);
    x--;
    move(x / n, x % n);
  }

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


  return 0;
}


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

using namespace std;

#define debug(x) cout << "\n" << __LINE__ << " " <<  (#x) << " is " << (x) << endl

int main(){
	#ifdef EVAL	
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	long long A, B;
	cin >> A >> B;
	cout << max({A + B, A - B, A * B});
	return 0;
}

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

public class Main {


    public static void solve() {
        int mod = (int) (1e9 + 7);
        int n = in.nextInt();
        int k = in.nextInt();

        int[] canHave = new int[n];

        for (int i = 0; i < n; i += 1) {
            canHave[i] = in.nextInt();
        }

        long[][] store = new long[n][k + 1];

        for (int j = 0; j <= k; j += 1) {
            if (canHave[0] >= j)
                store[0][j] = 1;
        }

        for(int i = 1; i < n; i += 1)
            store[i][0] = 1;

        for (int i = 1; i < n; i += 1) {
            long[] prefixSum = new long[k+1];
            prefixSum[0] = 1;
            for(int j = 1; j <= k; j += 1)
                prefixSum[j] = (prefixSum[j-1] + store[i-1][j])%mod;

            for (int j = 1; j <= k; j += 1) {
                long count = prefixSum[j];
                int unreachable = j-canHave[i]-1;
                if(unreachable >= 0)
                    count = (count-prefixSum[unreachable]+mod)%mod;
                store[i][j] = count;
            }
        }


        out.println((store[n - 1][k])%mod);

    }


    public static InputReader in = new InputReader();
    public static PrintWriter out;

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }


    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader() {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

        /**
         * When you call next(), that entire line will be skipped.
         * No flushing buffers.
         * Doesn't work when you want to scan the remaining line.
         *
         * @return entire line
         */
        public String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
                tokenizer = null;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }
    }
}

Measured memory_bytes: 172744
/*  ex3_3
    Rikuta  */

#include <stdio.h>

int main(void){

    int number,base_number;
    //countの導入
    int count=0;
    //numberとbase_numberの入力
    scanf("%d",&number);
    scanf("%d",&base_number);
    //numberがbase_numberで割った余りが0になるまで繰り返して，その文countを1足す
    while (number!=0)
    {
        number/=base_number;
        count++;
    }
    //countの出力
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 128
N = int(input())
out = "No"
Ds = []
for i in range(N):
    Ds.append(list(map(int,input().split())))
for i in range(N-2):
    if Ds[i][0]==Ds[i][1] and Ds[i+1][0]==Ds[i+1][1] and Ds[i+2][0]==Ds[i+2][1]:
        out = "Yes"
print(out)


Measured memory_bytes: 62408
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


a, b, c, d = LI()
s = [0] * 101
s[a] += 1
s[b] -= 1
s[c] += 1
s[d] -= 1
for i in range(100):
    s[i + 1] += s[i]

print(s.count(2))


Measured memory_bytes: 3064
#!/usr/bin/ruby
class Ternary
	def initialize(n)
		@n=n
	end
	def to_i
		@n
	end
	def -@
		Ternary.new(2-to_i)
	end
	def *(o)
		Ternary.new([to_i,o.to_i].min)
	end
	def +(o)
		Ternary.new([to_i,o.to_i].max)
	end
end
R=[*0..2]
loop{
	s=gets.chomp
	break if s=='.'
	r=0
	R.each{|a|R.each{|b|R.each{|c|
		r+=1 if eval([['0',0],['1',1],['2',2],['P',a],['Q',b],['R',c]].reduce(s){|x,(y,z)|x.gsub(y,'Ternary.new(%d)'%z)}).to_i==2
	}}}
	p r
}



Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define int long long
void run();
signed main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(13); run(); }
mt19937 rng(random_device{}());

void run() {
    string n;
    int k;
    cin >> n >> k;
    int m = (int) n.size();
    int ans = 0;
    for (int len = 1; len < m; ++len) {
        if (k == 1)
            ans += 9;
        else if (k == 2) {
            ans += 9 * 9 * (len - 1);
        } else
            ans += 9 * 81 * (len - 1) * (len - 2) / 2;
    }

    for (int a = '1'; a < n[0]; ++a) {
        if (k == 1)
            ++ans;
        else if (k == 2)
            ans += 9 * (m - 1);
        else
            ans += 81 * (m - 1) * (m - 2) / 2;
    }

    cerr << ans << endl;
    if (k != 1) {
        for (int i = 1; i < m; ++i) if (n[i] != '0') {
            for (int a = '1'; a < n[i]; ++a)
                if (k == 2)
                    ++ans;
                else
                    ans += 9 * (m - i - 1);
            
            if (k != 2) {
                for (int j = i + 1; j < m; ++j) if (n[j] != '0') {
                    ans += (n[j] - '0') + (m - j - 1) * 9;
                    break;
                }
                ans += (m - i - 1) * (m - i - 2) / 2 * 81;
                break;
            } else {
                ans += 1 + (m - i - 1) * 9;
                break;
            }
        }
    } else if (n[0] != '0') {
        ++ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
S=input()
F=[]
L=[]
max=0
for i in range(0,N+1):
    F=set(S[:i])
    L=set(S[i:])
    count=len(F&L)
    if count>max:
        max=count
    F=[]
    L=[]
print(max)


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


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

    vector<ll> a(n+1);
    vector<ll> b(m+1);

    ll va,vb;
    for(int i=0;i<n;i++){
        cin>>va;
        a.at(i+1)= a.at(i)+va;
    }

    for(int i=0;i<m;i++){
        cin>>vb;
        b.at(i+1)= b.at(i)+vb;

    }


    int t=m;ll co=0;
    for(ll i=0;i<=n;i++){
        for(ll j=t;j>=0;j--){
            if(a.at(i)+b.at(j)<=k){
                co = max(co,i+j);
                t = j;
                break;
            }
        }
    }

    cout<<co<<endl;




}



Measured memory_bytes: 6412
n,k = map(int,input().split())
ab=[]
for _ in range(n):
    ab.append(list(map(int,input().split())))
ab.sort()
for i in range(n):
    if k-ab[i][1]<=0:
        print(ab[i][0])
        exit()
    k-=ab[i][1]


Measured memory_bytes: 27872
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [a, b] <- getIntList
  if a <= 0 && b >= 0
    then putStrLn "Zero"
    else
      if a > 0 && b > 0
        then putStrLn "Positive"
        else
          if odd (a - b + 1)
            then putStrLn "Negative"
            else putStrLn "Positive"


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

int main(){
	int  ans, in[10], out[10], i = 0, j = 1;

	while(cin >> in[i]){
		if(in[i] == 0){
			cout << in[i-j] << endl;
			i --;
		}
		else {
			i ++;
		}
	}
	return 0;
}

Measured memory_bytes: 3076
//#define _GLIBCXX_DEBUG
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1000000000;
const ll MOD = 1000000007;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    IOS;
    ll s;
    cin >> s;
    ll ans = 0;
    COMinit();
    for (int i=1; s-2*i >= i; i++){
        ll n = s-2*i;
        ll k = i;

        ll sv = COM(n-1,k-1);
        sv %= MOD;
        if (sv < 0)sv += MOD;
        ans += sv;
        ans %= MOD;
        if (ans < 0)ans = MOD+ans;
        if (sv == 0)break;
    }
    cout << ans%MOD << endl;
}


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

using namespace std;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> X(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      X[i][j] = s[j] - '0';
    }
  }
  int res = 1 << 28;
  for (int b = 0; b < (1 << (H - 1)); b++) {
    int cnt = 0;
    vector<int> v;
    v.emplace_back(0);
    for (int i = 0; i < H - 1; i++) {
      if (b >> i & 1) {
        v.emplace_back(i + 1);
        cnt++;
      }
    }
    v.emplace_back(H);
    vector<int> cnts(v.size() - 1, 0);
    bool ok = true;
    map<int, int> mp;
    for (int i = 0; i < W; i++) {
      mp[i]++;
      if (!ok) break;
      int mx = 0;
      vector<int> nxt(v.size() - 1, 0);
      for (int j = 0; j < (int)v.size() - 1; j++) {
        int l = v[j], r = v[j + 1];
        nxt[j] = cnts[j];
        for (int k = l; k < r; k++) {
          nxt[j] += X[k][i];
        }
        chmax(mx, nxt[j]);
      }
      if (mx <= K) {
        swap(cnts, nxt);
      } else {
        if (mp[i] >= 2) ok = false;
        i--;
        cnts.assign(v.size() - 1, 0);
        cnt++;
        continue;
      }
    }
    if (ok) chmin(res, cnt);
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
  long long a=100;
  long long x;
  cin>>x;
  long long year=0;
  while(true) {
    if(a>=x) {
      break;
    }
    a+=a/100;
    year++;
  }
  cout<<year<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    int a=1;
    if(s=="SSS") a=0;
    else if(s=="RRS") a=2;
    else if(s=="SRR") a=2;
    else if(s=="RRR") a=3;

    cout<<a<<endl;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

struct State{
  ll num;
  int pos;
  bool is_over_flow;
  State(int _n,int _p,bool _o) : num(_n),pos(_p),is_over_flow(_o) {}
  State() : num(0),pos(0),is_over_flow(false) {}
};

ll compute_digit(ll num){
  ll res = 0;
  while(num > 0){
    num /= 10;
    res++;
  }
  return res;
}

ll fast_pow(ll x, ll n){
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}


State parse_mono(const string& str,int pos,ll n){
  if(str[pos] == 'n' && str[pos+1] == '^'){
    ll num = str[pos+2]-'0';
    int digit = compute_digit(n) * num;
    State s;

    if(digit > 10){
      s.is_over_flow = true;
      s.num = 0;
      s.pos = pos+3;
    }
    else{
      s.is_over_flow = false;
      s.num = fast_pow(n,num);
      s.pos = pos+3;
    }
    return s;
  }
}

State parse_poly(const string& str,int pos,ll n){
  State res;

  if(pos < str.size() && str[pos] != '+') {
    State s = parse_mono(str,pos,n);
    res.num += s.num;
    res.is_over_flow |= s.is_over_flow;
    pos = s.pos;
  }

  while(pos < str.size() && str[pos] == '+'){
    State s = parse_mono(str,pos+1,n);
    res.num += s.num;
    res.is_over_flow |= s.is_over_flow;
    pos = s.pos;
  }

  return res;
}

int main(){
  ll n,T;
  while(~scanf("%lld %lld",&n,&T)){
    string str;
    cin >> str;
    State s = parse_poly(str,0,n);
    if(s.is_over_flow || s.num * T > 1000000000LL){
      cout << "TLE" << endl;
    }
    else{
      cout << s.num * T << endl;
    }
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll int, ll int>
#define ff first
#define ss second
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define debug4(n, m, x, y) cout << "DEBUG4 " << n << ' ' << m << ' ' << x << ' ' << y << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#define upzero(n) rrn < 0) n = 0
#define alive(n) cout << "Alive here: checkpoint " << n << endl
#pragma GCC optimize("Ofast")
using namespace std;
void yes() {
    cout << "Yes\n";
    return;
}
void no() {
    cout << "No\n";
    return;
}
void solve(int case_no) {
    // implementation
    int a, b, c;
    cin >> a >> b >> c;
    return (a <= b * c ? yes() : no());
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(NULL));
    int t = 1;
//    cin >> t;
    for (int i = 1;i <= t;i++) solve(i);
}
/*

*/

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
  int k, a, b, flag = 0;
  
  scanf("%d %d %d", &k, &a, &b);
  for(int i = a;i <= b;i++){
    if(i % k == 0){
      flag = 1;
      break;
    }
  }
  
  if(flag == 0){
    printf("NG");
  }
  else{
    printf("OK");
  }
  
  return 0;
  
}

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

using namespace std;

const int mx = 1e3+5;

char mat[mx][mx];
int dp[mx][mx]={0};

const int mod = 1e9+7;

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

	int h,w;
	cin>>h>>w;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>mat[i][j];		
		}
	}
	bool iswall=false;
	for(int i=0;i<w;i++)
	{	
		if(mat[0][i]=='.' && iswall==false)
			dp[0][i]=1;
		else
		{
			dp[0][i]=0;
			iswall=true;
		}
	}

	iswall=false;
	for(int i=0;i<h;i++)
	{
		if(mat[i][0]=='.' && iswall==false)
		{
			dp[i][0]=1;
		}
		else
		{
			dp[i][0]=0;
			iswall=true;
		} 
	}

	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{	
			if(mat[i][j]=='.')
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}

	cout<<(dp[h-1][w-1])%mod<<'\n';
	return 0;
}

Measured memory_bytes: 5248
using System;

namespace _057b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] NM = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int[,] ab = new int[NM[0],2];
            int[,] cd = new int[NM[1],2];
            int[] read;
            for(int i = 0; i < NM[0]; i++){
                read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
                ab[i,0] = read[0];
                ab[i,1] = read[1];
            } 

            for(int i = 0; i < NM[1]; i++){
                read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
                cd[i,0] = read[0];
                cd[i,1] = read[1];
            }

            int kyori=0;
            int count = 0;
            int tmp_kyori;
            for(int i = 0; i < NM[0]; i++){
                count = 1;
                kyori = 0;
                for(int j = 0;j<NM[1];j++){
                    tmp_kyori = Math.Abs(ab[i,0]-cd[j,0])+Math.Abs(ab[i,1]-cd[j,1]);
                    if(j==0){
                        kyori = tmp_kyori;                       
                    }else{
                        if(kyori > tmp_kyori){
                            kyori = tmp_kyori;
                            count = j+1;
                        }
                    }
                }
                Console.WriteLine(count);
            }

        }
    }
}

Measured memory_bytes: 11220
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < n; ++i) {
            set.add(sc.nextInt());
        }

        int N = set.last();
        if (set.contains(N / 2)) {
            System.out.printf("%d %d\n", N, N / 2);
            return;
        }

        int rl = set.lower(N / 2);
        int rr = set.higher(N / 2);

        int R = rl >= N - rr ? rl : rr;

        System.out.printf("%d %d\n", N, R);
    }
}


Measured memory_bytes: 63532
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair <double,double> dd;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define inf=1000000000
ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}
ll p(ll d){
    ull s=1;
    ll cnt{0};
    while(d>s)s=ipow(2,cnt);
    return s-d;

}
int k;
vector<ll> a,meme;
ll mem(int AJ){
    
    if(meme[AJ]>=0)return meme[AJ];
    for(int i=1;i<=k;i++)
        if(meme[AJ]==-1)meme[AJ]=mem(AJ-i)+abs(a[AJ-i]-a[AJ]);
        else meme[AJ]=min(mem(AJ-i)+abs(a[AJ-i]-a[AJ]),meme[AJ]);
    return meme[AJ];

}
int main(){
    int n;
    cin>>n>>k;
    if(k>n)k=n;
    for(int i=0;i<n;i++)meme.push_back(-1);
         for(int i=0;i<n;i++)a.push_back(0);
    for(int i=0;i<n;i++)
        cin>>a[i];
    meme[0]=0;
    for(int i=1;i<k;i++){
        for(int j=i-1;j>=0;j--)
            if(meme[i]==-1)meme[i]=meme[j]+abs(a[j]-a[i]);
            else meme[i]=min(meme[i],meme[j]+abs(a[j]-a[i]));
    }

    cout<<mem(n-1);
return 0;
}


Measured memory_bytes: 6644
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;


int num_of_notes;
int num_of_beauty;
ll force_of_repulsion;
ll sum[200001];
ll dp[2001][2001];
int notes[2001];
ll beauty[100001];

ll compute(int i,int j){
  ll lhs = sum[notes[i]];
  ll rhs = (notes[j] - 1 < 0 ? 0 : sum[notes[j] - 1]);

  return (lhs - rhs) / force_of_repulsion;
}

int main(){
  while(~scanf("%d %d %lld",
               &num_of_notes,
               &num_of_beauty,
               &force_of_repulsion)){

    for(int note_idx = 0; note_idx < num_of_notes; note_idx++){
      scanf("%d",notes + note_idx);
      notes[note_idx]--;
    }

    memset(sum,0,sizeof(sum));

    for(int beauty_idx = 0; beauty_idx < num_of_beauty; beauty_idx++){
      scanf("%d",beauty + beauty_idx);
      sum[beauty_idx] = (beauty_idx - 1 >= 0 ? sum[beauty_idx - 1] : 0) + beauty[beauty_idx];
    }

    sort(notes,notes + num_of_notes);

    memset(dp,0x3f,sizeof(dp));

    dp[0][0] = 0;
    for(int i=0;i<num_of_notes;i++){
      int next = i + 1;
      if(next >= num_of_notes) break;
      for(int j=0;j<=i;j++){
        dp[next][j]
          = min(dp[next][j],dp[i][j] + compute(next,i));

        dp[next][i]
          = min(dp[next][i],dp[i][j] + compute(next,j));
      }
    }

    ll res = LINF;
    for(int i=0;i<num_of_notes;i++){
      res = min(dp[num_of_notes - 1][i] + compute(num_of_notes-1,i),res);
    }
    
    printf("%lld\n",res);
  }
}

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

public class PrintAFrame
{
    //??????H cm ?????? W cm ???????´????????????¢?????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int i;
        int k;
        int l;
        string[] strRectangleData;
        List<string> strRectangleList = new List<string>();
        /*---??£?¨???¨---*/

        /*??\???(H W)?????????{H W ????????????0?????´?????????}*/
        for(i = 0;;i++) {
            strRectangleList.Add(Console.ReadLine());
            strRectangleData = strRectangleList[i].Split(' ');
            if (strRectangleData[0] == "0" && strRectangleData[1] == "0"){
                break;
            }
        }

        /*????????????int?????§??´???*/
        int[,] intRectangleData = new int[strRectangleList.Count, 2];

        for (i = 0; i < strRectangleList.Count - 1; i++) {
            strRectangleData = strRectangleList[i].Split(' ');
            intRectangleData[i,0] = int.Parse(strRectangleData[0]);
            intRectangleData[i, 1] = int.Parse(strRectangleData[1]);
            }

        /*????????¢????????????[#]??§??¨???????????????[.]??§??¨???*/
        for (i = 0; i < strRectangleList.Count - 1; i++) {
            for (k = 0; k < intRectangleData[i, 0]; k++) {
                for (l = 0; l < intRectangleData[i, 1]; l++) {
                    if (k == 0 || k == intRectangleData[i, 0] - 1) {
                        Console.Write("#");
                    }
                    else if (l == 0 || l == intRectangleData[i, 1] - 1){
                        Console.Write("#");
                    }
                    else {
                        Console.Write(".");
                    }
                }
                Console.Write("\n");
            }
            Console.Write("\n");
        }
    }
}

Measured memory_bytes: 8980
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)



int main() {
    string s;
    cin >> s;
    s.insert(s.begin() + 4, ' ');
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,d;
    cin >> n >> d;
    int rs = 0;
    for (int i = 0; i < n; i++){
        long double x,y;
        cin >> x >> y;
        if (sqrt((x*x) + (y * y)) <= d){
            rs++;
        }
    }
    ctn(rs);
    return 0;
}

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

int main() {
    int m,d,c=0;
    std::cin >> m >> d;
    for (int i = 1; i <= m ; i++ ) {
        /* code */
        for(int j=1;j<=d;j++){
            if(j/10*(j%10)==i&&j%10>1&&j/10>1){
                c++;
            }
        }
    }
    std::cout << c << std::endl;
}


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

int main(){
    
    int i, N;
    cin >> N;
    
    long long int A[N], max, sum;
    max = 0;
    sum = 0;
    
    for ( i = 0; i < N; i++ ){
        cin >> A[i];
        
        if (A[i] < max){
            sum += (max - A[i]);
        
        } else {
            max = A[i];
        }
    }
    
    cout << sum << "\n";
    
    return 0;
}



Measured memory_bytes: 5072
n = int(input())
A = [int(x) for x in input().split()]

ans = 'DENIED'
judge = []
for i in A:
    if i % 2 == 0:
        if i % 3 == 0 or i % 5 == 0:
            judge.append(True)
        else:
            judge.append(False)
            
if all(judge):
    ans = 'APPROVED'
    print(ans)
else:
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  bool d=false;
  rep(i,1000000){
    if((a*(i+1)-c)%b==0){
    d=true;
      break;
    }
  }
  if(d) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, a, b, c;
	string ans;
	bool f = true;
	cin >> n >> a >> b >> c;
	string s[n];
	for (int i = 0; i < n; i++){
		cin >> s[i];
	}
	for (int i = 0; i < n; i++){
		if (s[i] == "AC"){
			if ((a == 0 && c == 0) || a < 0 || b < 0 || c < 0)
				f = false;
			if (s[i + 1] == "AB" && b == 0 && a == 1){
				ans += 'A';
				a++;
				c--;
			}else if (s[i + 1] == "BC" && b == 0 && c == 1){
				ans += 'C';
				c++;
				a--;
			}else if (a > c){
				ans += 'C';
				c ++;
				a --;
			}else{
				ans += 'A';
				a++;
				c--;
			}
		}else if (s[i] == "AB"){
			if ((a == 0 && b == 0) || a < 0 || b < 0 || c < 0){
				f = false;
			}
			if (s[i + 1] == "AC" && c == 0 && a == 1){
				ans += 'A';
				a++;
				b--;
			}else if (s[i + 1] == "BC" && c == 0 && b == 1){
				ans += 'B';
				b++;
				a--;
			}else if (a > b){
				ans += 'B';
				b++;
				a--;
			}else{
				ans += 'A';
				a++;
				b--;
			}
		}else{
			if ((b == 0 && c == 0) || a < 0 || b < 0 || c < 0)
				f = false;
			if (s[i + 1] == "AB" && a == 0 && b == 1){
				ans += 'B';
				b++;
				c--;
			}else if (s[i + 1] == "AC" && a == 0 && c == 1){
				ans += 'C';
				c++;
				b--;
			}else if (b > c){
				ans += 'C';
				c++;
				b--;
			}else{
				ans += 'B';
				b++;
				c--;
			}
		}
	}
	if (f){
		cout << "Yes\n";
		for (int i = 0; i < ans.size(); i++){
			cout << ans[i] << endl;
		}
	}else{
		cout << "No\n";
	}
	cerr << a << ' ' << b << ' ' << c;
}


Measured memory_bytes: 6884
import itertools

k = int(input())
arr = {i:{j:0 for j in range(k)} for i in range(k)}
def gcd(a, b):
    if a < b:
        a, b = b, a
    for i in range(1000):
        if a % b == 0:
            return b        
        b, a = a % b, b

ans = 0 
for a in range(k):
    for b in range(a, k):
        tmp = gcd(a + 1, b + 1)
        arr[a][b] = tmp
        arr[b][a] = tmp

for a in range(k):
    for b in range(a, k):
        tmp = arr[a][b]
        for c in range(k):
            if a != b:
                ans += arr[tmp - 1][c] * 2
            else:
                ans += arr[tmp - 1][c]
print(ans)

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
#define print(var) std::cout<<#var"="<<var<<std::endl
using Graph = vector<vector<int>>;

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    vector<vector<long>> dp(len, vector<long>(13));
    if(s[0] == '?'){
        for(int i=0;i<=9;i++){
            dp[0][i] = 1;
        }
    }
    else{
        dp.at(0).at((int)(s[0]-'0')) = 1;
    }    

    for(int i=0;i<len-1;i++){
        for(int j=0;j<13;j++){
            if(s[i+1]=='?'){
                for(int k=0; k<=9; k++){
                    int go = (j*10 + k) % 13; 
                    dp[i+1][go] += dp[i][j];
                }
            }
            else{
                int go = (j*10 + (int)(s[i+1]-'0')) % 13; 
                //cout << s[i] << " " << j << " " << (int)(s[i]-'0') << " "<< go << " " << dp[i][j] << endl;
                dp[i+1][go] += dp[i][j];
            }
        }
        for(int j=0;j<13;j++){
            dp[i+1][j] = dp[i+1][j] % 1000000007;
        }
    }
    cout << dp[len-1][5];
        //for(auto row:dp){for(auto elem:row){cout << elem << " ";}cout << endl;}


}


Measured memory_bytes: 13568
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;
    long S;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] H = new long[N];
        for(int i= 0;i<N;i++){
            H[i] = sc.nextInt();
        }
        boolean ans = true;
        for(int i = N-2;i >= 0;i--){
            if(H[i]-1 == H[i+1]){
                H[i]--;
            }else if(H[i+1]-H[i] < -1 ){
                ans = false;
            }
        }
        System.out.println(ans?"Yes":"No");
    }

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


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

#define INF (1LL << 31 - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define fi first
#define se second

inline void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int n, k;
char d[10];

int main() {
    cin >> n >> k;
    rep(i, k) {
        cin >> d[i];
    }

    while (true) {
        string t = to_string(n);
        int si = t.size();
        rep(i, si) {
            rep(j, k) {
                if (t[i] == d[j]) {
                    n++;
                    goto L;
                }
            }
        }

        break;

        L:;
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    // reverse(as.begin(), as.end());
    ll num = 0, ans = 0;
    for(int i = n - 1; i >= 0; i--){
        if(as[i] > i || num > as[i]){
            cout << -1 << '\n';
            return 0;
        }
        if(as[i] != num){
            ans += as[i];
        }
        prints(i, ans);
        num = as[i];
        num = max(num - 1, 0ll);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1024
n = gets.chomp.to_i

n.times do 
  l = gets.chomp.split
  3.times do |i|
    l[i] = l[i].to_i
  end
  l.sort!
  if l[0]**2 + l[1]**2 == l[2]**2
    puts "YES"
  else
    puts "NO"
  end
end

Measured memory_bytes: 6112