akhauriyash/Code-Regression huggingface dataset:
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N, Y;
  ci(N, Y);
  rep(i, N + 1){
    rep(j, N + 1){
      if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y && (N - i - j) >= 0){
        co(i, j, N - i - j);
        rt;
      }
    }
  }
  co(-1, -1, -1);
}

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

using namespace std;

unsigned int aI, aO, aT, aJ, aL, aS, aZ, k;

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

    cin >> aI >> aO >> aT >> aJ >> aL >> aS >> aZ;

    k = aO + aI + aJ + aL - (aI % 2 + aJ % 2 + aL % 2) % 3;

    if (aI + aJ + aL > 2 && (aI % 2 + aJ % 2 + aL % 2) % 3 == 2) {
        k++;
    }

    cout << k << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define LEN 1000000

typedef struct{
  char name[20];
  int time;
}que;

que Que[LEN];
int head=0, tail=0;

void enQue(que q){
  Que[head]=q;
  head++;
}

que deQue(void){
  tail++;
  return Que[tail-1];
}

int size(void){
  return head-tail;
}

int main(){
  int N, q;
  que Q;
  int i, j, k;
  int time=0;
  
  scanf("%d %d", &N, &q);
  for(i=0; i<N; i++){
    scanf("%s %d", Q.name, &Q.time);
    enQue(Q);
  }
  
  while(1){
    Q=deQue();
    if(Q.time<=q){
      time+=Q.time;
      printf("%s %d\n", Q.name, time);
    }
    else{
      Q.time-=q;
      time+=q;
      enQue(Q);
    }  
      if(size()==0) break;
  }
  
  return 0;
}

Measured memory_bytes: 6736
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
// const int imax = 100000;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i = 100; i >= 1; i--){
    if(a%i==0 && b%i==0){
      cnt++;
      if(k==cnt){
        printf("%d\n", i);
        return 0;
      }
    }

  }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""Untitled36.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1gX7akkWvXDnBU_uBNQLjSb2ijX28_WpH
"""

a = int(input())
print(a+a**2+a**3)

Measured memory_bytes: 9152
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ans
    integer(int32), allocatable:: l_s(:), r_s(:)
    character(300000):: s

    read*, n
    read*, s
    allocate(l_s(0:n),r_s(n+1))

    l_s(:) = 0
    do i=1,n
        if (s(i:i) == 'W') then
            l_s(i)=l_s(i-1)+1
        else
            l_s(i)=l_s(i-1)
        end if
    end do

    r_s(:) = 0
    do i=n,1,-1
        if (s(i:i) == 'E') then
            r_s(i) = r_s(i+1)+1
        else
            r_s(i) = r_s(i+1)
        end if
    end do

    ans=300000
    do i=1,n
        ans=min(ans, l_s(i-1)+r_s(i+1))
    end do
    print'(i0)', ans

end program name

Measured memory_bytes: 3340
#include<iostream>
#include<string.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  if (n % 2 == 1) {
    cout << "No" << endl;
  }
  else {
    for (int i = 0; i < n / 2; i++) {
      if (s[i] != s[n / 2 + i]) {
        cout << "No" << endl;
        break;
      }
      if (i == n / 2 - 1) {
        cout << "Yes" << endl;
      }
    }
  }
}

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

#define ll long long
#define ld long double

int n, m;
bool vis[100001];
int wa[100001];

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

    cin >> n >> m;
    for(int i=1;i<=n;i++) {
        vis[i] = false;
        wa[i] = 0;
    }
    int correct = 0, wrong = 0;
    for(int i=0;i<m;i++) {
        int p;
        string s;
        cin >> p >> s;
        if(vis[p]) {
            continue;
        }
        if(s == "AC") {
            vis[p] = true;
            correct++;
            wrong += wa[p];
        }
        else {
            wa[p]++;
        }
    }
    cout << correct << " " << wrong << '\n';
    return 0;
}



Measured memory_bytes: 768
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
        int k = sc.nextInt();
      
        //AとBの小さい方を取得
        int min = Math.min(a, b);
        
        //公約数のリスト
		List<Integer> ary = new ArrayList<>();

        for(int i=1; i <= min; i++) {
        	if(a % i == 0 && b % i ==0) {
        		ary.add(i);
        	}
		}
                
        System.out.print(ary.get(ary.size()-k));
	}
}

Measured memory_bytes: 23764
#include<stdio.h>
int main(){
  int n,m,i,c,j;
  while(scanf("%d %d",&n,&m),n){
    char p[8000010]={};
    c=0;
    for(i=n;c<=m;i++){
      if(p[i]==0){//printf("%d\n",i);
	for(j=i;j<8000000;j+=i)p[j]=1;
	c++;
      }
    }//printf("\n");
    printf("%d\n",i-1);
  }
  return 0;
}

Measured memory_bytes: 8420
from math import sqrt

def koch(n, c1, c2):
    if n == 0:
        return
    
    # 処理
    v = [c2[0] - c1[0], c2[1] - c1[1]]

    s = [c1[0] + v[0] / 3, c1[1] + v[1] / 3]
    t = [c1[0] + 2 * v[0] / 3, c1[1] + 2 * v[1] / 3]
    u = [c1[0] + v[0]/2 - v[1] * sqrt(3) / 6, c1[1] + v[1]/2 + v[0] * sqrt(3) / 6]

    koch(n-1, c1, s)
    print(" ".join(map(str, s)))
    koch(n-1, s, u)
    print(" ".join(map(str, u)))
    koch(n-1, u, t)
    print(" ".join(map(str, t)))
    koch(n-1, t, c2)


    

def main():
    fmt = "%.8f %.8f"
    q3 = sqrt(3)

    c1 = [0, 0]
    c2 = [100, 0]

    n = int(input())
    print(fmt % tuple(c1))
    koch(n, c1, c2)
    print(fmt % tuple(c2))

main()


Measured memory_bytes: 5712
def lucas(n):
  if(n == 0):
    return 2
  if(n == 1):
    return 1
  if(n == 25):
    return 167761
  if(n == 26):
    return 271443
  if(n == 50):
    return 28143753123
  if(n == 51):
    return 45537549124
  if(n == 75):
    return 4721424167835364
  if(n == 76):
    return 7639424778862807
  return lucas(n- 1)+ lucas(n- 2)

N = int(input())

print(lucas(N))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int a[200010];
int main() {
	int n;
	cin >> n;
	int c;
	for (int i = 1; i < n; i++) {
		cin >> c;
		a[c]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << endl;
	}
	return 0;
} 

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll N;
  cin >> N;
  string res = "";
  while (N>0) {
    N--;
    res = (char)('a'+(N%26))+res;
    N /= 26;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    auto cnt = make_v<int>(h, w);
    rep(i, h){
        vector<int> done(w);
        rep(j, w){
            if(s[i][j] == '#') continue;
            if(done[j]) continue;
            int l = 0;
            while(j + l < w){
                if(s[i][j + l] == '#') break;
                ++l;
            }
            rep(k, l){
                cnt[i][j+k] += l;
                done[j + k] = 1;
            }
        }
    }

    rep(i, w){
        vector<int> done(h);
        rep(j, h){
            if(s[j][i] == '#') continue;
            if(done[j]) continue;
            int l = 0;
            while(j + l < h){
                if(s[j + l][i] == '#') break;
                ++l;
            }
            rep(k, l){
                cnt[j + k][i] += l;
                done[j + k] = 1;
            }
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) chmax(ans, cnt[i][j] - 1);
    print(ans);


}



Measured memory_bytes: 20224
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && b >= c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define MOD 1000000007
#define dd double
#define vi vector<int>
#define vll vector<ll>
#define forr(i,n) for(ll i=0;i<n;i++)
#define revf(i,n) for(ll i=n-1;i>=0;i--)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define inp(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define outp(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" "
#define outp1(a,n) for(ll i=1;i<n;i++)cout<<a[i]<<" "
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define pb push_back
#define mp make_pair
#define mem(x,n) memset(x,n,sizeof(x))
#define BINSC binary_search
#define BITOUT __builtin_popcount
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define cn cout<<"\n";
ll p=MOD;
ll power(ll x, ll y) 
{ 
	ll res = 1;	 // Initialize result 

	x = x % p; // Update x if it is more than or 
				// equal to p 

	if (x == 0) return 0; // In case x is divisible by p; 

	while (y > 0) 
	{ 
		// If y is odd, multiply x with result 
		if (y & 1) 
			res = (res*x) % p; 

		// y must be even now 
		y = y>>1; // y = y/2 
		x = (x*x) % p; 
	} 
	return res; 
} 

int main()
{
     fast
     ll n;
     ll out=0;
     cin>>n;
     if(n==1)
     cout<<0;
     else 
     {
          out=power(10,n)-2*power(9,n);
          out=(out%MOD+power(8,n)%MOD)%MOD;
          out=out+MOD;
	     out%=MOD;
          cout<<out;
     }
}

Measured memory_bytes: 3592
def prime_factor(n)
  prime = []
  2.upto(n) do |i|
    break unless i <= n / i
    while (n % i).zero?
      prime << i
      n /= i
    end
  end
  prime << n unless n == 1
  prime
end

N = gets.to_i
M = 75

d = Hash.new{|h,k|h[k]=0}
1.upto(N){|i| prime_factor(i).each{|p| d[p] += 1}}

dp = Array.new(M+2){0}
dp[1] = 1
d.each do |k, v|
  nex = Array.new(M+2){0}
  1.upto(M) do |i|
    nex[i] += dp[i]
    1.upto(v) do |j|
      nex[[i*(j+1), M+1].min] += dp[i]
    end
  end
  dp = nex
end
p dp[M]


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> B(N - 1);
  for (int i = 0; i < N - 1; i++) {cin >> B.at(i);}
  int A = B.at(0) + B.at(N - 2);
  for (int i = 1; i < N - 1; i++) {A += min(B.at(i - 1), B.at(i));}
  cout << A << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <functional>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
  string s;
  cin>>s;
  int count = 0;
  rep0(i,s.length()){
    if(s[i] == 'o')count++;
  }
  if(count + (15 - (int)s.length()) > 7)p("YES");
  else p("NO");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <istream>

int main(void){
	int i, length, a, b;
	char buf[32];
	std::stringstream ss;
	std::string interpreter[3], str;
	while(true){
		fgets(buf, sizeof(buf), stdin);
		length = strlen(buf);
		buf[length-1] = '\0';
		ss << buf;
		i = 0;
		while(std::getline(ss, str, ' ')){
			interpreter[i++] = str;
		}

		if(interpreter[1].c_str()[0]=='?') break;
		a = atoi(interpreter[0].c_str());
		b = atoi(interpreter[2].c_str());
		if(interpreter[1].c_str()[0]=='+'){
			printf("%d\n",a+b);
		}
		else if(interpreter[1].c_str()[0]=='-'){
			printf("%d\n",a-b);
		}
		else if(interpreter[1].c_str()[0]=='*'){
			printf("%d\n",a*b);
		}
		else if(interpreter[1].c_str()[0]=='/'){
			printf("%d\n",a/b);
		}

		ss.str("");
		ss.clear(std::stringstream::goodbit);
	}
	return 0;
}



Measured memory_bytes: 3244
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000;
#define MAX_N 100000

struct node{
	int x;
	int y;
	int nodeNum;
};

bool xAscNode(const node &left,const node &right){
	return left.x < right.x;
}

bool yAscNode(const node &left,const node &right){
	return left.y < right.y;
}

struct edge{
	int start;
	int to;
	ll cost;
};

bool operator>(const struct edge &left,const struct edge &right){
	return left.cost > right.cost;
}

priority_queue<edge,vector<edge>,greater<edge>> edgeList;

typedef vector<vector<struct edge>> AdjList;
AdjList graph;

int par[MAX_N];

void initUnionFind(){
	rep(i,MAX_N) par[i] = i;
}

int root(int i){
	if( par[i] == i) return i;
	par[i] = root(par[i]);
	return par[i];
}

bool isSameRoot(int i,int j){
	i = root(i);
	j = root(j);
	return i == j;
}

void unite(int i,int j){
	i = root(i);
	j = root(j);
	if( i == j) return;
	par[i] = j;
}

void kruskal(){	
	initUnionFind();
	while(!edgeList.empty()){
		edge e = edgeList.top();
		edgeList.pop();
		int u,v;
		u = e.start;
		v = e.to;
		if( isSameRoot(u,v) == false){
			unite(u,v);
			edge e1;
			e1.cost = e.cost;
			e1.start = u;
			e1.to = v;
			graph[u].push_back(e1);

			/*edge e2;
			e2.cost = e.cost;
			e2.start = v;
			e2.to = u;
			graph[v].push_back(e2);*/
		}
	} 
}



int main()
{
	int n;
	cin>>n;
	graph = vector<vector<edge>>(n);
	struct node * nodeList = new struct node[n];
	rep(i,n){
		cin>>nodeList[i].x>>nodeList[i].y;
		nodeList[i].nodeNum = i;
	}
	sort(nodeList,nodeList+n,xAscNode);
	rep(i,n-1){
		edge e;
		e.cost = abs(nodeList[i].x - nodeList[i+1].x);
		e.start = nodeList[i].nodeNum;
		e.to = nodeList[i+1].nodeNum;
		edgeList.push(e);
	}

	sort(nodeList,nodeList+n,yAscNode);
	rep(i,n-1){
		edge e;
		e.cost = abs(nodeList[i].y - nodeList[i+1].y);
		e.start = nodeList[i].nodeNum;
		e.to = nodeList[i+1].nodeNum;
		edgeList.push(e);
	}

	kruskal();
	ll ans = 0;
	rep(i,n){
		for(auto iter = graph[i].begin(); iter != graph[i].end(); iter++){
			ans += iter->cost;
			//cout<<i<<"->"<<iter->to<<":"<<iter->cost<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 10988
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
l = [int(input()) for _ in range(n)]
l.sort()

m = 10 ** 9 + 1
for i in range(len(l) - k + 1):
    m = min(m, l[i + k - 1] - l[i])

print(m)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int m;
    ll k;
    cin >> m >> k;
    if(k == 0){
        for(int i = 0; i < pow(2, m); i++){
            cout << i << " " << i << " ";
        }
        cout << endl;
        return 0;
    }
    if(m == 1){
        cout << -1 << endl;
        return 0;
    }
    if(pow(2, m) <= k){
        cout << -1 << endl;
        return 0;
    }
    cout << k << " ";
    for(int i = 0; i < pow(2, m); i++){
        if(i == k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    for(int i = pow(2, m) - 1; i >= 0; i--){
        if(i == k) continue;
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=m/n;i>=1;i--)
	{
		if(m%i==0)
		{
			int t=m/i;
			if(t>=n)
			{
				cout<<i<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3624
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>

using namespace std;

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int main(){
	int K;
	cin >> K;
	long long int ans = 0;

	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			for (int k = 1; k <= K; k++) {

				int a = k,b = 1;
				for (int I = 1; I < 3; I++) {
					if (I == 1) b = j;
					else b = i;
					a = gcd(a, b);
				}
				ans += a;

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


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
const int INF = 100100100;
int main(){
    int h,w; cin >> h >> w;
    char s[h][w];
    int dist[h][w];
    int cnt=0;
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#') cnt++;
            dist[i][j]=INF;
        }
    }
    if(s[0][0]=='#' || s[h-1][w-1]=='#'){
        cout << -1 << endl;
        return 0;
    }
    queue<P> q;
    q.push({0,0});
    dist[0][0]=0;
    int dy[4]={1,0,-1,0};
    int dx[4]={0,1,0,-1};
    while(!q.empty()){
        P d=q.front(); q.pop();
        rep(i,4){
            int ny=d.fi+dy[i]; int nx=d.se+dx[i];
            if(0<=ny && ny<h && 0<=nx && nx<w && s[ny][nx]=='.' && dist[ny][nx]==INF){
                dist[ny][nx]=dist[d.fi][d.se]+1;
                q.push({ny,nx});
            }
        }
    }
    if(dist[h-1][w-1]==INF){
        cout << -1 << endl;
        return 0;
    }
    int ans=h*w-cnt-dist[h-1][w-1]-1;
    cout << ans << endl;
    
    
    
}


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

using namespace std;
int main()
{
	int N,X,i,x[100002],len[100002],tmp;
	cin >> N >> X;
	for(i=0; i<N; i++){
		cin >> x[i];
		len[i] = abs(X-x[i]);
	}
	sort(len, len+N-1);
	for(i=0; i<N-1; i++){
		tmp = len[i] % len[i+1];
		while(tmp != 0){
			len[i] = len[i+1];
			len[i+1] = tmp;
			tmp = len[i] % len[i+1];
	}
	}
	cout << len[N-1] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

long long euclidean_gcd(long long a, long long b) 
{
  while(1) 
  {
    if(a < b) swap(a, b);
    if(b == 0) break;
    a %= b;
  }
  return a;
}


long long insuu(long long n)
{
	if (n == 1)
  {
    return 1;
  }
	long long ans = 1;
  for (long long i = 2; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      while (n % i == 0)
      {
        n /= i;
      }
      ans++;
    }
    else
    {
      continue;
    }
  }
  if (n != 1)
  {
    ans++;
  }
  return ans;
}

int main()
{
  long long A,B;
  cin >> A >> B;
  long long common =  __gcd(A, B);

  cout << insuu(common) << endl;

}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0169
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int[] hand = RIntAr();
                if (hand.Sum() == 0) break;
                Console.WriteLine(CalcScore(hand));
            }
        }

        private static int CalcScore(int[] hand)
        {
            if (hand.Count() > 21) return 0;

            List<int> score = new List<int>() { 0 };
            for (int i = 0 ; i < hand.Count() ; i++)
            {
                if (hand[i] > 1)
                {
                    score = score.Select(x => x + (hand[i] > 10 ? 10 : hand[i])).Where(x => x <= 21).ToList();
                }
                else
                {
                    var score1 = score.Select(x => x + 1).Where(x => x <= 21);
                    var score2 = score.Select(x => x + 11).Where(x => x <= 21);
                    score = score1.Union(score2).Distinct().ToList();
                }
            }
            return score.Count() == 0 ? 0 : score.Max();
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18400
#include<bits/stdc++.h>
using namespace std;
#define reset(X) memset(X, 0, sizeof(X))
#define int long long
typedef long long ll;
#define pb push_back
#define se second
#define fi first
#define endl '\n'
#define all(X) X.begin(),X.end()

const int INF=1e18;
const int mod=1e9+7;
const int mod2=998244353;



#define REDN(a) int a;cin>>a;
#define REDL(a,n) int a[n];for(int i=0;i<n;i++) cin>>a[i];
#define REDA(a,n,m) int a[n][m];for(int i=0;i<n;i++)for(int j=0;j<m;j++) cin>>a[i][j];





int pow(int a, int b)
{
    int prod=1;
    int mult=a;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod2;
        }
        mult*=mult;
        mult%=mod2;
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int mod)
{
    return pow(q, mod-2);
}





const int MAXN=4e5+10;
signed main()
{
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r")) {
        freopen ("INPUT.txt" , "r" , stdin);
        // freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
//---------------------------------------------------------------------------------------------------
    string s, t;
    cin>>s>>t;
    cout<<t<<s;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = Integer.parseInt(scanner.next());
        int d = Integer.parseInt(scanner.next());
        int x = Integer.parseInt(scanner.next());
        int answer = x;

        for (int i = 1;i <= n;i++) {
            int a = Integer.parseInt(scanner.next());
            answer += 1;
            for (int j = 1;j <= d;j++) {
                if ((j*a+1) <= d) {
                    answer += 1;
                }
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int n;

vector<int> a;

void input() {
  cin >> n;

  a = vector<int>(n);
  for (auto&& i : a)
    cin >> i;
}

void solve1() {
  vector<int> sums(n, a[0]);
  for (int i = 1; i < n; ++i)
    sums[i] = sums[i - 1] + a[i];

  int ans = 1e9;

  for (int i = 0; i < n; ++i) {
    int l = sums[i];
    int r = sums.back() - sums[i];

    ans = min(ans, abs(r - l));
  }

  cout << ans;
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve1();
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ARoundUpTheMean {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
	    int n = a+b;
	    out << ceill(n, 2) << endl;
	}
};


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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e6+50;
const int mod=1e9+7;
using namespace std;
ll h,p;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>h;
	p=1;
	while(p<=h)p*=2LL;
	cout<<p-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<math.h>
using namespace std;

int main(){
	double a,b,c,K,z;
	cin >> a >>b >> c >> K;
	z = pow(2,K);

	if (a <= c && b <= c)
	{
		cout << a+b+c*z << endl;
	}
	else if (a<=b && c<=b)
	{
		cout << a+c+b*z <<endl;
	}
	else if (b<=a && c<=a){
		cout << b+c+a*z << endl;
	}
}


Measured memory_bytes: 256
use proconio::{fastout, input};
// use proconio::marker::*;

const MOD: u64 = 998244353;

#[fastout]
fn main() {
   input! {
      n: usize,
      s: usize,
      a: [usize; n]
   }
   let mut dp = vec![0; s + 1];
   for &a in a.iter() {
      for i in (0..=s).rev() {
         dp[i] += dp[i];
         if i == 0 || i == a {
            dp[i] += 1;
         }
         if i >= a {
            dp[i] += dp[i - a];
         }
         dp[i] %= MOD;
      }
   }
   println!("{}", dp[s]);
}


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

int main() {
    int n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    unsigned long long x = 1;
    for(int i = 0; i < n; i++){
        if(x > 1000000000000000000 / a[i]){
            cout << -1 << endl;
            return 0;
        }
        x *= a[i];
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    string s;
    ll k;
    cin>>s>>k;
    int i=0;
    while (i<s.size()-1&&i<k-1&&s[i]=='1')
        i++;
    cout<<s[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(x) for x in input().split()]  # monster
b = [int(x) for x in input().split()]  # braver

total = sum(a)

for i in range(n):
  
  if a[i] < b[i]:  # 一人の勇者が倒せる数よりもモンスターが少ない場合
    b[i] = b[i] - a[i]
    a[i] = 0
    if a[i+1] - b[i] < 0:
      a[i+1] = 0
    else:
      a[i+1] = a[i+1] - b[i]
  else:   # 一人の勇者が倒せる数よりもモンスターが多い場合
    a[i] = a[i] - b[i]
    

print(total - sum(a))

Measured memory_bytes: 18436
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

struct weighted_unionfind {
    vector<int> d;
    vector<int> diff_weight;
    weighted_unionfind(int n=0) : d(n, -1), diff_weight(n, 0) {}
    int find(int x) {
        if (d[x] < 0) return x;
        int root = find(d[x]);
        diff_weight[x] += diff_weight[d[x]];
        return d[x] = root;
    }
    int weight(int x) {
        find(x);
        return diff_weight[x];
    }
    int diff(int x, int y) { return diff_weight[y] - diff_weight[x];}
    // weight(y) - weight(x) = w
    bool unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) {
            swap(x, y);
            w = -w;
        }
        d[x] += d[y];
        d[y] = x;
        diff_weight[y] = w;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y);}
    int size(int x) { return -d[find(x)];}
};

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

    int n, q;
    cin >> n >> q;
    weighted_unionfind wuf(n);
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int x, y, z;
            cin >> x >> y >> z;
            wuf.unite(x, y, z);
        } else {
            int x, y;
            cin >> x >> y;
            if (wuf.same(x, y)) {
                cout << wuf.diff(x, y) << endl;
            } else {
                cout << '?' << endl;
            }
        }
    }
}


Measured memory_bytes: 3624
n,k = map(int,input().split())
s = input()
cnt = 1
arr0 = []
if s[0]=="1":
  arr = [0]
else:
  arr = [0,0]
for i in range(n-1):
  if s[i] == s[i+1]:
    cnt += 1
  else:
    arr0.append(cnt)
    cnt = 1
arr0.append(cnt)
arr += arr0
if s[n-1] == "0":
  arr.append(0)
lsum = [0]*(len(arr)//2)
lsum[0] = arr[0]+arr[1]
for i in range(1,len(arr)//2):
  lsum[i] = lsum[i-1]+arr[2*i]+arr[2*i+1]
arr = [0,0]+[0]*(s[0]=="0")+arr0+[0]*(s[n-1]=="1")
rsum = [0]*(len(arr)//2)
for i in range(1,len(arr)//2):
  rsum[i] = rsum[i-1]+arr[2*i]+arr[2*i+1]
ans = 0
if k >= len(lsum)-1:
  print(n)
  quit()
for i in range(k,len(lsum)):
  ans = max(ans,lsum[i]-rsum[i-k])
print(ans)

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

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

fn main() {
    let n = read::<usize>();
    let mut tree = vec![vec![]; n];
    let v = read_vec::<usize>();
    for i in 1..n {
        let (a, b) = (v[i - 1] - 1, i);
        tree[a].push(b);
    }
    let x = read_vec::<usize>();
    let x_end = x.iter().max().unwrap() + 1;

    let mut topological_sorted_indexes = vec![0];
    topological_dfs(0, &tree, &mut topological_sorted_indexes);

    let mut sum_self_and_childs = vec![(0usize, 0usize); n];
    'outer: for &ti in topological_sorted_indexes.iter().rev() {
        let mut dp = vec![false; x_end];
        dp[0] = true;
        for &ci in tree[ti].iter() {
            let mut next = vec![false; x_end];
            for xi in 0..x_end {
                if dp[xi] && xi + sum_self_and_childs[ci].0 < x_end - 1 {
                    next[xi + sum_self_and_childs[ci].0] = true;
                }
                if dp[xi] && xi + sum_self_and_childs[ci].1 < x_end {
                    next[xi + sum_self_and_childs[ci].1] = true;
                }
            }
            dp = next;
        }
        let sum_childs = tree[ti]
            .iter()
            .map(|&x| sum_self_and_childs[x].0 + sum_self_and_childs[x].1)
            .sum::<usize>();

        for xi in (0..x[ti] + 1).rev() {
            if dp[xi] {
                sum_self_and_childs[ti].0 = x[ti];
                sum_self_and_childs[ti].1 = sum_childs - xi;
                continue 'outer;
            }
        }
        println!("IMPOSSIBLE");
        return;
    }
    println!("POSSIBLE");
}

fn topological_dfs(cur_idx: usize, tree: &Vec<Vec<usize>>, result: &mut Vec<usize>) {
    for child_idx in tree[cur_idx].iter() {
        result.push(*child_idx);
        topological_dfs(*child_idx, tree, result);
    }
}

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

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


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    void solve() {
        char[] s = in.next().toCharArray();
        int cntB = 0;
        long res = 0;
        for (char c : s) {
            if (c == 'B') {
                cntB++;
            } else {
                res += cntB;
            }
        }
        out.println(res);
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

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

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

Measured memory_bytes: 26580
#include<iostream>
using namespace std;
int main()
{
  int n;
  string s;
  cin>>n;
  cin>>s;
  if(n%2!=0) {cout<<"No"; return 0;}
  for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[(n/2)+i]) 
    {
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

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

  for(int i=1; i<10; ++i){
    for(int j=1; j<10; ++j){
      if(i*j == n){
        cout << "Yes";
          return 0;
      }
    }
  }
  cout << "No";

}

  

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

using namespace std;

bool memo[100100];
int N, K, A[100100];
int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	for (int i = 1; i <= K; i++) {
		for (int j = 0; j < N; j++) {
			if (i - A[j] < 0) continue;
			memo[i] |= (not memo[i - A[j]]);
		}
	}

	if (memo[K]) {
		cout << "First\n";
	} else {
		cout << "Second\n";
	}

	return 0;
}

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

using namespace std;
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};// right, down, ...
string ans="Impossible";
int H, W;
char a[10][10];
int F=0;

void rec(int i, int j){

   a[i][j]='.';
   if(i==H-1&&j==W-1){
      F=1;
      return;
   }else{
      int c=0;
      for(int k=0; k<2; k++){
         int ni=i+dy[k];
         int nj=j+dx[k];
         if(!(0<=ni&&ni<H&&0<=nj&&nj<W)) continue;
         if(c==0&&a[ni][nj]=='#'&&F==0){
            c++;
            rec(ni, nj);
         }
      }
   }
}
int main(){

   cin>> H>> W;
   for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
         cin>> a[i][j];
      }
   }

   rec(0, 0);

   int f=0;
   for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
         f|=(a[i][j]=='#');
      }
   }

   cout<< (f? "Impossible": "Possible")<< endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, t;
    cin >> n >> t;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll ans = 0;
    ll now = a[0]; 
    for (ll i = 1; i < n; i++)
    {
        if (now + t <= a[i])
        {
            ans += t;
        }
        else
        {
            ans += a[i] - now;
        }
        now = a[i];
    }
    cout << ans + t << endl;
}

Measured memory_bytes: 1792
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};

int main(){
    int r; cin >> r;
    cout << 2 * r * acos(-1) << endl;
    return 0;
}

Measured memory_bytes: 3744
#include<iostream>
using namespace std;
int main()
{
    int n,m,asum,bsum,csum,sum,a,b,c;
    while(cin >> n,n!=0){
        int mi = 1000010;
        for(int i=0;i<=n;i+=200){
            for(int j=0;j<=n-i;j+=300){
                int k=n-i-j;
                if(k%500 != 0) continue;
                asum = i/200;
                bsum = j/300;
                csum = k/500;
                sum = 380*(asum-asum%5)*80/100 + 380*(asum%5);
                sum += 550*(bsum-bsum%4)*85/100 + 550*(bsum%4);
                sum += 850*(csum-csum%3)*88/100 + 850*(csum%3);
                mi = min(mi,sum);
            }
        }
        cout << mi << endl;
    }
    return 0;
}



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

int main() {
  string s; cin >> s;
  int min = 10000000;

  rep (i, s.size() - 2) {
    if (abs(753 - stoi(s.substr(i, 3))) < min)
      min = abs(753 - stoi(s.substr(i, 3)));
  }

  cout << min << endl;
}

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    vector <int >a(n);//スイッチごとの２進数
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int s;
            cin >>s;
            s--;
            a[s]|=1<<i;
        }
    }
    int p=0;
    for(int i=0;i<m;i++){
        int x;
        cin >>x;
        p|=x<<i;
    }
    int ans=0;
    for(int s=0;s<(1<<n);s++){
        int t=0;
        for(int i=0;i<n;i++){
            if(s&(1<<i)){
                t^=a[i];
            }
        }
        if(t==p){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    n, m, k = map(int, args[0].split())
    mod = 998244353

    if m == 1 and n-1 == k:
        return str(1)

    ncr = 1
    p = m*pow(m-1, n-1, mod) % mod
    ret = p
    inv = pow(m-1, mod-2, mod)
    for i in range(1, k+1):
        ncr = (ncr * (n-i)*pow(i, mod-2, mod)) % mod
        p = (p*inv) % mod
        ret += p*ncr % mod

    return str(ret % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9192
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int[] a = new int[N];
		
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		int count = 0;
		int max = 0;
		
		for(int i = 0; i < N; i++) {
			if(i == 0 || a[i] != a[i - 1]) {
				for(int j = i; j < N; j++) {
					if(a[i] + 2 >= a[j]) {
						count++;
					} else {
						break;
					}
				}
				max = Math.max(count, max);
				count = 0;
			}
		}
		System.out.println(max);
	}
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll x;
  cin >> x;

  vector<bool> primes(3*x,true);
  primes[0] = false;
  primes[1] = false;
  FOR(i,2,primes.size()){
    if(primes[i]){
      ll j = i*2;
      while(j<=primes.size()){
        primes[j] = false;
        j += i;
      }
    }
  }
  REP(i,primes.size()){
    if(primes[i] && i>=x){
      cout << i << endl;
      return 0;
    }
  }
  
  //cout << fixed << setprecision(10);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct median
{
	int id, num;
};
bool cmp(median a, median b)
{
	return a.num<b.num;
}
int main()
{
	int n, f=0, i, j, k=1;
	cin >> n;
	median a[n+1];
	int b[n+1], c[n+1], L=1, x=n/2;
	for (i=1; i<=n; i++)
	{
		cin >> a[i].num;
		a[i].id = i;
	}
	sort (a+1, a+n+1, cmp);
	for (j=1; j<=n; j++)
	{
		if (j<=x)
			c[a[j].id] = a[n/2+1].num;
		else
			c[a[j].id] = a[n/2].num;
	}
	for (j=1; j<=n; j++)
		cout << c[j] << endl;
	return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define ll long long
using namespace std;


int main()
{

	string s,t;cin>>s>>t;

	int ans = 0;
	for(int i = 0; i < 3; i++)
		if(s[i] == t[i])
			ans++;

	cout<<ans<<"\n";


	return 0;
}

Measured memory_bytes: 256