akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <math.h>
using namespace std;


int j(int x,int y,int z){
    int a = x*x+ y*y + z*z + x*y+y*z+z*x;
    return a;
}


void f(int k){
    int count = 0;
    int sup = (int) ceil(sqrt((double)k-3.75)-0.5);
    for(int x = 1; x <= sup ; x++){
        for(int y = 1; y <= sup;y++){
            for(int z = 1; z <= sup; z++){
                if(j(x,y,z) == k){
                    count++;
                }else if(j(x,y,z) > k){
                    break;
                }
            }
        }
    }
    std::cout << count << std::endl;
}



int main(){
    int N;
    std::cin >> N;
    int a[N];
    for(int i = 1;i < N+1 ; i++){
        f(i);
    }
    return 0;
}



Measured memory_bytes: 3564
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/7/13 12:59:34
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=1e6;
bool isprime[maxx+20];
LL pri[maxx+20],cnt=0;
LL gcd(LL x,LL y){
	return !y?x:gcd(y,x%y);
}

void findprime(){
	memset(isprime,true,sizeof(isprime));
	for(LL i=2;i<=maxx;++i){
		if(isprime[i]){
			pri[++cnt]=i;
	//		cout<<pri[cnt]<<endl;
		}
		for(LL j=1;j<=cnt;++j){
			if(i*pri[j]>maxx) break;
			isprime[i*pri[j]]=0;
			if(i%pri[j]==0) break;
		}
	}
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	findprime();
	LL x,y,d;
	scanf("%lld%lld",&x,&y);
	d=gcd(x,y);
//	cout<<d<<endl;
	int ans=1;  
	for(LL i=2;i*i<=d;++i){
		if(d%i==0) ++ans;
		while(d%i==0) d/=i;
	}
	if(d>1) ans++;
	printf("%d\n",ans);
	return 0;
}


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

using namespace std;

int f(int n, int x) {
    int counter = 0;
    for (int i = 1; i <= n - 2; i++) {
        for (int j = i + 1; j <= n - 1; j++) {
            for (int k = j + 1; k <= n; k++) {
                if (i + j + k == x) counter++;
            }
        }
    }
    return counter;
}

int main() {
    int n, x;
    while (1) {
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        cout << f(n, x) << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long ans = 200000000010; 
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            int temp = max(to_string(i).length(),to_string(n/i).length());
            if(temp<ans){
                ans = temp;
            }
        }
    }
    cout  << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		long a = saori.saorihayami();
		long v = saori.saorihayami();
		long b = saori.saorihayami();
		long w = saori.saorihayami();
		long t = saori.saorihayami();
		if(a < b){
			if(a+v*t >= b+w*t){
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		} else {
			if(a-v*t <= b-w*t){
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

int main(){
  
  int n;
  cin >> n;
  
  ostringstream stream;
  stream << n;
  string str = stream.str();
  int sum=0;
  for(int i=0; i<str.size(); i++) sum+=(str[i]-48);
  if(n%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int N;
double dp[302][302][302];
double ex(int x1, int x2, int x3) {
    if (x1 < 0 || x2 < 0 || x3 < 0) {
        return 0.0;
    }
    else {
        if (dp[x1][x2][x3] != 0) {
            return dp[x1][x2][x3];
        }
        else if (x1 + x2 + x3 == 0){
            return 0.0;
        }
        else{
            dp[x1][x2][x3] = (ex(x1-1, x2, x3) * x1 
            + ex(x1+1, x2-1, x3) * x2 
            + ex(x1, x2+1, x3-1) * x3 + N)
            /(x1 + x2 + x3);
            return dp[x1][x2][x3];
        }
    } 
}

int main() {
    cin >> N;
    int A[N] = {}, Num[3] = {};
    for (int i = 0;i < N; i++) {
        cin >> A[i];
        Num[A[i] - 1] += 1;//Num[i-1]はiコの寿司を載せた皿の枚数
    }
    double res;
    res = ex(Num[0],Num[1],Num[2]);
    printf("%.12lf",res);
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 1;
  for (int i = 1; i < n; i++)
    if (s.at(i) != s.at(i - 1)) cnt++;
  cout << cnt << endl;
}

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

A = []
B = []
C = []

inf = 1*10**7
max_n = 110
G = [[inf] * max_n for i in range(max_n)]
for i in range(N):
    G[i][i] = 0


for i in range(M):
    a, b, c = map(int, input().split())
    A.append(a-1)
    B.append(b-1)
    C.append(c)
    G[A[i]][B[i]] = C[i]
    G[B[i]][A[i]] = C[i]

for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])

ans = 0
for i in range(M):
    if (G[A[i]][B[i]] < C[i]):
        ans += 1

# print(G)


print(ans)


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    using P = pair<int, int>;
    vector<P> v(n);
    rep(i, n){
        int a;
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(all(v));
    rep(i, n){
        cout << v[i].second+1 << endl;
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
string S;
//=============================
void input()
{
    cin>>S;
}

void solve()
{
    bool ans = true;

    int count = 0;
    for (int i = 0; i < S.size(); ++i){
        if (i == 0) {
            if (S[i] != 'A'){
                ans = false;
                break;
            }
        }
        else if (i >= 2 && i <= (S.size()-2)){
            if (S[i] == 'C') {
                count++;
            }
            if (i == S.size()-2) {
                if (count != 1){
                    ans = false;
                    break;
                }
            }
        }
        else {
            if (S[i] < 'a' || S[i] > 'z'){
                ans = false;
                break;
            }
        }
    }
    cout<<(ans ? "AC" : "WA") << endl;
}

//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 384
w,h,n=map(int,input().split())
ow=0
oh=0
for i in range(n):
  x,y,a=map(int,input().split())
  if a==1 and ow<x:
    ow=x
  if a==2 and w>x:
    w=x
  if a==3 and oh<y:
    oh=y
  if a==4 and h>y:
    h=y
if w>ow and h>oh:
  print((w-ow)*(h-oh))
else:
  print(0)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int max = 0;
    int now = 0;
    for(int i = 0;i<n;i++){
      now = 0;
      for(int j = i + 1;j<=n;j++){
        String ss = s.substring(j-1,j);
        if(ss.equals("A") || ss.equals("C") || ss.equals("G") || ss.equals("T")){
          now++;
          continue;
        }else{
          break;
        }
      }
      if(max < now){
        max = now;
      }
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,M,Q;
    cin>>N>>M>>Q;
    vector<int> A(Q),B(Q),C(Q),D(Q);
    for(int i=0;i<Q;i++)
	{
        cin>>A[i]>>B[i]>>C[i]>>D[i];
        A[i]--; 
		B[i]--;
    }
    vector< vector <int> > V[11];
    for(int i=1;i<=M;i++) 
	V[1].push_back({i});
    for(int i=1;i<N;i++) 
	for(auto& v : V[i])
	{
        int b=v.back();
        for(int a=b;a<=M;a++)
		{
            auto v2=v;
            v2.push_back(a);
            V[i+1].push_back(v2);
        }
    }
    int ans=0;
    for(auto& v : V[N])
	{
        int res=0;
        for(int i=0;i<Q;i++) 
		if(v[B[i]]-v[A[i]]==C[i]) 
		res+=D[i];
        ans=max(ans, res);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 16184
#include <stdio.h>
#define N 1000
#define INF 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, A[N][N];
void dijkstra();

int main(){
  int i, j, u, k, v, c;

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

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    for(j=0; j<k; j++){
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }


  /* printf("test\n"); */
  dijkstra();

  return 0;
}

void dijkstra(){
  int i, u, v, minc;
  int c[N], d[N];

  for(i=0; i<n; i++){
    c[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  c[0] = GRAY;

  while(1){
    minc = INF;
    u = -1;
    for(i=0; i<n; i++){
      if(c[i] != BLACK && d[i] < minc){
	minc = d[i];
	u = i;
      }
    }
    if(minc == INF) break; 
    c[u] = BLACK;
    for(v=0; v<n; v++){
      if(c[v] != BLACK && A[u][v] != INF){
	if(d[u] + A[u][v] < d[v]){
	  d[v] = d[u] + A[u][v];
	  c[v] = GRAY;
	}
      }
    }
  }
  for(i=0; i<n; i++){
    if(d[i] == INF) {
      printf("%d -1\n", i);
    } else printf("%d %d\n",i ,d[i]);
  }
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int N;
    double ans;
    cin >> N; 
    vector <double> v(N);
    REP(i, N) cin >> v.at(i);
    sort(ALL(v));
    reverse(ALL(v));
    REP(i, N) v.at(i) /= pow(2, i+1);
    v.at(N-1) *= 2;
    REP(i, N) ans += v.at(i);   
    cout << ans << endl;
}

Measured memory_bytes: 384
l, a, b, m = [int(i) for i in input().split()]

cd = []
for i in range(18):
    cd.append(max(0, (10 ** (i + 1) - 1 - a) // b + 1))
    if cd[-1] >= l:
        cd[-1] = l
        break

cd_sum = 0
cd_2 = []

for i in cd:
    cd_2.append(i-cd_sum)
    cd_sum += i-cd_sum

X = [0, a, 1]
B = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
for i in range(len(cd_2)):
    A = [[(10 ** (i + 1)), 0, 0], [1, 1, 0], [0, b, 1]]
    B = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

    n = cd_2[i]
    while n > 0:
        if n % 2 == 1:
            B = [[(B[0][0] * A[0][0] + B[0][1] * A[1][0] + B[0][2] * A[2][0]) % m,
                  (B[0][0] * A[0][1] + B[0][1] * A[1][1] + B[0][2] * A[2][1]) % m,
                  (B[0][0] * A[0][2] + B[0][1] * A[1][2] + B[0][2] * A[2][2]) % m],
                 [(B[1][0] * A[0][0] + B[1][1] * A[1][0] + B[1][2] * A[2][0]) % m,
                  (B[1][0] * A[0][1] + B[1][1] * A[1][1] + B[1][2] * A[2][1]) % m,
                  (B[1][0] * A[0][2] + B[1][1] * A[1][2] + B[1][2] * A[2][2]) % m],
                  [(B[2][0] * A[0][0] + B[2][1] * A[1][0] + B[2][2] * A[2][0]) % m,
                   (B[2][0] * A[0][1] + B[2][1] * A[1][1] + B[2][2] * A[2][1]) % m,
                   (B[2][0] * A[0][2] + B[2][1] * A[1][2] + B[2][2] * A[2][2]) % m]]

            n -= 1

        else:
            A = [[(A[0][0] * A[0][0] + A[0][1] * A[1][0] + A[0][2] * A[2][0]) % m,
                  (A[0][0] * A[0][1] + A[0][1] * A[1][1] + A[0][2] * A[2][1]) % m,
                  (A[0][0] * A[0][2] + A[0][1] * A[1][2] + A[0][2] * A[2][2]) % m],
                 [(A[1][0] * A[0][0] + A[1][1] * A[1][0] + A[1][2] * A[2][0]) % m,
                  (A[1][0] * A[0][1] + A[1][1] * A[1][1] + A[1][2] * A[2][1]) % m,
                  (A[1][0] * A[0][2] + A[1][1] * A[1][2] + A[1][2] * A[2][2]) % m],
                  [(A[2][0] * A[0][0] + A[2][1] * A[1][0] + A[2][2] * A[2][0]) % m,
                   (A[2][0] * A[0][1] + A[2][1] * A[1][1] + A[2][2] * A[2][1]) % m,
                   (A[2][0] * A[0][2] + A[2][1] * A[1][2] + A[2][2] * A[2][2]) % m]]
            n //= 2

    X[0] = (X[0] * B[0][0] + X[1] * B[1][0] + X[2] * B[2][0]) % m
    X[1] = (X[0] * B[0][1] + X[1] * B[1][1] + X[2] * B[2][1]) % m
    X[2] = (X[0] * B[0][2] + X[1] * B[1][2] + X[2] * B[2][2]) % m

print(X[0] % m)


Measured memory_bytes: 3448
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

ll mod_pow(ll x, ll n, ll mod){ // x ^ n % mod
    ll res = 1;
    while(n > 0){
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll K, n;
    cin >> K >> n;
    COMinit();

    ll ans[K*2+1] = {};

    srep(i,2,K+2){
        if(i % 2 == 1){
            rep(j,i/2+1){
                ll tmp = COM(i/2, j) * mod_pow(2,j,MOD) % MOD * COM((K-i+1+j)+(n-j)-1, (n-j)) % MOD;
                ans[i] = (ans[i] + tmp) % MOD;
            }
        }else{
            // i/2使わない
            rep(j,i/2){
                ll tmp = COM(i/2-1, j) * mod_pow(2,j,MOD) % MOD * COM((K-i+1+j)+(n-j)-1, (n-j)) % MOD;
                ans[i] = (ans[i] + tmp) % MOD;
            }
            // i/2使う
            rep(j,i/2){
                ll tmp = COM(i/2-1, j) * mod_pow(2,j,MOD) % MOD * COM((K-i+1+j)+(n-j-1)-1, (n-j-1)) % MOD;
                ans[i] = (ans[i] + tmp) % MOD;
            }
        }
    }

    srep(i,K+2,K*2+1){
        ans[i] = ans[(K+1)*2 - i];
    }
    srep(i,2,K*2+1){
        cout << ans[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 15572
#include <cstdio>
#define MAX 26
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];

void preorderTreeWalk(int u) {
  if ( u == NIL ) return;
  printf( " %d", u);
  preorderTreeWalk(T[u].left);
  preorderTreeWalk(T[u].right);
}

void inorderTreeWalk(int u) {
  if ( u == NIL ) return;
  inorderTreeWalk(T[u].left);
  printf(" %d", u);
  inorderTreeWalk(T[u].right);
}

void postorderTreeWalk(int u) {
  if ( u == NIL ) return;
  postorderTreeWalk(T[u].left);
  postorderTreeWalk(T[u].right);
  printf(" %d", u);
}

int main() {
  int n, v, l, r;
  int root = 0;

  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) T[i].parent = NIL;

  for ( int i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].left = l;
    T[v].right = r;
    if ( l != NIL ) T[l].parent = v;
    if ( r != NIL ) T[r].parent = v;
  }

  for ( int i = 0; i < n; i++ ) if ( T[i].parent == NIL ) root = i;

  printf("Preorder\n");
  preorderTreeWalk(root);
  printf("\n");

  printf("Inorder\n");
  inorderTreeWalk(root);
  printf("\n");

  printf("Postorder\n");
  postorderTreeWalk(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mod 1000000007
using namespace std;
double dp[3001][3001];
#define printP(x) cout<<fixed<<setprecision(10)<<x;

double getP(double arr[], int i, int x){
    if(dp[i][x] > -0.9) return dp[i][x];
    if(x==0) return 1;
    if(i==0) return 0;
    return dp[i][x]= arr[i-1]*getP(arr,i-1,x-1) + (1-arr[i-1])*getP(arr,i-1,x);
}

int main(){
    int n; cin>>n;
    double arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp,-1,sizeof(dp));
    
    printP(getP(arr,n,(n+1)/2));
}


Measured memory_bytes: 74288
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=1e5+10;

char a[maxn],b[maxn];
int n,m=0;

int main()
{
	scanf("%s",a+1);
	n=strlen(a+1);
	for(int i=1;i<=n;i++)
		if (a[i]!='x') b[++m]=a[i];
	for(int i=1;i<=m/2;i++)
		if (b[i]!=b[m+1-i])
		{
			printf("-1\n");
			return 0;
		}
	if (m==0)
	{
		printf("0\n");
		return 0;
	}
	
	int l=0,r=n+1,ans=0;
	while(l<r)
	{
		int cl=0;l++;
		while(a[l]=='x') 
			{cl++;l++;}
		int cr=0;r--;
		while(a[r]=='x') 
			{cr++;r--;}
		ans+=abs(cl-cr);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {
	int d, d1, d10, m;
	cin >> m >> d;
	int ans = 0;

	for (int i = 10; i <= d; i++) {
		d1 = i % 10;
		d10 = i / 10;

		if (d1 * d10 <= m && d1 > 1 && d10 > 1) {
			ans++;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int dp[1000001];
int vis[100001];
int a[100001];
int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++) scanf("%d", &a[i]),vis[a[i]] = 1;
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        if(vis[i]) continue;
        dp[i] = (dp[i] + dp[i-1])%mod;
        if(i-2 >= 0) dp[i] = (dp[i] + dp[i-2])%mod;
    }
    printf("%d\n", dp[n]);
}

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

int main() {
	int n;
	cin >> n;
	int a[100][2];
	for (int i = 0; i < n; i++) {
		cin >> a[i][0] >> a[i][1];
	}
	//ループの終了条件に注意
	for (int i = 0; i < n-2; i++) {
		if (a[i][0] == a[i][1] && a[i + 1][0] == a[i + 1][1] && a[i + 2][0] == a[i + 2][1]) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,m;
  while(cin>>n>>k>>m,n+k+m){
    vi A(n);
    for(int i=0;i<n;i++)
      A[i] = i+1;
    ll now = m-1;
    //cout<<*(A.begin()+now)<<endl;
    A.erase(A.begin()+now);
    for(int i=0;i<n-2;i++){
      now+=k-1;now%=A.size();
      //cout<<*(A.begin()+now)<<endl;
      A.erase(A.begin()+now);
    }
    cout<<A[0]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3184
#include<stdio.h>
#include<map>
#define maxn 200005

using namespace std;
map<int,int>f;
long long ans ;
int main(){
	int n, i, j, m;
	int num[maxn];
	scanf("%d",&n);
	for(i = 1; i <= n; i++){
		scanf("%d",&num[i]);
	}
	for(i = 1; i <=n; i++){
		ans+=f[i-num[i]];
		f[i+num[i]]++;
		
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int cnt=0;
	bool f=true;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		if(str=="A")cnt++;
		else cnt--;
		if(cnt<0)f=false;
	}
	if(f && cnt==0)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}	

Measured memory_bytes: 3156
import java.util.Scanner;

public class Main
{

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

        int n = scan.nextInt();
        int g = 0;
        int s = 1000000;

        while (n != 0) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = scan.nextInt();

            }
            for (int b = 0; b < n; b++) {
                for (int c = b + 1; c < n; c++) {
                    if (a[b] > a[c]) {
                        g = a[b] - a[c];
                    } else {
                        g = a[c] - a[b];
                    }
                    if (s > g) {
                        s = g;
                    }
                }
            }
            System.out.println(s);
            s = 1000000;
            g = 0;
            n = scan.nextInt();
        }
    }
}



Measured memory_bytes: 46588
#include <iostream>
using namespace std;
int getMax(int a[100], int N) {
	int Max = 0;
	int Max_index = -1;
	for (int i = 0; i < N; i++) {
		if (Max < a[i]) {
			Max = a[i];
			Max_index = i;
		}
	}
	a[Max_index] = 0;
	return Max;
}
int main() {
	int N;
	int a[100] = { 0 };
	cin >> N;
	int tmp_a;
	for (int i = 0; i < N; i++) {
		cin >> tmp_a;
		a[i] = tmp_a;
	}
	int sum_A = 0, sum_B = 0;
	for (int i = 0; i < N; i++) {
		if ((i &1) == 0) {
			sum_A += getMax(a, N);
		}
		else {
			sum_B += getMax(a, N);
		}
	}
	cout << sum_A - sum_B << endl;
} 


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

int n;
long long dp[39];

long long rec(int n) {
  if (dp[n] != 0) return dp[n];
  return dp[n] = rec(n - 1) + rec(n - 2) + rec(n - 3);
}

int main() {
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    for (int i = 0; i <= n; i++) dp[i] = 0;
    dp[0] = 1, dp[1] = 1, dp[2] = 2, dp[3] = 4;
    
    long long ans = rec(n) / 3650;
    if (rec(n) % 3650 != 0) ans++;
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u) a--;
  if (t == u) b--;
  cout << a << " " << b << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    n = int(input())
    d, x = map(int, input().split())
    ans = 0
    factors = { dayNum:0 for dayNum in range(1, d+1) }
    for tmp in range(n):
        a = int(input())
        factors[1] += 1
        num = 1
        while num*a+1 <= d:
            factors[num*a+1] += 1
            num += 1
    for tmp in range(1, d+1):
        ans += factors[tmp]
    else:
        ans += x
        print(ans)

Measured memory_bytes: 3064
object Main extends App {
    val i = scala.io.StdIn.readLine().toInt

    if (i == 1){
      println("Hello World")
    } else {
      val a = scala.io.StdIn.readLine().toInt
      val b = scala.io.StdIn.readLine().toInt
      println(a+b)
    }
}

Measured memory_bytes: 25296
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<ll> suf(n+2);
    rep(i, n+1) cin >> a[i];

    if (n == 0) {
        if (a[0] == 1) {
            cout << 1 << endl;
            return 0;
        }
        else {
            cout << -1 << endl;
            return 0;
        }
    }
    if (a[0] > 0) {
        cout << -1 << endl;
        return 0;
    }

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

    ll x = 1;
    ll ans = 1;

    for (int i = 1; i <= n; ++i) {
        if (x * 2 < a[i]) {
            cout << -1 << endl;
            return 0;
        }
        ll d = min(x*2, suf[i]);
        ans += d;
        x = d - a[i];
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 4512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		String S = null;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			S = br.readLine();
			br.close();
		} catch (IOException e) {

		}
		int s = Integer.parseInt(S);
		int s2 = s % 60;
		int h = s / 3600;
		int m = s % 3600 / 60;
		System.out.println(h + ":" + m + ":" + s2);
	}
}



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

int main(){
    unordered_map<char, int> un_map;
    string str;
    cin >> str;
    for(auto it=str.begin(); it!=str.end(); ++it){
            un_map[*it]+=1;
    }
    for(auto itr=un_map.begin(); itr!=un_map.end(); ++itr){
        if(itr->second%2!=0){
            cout << "No" << endl;
            exit(0);
        } 
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define rep(i,x) for(int (i)=1;(i)<=(x);(i)++)
#define repp(i,x,y) for(int (i)=(x);(i)<=(y);(i)++)
#define forn(i,x) for(int (i)=0;(i)<(x);(i)++)
#define foreach(i,x) for(auto (i):(x))
using namespace std;
typedef pair<int,int>pii;
int main(){
	char ch;
	int res=0;
	while(cin>>ch)res+=(ch=='2');
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(all(vec),greater<int>());
    int ans=0;
    rep(i,k) ans += vec[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>  
    #include <cstdio>  
    #include <vector>  
    #include <algorithm>  
    #include <cstring>  
    #include <queue>  
      
    using namespace std;  
    const int MAXN=1e5+50;  
    const long long INF=1e18;  
    int n;  
    int k,p;  
    long long dis[MAXN];  
    int vis[MAXN];  
    struct Edge  
    {  
        int from;  
        int to;  
        int cost;  
        Edge(int a,int b,int c)  
        {  
            from=a;  
            to=b;  
            cost=c;  
        }  
    };  
    vector<Edge> edges;  
    vector<int> G[MAXN];  
      
    void Init()  
    {  
        for(int i=0; i<=n; i++)  
            G[i].clear();  
        edges.clear();  
    }  
    struct Heap  
    {  
        int d,u;  
        Heap(int a,int b)  
        {  
            d=a,u=b;  
        }  
        bool operator<(Heap h)const  
        {  
            return d>h.d;  
        }  
    };  
    void Dijkstra(int s)  
    {  
        priority_queue<Heap> p;  
        p.push(Heap(0,s));  
        for(int i=0; i<=n; i++) dis[i]=INF;  
        dis[s]=0;  
        memset(vis,0,sizeof(vis));  
        while(!p.empty())  
        {  
            Heap h=p.top();  
            p.pop();  
            int  u=h.u;  
            if(vis[u]) continue;  
            for(int i=0; i<G[u].size(); i++)  
            {  
                Edge &e=edges[G[u][i]];  
                if(vis[e.to]) continue;  
                if(dis[e.to]>dis[u]+e.cost)  
                {  
                    dis[e.to]=dis[u]+e.cost;  
                    p.push(Heap(dis[e.to],e.to));  
                }  
            }  
        }  
    }  
    int main()  
    {  
        scanf("%d",&n);  
        Init();  
        for(int i=0; i<n-1; i++)  
        {  
            int x,y,z;  
            scanf("%d%d%d",&x,&y,&z);  
            edges.push_back(Edge(x,y,z));  
            G[x].push_back(2*i);//无向边，两个方向加  
            edges.push_back(Edge(y,x,z));  
            G[y].push_back(2*i+1);  
        }  
        scanf("%d%d",&p,&k);  
        Dijkstra(k);  
        //for(int i=0;i<=n;i++)  
        //    cout<<dis[i]<<" ";  
        //  cout<<endl;  
        for(int i=0; i<p; i++)  
        {  
            int x,y;  
            scanf("%d%d",&x,&y);  
            cout<<dis[x]+dis[y]<<endl;  
        }  
        return 0;  
    }  

Measured memory_bytes: 12464
#include <bits/stdc++.h>
using namespace std;
#define MOD (1000000007)

int64_t C[2015][2015];

void pascal() {
	// パスカルの三角形。 2010まで埋める
	C[0][0] = 1;
	for (int i=1; i<2010; i++) {
		C[i][0] = 1;
		for (int j=1; j<i; j++) {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]) % MOD;
		}
		C[i][i] = 1;
	}
}

int main() {
	pascal();

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

	int64_t res;
	for (int i=1; i<=K; i++){
		// Kの塊がi個になるパターン
		// N-Kの隙間(+1)にKの塊を差し込む
		// C(N-K+1, i) = (N-K+1)!/(i!(N-K+1-i)!)
		// Kをi個の塊に分割したそれぞれの個数パターン
		// Kの隙間(-1)に区切りを差し込む
		// C(K-1, i-1) = (K-1)!/((i-1)!(K-i)!)
		res = C[N-K+1][i] * C[K-1][i-1] % MOD;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 30464
main = getLine >>= print . solve . map read . words

solve :: [Int] -> Int
solve [a, b, x] = (b' - a') `div` x + 1
    where
        a'
            | m == 0 = a
            | otherwise = x * (r + 1)
            where
                (r, m) = a `divMod` x
        b' = x * (b `div` x)


Measured memory_bytes: 508
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;


int main(){

    int ans = 10000;
    int m[5];
    for(int i = 0; i < 5; i++)cin >> m[i];
    for(int a = 0; a < 5; a++){
        for(int b = 0; b < 5; b++){
            if(b == a)continue;
            for(int c = 0; c < 5; c++){
                if(c == a)continue;
                if(c == b)continue;
                for(int d = 0; d < 5; d++){
                    if(d == a)continue;
                    if(d == b)continue;
                    if(d == c)continue;
                    for(int e = 0; e < 5; e++){
                        if(e == a)continue;
                        if(e == b)continue;
                        if(e == c)continue;
                        if(e == d)continue;
                        int tmp = 0;
                        tmp += m[a];
                        if(tmp % 10 != 0)tmp = 10 * (1 + tmp / 10);
                        tmp += m[b];
                        if(tmp % 10 != 0)tmp = 10 * (1 + tmp / 10);
                        tmp += m[c];
                        if(tmp % 10 != 0)tmp = 10 * (1 + tmp / 10);
                        tmp += m[d];
                        if(tmp % 10 != 0)tmp = 10 * (1 + tmp / 10);
                        tmp += m[e];
                        ans = min(ans, tmp);
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int n; cin >> n;
	Rep(i, 10) {
		if (n % i == 0 && n / i < 10) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
x,y=map(int,input().split())

if (2*x-y)%3!=0 or (2*x-y)<0:
  print(0)
  exit()
if (2*y-x)%3!=0 or (2*y-x)<0:
  print(0)
  exit()
p=int((2*x-y)/3)
q=int((2*y-x)/3)
M=p+q+2
Mod=10**9+7

fac=[0]*M
finv=[0]*M
inv=[0]*M

def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return (fac[n]*(finv[k]*finv[n-k]%Mod)%Mod)%Mod

COMinit()
print(COM(p+q,p))

Measured memory_bytes: 84084
import math

a,b,x = map(int, input().split())

v = a * a * b

if 2 * x == v:
    print(math.degrees(math.atan2(a,b)))

elif 2 * x > v:
    print(math.degrees(math.atan2(2 * (v - x), a ** 3)))

else:
    w = v - x
    print(math.degrees(math.atan2(a * b * b, 2 * x)))

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

const int INF = 1e9+1;
template <typename T>
void merge(vector<T> &a, int left, int mid, int right, int &num){
  int n1 = mid - left;
  int n2 = right - mid;
  vector<T> L(n1+1), R(n2+1);
  for(int i=0; i<n1; i++) L[i] = a[left+i];
  for(int i=0; i<n2; i++) R[i] = a[mid+i];
  L[n1] = INF;  R[n2] = INF;
  int l_id = 0, r_id = 0;
  for(int i=left; i<right; i++){
    if(L[l_id] <= R[r_id]){ a[i] = L[l_id]; l_id++;}
    else{ a[i] = R[r_id]; r_id++;}
    num++;
  }
  return;
}
template <typename T>
void mergeSort(vector<T> &a, int left, int right, int &num){
  //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=ja
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(a, left, mid, num);
    mergeSort(a, mid, right, num);
    merge(a, left, mid, right, num);
  }
  return;
}

template <typename T>
void CountingSort(vector<T> a){
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_A&lang=ja
  //要素0以上を想定したソート
  int n = (int)a.size();
  int MAX = 0;
  for(int i=0; i<n; i++) MAX = max(MAX, a[i]);

  vector<T> cnt(MAX+1, 0);
  for(int i=0; i<n; i++) cnt[a[i]]++;// a[i]の出現数を記録する
  for(int i=0; i<MAX; i++) cnt[i+1] = cnt[i+1] + cnt[i];// cnt[i]にi以下の数字の出現数を記録する

  vector<T> res(n);
  for(int i=n-1; i>=0; i--){
    res[cnt[a[i]]-1] = a[i];//カウントされたら1になるので-1して0スタートにする
    cnt[a[i]]--;
  }
  print_vec(res);
  return;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  // int num = 0;
  // mergeSort(a, 0, n, num);
  // print_vec(a);
  // cout << num << endl;
  CountingSort(a);

  return 0;
}





Measured memory_bytes: 26248
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define E 1e-6
#define INF 0x3f3f3f3f
void open(){freopen("data.txt","r",stdin);}
void out(){freopen("out.txt","w",stdout);}
const int maxn = 101010;
const int MOD = 1e9 + 7;

bool vis[10];
int ans=0x3f3f3f3f;
int n,m,r;
int R[10];
int d[205][205];
void dfs(int x,int cur)
{
    bool flag = 1;
    for(int i=1;i<=r;i++) if(!vis[R[i]]) flag=0 ;
    if(flag&&cur<ans){
        ans=cur;
        return;
    }

    for(int i=1;i<=r;i++){
        if(vis[R[i]]) continue;
        if(d[x][R[i]]>=INF) continue;
        vis[R[i]]=true;
        dfs(R[i],cur+d[x][R[i]]);
        vis[R[i]]=false;
    }
    return ;
}

int main()
{
    scanf("%d%d%d",&n,&m,&r);
    rep(i,1,r+1) scanf("%d",&R[i]);

    for(int i=0;i<205;i++) for(int j=0;j<205;j++) {
        if(i==j) d[i][j]=0;
        else d[i][j]=INF;
    }

    rep(i,0,m){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        d[u][v]=w;
        d[v][u]=w;
    }

    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            printf("%d to %d %d\n",i,j,d[i][j]);
        }
        cout<<endl;
    }*/

    memset(vis,0,sizeof(vis));
    for(int i=1;i<=r;i++){
        vis[R[i]]=true;
        dfs(R[i],0);
        vis[R[i]]=false;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll power(ll x, ll y, ll p)
{ll res = 1;x = x % p;while (y > 0){if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
ll modInverse(ll n, ll p)
{return power(n, p-2, p);}
ll nCr(ll n, ll r, ll p)
{if (r==0) return 1;ll fac[n+1];fac[0] = 1;for(ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p;return (fac[n]*modInverse(fac[r], p) % p * modInverse(fac[n-r], p) % p) % p;}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	ll i, j, k, n, m, t, p, temp, flag, x, y, z, count, a, b, c, d, sum, ans;
	char al;
	cin  >> al;
	if(0<=al-'A' && al-'A'<=26)
		cout << "A\n";
	else
		cout << "a\n";
	return 0;
}



Measured memory_bytes: 3636
#![allow(unused_mut)]

use std::io::{self, BufWriter, Write};
use std::error::Error;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() -> Result<(), Box<dyn Error>> {
    let sout = io::stdout();
    let mut o = BufWriter::new(sout.lock());
  
    input! {
        // input
        n : usize,
        k : usize,
        a : [i64; n],
    }

    // operate
    let mut b = Vec::new();
    for i in 0 .. n - k {
        b.push(if a[i] < a[i + k] {"Yes"} else {"No"});
    }

    for v in b {
        let line = format!("{}\n", v);
        o.write(line.as_bytes())?;
    }

    // let line = format!("\n");
    // o.write(line.as_bytes())?;
    Ok(())
  }


Measured memory_bytes: 8972
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL f(LL b, LL n){
  if(n < b) return n;
  LL N = n;
  LL res = 0;
  while(N>0){
    res += N%b;
    N /= b;
  }

  return res;
}

int main(void){
  LL n, s;

  cin >> n;
  cin >> s;

  if(s > n){
    cout << -1 << endl;
    return 0;
  }

  if(s == n){
    cout << n+1 << endl;
    return 0;
  }

  for(LL b=2;b*b<=n;b++){
    if(s == f(b, n)){
      cout << b << endl;
      return 0;
    }
  }

  LL ans = n+1;

  for(LL p=1;p*p<n;p++){
    LL b = (n-s)/p+1;
    if(b == 1) continue;
    if(s == f(b, n)) ans = min(ans, b);
  }

  if(ans != n+1){
    cout << ans << endl;
    return 0;
  }

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


Measured memory_bytes: 256
M=998244353
N,*A=open(0)
d=[0]*90001
d[0]=1
e=[0]*90001
e[0]=1
z=1
s=0
for a in A:
	i=s;a=int(a);s+=a;z*=3
	while i+1:d[i+a]+=d[i]%M;d[i]*=2;e[i+a]+=e[i]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
print([(z+e[s//2]*3)%M,z][s%2])

Measured memory_bytes: 142032
base = input().split()
a = int(base[0])
b = int(base[1])
if a>b:
    for i in range(a):
        print(b,end = "")
elif a==b:
    for i in range(a):
        print(b,end = "")
else:
    for i in range(b):
        print(a,end = "")

Measured memory_bytes: 3060
while True:
    try:
        __, m = (lambda row: [int(row[i]) for i in range(len(row))])(input().split())
        price = sorted(list(map(int, input().split())), reverse=True)
        print(str(sum([price[i] for i in range(len(price)) if (i+1)%m != 0])))
    except:
        break


Measured memory_bytes: 5724
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	int L;
	cin >> L;
	double d = (double)L / 3.0;
	cout << d * d * d << endl;
	return 0;
}

Measured memory_bytes: 256