akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll dp[25][15][200];

ll rec(ll n, ll k, ll s){
	if(n == 0) return (s == 0) && (k == 0);
	if(k == 0) return s == 0;
	if(dp[n][k][s] != -1) return dp[n][k][s];
	ll res = 0;
	for(ll i=n; i>=1; i--){
		if(i <= s) res += rec(i-1,k-1,s-i);
	}
	return dp[n][k][s] = res;
}

int main(){
	rep(i,21) rep(j,11) rep(k,156) dp[i][j][k] = -1;
	while(1){
		ll n,k,s; cin >> n >> k >> s;
		if(n+k+s == 0) break;
		cout << rec(n,k,s) << endl;
	}
}


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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
int main()
{
    FAST
string h;
cin>>h;
string che=h;

int c=0;
for(int i=0;i<h.length()-1;i++)
{
    if(che[i]==che[i+1])
    {
        if(che[i]=='1')
            che[i+1]='0';
        else
            che[i+1]='1';
            c++;
    }
}
int c1=0;
for(int i=h.length()-1;i>0;i--)
{
    if(h[i]==h[i-1])
    {
          if(h[i]=='1')
            h[i-1]='0';
        else
            h[i-1]='1';
        c1++;
    }
}
cout<<min(c,c1)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}


int main(void){
  int N, A, B, W, H;
  cin >> N >> A >> B;
  N = N-A;
  cout << N%B << endl;

}


Measured memory_bytes: 256
##貪欲法(greedy)
#区間スケジューリング
#D - Islands War
#https://atcoder.jp/contests/abc103/tasks/abc103_d

n, m = list(map(int,input().split()))
lst = [list(map(int,input().split())) for _ in range(m)]
lst.sort(key=lambda x: x[1])
ans = []
ans.append(lst[0])

for i in range(1,m):
    if ans[-1][1] <= lst[i][0]:
        ans.append(lst[i])

print(len(ans))

Measured memory_bytes: 29080
#include <iostream>
#include <cstdio>
using namespace std;
//最大公約数
int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a%b);
}

//最小公倍数
int lcm(int a, int b) {
    int ret = gcd(a,b);
    ret = a*(b/ret);
    return ret;
}

int main(int argc, const char * argv[])
{
    int a, b;
    while (~scanf("%d %d", &a, &b)) {
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }
    return 0;
}

Measured memory_bytes: 1188
#include<stdio.h>
    int main(){
      int x,y;
      scanf("%d%d",&x,&y);
      
      for (int c=0;c <= x;c++){
        int t =x-c;
        int asi = c*2+t*4;
        if(asi==y){
          printf("Yes");
          return 0;
        }
      }
        printf("No");
        return 0;
      }
      

Measured memory_bytes: 1712
# -*- coding: utf-8 -*-

s = list(input())

a = s[0]+s[1]
b = s[2]+s[3]

a_canBeM = False
b_canBeM = False
canBeY = True

M = ["01","02","03","04","05","06",
     "07","08","09","10","11","12"]

if a in M:
    a_canBeM = True
if b in M:
    b_canBeM = True

if a_canBeM and b_canBeM:
    print("AMBIGUOUS")
elif a_canBeM and (not b_canBeM):
    print("MMYY")
elif (not a_canBeM) and b_canBeM:
    print("YYMM")
else:
    print("NA")


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1,2,4,3);}
  void roll_y(){ roll(0,2,5,3);}
  void roll_x(){ roll(0,1,5,4);}
  void roll(int i,int j,int k,int l){
    int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
  }
};

int getRight( Cube c1,int f1,int f2 ){
  for(int i=0;i<6;i++){
    for(int j=0;j<4;j++){
      if( c1.f[0]==f1 && c1.f[1]==f2 ) return c1.f[2];
      c1.roll_z();
    }
    if( i%2 == 0 )c1.roll_y();
    else c1.roll_x();
  }
  return -1;
}

int main(){
  Cube c;
  int f1,f2;
  for(int i=0;i<6;i++)cin>>c.f[i];
  int q; cin>>q;
  for(int i=0;i<q;i++){
    cin>>f1>>f2;
    cout<<getRight(c,f1,f2)<<endl;
  }
  return 0;
}
  
  



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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for (int i = 0; i < p.size(); i++) {
        cin >> p.at(i);
    }
    for (int i = 0; i < q.size(); i++) {
        cin >> q.at(i);
    }

    int pPoint = 0;
    int qPoint = 0;

    vector<int> sortP = p;
    vector<int> sortQ = q;

    sort(sortP.begin(), sortP.end());
    sort(sortQ.begin(), sortQ.end());
    
    do {
        if(sortP == p){
            pPoint++;
            break;
        }else{
            pPoint++;
        }
    } while(next_permutation(sortP.begin(), sortP.end()));

    do {
        if(sortQ == q){
            qPoint++;
            break;
        }else{
            qPoint++;
        }
    } while(next_permutation(sortQ.begin(), sortQ.end()));

    cout << abs(pPoint - qPoint) << endl;

    /*for (int i = 0; i < p.size(); i++) {
        cout << p.at(i);
    }
    for (int i = 0; i < sortP.size(); i++) {
        cout << sortP.at(i);
    }*/
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int n;

struct item{
    char name[256];
    int cost;
    char used[100][256];
    int size;
} ;

item list[100];
int memo[100];

int getCost(int vertex)
{
    if(memo[vertex]!=-1)return memo[vertex];
    int i, j;
    int ans;
    
    if (list[vertex].size == 0){
        return (list[vertex].cost);
    }
    else {
        ans = 0;
        for (i = 0; i < list[vertex].size; i++){
            for (j = 0; j < n; j++){
                if (strcmp(list[vertex].used[i], list[j].name) == 0){
                    ans += getCost(j);
                }
            }
        }
        list[vertex].cost = list[vertex].cost > ans ? ans : list[vertex].cost;
    }
    return (list[vertex].cost);
}

int main(void)
{
    int i, j, k;
    int m, kk;
    char key[256], temp[256];
    int look, sum;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        for(i=0;i<n;i++)memo[i]=-1;
        for (i = 0; i < n; i++){
            scanf("%s%d", list[i].name, &list[i].cost);
            list[i].size = 0;
        }
        
        scanf("%d", &m);
        for (i = 0; i < m; i++){
            scanf("%s", key);
            for (j = 0; j < n; j++){
                if (strcmp(key, list[j].name) == 0){
                    look = j;
                }
            }
            scanf("%d", &kk);
            list[look].size = kk;
            for (j = 0; j < kk; j++){
                scanf("%s", temp);
                for (k = 0; k < n; k++){
                    if (strcmp(temp, list[k].name) == 0){
                        strcpy(list[look].used[j], temp);
                    }
                }
            }
        }
        scanf("%s", key);
        for (j = 0; j < n; j++){
            if (strcmp(key, list[j].name) == 0){
                look = j;
            }
        }
        
        printf("%d\n", getCost(look));
        
    }
    
    return (0);
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 300+10;
ld memo[maxn][maxn][maxn];
int seen[maxn][maxn][maxn];
int cnt[5],N;

ld dp(int a,int b,int c){
	if(!a && !b && !c)return 0;
	if(seen[a][b][c])return memo[a][b][c];
	seen[a][b][c] = 1;
	ld expectedMalos = ld(N)/ld(a+b+c);
	ld &res = memo[a][b][c];
	res = expectedMalos;
	if(a){
		res += dp(a-1,b,c)*ld(a)/ld(a+b+c);
	}
	if(b){
		res += dp(a+1,b-1,c)*ld(b)/ld(a+b+c);
	}
	if(c){
		res += dp(a,b+1,c-1)*ld(c)/ld(a+b+c);
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,maxn)forn(j,0,maxn)forn(k,0,maxn){
		seen[i][j][k] = 0;
		memo[i][j][k] = 0;
	}
	cin >> N;
	forn(i,0,N){
		int x; cin >> x;
		cnt[x]++;
	}
	ld res = dp(cnt[1],cnt[2],cnt[3]);
	cout << fixed << setprecision(10) << res << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

#define INF 1000000007

using namespace std;

struct Point{
    int x, y, h;
};

int main()
{
    int n;
    cin >> n;
    vector<Point> A(n);
    for (int i=0; i<n; i++){
        cin >> A[i].x >> A[i].y >> A[i].h;
    }
    int otv_x, otv_y, otv_h;
    for (int xc=0; xc<=100; xc++){
        for (int yc=0; yc<=100; yc++){
            bool is = true;
            int h = -1;
            for (int i=0; i<n; i++){
                if (A[i].h!=0){
                    h = A[i].h+abs(xc-A[i].x)+abs(yc-A[i].y);
                    break;
                }
            }
            for (int i=0; i<n; i++){
                if (max(h-abs(xc-A[i].x)-abs(yc-A[i].y), 0)!=A[i].h){
                    is = false;
                    break;
                }
            }
            if (is){
                otv_x = xc;
                otv_y = yc;
                otv_h = h;
            }
        }
    }
    cout << otv_x << " " << otv_y << " " << otv_h << endl;
}


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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;


int main(){
	int n;
	cin >> n;
	v1 a(n+1);
	rep(i, n){
		cin >> a[i+1];
	}
	ll x =1000;
	ll m = 0;
	for(int i = 1; i <= n-1; i++){
		x += a[i]*m;
		m=0;
		if(a[i+1]>a[i]){
			m = x/a[i];
			x %= a[i];
		}
	}
	if(m != 0) x+= m*a[n];
	cout << x << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

class PrimeList {
  private:
    u64 max;
    Vec<u64> vals;
    Vec<bool> is_prime;
  public:
    PrimeList(u64 val): max(val), is_prime(val + 1, true) {
        is_prime[0] = false; is_prime[1] = false;
        for(int i = 4; i <= max; i += 2) is_prime[i] = false;
        for(int i = 3; i * i <= max; i += 2) {
            if(!is_prime[i]) continue;
            for(int j = 3; i * j <= max; j += 2)
                if(is_prime[i * j]) is_prime[i * j] = false;
        }
        for (int i = 0; i <= max; i++) if (is_prime[i]) vals.push_back(i);
    }
    bool exists(u64 x) const { return is_prime[x]; }
    u64 size() const noexcept { return (u64)vals.size(); }
    u64 range_max() const noexcept { return max; }
    u64 operator[](u64 index) const { return vals[index]; }
    decltype(vals)::const_iterator begin() const noexcept { return vals.cbegin(); }
    decltype(vals)::const_iterator end() const noexcept { return vals.cend(); }
};

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

void Main() {
    u32 X;
    cin >> X;
    PrimeList p(2 * X);
    u32 i;
    for (i = 0; i < p.size(); i++) {
        if (p[i] >= X) break;
    }
    cout << p[i] << endl;
}



Measured memory_bytes: 640
n=int(input())
xy=[[] for i in range(n)]
ans=0
a=[0]*n
for i in range(n):
  a[i]=int(input())
  for j in range(a[i]):
    x,y=map(int,input().split())
    xy[i].append([x,y])
for i in range(2**n):
  temp=[0]*n
  for j in range(n):
    if ((i >> j) & 1):
      temp[j]=1
  count=True
  for j in range(n):
    for k in range(a[j]):
      if temp[j]==1:
        p=xy[j][k][0]-1
        if temp[p]!=xy[j][k][1]:
          count=False
          break
  if count==True:
    ans=max(ans,sum(temp))
print(ans)

Measured memory_bytes: 3064
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n;

int main() {
	while (cin >> n&&n) {
		REP(qqq, n) {
			int x1, x2, y1, y2, z1, z2, w1, w2, x3 = 0, y3 = 0, z3 = 0, w3 = 0;
			cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;

			x3 += x1*x2;
			y3 += x1*y2;
			z3 += x1*z2;
			w3 += x1*w2;

			y3 += y1*x2;
			x3 += y1*y2*-1;
			w3 += y1*z2;
			z3 += y1*w2*-1;

			z3 += z1*x2;
			w3 += z1*y2*-1;
			x3 += z1*z2*-1;
			y3 += z1*w2;

			w3 += w1*x2;
			z3 += w1*y2;
			y3 += w1*z2*-1;
			x3 += w1*w2*-1;

			cout << x3 << " " << y3 << " " << z3 << " " << w3 << endl;
		}
	}
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "Yes" << endl;}                                               
void no() {cout << "No" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 

const int INF = 1e9 + 9;
const long long LINF = 1e12 + 8;
const double EPS = 1e-9;
const long long MOD = 1e9 + 7; //998244353
const double PI = acos(-1);

struct vertex {
    int next[26];
    int cnt;
    int leaf;

    vertex() {
        for (int i = 0; i < 26; i++) {
            next[i] = -1;
        }
        cnt = 0;
        leaf = false;
    }
};

vertex t[400010];
int sz = 1;

void add_string(string s) {
    int v = 0;
    for (int i = 0; i < sz(s); i++) {
        int c = s[i] - 'a';
        if (t[v].next[c] == -1) {
            t[v].next[c] = sz++;
        }
        v = t[v].next[c];
        t[v].cnt++;
    }
    t[v].leaf = true;
}

void solve() {
    int n; cin >> n;
    vector<string> a(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        add_string(a[i]);
    }

    int precalc[n + 1][26][26];
    memset(precalc, 0, sizeof precalc);
    for (int i = 1; i <= n; i++) {
        string s = a[i];
        int v = 0;
        for (int j = 0; j < sz(s); j++) {
            int c = s[j] - 'a';
            for (int k = 0; k < 26; k++) {
                if (k == c) continue;
                if (t[v].next[k] != -1) precalc[i][c][k] += t[t[v].next[k]].cnt;
            }
            v = t[v].next[c];
            if (t[v].leaf) precalc[i][c][c]++;
        }
    }
    int q; cin >> q;
    for (int it = 0; it < q; it++) {
        int id; cin >> id; 
        string check; cin >> check;
        int res = 0;
        for (int i = 0; i < 26; i++) {
            for (int j = i; j < 26; j++) {
                res += precalc[id][check[j] - 'a'][check[i] - 'a'];
            }   
        }
        cout << res << endl;
    }
}

int main() {
    jonathan; 
    livingston;
    solve();
    return 0;
}

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

int main(){

    ll int n;
    cin>>n;
    ll int arr[n];
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    ll int dp[n];
    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    for(int i = 1;i<n;i++){
        dp[i] = INT_MAX;
        if(i-1>=0){
            dp[i] = min(dp[i],abs(arr[i]-arr[i-1])+dp[i-1]);
        }
        if(i-2>=0){
            dp[i] = min(dp[i],abs(arr[i]-arr[i-2])+dp[i-2]);
        }
    }

    cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 1792
#include<cstdio>
    #include<iostream>
     
    using namespace std;
     
    int a, b;
    int gcd, lcm;
     
    void GCD(){
     
    	int big, small;
     
    	big = a;
    	small = b;
     
    	while (big) {
    		swap(big, small);
    		big = big % small;
    	}
    	gcd = small;
     
    }
     
    void LCM() {
    	lcm = a / gcd * b;
    }
     
     
     
     
    int main(){
    	while (cin >> a >> b) {
     
    		GCD();
    		LCM();
    		cout << gcd << " " << lcm << endl;
    	}
    	return 0;
    }

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

const int INF = 1e9 + 7;

int N;
ll A[51];

int main() {
	cin>>N;
	rep(i,N) cin>>A[i];
	
	ll ret=0;
	rep(x,1000000) {
		rep(i,N) if(A[i]>=N) {
			ll del=A[i]/N;
			ret += del;
			A[i] -= del*N;
			rep(j,N) if(i!=j) A[j] += del;
		}
	}
	
	cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
    ll x; cin >> x;
    ll ans = 0;
    ll d = 0;
    if(x>=500){
        d = x / 500; 
        ans += d * 1000;
        x -= 500 * d;
    }

    d = 0;
    d = x / 5; 
    ans += d * 5;
    x -= 5 * d;

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

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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int a = keyboard.nextInt();
		int b = keyboard.nextInt();
		int c = keyboard.nextInt();
		
		String ans;
		if(a + b == c) {
			ans = "Yes";
		}else if(b + c == a){
			ans = "Yes";
		}else if(c + a == b){
			ans = "Yes";
		}else {
			ans = "No";
		}

			System.out.println(ans);
			
		keyboard.close();	
	}
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,C,K;
    cin >> N >> C >> K;
    vi T(N);in(N,T);
    sort(all(T));
    
    int limt = T[0] + K;
    int bus = 0;
    int ans = 1;
    
    rep(i,N) {
        
        if(T[i] <= limt && bus < C){
            bus++;
        }else{
            ans++;
            limt = T[i]+K;
            bus = 1;
        }
        
    }
    cout << ans << endl;

    
    
    
    

    return 0;
}


Measured memory_bytes: 640
import sys


# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

# ===CODE===
def main():
    n, m, z = map(int, input().split())
    ruisekiwa = [[0 for i in range(n + 1)] for j in range(n + 1)]

    d = []
    for i in range(m):
        l, r = map(int, input().split())
        ruisekiwa[r][l] += 1

    for i in range(n):
        for j in range(n):
            ruisekiwa[i + 1][j + 1] += ruisekiwa[i][j + 1] + ruisekiwa[i + 1][j] - ruisekiwa[i][j]

    for _ in range(z):
        p, q = map(int, sys.stdin.readline().split())
        ans = ruisekiwa[q][q] - ruisekiwa[p - 1][q] - ruisekiwa[q][p - 1] + ruisekiwa[p - 1][p - 1]
        print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int mod = 1e9 + 7;

using int64 = long long;
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  int odd = N / 2 + N % 2;
  cout << 1.0 * odd / N << endl;
}



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

int main(){

	int num[3],tmp,i,j;

	cin >> num[0] >> num[1] >> num[2];

	for(j = 2;j >= 1;j--){
		for(i = 0;i<j;i++){
			if(num[i] > num[i+1]){
				tmp = num[i];
				num[i] = num[i+1];
				num[i+1] = tmp;
			}
		}
	}

	cout << num[0] << " " << num[1] << " " << num[2] << endl;

	return 0;
}


Measured memory_bytes: 3104
defmodule Main do
  def main() do
    [d, t, s] = IO.gets("") |> String.trim() |> String.split(" ") |> Enum.map(fn x -> String.to_integer(x) end)
    case d/s > t do
      true -> IO.puts("No")
      _ -> IO.puts("Yes")
    end
  end
end

Measured memory_bytes: 30744
import java.util

import scala.io.StdIn.readLine
import scala.io.StdIn.readInt
import java.util.Scanner
import java.util.ArrayList

object Main extends App {
  val sc = new Scanner(System.in)
  val s = sc.next().reverse
//  println(s.size)
  var dp = new Array[Int](s.size+1)
  var cnt = new Array[Int](2019)
  var p = 1
  for(i <- 0 to s.size-1){
//    println(i)
    dp(i+1) = dp(i) + p*(s(i) - '0')
    dp(i+1) %= 2019
    p *= 10
    p %= 2019
  }
  for(i <- 0 to s.size)cnt(dp(i)) += 1
  var ans = 0l
  for(i <- 0 to 2018)ans += cnt(i)*(cnt(i)-1)/2
  println(ans)





}

Measured memory_bytes: 58352
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;

/*
const ll M = 1000000007;
vector<ll> fac(3001);
vector<ll> ifac(3001);
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}
 
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}
*/


ll lcm(ll a,ll b){
 
  ll r, x, tmp;
  x = a * b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return x/b;
}

ll gcd(ll a ,ll b){
    if(a==0){return b;}
    else if(b==0){return a;}
    else{
    ll tmp,r;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
    }
}




int main(void){
    const ll INF = 1000000007;
    ll r;
    cin >> r;
    cout << 3 * r * r << endl;
    
    return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long X;
  scanf("%lld", &X);
  std::vector<long long> x(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &x[i]);
    x[i] = abs(x[i] - X);
  }

  sort(all(x));
  ll ans = x[0];
  rep(i, 1, N) { ans = gcd(ans, x[i]); }
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 1024
n,w = list(map(int,input().split(' ')))
w_arr = [None]*(n+1)
v_arr = [None]*(n+1)
for i in range(1,n+1):
    w_arr[i],v_arr[i] = list(map(int,input().split(' ')))

dp = [[0]*(w+1) for i in range(n+1)]

for i in range(1,n+1):
    for j in range(w+1):
        if j-w_arr[i]>=0:
            dp[i][j] = max(dp[i-1][j-w_arr[i]] + v_arr[i], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
            
print(max(dp[-1]))

Measured memory_bytes: 148080
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<"No";return 0;
    }else if(a!=b&&b!=c&&c!=a){
        cout<<"No";return 0;
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	int x,y;

	for (int i = 0; i < 3000;i++ ) {

		cin >> x >> y;

		if (x == 0 && y == 0) break;

		if (x <= y) {
			cout << x << " " << y << endl;
		}
		if (x > y) {
			cout << y << " " << x << endl;
		}


		

	}




	return 0;

}




Measured memory_bytes: 3096
n,k=map(int,input().split())
extraNode = (n-1)*(n-2)//2 - k

if extraNode < 0:
    print(-1)
    exit()

print(n-1 + extraNode)
for i in range(1,n):
    print(i,n)
l=1
r=1
for  i in range(extraNode):
    r+=1
    if r>=n:
        l+=1
        r=l+1
    print(l,r)

Measured memory_bytes: 3616
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (A, B, C, K): (i64, i64, i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };

    let ans = if K % 2 == 0 {
        A - B
    } else {
        B - A
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
a,b=map(int,input().split())
hai1=[]
hai2=[]
for k in range(0,a):
  hai1.append(str(b))
for i in range(0,b):
  hai2.append(str(a))
ak="".join(hai1)
bk="".join(hai2)
c=[0]*2
c[0]=ak
c[1]=bk
c.sort()
print(int(c[0]))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <map>
#include <list>

using namespace std;

typedef long long ll;

int main() {

    string s;
    cin >> s;
    
    unordered_set<char> set;
    
    for(int i = 0; i < s.size(); i++)
    {
        set.insert(s[i]);
    }
    
    if(set.size() == 2)
        cout << "Yes";
    else 
        cout << "No";

    return 0;

}

Measured memory_bytes: 764
#n = int(input())

#values = [int(i) for i in input('Enter some values: ').split()]   
all = []

for i in range(4):
    all.append(input())
    
a, b, c  = all[:-1]

X = all[-1]

result = 0
for i in range(int(a)+1):
    for j in range(int(b)+1):
        for k in range(int(c)+1):
          total = i*500 + j*100 + k*50          
          if(total==int(X)):
              result+=1
            
            
print(result)


Measured memory_bytes: 3060
import sys
from itertools import product

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

K = []

for i in range(M):
    k = list(map(int, input().split()))
    K.append(k)

P = list(map(int, input().split()))



S = []

for s in product([0,1], repeat=N):
    S.append([0] + list(s))

count = 0

for s in S:
    verify = True
    for p,k in zip(P,K):
        _sum = 0
        for i in k[1:]:
            _sum += s[i]
        parity = _sum % 2
        if parity != p:
            verify = False
            break
    if verify:
        count += 1

print(count)


Measured memory_bytes: 3188
I = lambda: map(int, input().rstrip().split())
n = int(input())
if n <= 6:
  print(1)
else:
  ans = (n // 11) * 2
  if n % 11 == 0:
     pass
  elif (n // 11) % 2 == 0:
    if n % 11 <= 6:
      ans += 1
    else:
      ans += 2
  else:
    if n % 11 <= 5:
      ans += 1
    else:
      ans += 2
  print(ans)

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

const long long inf = 1000000000000000000;

int n;
long long k, a, l, r, m, ans;
vector < long long > neg, pos;

long long f (long long x) {
	long long res = 0;
    for (int i = 0; i < int(neg.size()); ++i) {
        long long ln = i + 1, rn = int(neg.size()) - 1;
        long long resn = rn + 1;
        while (ln <= rn) {
			long long mn = (ln + rn) / 2;
			if (neg[mn] * neg[i] <= x) 
				rn = mn - 1, resn = mn;
            else 
                ln = mn + 1;
        }
        res += int(neg.size()) - resn;
    }  
    for (int i = 0; i < int(pos.size()); ++i) {
        long long ln = i + 1, rn = int(pos.size()) - 1;
        long long resn = -1;
        while (ln <= rn) {
            long long mn = (ln + rn) / 2;
            if (pos[i] * pos[mn] <= x) 
                ln = mn + 1, resn = mn;
            else 
                rn = mn - 1;
        }
        if (resn != -1)
            res += resn - i;
    }
    for (int i = 0; i < int(pos.size()); ++i) {
        long long ln = 0, rn = int(neg.size()) - 1;
        long long resn = -1;
        while (ln <= rn) {
            long long mn = (ln + rn) / 2;
            if (pos[i] * neg[mn] <= x) 
                ln = mn + 1, resn = mn;
            else
                rn = mn - 1;
        }
        res += resn + 1;
    }
	return res;
}

signed main () {
	scanf("%d %lld", &n, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", &a);
		if (a < 0)
			neg.push_back(a);
		else
			pos.push_back(a);
	}
	sort(neg.begin(), neg.end());
	sort(pos.begin(), pos.end());
	l = -inf, r = inf;
	while (l <= r) {
		m = (l + r) / 2;
		if (f(m) >= k)
			r = m - 1, ans = m;
		else
			l = m + 1;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 5456
#include <bits/stdc++.h>
using namespace std;
const int maxn=100010;
int n,m;
long long w[maxn],v[maxn],dp[maxn];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++)
        for(int j=m;j>=w[i];j--)
            dp[j]=max(dp[j],1ll*dp[j-w[i]]+v[i]);
    cout<<dp[m];
    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
    int i,n,a=0,b=0;
    for(i=0;i<3;i++){
        cin>>n;
        if(n==5){
            a++;
        }
        if(n==7){
            b++;
        }
    }
    if(a==2 && b==1){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
}

Measured memory_bytes: 256
#import sys
from heapq import heappush, heappop
#input = sys.stdin.readline
N,M = map(int, input().split())
A = []
for a in input().split():
  heappush(A,-int(a))

for _ in range(M):
  tmp = heappop(A)
  heappush(A, -(-tmp//2))

print(-sum(A))


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	ll cnt=n/(a+b)*a;
	n%=(a+b);
	cnt+=min(a,n);
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.ReadLine();
        var list = Console.ReadLine().Split(' ').Select(x=>double.Parse(x)).ToArray();
        Array.Sort(list);
        double ans = list.Aggregate((double a,double b) => (a+b)/2);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 19856
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  int n; cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    if(i % 5 == 0 || i % 3 == 0) continue;
    ans += i;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#define N 20
#define Q 200
 
int A[2000];
int m[2000];
int n;
 
int solve(int,int);
 
int main(){
  int q,i;
 
  scanf("%d",&n); 
   
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
   
  scanf("%d",&q);

  for(i=0;i<q;i++) {
  	scanf("%d",&m[i]);
  }
  
  for(i=0;i<q;i++) {
  	if(solve(0,m[i])==1)printf("yes\n");
  	else printf("no\n");
  }
  	return 0;
  
}
  int solve(int k, int m) {
  	int result;
  	
  	if(m == 0) return 1;
  	if( k >= n) return 0;
  	result = solve(k+1,m)||solve(k+1,m-A[k]);
  	return result;
  }


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

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

    vector<int> p(m);
    for(int i = 0 ; i < m ; ++i){
        cin >> p[i];
        --p[i];
    }

    vector<long long> a(n - 1), b(n - 1), c(n - 1);
    for(int i = 0 ; i < n - 1 ; ++i){
        cin >> a[i] >> b[i] >> c[i];
    }

    vector<int> imos(n);
    for(int i = 0 ; i < m - 1 ; ++i){
        int a = p[i];
        int b = p[i + 1];
        if(b < a){
            swap(a, b);
        }
        ++imos[a];
        --imos[b];
    }
    for(int i = 1 ; i < n ; ++i){
        imos[i] += imos[i - 1];
    }

    long long ans = 0;
    for(int i = 0 ; i < n - 1 ; ++i){
        ans += min(a[i] * imos[i], b[i] * imos[i] + c[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5908
# coding=utf-8
from __future__ import division
from  math import sqrt


def mean(list_):
    return sum(list_) / len(list_)


def std(list_):
    m = mean(list_)
    return sqrt(sum([(x - m) ** 2 for x in list_]) / len(list_))

def main():
    n = input()
    while n:
        scores = map(int, raw_input().split())
        print std(scores)
        n = input()


if __name__ == '__main__':
    main()

Measured memory_bytes: 4496
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<bitset>
#include <numeric>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define LONG_INF 9223372036854775807
#define INF 1000000000LL
#define EPS 1e-10
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define dump(a) rep(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define all(v) v.begin(),v.end()
#define pb push_back

#define MAX_N 200000
int dp[MAX_N];


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<string,int> dp{};
    int N;
    cin >> N;
    string s;
    rep(i, N){
        cin >> s;
        if(dp[s]>=0) dp[s]++;   
    }
    
    int ret = 0;
    for(auto it = dp.cbegin(); it != dp.cend(); ++it ) ret ++;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 19172
N, Y = map(int, input().split())

x, y, z = -1, -1, -1

for a in range(N+1):
    for b in range(N+1-a):
        if 10000*a + 5000*b + 1000*(N-a-b) == Y:
            x, y, z = a, b, N-a-b
        
print("{} {} {}".format(x,y,z))

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
        }
        Arrays.sort(A);
        long ans = method1(A);
        ans = Math.max(ans,method2(A));
        System.out.println(ans);
    }
    private long method2(long[] A) {
        int N = A.length;
        long ans = 0;
        if (N % 2 == 0) {
            for (int i = N-1; 0 <= i; i--) {
                if (N / 2 < i) {
                    ans += A[i] * 2;
                    continue;
                }
                if (N / 2 == i) {
                    ans += A[i];
                    continue;
                }
                if (N / 2 - 1 == i) {
                    ans -= A[i];
                    continue;
                }
                ans -= A[i]*2;
            }
        } else {
            for (int i = N-1; 0 <= i; i--) {
                if (N / 2 < i) {
                    ans += A[i] * 2;
                    continue;
                }
                if (N / 2 - 1 <= i) {
                    ans -= A[i];
                    continue;
                }
                ans -= A[i] * 2;
            }
        }
        return ans;
    }
    private long method1(long[] A) {
        int N = A.length;
        long ans = 0;
        if (N % 2 == 0) {
            for (int i = N-1; 0 <= i; i--) {
                if (N / 2 < i) {
                    ans += A[i] * 2;
                    continue;
                }
                if (N / 2 == i) {
                    ans += A[i];
                    continue;
                }
                if (N / 2 - 1 == i) {
                    ans -= A[i];
                    continue;
                }
                ans -= A[i]*2;
            }
        } else {
            for (int i = N-1; 0 <= i; i--) {
                if (N / 2 + 1 < i) {
                    ans += A[i] * 2;
                    continue;
                }
                if (N / 2 <= i) {
                    ans += A[i];
                    continue;
                }
                ans -= A[i]*2;
            }
        }
        return ans;
    }
}


Measured memory_bytes: 63712
#include <bits/stdc++.h>
using namespace std;
#define maxn 1000010
#define ull unsigned long long
#define  ll long long
#define db double

int main() {
   int n,m;
cin>>n>>m;
if(n==m){
for(int i=0;i<n;i++)cout<<n;
} else{
if(n>m)for(int i=0;i<n;i++)cout<<m;
else for(int i=0;i<m;i++)cout<<n;
}  return 0;
}

Measured memory_bytes: 256
Q = {
    1: 2,
    2: 5,
    3: 5,
    4: 4,
    5: 5,
    6: 6,
    7: 3,
    8: 7,
    9: 6,
}
 
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
 
# 桁数の最大
dp = [-1] * (N + 1)
dp[0] = 0
 
for a in A:
    for i in range(Q[a], N + 1):
        if dp[i - Q[a]] >= 0:
            dp[i] = max(dp[i], dp[i - Q[a]] + 1)
            #print(dp)
 
# 整数の復元
ans = ''
 
# 大きな数から試す
A.sort(reverse=True)
 
i = N
while i:
    for a in A:
        if i - Q[a] >= 0 and dp[i - Q[a]] == dp[i] - 1:
            ans += str(a)
            i -= Q[a]
            break
 
print(ans)

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

int main(){
  string S;
  cin>>S;
  bool ans=false;
  for(int i=0;i<3;++i){
    if(S.at(i)==S.at(i+1)){
      ans=true;
    }
  }

  if(ans){cout<<"Bad"<<endl;}
  else{cout<<"Good"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    vector<int> p2;
    for (int i = 0; i <= 6; i++) p2.push_back(pow(2, i));
    int N;
    cin >> N;
    for (int i = 6; i >= 0; i--)
        if (p2[i] <= N) {
            cout << p2[i] << endl;
            return 0;
        }
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

int q , w , e , z ;

int main()
{
	speed;

    string s ;
    cin >> s ;
    for(int i = 0 ; i < s.size() ; i ++ ){
            z = 0 ;
            for(int j = i ; j < s.size() ; j ++ ){
                if(s[j]=='A' || s[j]=='G' || s[j]=='C' || s[j]=='T' ){
                    z++;
                }
                else{
                    q=max(z,q);
                    break ;
                }
            }
            q = max( q, z );
    }

    cout << q ;

	time;
}


Measured memory_bytes: 256