akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	ll n,k,s;
	cin>>n>>k>>s;
	vl ans;
	rep(i,k)ans.push_back(s);
	int a=0;
	rep(i,sqrt(s)+2){
		if(i==0)continue;
		if(s%i!=0){
		a=i;
		break;
		}
	}
	if(a==0)a=1;
	rep(i,n-k)ans.push_back(a);
	rep(i,n-1)cout<<ans[i]<<' ';
	cout<<ans[n-1]<<endl;
}

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

int main(){
    while(true) {
        int a = 0, b = 0;
        int n = 0;
        std::cin >> a >> b;
        if(a == 0 && b == 0){
            break;
        }
        std::cin >> n;
        std::vector<std::vector<int>> road;
        road = std::vector<std::vector<int>>(a, std::vector<int>(b, 0));
        for (int i = 1; i < b; ++i) {
            road[0][i] = 1;
        }
        for (int i = 1; i < a; ++i) {
            road[i][0] = 1;
        }
        for (int i = 0; i < n; ++i) {
            int x, y;
            std::cin >> x >> y;
            road[x - 1][y - 1] = -1;
            if(x == 1){
                for(int i = y-1; i< b; ++i){
                    road[0][i] = 0;
                }
            }
            if(y == 1){
                for(int i = x-1; i < a; ++i){
                    road[i][y-1] = 0;
                }
            }
        }
        for (int i = 1; i < a; ++i) {
            for (int j = 1; j < b; ++j) {
                if (road[i][j] == -1) {
                    road[i][j] = 0;
                } else {
                    road[i][j] = road[i-1][j] + road[i][j-1];
                }
            }
        }
        std::cout << road[a - 1][b - 1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3000
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

struct BIT //0-indexed
{
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}
};

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

	int N, K;
	cin >> N >> K;

	vector<int> A(N);
	vector<int> SA;
	rep(i, 0, N)
	{
		cin >> A[i];
		A[i] = A[i] - K;
		if (i > 0)A[i] += A[i - 1];
		SA.push_back(A[i]);
		SA.push_back(A[i] - 1);
	}

	SA.push_back(-1);
	sort(all(SA));
	SA.erase(unique(all(SA)), SA.end());

	BIT bit(2 * N + 2);
	rep(i, 0, N)
	{
		int idx = lower_bound(all(SA), A[i]) - SA.begin();
		bit.add(idx, 1);
	}

	int ans = 0;
	rep(i, 0, N)
	{
		int idx;
		if (i == 0)
		{
			idx = lower_bound(all(SA), -1) - SA.begin();
		}
		else
		{
			idx = lower_bound(all(SA), A[i - 1] - 1) - SA.begin();
		}
		ans += N - i - bit.sum(idx);
		idx = lower_bound(all(SA), A[i]) - SA.begin();
		bit.add(idx, -1);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11060
#include<bits/stdc++.h>
using namespace std;
int N,M;
int A[1000];
int ans=0;
 
int main(){
  cin>>N>>M;
  for(int i=0;i<N;i++)cin>>A[i];
  int p=0;
  do{
    int mini=1e9;
    int maxm=0;
    for(int i=0;i<M;i++){
      mini=min(mini,A[p]);
      maxm=max(maxm,A[p]);
      p=(p+1)%N;
    }
    ans+=(maxm-mini);
  }while(p>0);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {

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

		while(sc.hasNext()) {
			int x  = sc.nextInt();
				if (x == 0) {
					break;
				} else {
					System.out.println( length_of_zero(x) );
				}

		}

	}

	private static int length_of_zero(int x) {
		int ans = 0;

			for (int i = 0; Math.pow(5, i + 1) <= x; i++) {
				ans += x / Math.pow(5, i + 1);
			}

		return ans;
	}
}


Measured memory_bytes: 25680
import java.util.Scanner;
public class Main{ 
	public static void main(String[] args) {
	Scanner input = new Scanner (System.in);
		int a = input.nextInt();
		int b=input.nextInt();
		int c=input.nextInt();
		if(a==5 && b==5 && c==7)
	          System.out.println("YES");
	      else if(a==7 && b==5 && c==5)
	          System.out.println("YES");
	      else if(a==5 && b==7 && c==5)
	          System.out.println("YES");
	      else
	          System.out.println("NO");}}
	

Measured memory_bytes: 27000
#include<bits/stdc++.h>
#define mod 1000000007
#define N 1005
#define M 10005
#define ll long long
using namespace std;
inline int read(){
	int ans=0;
	char ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
	return ans;
}
struct edge{int v,next;}e[M<<1];
ll ifac[M],fac[M],dfn[N],low[N],tot=0,ans=1;
int n,m,k,top=0,first[N],cnt=0,stk[N],siz,rec,pot,edg;
set<int>tmp;
inline void add(int u,int v){e[++cnt].v=v,e[cnt].next=first[u],first[u]=cnt;}
inline ll ksm(ll x,int p){
	ll ret=1;
	while(p){
		if(p&1)ret=ret*x%mod;
		x=x*x%mod,p>>=1;
	}
	return ret;
}
inline ll gcd(ll a,ll b){while(b){ll t=a;a=b,b=t%a;};return a;}
inline ll polya(int x){
	ll ret=0;
	for(int i=1;i<=x;++i)(ret+=ksm(k,gcd(x,i)))%=mod;
	return ret*ksm(x,mod-2)%mod;
}
inline ll C(int n,int m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
inline void dfs(int p,int fa){
	dfn[p]=low[p]=++tot,stk[++top]=p;
	for(int i=first[p];i;i=e[i].next){
		int v=e[i].v;
		if(v==fa)continue;
		if(dfn[v]){low[p]=min(low[p],dfn[v]);continue;}
		dfs(v,p),low[p]=min(low[p],low[v]);
		if(low[v]>=dfn[p]){
			tmp.clear(),pot=edg=0;
			do tmp.insert((rec=stk[top--])),++pot; while(rec!=v);
			tmp.insert(p),++pot;
			for(set<int>:: iterator it=tmp.begin();it!=tmp.end();++it)for(int k=first[*it];k;k=e[k].next)if(tmp.count(e[k].v))++edg;
			edg>>=1;
			ll ttmp;
			if(edg<pot)(ans*=k)%=mod;
			if(edg==pot)(ans*=polya(edg))%=mod;
			if(edg>pot)(ans*=C(edg+k-1,k-1))%=mod;
		}
	}
	if(!fa)--top;
}
int main(){
	n=read(),m=read(),k=read(),ifac[0]=fac[0]=ifac[1]=1;
	for(int i=2;i<M;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;
	for(int i=1;i<M;++i)fac[i]=fac[i-1]*i%mod,(ifac[i]*=ifac[i-1])%=mod;
	for(int i=1;i<=m;++i){
		int a=read(),b=read();
		add(a,b),add(b,a);
	}
	for(int i=1;i<=n;++i)if(!dfn[i])dfs(i,0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans;
    ans = min(a,k);
    k -= (a+b);
    if(k>0) ans -= k;
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n, x);
  Cins(int, n, a);

  sort(rng(a));

  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if (x == a[n - 1]) ans++;
  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

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

constexpr ll mod = 1e9 + 7;


class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; } const
		ll operator[](int k) { return F[k]; }
};

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};


int main() {
	ll n, m;
	cin >> n >> m;
	Divisor d(m);
	Factorial f(100 + n);
	ll sum = 1;
	for (auto p : d.pfac()) {
		auto s = p.second;
		auto c = f.cmb(s + n - 1, n - 1);
		sum *= c;
		sum %= mod;	
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4976
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	aStr := nextString()
	bStr := nextString()

	a, _ := new(big.Int).SetString(aStr, 10)
	b, _ := new(big.Int).SetString(bStr, 10)
	c := big.NewInt(0).Sub(a, b)

	fmt.Println(c)
}



Measured memory_bytes: 6924
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();   // 58978979;
        int h = s / 3600;
        s -= h*3600;
        int m = s/60;
        s-= m*60;
        System.out.println(h+":"+m+":"+s);
    }
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()
#define allof(a) (a).begin(),(a).end()

typedef pair< int, int > pii;

int main() {
	int n, m;
	cin >> n >> m;
	
	vector< int > deg(n, 0);
	vector< vector< pii > > edges(n, vector< pii >());
	
	for_(i,0,m) {
		int u, v, w;
		cin >> u >> v >> w;
		edges[u].push_back(pii(v, w));
		++deg[v];
	}
	
	vector< int > dp(n, 0);
	
	queue< int > topol;
	topol.push(0);
	
	while (!topol.empty()) {
		int v = topol.front(); topol.pop();
		
		int edge_num = size_of(edges[v]);
		
		for_(i,0,edge_num) {
			pii p = edges[v][i];
			int u = p.first, w = p.second;
			
			--deg[u];
			if (deg[u] == 0) topol.push(u);
			
			dp[u] = max(dp[u], dp[v] + w);
		}
	}
	
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n;
    cin >> n;
    vector<int> data(n+1);
    data[0]=0;
    rep(i,0,n){
        cin >> data[i+1];
    }
    int ans=0;
    rep(i,0,n){
        if(data[i+1]>data[i]){
            ans += data[i+1]-data[i];
        }
    }
    cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int L,R;
  cin >> L >>R;
  if(R-L>=2019){
    cout << 0 << endl;
  }
  else{
    ll ans=((R%2019)*(L%2019))%2019;
    for(ll i=L; i<R; i++){
      for(ll j=i+1; j<=R; j++){
	ans = min(((i%2019)*(j%2019))%2019,ans);
      }
    }
    cout << ans << endl;
  }
  
  return 0;
    

}


Measured memory_bytes: 256
N = int(input())
S100 = input()
S100list = list(S100)
X100 = set(S100list)
PIN = 0
for i in X100:
    S10 = S100[S100.find(i)+1:]
    X10 = set(list(S10))
    for j in X10:
        S1 = S10[S10.find(j)+1:]
        X1 = set(list(S1))
        PIN += len(X1)
    
print(PIN)

Measured memory_bytes: 77064
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
ans = 0
def A(x,N,K):
    p = N // K
    q = N % K
    if x == 0:
        x += K
    if x <= q:
        return p + 1
    else:
        return p
for a_mod in range(K):
    b_mod = (K - a_mod) % K
    c_mod = b_mod
    if (b_mod + c_mod) % K == 0:
        ans += A(a_mod,N,K) * A(b_mod,N,K) * A(c_mod,N,K)

print(ans) 

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

#define ll      long long
#define MAX     1000007
#define inf     99999999999999
#define MOD     1000000007
#define pii     pair<int,int>
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);

double a,b,c,d,e,f,rwater,rsugar;
ll dp[3005][3005];


int main ()
{
    double res = -inf;
    scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f);
    for(double i=0;(a*100*i)<=f;i++)
    {
        for(double j=0;(b*100*j)<=f;j++)
        {
            for(double k=0;(k*c)<=f;k++)
            {
                for(double l=0;(l*d)<=f;l++)
                {
                    double water = ((i*a) + (j*b))*100;
                    double sugar = (k*c) + (l*d);
                    double req = (100.0* sugar)/e;

                    if((water + sugar) <= f && req<=water)
                    {

                        double temp = (double)(sugar*100.0)/(double)(sugar + water);
                        if(temp>res)
                        {
                            rwater = water+sugar;
                            rsugar = sugar;
                            res = temp;
                        }
                    }
                }
            }
        }
    }
    printf("%lld %lld\n",(ll)rwater,(ll)rsugar);
    return 0;
}


Measured memory_bytes: 256
lst = input().split()
H = int(lst[0])
W = int(lst[1])

field = []
for i in range(H):
   l = []
   s = input()
   for j in range(W):
      l.append(s[j])
   field.append(l)

def count(x, y):
   result = 0
   for P in [[x-1, y-1], [x, y-1], [x+1, y-1], [x-1, y], [x+1, y], [x-1, y+1], [x, y+1], [x+1, y+1]]:
      try:
         if (0 <= P[0]) and (0 <= P[1]) and (field[P[1]][P[0]] == '#'):
            result += 1
      except:
         pass
   return result

for i in range(H):
   for j in range(W):
      if field[i][j] == '.':
         field[i][j] = str(count(j, i))

def list2str(L):
   result = ''
   for t in L:
      result += t
   return result

for I in field:
   print(list2str(I))

Measured memory_bytes: 9180
arr = [input() for i in range(4)]

count = 0
for fi in range(0, int(arr[0])+1):
    for hun in range(0, int(arr[1])+1):
        for fifty in range(0, int(arr[2])+1):
            sum = fi * 500 + hun * 100 + fifty * 50
            if sum == int(arr[3]):
                count += 1
print(count)

Measured memory_bytes: 3060
N = int(input())
A = tuple(map(int, input().split()))


def f(pm):
    ans, s = 0, 0
    for a in A:
        s += a
        if s * pm <= 0:
            d = abs(s - pm)
            ans += d
            s += d * pm
        pm *= -1
    return ans


print(min(f(1), f(-1)))


Measured memory_bytes: 14340
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    r, D, x = LI()
    for i in range(10):
        x = r * x - D
        print(x)
    return


main()

Measured memory_bytes: 3064
line = input()
WA_flag = 0
C_flag = 0
check_point = 0

for cnt, elm in enumerate(line):
    if cnt == 0:
        if elm != "A":
            WA_flag += 1
            #print("A_wrong: " + elm)
    if cnt > 1 and cnt < (len(line) - 1):
        if elm =="C":
            C_flag += 1
            check_point = cnt

if C_flag != 1:
    WA_flag += 1
    #print("C_num wrong: " + elm)
else:
    for cnt, elm in enumerate(line):
        if cnt != 0 and cnt != check_point:
            if elm.isupper():
                WA_flag += 1
                #print("upper_wrong: " + elm)

if WA_flag != 0:
    print("WA")
else:
    print("AC")

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long a = cin.Long();
			long b = cin.Long();

			long gcd = GCD(a, b);
			var gp = GetPrimeFactor(gcd);
			gp.Add(1);

			Console.WriteLine(gp.Count());
		}

		public static HashSet<long> GetPrimeFactor(long value)
		{
			long temp = value;
			long max = (long)Math.Ceiling(Math.Sqrt(temp));
			var factors = new HashSet<long>();
			for (int i = 2; i <= max; ++i) {
				if (temp % i == 0) {
					factors.Add(i);
					while (temp % i == 0) {
						temp /= i;
					}
				}
			}

			if (temp != 1) {
				factors.Add(temp);
			}

			return factors;
		}

		public static long GCD(long a, long b)
		{
			if (a > b) {
				if (b == 0) {
					return a;
				}

				return GCD(b, a % b);
			} else {
				if (a == 0) {
					return b;
				}

				return GCD(a, b % a);
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13396
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m, x;
    scan(n, m, x);
    auto 参考書の値段とアルゴリズム = new long[][](n);
    // writeln(tmp);
    foreach (i; 0 .. n)
    {
        参考書の値段とアルゴリズム[i] = aryread();
    }
    // writeln(tmp);

    long func(long[] 買う買わない)
    {
        long 合計金額;
        auto 理解度 = new long[](m);
        if (買う買わない.length == n)
        {
            foreach (i; 0 .. (買う買わない.length))
            {
                if (買う買わない[i] == 1)
                {

                    合計金額 += 参考書の値段とアルゴリズム[i][0];
                    foreach (アルゴリズム番号; 1 .. m + 1)
                    {
                        理解度[アルゴリズム番号 - 1] += 参考書の値段とアルゴリズム[i][アルゴリズム番号];
                    }
                }
            }
            foreach (i; 0 .. m)
            {
                if (理解度[i] >= x)
                {
                    continue;
                }
                else
                {
                    return -1;
                }
            }
            return 合計金額;
        }
        else
        {
            // func(a~0);
            // func(a~1);
            long func_0 = func(買う買わない ~ 0);
            long func_1 = func(買う買わない ~ 1);
            if (func_0 != -1 && func_1 != -1)
            {
                return min(func_0, func_1);
            }
            else if (func_0 == -1 && func_1 != -1)
            {
                return func_1;
            }
            else if (func_1 == -1 && func_0 != -1)
            {
                return func_0;
            }
            else
            {

                return -1;
            }

        }
    }

    func([]).writeln();

    // func([1,1,0])
    // func([1,1,1])
    // long func(long[] a);
    // func([]);
    // func([1]);
    // func([0]);
    // func([1,0]);
    // func([1,1]);

    // xxx  func(xxx) = min(func(1xx), func(0xx))
    // 1xx

    // 11x
    // 111
    // 110

    // 10x
    // 101
    // 100

    // writeln(func(tmp, x));

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 4504
# -*- coding: utf-8 -*-
from functools import lru_cache
import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 2**60


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


class Doubling():
    def __init__(self, a0):
        """
        a0 is an array-like object which contains ai, 0 <= i < N.
        ai is the next value of i.
        """
        N = len(a0)
        self.N = N
        self.nt = [[None] * N for i in range(N.bit_length()+1)]
        for i, a in enumerate(a0):
            self.nt[0][i] = a

        for i in range(1, len(self.nt)):
            for j in range(N):
                if self.nt[i-1][j] is None:
                    self.nt[i][j] = None
                else:
                    self.nt[i][j] = self.nt[i-1][self.nt[i-1][j]]

    def apply(self, i, n):
        """
        Apply n times from i
        """
        j = i
        for k in range(n.bit_length()):
            m = 1 << k
            if m & n:
                j = self.nt[k][j]
            if j is None:
                break
        return j


class LCA():
    def __init__(self, g, root):
        s = [root]
        self.N = len(g)
        self.p = [None] * self.N
        self.d = [INF] * self.N

        self.p[root] = root
        self.d[root] = 0
        while s:
            u = s.pop()
            for v in g[u]:
                if self.d[v] is INF:
                    self.p[v] = u
                    self.d[v] = self.d[u] + 1
                    s.append(v)

        self.doubling = Doubling(self.p)

    def query(self, u, v):
        if self.d[u] > self.d[v]:
            u, v = v, u
        o = self.d[v] - self.d[u]
        v = self.doubling.apply(v, o)

        if u == v:
            return u

        for k in range(len(self.doubling.nt)-1, -1, -1):
            if self.doubling.nt[k][u] != self.doubling.nt[k][v]:
                u = self.doubling.nt[k][u]
                v = self.doubling.nt[k][v]
        return self.doubling.nt[0][u]


def slv(N, KC, Q, UV):
    g = [list() for _ in range(N)]
    for u, (k, *c) in enumerate(KC):
        for v in c:
            g[u].append(v)
            g[v].append(u)

    lca = LCA(g, 0)

    ans = []
    for u, v in UV:
        i = lca.query(u, v)
        ans.append(i)

    return ans


def main():
    N = read_int()
    KC = [read_int_n() for _ in range(N)]
    Q = read_int()
    UV = [read_int_n() for _ in range(Q)]
    print(*slv(N, KC, Q, UV), sep='\n')


if __name__ == '__main__':
    main()



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

using namespace std;
typedef long long LL;
const LL mod=998244353;
const int Max_Num=2e5+10;
LL F[Max_Num], Finv[Max_Num];

LL modinv(LL x){
	LL m=mod, u=1, v=0;
	while(m){
		LL t=x/m;
		x-=t*m; swap(x,m);
		u-=t*v; swap(u,v);
	}
	u%=mod;
	if(u<0) u+=mod;
	return u;
}

LL modpow(LL x, LL n){
	LL r=1;
	while(n){
		if(n&1) r=r*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return r;
}

void fact(){
	F[0]=1;
	rep(i,Max_Num-1){
		F[i+1]=F[i]*(i+1);
		F[i+1]%=mod;
	}
	rep(i,Max_Num) Finv[i]=modinv(F[i]);
}

LL comb(LL n, LL k){
	LL res=F[n];
	res*=Finv[k]*Finv[n-k]%mod;
	return res%mod;
}

int main(){
	fact();
	int N, M, K;
	cin >> N >> M >> K;
	if(M==1){
		if(K==N-1) cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	LL ans=0;
	for(LL i=0; i<=K; i++){
		LL res=comb(N-1,i);
		(res*=M)%=mod;
		res*=modpow(M-1,N-1-i);
		ans+=res%mod;
		ans%=mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6728
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let mut a = Vec::new();
    for _ in 0..n {
        a.push(i.read::<usize>());
    }
    let r = if solve(&a) { "first" } else { "second" };
    writeln!(o, "{}", r).unwrap();
}
fn solve(a: &[usize]) -> bool {
    a.iter().any(|&a| a % 2 != 0)
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
  int o,n,k,i,j;
  int key;
  int A[110];
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&A[i]);
  for(j=1;j<=n;j++)
    {   
	      key = A[j];		
	      i = j-1;
	      while(i>0 && A[i]>key)
		{
		  A[i+1]=A[i];  
		  i = i-1;
		}
	      A[i+1] = key;
	      for(k=1;k<=n;k++){
		if(k == n)printf("%d\n",A[k]);
		else printf("%d ",A[k]);
	      }
    }
  
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var n = long.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        if (n == 1)
        {
            Console.WriteLine("1");
            return;
        }

        if (a.Distinct().Count() == 1)
        {
            Console.WriteLine("0");
            return;
        }

        long ans = 0;

        n = a.Length;
        long max = a.Max();
        bool[] isNG = new bool[max + 1];
        
       
        a = a.OrderBy(t => t).ToArray();

        for (long i = 0; i < n; i++)
        {
            if (i == 0)
            {
                for (long tmp = 1; tmp < 1000000; tmp++)
                {
                    if (a[i] * tmp > max) break;
                    isNG[a[i] * tmp] = true;
                }

                if (i < n - 1)
                {
                    if (a[i] == a[i + 1]) continue;
                }

                ans++;

                continue;
            }

            bool flag = false;
            if (isNG[a[i]]) flag = true;
            for (long tmp = 1; tmp < 1000000; tmp++)
            {
                if (a[i] * tmp > max) break;
                isNG[a[i] * tmp] = true;
            }

            if (flag) continue;

            if(i > 0)
            {
                if (a[i - 1] == a[i]) continue;
            }
            if(i < n-1)
            {
                if (a[i] == a[i + 1]) continue;
            }

            ans++;
            
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 53168
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
int mod;

int d[2001][2001][2];
int d0[2001][2001];
int f[2001][2001][2];

ll calc(int i3, int i2, int i1) {
  vi l;
  vi c = {i1,i2,i3};
  int n = 0;
  for (int t = 0; t < 3; ++t) for (int i = 0; i < c[t]; ++i) {
    l.push_back(t + 1);
    n += l.back();
  }
  set<vi> ts;
  vi v(n);
  for (int i = 0; i < n; ++i) v[i] = i;
  do {
    vvi a(l.size());
    int it = 0;
    for (int i = 0; i < l.size(); ++i) for (int j = 0; j < l[i]; ++j) a[i].push_back(v[it++]);
    vi x;
    for (int i = 0; i < n; ++i) {
      pii mi(1e9, 0);
      for (int j = 0; j < l.size(); ++j) if (!a[j].empty()) {
        mi = min(mi, pii(a[j].back(), j));
      }
      x.push_back(mi.first);
      a[mi.second].pop_back();
    }
    ts.insert(x);
  } while (next_permutation(v.begin(), v.end()));
  return ts.size();
}

ll g(int i3, int i2, int i1) {
  if (i2 == 0) return d0[i3][i1];
  assert(i1 <= 1);
  return d[i3][i2][i1];
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n >> mod;
  d[0][0][0] = 1;
  d0[0][0] = 1;
  f[0][0][0] = 1;
  for (int i3 = 0; i3 <= n; ++i3) for (int i2 = 0; i2 <= n; ++i2) for (int i1 = 0; i1 <= 2; ++i1) {
    ll k = 3 * i3 + 2 * i2 + i1;
    if (k > 3 * n || i1 + i2 + i3 > n || i1 + i2 + i3 == 0) continue;
    ll k1 = k - 1;
    ll k2 = k1 * (k1 - 1) % mod;
    int& res = f[i3][i2][i1];
    res = 0;
    if (i1) {
      res = (res + f[i3][i2][i1-1]) % mod;
    } else if (i2) {
      res = (res + f[i3][i2 - 1][i1 + 1]) % mod;
    }
    if (i2) {
      res = (res + f[i3][i2 - 1][i1] * k1) % mod;
    }
    if (i3) res = (res + f[i3 - 1][i2][i1] * k2) % mod;
  }
  for (int i3 = 0; i3 <= n; ++i3) for (int i2 = 0; i2 <= n; ++i2) for (int i1 = 0; i1 <= (i2 == 0 ? n : 1); ++i1) {
    ll k = 3 * i3 + 2 * i2 + i1;
    if (k > 3 * n || i1 + i2 + i3 > n || i1 + i2 + i3 == 0) continue;
    ll k1 = k - 1;
    ll k2 = k1 * (k1 - 1) % mod;
    int& res = (i2 == 0 ? d0[i3][i1] : d[i3][i2][i1]);
    res = 0;
    if (i1) {
      res = (res + g(i3, i2, i1 - 1)) % mod;
    } else if (i3) {
      res = (res + g(i3 - 1,i2 + 1,i1) + (i2 > 0 ? f[i3][i2-1][1] : 0)) % mod;
    } else if (i2) {
      res = (res + g(i3,i2 - 1,i1 + 1)) % mod;
    }
    if (i2) {
      res = (res + g(i3,i2 - 1,i1) * k1) % mod;
    } else if (i3) {
      res = (res + g(i3 - 1,i2,i1 + 1) * k1) % mod;
    }
    if (i3) res = (res + g(i3 - 1,i2,i1) * k2) % mod;
//    cerr << i3 << ' ' << i2 << ' ' << i1 << ' ' << res << ' ' << calc(i3, i2, i1) << endl;
  }
  cout << g(n, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 78208
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define int long long
#define abs Abs
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int SMOD = 1000000007;
const int NMOD = 1000000009;
int dx[]={1,0,-1,0,1,1,-1,-1};
int dy[]={0,-1,0,1,-1,1,-1,1};
ll Abs(ll x){return (x<0 ? -x : x);}
bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
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 qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct xyz{
    xyz(){
        cin.tie(0), ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
    };
}xyzzy;

int x[10000000];
signed main(){
    int n;
    cin >> n;
    int i  =1;
    x[n]++;
    while(true){
        if(n&1){
            x[3*n+1]++;
            if(x[n=3*n+1]==2) break;
        }else{
            x[n/2]++;
            if(x[n=n/2]==2) break;
            }
        i++;
    }
    cout << i+1 fin;
  return 0;
}


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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int n1 = (a + d - 1) / d;
	int n2 = (c + b - 1) / b;
	if (n1 >= n2) {
		cout << "Yes";
	}	else {
		cout << "No";
	}
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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(void){
    int N,D;
    cin>>N>>D;
    int X[N][D];
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin>>X[i][j];
        }
    }
    int res=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            double ans=0;
            for(int k=0;k<D;k++){
                ans+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            ans=sqrt(ans);
            if(ans==int(ans)) res++;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;x = x % p;if (x == 0)return 0;while (y > 0)  
    {if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;  }  return res;  
}
bool sortinrev(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b){if(a.fi==b.fi)return b.se>a.se;return a.fi>b.fi;}
void run(vector<int>v){for(int i=0;i<v.size();i++)cout<<v[i]<<" ";cout<<endl;}
void solve()
{
    int n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
        // cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
    }
    ll dp1[n],dp2[n],dp3[n];
    dp1[0] = a[0];dp2[0] = b[0];dp3[0] = c[0];
    for(int i=1;i<n;i++)
    {
        dp1[i] = max(dp2[i-1],dp3[i-1])+a[i];
        dp2[i] = max(dp1[i-1],dp3[i-1])+b[i];
        dp3[i] = max(dp2[i-1],dp1[i-1])+c[i];
        // cout<<dp1[i]<<" "<<dp2[i]<<" "<<dp3[i]<<endl;
    }
    cout<<max(dp1[n-1],max(dp2[n-1],dp3[n-1]))<<endl;
    
    

}
int main() 
{ 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    solve();
    
        
    
    
    return 0; 
} 

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

int main() {
  int n;
  cin >> n;
  
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    
    sum += r - (l - 1);
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
K = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    K[a-1].append(b-1)
    K[b-1].append(a-1)

c = 0
P = [0]*N
P[0] = 1
def bfs(start,used):
    global c
    for i in K[start]:
        M = used[:]
        k = 0
        if M[i] == 0:
            M[i] = 1
            for j in M:
                if j != 1:
                    k = 1
                    break
            if k == 0:
                c += 1
            else:
                bfs(i,M)

bfs(0,P)
print(c)

Measured memory_bytes: 41308
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

    ll N, K;
    cin >> N >> K;
    ll nz = 0, ne = 0;
    for(int i = 1; i <= N; i ++){
        if(i % K == 0)nz ++;
        if(K % 2 == 0 && i % K == K / 2)ne ++;
    }
    if(K % 2 == 1){
        cout << nz * nz * nz << endl;
    }
    else{
        cout << nz * nz * nz + ne * ne * ne << endl;
    }
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n , m = map(int, input().split())
g = [[] for i in range(n)]
v = [0]*n
v[0]=1
f = [0]*n
for i in range(m):
    a , b = map(int, input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)

d=deque()
d.append(0)

while d:
    room = d.popleft()
    for i in g[room]:
        if v[i]==1:
            continue

        d.append(i)
        v[i]=1
        f[i]=room

for i in range(n):
    if v[i]==0:
        print('No')
        exit()
print('Yes')
for i in range(1,n):
    print(f[i]+1)


Measured memory_bytes: 34804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
vector<vector<int>> g;
vector<int> d, v;
void dfs(int now, int pre) {
    d[now] = v[now];
    if (pre != -1) d[now] += d[pre];
    for (int nxt : g[now]) {
        if (nxt == pre) continue;
        dfs(nxt, now);
    }
}
int main() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    v.resize(n);
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        v[p] += x;
    }
    d.resize(n);
    dfs(0, -1);
    rep(i, n) cout << d[i] << endl;
}

Measured memory_bytes: 24320
N = gets.to_i
a = gets.split.map(&:to_i)

VMAX = 10000
S = a.min

def solve(a)
  ans = 0
  b = Marshal.load(Marshal.dump(a)).sort
  v = Array.new(N, false)
  t = []

  (0...N).each do |i|
    t[b[i]] = i
  end

  (0...N).each do |i|
    next if v[i]

    cur = i
    s = 0
    m = VMAX
    an = 0

    loop do
      v[cur] = true
      an += 1
      val = a[cur]
      m = [m, val].min
      s += val
      cur = t[val]

      break if v[cur]
    end
    ans += [s + (an - 2) * m, m + s + (an + 1) * S].min
  end
  ans
end

puts solve(a)


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=101234;

int n,w[412][412];
bool flg[412][412];
ll a,s[412],dp[412][412],res,max2;

ll DP(int l,int r)
{
    if(flg[l][r])
        return dp[l][r];
    if(r-l==1)
    {
        dp[l][r]=0;
        w[l][r]=l;
    }
    else
    {
        for(int i=w[l][r-1]; i<=w[l+1][r]; ++i)
        {
            if(dp[l][r]>=DP(l,i)+DP(i+1,r))
            {
                dp[l][r]=dp[l][i]+dp[i+1][r];
                w[l][r]=i;
            }
        }
    }
    dp[l][r]+=s[r]-s[l-1];
    flg[l][r]=1;
    return dp[l][r];
}

int main()
{
    scanf("%d",&n);
    max2=0x7fffffffffffffff;
    for(int i=1; i<n; ++i)
        for(int j=i+1; j<=n; ++j)
        {
            dp[i][j]=max2;
            w[i][j]=i;
        }
    for(int i=1; i<=n; ++i)
    {
        scanf("%lld",&a);
        s[i]=s[i-1]+a;
        flg[i][i]=1;
    }
    res=DP(1,n);
    printf("%lld",res);
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	int an=0,bn=0,cn=0,f=1;
	string a,b,c;
	cin>>a>>b>>c;
	while(an!=a.size()+1 && bn!=b.size()+1 && cn!=c.size()+1){
		if(f==1){
			if(a[an]=='a')f=1;
			else if(a[an]=='b')f=2;
			else f=3;
			an++;
		}
		else if(f==2){
			if(b[bn]=='a')f=1;
			else if(b[bn]=='b')f=2;
			else f=3;
			bn++;
		}
		else{
			if(c[cn]=='a')f=1;
			else if(c[cn]=='b')f=2;
			else f=3;
			cn++;
		}
	}
	//cout<<an<<" "<<bn<<" "<<cn<<endl;
	if(an==a.size()+1)cout<<"A"<<endl;
	if(bn==b.size()+1)cout<<"B"<<endl;
	if(cn==c.size()+1)cout<<"C"<<endl;
	return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    int ar[51];
    int ans=0,n;

    void func(int a,int b,int rem)
    {
        //cout<<a<<" "<<b<<endl;
        int i,j,sum=0;
        map<int,int> mp;
        for(i=1;i<=a;++i)
        {
            mp[ar[i]]++;
            sum=sum+ar[i];
        }
        for(i=1;i<=b;++i)
        {
            //cout<<n-i+1<<endl;
            mp[ar[n-i+1]]++;
            sum=sum+ar[n-i+1];
        }
        int x;
        for(auto it:mp)
        {
            if(it.f>0 || rem<=0)
                break;
            x=min(rem,it.s);
            rem=rem-x;
            sum=sum-it.f*x;
        }
        ans=max(ans,sum);
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int k,i,j,l,m;
            cin>>n>>k;
            int ar2[n+1];
            ar2[0]=0;
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
                ar2[i]=ar2[i-1]+ar[i];
            }
            

            int sum,ct;
            for(i=0;i<=n && i<=k;++i)
            {
                for(j=0;i+j<=k && i+j<=n;++j)
                    func(i,j,k-(i+j));
            }
            cout<<ans<<endl;
        }
        return 0;
    }


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

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 998244353;
    long inv2 =1;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
        out.println(main.solve());
        out.flush();
    }
    long solve() throws IOException {
        int n = sc.nextInt();
        long[] a = new long[n+1];
        for(int i=0; i<=n; i++) a[i] = sc.nextLong();
//        if(a[0]>0) return -1;
        long[] mini = new long[n+1], maxi = new long[n+1];
        mini[n] = a[n]; maxi[n] = a[n];
        for(int i=n-1; i>=0; i--){
            mini[i] = (mini[i+1]+1)/2;
            mini[i] += a[i]; maxi[i] = maxi[i+1]+a[i];
        }
        if(mini[0]!=1) return -1;
        long cur = 1, ans = 1;
        for(int i=1; i<=n; i++){
            cur = Math.min(cur*2, maxi[i]);
            ans += cur;
            cur -= a[i];
        }
        return ans;
    }
}

Measured memory_bytes: 59844
import bisect
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))

li = sorted(LI(), reverse=True)
print(int(str(li[0])+str(li[1])) + int(li[2]))


Measured memory_bytes: 3316