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


typedef struct Dice {
	int t, b, n, w, s, e;
}Dice;

Dice d = { 1,6,5,4,2,3 };
int n,sum;
string s;

int ini()
{
	d = { 1,6,5,4,2,3 };
	sum = 1;
	return 0;
}
int north() {
	int r = d.t;
	d.t = d.s;
	d.s = d.b;
	d.b = d.n;
	d.n = r;
	return 0;
}
int east() {
	int r = d.t;
	d.t = d.w;
	d.w = d.b;
	d.b = d.e;
	d.e = r;
	return 0;
}
int west() {
	int r = d.t;
	d.t = d.e;
	d.e = d.b;
	d.b = d.w;
	d.w = r;
	return 0;
}
int south() {
	int r = d.t;
	d.t = d.n;
	d.n = d.b;
	d.b = d.s;
	d.s = r;
	return 0;
}
int right() {
	int r = d.n;
	d.n = d.w;
	d.w = d.s;
	d.s = d.e;
	d.e = r;
	return 0;
}
int left() {
	int r = d.n;
	d.n = d.e;
	d.e = d.s;
	d.s = d.w;
	d.w = r;
	return 0;
}

int main(){
	while (cin >> n && n > 0) {
		ini();
		for (int i = 0; i < n; i++) {
			cin >> s;
			if (s == "North")
				north();
			else if (s == "West")
				west();
			else if (s == "South")
				south();
			else if (s == "East")
				east();
			else if (s == "Right")
				right();
			else if (s == "Left")
				left();
			sum += d.t;
		}
		cout << sum << endl;
	}

	return 0;
}

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

int main() {
  int m,k;
  cin>>m>>k;
  if(m==0){
    if(k==0){
      cout<<0<<endl;
      cout<<0<<endl;
    }
    else{
      cout<<-1<<endl;
    }
  }
  else if(m==1){
    if(k==0){
      cout<<0<<endl;
      cout<<0<<endl;
      cout<<1<<endl;
      cout<<1<<endl;
    }
    else{
      cout<<-1<<endl;
    }
  }
  else{
    if(k<(1<<m)){
      rep(i,0,(1<<m)){
        if(i!=k){
          cout<<i<<endl;
        }
      }
      cout<<k<<endl;
      for(int i=(1<<m)-1;i>=0;i--){
        if(i!=k){
          cout<<i<<endl;
        }
      }
      cout<<k<<endl;
    }
    else{
      cout<<-1<<endl;
    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
#define ll long long
using namespace std;

ll A[100010], sum[100010], mod=1000000007;

ll modpow(ll a, ll b, ll m){
    ll res=1, p=0, now=a;
    b %= (m-1);
    for(int i=0; b>p; ++i){
        if(b&((ll) 1<<i)){
            res=(res*now)%m;
            p |= ((ll) 1<<i);
        }
        now=(now*now)%mod;
    }
    return res;
}
ll modinv(ll a, ll m){
    return modpow(a, m-2, m);
}
ll moddiv(ll a, ll b, ll m){
    return (a*modinv(b, m))%m;
}

int main() {
	ll N;
	cin >> N;
	for(ll i=0; i<N; ++i) cin >> A[i];
	sum[0]=0;
	for(ll i=0; i<N; ++i) sum[i+1]=(sum[i]+A[i])%mod;
	ll frac=1, ans=0;
	for(ll i=1; i<=N; ++i) frac=(frac*i)%mod;
	ll now=0;
	for(ll i=1; i<=N-2; ++i){
		now=(now+mod+sum[N-i]-sum[i])%mod;
		ans=(ans+(now*moddiv(frac, ((i+2)*(i+1)/2)%mod, mod))%mod)%mod;
	}
	ans=(ans+(sum[N]*frac)%mod)%mod;
	for(ll i=1; i<N; ++i){
		ans=(ans+(((sum[i]+sum[N]-sum[N-i]+mod)%mod)*moddiv(frac, i+1, mod))%mod)%mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import numpy as np

n,wmax = map(int, input().split())

w = [0] * n
v = [0] * n

for i in range(n):
  w[i], v[i] = map(int, input().split())

dp = np.zeros((n+1, wmax+1))

for i in range(n):
  dp[i+1, :w[i]] = dp[i, :w[i]]
  dp[i+1, w[i]:] = np.maximum(dp[i, w[i]:], dp[i, :wmax-w[i]+1] + v[i])

print(int(dp.max()))

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

using namespace std;

int main(){
    int n;
    int ans = 0;
    int h_max = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        if(h_max<=tmp){
            h_max = tmp;
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(),A.end());

    if(K >= N) {
        cout << 0 << endl;
        return 0;
    }

    for(int i=0; i<K; i++) {
        A.pop_back();
    }
    ll sum = 0;
    for(int i=0; i<A.size(); i++) {
        sum += A[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 4816
#include<stdio.h>
int main(){
	int i, x[52]={}, n, y, z=1;
	char m;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf(" %c %d", &m, &y);
		if(m=='S'){
			x[y-1]=y;
		}else if(m=='H'){
			x[y+12]=y;
		}else if(m=='C'){
			x[y+25]=y;
		}else if(m=='D'){
			x[y+38]=y;
		}
	}
	for(i=0;i<52;i++){
		if(x[i]!=z && i <= 12){
			printf("S %d\n", i+1);
		}else if(x[i]!=z && i <= 25){
			printf("H %d\n", i-12);
		}else if(x[i]!=z && i <= 38){
			printf("C %d\n", i-25);
		}else if(x[i]!=z && i <= 51){
			printf("D %d\n", i-38);
		}
		z++;
		if(z==14){
			z=1;
		}
	}
}
		
	


Measured memory_bytes: 2044
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N);
	for (int i = 0;i < N;i++)
		cin >> a[i];
	UnionFind uf(N);
	for (int i = 0;i < M;i++) {
		ll x, y;
		cin >> x >> y;
		uf.unionSet(x, y);
	}
	vector<P> v;
	set<ll> rt;
	vector<P> top(N);
	for (int i = 0;i < N;i++) {
		v.push_back(P(a[i], i));
		rt.insert(uf.root(i));
		if (top[uf.root(i)] == P(0, 0))
			top[uf.root(i)] = P(a[i], i);
		else
			top[uf.root(i)] = min(top[uf.root(i)], P(a[i], i));
	}
	ll need = ((ll)rt.size() - 1);
	sort(v.begin(), v.end());
	ll ans = 0;
	ll cnt = 0;
	vector<ll> used(N);
	vector<int> alive(N, 1);


	for (int i = 0;i < N;i++) {
		if (top[i] == P(0, 0))
			continue;
		ans += top[i].first;
		cnt++;
		used[top[i].second]++;
		alive[top[i].second] = false;
	}

	for (int i = 0;i < N;i++) {
		if (cnt == need*2)
			break;
		ll cost, now;
		tie(cost, now) = v[i];
		if (!alive[now])
			continue;
		ll team = uf.root(now);
		if (used[team] >= need)
			continue;
		ans += cost;
		cnt++;
		used[team]++;
		uf.unionSet(i, team);
	}
	if (cnt < need * 2)
		cout << "Impossible" << endl;
	else if (need == 0)
		cout << 0 << endl;
	else
		cout << ans << endl;
	return 0;
}
/*
5 2
1 1 1 1 100
0 1
2 3

*/

Measured memory_bytes: 10352
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e;
  cin >> a >> b;
  if (4*a<b) {
    cout << "No";
  }else if (2*a>b) {
    cout << "No";
  }else if (b%2!=0){
    cout << "No";
  }else{
    cout << "Yes";
  }
  return 0;
}

Measured memory_bytes: 3568
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

int main()
{
  int n;
  scanf("%d", &n);
  vector<int> data(n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &data[i]);
  }
  std::sort(data.begin(), data.end());
  printf("%d\n", data.back() - data.front());
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
unsigned long long ans=0,l1[51],l2[51],n,k;
void dfs(int j){
	if(j==0){
		k--;
		ans++;
		return;
	}
	k--;
	if(k==0){
		return;
	}
	if(l1[j-1]<=k){
		k-=l1[j-1];
		ans+=l2[j-1];
	}else{
		dfs(j-1);
		return;
	}
	if(k>=1){
		k--;
		ans++;
	}
	if(k==0){
		return;
	}
	if(l1[j-1]<=k){
		k-=l1[j-1];
		ans+=l2[j-1];
	}else{
		dfs(j-1);
		return;
	}
	k--;
}
int main(){
//	freopen("c://a.out","w",stdout);
//	string ham[20];
//	ham[0]="P";
//	for(int i=1;i<=10;i++){
//		ham[i]="B"+ham[i-1]+"P"+ham[i-1]+"B";
//		cout<<ham[i]<<endl<<endl;
//	}
	cin>>n>>k;
	l1[0]=1;
	l2[0]=1;
	for(int i=1;i<=n;i++){
		l1[i]=l1[i-1]*2+3;
		l2[i]=l2[i-1]*2+1;
	}
	dfs(n);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
ll M=1e9+7;
int quick_pow(int x,int p){
    int a=1,po=x;
    while(p){
        if(p&1)  a=1ll*a*po%M;
        po=1ll*po*po%M;p>>=1;
    }
    return a;
}
//Start from Here
int main(){
    string S;
    cin>>S;
    rep(i, S.size()){
        cout<<"x";
    }
    cout<<endl;
}

Measured memory_bytes: 256
//CODING ME ACCHHA KARNEKA HAI TERKO TO BAS PRACTICE KARTE REH
#include <bits/stdc++.h>
#define pragma
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define aisort sort(a,a+n)
#define adsort sort(a,a+n,greater<ll>())
#define PI 2 * acos(0)

typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef set<ll> Set;

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;

//MODULO OPEARTIONS
    inline ll add(ll a, ll b) { return (mod + a + b) % mod; }
    inline ll sub(ll a, ll b) { return (a - b + mod) % mod; }
    inline ll mul(ll a, ll b) { return (1ll * a * b) % mod; }

//POWER
    ll fastpow(ll x,ll y)
    {ll res = 1;x = x % mod;while (y > 0){ if (y & 1)res = (res * x) % mod; y = y >> 1 ; x = (x * x) % mod; } return res;}

//MODULAR INVERSE
    ll inv(ll x){ return fastpow(x , mod - 2);}
    
//PRIME
    bool isPrime(ll n) { if (n <= 1)  return false; if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false; for (int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,sum=0;
    cin>>n;
    ll res=n/500;
    sum+=(res*1000);
    n-=(res*500);
    res=n/5;
    sum+=(res*5);
    cout<<sum;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

int dp[1002][1002];

int main(){
	int n;
	cin >> n;
	int x, y;
	string X, Y;
	r(k, n){
		cin >> X >> Y;
		x = X.size();
		y = Y.size();
		X = ' ' + X;
		Y = ' ' + Y;

		r(i, x+1)
			r(j, y+1)
				dp[i][j] = 0;

		for (int i = 1; i <= x; i++) {
			for (int j = 1; j <= y; j++) {
				if (X[i] == Y[j]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				} else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}

		cout << dp[x][y] << endl;
	}
	return 0;
}



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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll U = 0;
    rep(i, N) U ^= A[i];

    int cnt = 0;
    for (int i = 60; i >= 0; --i) {
        if (U >> i & 1) continue;

        bool find = false;
        for (int j = cnt; j < N; j++) {
            if (A[j] >> i & 1) {
                swap(A[cnt], A[j]);
                cnt++;
                find = true;
                break;
            }
        }

        if (find) {
            rep(j, N) {
                if (j == cnt - 1) continue;
                if (A[j] >> i & 1) A[j] ^= A[cnt - 1];
            }
        }
    }

    ll ans = 0, res = 0;
    rep(i, N - 1) {
        res ^= A[i];
        ans = max(ans, res + (U ^ res));
    }

    cout << ans << endl;
}

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

// ABC121A - White Cells
// https://atcoder.jp/contests/abc121/tasks/abc121_a
void ABC121A() {
	int H, W;
	cin >> H >> W;

	int h, w;
	cin >> h >> w;

	cout << H * W - (W * h + H * w - h * w);

}


int main() {
	ABC121A();

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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


		int d = sc.nextInt();

		switch (d) {
		case 25:
			System.out.println("Christmas");
			break;

		case 24:
			System.out.println("Christmas Eve");
			break;

		case 23:
			System.out.println("Christmas Eve Eve");
			break;

		case 22:
			System.out.println("Christmas Eve Eve Eve");
			break;

		default:
			break;
		}

		sc.close();
	}

}


Measured memory_bytes: 21844
from itertools import permutations as perm

n = int(input())
l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append([x, y])

sm = 0
cnt = 0

permm = list(range(n))
for p in perm(permm):
    for i, j in zip(p, p[1:]):
        x1, y1 = l[i]
        x2, y2 = l[j]
        sm += ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
    cnt += 1

print(sm / cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int H,W;
  char a;
  cin>>H>>W;
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      if(i==0||i==H+1||j==0||j==W+1)cout<<"#";
      else{
        cin>>a;
        cout<<a;
      }
    }
    cout<<endl;
  }
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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 (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int H,W,D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    rep(i, H) rep(j, W) cin >> A[i][j];

    vector<int> x(H * W + 1), y(H * W + 1);
    rep(i,H) rep(j,W){
        x[A[i][j]] = j;
        y[A[i][j]] = i;
    }

    vector<ll> d(H * W + 1); // d[i] : iに移動するまでにかかるコスト
    for(int i=1;i<=H*W;i++){
        if (i < D) d[i] = 0;
        else{
            int cx = x[i];
            int cy = y[i];
            int px = x[i-D];
            int py = y[i - D];
            d[i] = d[i - D] + abs(cx - px) + abs(cy - py);
        }
    }

    int Q;
    cin >> Q;
    rep(q,Q){
        int L,R;
        cin >> L >> R;

        cout << d[R] - d[L] << endl;
    }
}


Measured memory_bytes: 5108
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	inputList, _ := toIntArray(splitInput(scanner, " "))
	a := inputList[0]
	inputList, _ = toIntArray(splitInput(scanner, " "))
	b := inputList[0]

	var ans int
	if a == 1 {
		if b == 2 {
			ans = 3
		} else {
			ans = 2
		}
	} else if a == 2 {
		if b == 1 {
			ans = 3
		} else {
			ans = 1
		}
	} else {
		if b == 1 {
			ans = 2
		} else {
			ans = 1
		}
	}

	fmt.Println(ans)
}

func splitInput(scanner *bufio.Scanner, sep string) []string {
	scanner.Scan()
	return strings.Split(scanner.Text(), sep)
}

func toIntArray(str []string) ([]int, error) {
	length := len(str)
	resVal := make([]int, length)
	var err error
	for i := 0; i < length; i++ {
		resVal[i], err = strconv.Atoi(str[i])
		if err != nil {
			return nil, err
		}
	}
	return resVal, nil
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#define MOD 1000000007
#define forn(a, n) for(int a = 0; a<(int) (n); ++a)
#define dforn(a, n) for(int a = (n)-1; a>=0; --a)
#define forall(a, all) for(__typeof(all.begin()) a = all.begin(); a != all.end(); ++a)
#define EPS 0.000000000001
typedef long long tint;
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<tint> c(n), s(n), f(n);
	forn(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	forn(i,n) {
		tint t = 0;
		forn(j, n-i-1) {
			t = max(t, s[i+j]);
			t = f[i+j] * ((t+f[i+j]-1)/f[i+j]);
			t += c[i+j];
		}
		cout << t << endl;
	} 
	
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();

			int[][] A = new int[n][m];
			int[][] B = new int[m][l];
			long[][] C = new long[n][l];

			for(int i=0;i<n;i++) {
				for(int j=0;j<m;j++) {
					A[i][j] = sc.nextInt();
				}
			}
			for(int i=0;i<m;i++) {
				for(int j=0;j<l;j++) {
					B[i][j] = sc.nextInt();
				}
			}

			for(int i=0;i<n;i++) {
				for(int j=0;j<l;j++) {
					for(int k=0;k<m;k++) {
						C[i][j] += (long)A[i][k] * B[k][j];
					}
				}
			}

			for(int i=0;i<n;i++) {
				for(int j=0;j<l;j++) {
					System.out.print(C[i][j]);
					if(j!=l-1) {
						System.out.print(" ");
					}
				}
				System.out.println();
			}
		}
	}
}



Measured memory_bytes: 53412
package main

import (
	"fmt"
)

func main() {
	var N, M, C int
	fmt.Scan(&N, &M, &C)
	B := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scan(&B[i])
	}
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	ret := 0
	for i := 0; i < N; i++ {
		sum := 0
		for j := 0; j < M; j++ {
			sum += B[j] * A[i][j]
		}
		if sum+C > 0 {
			ret++
		}
	}
	fmt.Println(ret)
}


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

using namespace std;
using ll = long long;
using ld = long double;

void solve() {
  int x, n;
  cin >> x >> n;

  if (n == 0) {
    cout << x << endl;
    return;
  }

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());

  int ans = 0;
  int id = 0;
  for (int i = 0; i < 102; i++) {
    if (i == p[id]) {
      ++id;
      continue;
    }

    if (abs(x - ans) > abs(x - i)) {
      ans = i;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

bool solve(){
  string s,t;
  cin>>s>>t;
  int n = s.size();

  map<char,char> ma, rev;
  rep(i,n) {
    ma[s[i]] = t[i];
    rev[t[i]] = s[i];
  }

  for(auto &p : ma){
    if(rev[p.second] != p.first) return false;
  }

  rep(i,n) s[i] = ma[s[i]];

  return s == t;
}

int main(){
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n;
string s;
int main(){
  cin >>n >> s;
  if(n % 2 == 1)cout << "No"<<endl;
  else{
      REP(i,n / 2){
          if(s[i] != s[i + n / 2]){
              cout << "No" <<endl;
              return 0;
          }
      }
      cout << "Yes"<<endl;
  }
}


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

using namespace std;

int const maxn = 1005;
int sum[2][4 * maxn][4 * maxn];

inline int get_sum(int t, int lx, int ly, int rx, int ry) {
    return sum[t][rx][ry] - sum[t][rx][ly - 1] - sum[t][lx - 1][ry] + sum[t][lx - 1][ly - 1];
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k, x, y, ans = 0;
    char c;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> x >> y >> c;
        x = x % (2 * k) + 1, y = y % (2 * k) + 1;
        if (c == 'B') sum[0][x][y]++, sum[0][x + 2 * k][y]++, sum[0][x][y + 2 * k]++, sum[0][x + 2 * k][y + 2 * k]++;
        else sum[1][x][y]++, sum[1][x + 2 * k][y]++, sum[1][x][y + 2 * k]++, sum[1][x + 2 * k][y + 2 * k]++;
    }
    for (int i = 1; i <= 4 * k; ++i) {
        for (int j = 1; j <= 4 * k; ++j) {
            for (int t = 0; t < 2; ++t) {
                sum[t][i][j] = sum[t][i - 1][j] + sum[t][i][j - 1] - sum[t][i - 1][j - 1] + sum[t][i][j];
            }
        }
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int t = 0; t < 2; ++t) {
                int cur = get_sum(t, i, j, i + k - 1, j + k - 1) + get_sum(t, i + k, j + k, i + 2 * k - 1, j + 2 * k - 1) + get_sum((1^t), i + k, j, i + 2 * k - 1, j + k - 1) + get_sum((1^t), i, j + k, i + k - 1, j + 2 * k - 1);
                ans = max(ans, cur);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 126208
N = int(input())
l = sorted([int(x) for x in input().split()])
ans = 0
if N < 3:
    print(0)
    exit()
for i in range(N-2):
    for j in range(i+1, N-1):
        if l[i] == l[j]:
            continue
        for k in range(j+1, N):
            if l[j] == l[k]:
                continue
            if l[i] + l[j] > l[k]:
                ans += 1
print(ans)

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

int main()
{
    int a, b;
    string op;

    while (true)
    {
        cin >> a >> op >> b;

        if (op == "+")
        {
            cout << a + b << endl;
        }
        else if (op == "-")
        {
            cout << a - b << endl;
        }
        else if (op == "*")
        {
            cout << a * b << endl;
        }
        else if (op == "/")
        {
            cout << a / b << endl;
        }
        else{
            break;
        }
    }
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>

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



int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.length()){
        if ( s[i] == t[i] ){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main (){

int i,n,x;
fscanf(stdin,"%d",&n);

for (i = 1;i<=n;i++){
x = i;
if (x%3 == 0){
printf(" %d",i);
continue;
}
do {
if (x%10 == 3){
printf(" %d",i);
break;
}
x/=10;
}while (x);
}
printf("\n");
return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
long long a,b,c;
int main ()
{
	cin>>a>>b>>c;
	if (b-a==c-b)
	{
		cout<<"YES"<<endl;
		return 0;
	}
	else
	cout<<"NO"<<endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int,int>> a(N);
    rep(i, N) {
        pair<int, int> p;
        cin >> p.second >> p.first;
        a.push_back(p);
    }
    sort(a.begin(), a.end());
    int time = 0;
    for (auto p : a) {
        time += p.second;
        if (time > p.first) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6428
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let u: u32 = read();

    if u == 25 {
        println!("Christmas");
    } else if u == 24 {
        println!("Christmas Eve");
    } else if u == 23 {
        println!("Christmas Eve Eve");
    } else if u == 22 {
        println!("Christmas Eve Eve Eve");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#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 PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    ll k,a,b,res = 1;
    cin >> k >> a >> b;
    if(a >= b-2) res += k;
    else{
        if(k <= a) res += k;
        else{
            res += a-1;
            k -= a-1;
            if(k%2 == 1){
                res++;
                k--;
            }
            while(k!=0){
                res += b-a;
                k -= 2;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

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

  ll g = 0, p = 0;

  int n = s.size();

  for (int i = 0; i < n; i++)
    if(s[i] == 'g'){
      g++;
    }
    else{
      p++;
    }

  ll ans = (g-p)/2;

  cout << ans << endl;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

ll sol_even(int n, const vector<ll> &a) {
    ll dp[200200][2];
    rep(i,200200) rep(j,2) dp[i][j] = -LINF;
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    rep(i,n) {
        if (i+2 < n) chmax(dp[i+2][0], dp[i][0]+a[i+2]);
        if (i+3 < n) chmax(dp[i+3][1], dp[i][0]+a[i+3]);
        if (i+2 < n) chmax(dp[i+2][1], dp[i][1]+a[i+2]);
    }

    return max(dp[n-2][0], dp[n-1][1]);
}

ll dp[200200][3][2];
ll sol_odd(int n, const vector<ll> &a) {
    rep(i,200200) rep(j,3) rep(k,2) dp[i][j][k] = -LINF;
    dp[0][0][0] = a[0];
    dp[1][1][0] = a[1];
    dp[2][2][0] = a[2];
    rep(i,n) {
        if (i+2 < n && i+2 != n-1) chmax(dp[i+2][0][0], dp[i][0][0]+a[i+2]);
        if (i+3 < n) chmax(dp[i+3][1][0], dp[i][0][0]+a[i+3]);
        if (i+4 < n) chmax(dp[i+4][0][1], dp[i][0][0]+a[i+4]);
        if (i+3 < n) chmax(dp[i+3][2][0], dp[i][1][0]+a[i+3]);
        if (i+2 < n) chmax(dp[i+2][1][0], dp[i][1][0]+a[i+2]);
        if (i+2 < n) chmax(dp[i+2][2][0], dp[i][2][0]+a[i+2]);
        if (i+2 < n) chmax(dp[i+2][0][1], dp[i][0][1]+a[i+2]);
    }
    return max({dp[n-3][0][0], dp[n-2][1][0], dp[n-1][2][0], dp[n-1][0][1]});
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    if (n%2) cout << sol_odd(n,a) << '\n';
    else cout << sol_even(n,a) << '\n';

    return 0;
}

Measured memory_bytes: 14324
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		int t=INF,pre,ans,cnt=0;
		rep(i,n){
			int a; scanf("%d",&a);

			int j;
			for(j=m;j>=0;j--) if(j%a==0) break;
			if(j==t && a==pre){
				cnt++;
			}
			else if(j<t || (j==t && a<pre)){
				t=j;
				pre=a;
				cnt=1;
				ans=i;
			}
		}

		if(cnt>=2) ans=n-1;
		printf("%d\n",ans+1);
	}

	return 0;
}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val (n, q) = readInputLine().split(" ").map { Integer.parseInt(it) }
    val s = readInputLine().toCharArray()
    
    // 予めカウントしておく
    val acCount = mutableListOf<Int>()
    acCount.add(0)
    var beforeA = false
    for (i in 1..n) {
        if (s[i - 1] == 'C' && beforeA) {
            acCount.add(acCount[i - 1] + 1)
        } else {
            acCount.add(acCount[i - 1])
        }
        if (s[i - 1] == 'A') {
            beforeA = true
        } else {
            beforeA = false
        }
    }
    
    for (i in 0 until q) {
        val (l, r) = readInputLine().split(" ").map { Integer.parseInt(it) }
        println("${acCount[r] - acCount[l]}")
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 67304
# https://atcoder.jp/contests/abc054/submissions/4360181

def main():
    from collections import defaultdict

    INF = 40 * 100 + 1

    N, Ma, Mb = map(int, input().split())

    memo = defaultdict(lambda: INF)

    for _ in range(N):
        ai, bi, ci = map(int, input().split())
        x = Ma * bi - Mb * ai  # Σai:Σbi=Ma:Mb<->Ma*Σbi-Mb*Σai=0

        for key, value in tuple(memo.items()):
            memo[key + x] = min(
                memo[key + x],
                value + ci
            )  # 既存の組み合わせに混合
        memo[x] = min(memo[x], ci)  # 新規のみ

    print(memo[0] if 0 in memo else -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <stdio.h>
#define N 10000
#define Q 500

int main() {
    
    int i,j,n,q,count=0;
    int S[N],T[Q];
    
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d",&S[i]);
    }
    
    scanf("%d",&q);
    for(i=0; i<q; i++) {
        scanf("%d",&T[i]);
        for(j=0; j<n; j++) {
            if(T[i]==S[j]) {
                count++;
                break;
            }
        }
    }
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#define maxn 100005
using namespace std;
int n,a[maxn],b[maxn],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++)
	{
		a[i]=lower_bound(b+1,b+n+1,a[i])-b;
		ans+=((a[i]^i)&1);
	}
	printf("%d",ans/2);
	return 0;
}

Measured memory_bytes: 4556
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

    int A, B;
    std::cin >> A >> B;
    std::cout << (A % 3 && B % 3 && (A + B) % 3 ? "Impossible" : "Possible") << std::endl;

}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  vpii v(n);
  rep(i, n) cin >> v[i].fi >> v[i].se;
  auto p = *max_element(all(v), [](pii a, pii b) {
    return a.se == b.se ? a.fi > b.fi : a.se < b.se;
  });
  cout << p.fi << ' ' << p.se << endl;
}

Measured memory_bytes: 3096
n = int(input())
i = 1
s = ""
while i <= n:
    x = i
    if x % 3 == 0:
        s += " "+str(i)
        i += 1
        continue

    while x > 0:
        if x % 10 == 3:
            s += " " + str(i)
            break
        x = x//10
    i += 1
print(s)


Measured memory_bytes: 5624
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;

// index が条件を満たすかどうか vector<>maeに検索したいvectorを入れる keyを超える最小の要素番号を返す
bool isOK(int index, long long key, vector<long long>&mae) {
	if (mae[index] >= key) return true;
	else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(long long key, vector<long long>&mae) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)mae.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key, mae)) right = mid;
		else left = mid;
	}

	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}

int n, m;
string s;

int main() {
	VLL squ(1);
	cin >> n;
	VLL a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	squ[0] = a[0];
	for (int i = 1; i < n; i++)
	{
		int b=binary_search(a[i], squ);
		if (b == 0) {
			squ.insert(squ.begin(), a[i]);
		}
		else {
			squ[b - 1] = a[i];
		}
	}
	cout << squ.size() << endl;
}

Measured memory_bytes: 2296
#include<bits/stdc++.h>
using namespace std;
int n,x,r,m;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++,r+=x,m=max(m,x))cin>>x;
    r-=m;r+=m/2;
    cout<<r<<endl;
    return 0;
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  int n, m; cin >> n >> m;
  int a[m];
  int sum = 0;
  for (int i = 0; i < m; ++i){
    cin >> a[i];
    sum += a[i];
  }
  int ans = n - sum;
  if(ans>=0)  cout << ans << endl;
  else  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3660
import math
N = int(input())

x = N
ans = []
y = 2
while y <= math.sqrt(x):
    while x % y == 0:
        ans.append(y)
        x = x //y
    y += 1

if x > 1:
    ans.append(x)

print("%d:" %N,*ans)
        
        





Measured memory_bytes: 5664
N = int(input())
A = list(map(int,input().split()))

if len(set(A)) >3 :
  print("No")
elif len(set(A))  == 3 :
  x,y,z = sorted(list(set(A)))[0],sorted(list(set(A)))[1],sorted(list(set(A)))[2]
  if N%3 == 0 and \
  A.count(x) == N//3 and\
  A.count(y) == N//3 and\
  A.count(z) == N//3 and\
  x^y^z == 0:
    print("Yes")
  else:
    print("No")
elif len(set(A)) == 2:
  x,y = sorted(list(set(A)))[0],sorted(list(set(A)))[1]
  if N%3 == 0 and \
  A.count(x) == N//3 and\
  A.count(y) == 2*N//3 and\
  y^y== 0:
    print("Yes")
  else:
    print("No")
else:
  if list(set(A))[0] ==0:
    print("Yes")
  else:
    print("No")
  
  

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

int r[101010];

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

	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	for (int i = 1; i < n; ++i) {
		r[i] = 1e9;
		for (int j = 1; j <= k; ++j) {
			if (i-j < 0) break;
			r[i] = min(r[i], r[i-j] + abs(v[i-j] - v[i]));
		}
	}
	cout << r[n-1] << '\n';
}


Measured memory_bytes: 1024
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n,sum=0,i=100000000;
  std::cin >> n;
  int a=n;
  while(n>0){
    sum+=n/i;
    n=n%i;
    i/=10;
  }
  
  if(a%sum) printf("No\n");
  else printf("Yes\n");

  return 0;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int lcm(int a,int b){return a*b/gcd(a, b);}

int main()
{
  int n, sum_s = 0, ans = 0;
  vector<int> s(100);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> s[i];
    sum_s += s[i];
  }
  sort(s.begin(), s.begin() + n - 1);
  if (sum_s % 10 != 0)
  {
    cout << sum_s << endl;
    return (0);
  }
  for (int i = 0; i < n; i++)
  {
    if ((sum_s - s[i]) % 10 != 0)
    {
      ans = sum_s - s[i];
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int k;
string s;
int main(){
    cin >> k >> s;
    if(s.size() <= k) cout << s;
    else{
        for(int i = 0; i < k; ++i) cout << s[i];
        cout << "...";
    } 
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N,R;
	cin >> N >> R;

	int ans = 0;
	if (N >= 10){
		ans = R;
	} else {
		ans = R + 100 * (10 - N);
	}


		cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

count = B[A[0]-1]

for i in range(1,N):
    count += B[A[i]-1]
    if A[i] == A[i-1] + 1:
        count += C[A[i-1]-1]

print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int n, i, j, w, x, y, z, d, t;
    int tariffs[7][3] = { {  60,  2,  600 },
                          {  80,  5,  800 },
                          { 100, 10, 1000 },
                          { 120, 15, 1200 },
                          { 140, 20, 1400 },
                          { 160, 25, 1600 },
                          { 999, 999, 999 } };
    while (1) {
        if (1 != scanf(" %d", &n)) return 1;
        if (n > 10000) return 1;
        if (n == 0) break;
        for (i=t=0; i<n; i++) {
            if (4 != scanf(" %d %d %d %d", &x ,&y, &z, &w)) return 1;
            if (x < 1 || x > 200 || y < 1 || y > 200 || z < 1 || z > 200) return 1;
            d = x + y + z;
            for (j=0; d > tariffs[j][0] || w > tariffs[j][1]; j++)
                ;
            if (j > 5) continue;
            t += tariffs[j][2];
        }
        printf("%d\n", t);
    }
    return 0;
}

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


bool pos[12][5010] = {};
bool dp[5010][1<<12];
bool dn[5010][1<<12];
string p[12];
string s;

int n,m;
bool dfs(int x,int bit){
	if( bit == 0 ) return 1;
	if( dn[x][bit] ) return dp[x][bit];
	bool ans = 0;
	for(int i = 0 ; i < n ; i++){
		if( (bit >> i & 1) && pos[i][x] ){
			ans |= dfs(x+p[i].size(),bit^(1<<i));
		}
	}
	dn[x][bit] = true;
	return dp[x][bit] = ans;
}

int main(){
	while( cin >> n >> m && n ){
		memset(dp,0,sizeof(dp));
		memset(dn,0,sizeof(dn));
		memset(pos,0,sizeof(pos));
		
		
		for(int i = 0 ; i < n ; i++) cin >> p[i];
		s = "";
		for(int i = 0 ; i < m ; i++){
			string c; cin >> c;
			s += c;
		}
		for(int j = 0 ; j < n ; j++){
			for(int i = 0 ; i + p[j].size() <= s.size() ; i++){
				int f = 1;
				for(int k = 0 ; k < p[j].size() ; k++)
					if( p[j][k] != s[i+k] ){ f = 0; break; }
				if(f) pos[j][i] = 1;
			}
		}
		int ans = 0;
		for(int i = 0 ; i < s.size() ; i++){
			if( dfs(i,(1<<n)-1) ){
				ans++;
			}
		}
		cout << ans << endl;
		
	}
}

Measured memory_bytes: 41372
int p[10000],n=2,i,j;
void main(){
  *p=2;
  for(;i<10000;)
    for(;;){
    a:  n++;
      for(j=0;p[j]*p[j]<=n;j++)
	if(n%p[j]==0) goto a;
      p[++i]=n;
      break;
    }
  for(i=1;i<10000;)
    p[i]+=p[i++-1];
  for(;;){
    scanf("%d",&n);
    if(!n) break;
    printf("%d\n",p[n-1]);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	long long N, K;
	long long H[200000];
	long long sum = 0;
 
	cin >> N >> K;
	for(int i=0; i<N; i++){
		cin >> H[i];
	}
	
	sort(H, H+N, greater<long long int>());
 
	for(int i=K; i<N; i++){
		sum += H[i];
	}
 
	cout << sum << endl;
 
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
  #include <vector>
  #include <string.h>
  #include <stack>
  #include <queue>
  #include <algorithm>
  #include <climits>
  #include <cmath>
  #include <map>
  #include <set>
  #include <assert.h>
  #include <stdio.h>
  #define REP(i,n) for(ll i=0;i<(n);i++)
  #define MOD 1000000007
  #define int long long
  #ifdef int
  const long long INF = LLONG_MAX / 10;
  #else
  const int INF = 1010101010;
  #endif
  using namespace std;
  typedef long long ll;
  typedef vector<vector<ll> > mat;
  typedef pair<int, int> P;
  //typedef pair<double, double> P;
  const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
  const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
  
  string s;
  int x, y;
  const int Z = 18003;
  const int N = 2 * Z + 1;
  bool dp[2][2][N];
  //char hoge[505050];
  // char s[N];

  signed main() {
    cin >> s;
    // scanf("%s", s);
    cin >> x >> y;
    // scanf("%lld%lld", &x, &y);
    int n = s.length();
    // int n = strlen(s);

    // REP(i,8000) s += 'a';

    dp[0][0][Z] = dp[1][0][Z] = 1;

    int pos = 0LL;
    while (pos < n && s[pos] == 'F') {
      pos++;
      x--;
    }

    int t = 0LL;
    while (pos < n) {
      pos++;
      t ^= 1;
      int L = 0;
      while (pos < n && s[pos] == 'F') {
        pos++;
        L++;
      }
      REP(i,N) dp[t][1][i] = 0; //1の方は計算結果
      REP(i,N) {
        if (!dp[t][0][i]) continue;
        dp[t][1][i-L] = dp[t][1][i+L] = 1;
      }
      REP(i,N) dp[t][0][i] = dp[t][1][i];
    }

    if (dp[0][0][Z+x] && dp[1][0][Z+y]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }

    return 0;
  }

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

using namespace std;

int main(){
	string s;
	cin>>s;
	int a=s[0]-'0';
	int b=s[1]-'0';
	int c=s[2]-'0';
	int d=s[3]-'0';

	for(int i=0;i<(1<<3);i++){
		bitset<3> hoge=i;
		char A='-';
		char B=A;
		char C=A;

		int ret=a;

		if(hoge.test(0)){
			ret+=b;
			A='+';
		}else ret-=b;

		if(hoge.test(1)){
			ret+=c;
			B='+';
		}else ret-=c;

		if(hoge.test(2)){
			ret+=d;
			C='+';
		}else ret-=d;

		if(ret==7){
			cout<<a<<A<<b<<B<<c<<C<<d<<"=7"<<endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

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

  int res = 0;
  for (size_t i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    if (a >= k) ++res;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long double arr1[100],arr2[100];
	long long n,i,x,j;
	x=1.0;
	long double ans;
	ans=0.0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arr1[i]>>arr2[i];
	}
	for (i=1;i<=n;i++)
	{
		x=x*i;
	}
	for (i=0;i<n;i++)
	{
		for (j=0;j<n;j++)
		{
			ans=ans+sqrt((arr1[i]-arr1[j])*(arr1[i]-arr1[j])+ (arr2[i]-arr2[j])*(arr2[i]-arr2[j]))*(x/n);
		}
	}
	ans=ans/x;
	cout<<setprecision(10)<<ans<<endl;
}

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

int main(){
   int n;
   cin >> n;
   int a[n],b[n],c[n];
   rep(i,n)cin>>a[i]>>b[i]>>c[i];
   ll dp[3][n];
   rep(i,3)rep(k,n)dp[i][k] = 0;
   //初期値を代入
   dp[0][0] = a[0],dp[1][0] = b[0],dp[2][0] = c[0];

   rep(i,n-1){
      dp[0][i+1] = max(dp[1][i]+a[i+1],dp[2][i]+a[i+1]);//a
      dp[1][i+1] = max(dp[0][i]+b[i+1],dp[2][i]+b[i+1]);//b
      dp[2][i+1] = max(dp[0][i]+c[i+1],dp[1][i]+c[i+1]);//c
      //cout << dp[0][i+1]<<" "<< dp[1][i+1]<<" "<< dp[2][i+1]<<endl;
   }
   
   ll MAX = 0;
   rep(i,3){
      MAX = max(MAX,dp[i][n-1]);
   }
   cout << MAX <<endl;
   return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll bl = b * 100 + 0.5;
    a *= bl;
    a /= 100;
    cout << a << endl;
    return 0;
}

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

    
int main()
{
   string s;
   int c=0;
   map<char,int>cnt;
   cin>>s;
   for(int i=0;i<s.size();i++){ 
       cnt[s[i]]++;
   } 
   for(char i='A';i<='Z';i++){ 
       if(cnt[i]==2)c++;
   }
   cout<<(c==2?"Yes":"No")<<endl; 

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    double r = in.nextDouble();
    double pi = Math.PI;
    double menseki = pi * r * r;
    double ensyu = 2 * pi * r;
    
    System.out.printf("%.6f %.6f",menseki,ensyu);
  }
}

Measured memory_bytes: 28284
use proconio::{input, fastout};
use std::collections::HashMap;

macro_rules! echo {
  ($val:expr) => {
    println!("{}", $val);
  }
}

#[fastout]
fn main() {
  input!{
    n: usize,
    sa: [String; n]
  };
  let mut map = HashMap::new();
  for s in sa {
    *map.entry(s).or_insert(0) += 1;
  }
  for key in ["AC", "WA", "TLE", "RE"].iter() {
    println!("{} x {}", key, map.get(&String::from(*key)).unwrap_or(&0));
  }
}


Measured memory_bytes: 7848
n = int(input())
L = [[0, 0] for _ in range(n)]
for i in range(n):
  x, l = map(int, input().split())
  L[i][1] = x -l
  L[i][0] = x + l
  
L.sort()

ans = 0
for i in range(n):
  if i == 0:
    temp = L[i][0]
    ans += 1
  else:
    if L[i][1] >= temp:
      ans += 1
      temp = L[i][0]
    else:
      continue
print(ans)

Measured memory_bytes: 56352
import sys
input = sys.stdin.readline
import math

def gcd(a, b):
  if a < b:
    return gcd(b, a)
  if b == 0:
    return a
  return gcd(b, a%b)


A, B = map(int, input().split())
G = gcd(A, B)
d = [1]

for i in range(2, int(math.sqrt(G))+1):
  if G % i == 0:
    d.append(i)
    while G % i == 0:
      G /= i
      
if G != 1:
  d.append(G)

print(len(d))

Measured memory_bytes: 3064