akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
         
typedef long long ll;
using namespace std;
        
#define F first
#define S second
#define sqr(x) x*x
#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
       
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
int lcm(int a,int b){return abs(a*b)/gcd(a,b);}
     
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k , q;
    cin >> n >> k >> q;
    int arr[n];
    for(int i = 0; i < n; ++i){
        arr[i] = k - q;
    }
    for(int i = 0;i < q; ++i){
        int x;
        cin >> x;
        x--;
        arr[x] += 1;
    }
    for(int i = 0; i < n; ++i){
        if(arr[i] > 0){
            cout << "Yes" << "\n";
        }else{
            cout << "No" << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		Main[] dices = new Main[count];
		for(int i = 0;i < count;i++) {
			dices[i] = new Main(sc);
		}

		int point = 0;

		for(int i = 0;i < count ;i++) {
			for(int j = i + 1;j < count;j++) {

				int roll = 0;
				if(dices[j].top == dices[i].south || dices[j].top == dices[i].north || dices[j].top == dices[i].bottom) {
					while(dices[j].top != dices[i].top && roll <= 4) {
						dices[i].goNorth();
						roll++;
					}
					roll = 0;
					while(dices[j].bottom != dices[i].bottom && roll <= 4) {
						dices[i].goNorth();
						roll++;
					}
				} else if(dices[j].top == dices[i].west || dices[j].top == dices[i].east) {
					roll = 0;
					while(dices[j].top != dices[i].top && roll <= 4) {
						dices[i].goEast();
						roll++;
					}
					roll = 0;
					while(dices[j].bottom != dices[i].bottom && roll <= 4) {
						dices[i].goEast();
						roll++;
					}
				}

				if(dices[j].south == dices[i].east || dices[j].south == dices[i].west || dices[j].south == dices[i].north ) {
					roll = 0;
					while(dices[j].south != dices[i].south && roll <= 4) {
						dices[i].spin();
						roll++;
					}
					roll = 0;
					while(dices[j].north != dices[i].north && roll <= 4) {
						dices[i].spin();
						roll++;
					}
				}

				if(dices[j].top == dices[i].top && dices[j].south == dices[i].south && dices[j].east == dices[i].east && dices[j].west == dices[i].west && dices[j].north == dices[i].north && dices[j].bottom == dices[i].bottom) {
					point++;
				}

			}
		}


		if(point > 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}








	}

	int top;
	int south;
	int east;
	int west;
	int north;
	int bottom;


	public Main(Scanner sc) {
		this.top = sc.nextInt();
		this.south = sc.nextInt();
		this.east = sc.nextInt();
		this.west = sc.nextInt();
		this.north = sc.nextInt();
		this.bottom = sc.nextInt();
	}

	public void goNorth() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = s;
		this.south = b;
		this.north = t;
		this.bottom = n;
	}

	public void goSouth() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = n;
		this.south = t;
		this.north = b;
		this.bottom = s;
	}

	public void goEast() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = w;
		this.east = t;
		this.west = b;
		this.bottom = e;
	}

	public void goWest() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;

		this.top = e;
		this.east = b;
		this.west = t;
		this.bottom = w;
	}

	public void spin() {
		int t = this.top;
		int s = this.south;
		int e = this.east;
		int w = this.west;
		int n = this.north;
		int b = this.bottom;


		this.south = w;
		this.east = s;
		this.west = n;
		this.north = e;


	}


}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var zero = s.Count(c => c == '0');
            var one = s.Length - zero;
            var abs = Math.Abs(zero - one);

            Console.WriteLine(s.Length - abs);
        }
    }
}

Measured memory_bytes: 13244
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % mod;
		x = x * x % mod; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int a; cin >> a;
	cout << a + a * a + a * a * a << "\n";
}



signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)
	solve();
		return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  int k[m],s[m][10];
  for(int i=0;i<m;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      cin>>s[i][j];
    s[i][j]--;
    }
  }
  int p[m];
  for(int i=0;i<m;i++) cin>>p[i];
  	int ans=0;
 	 for(int bit=0;bit<(1<<n);bit++){
    	int a=0;
    
    	for(int i=0;i<m;i++){
      	  int count=0;	
          for(int j=0;j<k[i];j++){
        		if(bit&(1<<s[i][j])) count++;
            }
            if(count%2==p[i]) a++;
        }
	    if(a==m) ans++;
     }

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


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

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

	long long int x,k,d;

	cin >> x >> k >> d;

	if(x<0)
	{
		long long int X = abs(x)/d;
		if(X > k)
		{
			long long int res = x + k*d;
			cout << abs(res) << '\n';
		} 
		else
		{
			long long int res = x + X*d;
			k-=X;
			if(k%2==0)
			{
				cout << abs(res) << '\n';
			}
			else
			{
				cout << min(abs(res-d),abs(res+d)) << '\n';
			}
		}
	}
	else
	{
		long long int X = x/d;
		if(X > k)
		{
			long long int res = x - k*d;
			cout << abs(res) << '\n';
		} 
		else
		{
			long long int res = x - X*d;
			k-=X;
			if(k%2==0)
			{
				cout << abs(res) << '\n';
			}
			else
			{
				cout << min(abs(res-d),abs(res+d)) << '\n';
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3688
package main

import "fmt"

func main() {

	var cnt int
	fmt.Scan(&cnt)
	nums := make([]int, cnt)

	for i := range nums {
		fmt.Scan(&nums[i])
	}

	ok := true
	ans := 0

	for ok {
		for i := range nums {
			if nums[i]%2 != 0 {
				ok = false
			}
		}

		if !ok {
			fmt.Print(ans)
			return
		}

		for i := range nums {
			nums[i] = nums[i] / 2
		}

		ans++
	}

	fmt.Print(ans)
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(void)
{
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  bool flag = false;
  while(1)
  {
    if(C > 0)C -= B;
    else
    {
      flag = true;
      break;
    }
    if(A > 0)A -= D;
    else
    {
      break;
    }
  }
  
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3592
def method_name(n, ai)
  sort_desc = ai.sort.reverse
  max = sort_desc[0]
  second = sort_desc[1]
  size = ai.size

  if max == second
    size.times{puts max}
  else
    ai.each_with_index do |v, i|
      if v == max
        puts second
      else
        puts max
      end
    end
  end
end

n = gets.chomp.to_i
ai = []
n.times{ai << gets.chomp.to_i}
method_name(n, ai)

Measured memory_bytes: 7784
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
int MAX_N = 100005;
int n, m;
void input() {
    RI(n, m);
}

void solve() {
	map<int,int> mp;
	int s = 0;
	LL ans=0;
	mp[0]=1;
	REP(i, n) {
		int a; RI(a);
		s = (s+a)%m;
		ans += mp[s];
		mp[s]++;
	}

	printf("%lld\n", ans);
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


Measured memory_bytes: 3200
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(n):
    if a[i] < b[i]:
        if a[i]+a[i+1] <= b[i]:
            c += a[i]+a[i+1]
            a[i+1] = 0
        else:
            c += b[i]
            a[i+1] -= (b[i]-a[i])
    elif a[i] >= b[i]:
        c += b[i]
    
print(c)


Measured memory_bytes: 18476
#include<stdio.h>
#include<math.h>
main()
{
    long long int n,a[200005],c,i;char b;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        a[i]=0;
    }

    for(;;)
    {
        scanf("%lld",&c);
        a[c]=a[c]+1;
        scanf("%c",&b);
        if(b==10)
            break;
    }
    for(i=1;i<=n;i++)
    {
        printf("%lld\n",a[i]);
    }
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

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

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

template<class T>
void chmax(T& a,T b){
	a=max(a,b);
}

template<class T>
void chmin(T& a,T b){
	a=min(a,b);
}

int main(){
	int n=read(),a=read(),b=read();
	string s;
	cin>>s;
	int p=0,q=0;
	for(auto c:s){
		if(c=='a'){
			if(p<a+b){
				printf("Yes\n");
				p++;
			}else
				printf("No\n");
		}else if(c=='b'){
			if(p<a+b&&q<b){
				printf("Yes\n");
				p++;
				q++;
			}else
				printf("No\n");
		}else
			printf("No\n");
	}
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

int main() {
	ll N, T, L, B, t;
	ll dp[110][110][2];// i回ふってjマスにいる場合の数,k=1で休み、k=0で動ける状態
	bool tabL[110], tabB[110];

	const ll corr = 16926659444736; // 6^k
	const ll corr_div = 279936; // 6^k

	while (1) {
		cin >> N >> T >> L >> B;
		if (N == 0 && T == 0 && L == 0 && B == 0) break;
		// 配列は毎回初期化する
		repi(i, 0, T + 1) {
			repi(j, 0, N + 1) {
				repi(k, 0, 2) {
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][0][0] = 1 * corr;
		repi(i, 0, N + 1) {
			tabL[i] = false;
			tabB[i] = false;
		}
		repi(i, 0, L) {
			cin >> t;
			tabL[t] = true;
		}
		repi(i, 0, B) {
			cin >> t;
			tabB[t] = true;
		}

		repi(i, 0, T) {
			repi(j, 0, N) {
				repi(k, 0, 2) {
					if (k == 1) dp[i + 1][j][0] += dp[i][j][1];
					else {
						repi(s, 1, 7) {
							ll cur = j + s;
							if (cur > N) cur = N - (cur - N);
							ll dp_value = ((dp[i][j][0] * corr_div) / 6) / corr_div;

							if (tabL[cur]) {
								dp[i + 1][cur][1] += dp_value;
							}
							else if (tabB[cur]) {
								dp[i + 1][0][0] += dp_value;
							}
							else {
								dp[i + 1][cur][0] += dp_value;
							}
						}
					}
				}
			}
		}

		ll ans_temp = 0;
		double ans;
		repi(i, 1, T + 1) {
			ans_temp += dp[i][N][0];
		}
		ans = (double)ans_temp / (double)corr;
		cout << fixed << setprecision(6) << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3348
def selection_sort(A, N):
    c = 0
    for i in range(N-1):
        minj = A[i+1:].index(min(A[i+1:])) + i+1
        if A[i] > A[minj]:
            A[i], A[minj] = A[minj], A[i]
            c += 1
    return A, c

N = int(input())
A = list(map(int, input().split()))
A, c = selection_sort(A, N)
print(' '.join(map(str, A)))
print(c)


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
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; }


int main(){
  long long n; cin >> n;
  vector<long long> a(n);
  unordered_map<long long, long long> mp;
  rep(i, 0, n){
    long long c; cin >> c;
    a[i] = c;
    mp[c]++;
  }
  long long tmp=0;
  unordered_map<long long, long long> mp2;
  unordered_map<long long, long long> mp3;
  for(auto it: mp){
    tmp += (it.second * (it.second - 1)) / 2;
    if(it.second >= 1){
      mp2[it.first] = (it.second * (it.second - 1)) / 2;
    }else{
      mp2[it.first] = 0;
    }
    if(it.second >= 2){
      mp3[it.first] = ((it.second - 1) * (it.second - 2)) / 2;
    }else{
      mp3[it.first] = 0;
    }
  }
  rep(i, 0, n){
    cout << tmp - mp2[a[i]] + mp3[a[i]] << endl;
  }
}
     


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

int sign(int x){
  return (x>0)-(x<0);
}
int main(){
  int x,y;
  int count = 0;
  cin >> x >> y;
  
  if( sign(x)*sign(y)==1 ){
    if( x<y ) cout << y-x << endl;
    if( x>y ) cout << x-y+2 << endl;
  }
  if( sign(x)*sign(y)==-1 ){
    if( sign(x)*x<=sign(y)*y ) cout << sign(y)*y-sign(x)*x+1 << endl;
    if( sign(x)*x>sign(y)*y ) cout << sign(x)*x-sign(y)*y+1 << endl;
  }
  if( x*y==0 ){
    if( x<y ) cout << y-x << endl;
    if( x>y ) cout << x-y+1 << endl;
  }
}

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

def divisor(n):
    res = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
    return sorted(res)

ans = 0
for i in divisor(N):
    if i > 1 and N // (i - 1) == N % (i - 1):
        ans += i - 1
        # print(i, N // (i - 1), N % (i - 1))
        
print(ans)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a)
int main(){
	ll n,k;
	while(cin>>n>>k){
		cout<<min(n%k,k-(n%k))<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
s = input()

if '##' in s[a-1:c] or '##' in s[b-1:d]:
    print('No')
else:
    if d<c and '...' not in s[b-2:d+1]:
        print('No')
    else:
        print('Yes')



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

int main(){
  long long int N;
  cin >> N;
//  vector<int> vec(N);
//  long long int sum=0;
//  for(int i=0;i<N;i++){
//    sum += i%(i+1);
//  }

  cout << (N*(N-1))/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define infin ll (pow(10,9)+7);
int main()
{
    ll n,d,x,y;
    cin>>n>>d;
    int count=0;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        if((x*x)+(y*y)<=(d*d))
        {
          count+=1;
          //cout<<i+1<<" this one"<<endl;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    map<ll,ll> m;ll u;
    REP(i,n)
    {
        cin>>u;
        m[u]++;
    }
    ll ans=0;
    for(auto i:m)
    {
        if(i.second & 1)
        ans++;
    }
    cout<<ans;
  }  
  return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#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; }



string s;
void solve(){
	cin >> s;
	int n = s.size();
	
	if(s[0] == s[n-1]){
		if(n&1){
			cout << "Second" << endl;
		}
		else{
			cout << "First" << endl;
		}
	}
	else{
		if(n&1){
			cout << "First" << endl;
		}
		else{
			cout << "Second" << 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: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    ll h; cin >> h;
    ll ans = 1, cut = 0;

    while (h) {
        h /= 2;
        cut++;
    }
    cut--;

    ll a = 2;

    rep(i,cut) {
        ans += a;
        a *= 2;
    }

    cout << ans << endl;


    return 0;
}

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

using namespace std;

int main(void) {
    string n;
    cin >> n;
    // cout << n.at(0) << endl;
    // cout << n.at(1) << endl;
    // cout << n.at(2) << endl;
    if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
    int n, d, x, a;
    cin >> n >> d >> x;

    int sum = x;
    for(int i=0; i<n; i++){
        cin >> a;
        sum += 1 + (d-1) / a;
    }

    cout << sum << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(void){
    int R;
    cin >> R;
    long double temp=2*R*M_PI;
    cout.precision(32);
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 3752
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0

#縦に文字列を複数入力　＆　操作
for i in range(n):
    s = input()
    if s == "AC":
        c0 += 1
    if s == "WA":
        c1 += 1
    if s == "TLE":
        c2 += 1
    if s == "RE":
        c3 += 1    
        
print('AC x ',end='')
print(c0)
print('WA x ',end='')
print(c1)
print('TLE x ',end='')
print(c2)
print('RE x ',end='')
print(c3)

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

int main() {
  int N, K, x;
  int sum = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    int a = 0;
    int b = 0;

    cin >> x;
    a = x * 2;
    b = (K - x) * 2;
    if (a > b) {
      sum += b;
    } else {
      sum += a;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
N,M=map(int, input().split())
L=[]
R=[]
for _ in range(M):
	l,r=map(int, input().split())
	L.append(l)
	R.append(r)

l = max(L)
r = min(R)

res = 0
for i in range(1,N+1):
	if l<=i and i<=r:
		res+=1
print(res)


Measured memory_bytes: 10996
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException{
    int i=0;
    int[] array=new int[10000];

    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    for(int j=0;j<array.length;j++){
      array[j]=Integer.parseInt(br.readLine());
      if(array[j]==0){
        break;
      }
      i++;
    }

    for(int j=0;j<i;j++){
      System.out.println("Case "+(j+1)+": "+array[j]);
    }
  }
}


Measured memory_bytes: 32640
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

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

    ll n;
    cin>>n;
    set<ll> s;

    rep(i,n){
        int a;
        cin>>a;
        s.insert(a);
    }

    if((ll)(s.size())==n){
        cout<<"YES"<<endl; return 0;
    }else{
        cout<<"NO"<<endl; return 0;
    }
}

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

int main ()
{
        long long int n , m , s , g1 , g2;
        while( cin >> n >> m >> s >> g1 >> g2 , n && m && s && g1 && g2 )
        {
                s--; g1--; g2--;
                vector<vector<long long int> >data;
                data.resize ( n );
                for( size_t i = 0; i < n; i++ )
                {
                        data[i].resize ( n );
                        for( size_t j = 0; j < n; j++ )
                        {
                                data[i][j] = INT_MAX / 6;
                        }
                        data[i][i] = 0;
                }
                long long int a , b , c;
                for( size_t i = 0; i < m; i++ )
                {
                        cin >> a >> b >> c;
                        a--; b--;
                        data[a][b] = c;
                }
                for( size_t k = 0; k < n; k++ )
                {
                        for( size_t j = 0; j < n; j++ )
                        {
                                for( size_t i = 0; i < n; i++ )
                                {
                                        data[i][j] = min ( data[i][j] , data[i][k] + data[k][j] );
                                }
                        }
                }
                long long int ans = INT_MAX;
                for( size_t i = 0; i < n; i++ )
                {
                        ans = min ( ans , data[s][i] + data[i][g1] + data[i][g2] );
                }
                cout << ans << endl;
                data.clear ();
        }
        return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
  
#define M 1046527
#define NIL (-1)
#define L 14
  
char H[M][L];
  
int getChar(char c){
  if(c == 'A') return 1;
  else if(c == 'C') return 2;
  else if(c == 'G') return 3;
  else if(c == 'T') return 4;
  else return 0;
}
  
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for(i = 0; i < strlen(str); i++){
    sum+= p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}
  
int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }
  
int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}
  
int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for( i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
  
int main(){
  int i, n, h;
  char str[L], com[9];
  for(i = 0; i < M; i++) H[i][0] = '\0';
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s %s", com, str);
    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)){
        printf("yes\n");
      }
      else printf("no\n");
    }
  }
  return 0;
}

Measured memory_bytes: 14916
from fractions import gcd


N = int(input())
A = list(map(int, input().split()))

L = [0] * (N + 1)
R = [0] * (N + 1)

for i in range(N):
    L[i + 1] = gcd(L[i], A[i])
    j = (N - 1) - i
    R[j] = gcd(R[j + 1], A[j])

ans = 1
for i in range(N):
    m = gcd(L[i], R[i + 1])
    ans = max(m, ans)

print(ans)


Measured memory_bytes: 89580
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double h = sc.nextDouble();
		double m = sc.nextDouble();
		final double PI = Math.PI;
		double ht = ((h*60+m)/720 )*2*PI;
		double mt = (m/60)*2*PI;
		double hx = a*Math.cos(ht);
		double hy = a*Math.sin(ht);
		double mx = b*Math.cos(mt);
		double my = b*Math.sin(mt);
		
		double dx = hx-mx;
		double dy = hy-my;

		double ans = Math.sqrt(dx*dx+dy*dy);
		System.out.printf("%.10f", ans);
	}
}


Measured memory_bytes: 37528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, n;
    cin, a, b, n;
    ll x = min(n, b - 1);
    cout << (a * x) / b - a * (x / b) << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>
#include <map>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii > P1;

#define rep(i,x,n) for(int i=x;i<n;++i)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define mp1(a,b,c) P1(a,P(b,c))
#define get_arsize(a) (sizeof(a)/sizeof(a[0]))
const int MAX = 1000005;
const ll mod = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// フェルマーの小定理で逆数扱える
void init() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}


ll C(int n, int k) {
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
  int x, y;
	cin >> x >> y;

  // 連立方程式解いた
  int m = (2 * x - y) / 3;
  int n = (2 * y - x) / 3;

  if ((x + y) % 3 || n < 0 || m < 0) {
    cout << 0 << endl;
    return 0;
  }

  init();
  cout << C(m+n, n) << endl;
  return 0;
}

Measured memory_bytes: 23680
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;


int n,k;
int h[100010];
int dp[100010];
int cost(int i,int j){
	return abs(h[i]-h[j]);
}
int main(int argc,char** argv){
	cin>>n>>k;
	rep(i,n){
		cin>>h[i];
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=INF+10;
		for(int j=1;j<=k;j++){
			int from=i-j;
			if(from<0)continue;
			dp[i]=min(dp[from]+cost(from,i),dp[i]);
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n , k , sum = 0;
    cin >> n >> k;
    int arr[n];
    for (int i = 0 ; i < n ; i++)
        cin >> arr[i];
    sort(arr , arr + n);
    for (int i = 0 ; i < k ; i++)
        sum += arr[i];
    cout << sum << endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      ll n,m; cin>>n>>m;
      if(n==1 and m==1){
            cout<<1<<endl;
      }else if(n==1){
            cout<<m-2<<endl;
      }else if(m==1){
            cout<<n-2<<endl;
      }else{
            cout<<(n-2)*(m-2)<<endl;
      }
}

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

int main()
{
    int N, dame = 0, minP = pow(10, 5) * 2 + 1;
    cin >> N;
    vector<int> P(N);

    for (int i = 0; i < N; i++)
    {
        cin >> P.at(i);
        minP = min(P.at(i), minP);
        if(minP<P.at(i))
        {
            dame++;
        }
    }
    cout << N - dame << endl;
}


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

namespace contest_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int  N=int.Parse( Console.ReadLine());
            string S = Console.ReadLine();
          
            long sum = 0;
            List<long> R=new List<long>(new long[N+1]),
                G=new List<long>(new long[N + 1]),
                B=new List<long> (new long[N + 1]);
            for (int i = N - 1; i >= 1; i--)
            {
                R[i] = R[i+1];
                G[i] = G[i+1];
                B[i] = B[i+1];
                switch (S[i])
                {
                    case 'R':
                        R[i]++;
                        break;
                    case 'G':
                        G[i]++;
                        break;
                    case 'B':
                        B[i]++;
                        break;
                }

            }
            for (int i = 0; i < N-2; i++)
            {
                char fst = S[i];
                for (int k = i+1; k < N-1; k++)
                {
                    char scd = S[k];
                    int dist = k - i;
                    if (fst!=scd)
                    {
                        if('R'!=fst && 'R' != scd)
                        {
                            sum += R[k + 1];
                            if (k + dist < N) 
                                if(S[k+dist]=='R')
                            {
                                    sum--;
                            }
                        }
                        if ('G' != fst && 'G' != scd)
                        {
                            sum += G[k + 1];
                            if (k + dist < N)
                                if (S[k + dist] == 'G')
                                {
                                    sum--;
                                }
                        }
                        if ('B' != fst && 'B' != scd)
                        {
                            sum += B[k + 1];
                            if (k + dist < N)
                                if (S[k + dist] == 'B')
                                {
                                    sum--;
                                }
                        }
                    }
                }
            }
            Console.WriteLine(sum);


        }
        
    }
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    rep(i,H) rep(j,W) cin >> a.at(i).at(j);
    rep(i,H) rep(j,2) rep(k,W) {
        cout << a.at(i).at(k);
        if (k == W-1) cout << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct Graph {
    struct Vertex { int n, c; };
    struct Edge { int i, n, c; };
    Graph(int n, int m) : v(n, { -1 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j, int c) {
        e[m] = { j, v[i].n, c };
        v[i].n = m;
        m++;
    }
    void bfs01(int s, int t) {
        deque<int> q;
        q.push_back(s);
        for (int i = 0; i < n; i++) v[i].c = 1 << 30;
        v[s].c = 0;
        while (!q.empty()) {
            int i = q.front(); q.pop_front();
            if (i == t) break;
            for (int j = v[i].n; j >= 0; j = e[j].n) {
                Edge& o = e[j];
                int c = v[i].c + o.c;
                if (c < v[o.i].c) {
                    v[o.i].c = c;
                    if (o.c == 0) {
                        q.push_front(o.i);
                    } else {
                        q.push_back(o.i);
                    }
                }
            }
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;
};

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

    Graph g(k, (k - 1) * 2);
    for (int i = 1; i < k; i++) {
        g.add_edge(i, i * 10 % k, 0);
        g.add_edge(i, (i + 1) % k, 1);
    }

    g.bfs01(1, 0);

    cout << g.v[0].c + 1 << endl;

    return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,k;
	cin >> n >> k;
	ll ans = k;
	FOR(i,0,n-1){
		ans *= (k-1);
	}
	ANS(ans);
	return 0;
}


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

mise = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    mise.append(array)
mise.sort()

keihi = 0

for ima in range(N):
    if M < mise[ima][1]:
        keihi += mise[ima][0] * M
        break
    else:
        M = M - mise[ima][1]
        keihi += mise[ima][0] * mise[ima][1]
    
print(keihi)

Measured memory_bytes: 27760
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
struct dice{
  int up,s,e,w,n,dn;
  void to(char dir){
    if(dir=='N'){
      int tmp = n;
      n = up;
      up = s;
      s = dn;
      dn = tmp;
    }else if(dir=='S'){
      int tmp = s;
      s = up;
      up = n;
      n = dn;
      dn = tmp;
    }else if(dir=='E'){
      int tmp = e;
      e = up;
      up = w;
      w = dn;
      dn = tmp;
    }else if(dir=='W'){
      int tmp = w;
      w = up;
      up = e;
      e = dn;
      dn = tmp;
    }else if(dir=='R'){
      int tmp = e;
      e = n;
      n = w;
      w = s;
      s = tmp;
    }else if(dir=='L'){
      int tmp = e;
      e = s;
      s = w;
      w = n;
      n = tmp;
    }
  }
  void to(string dirs){
    REP(i,dirs.size()) to(dirs[i]);
  }
  bool operator==(dice di){
    return up==di.up && n==di.n && e==di.e && w==di.w && s==di.s && dn==di.dn;
  }
};
signed main(){
  int a[6];
  REP(i,6) cin >> a[i];
  dice di = {a[0],a[1],a[2],a[3],a[4],a[5]};
  REP(i,6) cin >> a[i];
  dice di2 = {a[0],a[1],a[2],a[3],a[4],a[5]};
  string s = "RRRRNRRRRSERRRRWSRRRRNWRRRRWRRRR";
    REP(i,s.size()){
      di.to(s[i]);
      if(di==di2) {
        puts("Yes");
        break;
      }
      if(i==(ll)s.size()-1) puts("No");
    }
}



Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
    char S[3],T[3];
    cin>>S>>T;
    int hit=0;
    rep(i,3){
        if(S[i]==T[i]){
            hit++;
        }
    }
    cout<<hit<<endl;
}


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

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

 //    #ifndef ONLINE_JUDGE
	// 	freopen("../../a.in","r",stdin);
	// 	freopen("../../a.out","w",stdout);
	// #endif

	int n, k, ct=1;
	vector<int>v;
	cin >> n >> k;
	string s;
	cin >> s;

	for (int i=1; i<n; i++){
		if (s[i]!=s[i-1]){
			v.push_back(ct);
			ct=1;
		} else ++ct;
	}
	v.push_back(ct);

	if (s[0]=='0'){
		long long mx=0;
		for (int i=0; i<v.size(); i+=2){
			long long sum=0;
			for (int j=i, nl=0; nl<k && j<v.size(); j+=2, nl++){
				if (j==i && j-1>=0) sum+=v[j-1];
				if (j+1<v.size()) sum+=v[j]+v[j+1];
				else sum+=v[j];
			}
			mx = max(mx,sum);
		}
		cout << mx << "\n";
		
	} else {
		long long mx=0;
		for (int i=1; i<v.size(); i+=2){
			long long sum=0;
			for (int j=i, nl=0; nl<k && j<v.size(); j+=2, nl++){
				if (j==i && j-1>=0) sum+=v[j-1];
				if (j+1<v.size()) sum+=v[j]+v[j+1];
				else sum+=v[j];
			}
			mx = max(mx,sum);
		}

		if (mx==0) mx = v.front();

		cout << mx << "\n";
	}
}

Measured memory_bytes: 1020