akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    string s;
    for(int i =0;i < N; i++){
        cin >> s;
        if(s == "Y"){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

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

dp = [float('inf')] * (n+1)

for i in range(n+1):
  dp[i] = min(dp[i], i)
  j = 6
  while i+j<=n:
    dp[i+j] = min(dp[i+j], dp[i]+1)
    j *= 6
  k = 9
  while i+k<=n:
    dp[i+k] = min(dp[i+k], dp[i]+1)
    k *= 9
    
print(dp[n])

Measured memory_bytes: 9656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const double pi=3.14159265358979323846;
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b){
    if (a % b == 0){
        return(b);
    }else{
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
bool isprime(int n){
    if (n < 2) return false;
    else if (n == 2) return true;
    else if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2){
        if (n % i == 0){
            return false;
        }
    }
    return true;
}
void sayYes(bool f) {
    if (f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
void sayYES(bool f) {
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

int main() {
  int n;
  cin >> n;
  vector<int> a=input(n-1);
  vector<int> ans(n,0);
  rep(i,n-1){
    ans[a[i]-1]++;
  }
  rep(i,n){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, s=0;
  cin >> A >> B;
  for(int i=A;i<=B;i++) if(i/10000==i%10 && i/1000%10==i/10%10) s++;
  cout << s << endl; 
}

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

int main(){
  string w, t;
  int c = 0;
  cin >> w;
  while(1){
    cin >> t;
    if(t == "END_OF_TEXT") break;
    for(int i = 0; i < t.size(); i++) t[i] = tolower(t[i]);
    if(t == w) c++;
  }
  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null){
int a=Integer.parseInt(line);
BigInteger x=BigInteger.valueOf(a);
System.out.println(prevProbablePrime(a)+" "+x.nextProbablePrime());
}
}
public static int prevProbablePrime(int a){
a--;
while(true){
BigInteger y=BigInteger.valueOf(a);
if(y.isProbablePrime(2)){
return a;
}
a--;
}
}
}

Measured memory_bytes: 21168
#include <iostream>
#include <cmath>
#include <cstdio>
 
using namespace std;
 
double s(double a,double b,double c){
    double s = (a+b+c)/2;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}
 
int main(){
    double a,l,x;
    while(cin >> a >> l >> x){
        double y = (l+x)/2;
        printf("%.15f\n",s(a,l,l)+s(y,y,l)*2);
    }
    return 0;
}

Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include<string>
#include<map>
using namespace std;


int main() {

#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	int N;
	cin >> N;
	string s;
	cin >> s;
	map<char, int> cnt;
	for (auto& i : s){
		if (i != '+')cnt[i]++;
	}
	vector<int> num(10);
	for (auto& it : cnt){
		num[it.second]++;
	}
	int res = 0;
	if (num[1] > 0)res += num[1] * 2;
	for (int i = 2; i < 10; i++){
		if (num[i]>0){
			res += 3;
			if (num[i] > 1)res += 2;
			res += num[i] * 2 - 1;
		}
	}
	res--;
	cout << res << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int d[100];
    rep(i, n) cin >> d[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (i != j) ans += d[i]*d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ll = list()
    for i in range(n):
        tmp = list(map(str, input().split()))
        tmp[1] = int(tmp[1])
        tmp.append(i+1)
        ll.append(tmp)
    ll_s = sorted(ll, key=lambda x:(x[0],-x[1]))
    for i in ll_s:
        print(i[2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
print([0, 1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692][int(input())])

Measured memory_bytes: 9308
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine

getNString n = concat . map readString <$> replicateM n BS.getLine

calc :: String -> String -> String
calc _ [] = ""
calc [] _ = ""
calc (c : s) (a : ans)
  | c == a = a : (calc s ans)
  | c > a = calc (c : s) ans
  | c < a = calc s (a : ans)

simulate :: [String] -> String -> String
simulate [] ans = ans
simulate (s : ss) ans = simulate ss (calc s ans)

main = do
  n <- getInt
  ss <- getNString n
  let ss' = map sort ss
  putStrLn $ simulate (tail ss') (head ss')


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

using namespace std;
int tree[1000000],n;
int sum(int k)
{
    int s=0;
    while (k>=1)
    {
        s+=tree[k];
        k-=k&-k;
    }
    return s;
}
void add(int k,int x)
{
    while (k<=n)
    {
        tree[k]+=x;
        k+=k&-k;
    }
}
int main()
{
    int q,kom,l,r,i;
    scanf("%d%d",&n,&q);
    for(i=0;i<n;i++)
        tree[i]=0;
    for(i=0;i<q;i++)
    {
        scanf("%d%d%d",&kom,&l,&r);
        if (kom==0)
            add(l,r);
        else if (l!=0)printf("%d\n",sum(r)-sum(l-1));
        else printf("%d\n",sum(r));
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int cnt=3;
  
  if(a==b){
    cnt--;
  }
  if(b==c){
    cnt--;
  }
  if(a==c){
    cnt--;
  }
  if(a==b && b==c){
    cnt++;
  }
  
  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            String t = in.nextString();
            int q = in.nextInt();
            int[] a = new int[q];
            int[] b = new int[q];
            int[] c = new int[q];
            int[] d = new int[q];
            for (int i = 0; i < q; i++) {
                a[i] = in.nextInt() - 1;
                b[i] = in.nextInt() - 1;
                c[i] = in.nextInt() - 1;
                d[i] = in.nextInt() - 1;
            }

            int n = s.length();
            int m = t.length();

            int[] sumS = new int[n + 1];
            for (int i = 0; i < n; i++) {
                sumS[i + 1] = s.charAt(i) == 'A' ? 1 : 2;
            }
            for (int i = 0; i < n; i++) {
                sumS[i + 1] += sumS[i];
            }

            int[] sumT = new int[m + 1];
            for (int i = 0; i < m; i++) {
                sumT[i + 1] = t.charAt(i) == 'A' ? 1 : 2;
            }
            for (int i = 0; i < m; i++) {
                sumT[i + 1] += sumT[i];
            }

            for (int i = 0; i < q; i++) {
                int x = sumS[b[i] + 1] - sumS[a[i]];
                int y = sumT[d[i] + 1] - sumT[c[i]];

                out.println(x % 3 == y % 3 ? "YES" : "NO");
            }
        }

    }

    static class InputReader {
        private BufferedReader in;
        private StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 45796
def coin(i,k):
    count = 0
    while i < k:
        i = i * 2
        count += 1
    return count
 
n, k = map(int, input().split())
sum = 0
coin_count = 0
 
 
for i in range(1,n+1):
    x = coin(i, k)
    sum += (1/n) * ((0.5) ** x)
 
print(sum)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  string s;
  cin>>s;
  set<char>S;
  for(int i=0;i<s.size();i++)S.insert(s[i]);
  if(S.size()==s.size())cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 256
import Foundation

func readInts() -> [Int]{
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let rck = readInts()
    let (row, col, k) = (rck[0], rck[1], rck[2])
    var tableC = [[String]]()
    for _ in 0..<row {
        tableC.append(readLine()!.map { String($0) })
    }
    
    // ≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈ここまで入力
    // bit全探索で処理する
    var ans = 0
    for r in 1..<1<<row {
        for c in 1..<1<<col {
            var countBlack = 0
            for i in 0..<row {
                for j in 0..<col {
                    if r >> i & 1 == 1 && c >> j & 1 == 1 && tableC[i][j] == "#" {
                        countBlack += 1
                    }
                }
            }
            if countBlack == k {
                ans += 1
            }
        }
    }
    print(ans)
}
main()


Measured memory_bytes: 13508
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  var listA1 = Array.fill(n)(sc.nextInt)
  var listA2 = Array.fill(n)(sc.nextInt)

  var ans = 0
  for (i <- 0 until n) {
    val sum = listA1.slice(0, i + 1).sum + listA2.slice(i, n).sum
    ans = math.max(ans, sum)
  }
  println(ans)
}


Measured memory_bytes: 27584
def main():
    A, B = map(int, input().split())
    if A - B == 0:
        print('Draw')
    elif A == 1:
        print('Alice')
    elif B == 1:
        print('Bob')
    elif A - B > 0:
        print('Alice')
    elif B - A > 0:
        print('Bob')


main()


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

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

int main()
{
    int array[32] = {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;
    cin>>K;
    cout<<array[K-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC90(void);
void ABC91(void);
void ABC92(void);
void ABC93(void);
void ABC94(void);
void ABC95(void);
void ABC96(void);
void ABC97(void);
void ABC98(void);
void ABC99(void);

int main(void){
    ABC96();
}

void ABC96(){
    int a,b,c,k,ma,m,i;
    cin>>a>>b>>c>>k;
    ma=max(max(a,b),c);
    m=ma;
    for(i=0;i<k;i++){
        m*=2;
    }
    cout<<a+b+c-ma+m<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		long X = Math.abs(stdIn.nextLong());
		long K = stdIn.nextLong();
		long D = stdIn.nextLong();
		
		//X = Math.abs(X);
		
		long ans = X;
		
		long step = Math.min(K, X / D);
		K -= step;
		X -= step * D;
		
		if(K % 2 == 0) {
//			System.out.println(X);
			ans = X;
		}else {
			ans = D - X;
//			System.out.println(D - X);
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 35720
#include <stdio.h>

int rec(int th, int sum, int a, int *M, int n) {
  int i;
  if(sum == a) return 1;
  for(i = th; i < n; ++i) {
    if(rec(i+1,sum+M[i],a,M,n)) return 1;
  }
  return 0;
}

int main() {
  int i;
  int n, M[20], q, a;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d", M+i);
  }
  scanf("%d", &q);
  while(q--) {
    scanf("%d", &a);
    if(rec(0,0,a,M,n)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 376
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x);
#define MAX (10000000)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

const int N = 1001;
int label[N+1];

int ds(int i){
  if(label[i] == i) return i;
  return label[i] = ds(label[i]);
}

int main(){
  int v,d;
  int fib[N+1];
  fib[0] = 1; fib[1] = 2;
  for(int i=2; i<=N; i++)
    fib[i] = (fib[i-1] + fib[i-2]) % N;

  while(~scanf("%d%d",&v,&d)){
    REP(i,v+1) label[i] = i;
    for(int i=1; i<=v; i++){
      for(int j=i+1; j<=v; j++){
        if(abs(fib[i] - fib[j]) < d){
          int l1 = ds(i);
          int l2 = ds(j);
          label[l1] = label[l2] = min(l1,l2);
        }
      }
    }
    int ans = 0;
    for(int i=1; i<=v; i++)
      if(i == ds(i)) ans++;
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define LOOP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
 
using namespace std;

int main() {
  ll N, sum;
  scanf("%lld", &N);
  
  vector<ll> A(N), count(N+1);
  LOOP(ll,i,1,N+1) count[i]=0;
  LOOP(ll, i, 0, N){ 
    scanf("%lld", &A[i]);
    count[A[i]]++;
  }
  
  sum = 0;
  LOOP(ll,i,1,N+1) sum += count[i]*(count[i]-1)/2;
  
  LOOP(ll,i,0,N) printf("%lld\n", sum-count[A[i]]+1);
  
  return 0;
}


Measured memory_bytes: 5760
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
cnt = [0]*8
ans = "No"
for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            cnt[i] += 1
            cnt[j+3] += 1
            if i== j:
                cnt[-2] += 1
            if i+j == 2:
                cnt[-1] += 1
for k in range(8):
    if cnt[k] >= 3:
        ans = "Yes"
        break
print(ans)

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define reg register
using namespace std;
const int MAXN = 2e5 + 10;
int n, m;
double f[MAXN], sum[MAXN];
int main() {
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; ++i) {
        scanf("%lf", &f[i]);
        sum[i] = sum[i - 1] + (f[i] + 1) / 2;
    }
    double ans = 0;
    for(reg int i = 1; i <= n - m + 1; ++i)
        ans = max(ans, sum[i + m - 1] - sum[i - 1]);
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var l = new List<Tuple<long, long>>();
            for (int i = 0; i < n; i++)
            {
                var r = ReadSplit();
                var a = r[0].Long();
                var b = r[1].Long();
                l.Add(new Tuple<long, long>(a, b));
            }
            l = l.OrderBy(x => x.Item2).ToList();
            //var last = l[n - 1].Item2;
            long now = 0;
            var ans = "Yes";
            foreach (var item in l)
            {
                now += item.Item1;
                if (now > item.Item2)
                {
                    ans = "No";
                }
            }
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 35368
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
	long long Q = 0, H = 0, S = 0, D = 0;
	long long N = 0;

	cin >> Q >> H >> S >> D;
	cin >> N;

	// 1L の最小値
	long long p1 = min(Q * 4, H * 2);
	p1 = min(p1, S);

	// 2L の最小値
	long long p2 = min(Q * 8, H * 4);
	p2 = min(p2, S * 2);
	p2 = min(p2, D);
		
	long long sum = 0;
	if (N % 2) {
		sum += p1;
	}

	long long num2 = N / 2;
	sum += num2 * p2;
		
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

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

int main() {
	int N, K; cin >> N >> K;
	int ans = 1;
	rep(i, N) {
		ans = min(ans * 2, ans + K);
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

short dp[2][1 << 20];
template<int SZ> int solve(int n, int m){
	if(SZ / 2 >= m) return solve<SZ / 2>(n, m);
	
	int ans = 0;
	vector<bitset<SZ>> b(n);
	
	rep(i, n){
		string s; cin >> s;
		rep(j, m) if(s[j] == '1') b[i][j] = 1;
	}
	rep(mask, 1 << n){
		int k = __builtin_popcount(mask);
		if(ans >= k) continue;
		
		bitset<SZ> sum;
		rep(i, n) if(mask & 1 << i) sum ^= b[i];
		if(sum.none()) ans = max(ans, k);
	}
	return ans;
};
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m;
	while(cin >> n >> m, n){
		if(m > 20){
			cout << solve<512>(n, m) << endl;
		}
		else{
			memset(dp, -1, sizeof(dp));
			vi b(n);
			rep(i, n){
				string s; cin >> s;
				rep(j, m) if(s[j] == '1') b[i] |= 1 << j;
			}
			
			dp[0][0] = 0;
			int cur = 0, next = 1;
			rep(i, n){
				memcpy(dp[next], dp[cur], sizeof(dp[cur]));
				rep(j, 1 << m) if(dp[cur][j] >= 0){
					dp[next][j ^ b[i]] = max(dp[next][j ^ b[i]], (short)(dp[cur][j] + 1));
					//dp[next][j] = max(dp[next][j], dp[cur][j]);
				}
				swap(cur, next);
			}
			cout << dp[cur][0] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7280
package main

import (
    "fmt"
)

func main() {
    var s, t []byte
    fmt.Scan(&s, &t) 

    // dp[i][j] si/tj番目までで最長の部分列
    dp := make([][][]byte, len(s)+1)
    for i := range dp {
        dp[i] = make([][]byte, len(t)+1)
    }   

    for i := 1; i < len(s)+1; i++ {
        for j := 1; j < len(t)+1; j++ {
            var li, lj, lij int 
            li = len(dp[i-1][j])
            lj = len(dp[i][j-1])
            if s[i-1] == t[j-1] {
                lij = len(dp[i-1][j-1]) + 1 
            }   
            switch {
            case li >= lj && li >= lij:
                dp[i][j] = dp[i-1][j]
            case lj >= lij:
                dp[i][j] = dp[i][j-1]
            default:
                dp[i][j] = add(dp[i-1][j-1], s[i-1])
            }   
            if i >= 3 { 
                dp[i-2][j] = []byte{}
            }   
        }   
    }   

    fmt.Println(string(dp[len(s)][len(t)]))
}

func add(bs []byte, b byte) []byte {
    nbs := make([]byte, 0, len(bs)+1)
    nbs = append(nbs, bs...)
    return append(nbs, b)
}


Measured memory_bytes: 450820
x,y;
main(){
    char c;
    for(;scanf("%d %c %d",&x,&c,&y),c!='?';){
        switch(c){
        case '+':x+=y;break;
        case '-':x-=y;break;
        case '*':x*=y;break;
        case '/':x/=y;break;
        }
        printf("%d\n",x);
    }
}

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    char now = S[0];
    int cnt = 1;
    for(int i = 1; i < N; i++){
        if(S[i] == now)continue;
        else{
            now = S[i];
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <algorithm>
#include <vector>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 300500
#define ll long long
template <class T>
IN void in(T &x)
{
	x = 0; R char c = gc;
	for (; !isdigit(c); c = gc);
	for (;  isdigit(c); c = gc)
	x = (x << 1) + (x << 3) + c - 48;
}
template <class T> IN T max(T a, T b) {return a > b ? a : b;}
template <class T> IN T min(T a, T b) {return a < b ? a : b;}
int n, tup, tdown, w, h, ans;
int up[MX], down[MX];
struct Cood {int x, y;} dat[MX];
IN bool operator < (const Cood &x, const Cood &y) {return x.x < y.x;}
namespace SGT
{
	#define ls (now << 1)
	#define rs (now << 1 | 1)
	int tag[MX << 2], mx[MX << 2];
	IN void pushup(R int now) {mx[now] = max(mx[ls], mx[rs]);}
	IN void pushdown(R int now)
	{
		if (tag[now])
		{
			mx[ls] += tag[now], tag[ls] += tag[now];
			mx[rs] += tag[now], tag[rs] += tag[now];
			tag[now] = 0;
		}
	}
	void modify(R int now, R int lef, R int rig, R int lb, R int rb, R int val)
	{
		if (lef >= lb && rig <= rb) return tag[now] += val, mx[now] += val, void();
		int mid = lef + rig >> 1; pushdown(now);
		if (lb <= mid) modify(ls, lef, mid, lb, rb, val);
		if (rb >  mid) modify(rs, mid + 1, rig, lb, rb, val);
		pushup(now);
	}
	int query(R int now, R int lef, R int rig, R int lb, R int rb)
	{
		if (lef >= lb && rig <= rb) return mx[now];
		int mid = lef + rig >> 1, ret = -INT_MAX; pushdown(now);
		if (lb <= mid) ret = query(ls, lef, mid, lb, rb);
		if (rb >  mid) ret = max(ret, query(rs, mid + 1, rig, lb, rb));
		return ret;
	}
}
void solve()
{
	int mid = h >> 1;
	tup = tdown = 0;
	up[0] = down[0] = 1;
	std::sort(dat + 2, dat + 1 + n);
	SGT::modify(1, 1, n, 1, n, h << 1);
	for (R int i = 2; i <= n; ++i)
	{
		SGT::modify(1, 1, n, 1, i - 1, (dat[i].x - dat[i - 1].x) << 1);
		ans = max(ans, SGT::mx[1]);
		if (dat[i].y >= mid)
		{
			SGT::modify(1, 1, n, up[tup], i - 1, (dat[i].y - h) << 1);
			W (tup && dat[up[tup]].y >= dat[i].y)
			{
				SGT::modify(1, 1, n, up[tup - 1], up[tup] - 1, (dat[i].y - dat[up[tup]].y) << 1);
				--tup;
			}
			up[++tup] = i;
		}
		else
		{
			SGT::modify(1, 1, n, down[tdown], i - 1, -(dat[i].y << 1));
			W (tdown && dat[down[tdown]].y <= dat[i].y)
			{
				SGT::modify(1, 1, n, down[tdown - 1], down[tdown] - 1, (dat[down[tdown]].y - dat[i].y) << 1);
				--tdown;
			}
			down[++tdown] = i;
		}
	}
}
int main(void)
{
	in(w), in(h), in(n); ++n;
	for (R int i = 2; i <= n; ++i) in(dat[i].x), in(dat[i].y);
	dat[++n] = {w, h};
	solve();
	std::memset(SGT::tag, 0, sizeof(SGT::tag));
	std::memset(SGT::mx, 0, sizeof(SGT::mx));
	std::swap(w, h);
	for (R int i = 2; i <= n; ++i) std::swap(dat[i].x, dat[i].y);
	solve();
	printf("%d", ans);
}

Measured memory_bytes: 12800
#include<cstdio>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int a[3];
int main()
{
    for(int i=0;i<3;i++)
    scanf("%d",&a[i]);
    sort(a,a+3);
    printf("%d\n",a[0]+a[1]);
    return 0;
}


Measured memory_bytes: 128
main(a,b,c){for(;scanf("%d%d%d",&a,&b,&c),~a;printf("%02d:%02d:%02d\n%02d:%02d:%02d\n",a/3600,a/60%60,a%60,b/3600,b/60%60,b%60))a=7200-a*3600-b*60-c,b=a*3;exit(0);}

Measured memory_bytes: 612
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
const int inf=0x7fffffff;
typedef long long int ll;
using namespace std;
char w[21]=" ";
char t[1000+10];
char tt[1000+1000];
char eof[]="END_OF_TEXT";
void turn(){
	int i=0;
	while(tt[i]!='\0'){tt[i]=tolower(tt[i]);i++;}
}
int main()
{
//#ifdef DEBUG
//	freopen("in", "r", stdin);
////	freopen("out", "w", stdout);
//#endif
	scanf("%s", t);
	//cout<<t<<endl;
	strcat(w,t);
	strcat(w," ");
	//cout<<w<<endl;
	int cnt=0;
	memset(t,0,sizeof(t));
	memset(tt,0,sizeof(tt));
	while(fgets(t,sizeof(t),stdin)!=NULL){
//cout<<t<<endl;
		if(!strcmp(w,eof))break;
		strcat(tt,".");
		strcat(tt,t);
		strcat(tt,".");
	}
	for(int i=0;tt[i]!='\0';i++){
		if(tt[i]=='.'||tt[i]=='\n')tt[i]=' ';
	}
	turn();
	char *cur=tt+1;
	char *tmp;
	//cout<<tt<<endl;
	while(1){
		tmp=strstr(cur,w);
		if(!tmp)break;
		cur=tmp+1;
	//	cout<<*cur<<endl;
//		while(*cur!='\0'&&isalpha(*cur))cur++;
		cnt++;
	//	cout<<cur-tt<<endl;
	}
	printf("%d\n", cnt);
	//insert code
	return 0;
}
//1_9_a.cc

Measured memory_bytes: 1156
#include<iostream>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{int n,an;
	cin>>n>>an;
	for(int x=0;x<=n;x++)
	{
		for(int y=0;y<=n-x;y++)
		{
			int z=n-x-y;
			if(10000*x+5000*y+1000*z==an)
			{
				cout<<x<<" "<<y<<" "<<z;
				system("pause");
				return 0;
			}
		}
	}
	cout<<"-1 -1 -1";
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }

const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 500;

int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  int sz[MAX_N / BACKET + 1];
  char s[32];
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
    
  fgets(s, sizeof(s), stdin);
  sscanf(s, "%d %d", &N, &Q);
      
  while(Q--) {
    int t, a, b;
    fgets(s, sizeof(s), stdin);
    sscanf(s, "%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      bool update = small[curr] == A[a] && sz[curr] == 1;
      A[a] = b;
      if(small[curr] == b) {
        ++sz[curr];
      } else if(small[curr] > b) {
        small[curr] = b;
        sz[curr] = 1;
      } else if(update) {
        small[curr] = INF;
        sz[curr] = 1;
        for(int i = 0; i < BACKET; i++) {
          if(small[curr] == A[curr * BACKET + i]) {
            ++sz[curr];
          } else if(small[curr] > A[curr * BACKET + i]) {
            small[curr] = A[curr * BACKET + i];
            sz[curr] = 1;
          }
        }
      }
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        if(ret > small[begin - 1]) for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        if(ret > small[end]) for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}

Measured memory_bytes: 5124
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &N, &K)

  if (N+1)/2 >= K {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

void solve(){
    int a, b, c;
    int count = 0;
    cin >> a >> b >> c;
    for(int i = a; i <= b; i++){
        if(c%i == 0){
            count++;
        }
    }
    cout << count << endl;
}

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

Measured memory_bytes: 3076
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        
        static List<(long p, long index)> factring(long N ,long current= 2,
            List<(long p, long index)> rt=null)
        {
            if(rt == null)
                rt=new List<(long p, long index)>();
            if (N == 1)
                return rt;
            long tmp = N;
            for (long i = current; i * i <= N; i++)
            {
                long dex = 0;
                while (tmp % i == 0)
                {
                    tmp = tmp / i;
                    dex++;
                }
                if (dex != 0)
                {
                    rt.Add((i, dex));
                    rt = factring(tmp, current + 1, rt);
                    return rt;
                }
            }
            rt.Add((N, 1));
            return rt;
            

        }
        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);
                //Console.ReadLine();
                var vals = Console.ReadLine().Split(' ')
                    .Select(x => long.Parse(x)).ToList();
                long N = vals[0];

                List<(long p, long index)> ft = factring(N);
                
                
                long ans = 0;
                foreach (var f in ft)
                {
                    long usd = 0;
                    for (long i = 0; usd + i + 1 <= f.index; i++)
                    {
                        usd += i + 1;
                        ans++;
                    }
                }



                Console.WriteLine(ans);
                Console.Out.Flush();
            }
        }



    }

}


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

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000000000
int n;

int main(){
    ll n,a,b; cin >> n >> a >> b;
    
    ll ans1 = n/(a+b);
    ll ans2 = n%(a+b);
    if(ans2 != 0){
    	if(a == 0){
    		ans2 = 0;
    	} else{
            if(ans2 >= a) ans2 = a;
    	}
    }
    
    cout << ans1*a + ans2 << endl;
    return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main()
{

    int t,n,i;

    string s;
        cin>>n;
            vector<int>arra(n);
        int ans=0;
        for(i=0;i<n;i++)
        {
            cin>>arra[i];
            ans=ans^arra[i];
        }
        for(i=0;i<n;i++)
        {
            arra[i]=ans^arra[i];
        }
        for(i=0;i<n;i++)
        cout<<arra[i]<<" ";
    return 0;
}



Measured memory_bytes: 4028
#include<stdio.h>
int main(void)
{
	int h,w,i,j;
	char s[1000][1000];
	scanf("%d %d", &h, &w);
	for(i=1; i<=h; i++)
	scanf("%s", &s[i]);
	for(i=1; i<=h*2; i++)
	{
		for(j=0; j<w; j++)
		printf("%c", s[(i+1)/2][j]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    string S;  cin >> S;

    string yy = S.substr(0, 2);
    string mm = S.substr(2, 2);

    string ans;
    if (1 <= stoi(mm) && stoi(mm) <=12) {
        if (1 <= stoi(yy) && stoi(yy) <= 12) ans = "AMBIGUOUS";
        else ans = "YYMM";
    } else {
        if (1 <= stoi(yy) && stoi(yy) <= 12) ans = "MMYY";
        else ans = "NA";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys

sys.setrecursionlimit(10**9)

def dfs(h,w,start):
    if S[h][w]=="#":
        black[start[0]][start[1]]+=1
    else:
        white[start[0]][start[1]]+=1
    
    visited[h][w]=1
    if h!=0:
        if visited[h-1][w]==-1 and S[h-1][w]!=S[h][w]:
            dfs(h-1,w,start)
    if w!=0:
        if visited[h][w-1]==-1 and S[h][w-1]!=S[h][w]:
            dfs(h,w-1,start)        
    if h!=H-1:
        if visited[h+1][w]==-1 and S[h+1][w]!=S[h][w]:
            dfs(h+1,w,start)        
    if w!=W-1:
        if visited[h][w+1]==-1 and S[h][w+1]!=S[h][w]:
            dfs(h,w+1,start)    
    return 

H,W=map(int,input().split())

S=[]

for _ in range(H):
    S.append(list(input()))

visited=[[-1 for j in range(W)] for i in range(H)]
black=[[0 for j in range(W)] for i in range(H)]
white=[[0 for j in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if visited[i][j]==-1:
            dfs(i,j,[i,j])
        #print(visited)

ans=0
for i in range(H):
    for j in range(W):
        ans+=black[i][j]*white[i][j]
"""
print(S)
print(black)
print(white)
"""
print(ans)

Measured memory_bytes: 142580
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
    c = input()
    nm = 0
    rn = 0
    for i in c:
        if i == "R":
            rn += 1

    for i in c[:rn:]:
        if i == "W":
            nm += 1

    print(nm)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 70172
#include<iostream>
using namespace std;
int main() {
    int n, ans = 0;
    int cent[] = { 1, 5, 10, 25 };
    cin >> n;
    for (int i = 3; i >= 0; i--) {
        if (n / cent[i] != 0) {
            ans += n / cent[i];
            n = n % cent[i];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<stdio.h>

int main(void){

  int i,j;
  int H,W;

  while(1){
    scanf("%d %d",&H,&W);


    if(H==0 && W==0)
      break;

    else{
      for(i=0;i<H;i++){
        if(i%2 == 0){
          for(j=0;j<W;j++){
            if(j%2==0)
              printf("#");
            else
              printf(".");
          }
        }
        else{
          for(j=0;j<W;j++){
            if(j%2==0)
              printf(".");
            else
              printf("#");
          }
        }
        printf("\n");
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 572
#abc100 b
d,n=map(int,input().split())

def func(x):
    if x%100!=0:
        return 0
    return func(int(x/100))+1

i=1
cnt=0
while True:
    if func(i)==d:
        cnt+=1
    if cnt==n:
        print(i)
        break
    i+=1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int n; cin>>n;
  int d[n][2];
  rep(i,n)rep(j,2)cin>>d[i][j];
  string ans="No";
  
  for(int i=2;i<n;i++){
    if(d[i][0]==d[i][1] && d[i-1][0]==d[i-1][1]&&d[i-2][0]==d[i-2][1])ans="Yes";
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
int main(){
    double a[1000];
    int n;
    double m=0;
    double ans=0;
    int i;
    while(scanf("%d",&n),n!=0){
        m=0;
        ans=0;
        for(i=0;i<n;i++){
            scanf("%lf",&a[i]);
            m+=a[i];
        }
        m/=(double)n;
        for(i=0;i<n;i++){
            ans+=pow(a[i]-m,2.0);
        }
        ans/=(double)n;
        printf("%lf\n",sqrt(ans));
    }
    return 0;
}

Measured memory_bytes: 660
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5;
int dp[maxn+5];
bool is_prime[maxn+5];
void Prime(){
	is_prime[1]=1;
	for(long long i=2;i<=maxn;i++){
		if(!is_prime[i]){
			for(long long j=i*i;j<=maxn;j+=i){
				is_prime[j]=1;
			}
		}
	}
}
int main(){
	Prime();
	for(int i=1;i<=maxn;i++){
		if(!is_prime[i]&&!is_prime[(i+1)/2]){
			dp[i]=dp[i-1]+1;
		}else{
			dp[i]=dp[i-1];
		}
	}
	int q,l,r;
	cin>>q;
	while(q--){
		cin>>l>>r;
		cout<<dp[r]-dp[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  string s;
  cin >> s;
  bool ok = true;
  if(s[2]!=s[3]) ok = false;
  if(s[4]!=s[5]) ok = false;
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
    int N, d[100000];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> d[i];
    
    sort(d, d + N);
    int num_of_K = d[N / 2] - d[N / 2 - 1];
    cout << num_of_K << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[][] dist = new long [n][n];
		for (int i=0;i<n;i++) {
			for (int j=0;j<n;j++) {
				dist[i][j]=sc.nextLong();
			}
		}

		System.out.println(calc(dist));
	}

	static long calc(long[][] dist) {
		int n = dist[0].length;
		boolean [][] omit = new boolean[n][n];


		for(int i=0;i<n;i++) {
			for (int j=i+1;j<n;j++) {
				for(int k=j+1;k<n;k++) {
					if (dist[i][j] + dist[i][k] < dist[j][k]) {
						return -1;
					} else if (dist[i][j] + dist[i][k] == dist[j][k]) {
						omit[j][k]=true;
					}

					if (dist[i][j] + dist[j][k] < dist[i][k]) {
						return -1;
					} else if (dist[i][j] + dist[j][k] == dist[i][k]) {
						omit[i][k]=true;
					}

					if (dist[i][k] + dist[j][k] < dist[i][j]) {
						return -1;
					} else if (dist[i][k] + dist[j][k] == dist[i][j]) {
						omit[i][j]=true;
					}
				}
			}
		}

		long total = 0;
		for(int i=0;i<n;i++) {
			for (int j=i+1;j<n;j++) {
				if(!omit[i][j]) {
					total += dist[i][j];
				}
			}
		}
		return total;
	}

}


Measured memory_bytes: 61900
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int dp[30010][4];

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<vector<int>> next(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; i--)
    {
        for (int j = 0; j < 10; j++)
        {
            next[i][j] = next[i+1][j];
        }
        next[i][s[i]-'0'] = i;        
    }

    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++)
        {
            if (next[i][j] >= n) continue;
            dp[next[i][j]+1][1] += dp[i][0];
            dp[next[i][j]+1][2] += dp[i][1];
            dp[next[i][j]+1][3] += dp[i][2];
        }
    }

    int ans = 0;
    for (int i = 0; i <= n; i++)
    {
        ans += dp[i][3];
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define int long long int
#define pll pair<ll,ll>
#define un unsigned
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000009
#define eps 0.0000000001
#define inf 10000000000001
#define all(x) (x).begin(),(x).end()
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define debug(x) cerr<<"LINE: "<<__LINE__<<" || "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(auto i=s;i<n;i++)
#define rloop(i,n,b) for(auto i=n-1;i>=b;i--)
using namespace std;

int a[101],dp[100005];

int f(int k,int n)
{	
	if(dp[k]!=-1) return dp[k];
	loop(i,0,n)
	{
		if(k-a[i]==0) return dp[k] = 1; //curr player removes stone & pile becomes empty
		if(k-a[i]>0 && f(k-a[i],n)==0) return dp[k] = 1; //curr player can make a move & next player cant, then curr player wins
	}
	return dp[k] = 0; //curr player isnt able to make a single move so it loses
}

signed main()
{
	fastio(0);
	int n,k;
	cin>>n>>k;
	loop(i,0,n)	cin>>a[i];
	memset(dp,-1,sizeof(dp));
	if(f(k,n)) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

Measured memory_bytes: 4224