akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;

	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		
		var n = p[0];
		long wa = p[1];
		for(int i = 1; i < n; i++)
		{
			wa *= (p[1]-1);
		}
		Console.WriteLine(wa);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
using namespace std;
#define INF 10e10
static const int MAX_N=100,MAX_W=10e5;
int w[MAX_N],v[MAX_N];
long dp[MAX_W];
int main(void){
	int W,N;
		cin >> N >> W;
	for(int i=0;i<N;i++)
		cin >> w[i] >> v[i];
	for(int i=0;i<N;i++){
		for(int j=W;j>=0;j--){
			if(j>=w[i])
				dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	cout << dp[W] << endl;
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
}
int n, res;
signed main() {
    read (n);
    for (int i = 1; i <= n; ++i) {
        res += (n - 1) / i;
    }
    return printf ("%lld\n", res), 0;
}


Measured memory_bytes: 3756
N, K = map(int, input().split(" "))
S = input()
ans = 0
count_0 = []
count_1 = []

tmp = 0
now_is_0 = True
if S[0] == "1":
    now_is_0 = False

for i, c in enumerate(S):
    if c == "0":
        if now_is_0:
            tmp += 1
        else:
            count_1.append(tmp)
            now_is_0 = True
            tmp = 1
    else:
        if now_is_0:
            count_0.append(tmp)
            now_is_0 = False
            tmp = 1
        else:
            tmp += 1
if now_is_0:
    count_0.append(tmp)
else:
    count_1.append(tmp)

if len(count_0) <= K:
    print(N)
    exit()

if S[0] == "0":
    count_1 = [0, ] + count_1
if S[N-1] == "0":
    count_1 = count_1 + [0, ]

tmp_ans = sum(count_0[:K] + count_1[:K+1])
max_ans = tmp_ans

i = 0
length = len(count_1)
while K+i+1 < length:
    tmp_ans -= count_1[i]
    tmp_ans -= count_0[i]

    tmp_ans += count_0[K+i]
    tmp_ans += count_1[K+1+i]
    max_ans = max(tmp_ans, max_ans)
    i += 1
print(max_ans)


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



char c;
void solve(){
	cin >> c;
	
	cout << (char)(c+1) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	string s; cin>>s;
	int k=0;
	int q1; cin>>q1;
	deque <char> q;
	for(int i=0;i<s.length();i++) q.pb(s[i]);
	while(q1--)
	{
	    int p; cin>>p;
	    if(p==1){ k++; k%=2; continue; }
	    int w; cin>>w; char c; cin>>c;
	    if(k){ if(w==1) q.pb(c); else q.push_front(c); }
	    else { if(w==1) q.push_front(c); else q.pb(c); }
	}
	//if(k) reverse(s.begin(),s.end());
	string r="";
	while(!q.empty())
	{
	    r += q.front();
	    q.pop_front();
	}
	if(k) reverse(r.begin(),r.end());
	cout<<r;
	
	return 0;
}


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

int main(){
  long n;
  cin >> n;
  long limit = (int)ceil(sqrt(n));
 
  long j;
  long k = 0;
  long min = 999999999999;
  for(long i=1; i<=limit; i++){
    if(n%i==0){
      j = n/i;
      k = i+j-2;
      if(min > k) min = k;
    }
  }
  
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

const int M = 100000;

int solve(int w, int h) {
  int count[w][h][2][2];
  for (int wi = 0; wi < w; ++wi) {
    count[wi][0][0][0] = 1;
    count[wi][0][1][0] = count[wi][0][0][1] = count[wi][0][1][1] = 0;
  }
  for (int hi = 0; hi < h; ++hi) {
    count[0][hi][1][1] = 1;
    count[0][hi][1][0] = count[0][hi][0][1] = count[0][hi][0][0] = 0;
  }
  for (int wi = 1; wi < w; ++wi) {
    for (int hi = 1; hi < h; ++hi) {
      count[wi][hi][0][0] = (count[wi - 1][hi][0][0] + count[wi - 1][hi][0][1]) % M;
      count[wi][hi][0][1] = count[wi - 1][hi][1][1] % M;
      count[wi][hi][1][0] = count[wi][hi - 1][0][0] % M;
      count[wi][hi][1][1] = (count[wi][hi - 1][1][0] + count[wi][hi - 1][1][1]) % M;
    }
  }
  return (  count[w - 1][h - 1][0][0] + count[w - 1][h - 1][0][1]
          + count[w - 1][h - 1][1][0] + count[w - 1][h - 1][1][1]) % M;
}

int main() {
  int w, h;
  while (true) {
    cin >> w >> h;
    if (w == 0) {
      return 0;
    }
    cout << solve(w, h) << endl;
  }
}

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

class Program
{
    static void Main()
    {
        var ab = Console.ReadLine().Split(' ').Select(x=>decimal.Parse(x)).ToArray();
        var A = ab.Max();
        var B = A==ab[0]?ab[1]:ab[0];      
        var num = Math.Abs((A - B) / 2);
        if (num == (int)num) Console.WriteLine(Math.Abs(B+num));
        else Console.WriteLine("IMPOSSIBLE");
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define eb emplace_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll k, s, ret=0;
	
int main(void){
	IOS
	cin >> k >> s;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			ll z=s-(i+j);
			if(z<0 || z>k) continue;
			if(i+j+z==s){
				ret++;
			}
		}
	}
	cout << ret << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	rep(i, b) {
		rep(j, w) {
			if (j < a)cout << 0;
			else cout << 1;
		}
		cout << endl;
	}
	rep(i, h - b) {
		rep(j, w) {
			if (j < a)cout << 1;
			else cout << 0;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static char[][] table;
	static int h,w;

	static void solve() {
		h = in.nextInt();
		w = in.nextInt();
		int n = in.nextInt();
		int ci = -1, cj = -1;
		table = new char[h][w];
		for (int i=0; i<h; i++) {
			table[i] = in.next().toCharArray();
			for (int j=0; j<w; j++) {
				if (table[i][j] == 'S') {
					ci = i;
					cj = j;
				}
			}
		}

		int ans = 0;

		for (int i=1; i<=n; i++) {
			int[] res = bfs(ci,cj,i);
			ci = res[0];
			cj = res[1];
			ans += res[2];
		}

		out.println(ans);
	}

	static int[] bfs(int ci, int cj, int target) {

		boolean[][] visited = new boolean[h][w];
		visited[ci][cj] = true;

		int[] di = {0,1,0,-1};
		int[] dj = {1,0,-1,0};

		ArrayDeque<int[]> que = new ArrayDeque<int[]>();
		que.add(new int[]{ci,cj,0});

		while (!que.isEmpty()) {
			int[] cur = que.pollFirst();
			int i = cur[0];
			int j = cur[1];
			int d = cur[2];

			if (table[i][j] - '0' == target) return new int[]{i,j,d};

			for (int k=0; k<4; k++) {
				int ni = i + di[k];
				int nj = j + dj[k];
				if (ni < 0 || nj < 0 || h <= ni || w <= nj || visited[ni][nj] || table[ni][nj] == 'X') continue;
				que.add(new int[]{ni,nj,d+1});
				visited[ni][nj] = true;
			}
		}

		return null;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 67828
#include<bits/stdc++.h>   
#define ll long long
#define sz size
#define pb push_back
#define x first
#define y second
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define int long long    
#define rc(s) return cout<<s,0
using namespace std;


int n,t;
pair<int,int>a[200005];
signed main(){ 
    ios_base::sync_with_stdio(0);  cin.tie(); cout.tie();
    cin >> n >> t;
    for(int i=1;i<=n;i++){
        cin >> a[i].y >> a[i].x;
    }
    int ans=1e18;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(a[i].x<=t){
            ans=min(ans,a[i].y);
        }
    }
    if(ans==1e18)cout<<"TLE";
    else cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
 
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
 
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
 
int main()
{
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for(int i = 1; i <= m; i ++)
	{
		for(int j = 10; j <= d; j ++)
		{
			int x = j / 10;
			int y = j % 10;
			if(x * y == i && x >= 2 && y >= 2)
			ans +=(x * y == i);
		}
	} 
	cout << ans;
	
 
 
 
 
 
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize);

    let n_sqrt = (n as f64).sqrt() as usize;
    let mut min = 1000000000020;
    for i in 1..n_sqrt + 1 {
        if n % i == 0 {
            if min > (i + (n / i) - 2) {
                min = i + n / i - 2;
            }
        }
    }

    println!("{}", min);
}


Measured memory_bytes: 2160
n = input()
ps = [map(int, raw_input().split()) for i in xrange(n)]
def intersection(p1, p2, q1, q2):
    dx0 = p2[0] - p1[0]
    dy0 = p2[1] - p1[1]
    dx1 = q2[0] - q1[0]
    dy1 = q2[1] - q1[1]
    a = dy0*dx1; b = dy1*dx0; c = dx0*dx1; d = dy0*dy1
    if a == b: return None
    x = (a*p1[0] - b*q1[0] + c*(q1[1] - p1[1])) / float(a - b)
    y = (b*p1[1] - a*q1[1] + d*(q1[0] - p1[0])) / float(b - a)
    return x, y
def cross(a, b, c):
    return (b[0]-a[0])*(c[1]-a[1]) - (b[1]-a[1])*(c[0]-a[0])
def calc_area(ps):
    return abs(sum(ps[i][0]*ps[i-1][1] - ps[i][1]*ps[i-1][0] for i in xrange(len(ps)))) / 2.
for t in xrange(input()):
    vs = []
    x1, y1, x2, y2 = map(int, raw_input().split())
    p1 = (x1, y1); p2 = (x2, y2)
    for i in xrange(n):
        q1 = ps[i-1]; q2 = ps[i]
        if cross(p1, p2, q1) * cross(p1, p2, q2) <= 0:
            r = intersection(p1, p2, q1, q2)
            if r is not None:
                vs.append(r)
        if cross(p1, p2, q2) >= 0:
            vs.append(q2)
    print "%.09f" % calc_area(vs)

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

int main(){
    long long n,sum=0LL,l=0LL,r=0LL;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}
    int lidx=0,ridx=n-1;
    for(int i=0;i<n;i++){
        if(l<=r){
            l+=a[lidx++];
        }
        else r+=a[ridx--];
    }
    //cout<<l<<" "<<r<<endl;
    cout<<abs(l-r)<<endl;
    return 0;
    
}

Measured memory_bytes: 1792
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

void solve() {
	//cout << log(10000) << endl;
	int n; cin >> n;
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		ll a; cin >> a;
		if (ans == 0 || a == 0) {cout << 0; return ;}
		if (ans > ll(2e18) / a) {ans = 2e18;}
		else	ans *= a;
	}
	if (ans > ll(1e18)) {cout << -1; return ;}
	cout << ans;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();


}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;

class UnionFind {
    vector<int> _nodes;

public:
    UnionFind(int size) : _nodes(vector<int>(size+1, -1)) {}

    int findRoot(int a) {
        if (_nodes[a] == -1) return a;
        const int root = findRoot(_nodes[a]);
        _nodes[a] = root;
        return root;
    }
    void unite(int a, int b) {
        const int rootA = findRoot(a);
        const int rootB = findRoot(b);
        if (rootA == rootB) return;

        _nodes[rootB] = rootA;
    }
};


void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C, std::vector<long long> D){
    UnionFind friends(N);
    vector<int> numFriends(N+1);
    rep(i,0,M) {
        friends.unite(A[i], B[i]);
        numFriends[A[i]]++;
        numFriends[B[i]]++;
    }
    vector<int> clusterSize(N+1);
    rep(i,1,N+1) {
        clusterSize[friends.findRoot(i)]++;
    }
    vector<int> answer(N+1);
    rep(i,1,N+1) {
        answer[i] = clusterSize[friends.findRoot(i)] - numFriends[i] - 1;
    }
    rep(i,0,K) {
        if (friends.findRoot(C[i]) == friends.findRoot(D[i])) {
            answer[C[i]]--;
            answer[D[i]]--;
        }
    }
    rep(i,1,N+1) {
        cout << answer[i] << (i == N ? "\n" : " ");
    }
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    std::vector<long long> C(K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
    }
    solve(N, M, K, std::move(A), std::move(B), std::move(C), std::move(D));
    return 0;
}


Measured memory_bytes: 6016
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
void sort(int x[], int n){
    int y, i, j;
    for(i=n; i>1; i--){
        for(j=0; j<=i-2; j++){
            if(x[j] < x[j+1]){
                y = x[j];
                x[j] = x[j+1];
                x[j+1] = y;
            }
        }
    }
}
int main(void){
    int n;
    int d[101];
    int i, cou=1;
    
    n  = num();
    for(i=0; i<n; i++){
        d[i] = num();
    }
    
    sort(d, n);
    
    for(i=1; i<n; i++){
        if(d[i-1] > d[i]){
            cou++;
        }
    }
    
    printf("%d\n", cou);
    
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

using namespace std;

int a[2000000];
int b[2000000];
int c[10001];

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

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

    for(int i = 0; i < n; i++){
        c[a[i]]++;
    }

    for(int i = 1; i < 10001; i++){
        c[i] += c[i-1];
    }

    for(int i = n - 1; i >= 0; i--){
        b[c[a[i]]-1] = a[i];
        c[a[i]]--;
    }

    for(int i = 0; i < n; i++){
        if(i){
            printf(" %d", b[i]);
        }
        else{
            printf("%d", b[i]);
        }
    }
    printf("\n");
}


Measured memory_bytes: 18380
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int a, l;
		cin >> a >> l;

		if ( !( a | l ) )
		{
			break;
		}

		map<int,int> done;
		done[ a ] = 0;

		int res = 0, res2;
		while ( true )
		{
			res++;

			OSS oss;
			oss << setw( l ) << setfill( '0' ) << a;
			string mins( oss.str() ), maxs( oss.str() );
			sort( ALL( mins ) );
			sort( ALL( maxs ), greater<char>() );
			int ma, mi;
			{
				ISS iss( mins );
				iss >> mi;
				ISS iss2( maxs );
				iss2 >> ma;
			}
			if ( EXIST( done, ma - mi ) )
			{
				res2 = ma - mi;
				break;
			}
			a = ma - mi;
			done[ ma - mi ] = res;
		}

		cout << done[ res2 ] << ' ' << res2 << ' ' << res - done[ res2 ] << endl;
	}

	return 0;
}

Measured memory_bytes: 1244
N = int(input())

B = [int(i) for i in input().split()]

# A の初期化
A = [0 for i in range(N)]

for i in range(len(B)):
    if i == 0:
        A[i] = B[i]
    else:
        if A[i] >= B[i]:
            A[i] = B[i]
            
    A[i+1] = B[i]
    
print(sum(A))

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

using namespace std;
using int64 = long long;
using IntPair = pair<int, int>;

constexpr int DEBUG = 0;

struct Edge {
  IntPair from;
  IntPair to;
  bool w;
  Edge(IntPair from, IntPair to, bool w) : from(from), to(to), w(w) {}
};

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

  int n, m;
  cin >> n >> m;

  map<IntPair, vector<Edge>> graph;
  for (int i = 0; i < m; i++) {
    int v1, v2, c;
    cin >> v1 >> v2 >> c;
    v1--;
    v2--;
    IntPair a1 = IntPair(v1, 0);
    IntPair b1 = IntPair(v1, c);
    IntPair a2 = IntPair(v2, 0);
    IntPair b2 = IntPair(v2, c);
    graph[a1].push_back(Edge(a1, b1, true));
    graph[b1].push_back(Edge(b1, a1, false));
    graph[a2].push_back(Edge(a2, b2, true));
    graph[b2].push_back(Edge(b2, a2, false));
    graph[b1].push_back(Edge(b1, b2, false));
    graph[b2].push_back(Edge(b2, b1, false));
  }

  map<IntPair, int> d_map;
  set<IntPair> visited;
  deque<IntPair> q;
  d_map[IntPair(0, 0)] = 0;
  q.push_back(IntPair(0, 0));

  while (!q.empty()) {
    auto p = q.front();
    q.pop_front();

    if (visited.find(p) != visited.end()) continue;
    visited.insert(p);
    
    if (p.first == n - 1) {
      cout << d_map[p] << endl;
      return 0;
    }
    for (const auto& e : graph[p]) {
      auto next = e.to;
      if (e.w) {
        if (d_map.find(next) == d_map.end()) {
          d_map[next] = d_map[p] + 1;
          q.push_back(next);
        }
      } else {
        if (d_map.find(next) == d_map.end() || d_map[p] < d_map[next]) {
          d_map[next] = d_map[p];
          q.push_front(next);
        }
      }
    }
  }

  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 104576
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	ll n,m;
	cin>>n>>m;
	vector<vector<ll> > s(m);
	for(ll i=0;i<m;i++){
		vector<ll> tmp;
		ll k;
		cin>>k;
		for(ll j=0;j<k;j++){
			ll tt;
			cin>>tt;
			tt--;
			tmp.push_back(tt);
		}
		s[i] = tmp;
	}
	vector<ll> p(m);
	for(ll i=0;i<m;i++)cin>>p[i];
	ll res = 0;
	for(ll i=0;i< (1<<n) ;i++){
		bool f = true;
		for(ll j = 0;j<m;j++){
			int cnt = 0;
			for(int k=0;k<s[j].size();k++){
				if( (i &	(1<<s[j][k]) ) != 0 ){
					cnt++;
				//	cout<<i<<' '<<s[j][k]<<endl;
				}
			}
			if(p[j] != cnt%2){
				f = false;
				break;
			}
		}
		if(f){
			res++;
			//cout<<i<<endl;
		}
	}
		cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] As = new int[N];
    int total = 0;
    long count = 0;
    for (int i = 0; i < N; i++) {
    	As[i] = sc.nextInt();
    	total += As[i];
    }
    for (int i = 0; i < N; i++) {
    	if(total <= (As[i] * 4 * M)) count++;
    }
    System.out.println(M <= count ? "Yes" : "No");
  }
}


Measured memory_bytes: 23764
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(m)]

def search(UF,loc):
    if UF[loc] == loc:
        return UF[loc]
    else:
        UF[loc] = search(UF,UF[loc])
        return UF[loc]
    

ans = 0

for i in range(m):
    aa,bb = AB[i]
    UF = [_ for _ in range(n+1)]
    for k in range(m):
        a,b = AB[k]
        if i!=k:
            UF[a] = search(UF,a)
            UF[b] = search(UF,b)
            if UF[a] != UF[b]:
                UF[max(UF[a],UF[b])] = UF[min(UF[a],UF[b])]
    for l in range(1,n+1):
        UF[l] = search(UF,l)
    for j in range(1,n):
        if UF[j] != UF[j+1]:
            ans += 1
            break
print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int n;
int odd[100010];
int even[100010];
int tmp;
int num = 0;
int o1 = 0, o2 = 0, e1 = 0, e2 = 0;
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp;
        if (i % 2)
            odd[tmp]++;
        else
            even[tmp]++;
    }
    for (int i = 1; i <= 100000; i++)
    {
        if (odd[i] > odd[o1])
        {
            o2 = o1;
            o1 = i;
        }
        else if (odd[i] > odd[o2])
        {
            o2 = i;
        }
        if (even[i] > even[e1])
        {
            e2 = e1;
            e1 = i;
        }
        else if (even[i] > even[e2])
        {
            e2 = i;
        }
    }
    if (e1 == o1)
    {
        num = max(even[e1] + odd[o2], odd[o1] + even[e2]);
    }
    else
    {
        num = even[e1] + odd[o1];
    }
    cout << n - num << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  stack<char> st;
  int ans = 0;
  rep(i, x.size()) {
    if (x[i] == 'S')
      st.push('S');
    else {
      if (st.empty())
        ans++;
      else
        st.pop();
    }
  }
  ans += st.size();
  cout << ans << endl;
}


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

#define int long long

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

    int ans = LLONG_MAX;

    for(int i = 1;i*i <= n;i++){
        if(n % i == 0){
            ans = min(ans, (i-1) + (n/i-1));
        }
    }

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



Measured memory_bytes: 256
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
    int e[5],a,b,c,d;
    while(cin>>e[0])
    {
        if(e[0]>=7&&e[0]<=9999)
           {
                a=e[0]/1000;
                b=(e[0]-a*1000)/100;
                c=e[0]%100/10;
                d=e[0]%10;
                cout<<a;
                if(a+b+c+d==7) cout<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
                else if(a+b+c-d==7) cout<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
                else if(a+b-c+d==7) cout<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
                else if(a-b+c+d==7) cout<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
                else if(a+b-c-d==7) cout<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
                else if(a-b-c+d==7) cout<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
                else if(a-b+c-d==7) cout<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
                else if(a-b-c-d==7) cout<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
           }
        else break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;

int N, M;
const int INF = 1<<29l;
vector<vector<pair<int, ll> > > V;

set<pair<int,int> > use;

void dijkstra(int s){
    int d[N];
    int color[N];
    for(int i = 0; i < N; i++) {
        d[i] = INF;
        color[i] = 0;
    }
    
    vector<vector<int> > prev(N);
    priority_queue<pair<ll, int> > PQ;
    PQ.push(make_pair(0, s));
    d[s] = 0;
    color[s] = 1;
    
    while(!PQ.empty()){
        pair<int, ll> f = PQ.top(); PQ.pop();
        ll cur_dist = f.first;
        int u = f.second;
        color[u] = 2;
        if(d[u] < cur_dist * (-1)) continue;
        for(int j = 0; j < V[u].size(); j++){
            int v = V[u][j].first;
            if(color[v] == 2) continue;
            if(d[v] > d[u] + V[u][j].second){
                d[v] = d[u] + V[u][j].second;
                PQ.push(make_pair(-1 * d[v], v));
                
                /* 復元のための*/
                prev[v].clear();
                prev[v].push_back(u);
            } else if(d[v] == d[u] + V[u][j].second){
                prev[v].push_back(u);
            }
            color[v] = 1;
        }
    }
    
    for(int v = 0; v < N; v++ ){
        for(int u = 0; u < prev[v].size(); u++){
            use.insert(make_pair(min(prev[v][u], v), max(prev[v][u], v)));
        }
    }
}

int main(void){
    // Your code here!
    cin >> N >> M;
    V.resize(N);
    int a, b, c;
    for(int i = 0; i < M; i++){
        cin >> a >> b >> c;
        a--;
        b--;
        V[a].push_back(make_pair(b, c));
        V[b].push_back(make_pair(a, c));
    }
    for(int i = 0; i < N; i++) dijkstra(i);
    cout << M - (int)use.size() << endl;
}


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

int main() {
  int N, ac = 0, wa = 0, tle = 0, re = 0;
  cin >> N;
  string s;
  
  rep(i,N) {
    cin >> s;    
    if (s == "AC") {
      ac++;
    }
    if (s == "WA") {
      wa++;
    }
    if (s == "TLE") {
      tle++;
    }
    if (s == "RE") {
      re++;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl; 
}

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

public static partial class Program
{
    public static void Main()
    {
        var nk = CRL().ArrayInts();
        var n = nk[0];
        var k = nk[1];
        var val = k * Math.Pow(k - 1, n - 1);
        CWL(val);
    }
}

public static partial class Program
{
    //テンプレここから
    public static int ToInt(this double d) => (int) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] {0, -1, 0, 1};
    public static long[] dy = new long[] {-1, 0, 1, 0};
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);

    public static long LCM(long a, long b) => a * b / GCD(a, b);

    //テンプレここまで
}

Measured memory_bytes: 13396
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<vector>
#define pb push_back
#define eb emplace_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 10000007
#define inf 1000000000000000000
#define MOD 1000000007
using namespace std;
const int maxv=300;
double prob[maxv+1][maxv+1][maxv+1],expected_waste[maxv+1][maxv+1][maxv+1];
void solve(){
	int n,x;
	int a[4]={0,0,0,0};
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&x);
		a[x]++;
	}
	prob[a[1]][a[2]][a[3]]=1;
	for (int c = n; c>=0; --c)
	{
		for (int b = n; b>=0;--b)
		{
			for (int a = n; a>=0; --a)
			{
				if(a==0 && b==0 && c==0)
					continue;
				if(a+b+c>n)
					continue;
				double prob_waste=(double) (n - (a + b + c)) / n;
				double exp_waste=(prob_waste)/(1-prob_waste)+1;
				expected_waste[a][b][c]+=exp_waste*prob[a][b][c];
				if(a!=0){
                    double p_go = (double) a / (a + b + c);
					prob[a-1][b][c]+=prob[a][b][c]*p_go;
					expected_waste[a-1][b][c]+=expected_waste[a][b][c]*p_go;
				}
				if(b!=0){
                    double p_go = (double) b / (a + b + c);
					prob[a+1][b-1][c]+=prob[a][b][c]*p_go;
					expected_waste[a+1][b-1][c]+=expected_waste[a][b][c]*p_go;
				}
				if(c!=0){
                    double p_go = (double) c / (a + b + c);
					prob[a][b+1][c-1]+=prob[a][b][c]*p_go;
					expected_waste[a][b+1][c-1]+=expected_waste[a][b][c]*p_go;
				}
			}
		}
	}
	printf("%.10lf",expected_waste[0][0][0]);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


Measured memory_bytes: 426240
import scipy as sp
N = int(input())
l = []
for i in range(N):
    l.append(list(map(int, input().split())))

l = sp.array(sorted(l, key=lambda x: x[1]))

a = sp.cumsum(l[:,0])
b = l[:,1]

c = b-a
t = True
for i in c:
    if i < 0:
        t = False
        print("No")
        break

if t:
    print("Yes")

Measured memory_bytes: 64376
#include <bits/stdc++.h>
using namespace std;
int n,a[100005][3][2];
bool f[3];
int laze(int d){
    int res=INT_MIN;
    for(int s=0;s<=2;++s){
        if(!f[s]){
            res=max(res,a[d-1][s][1]);
        }
    }
    return res;
}
int main(){
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i][0][0];
        cin >> a[i][1][0];
        cin >> a[i][2][0];
    }
    a[0][0][1]=a[0][0][0];
    a[0][1][1]=a[0][1][0];
    a[0][2][1]=a[0][2][0];
    for(int i=1;i<n;++i){
        for(int j=0;j<=2;++j){
            f[j]=1;
            a[i][j][1]=laze(i)+a[i][j][0];
            f[j]=0;    
        }
    }
    cout << max(max(a[n-1][0][1],a[n-1][1][1]),a[n-1][2][1]);
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String[] a = new String[k];
		for (int i = 0; i < k; i++)	a[i] = sc.next();
		
		for (int i = n;; i++) if (f(i, a)) { System.out.println(i); return; }
	}
	
	static boolean f(int in, String[] a) {
		return !Stream.of(a).anyMatch(s -> String.valueOf(in).contains(s));
	}
}


Measured memory_bytes: 37568
import math

K = int(input())

gcdSum = 0
myDict = {}

for iIndx in range(1, K+1):
    for jIndx in range(1, iIndx+1):
        presGcd = math.gcd(iIndx, jIndx)
        if (presGcd in list(myDict.keys())) and (iIndx == jIndx):
            myDict[presGcd] += 1
        elif (presGcd in list(myDict.keys())) and (iIndx != jIndx):
            myDict[presGcd] += 2
        elif (presGcd not in list(myDict.keys())) and (iIndx == jIndx):
            myDict[presGcd] = 1
        elif (presGcd not in list(myDict.keys())) and (iIndx != jIndx):
            myDict[presGcd] = 2
        else:
            print('error')

for kIndx in range(1, K+1):
    for keyItem in list(myDict.keys()):
        gcdSum += math.gcd(keyItem, kIndx) * myDict[keyItem]

print(gcdSum)

Measured memory_bytes: 9156
N = int(input())
ans = 0
for i in range(1, N + 1):
    if i * i > N:
        break
    if N % i > 0:
        continue
    if i < N // i - 1:
        ans += N // i - 1
    if N // i < i - 1:
        ans += i - 1
print(ans)

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;


int main(){
  int n;
  cin >> n;
  vector<p> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  ll res = 0;
  for (int i = n-1; i >= 0; i--) {
    ll now = v[i].first;
    ll target = v[i].second;
    ll tmp = (now + res) % target;
    if(tmp == 0) continue;
    res += target - tmp;
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
int d,g;
int p[20]={};
int c[20]={};
int solve(vector<bool> const& status){
  int res=0;int score=0;
  rep(i,d+1){
    if(status[i]){
      score+=c[i];
      score+=100*i*p[i];
      res+=p[i];
    }
  }
  int i=d;int j=0;
  while(score<g){
    while(status[i]){
      i--;
      if(i==0)break;
    }
    score+=100*i;
    j++;
    if(j==p[i]){
      score+=c[i];
      i--;
      j=0;
    }
    res++;
  }
  return res;
}
int calc(vector<bool> status,int cur){
  if(cur==d+1)return solve(status);
  else{
    int res=calc(status,cur+1);
    status[cur]=true;
    res=min(res,calc(status,cur+1));
    return res;
  }
  return 0;
}
signed main(){
  cin>>d>>g;
  rep1(i,d)cin>>p[i]>>c[i];
  vector<bool> status(d+1,false);
  cout<<calc(status,1)<<endl;
  return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  int d;
  int t;
  int s;

  cin >> d >> t >> s;

  if (s * t >= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using ui = unsigned int;

struct recode {
	ui lv;
	recode(ui x) :lv{
		[=]()->ui {
			ui c = 0;
			for (const ui e : {2, 4, 14, 24, 74}) {
				if (e <= x)
					c += 1;
				else
					break;
				return c;
			}
		}()
	}{}
};

int main() {
	ui dtab[105]{};


	ui n;
	std::cin >> n;

	for (ui i{2}; i < n+1; ++i) {


		auto x = i;
		for (ui j{ 2 }; j <= i; j+=(j==2?1:2)) {
			while (x%j == 0) {
				++dtab[j];
				x /= j;
			}
		}


	}

	/*
	for (ui i{0};i<105;++i)
		std::cout <<"["<<i<<":"<< dtab[i]<<"]"
			<< ( i%10!=0 ? " " : "\n" );
	*/
	int ar[5]; ui idx{ 0 };
	for (const ui e : {2, 4, 14, 24, 74}) {
		ar[idx]
			= std::count_if(std::begin(dtab), std::end(dtab)
			, [=](auto x)->bool {
				return e <= x;
			}
		);
		idx++;
	}
	
/*
	for (auto&e : ar)
		std::cout << e << " ";
	std::cout << "\n";
*/

	auto res =
		[&]()->int {
		auto a = ar[0] >= 2 && ar[1] >= 1 ?
			(ar[0] - 2)*(ar[1] - 1)* ar[1]/2 : 0;
//		abcとbacの順列を区別しないので2で割る
//		std::cout << ar[0] - 2 <<" "<<ar[1]-1<<  "\n";

		auto b = ar[1] > 0 ? (ar[1] - 1)*ar[2] : 0;

		auto c = ar[0] > 0 ? (ar[0] - 1)*ar[3]:0;
//		std::cout << a << " " << b << " " << c << "\n";
		return a + b + c + ar[4];
	}();
	std::cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int H,W;
        int i,j;
        while(true){
            H =sc.nextInt();
            W =sc.nextInt();
            if(H==0 && W==0) break;
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }

    }
}


Measured memory_bytes: 37508
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#define rep(j, n) for (int i = j; i < n; i++)
#define repd(j, n) for (int i = j; i > n; i--)
#define ll long long
using namespace std;

int main() {
	string ans = "NO";
	int n, k;
	cin >> n >> k;
	if (n >= 2 * k - 1) {
		ans = "YES";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))
#define chmin(p,q)(p=min(p,q))
#define bit(n,m)((n>>m)&1)

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g,c;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[2010];//適宜変える
	int id[20];//適宜変える
}G;
int deg[20];
int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

G g;
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld%lld",&x,&y,&c);
		deg[x]++;
		deg[y]++;
		g.e[2*i].s=x;
		g.e[2*i].g=y;
		g.e[2*i].c=c;
		g.e[2*i+1].s=y;
		g.e[2*i+1].g=x;
		g.e[2*i+1].c=c;
	}
	g.vcnt=n;
	g.ecnt=2*m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}


//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
//*
ll cost[110][110];
ll dddd[110][110];
void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=cost[i][j];//辺が無いところはINFにする前処理が必要
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
}


int dp[1<<15];
int main(){
	readgraph();
	for(int i=0;i<g.vcnt;i++)for(int j=0;j<g.vcnt;j++)cost[i][j]=INF;
	for(int i=0;i<g.ecnt;i++)chmin(cost[g.e[i].s][g.e[i].g],g.e[i].c);
	waasharuhuroido(g.vcnt);
	
	for(int i=1;i<1<<g.vcnt;i++){
		int b=__builtin_popcount(i);
		if(b%2)continue;
		dp[i]=3e6;
		int j=0;
		while(!bit(i,j))j++;
		for(int k=j+1;k<g.vcnt;k++)if(bit(i,k)){
			chmin(dp[i],dp[i^(1<<j)^(1<<k)]+dddd[j][k]);
		}
	}

	int tans=0;
	for(int i=0;i<g.ecnt;i++)tans+=g.e[i].c;
	tans/=2;
	int flag=0;
	for(int i=0;i<g.vcnt;i++)flag|=(deg[i]%2)<<i;
	int ans=3e6;
	if(__builtin_popcount(flag)%2){
		for(int k=0;k<g.vcnt;k++)if(!bit(flag,k))chmin(ans,tans+dp[flag|(1<<k)]);
	}else ans=tans+dp[flag];
	
	printf("%d\n",ans);
}


Measured memory_bytes: 2112
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    map<ll,ll>a_cnt;
    for(ll i=0;i<n;++i)++a_cnt[in()];

    ll ans=0;
    set<ll>app;
    for(auto aa:a_cnt){
        if(aa.second==1){
            bool is_ok=true;
            for(ll i=1;i*i<=aa.first;++i){
                if(aa.first%i==0){
                    ll y1=i,y2=aa.first/i;
                    is_ok&=!app.count(y1)&&!app.count(y2);
                }
            }
            if(is_ok)++ans;
        }
        app.insert(aa.first);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 25444
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






typedef long long ll;
int N, A[303][303];
ll d[303][303];
#define INF INT_MAX/2
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) rep(j, 0, N) cin >> A[i][j];

    vector<pair<ll, pair<int, int>>> v;
    rep(i, 0, N) rep(j, i + 1, N) v.push_back({ -A[i][j],{ i,j } });
    sort(v.begin(), v.end());

    ll ans = 0;
    rep(i, 0, N) rep(j, i + 1, N) ans += A[i][j];
    fore(p, v) {
        ll c = -p.first;
        int a = p.second.first;
        int b = p.second.second;
        if (A[a][b] == INF) continue;

        rep(i, 0, N) if (i != a && i != b && A[a][i] != INF && A[i][b] != INF) {
            if (A[a][i] + A[i][b] == c) {
                ans -= c;
                A[a][b] = A[b][a] = INF;
                break;
            } else if (A[a][i] + A[i][b] < c) {
                printf("-1\n");
                return;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1784