akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long n , m ;
int ans = 1 ;
signed main() {
  scanf("%lld %lld", & n , & m) ;
	for(register int i = 2 ; 1ll * i * i <= n ; i ++)
  	if(n % i == 0) {
  		while(n % i == 0) n /= i ;
  		if(m % i == 0) ans ++ ;
  		while(m % i == 0) m /= i ;
  	}
	if(n != 1 && m % n == 0) ans ++ ;
	printf("%d\n" , ans) ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
using namespace std;
int x[10], y[10];
double dist(int i,int j){
    int dx=x[i]-x[j];
    int dy=y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
}

int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++)cin>>x[i]>>y[i];
    double sum=0;
    vector<int>v(N);
    for(int i=0;i<N;i++)v[i]=i;
    do{
        for(int i=0;i<N-1;i++)sum+=dist(v[i],v[i+1]);
    }while(next_permutation(v.begin(),v.end()));
    int kai=1;
    for(int i=N;i>=1;i--)kai*=i;
    cout<<fixed<<setprecision(7)<<sum/kai;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	int a, b, c, d;
	int count;

	while(scanf("%d", &n) != EOF) {
		count = 0;

		for(a = 0; a <= 9; a++) {
			for(b = 0; b <= 9; b++) {
				for(c = 0; c <= 9; c++) {
					for(d = 0; d <= 9; d++) {
						if( (a+b+c+d) == n ) {
							count ++;
						}
					}
				}
			}
		}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    char a[3][3];
    F0R(i,3) F0R(j,3) {cin >> a[i][j]; if(i == j) cout << a[i][j];}
    cout << endl;



    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	//IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int n;
		cin >> n;
		int x = n/1000;
		if(n%1000!=0)
			x++;
		int tot = x*1000;
		cout << tot - n << endl;
	}
}



Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> p(N + 1);
  REP1(i, N) cin >> p[i];
  vector<int> a(N + 1), b(N + 1), c(N + 1);
  REP1(i, N) c[p[i]] = i;
  REP1(i, N) {
    a[i] = 30000 * i;
    b[i] = 30000 * (N - i) + c[i];
  }
  REP1(i, N) {
    if (i != 1) cout << " ";
    cout << a[i];
  }
  cout << endl;
  REP1(i, N) {
    if (i != 1) cout << " ";
    cout << b[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 896
void main() {
	const int INF = 2000000000;
	const int MOD = 1000000007;
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto arr = M.iota.map!(i => ri).array;

	auto dp = new int[](N+1);
	dp[0] = 1;
	foreach(v; arr) {
		dp[v] = INF;
	}
	if(dp[1] != INF) dp[1] = 1;
	foreach(i; 2..N+1) {
		if(dp[i] == INF) continue;
		int tmp;
		if(dp[i-1] != INF) tmp += dp[i-1];
		if(dp[i-2] != INF) tmp += dp[i-2];
		tmp %= MOD;
		dp[i] = tmp;
	}
	dp.back.writeln;
}

// =======================111=1===========

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.ascii : toLower;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 4092
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1e9+7 ;

int main(){
  ll n,l;
  cin >> n >> l;
  ll a[n];
  rep(i,n)cin >> a[i];
  rep(i,n-1){
    if(a[i]+a[i+1]>=l){
      cout << "Possible" << endl;
      int p=i;
      rep(i,p)cout << i+1 << endl;
      for(int i=n-2;i>=p+1;i--)cout << i+1 << endl;
      cout << p+1 << endl;
      return 0;
    }
  }
  cout << "Impossible" << endl;
return 0;}

Measured memory_bytes: 1536
class Dice

  def initialize(surfaces)
    @surfaces = surfaces.dup 
  end

  def top
    @surfaces[0]
  end

  def N
    old = @surfaces.dup
    @surfaces[4] = old[0]
    @surfaces[5] = old[4]
    @surfaces[1] = old[5]
    @surfaces[0] = old[1]
    self
  end

  def E
    old = @surfaces.dup
    @surfaces[2] = old[0]
    @surfaces[5] = old[2]
    @surfaces[3] = old[5]
    @surfaces[0] = old[3]
    self
  end

  def S
    old = @surfaces.dup
    @surfaces[1] = old[0]
    @surfaces[5] = old[1]
    @surfaces[4] = old[5]
    @surfaces[0] = old[4]
    self
  end

  def W
    old = @surfaces.dup
    @surfaces[3] = old[0]
    @surfaces[5] = old[3]
    @surfaces[2] = old[5]
    @surfaces[0] = old[2]
    self
  end
end

n = gets.chomp.split.map(&:to_i)
c = gets.chomp

d = Dice.new(n)
c.each_char{|m| d.send(m) }
puts d.top

Measured memory_bytes: 8704
#!/usr/bin/env python3
import sys


def solve(S: str):
    start = 0
    answer = 0
    s = ""
    prev = ""
    while start < len(S):
        s += S[start]
        if prev == s:
            start +=1
            continue
        else:
            prev = s
            s = ""
            start +=1
            answer +=1
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3508
n,k = map(int,input().split())
V = [0]+list(map(int,input().split()))+[0]
S = [0]
for v in V[1:-1]:
    S.append(S[-1]+v)

ans = 0
leftminus = []
leftm = 0
for left in range(min(n+1,k+1)):
    if V[left] < 0:
        leftminus.append(V[left])
        leftm += 1
    for right in range(n+1,left,-1):
        rightminus = []
        tempans = S[left]
        times = left + n - right + 1
        rm = leftm
        if times > k:
            break
        for v in V[right:]:
            tempans += v
            if v < 0:
                rightminus.append(v)
                rm += 1
        minus = rightminus+leftminus
        minus.sort()
        for j in range(min(k-times,rm)):
            tempans -= minus[j]
        if ans < tempans:
            ans = tempans
print(ans)

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

const int N = 220000;
const int mod = 998244353;

char a[N];
int x[N];
int dp[N];
int pw[N];
int res[N];

vector<int> divisor[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	for (int i = 2; i < N; i++) for (int j = i; j < N; j += i) divisor[j].push_back(i); 
	pw[0] = 1;
	for (int i = 1; i < N; i++) pw[i] = (long long)pw[i - 1] * 2 % mod;
	int n; cin >> n >> a;
	bool ismax = 1;
	for (int i = 0; i < n; i++) if (a[i] == '0') ismax = 0;
	int cur = 1;
	for (int i = n - 1; i >= 0; i--) {
		x[i] = a[i] - '0' + cur;
		if (x[i] == 2) x[i] = 0, cur = 1;
		else cur = 0;
	}
	for (int i = 1; i <= n; i++) {
		if (n % i) continue;
		if (ismax) {
			dp[i] = pw[i];
			continue;
		}
		for (int j = 0; j < i; j++) {
			if (x[j] == 0) continue;
			dp[i] += pw[i - j - 1];
			if (dp[i] >= mod) dp[i] -= mod;
			continue;
		}
		bool ok = 0;
		for (int j = i; j < n; j++) {
			int now;
			if ((j / i) & 1) now = x[j % i] ^ 1;
			else now = x[j % i];
			if (now == x[j]) continue;
			if (now < x[j]) ok = 1;
			break;
		}
		dp[i] += ok; if (dp[i] >= mod) dp[i] -= mod;
	}
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (n % i == 0 && n / i % 2 == 1) {
			for (int j = i * 3; j <= n; j += 2 * i) {
				dp[j] = (dp[j] + mod - dp[i]) % mod;
			}
			sum = (sum + dp[i] * 2LL * i) % mod;
		}
	}
	cout << sum << endl;
//	int sum = 0;
//	for (int k = 1; k <= n; k++) {
//		int L = n / k;
//		int C = n % k;
//		if (C != 0 && k % (C + C) == 0) {
//			res[k] += dp[C];
//			if (res[k] >= mod) res[k] -= mod;
//			sum += dp[C];
//			if (sum >= mod) sum -= mod;
//			for (int d : divisor[L]) {
//				res[d * k] -= dp[C];
//				if (res[d * k] < 0) res[d * k] += mod;
//			}
//		}
//	}
////	for (int i = 1; i <= n; i++) {
////		if (n % i == 0 && ((n / i) & 1)) {
////			sum += dp[i];
////			if (sum >= mod) sum -= mod;
////		}
////	}
//	int xx = 0;
//	for (int i = 0; i < n; i++) xx = (long long)(xx * 2LL + x[i]) % mod;
//	if (ismax) xx = pw[n];
//	xx -= sum; if (xx < 0) xx += mod;
//	int ans = 2LL * n * xx % mod;
//	for (int i = 1; i <= n; i++) {
//		ans = (ans + (long long)i * res[i]) % mod;
//	}
//	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 26496
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	//input = input.split("\n");
	tmp = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var output_string="";
	output_string= a * b % 2 == 0 ? "Even" : "Odd" ;
	//出力
	console.log(output_string);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int main(void){
int sx,sy,tx,ty;
cin >> sx >> sy >> tx >> ty;
const int dx=tx-sx,dy=ty-sy;
cout<<string(dy,'U')<<string(dx,'R');
// Path 2
cout<<string(dy,'D')<<string(dx,'L');
// Path 3
cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
// Path 4
cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
// EndLine
cout << endl;
return 0;
}

Measured memory_bytes: 256
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var str = Console.ReadLine().SplittedStringToInt32List();
        Console.WriteLine(str[0]*str[1] >= str[2]*str[3] ? str[0]*str[1] : str[2]*str[3]);
    }


    public class Edge
    {
        public int From;
        public int To;
        public int Cost;
    }

    public static List<KeyValuePair<int,int>> GetShortestPathes(int s, IEnumerable<Edge> edges, int vertices)
    {
        var ls = new KeyValuePair<int, int>[vertices];

        return ls.ToList();
    }


    #region ライブラリ

    #region 文字列処理

    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();

    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
    #region DeepClone
    public static T DeepClone<T>(this T src)
    {
        using (var memoryStream = new MemoryStream())
        {
            var binaryFormatter
              = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, src);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return (T)binaryFormatter.Deserialize(memoryStream);
        }
    }
    #endregion

    public static int Gcd(int a,int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    public static BigInteger Gcd(BigInteger a, BigInteger b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }


    public static BigInteger Factorial(int n)
    {
        var dp = new BigInteger[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] * (i + 1);
        }
        return dp[n - 1];
    }

    public static List<int> PrimeFactorize(int n)
    {
        var bases = n;
        var num = (int)Math.Pow(n, 0.5);
        var ls = new List<int>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        var nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }

    #endregion

}


Measured memory_bytes: 11348
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("READ.txt", "r", stdin)
#define Write          freopen("OUTPUT.txt", "w", stdout)
#define INF            1000000007

vector<int>adj[200005];
int visited[200005]={0};
int ans=0,Max=0;;

void Dfs(int i)
{
	if(visited[i]==1) return;
	visited[i]=1;
	ans++;
	Max=max(ans,Max);
	for(int j=0;j<adj[i].size();j++)
	{
		Dfs(adj[i][j]);
	}
}

void solve()
{
    double S,T,D;
    cin>>S>>T>>D;
    if((S/D)<=T) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

int main()
{
    fast
    #ifndef ONLINE_JUDGE
    Read;
    Write;
    #endif
    //sieve();
    //int cnt=1;
    //int t; cin>>t; while(t--) solve();
    solve();
}

Measured memory_bytes: 8412
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String[][] field = new String[h][w];
    for (int i = 0; i < h; i++) {
      field[i] = sc.next().split("");
    }
    int[][] directions = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (field[i][j].equals("#")) {
          boolean flg = false;
          for (int[] direction : directions) {
            if (i + direction[0] >= 0 && i + direction[0] < h && j + direction[1] >= 0 && j + direction[1] < w) {
              flg = flg || "#".equals(field[i + direction[0]][j + direction[1]]);
            }
          }
          if (!flg) {
            System.out.println("No");
            return;
          }
        }
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n;
    cin >> n;
    vector<psi> v(n);
    string S;
    int x;
    map<psi, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> S >> x;
        v[i] = psi(S, -x);
        mp[psi(S, -x)] = i + 1;
    }
    sort(v.begin(), v.end());
    for (auto p : v) {
        cout << mp[p] << '\n';
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	scanf("%d",&a);
	b=a/3600;
	c=a%3600/60;
	d=a-(b*3600+c*60);
	printf("%d:%d:%d\n",b,c,d);
	return 0;
}

Measured memory_bytes: 592
S = input()
ACGT = ['A', 'C', 'G', 'T']
ans = []
if len(S) == 1:
    if S in ACGT:
        print(1)
    else:
        print(0)
else:
    for i in range(len(S)):
        j = 0
        while i + j < len(S):
            if S[i + j] in ACGT:
                j += 1
            else:
                ans.append(S[i : i + j])
                break
        if i + j == len(S):
            ans.append(S[i : len(S)])
    
    print(max([len(x) for x in ans]))

Measured memory_bytes: 3064
S = input()
flag = True
for i in range(0,len(S),2):
    if flag and (S[i]=='R' or S[i]=='U' or S[i]=='D') :
        flag=True
    else:
        flag=False
for i in range(1,len(S),2):
    if flag and (S[i]=='L' or S[i]=='U' or S[i]=='D') :
        flag=True
    else:
        flag=False
if flag:
    print('Yes') 
else:
    print('No')


Measured memory_bytes: 38384
def main():
    N = int(input())
    Prices = list(map(int, input().split()))

    current_money = 1000
    cheap = Prices[0]
    index_cheap = 1
    index_expen = 1

    N_stock = 0


    while (True):

        if (index_expen >= N or index_cheap >= N):
            break
        
        while (index_cheap < N):
            if (cheap >= Prices[index_cheap]):
                cheap = Prices[index_cheap]
                index_cheap += 1
            
            else:
                cheap = Prices[index_cheap]
                index_expen = index_cheap
                index_cheap -= 1
                break

        if (index_expen >= N or index_cheap >= N):
            break

        N_toBuy = current_money // Prices[index_cheap]
        current_money += (Prices[index_expen] - Prices[index_cheap]) * N_toBuy
        

        index_cheap = index_expen


    print(current_money)



if __name__ == '__main__':
    main()

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MAXN = 3003;
int n, t;
pii p[MAXN];
int dp[MAXN][MAXN];

int solve(int time, int dish) {
    if (time >= t or dish >= n) {
        return 0;
    }

    int& res = dp[time][dish];
    if (res != -1)
        return res;

    return res = max(solve(time, dish + 1), p[dish].second + solve(time + p[dish].first, dish + 1));
}

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

    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        cin >> p[i].first >> p[i].second;
    }

    sort(p, p + n);

    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << '\n';
    
    return 0;
}


Measured memory_bytes: 35712
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    long long int N, X, Y, D, a = 0;
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        cin >> X >> Y;
        if (D >= hypot(X, Y)) a++;
    }
    cout << a;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0; i<x; i++)
#define repn(i,x) for(int i=1; i<=x; i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int main() {
    int k, s;
    int x, y, z;
    cin >> k >> s;
    if (s == 0)
        cout << 1;
    else
    {
        int count = 0;
        for (int x = 0; x <= k; x++)
            for (int y = 0; y <=k; y++) {
                z = s - x - y;
                if (z >= 0 && z <= k)
                    count++;
            }
        cout << count;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
  
struct node{
  struct node *par;
  struct node *left;
  struct node *right;
  int key;
};
typedef struct node* NodePointer;
  
void init(void);
NodePointer makenode(int);
void insert(int,NodePointer);
void preorder(NodePointer);
void inorder(NodePointer);
NodePointer find(int,NodePointer);
void delete_node(NodePointer); 
NodePointer tree_successor(NodePointer);
NodePointer tree_minimum(NodePointer);
 
NodePointer head, tail;
  
int main(){
  char str[7];
  int n,k;
  NodePointer x;
  
  init();
  scanf("%d" ,&n);
  while(n--){
    scanf("%s" ,str);
  
    if(str[0] == 'i'){
      scanf("%d" ,&k);
      insert(k, head);
    }else if(str[0] == 'p'){
      inorder(head->right);
      puts("");
      preorder(head->right);
      puts("");
    }else if(str[0] == 'f'){
      scanf("%d" ,&k);
      if(find(k,head->right) != NULL){
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }else{
      scanf("%d" ,&k);
      x = find(k,head->right);
      delete_node(x);
    }
  }
  
  return 0;
}
  
void init(){
  head = makenode(-1);
  tail = makenode(-1);
  head->par = head;;
  head->right = tail;
  head->left = tail;
}
  
NodePointer makenode(int k){
  NodePointer x;
  
  x = malloc(sizeof(struct node));
  x->key = k;
  x->left = x->right = tail;
  
  return x;
}
  
void insert(int k, NodePointer p){
  if(k < p->key){
    if(p->left == tail){
      p->left = makenode(k);
      p->left->par = p;
    }else{
      insert(k,p->left);
    }
  }else{
    if(p->right == tail){
      p->right = makenode(k);
      p->right->par = p;
    }else{
      insert(k,p->right);
    }
  }
}
  
void preorder(NodePointer node){
  if(node != tail){
    printf(" %d", node->key);
    preorder(node->left);
    preorder(node->right);
  }
}
  
void inorder(NodePointer node){
  if(node != tail){
    inorder(node->left);
    printf(" %d", node->key);
    inorder(node->right);
  }
}
  
NodePointer find(int k,NodePointer node){
  if(node == tail){
    return NULL;
  }
  
  if(node->key == k){
    return node;
  }else if(node->key < k){
    return find(k,node->right);
  }else{
    return find(k,node->left);
  }
}
 
void delete_node(NodePointer node){
  NodePointer x,y;
  if(node->left == tail || node->right == tail){
    y = node;
  }else{
    y = tree_successor(node);
  }
 
  if(node->left != tail){
    x = y->left;
  }else{
    x = y->right;
  }
 
  if(x != tail){
    x->par = y->par;
  }
  if(y->par == tail){
    node->par = x;
  }else if(y == y->par->left){
    y->par->left = x;
  }else{
    y->par->right = x;
  }
 
  if(y != node){
    node->key = y->key;
  }
}
 
NodePointer tree_successor(NodePointer x){
  NodePointer y;
 
  if(x->right != tail){
    return tree_minimum(x->right);
  }
 
  y = x->par;
  while(y != tail && x == y->right){
    x = y;
    y = y->par;
  }
 
  return y;
}
 
NodePointer tree_minimum(NodePointer x){
  while(x->left != tail){
    x = x->left;
  }
  return x;
}


Measured memory_bytes: 20468
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define lli long long int  
#define ll  long long 
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(),v.rend() //reverse
#define vl   vector<lli>
#define mii unordered_map<ll,ll>
#define pb push_back
double pi = 2*acos(0.0);
const int INF = 1e9 + 7;
//ull power(ull a,ull b){ ull res=1;while(b){if(b&1)res=res*a;b=b/2; a=(a*a); }return res;}
bool sortinrev(const pair<int,int> &a,   const pair<int,int> &b) {  if(a.second==b.second) return a.first>b.first;  return (a.second > b.second);} 






void WetPitch()
{
  string s;
  cin>>s;
  ull sum=0;
  for(int i=0;i<s.length();i++)
  {
   sum+=s[i]-'0';
  }
  if(sum%9==0)
  	cout<<"Yes"<<endl;
  else
  	cout<<"No"<<endl;




}     
signed main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	lli tst;
    tst=1; 
    //cin>>tst;
    while(tst--)
    WetPitch();
    return 0;
 } 

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

int main(void){
    int n;
    cin >> n;
    int a[n];
    vector<vector<int>> x(n+1,vector<int>(n+1,-1));
    
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            int p,q;
            cin >> p >> q;
            x[i][p-1] = q;
        }
    }
    
    int alina = 0;
    for(int i = 0;i < (1 << n);i++){
        int b[n],gray = 0;
        rep(j,n){
            if(i & (1 << j)){
                b[j] = 1;
                gray++;
            }
            else b[j] = 0;
        }
        
        bool check = true;
        rep(j,n){
            if(i & (1 << j)){
                rep(l,n){
                    if(x[j][l] == -1)continue;
                    
                    if(b[j] == 1){
                        if(x[j][l] != b[l])check = false;
                    }
                }
            }
        }
        
        if(check)alina = max(alina,gray);
    }
    
    cout << alina << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int n;
    cin >> n;
    vector<vector<int>> tmp(n, vector<int>(30,0));
    REP(i, n){
        string S;
        cin >> S;
        SORT(S);
        for(auto && s : S) REP(j, 30){
            if((s-'a') == j) tmp[i][j]++;
        }
    }

    string ans = "";
    REP(i, 30){
        int m = INF;
        REP(j, n){
            m = min(m, tmp[j][i]);
        }
        REP(j, m){
            ans.push_back((char)('a'+i));
        }
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll x;
    cin >> x;

    ll a,b;
    ll top = 1e9+1;


    reps(i,-150,150){
        reps(j,-150,150){
            ll tmp = pow(i,5) - pow(j,5);
            if(tmp == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4096
import java.util.Scanner;
import java.util.Arrays;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S=sc.nextInt();
    int W=sc.nextInt();
  if (W-S>=0) {
    System.out.println("unsafe");
  }else{
    System.out.println("safe");  
  }


  }
}


Measured memory_bytes: 35724
#include <stdio.h>
int main(void)
{
	int a, b, c;					// クッキーa,b,cの個数
	int ta, tb, tc;					// クッキー交換時のtmp
	int cnt;						// クッキーの交換回数
	scanf("%d %d %d", &a, &b, &c);
	//printf("a = %d, b = %d, c = %d\n", a, b, c);
	// ここから
	cnt = 0;
	while (1) {
		// a = b = cでaが偶数ならば無限に交換できる
		if (((a == b) && (b == c)) && (a % 2 == 0)) {
			cnt = -1;
			break;
		}
		// a, b, cのいずれかが奇数ならば交換をやめる
		if ((a % 2) || (b % 2) || (c % 2)) {
			break;
		}
		// 交換回数の更新
		cnt++;
		// クッキーの交換
		ta = b / 2 + c / 2;
		tb = a / 2 + c / 2;
		tc = a / 2 + b / 2;
		a = ta;
		b = tb;
		c = tc;
		//printf("a = %d, b = %d, c = %d\n", a, b, c);
	}
	// ここまで交換処理
	printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >> a;
  if(a=="SRS"||a=="RSR"||a=="SSR"||a=="RSS"){
    cout << "1" << endl;
  }
  else if(a=="RRS"||a=="SRR"){
    cout << "2" << endl;
  }
  else if(a=="RRR"){
    cout << "3" << endl;
  }
  else{
    cout << "0" << endl;
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

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; }

inline int gcd(int a, int b) { return (a%b == 0) ? b : gcd(b, a%b); }
inline int fac(int n) { return (n==0) ? 1 : n * fac(n - 1); }

int count_matches(string a, string b) {
    bool alpha[27] = {};
    int cnt = 0;
    for (int i = 0; i < a.length(); i++)
    {
        int code = a[i] - 'a';
        if (alpha[code] == false && find(b.begin(), b.end(), a[i]) != b.end())
        {
            alpha[code] = true;
            cnt++;
        }
    }
    return cnt;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int max = 0;
    for (int i = 1; i < n; i++)
    {
        string a = s.substr(0, i);
        string b = s.substr(i, n - i + 1);
        int matches = count_matches(a, b);
        if (matches > max) {
            max = matches;
        }
    }

    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = 1e9+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
// priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > pq;
// cout << fixed << setprecision(5) << sum << endl;

template<typename T> //最大公約数
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T> //最小公倍数
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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 nCr(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long MOD) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long Mod) {
    return modpow(a, Mod - 2, Mod);
}


bool IsPrime(int x){
    for (int i = 2; i*i <= x; i++){
        if (x % i == 0){
            return false;
        }
    }
    return true;
}

vector<pair<ll, ll> > PrimeFactor(ll N){
    vector<pair<ll, ll> > prime;
    for (int i = 2; i*i <= N; i++){
        if (N % i != 0) continue;
        int cnt = 0;
        while (N % i == 0){
            cnt++;
            N /= i;
        }
        prime.push_back({i, cnt});
    }
    if (N > 1){
        prime.push_back({N, 1});
    }
    return prime;
}

vector<pair<ll, ll> > CountPrime(ll N){
    vector<pair<ll, ll> > prime;
    for (ll i = 2; i * i <= N; i++){
        if (N % i != 0) continue;
        ll cnt = 0, n = N;
        while (n % i == 0){
            cnt++;
            n /= i;
        }
        prime.push_back({i, cnt});
    }
    prime.push_back({N, 1});
    return prime;
}

// N人、残りの個数
ll dp[110][100100];

int main(){
    int N; cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++){
        cin >> T[i];
    }
    ll lcm = T[0];
    for (int i = 1; i < N; i++){
        lcm = lcm / GCD(lcm, T[i]) * T[i];
    }
    cout << lcm << endl;
}


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

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

  string S;
  cin >> S;

  auto count_unique_chars = [](string s, int pos, int len){
                              set<char> st;
                              for(int i = pos; i < pos + len; i++){
                                st.insert(s[i]);
                              }
                              return st.size();
                            };

  int cnt_all = count_unique_chars(S, 0, N);
  int ret = 0;
  for(int i = 0; i < N; i++){
    // [0, i), [i: N)
    int cnt1 = count_unique_chars(S, 0, i),
      cnt2 = count_unique_chars(S, i, N - i);
    ret = max(ret, cnt1 + cnt2 - cnt_all);
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	
	if(a >= b){cout << "delicious" << endl;
		
	}
	else if(a+x >= b){
		cout << "safe" << endl;
	}
	else{
		cout << "dangerous" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int score = 1000;
    	int scorecount =0;
    	int N=sc.nextInt();
    	int T=sc.nextInt();
    	int A[] = new int[N];
		int B[] = new int[N];

    	for(int i = 0;i<N;i++){
    		A[i]= sc.nextInt();
    		B[i]=sc.nextInt();

    	if(A[i]<=score && B[i]<=T){
    		score = A[i];
    		scorecount++;
    	}

    	}
    	if(score == 1000 && scorecount == 0){
    		System.out.println("TLE");
    	}else{
    		System.out.println(score);
    	}



    }
}

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

#define CO const
#define IN inline
typedef long long int64;

template<class T> IN T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int mod=1e9+7,i2=(mod+1)/2;
IN int add(int a,int b){
	return (a+=b)>=mod?a-mod:a;
}
IN int mul(int a,int b){
	return (int64)a*b%mod;
}
IN int fpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1) ans=mul(ans,a);
	return ans;
}

CO int N=110;
int n;
namespace seg{
	pair<int,int> val[4*N];
	
	#define lc (x<<1)
	#define rc (x<<1|1)
	#define mid ((l+r)>>1)
	void build(int x,int l,int r){
		if(l==r) {val[x]={read<int>(),l}; return;}
		build(lc,l,mid),build(rc,mid+1,r);
		val[x]=min(val[lc],val[rc]);
	}
	pair<int,int> query(int x,int l,int r,int ql,int qr){
		if(ql<=l and r<=qr) return val[x];
		if(qr<=mid) return query(lc,l,mid,ql,qr);
		if(ql>mid) return query(rc,mid+1,r,ql,qr);
		return min(query(lc,l,mid,ql,qr),query(rc,mid+1,r,ql,qr));
	}
	#undef lc
	#undef rc
	#undef mid
}

int num,L[N],R[N],H[N];
vector<int> to[N];

int build(int l,int r){
	int x=++num;
	L[x]=l,R[x]=r,H[x]=seg::query(1,1,n,l,r).first;
	vector<int> pos;
	for(int i=l;i<=r;){
		pair<int,int> v=seg::query(1,1,n,i,r);
		if(v.first>H[x]) break;
		pos.push_back(v.second);
		i=v.second+1;
	}
	pos.push_back(r+1);
	int last=l-1;
	for(int now:pos){
		if(last+1<=now-1){
			to[x].push_back(build(last+1,now-1));
			H[to[x].back()]-=H[x];
		}
		last=now;
	}
	return x;
}

int F[N][2],coef=1;

void dfs(int x){
//	cerr<<x<<" "<<L[x]<<" "<<R[x]<<" H="<<H[x]<<endl;
	int len=R[x]-L[x]+1;
	for(int y:to[x]) dfs(y),len-=R[y]-L[y]+1;
	F[x][0]=fpow(2,len),F[x][1]=2;
	for(int y:to[x]){
		F[x][0]=mul(F[x][0],add(F[y][0],mul(2,F[y][1])));
		F[x][1]=mul(F[x][1],F[y][1]);
	}
	F[x][0]=add(F[x][0],mod-F[x][1]);
	F[x][1]=mul(F[x][1],fpow(2,H[x]-1));
//	cerr<<x<<" F="<<F[x][0]<<" "<<F[x][1]<<endl;
}

int main(){
	read(n);
	seg::build(1,1,n);
	int root=build(1,n);
	dfs(root);
	int ans=add(F[root][0],F[root][1]);
	ans=mul(ans,coef);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.array;
import std.math;

void main()
{
    auto reader = readln.split;
    int A = reader[0].to!int;
    int B = reader[1].to!int;

    int diff = abs(A - B);
    if (diff % 2 == 0){
        writeln((A + B) / 2);
    } else {
        writeln("IMPOSSIBLE");
    }
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, P;
  string S;
  cin >> N >> P >> S;

  i64 result = 0;

  // 解説を読む

  // P が 2 か 5 のときは、例えば入力 10 などを正常に判定できないので
  // その場合は部分文字列の右端1文字だけで判定する

  if (P != 2 && P != 5) {

    vector<int> rs(P, 0);
    rs[0]++;

    // 10^(N-1-i) % P のあまり
    i64 tr = 1;

    // 繰り越しのあまり
    i64 r = 0;

    RF0(i, N) {
      r = (r + tr * (S[i] - '0')) % P;
      rs[r]++;

      tr = (tr * 10) % P;
    }

    F0R(i, P) {
      result += (i64)rs[i] * (rs[i] - 1) / 2;
    }
  }
  else {
    F0R(i, N) {
      if ((S[i] - '0') % P == 0) {
        result += i + 1;
      }
    }
  }

  cout << result;
}
#endif


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define forr(i, n) for(int i = 0;i < (int)n; i++)
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define mp make_pair
#define test int tests;cin >> tests;while(tests--)
#define endl "\n"
const int INF = 2e9;
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("inputa.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  	int x, n;
  	cin >> x >> n;
  	int arr[n];
  	set<int> s;
  	forr(i, n) {
  		cin >> arr[i];
  		s.insert(arr[i]);
  	}
  	int ans = -INF, mini = INF;
  	for(int i = -2000;i <= 2000; ++i){
  		if(s.count(i)!=0) continue;
  		int diff = abs(x-i);
  		if(diff < mini){
  			mini = diff;
  			ans = i;
  		}
  	}
  	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3672
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='?')s[i]='D';
	}
	cout<<s<<endl;
}


Measured memory_bytes: 3656
#include<iostream>
using namespace std;
#define lli long long int
#include<vector>
#include<algorithm>
int main(){
  lli n,m,l,r,i,j,maxl=0,minir=1e5+1;
  cin>>n>>m;
  //vector<int>v(n+1);
  for(i=1;i<=m;i++){
    cin>>l>>r;
    maxl=max(maxl,l);
    minir=min(minir,r);
  }
  lli k=minir-maxl+1;
  if(k<0)
    cout<<"0";
  else
    cout<<k;
  //cout<<k;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int m, f, r;
	while(1){
		scanf("%d %d %d", &m, &f, &r);

		if(m == -1 && f == -1 && r == -1){
			break;
		}else if(m == -1 || f == -1 || m + f < 30){
			printf("F\n");
		}else if(80 <= m + f){
			printf("A\n");
		}else if(65 <= m + f){
			printf("B\n");
		}else if(50 <= m + f){
			printf("C\n");
		}else if(30 <= m + f){
			if(r >= 50){
				printf("C\n");
			}else{
				printf("D\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 584
using System;
using System.Linq;

namespace ABC146
{
    class A
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            if(S == "SUN") Console.WriteLine(7);
            if(S == "MON") Console.WriteLine(6);
            if(S == "TUE") Console.WriteLine(5);
            if(S == "WED") Console.WriteLine(4);
            if(S == "THU") Console.WriteLine(3);
            if(S == "FRI") Console.WriteLine(2);
            if(S == "SAT") Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M=1e9+7;
const ll inf=1e18+5;
using namespace std;
ll z;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){ 
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
string findWinner(int A[], int n) 
{ 
	int res = 0; 
	for (int i = 0; i < n; i++){ 
		if(A[i]>1) res ^= A[i]; 
	}
	// case when Alice is winner 
	if (res == 0 || n % 2 == 0) 
		return "Alice"; 

	// when Bob is winner 
	else
		return "Bob"; 
} 
void solve(){
		ll a,b;
		cin>>a>>b;
		cout<<a*b<<"\n";
 }


int main(){
	fast();
	solve();
	//cin>>z;
	//while(z--) solve();
	return 0;
}



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

int main() {
    double A,B,H,M,TH,TM,T,ans;
    cin>>A>>B>>H>>M;
    TH=2*M_PI*(H+M/60)/12;
    TM=2*M_PI*M/60;
    T=min(TH-TM,180-(TH-TM));
    ans=sqrt(A*A+B*B-2*A*B*cos(T));
    printf("%.10f\n",ans);
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }   
}

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    for(int i = a; i <= a*b; i+= a){
        ans |= i % b == c;
    }
    print_ans(ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
vector<ll> rain;
int main(){
  int n;
  cin>>n;
  ll sum=0;
  for(int i=0;i<n;i++){
    ll r;
    cin>>r;
    rain.push_back(r);
    sum+=r;
  }

  ll ans1=sum;
  for(int i=1;i<n;i+=2){
    ans1-=rain[i]*2;
  }
  cout<<ans1<<" ";
  for(int i=1;i<n;i++){
    cout<<rain[i-1]*2-ans1<<(i==n-1?"\n":" ");
    ans1=rain[i-1]*2-ans1;
  }
}


Measured memory_bytes: 2164
#include <iostream>
#include <math.h>
using namespace std;
using ull = unsigned long long;

int main(){
    string s;
    cin >> s;
    
    ull ans = 0;
    
    int size = s.size();
    ull nums[size][size];
    
    nums[0][0] = (int)(pow(2, size));
    for(int i = 0; i < s.size(); ++i){
        for(int j = 0; j <= i; ++j){
            nums[i][j] = (i == j ? nums[0][0] / 2 : nums[i-1][j] / 2);
        }
    }

    

    for(int i = 0; i < size; ++i){
        for(int j = 0; j <= i; ++j){
            ans += (s[size-i-1] - '0')*(ull)(pow(10, i - j))*nums[i][j];
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 632
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main()
{
  int N;
  cin >> N;
  set <string> W;
  bool ans = true;
  char c = '\0';
  for (int i = 0; i < N; i++) {
    string w;
    cin >> w;
    W.insert(w);
    if (c!='\0') {
      if (c!=w[0]) {
        ans = false;
      }
    }
    c = w[w.length()-1];
  }
  if (N > W.size()) ans = false;
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628