akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main()
{
    int r;
    double ans;
    
    scanf("%d", &r);
    
    printf("%lf", 2*M_PI*(double)r);
    
    return 0;
}



Measured memory_bytes: 1748
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n,a;
  cin >> n >> a;
  cout << n*n-a<<endl;
}


Measured memory_bytes: 256
N = int(input())

L = []
for i in range(N):
    L.append(int(input()))

State = [1]
for _ in range(N-1):
    State.append(0)

i=0
count=1
while 1:
    i = L[i]-1
    if State[i]==1:
        print(-1)
        exit()

    if i+1 == 2:
        print(count)
        exit()

    State[i]=1
    count+=1

Measured memory_bytes: 13916
#include<stdio.h>
#include<math.h>
#define EPS 1e-10

double length(double a1,double a2,double b1,double b2){
  return sqrt( (a1 - b1) * (a1 - b1) + (a2 -b2) * (a2 - b2) ) ;
}

double flon(double len1, double len2, double len3){
  double s;
  s = (len1 + len2 + len3) / 2.0;
  return sqrt( s * (s-len1) * (s-len2) * (s-len3) ) ;
}

int main(void){
  int i;
  double p[8];
  double len12,len13,len14,len23,len24,len34;

  while(1){
    for(i=0;i<7;i++)scanf("%lf,",&p[i]);
    if(scanf("%lf ",&p[7])==EOF)break;
    
    len12 = length(p[0],p[1],p[2],p[3]);
    len13 = length(p[0],p[1],p[4],p[5]);
    len14 = length(p[0],p[1],p[6],p[7]);
    len23 = length(p[2],p[3],p[4],p[5]);    
    len24 = length(p[2],p[3],p[6],p[7]);
    len34 = length(p[4],p[5],p[6],p[7]);

    if( fabs(flon(len12,len14,len24)+flon(len24,len23,len34) - flon(len13,len23,len12) - flon(len13,len14,len34) ) < EPS){
      printf("YES\n");
    }else{
      printf("NO\n");
    }

  }

  return 0;
}

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

int main(void) {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    vector<int> b(n - 1);
    for (int i = 1; i < n; i++) {
        b.at(i - 1) = a.at(i) - a.at(i - 1);
    }
    b.push_back(a.at(0) + k - a.at(n - 1));
    cout << k - *max_element(b.begin(), b.end()) << endl;
    return 0;
}

Measured memory_bytes: 5640
#include <stdio.h>

int main(){
	char *day[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int i,date[2],month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	while(1){
		scanf("%d %d",&date[0],&date[1]);
		if(!date[0]) break;
		for(i = 0;i < date[0] - 1;i++) date[1] += month[i];
		printf("%s\n",day[(date[1] + 2) % 7]);
	}
}

Measured memory_bytes: 1012
n = int(input())

dic = {}

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            fn = (x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x)
            if fn in dic:
                dic[fn] = dic[fn] + 1
            else:
                dic[fn] = 1

for i in range(1,n+1):
    if i in dic:
        print(dic[i])
    else:
        print(0)

Measured memory_bytes: 72052
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a, b, c; cin>>a>>b>>c;
  if(a+b+c!=17){
    cout<<"NO"<<endl;
  }else if(a==b && c==7){
    cout<<"YES"<<endl;
  }else if(a==c && b==7){
    cout<<"YES"<<endl;
  }else if(b==c && a==7){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

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

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

    int l = 0, r = n-1;
    int cnt = 0;
    while(l<r){
        while(l<n-1 && s[l]!='W') l++;
        while(r>0 && s[r]!='R') r--;
        if(l>=r) break;
        s[l] = 'R'; s[r] = 'W';
        cnt++;
    }
    //cout << s << endl;
    cout << cnt << endl;
    return 0;
}

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

int main()
{
	int N;
	scanf("%d", &N);
	
	int r, s;
	int min = 100;
	int max = 0;
	int p[N];
	long long int L = 9223372036854775807;
	for(r=0; r<N; r++){
		scanf("%d", &p[r]);
		if(p[r]<min) min = p[r];
		if(p[r]>max) max = p[r];
	}		
	
	for(s=min; s<=max; s++){
		long long int sum = 0;
		for(r=0; r<N; r++){
			sum = sum + (p[r]-s)*(p[r]-s);
		}
		if(sum < L) L = sum;
	}
	
	printf("%ld", L);

		return 0;
	
}

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

int main() {
  int N;
  cin >> N;
  string S;
  ll kaisuu = 0;
  if(N == 0) { cout << 0; return 0; }
  while(N != 0) {
    int r;
    if(N % 2 < 0) r = (N % 2) + 2;
    else r = (N % 2);
    S += (char)('0' + r);
    N = (N - r) / (-2);
  }
  reverse(S.begin(), S.end());
  cout << S;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    if (a + b > c + d)
        printf("Left\n");
    else if (a + b < c + d)
        printf("Right\n");
    else
        printf("Balanced\n");
    return 0;
}

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

N = int(input().rstrip('\n'))
As = [int(x) for x in input().rstrip('\n').split()]
now = 1000
kabu = 0
time = 'buy'
for i in range(N):
  if i < N-1:
    if time =='buy':
      if As[i] < As[i+1]:
        kabu += now // As[i]
        now = now % As[i]
        time = 'sell'
    else:
      if As[i]>As[i+1]:
        now += kabu * As[i]
        kabu = 0
        time = 'buy'
  else:
    now += kabu*As[-1]
print(now)


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

int main(){
  vector<vector <int> > cards(4, vector<int>(13, 0));
  int N;
  cin >> N;
  char c;
  int n;
  for(int i = 0; i < N; i++){
    cin >> c >> n;
    if(c == 'S') cards.at(0).at(n - 1) = 1;
    else if(c == 'H') cards.at(1).at(n - 1) = 1;
    else if(c == 'C') cards.at(2).at(n - 1) = 1;
    else if(c == 'D') cards.at(3).at(n - 1) = 1;
  }

  for(int j = 0; j < 13; j++){
    if(cards.at(0).at(j) == 0){
      cout << "S " << j + 1 << endl;
    }
  }
  for(int j = 0; j < 13; j++){
    if(cards.at(1).at(j) == 0){
      cout << "H " << j + 1 << endl;
    }
  }
  for(int j = 0; j < 13; j++){
    if(cards.at(2).at(j) == 0){
      cout << "C " << j + 1 << endl;
    }
  }
  for(int j = 0; j < 13; j++){
    if(cards.at(3).at(j) == 0){
      cout << "D " << j + 1 << endl;
    }
  }

}


Measured memory_bytes: 3120
#include<stdio.h>
int main()
{
  int i,sum=0;
  char s[10];
  // 整数の入力
  scanf("%s", s);
  for(i=0;i<6;i++)
    {
      if(s[i]=='1')
	{
	  sum+=1;
	}
    }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool flag=true;


int main() {
ll A,B;
  cin >> A;

FOR(i,0,9){
    if(i*111<A && (i+1)*111>=A){
        A=i*111+111;
    }
}


  cout<<A<<endl;
  return 0;
}


Measured memory_bytes: 256
import heapq as hp
N, M = [int(item) for item in input().split()]
price_list = sorted([-1 * int(item) for item in input().split()])

total_m = 0

def discount(price_list, ticket_num):
    total_ticket =0
    hp.heapify(price_list)

    while total_ticket < ticket_num:
        temp = hp.heappop(price_list)
        hp.heappush(price_list, -1* (-1*temp//2))
        total_ticket += 1

    return price_list

res = discount(price_list, M)
print(-1 * sum(res))

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

int main(){
    int n;
    cin >> n;
    string w[101];
    for(int i=0;i<n;i++) cin >> w[i];
    int flag1 = 0;
    int flag2 = 0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(w[i] == w[j]){
                flag1 = 1;
                break;
            }
        }
        if(flag1==1) break;
    }
    for(int i=0;i<n-1;i++){
        if(w[i].back() != w[i+1].front()){
            flag2 = 1;
            break;
        }
    }
    if(flag1==0){
        if(flag2==0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
G=[[] for n in range(N)]
E=[]
for n in range(N-1):
    a,b=map(int,input().split())
    E.append((a-1,b-1))
    G[a-1].append(b-1)
    G[b-1].append(a-1)
K=max([len(v) for v in G])

P=[-1]*N
Q=[0]
X=[]
count=0
while Q:
    v=Q.pop()
    X.append(v)
    for u in G[v]:
        if u==P[v]:
            continue
        P[u]=v
        Q.append(u)

C={}
for v in X:
    color=0
    try:
        p_color=C[min(v,P[v]),max(v,P[v])]
    except:
        p_color=-1
    for u in G[v]:
        if u==P[v]:
            continue
        if color==p_color:
            color+=1
        C[min(u,v),max(u,v)]=color
        color+=1

print(K)
for e in E:
    print(C[e]+1)


Measured memory_bytes: 52588
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sumc = 0
for i in range(n - 1):
    if a[i + 1] - a[i] == 1:
        sumc += c[a[i] - 1]

print(sum(b) + sumc)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		while(sc.hasNext()) {
			String s = sc.nextLine();
			s += " ";
			String n = "";
			for(int i = 0; i < s.length(); i++) {
				String t = s.substring(i, i + 1);
				if(t.matches("[0-9]")) {
					if(n.length() == 0 && t.equals("0")) continue;
					n += t;
				}else {
					if(n.length() > 0) {
						sum += Integer.parseInt(n);
						n = "";
					}
				}
			}
		}
		sc.close();
		System.out.println(sum);
	}
}


Measured memory_bytes: 27836
x = int(input())

if x == 2:
  print(x)
else:
  if x % 2 == 0:
    x += 1
  while True:
    sqrt = int(x ** 0.5)
    for i in range(3,sqrt+1,2):
      if x % i == 0:
        x += 2
        break
    else:
      print(x)
      break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
// #include <atcoder/all>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// v ector<long long> v(n), c(n);
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
// vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(w + 1,
// vector<int>(k+1, 0)));

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int res = 0;
    for (int i = 0;i < n; i++) {
        int cnt = 0;
        for (int j = 0; j < 26; j++) {
            char c = 'a' + j;
            bool f = false;
            bool e = false;
            for (int k = 0; k < i ; k++) if(s[k] == c) f = true;
            for (int k = i; k < n ; k++) if(s[k] == c) e = true;
            if (f && e) cnt++;
        }
        res = max(res,cnt);
    }
    print(res);
    

    return 0;
}


Measured memory_bytes: 3588
class Card():
    def __init__(self, card):
        self.card = card
        self.mark = card[0]
        self.number = card[1]
        
    def __lt__(self, other):
        if not isinstance(other, Card):
            return NotImplemented
        return self.number < other.number
        
    def __repr__(self):
        return '{}{}'.format(self.mark, self.number)


def BubbleSort(target):
    ls = target.copy()
    flag = 1
    while flag:
        flag = 0
        for i in range(len(ls)-1, 0, -1):
            if ls[i] < ls[i-1]:
                ls[i], ls[i-1] = ls[i-1], ls[i]
                flag = 1
    print(' '.join(map(str, ls)))
    return sorted(ls)


def SelectSort(target):
    ls = target.copy()
    for i in range(len(ls)):
        minj = i
        for j in range(i+1, len(ls)):
            if ls[j] < ls[minj]:
                minj = j
        if ls[i] != ls[minj]:
            ls[i], ls[minj] = ls[minj], ls[i]
    
    print(' '.join(map(str, ls)))
    return sorted(ls)

def judge(original, sorted_list):
    if original == sorted_list:
        print('Stable')
    else:
        print('Not stable')


_ = int(input())
l2 =  [Card(i) for i in input().split()]
l2_sort = sorted(l2)

bubble = BubbleSort(l2)
judge(l2_sort, bubble)

select = SelectSort(l2)
judge(l2_sort, select)



Measured memory_bytes: 5612
class Scanner {
  private buffer = '';
  private stdinQueue: any = [];

  constructor() {
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on(
      'data',
      (chunk): void => {
        this.buffer += chunk;
        while (this.stdinQueue.length > 0) {
          const i = this.buffer.indexOf('\n');
          if (i < 0) {
            break;
          }
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          this.stdinQueue.shift()(line);
        }
      },
    );
  }
  public getLine(): Promise<string> {
    return new Promise((resolve, reject) => {
      const i = this.buffer.indexOf('\n');
      if (i >= 0 && this.stdinQueue.length == 0) {
        let line = this.buffer.substr(0, i);
        if (line.endsWith('\r')) {
          line = line.slice(0, -1);
        }
        this.buffer = this.buffer.substr(i + 1);
        resolve(line);
      } else {
        this.stdinQueue.push(resolve);
      }
    });
  }

  public close(): void {
    process.stdin.pause();
  }
}

async function slove() {
  const sc = new Scanner();
  const S = await sc.getLine();
  const t = S.match(/o/g);
  let ans = 700;
  if (t !== null) {
    ans = 700 + 100 * t.length;
  }
  console.log(ans);
  sc.close();
}

slove();


Measured memory_bytes: 7500
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    a,b = LI()

    return max([a+b,a-b,a*b])


print(main())





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

using namespace std;/**
vector<vector<long long> >v(1002,vector<long long>(100006,-1));
long long sol(int idx=0,long long ttlw=0){
    if(idx==n)
        return 0;
    if(v[idx][ttlw]!=-1)
        return v[idx][ttlw];
    if(ttlw+wt[idx]>w)
        return v[idx][ttlw]=sol(idx+1,ttlw);
    return v[idx][ttlw]=max(vl[idx]+sol(idx+1,ttlw+wt[idx]),sol(idx+1,ttlw));
}
*/
int main()
{
    long long n,w;
    cin>>n>>w;
    long long wt[n+1],vl[n+1];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>vl[i];
    }
    long long dp[n+1][w+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0||j==0)
                dp[i][j]=0;
            else if(wt[i-1]<=j)
                dp[i][j]=max(dp[i-1][j],vl[i-1]+dp[i-1][j-wt[i-1]]);
            else
                dp[i][j]=(dp[i-1][j]);
        }
    }

    cout << dp[n][w] << endl;
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
long double a,b,c;
	cin>>a>>b>>c;
	if(a+b+2*sqrtl(a*b)<c)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ll ans = 0;
    for (int m = 0; m <= min({1LL, i, j, l}); m++) { ans = max(ans, (i - m) / 2 * 2 + (j - m) / 2 * 2 + (l - m) / 2 * 2 + m * 3); }
    cout << ans + o << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
from heapq import heappop, heappush

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    d = defaultdict(list)
    for _ in range(N):
        a, b = map(int, input().split())
        d[a].append(-b)

    ans = 0
    heap = []
    for i in range(1, M+1):
        for b in d[i]:
            heappush(heap, b)
        if heap:
            ans -= heappop(heap)

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 27640
def inpl(): return [int(i) for i in input().split()]
N, A, B, C, D = inpl()
for k in range(N+1):
    j = N-1-k
    if D*k - C*j >= B-A >= C*k - D*j:
        print('YES')
        break
else:
    print('NO')

Measured memory_bytes: 38768
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll A,B,C,ans;
  cin>>A>>B>>C;
  ans=C-(A-B);
  if(ans<0) ans=0;
  cout<<ans<<endl;
  return 0;
}



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

int main(){
  int N, K;
  cin >> N >> K;
  
  long long x = N/K;
  long long y = (2*N + K)/(2*K);
  long long ans;
  if(K%2==1)ans = x*x*x;
  else ans = x*x*x + y*y*y;
 
  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 Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
// auto mod int
const int mod = 1000000007;

int main(){
  int n;cin>>n;
  ll a[n];
  rep(i,n){
    cin>>a[i];
  }
  ll ans=0;
  ll m=1;
  rep(i,60){
    ll a1=0;
    rep(j,n){
      if(a[j]>>i&1){
        a1+=1;
        a1%=mod;
      }
    }
    ll now=a1*(n-a1)%mod;
    now=now*m;
    now%=mod;
    ans+=now;
    ans%=mod;
    m=m*2;
    m%=mod;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back

void solve(){
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    REP(i, n){
        a[i] += l+i;
    }

    int sum = 0;
    REP(i, n) sum += a[i];

    if(l >= 0){
        cout << sum - a[0] << endl;
    }
    else{
        REP(i, n){
            if(a[i] == 0){
                cout << sum << endl;
                exit(0);
            }
        }
        cout << sum - a[n-1] << endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 256
i = gets.to_i
start = gets.to_i
ary = gets.split(" ").map(&:to_i)
sum = 0
(0..i-1).each do |n|
     if ary[n] >= start -ary[n]
         sum += (start -ary[n])*2
     else
         sum += ary[n] *2
     end
end
p sum

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

ll dp[100005];
ll arr[100005];

int main(){
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++) cin>>arr[i];
    for(ll i=1;i<=n;i++){
        ll t=INT_MAX;
        for(ll j=1;j<k+1&&i-j>=0;j++){
            dp[i]=min(t,dp[i-j]+abs(arr[i]-arr[i-j]));
            t=dp[i];
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

n, m = nm()
if n % 2:
    for i in range(m):
        print(i+1, m*2-i)
else:
    m2 = m // 2
    m1 = m - m2
    for i in range(m1):
        print(i+1, m1*2-i)
    for i in range(m2):
        print(i+1+m1*2, 2*m+1-i)


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
vi g[125252];
int k;

int depth[125252];
int kth[125252][20];
set<pii> depset;
void depdfs(int p,int d){
  depth[p] = d;
  depset.insert(pii(d,p));
  if(p!=0){
    kth[p][0] = a[p];
    FOR(i,1,20)kth[p][i] = kth[kth[p][i-1]][i-1];
  }
  REP(i,g[p].size()){
    int to = g[p][i];
    depdfs(to,d+1);
  }
}

void ersdfs(int p){
  pii P = pii(depth[p],p);
  if(depset.find(P)==depset.end())return;
  depset.erase(depset.find(P));
  REP(i,g[p].size()){
    int to = g[p][i];
    ersdfs(to);
  }
}

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n){
    scanf("%d",a+i);
    --a[i];
    if(i!=0)g[a[i]].push_back(i);
  }
  int ans = 0;
  if(a[0]!=0){
    a[0] = 0;
    ans++;
  }
  depdfs(0,0);
  while(depset.size()){
    pii P = *depset.rbegin();
    if(P.first <= k)break;
    // (k-1)th upper
    int p = P.second;
    int to = p;
    int up = k-1;
    REP(i,20){
      if(up&(1<<i)){
        to = kth[to][i];
      }
    }
    ersdfs(to);
    ans++;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 25856
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;


int main()
{
	long long N;
	cin >> N;
	vector<long long> time;
	for (int i = 0; i < 5; i++) {
		long long k = 0;
		cin >> k;
		time.push_back(k);
	}
	
	sort(time.begin(),time.end());
	long long ans = 0;
	
	ans = (N - N % time[0]) / time[0] + 5;
	if (N % time[0] == 0) {
		ans--;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
package main

import "fmt"
import "sort"

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	count := 0
	for i, v := range a {
		if x < v || (i == n-1 && v != x) {
			break
		}
		x -= a[i]
		count++
	}
	fmt.Println(count)

}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;


int main(void) {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int i, j;
	if (x > y) {
		i = a;
		j = x - y;
	}
	else {
		i = b;
		j = y - x;
	}
	cout << min(a*x + b * y, min(2 * c*max(x, y), 2 * c*min(x, y) + i * j));
	return 0;
}

Measured memory_bytes: 256
N, X, M = map(int, input().split())
hist = [-1] * (M + 1)
ans = X; hist[X] = 0; A = [X]
r = X % M
i = 1
N -= 1
while N:
    nxt = (r * r) % M
    if hist[nxt] != -1:
        break
    ans += nxt
    hist[nxt] = i; A.append(nxt); i += 1
    r = nxt; N -= 1
if N:
    A_sub = A[hist[nxt]:]
    L = len(A_sub)
    q, rem = divmod(N, L)
    ans += sum(A_sub) * q + sum(A_sub[:rem])
print(ans)

Measured memory_bytes: 13892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); 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<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    string n;
    cin >> n;
    if ((n.at(0) == '7') || (n.at(1) == '7') || (n.at(2) == '7')) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
from sys import stdin,stdout,setrecursionlimit
from collections import Counter as C
setrecursionlimit(10**6)
M = 1000000007
input = stdin.readline
def write(n,sep="\n"):
	stdout.write(str(n))
	stdout.write(sep)
def gil():
	return list(map(int, input().split()))
	
n = int(input())
d = []
for i in range(n):
    d.append(gil())
dp = [[0,0,0]]
for dz in range(n):
    ndp = [0] * 3
    for i in range(3):
        for j in range(3):
            if i != j:
                ndp[i] = max(ndp[i], dp[dz][j] + d[dz][i])
    dp.append(ndp)
#print(dp)
print(max(dp[-1]))

    
# tabular approach


Measured memory_bytes: 98256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	int n; cin >> n;
	vector<string> s(n);
	rep(i,n){
		cin >> s[i];
		SORT(s[i]);
	}
	map<string,ll> mp;
	ll ans = 0;
	rep(i,n){
		mp[s[i]] += 1;
		if(mp[s[i]]>1) ans += mp[s[i]]-1;
	}
	out(ans);
}




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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
	int n,m;cin>>n>>m;
	vector<int> a(n);
	int i;
	rep(i,n)cin>>a[i];
	vector<int> rem(n+1,0);
	rep(i,n)rem[i+1]=(rem[i]+a[i])%m;
	sort(all(rem));
	ll ans=0;
	int now=rem[0]; // rem[0]=0
	ll count=1;
	rep(i,n)
	{
		if(rem[i+1]==now)
		{
			count++;
		}
		else
		{
			now=rem[i+1];
			ans+=count*(count-1)/2;
			count=1;
		}
	}
	ans+=count*(count-1)/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main(){
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int f=0,s=0;
	for(int i=0;i<n;i+=2){
		if(a[i]==a[i+1]){
			s=f;
			f=a[i];
		}
		else i--;
	}
	cout<<(long long)f*s<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int A, B;
    cin>>A>>B;
    cout<<A*B<<endl;
}



Measured memory_bytes: 3636
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
ans=[]
mm=0
for i in l:
    k=(10-i%10)%10
    ans.append(k)
print(sum(l)+sum(ans)-max(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
 
using namespace std;
 
int main () {
  long L;
  vector<string> ans;
  cin >> L;
  for (int i = 1; i < 20; i++) {
    if (L == 1) {
      ans.push_back(to_string(i) + " " + to_string(i + 1) + " 0");
      continue;
    }
    if (L % 2 != 0) {
      ans.push_back(to_string(i) + " 20 " + to_string(L - 1));
      L--;
    }
    L /= 2;
    ans.push_back(to_string(i) + " " + to_string(i + 1) + " " + to_string(L));
    ans.push_back(to_string(i) + " " + to_string(i + 1) + " " + to_string(0));
  }
  cout << 20 << " " << ans.size() << endl;
  for (string s: ans) {
    cout << s << endl;
  }
}


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

int main() {
    int x, y;
    cin >> x >> y;
    if (y < 2 * x)
        cout << "No" << endl;
    else if (4 * x < y)
        cout << "No" << endl;
    else if (y % 2 == 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}


Measured memory_bytes: 3600
#include <iostream>

int main(int argc, char* argv[]) {
    int n;
    std::cin >> n;
    if (n == 1) {
        std::cout << "Hello World" << std::endl;
        return 0;
    }
    int a, b;
    std::cin >> a;
    std::cin >> b;
    std::cout << a + b << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int C[10001] = {0};

int n,a[2000001],b[2000001];

void CountingSort(int* A, int* B, int k){
	for(int i = 0; i <= k; i++){
		C[i] = 0;
	}

	for(int j = 1; j <= n; j++){
		C[A[j]]++;
	}

	for(int i = 1; i <= k; i++){
		C[i] = C[i] + C[i-1];
	}

	for(int j = n; j > 0; j--){
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
}


int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",&a[i]);
	}
	CountingSort(a,b,10000);
	printf("%d",b[1]);
	for(int i = 2; i <= n; i++){
		printf(" %d",b[i]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 18280
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(j, m) for (int j = 0; j <= (int)(m); j++)

void chmin(int &a, int b){
    if(a>b){
        a=b;
    }
}

int n, aa, bb, cc;
vector<int> l;


int dfs(int i, int a, int b, int c)
{if(i==n){
    if(a*b*c==0){return 100000000;}
    return abs(a-aa)+abs(b-bb)+abs(c-cc);
}
int res=dfs(i+1,a,b,c);
chmin(res,dfs(i+1,a+l[i],b,c)+(a?10:0));
chmin(res,dfs(i+1,a,b+l[i],c)+(b?10:0));
chmin(res,dfs(i+1,a,b,c+l[i])+(c?10:0));
return res;
}
int main()
{

    cin >> n >> aa >> bb >> cc;
    l.resize(n);
    vector<int> lis;
    
    rep(i, n)
    {
        cin >> l[i];
    }

    cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 3640
#include <vector>
#include <set>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	set<vector<int> >se;
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		vector<int>v(3);
		scanf("%d%d%d",&v[0],&v[1],&v[2]);
		sort(v.begin(),v.end());
		se.insert(v);
	}
	printf("%d\n",N-se.size());
}

Measured memory_bytes: 2860
# coding: utf-8
# Your code here!
N=int(input())

ans=sorted(list(input()))

for i in range(N-1):
    temp=[]
    target=(list(input()))
    for item in ans:
        for index in range(len(target)):
            if target[index]==item:
                temp.append(target.pop(index))
                break
    ans.clear()
    ans=ans+temp

print(("").join(ans))
#for i in range(N-1):
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define N 1000005
#define mod 1000000007
using namespace std;
int a[N],cnt[N];
bool b[N];
void solve(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        cnt[a[i]]++;
    }
    int gcd=__gcd(a[0],a[1]);
    for(int i=2;i<n;i++) gcd=__gcd(gcd,a[i]);
    if(gcd>1){
        cout<<"not coprime";
        return;
    }
    for(int i=2;i<N;i++){
        if(b[i]) continue;
        int c=0;
        for(int j=i;j<N;j+=i){
            c+=(cnt[j]>0);
            b[j]=1;
        }
        if(c>1){
            cout<<"setwise coprime";
            return;
        }
    }
    cout<<"pairwise coprime";
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	bool ok = false;
	REP(i, 100000000) {
		if (C >= A && C <= B)ok = true;
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////

void solve() {
	int N,K;
	cin >> N>>K;
	
	int ans = 0;
	if (N <= K) {
		ans = 1;
	}
	else {
		ans = ((N - K) + (K - 2)) / (K-1) + 1;
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;
int a[34]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int K;
int main(){
	scanf("%d",&K);
    printf("%d",a[K]);
	return 0;
}

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

int main() {
  int a, b, c, x, o = 0;
  cin >> a >> b >> c >> x;
  for(int i = 0; i <= a; i++)
    for(int j = 0; j <= b; j++)
      for(int k = 0; k <= c; k++)
        if(500 * i + 100 * j + 50 * k == x)
          o++;
  cout << o << endl;
}

Measured memory_bytes: 256
ctr = 1
while True:
    w = int(input())
    if w==0: break
    dp = [0]*(w+1)

    n = int(input())
    for i in range(n):
        vi, wi = map(int, input().split(","))
        for j in range(w,wi-1,-1):
            dp[j] = max(dp[j],dp[j-wi]+vi)

    print("Case "+str(ctr)+":")
    print(max(dp))
    print(dp.index(max(dp)))
    ctr += 1

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

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

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

        if(op=='?') break;

        switch(op){
        case '+':
            cout << a + b << endl; break;
        case '-':
            cout << a - b << endl; break;
        case '*':
            cout << a * b << endl; break;
        case '/':
            cout << a / b << endl; break;
        }
    }
}

Measured memory_bytes: 3052
#include<iostream>
using namespace std;
int main(){
  int a,b,c,n,tmp;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c;
    if(a<b){
      tmp=a;
      a=b;
      b=tmp;
    }
    if(a<c){
      tmp=a;
      a=c;
      c=tmp;
    }
    if(a*a==b*b+c*c){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, cnt=0;
	while(cin>>n, n>0){
		cout << "Case " << ++cnt << ": " << n << "\n";
	}
	return 0;
}


Measured memory_bytes: 3072
#include<stdio.h>

        #define N 1000


        int n,A[N],B[N],C[N],con,res,min;

        int small(int a,int b)
        {
          if(a<b)return a;
          else return b;
        }

        int search(int a)
        {
          int i;
          for(i=0; i<n; i++){
            if(A[i]==a)return i;
          }
        }

        int main()
        {
          int i,j,sum=0,p;

          scanf("%d",&n);

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

          for(i=n-1; i>0; i--){
            for(j=0; j<i; j++){
              if(B[j]>B[j+1]){
                int tmp;
                tmp=B[j];
                B[j]=B[j+1];
                B[j+1]=tmp;
              }
            }
          }

          for(i=0; i<n; i++)C[i]=0;

          for(i=0; i<n; i++){
            p=i;
            con=res=0;
            min=(1<<24);

            while(C[p]==0){
              C[p]=1;
              con++;
              res+=A[p];
              min=small(min,A[p]);
              p=search(B[p]);
            }

            if(con<2)continue;
            sum+=small(res+B[0]*(con+1)+min,res+min*(con-2));
          }

          printf("%d\n",sum);

          return 0;
        }



Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n,k;cin>>n>>k;
    vector<ll>pos(0);
    vector<ll>neg(0);
 
    rep(i,n){
        ll b;cin>>b;
        if(b<0){
            neg.pb(-b);
        }else{
            pos.pb(b);
        }
    }
    sort(rall(pos));
    sort(rall(neg));
    ll i=0;
    ll j=0;
    ll ans=1;
    if(n==k){
        rep(i,pos.size()){
            ans=ans*pos[i]%inf;
        }
        rep(i,neg.size()){
            ans=ans*(-neg[i])%inf;
        }
        if(ans<0)ans+=inf;
        cout<<ans<<endl;
        return 0;
    }
    if(neg.size()==n){
        if(k%2==0){
            rep(i,k){
                ans=ans*neg[i]%inf;
            }
            cout<<ans<<endl;
            return 0;
        }
        sort(all(neg));
        rep(i,k){
            ans=ans*(-neg[i])%inf;
        }
        if(ans<0)ans+=inf;
        cout<<ans<<endl;
        return 0;
    }
    ll cnt=0;
    while(cnt<k){
        if(i==pos.size()){
            ans=ans*(-neg[j])%inf;
            j++;
            cnt++;
        }else{
            if(j==neg.size()){
                ans=ans*pos[i]%inf;
                i++;
                cnt++;
            }else{
                if(pos[i]>neg[j]){
                    ans=ans*pos[i]%inf;
                    i++;
                    cnt++;
                }else{
                    ans=ans*(-neg[j])%inf;
                    j++;
                    cnt++;
                }
            }
        }
    }
    if(j%2==0){
        if(ans<0)ans+=inf;
        cout<<ans<<endl;
    }else{
        ll an1=1;
        ll an2=1;
        rep(k,i+1){
            if(k==pos.size())break;
            an1=an1*pos[k]%inf;
        }
        rep(k,j-1){
            an1=an1*(-neg[k])%inf;
        }
        rep(k,i-1){
            an2=an2*pos[k]%inf;
        }
        rep(k,j+1){
            if(k==neg.size())break;
            an2=an2*(-neg[k])%inf;
        }
        if(i==0){
            ans=an1;
        }else if(j==neg.size()){
            ans=an1;
        }else{
            if(pos[i]*pos[i-1]>=neg[j]*neg[j-1]){
                ans=an1;
            }else{
                ans=an2;
            }
        }
        if(ans<0)ans+=inf;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
 
int main(){
    long int N, A, B; cin >> N >> A >> B;
    long int X[N]; rep(i,N) cin >> X[i];
 
    unsigned long long int dp[N]; dp[0] = 0;
    rep(i,N-1){
        long int dst = X[i+1] - X[i];
        dp[i+1] = dp[i] + min(dst*A, B);
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    
    int n,a,b,p[111];
    cin>>n>>a>>b;
    int x=0,z=0,y=0;
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(p[i]<=a)x++;
        if(a<p[i] && p[i]<=b)y++;
        if(b<p[i])z++;
    }
    cout<<min(min(x,y),z);
    
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;
use std::cmp::min;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let k: usize = read().unwrap();
    let n: usize = read().unwrap();
    let mut a: Vec<usize> = Vec::new();
    for _ in 0..n {
        a.push(read().unwrap());
    }

    let mut dist: Vec<usize> = Vec::new();
    for n_i in 0..n {
        if n_i == 0 {
            dist.push(k - a[n - 1] + a[0]);
        } else {
            dist.push(a[n_i] - a[n_i - 1]);
        }
    }
    dist.sort();
    println!("{:?}", k - dist[n-1]);
}

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

signed main(){
	int n, m;
	
	cin>>n;
	
	if(n%2==0)cout<<(n/2)*(n/2)<<endl;
	else cout<<(n/2)*(n/2+1)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			double[][] map = new double[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j] = scanner.nextDouble();
				}
			}
			double[][] dp = new double[m][n];
			for (int i = 0; i < n; i++) {
				dp[0][i] = 1.0;
			}
			for (int i = 1; i < m; i++) {
				for (int j = 0; j < n; j++) {
					for (int k = 0; k < n; k++) {
						dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] * map[k][j]);
					}
				}
			}
			double max = 0;
			for (int i = 0; i < n; i++) {
				max = Math.max(max, dp[m - 1][i]);
			}
			System.out.println(String.format("%.2f", max));

		}
	}
}

Measured memory_bytes: 62236
#include<bits/stdc++.h>
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infd DBL_MAX
#define infl LLONG_MAX
#define mod 1000000007
#define f first
#define s second
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
//int dx[]={+1,-1,0,0};//vertical horizontal
//int dy[]={0,0,+1,-1};//vertical horizontal
//int dx[]={+1,+1,-1,-1,+2,-2,+2,-2};//knights move
//int dy[]={+2,-2,+2,-2,+1,+1,-1,-1};//knights move
//int dx[]={+1,-1,0,0,+1,+1,-1,-1};//vertical horizontal diagonal
//int dy[]={0,0,+1,-1,-1,+1,+1,-1};//vertical horizontal diagonal
using namespace std;
using namespace __gnu_pbds;
/*typedef tree<int, null_type,less<int>, rb_tree_tag,
             tree_order_statistics_node_update>indexed_set;
for set use above*/
typedef tree<pair<int,int>, null_type,less<pair<int, int>>, rb_tree_tag,
tree_order_statistics_node_update> indexed_multiset;


int main()
{
    int x;
    cin>>x;
    if(x==0)
    {
        cout<<1;
    }
    else
    {
        cout<<0;
    }
    return 0;
}



Measured memory_bytes: 3592