akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

int main() {
	int n, a, b;	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	char c,c1;
	scanf("%c",&c1);
	for(int i=1;i<=3;i++)
	{
		scanf("%c",&c);
		if(c1==c)
		{printf("Bad");return 0;}
		c1=c;
		}	
	printf("Good");
	return 0;	
} 

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    //??\?????¨?????????
    Scanner sc = new Scanner(System.in);
    ArrayList<ArrayList<Integer>> ary_ans = new ArrayList<>();
    while (true) {
      ArrayList<Integer> ary = new ArrayList<>();
      int input1 = Integer.parseInt(sc.next());
      int input2 = Integer.parseInt(sc.next());
      ary.add(input1);
      ary.add(input2);
      Collections.sort(ary);    //??????????????§?????????????????????????´???´????????????
      ary_ans.add(ary);
      if (input1 == 0 && input2 == 0) break;
    }
    //System.out.println(ary_ans);//????????????????´???´???????????? ????????????????????????????´???´???????????????????????????

    //????????¨???????????????????°?????°???????
    for (int i = 0; i < ary_ans.size() - 1; i++) {
      for (int j = 0; j < ary_ans.get(i).size(); j++) {
        System.out.println(ary_ans.get(i).get(j) + " " + ary_ans.get(i).get(j + 1));
        if (j == ary_ans.get(i).size()) ;
        break;
      }
    }
  }
}

Measured memory_bytes: 38236
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n,k,i;
	char s[50];

	scanf("%d %d",&n,&k);
	scanf("%s",s);

	for(i=0;i<n;i++){
		if(i==k-1) printf("%c",s[i]+32);
		else printf("%c",s[i]);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

import static java.lang.Math.max;

public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] H = new int[N];
        for (int i = 0; i < N; i++) {
            H[i] = Integer.parseInt(sc.next());
        }
        int[] t = new int[N];
        for (int i = 0; i < M; i++) {
            int A = Integer.parseInt(sc.next());
            int B = Integer.parseInt(sc.next());
            t[A - 1] = max(t[A - 1], H[B - 1]);
            t[B - 1] = max(t[B - 1], H[A - 1]);
        }
        int result = 0;

        for (int i = 0;i < N; i++) {
            if (H[i] > t[i]) {
                result += 1;
            }

        }

        System.out.print(result);

    }
}

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

int main(){
    int N;
    cin >> N;
    std::vector<long> d(N);
    for(int i=0; i < N; i++){
        cin >> d.at(i);
    }
    long tot = 0;
    for(int i=0; i < N-1; i++){
        for(int j=i+1; j < N; j++){
            tot += d.at(i) * d.at(j);
        }
    }
    cout << tot << endl;
    return 0;


}


Measured memory_bytes: 256
from collections import deque

n = int(input())
t = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    t[a].append(b)
    t[b].append(a)
c = sorted(list(map(int, input().split())))

queue = deque([0])
ans = [0 for i in range(n)]
num = n - 1
while queue:
    cur_node = queue.popleft()
    if ans[cur_node] > 0:
        continue
    ans[cur_node] = c[num]
    num -= 1
    for i in t[cur_node]:
        queue.append(i)
print(sum(c) - max(c))
print(*ans)

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

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

  int n; cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(to_string(i).size()&1) ans++;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * Eating Symbols Easy
	 */
	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)) {
			int ans = 0;
			String[] s = sc.next().split("");
			for (String i : s) {
				if (i.equals("+")) {
					ans ++;
				} else {
					ans --;
				}
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int a[200000];
  fill(a,a+200000,INF);
  int K,N;
  int kind = 0;
  cin >> N >> K;
  LOOP(i,N){
    int s;
    cin >> s;
    if(a[s]==INF){
      kind++;
      a[s]=0;
    }
    a[s]++;
  }
  sort(a,a+200000);
  int ans=0;
  if(kind>K){
    LOOP(i,kind-K){
      ans+=a[i];
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 107;

void read() {
  string s;
  cin >> s;
  cout << s.substr(0, 4) + " " + s.substr(4, 8) << endl;
}


void kill() {

}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
memory = [10**6 for _ in range(N + 1)]
flg = [False for _ in range(N + 1)]
memory[0] = 0
flg[0] = True
for a in A:
  m = 0
  while m < len(memory) and m + a < len(memory):
    if flg:
      memory[m + a] = min(memory[m] + 1, memory[m + a])
      flg[m + a] = True
    m += 1
print(memory[-1])


Measured memory_bytes: 8036
package main

import (
	"bufio"
	"fmt"
	"os"
)

func solution(n int, p [][2]int) int {
	max := func(x, y int) int {
		if x > y {
			return x
		}
		return y
	}
	min := func(x, y int) int {
		if x < y {
			return x
		}
		return y
	}
	zmax, zmin, wmax, wmin := -1<<31, 1<<31, -1<<31, 1<<31
	for i := range p {
		z := p[i][0] + p[i][1]
		w := p[i][0] - p[i][1]
		zmax = max(zmax, z)
		zmin = min(zmin, z)
		wmax = max(wmax, w)
		wmin = min(wmin, w)
	}
	return max(zmax-zmin, wmax-wmin)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	p := make([][2]int, n)
	for i := range p {
		fmt.Fscan(r, &p[i][0], &p[i][1])
	}
	fmt.Println(solution(n, p))
}


Measured memory_bytes: 8428
N = input()
K = int(input())
n0 = int(N[0])

# 数値Nから,1の位の位置をp1とする[keta]桁の部分数値が全て0であるか
def if_part_zero (N, p1, keta):
  partnum = 0
  beki = keta - 1
  for i in range(p1 - keta + 1, p1 + 1):
    if int(N[i]) > 0:
      return False
  return True


t = 0
if (K == 1):
  t = n0 + (len(N) - 1) * 9

if (K == 2):
  enough = 0
  for i in range(0, len(N) - 1):
    if i > 0:
      pattern1 = 9
      enough = 1
    else:
      pattern1 = n0
    for j in range(i + 1, len(N)):
      if enough == 1 or if_part_zero(N, j - 1, j - i - 1) == False:
        pattern2 = 9
      else:
        pattern2 = int(N[j])
      # print ("i=" + str(i) + " j=" + str(j) + " p=" + str((pattern1 - 1) * 9 + pattern2))
      t += (pattern1 - 1) * 9 + pattern2
    
if (K == 3):
  enough1 = 0
  enough2 = 0
  for i in range(0, len(N) - 2):
    if i > 0:
      pattern1 = 9
      enough1 = 1
    else:
      pattern1 = n0
    for j in range(i + 1, len(N) - 1):
      if enough1 == 1 or if_part_zero(N, j - 1, j - i - 1) == False:
        pattern2 = 9
        enough2 = 1
      else:
        pattern2 = int(N[j])
      if pattern1 == 1 and pattern2 == 0:
        continue
      for k in range(j + 1, len(N)):
        if enough1 == 1 or enough2 == 1 or if_part_zero(N, k - 1, k - j - 1) == False:
          pattern3 = 9
        else:
          pattern3 = int(N[k])
        
        # print ("1=" + str(pattern1) + " 2=" + str(pattern2) + " 3=" + str(pattern3) + " p=" + str(((pattern1 - 1) * 9 + pattern2 - 1) * 9 + pattern3))
        t += ((pattern1 - 1) * 9 + pattern2 - 1) * 9 + pattern3

print (t)


Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();
        
        int ans = 0;
        if( N ==  100 ) {
            ans = (int)Math.pow(100, D) * (N + 1);
        } else {
            ans = (int)Math.pow(100, D) * N;
        }
        System.out.println( ans );
    }
}


Measured memory_bytes: 35704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  int m,n;
  cin >> m >> n;
  if(m >= 2 && n >= 2)
    cout << (ll)(m-2)*(ll)(n-2) << endl; 
  else if(m == 1 && n >= 2)
    cout << n-2 << endl;
  else if(n == 1 && m >= 2)
    cout << m-2 << endl;
  else
    cout << 1 << endl;    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define for(i,n) for(int i=0;i<n;i++)
#define ll long long
#define MAX 1e9
#define MIN -1e9
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
   
    
   int n;
   cin>>n;
   
   int count=0;
   for(int i=1;i<=n;i++)
   {
       int k;
       cin>>k;
       if(k%2!=0 and i%2!=0)
       {
           count++;
       }
   }
    cout<<count<<endl;
   
return 0;
}


Measured memory_bytes: 3656
N,A,B = [int(i) for i in input().split()]
S = input().split()[0]

all = 0
b = 0

for i in range(len(S)):
  if S[i]=='c':
    print("No")
    continue
  if S[i]=='b' and all<(A+B) and b<B: 
    b+=1
    all+=1
    print("Yes")
    continue
  elif S[i]=="a" and all<A+B:
    all+=1
    print("Yes")
    continue
  print("No")
  

Measured memory_bytes: 4016
import sys
n, yen = map(int, input().split())


x_max = yen // 10000
for i in range(x_max + 1):
    rest_x = yen - 10000 * i
    y_max = rest_x // 5000
    for j in range(y_max + 1):
        if (rest_x - 5000 * j) % 1000 == 0:
            k = (rest_x - 5000 * j) // 1000
            if i + j + k == n:
                print(i, j, k)
                sys.exit()

print(-1, -1, -1)


Measured memory_bytes: 3060
N = int(input())
XL = [tuple(map(int, input().split())) for _ in range(N)]

rnl = [(X + L, L - X) for X, L in XL]
rnl.sort()

ans = 0
cur_max = -float("inf")

for r, nl in rnl:
    l = -nl
    if l >= cur_max:
        ans += 1
        cur_max = r

print(ans)


Measured memory_bytes: 30484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long cnt = 0;
		
		for(int i = 0; i<M; i++) {
			cnt += sc.nextLong();
		}
		if(N-cnt>-1) System.out.println(N-cnt);
		else System.out.println(-1);
		
	}
}


Measured memory_bytes: 46024
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int count = 0;
        for(int i = 0; i < x; i++){
            int y = sc.nextInt();
            if(y%2 == 0 && y != 2){
                continue;
            }
            if(check(y)){
                count++;
            }
        }
        System.out.println(count);
    }
    public static boolean check(int y){
        int z = (int)Math.sqrt(y);
        for(int j = 2; j <= z; j++){
            if(y%j == 0){
                return false;
            }
        }
        return true;
    }
}

Measured memory_bytes: 41320
#include <bits/stdc++.h>
using namespace std;
#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 itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


#define H_max 100
#define W_max 100

int main(){
    int H,W;
    cin >> H >> W;
    string field[W_max + 5];
    string tmp;
    REP(i,W+2) field[0].insert(0,"#");
    REP(i,H){
        cin >> tmp;
        field[i+1].insert(0,"#");
        field[i+1].insert(1,tmp);
        field[i+1].insert(W+1,"#");
    }
    REP(i,W+2) field[H+1].insert(0,"#");
    REP(i,H+2) cout << field[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin >> s;
    for(auto i: s) cout << "x";

    return 0;
}




Measured memory_bytes: 3652
a=(`dd`)
c=(0 0 0)
f=0
for((;c[f]<${#a[f]};))do
	d=${a[f]:c[f]:1}
	c[f]=$[c[f]+1]
	f=`echo $d|tr a-c 0-2`
done
echo $f|tr 0-2 A-C

Measured memory_bytes: 832
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

int main(){
	ll a , b  ; 
	cin>>a>>b ; 

	if((a+b)%2 == 0){
		cout<<(a+b)/2<<"\n" ; 
	}
	else{
		cout<<"IMPOSSIBLE\n" ; 
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long x = n / (a + b);
    long long ans = x * a;
    ans += min(a, n - x * (a + b));
    cout << ans << endl;
    return 0;
}


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

const int N = 3005;
string s , t;
int f[N][N];

void trace(int i , int j)
{
    if(i == 0 || j == 0)return;
    if(f[i][j] == f[i-1][j-1] + 1 && f[i-1][j] + 1 == f[i][j] && f[i][j-1] + 1 == f[i][j])
    {
        trace(i-1 , j-1);
        cout << s[i-1];
    }
    else
    {
        if(f[i][j] == f[i-1][j])trace(i-1 , j);
        else trace(i , j-1);
    }
}

int main()
{
    cin >> s >> t;
    f[0][0] = 0;
    f[0][1] = 0;
    f[1][0] = 0;
    for(int i = 1; i <= s.size(); ++i)
    {
        for(int j = 1; j <= t.size(); ++j)
        {
            if(s[i-1] == t[j-1])f[i][j] = f[i-1][j-1] + 1;
            else f[i][j] = max(f[i-1][j] , f[i][j-1]);
        }
    }
    //cout << f[s.size()][t.size()];
    trace(s.size() , t.size());
    return 0;
}


Measured memory_bytes: 38964
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
    int n;
    int R[MAX];
    cin >> n;

    for (int i = 0; i < n; i++){
        cin >> R[i];
    }

    int max_value = -2000000000;
    int min_value = R[0];

    for (int i = 1; i < n; i++){
        max_value = max(max_value, R[i] - min_value);    //最大値を更新
        min_value = min(min_value, R[i]);   //最小値を保持
    }

    cout << max_value << endl;

    return 0;
}



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

int main(){
    int K,S;
    cin>>K>>S;
    int ans=0;

    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(S-j-i<=K&&0<=S-j-i)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
string s;
cin>>s;
int c=-1,f=-1;
for(int i=0;i<s.size();i++)
if(s[i]=='C'){c=i;break;}
for(int i=0;i<s.size();i++)
if(s[i]=='F')f=i;

if(c!=-1 && f!=-1){
if(c<f)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;

int main(){
	int n,m;
	cin>>n>>m;
	cout<<(1<<m)*(1900*m+100*(n-m))<<endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

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

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);
    auto f = make_v<int>(0, N, 10);

    rep(i, N) rep(j, 10) {
        read(f[i][j]);
    }

    auto p = make_v<i64>(0, N, 10);
    rep(i, N) rep(j, 11) {
        read(p[i][j]);
    }

    i64 ans = -LINF;
    reps(bit, 1, (1 << 10) - 1) {
        bitset<10> b(bit);
        i64 sum = 0;
        rep(shop, N) {
            int cnt = 0;
            rep(t, 10) if (f[shop][t] && b[t]) ++cnt;
            sum += p[shop][cnt];
        }
        chmax(ans, sum);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long N;
	long sum=0;
	long i;
	scanf("%ld",&N);
	for(i=1;i<(sqrt(4*N-1)-1)*0.5;i++){
		if(N%i==0){
			sum+=N/i-1;
		}
	}
	printf("%ld",sum);
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  int g;
  cin >> g;
  --g;
  string ans = "Yes";
  for (int i = 1; i < n; ++i) {
    int h;
    cin >> h;
    // cerr << g << '\n';
    // cerr << h << '\n';
    if (h > g) {
      --h;
    }
    if (h < g) {
      ans = "No";
      break;
    }
    g = h;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3608
N=int(input())
A=list(map(int,input().split()))
a=0
c=1000
for i in range(N-1):
  if A[i]<A[i+1] and a==0:
    a,c=divmod(c,A[i])
    sb="False"
  elif A[i]>A[i+1] and a>0:
    c+=a*A[i]
    a=0

print(a*A[-1]+c)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rall(s) (s).rbegin(),(s).rend()
#define bs(x) (bitset<18>(x)).to_string()
#define sep ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
typedef long long ll;
int main(){
    sep;
    string s;
    cin>>s;
    if(s!=string(rall(s))) return cout<<"No",0;
    string t,q;
    q=s.substr((s.size()+3)/2-1);
    t=s.substr(0,(s.size()-1)/2);
    if(t!=string(rall(t))) return cout<<"No",0;
    if(q!=string(rall(q))) return cout<<"No",0;
    cout<<"Yes";
}

Measured memory_bytes: 256
X=4
Y=2
i=0
m={}
v=[]
for i in range(X*Y): v.append(str(i))
m[''.join(v)]=[0,0]
q=[v]
while len(q)>0:
	v=q.pop(0)
	coor=m[''.join(v)][0]
	x=coor%X
	y=coor/X
	depth=m[''.join(v)][1]
	if 0<x:
		v[coor],v[coor-1]=v[coor-1],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor-1,depth+1]
			q.append(v[:])
		v[coor],v[coor-1]=v[coor-1],v[coor]
	if x<X-1:
		v[coor],v[coor+1]=v[coor+1],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor+1,depth+1]
			q.append(v[:])
		v[coor],v[coor+1]=v[coor+1],v[coor]
	if 0<y:
		v[coor],v[coor-X]=v[coor-X],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor-X,depth+1]
			q.append(v[:])
		v[coor],v[coor-X]=v[coor-X],v[coor]
	if y<Y-1:
		v[coor],v[coor+X]=v[coor+X],v[coor]
		if ''.join(v) not in m:
			m[''.join(v)]=[coor+X,depth+1]
			q.append(v[:])
		v[coor],v[coor+X]=v[coor+X],v[coor]
try:
	while True:
		v=raw_input().rstrip().split()
		print(m[''.join(v)][1])
except EOFError:
	pass

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[50];

bool f(LL x) {
	LL sum = 0;
	inc(i, n) {
		sum += (a[i] - (n - 1) + x + (n)) / (n + 1);
	}
	return (sum <= x);
}

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL sum = 0;
	inc(i, n) { sum += a[i]; }
	
	LL L = -1, H = sum + 1;
	while(H - L > 1) {
		LL M = (L + H) / 2;
		(f(M) ? H : L) = M;
	}
	
	for(LL i = max(0LL, H - 200000); i <= H; i++) {
		if(f(i)) { cout << i << endl; return 0; }
	}
	
	assert(false);
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
  int n, x;
  int i, j, k;
  int m = 0;
  int count;
  int knt = 0;
  int a[1000];

  while (1) {
    count = 0;
    scanf("%d %d", &n, &x);
    if (n == 0 && x == 0) {
      break;
    }
    for (i = 1; i < n - 1; i++) {
      for (j = i + 1; j < n; j++) {
        for (k = j + 1; k <= n; k++) {
          if (i + j + k == x) {
            count++;
            break;
          }
        }
      }
    }
    a[m++] = count;
    knt++;
  }
  for (i = 0; i < knt; i++) {
    printf("%d\n", a[i]);
  }
}



Measured memory_bytes: 2068
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cmath>
using namespace std;

const int INF = 1e9;

int main(){
    int n, m;
    vector<int> t;
    vector< pair<int, int> > px;
    cin >> n;
    for(int i=0;i<n;i++){
        int ti;
        cin>>ti;
        t.push_back(ti);
    }
    cin >> m;
    for(int i=0;i<m;i++){
        int p, x;
        cin >>p>>x;
        px.push_back(make_pair(p, x));
    }
    for(int i=0;i<m;i++){
        int total = 0;
        for(int j=0;j<n;j++){
            if(px[i].first==j+1)
                total+=px[i].second;
            else
                total+=t[j];
        }
        cout<<total<<endl;
    }

}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int A, B;
    cin >> A >> B;
    cout << max(0, A - 2*B) <<endl;
  	
    
  	return 0;
}









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

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args) { 

            string n = Console.ReadLine();
            char n_last = n[n.Length - 1];
            string str = "unassigned";
            switch (n_last)
            {
                case '2':
                case '4':
                case '5':
                case '7':
                case '9':
                    str = "hon";
                    break;
                case '0':
                case '1':
                case '6':
                case '8':
                    str = "pon";
                    break;
                case '3':
                    str = "bon";
                    break;
                default:
                    break;
            }
            Console.WriteLine(str);
        }
    }
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, long long K, long long Q, std::vector<long long> A){

    lli small = -1,large = 1e9;

    lli ans = INF;

    REP(f,0,N){
        lli middle = A[f];

        //middle以上のものが撮れるかどうか？？？
        vector<lli> q;
        vector<lli> p;
        REP(i,0,N){
            if(A[i]>=middle)p.push_back(A[i]);
            else{
                if(p.size()>=K){
                    SORT(p);
                    lli size = p.size();
                    REP(i,0,size-K+1){
                        q.push_back(p[i]);
                    }
                }
                p.clear();
            }
        }
        if(p.size()>=K){
            SORT(p);
            lli size = p.size();
            REP(i,0,size-K+1){
                q.push_back(p[i]);
            }
        }
        SORT(q);
        LOG2(middle,q.size());
        if(q.size()>=Q){
            chmin(ans,q[Q-1]-q[0]);
        }
    }

    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    lli N; cin >> N;
    lli h=1,n=1,w=1;

    for(lli i=1; i<=3500; i++)
    {
        for (lli j=1;  j<= 3500; j++)
        {
            if ( ((4 * i * j - N * i - N * j)!=0) &&
                ((N * i * j) % (4 * i * j - N * i - N * j) == 0) &&
                ((N * i * j) / (4 * i * j - N * i - N * j) > 0))
            {
                w=(N * i * j) / (4 * i * j - N * i - N * j);
                n=i;
                h=j;
            }
        }
    }
    cout << h << " " << n << " " << w << endl;
    return 0;
}

Measured memory_bytes: 256
#0WA n==1 mod saikikilimit exit
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))


#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a

#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass #sortされていない

#0番目ぶー
res = gcdlist(a[1::])

#else
p = sorted(divisor(a[0]))
for i in range(len(p)-1,-1,-1):
    if p[i]<=res:
        break
    cnt = 1
    for j in range(1,n):
        if a[j]%p[i]==0:
            cnt += 1
    if cnt >= n-1:
        res = p[i]
        break
print(res)

Measured memory_bytes: 14140
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int d;
  cin >> d;
  str s = "Christmas";
  REP(_,25-d){
    s += " Eve";
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
N,M,X,Y = gets.split.map(&:to_i)
XX = gets.split.map(&:to_i)
YY = gets.split.map(&:to_i)
(X+1).upto(Y) do |z|
  c1 = (X<z && z<=Y)
  c2 = (XX.max < z)
  c3 = (YY.min >=z)
  if c1 && c2 && c3 
    puts "No War"
    exit 0
  end
end
puts "War"



Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

ll n,k;
ll dp[1001][1001]={};

int main(){
	scanf("%lld %lld",&n,&k);
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[i][j]+=dp[i-1][j]*j;
			dp[i][j]+=dp[i-1][j-1];
			dp[i][j]%=MOD;
		}
	}
	ll ans=0;
	for(int i=1;i<=k;i++){
		ans=(ans+dp[n][i])%MOD;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 11016
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        BufferedReader in = new BufferedReader(new java.io.InputStreamReader(System.in));
        {
            try {
                String s =in.readLine();
                StringTokenizer st;
                while(s!=null)
                {
                    st = new StringTokenizer(s);
                    int p =Integer.parseInt(st.nextToken()) + Integer.parseInt(st.nextToken()) ;
                     
                    System.out.println((int)Math.log10(p)+1);
                    s =in.readLine();
                }
            } catch (Exception ex) {
                System.exit(0);
            }
     }
    
}
}

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

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

  for(int i=0; i<=n; ++i){
    for(int j=0; j<=n; ++j){
      if(4*i+7*j == n){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";


}

Measured memory_bytes: 256
/*
g++ -std=c++14 -o2 -Wall template.cpp -o .\out\template.out
.\out\template.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s;
  vector<int> p;
  for (int i = 0; i < m; ++i) {
    int km;
    cin >> km;
    vector<int> ss;
    for (int j = 0; j < km; ++j) {
      int c;
      cin >> c;
      ss.push_back(c-1);
    }
    s.push_back(ss);
  }
  for (int i = 0;i < m; ++i) {
    int c;
    cin >> c;
    p.push_back(c);
  }
  int ans = 0;
  for (int i = 0;i < 1 << n; ++i) {
    bool res = true;
    for (int j = 0; j < m; ++j) {
      int num = 0;
      for (auto& c : s[j]) {
        if (((i >> c) & 1)== 1) ++num;
      }
      if (num % 2 != p[j]) res = false;
    }
    if (res) ++ans;
  }
  cout << ans << "\n";
  return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

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

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}

// ----------------------------------------------------------------------
struct MyException: exception {};

struct Peer {
  int nd;
  int wt;
  Peer(int n, int w) : nd(n), wt(w) {}
};

struct Crt {
  int cst;
  char sgn;
  Crt(int c, int s) : cst(c), sgn(s) {}
};

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N, M; cin >> N >> M;
  vector<vector<Peer>> nbr(N);
  
  for (int i = 0; i < M; i++) {
    int u, v, s; cin >> u >> v >> s; u--; v--;
    nbr.at(u).emplace_back(v, s);
    nbr.at(v).emplace_back(u, s);
  }

  int vMin = 1;
  int vMax = INT_MAX;

  vector<Crt> crt(N, Crt(0, 0));

  auto dfs = fix([&](auto f, int n, int p, int w) -> void {
      if (n == 0 && p == -1) {
	crt.at(0) = Crt(0, 1);
      }else {
	int c = w - crt.at(p).cst;
	int s = -crt.at(p).sgn;
	if (crt.at(n).sgn == s) {
	  if (crt.at(n).cst != c) throw MyException();
	  return;
	}
	if (crt.at(n).sgn == -s) {
	  int c2 = s * (crt.at(n).cst - c);
	  if (c2 % 2 == 1 || c2 / 2 < vMin || vMax < c2 / 2) {
	    throw MyException();
	  }
	  vMin = vMax = c2 / 2;
	  return;
	}
	assert(crt.at(n).sgn == 0);
	crt.at(n) = Crt(c, s);
	if (s == 1) {
	  vMin = max(vMin, 1 - c);
	}else if (s == -1) {
	  vMax = min(vMax, c - 1);
	}else {
	  assert(false);
	}
	if (vMin > vMax) throw MyException();
      }
      for (auto e : nbr.at(n)) {
	if (e.nd == p) continue;
	f(e.nd, n, e.wt);
      }
    });

  try {
    dfs(0, -1, -1);
    cout << vMax - vMin + 1 << endl;
  }catch(const MyException& e) {
    cout << 0 << endl;
  }

  return 0;
}



Measured memory_bytes: 15872
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
	int n, m, k;
	while (cin >> n >> m >> k && n){
		vector<vector<double> > dp(n+1, vector<double>(n*m+1));
		dp[0][0] = 1.0;
		REP(i,n) REP(j,(n-1)*m+1) FOR(p,1,m) {
			dp[i+1][j+p] += 1.0/m * dp[i][j];
		}
		double ans = 0.0;
		REP(i,m*n+1){
			if (i <= k) ans += dp[n][i];
			else ans += (i-k) * dp[n][i];
		}
		printf("%.10f\n", ans);
	}
    return 0;
}

Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[100001];
signed main()
{
	int n,m;
	int ans=0,sum=0;
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]),sum+=a[i];
	}
	for(int i=1;i<=n;i++)
		ans+=a[i]*(sum-a[i]);
	printf("%lld",ans/2);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

string S;
int N;
int ans = 0;
bool halt = false;

void recursive(int i, string T, int k) {
    if(i == N) {
        halt = true;
        ans = k;
        return;
    }
    for(int l = 1; l <= N - i; l++) {
        if(T != S.substr(i, l)) {
            recursive(i + l, S.substr(i, l), k + 1);
            if(halt) return;
        }
    }
}

int main() {
    cin >> S;
    N = S.size();
    recursive(0, "", 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 30596
#include<stdio.h>
#include<math.h>

int main(){
  int n,i;
  long a[100000],dis=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
    if(i==0)
      dis+=labs(a[i]);
    else
      dis+=labs(a[i]-a[i-1]);
    if(i==n-1)
      dis+=labs(a[i]);
  }
  for(i=0;i<n;i++){
    if(i==0)
      printf("%ld\n",dis-labs(a[0])+labs(a[1])-labs(a[0]-a[1]));
    else if(i==n-1)
      printf("%ld\n",dis-labs(a[n-1])+labs(a[n-2])-labs(a[n-2]-a[n-1]));
    else
      printf("%ld\n",dis-labs(a[i-1]-a[i])+labs(a[i-1]-a[i+1])-labs(a[i]-a[i+1]));
  }
}

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

using namespace std;
using ll=long long;

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

    vector<vector<ll>> G(n,vector<ll>(n,INT64_MAX/3));
    for (int i = 0; i < m; ++i) {
        ll a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        if(c>l)continue;
        G[a][b]=c;
        G[b][a]=c;
    }
    for (int i = 0; i < n; ++i) {
        G[i][i]=0;
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(G[i][j]<=l)G[i][j]=1;
            else G[i][j]=INT32_MAX/3;
        }
    }
    for (int i = 0; i < n; ++i) {
        G[i][i]=0;
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
            }
        }
    }
    int q;
    cin>>q;
    for (int i = 0; i < q; ++i) {
        int s,t;
        cin>>s>>t;
        --s;--t;
        if(G[s][t]!=INT32_MAX/3)cout<<G[s][t]-1<<"\n";
        else cout<<"-1\n";
    }
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int compare_string(const void *a, const void *b) {
  return strcmp(a,b);
}


int main(){
	
	int N,L,i;
	scanf("%d%d",&N,&L);
	
	char moji[110][110];
	
	for(i=0;i<N;i++){
	scanf("%s",moji[i]);
	}
	
	
	qsort(moji,N,sizeof(moji[0]),compare_string);
	
	for(i=0;i<N;i++){
	printf("%s",moji[i]);
	}
	printf("\n");
	
	return 0;
}

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

int main(){
  long n,m;
  cin >> n >> m;
  cout << (((n-m)*100+m*1900)<<m) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            int d = x - (i * 500 + j * 100);
            if(d < 0){break;}
            if((d % 50) != 0){continue;}
            if(d / 50 <= c){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void){
	char a[]="XYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char b[1001];
	int i=0,o=0;

	scanf("%s",b);

	while(b[i]){
		while(a[o]){
		if(b[i] == a[o] && o>=3){
		b[i]=a[o-3];
		break;}o++;
		}o=0;
		i++;
	}
	printf("%s",b);
	printf("\n");
	return 0;
}

Measured memory_bytes: 540
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

long[] PrimeList(long Max) {
    long[] Ret;
    bool[] isPrime = new bool[Max + 1];
    isPrime[] = true;
    isPrime[0] = isPrime[1] = false;
    for (long i = 2; i <= Max; i++) {
        if (isPrime[i]) {
            Ret ~= i;
            for (long j = i + i; j <= Max; j += i) {
                isPrime[j] = false;
            }
        }
    }
    return Ret;
}
 
void main() {
    long M, A, B;
    
    bool input() {
        readf("%d %d %d\n", &M, &A, &B);
        if (M == 0 && A == 0 && B == 0) return false;
        return true;
    }

    const MM = 100000;
    const pList = PrimeList(MM);

    void solve() {
        //printf("%d\n", pList.length);
        long Ans[2];
        long MaxArea = 0;
        for (int i = 0; i < pList.length; i++) {
            for (int j = i; j < pList.length; j++) {
                long p = pList[i], q = pList[j];
                if (p * q > M) break;
                if (q * A > p * B) break;
                if (MaxArea < p * q) {
                    Ans[0] = p;
                    Ans[1] = q;
                    MaxArea = p * q;
                }
            }
        }
        writefln("%(%s %)", Ans);
    }

    while (input()) solve();
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
    int A,B;
    cin >> A >> B;

    int cnt = 0;
    int tt  = 1;

    while (tt < B){
        tt += (A-1);
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


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

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

  vector<int> r(2019);
  int n = s.length(), t = 0, ten = 1;
  r[0] = 1;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int d = s[n - i - 1] - '0';
    t = (d * ten + t) % 2019;
    ans += r[t];
    r[t]++;
    ten = ten * 10 % 2019;
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 3812