akhauriyash/Code-Regression huggingface dataset:
R,G,B,n=map(int, input().split())
cnt=0
for r in range(n+1):
    for g in range(n+1):
        b=(n-r*R-g*G)/B
        #print(r,g,b)
        if b>=0:
            if b==int(b):
                cnt+=1

print(cnt)

Measured memory_bytes: 73628
let HWK: [Int] = readLine()!.split(separator: " ").map { Int($0)! }
let cs: [[Int]] = (1...HWK[0]).map { _ in readLine()!.map { $0 == "#" ? 1 : 0 } }
var res: Int = 0

var W: Int = 1
for _ in 0..<HWK[0] + HWK[1] { W *= 2 }

for bit in 0..<W {
    var temp = cs
    var num2 = String(bit, radix: 2)
    num2 = String(repeating: "0", count: HWK[0] + HWK[1] - num2.count) + num2
    var bCount = 0
    
    for (k, opt) in num2.enumerated() {
        if opt == "0" {
            if k < HWK[0] {
                let i = k
                temp[i] = Array(repeating: 0, count: HWK[1])
            } else {
                let j = k - HWK[0]
                for i in 0..<HWK[0] { temp[i][j] = 0 }
            }
        }
    }
    for i in 0..<HWK[0] {
        bCount += temp[i].reduce(0, +)
    }
    if bCount == HWK[2] { res += 1}
}
print(res)  // (๑•ૅㅁ•๑)

Measured memory_bytes: 8316
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[n + 1];
    for(int i = 0; i < n; i++) cin >> A[i];
    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        int minA = A[i], idx = -1;
        for(int j = i + 1; j < n; j++)
        {
            if(A[j] < minA)
            {
                minA = A[j];
                idx = j;
            }
        }
        if(idx != -1)
        {
            swap(A[i], A[idx]);
            cnt++;
        }
    } 
    for(int i = 0; i < n; i++)
    {
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3208
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int count=0;
		for(int i=a; i>0; i--){
			if(a%i==0 && b%i==0){
				count++;
				if(count==k){
					System.out.println(i);
				}
			}
		}
	}
}

Measured memory_bytes: 23764
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, M = Scanner.map_int()
    A = [-a for a in Scanner.map_int()]
    heapq.heapify(A)
    for _ in range(M):
        a = heapq.heappop(A)
        a = -(-a // 2)
        heapq.heappush(A, a)
    print(-sum(A))


if __name__ == "__main__":
    main()


Measured memory_bytes: 90788
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < s.size(); i++)
    {
        sum += s[i] - '0';
        sum = sum % 9;
    }
    printf(sum ? "No\n" : "Yes\n");
    return 0;
}

Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,a,b;
  while(cin>>n>>a>>b,a||n||b){
    vector<int>in(n);
    rep(i,n)cin>>in[i];
    double sum=0;
    rep(i,n)sum+=in[i];
    sum*=100-b;
    if(in[a-1]==0)cout<<0<<endl;
    else cout<<(int)(sum/in[a-1])<<endl;
  }

}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			var d=long.Parse(Console.ReadLine());
			if(d==0)break;
			Sol mySol=new Sol(d);
			Console.WriteLine(mySol.Ans);
		}
	}
}

class Sol{
	long ans;
	public long Ans{
		get{return ans;}
	}
	
	public Sol(long n){
		ans=2*n*4+2*(n*n-SafeArea(n));
	}
	
	long SafeArea(long N){
		// X=CとY=CとX*Y=C (C:=N/2)　で囲まれた
		// 領域の中の格子点四角形の個数を数えて×4
		// Y<X領域で台形分割する
		if(N==2||N==4)return 0L;
		long Area=0;
		long trapezoid=0;
		long C=N/2;

		long X=C;
		long Y=2;

		long Xnext=0;

		while(true){
			if(C%Y==0)Xnext=C/Y;
			if(C%Y!=0)Xnext=C/Y+1;
			//台形×8
			trapezoid=((X-Y)+(Xnext-Y))*(X-Xnext)*4;
			Area+=trapezoid;

			X=Xnext;
			if(X==Y)break;
			Y++;
			if(X==Y)break;
		}
		return Area;
	}
}

Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n;
  cin >> n;
  vector<double> p(n);
  for(ll i=0;i<n;i++) cin >> p[i];
  vector<vector<double>> dp(n+1,vector<double>(n+1));
  dp[0][0]=1.0;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<=i;j++) {
      dp[i+1][j]+=dp[i][j]*(1-p[i]);
      dp[i+1][j+1]+=dp[i][j]*p[i];
    }
  }
  double ans=0;
  for(ll i=n/2+1;i<=n;i++) {
    ans+=dp[n][i];
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*16
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long k, a, b;
	cin >> k >> a >> b;
	long long ans = 1;
	if (a-1 >= k||a+2 >= b) {
		cout << ans + k << endl;
		return 0;
	}
	k -= a - 1;
	ans = a;
	long long next_go = k / 2;
	ans += next_go * (b - a);
	next_go *= 2;
	k -= next_go;
	if (k == 1) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,e;
	double d;
	scanf("%d %d",&a,&b);
	c=a/b;
	d=1.0*a/b;
	e=a%b;
	printf("%d %d %.8lf\n",c,e,d);
	return 0;
}

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

int *s;
int *t;
int n, q;

void solve(){
  int count = 0;
  sort(s, s+n);
  sort(t, t+q);
  for(int i = 0; i < q; i++){
    for(int j = 0; j < n; j++){
      if(s[j] == t[i]){
        count++;
        break;
      }
    }
  }
  cout << count << endl;
  return ;
}


int main(){
  cin >> n;
  s = new int[n];
  for(int i = 0; i < n; i++) cin >> s[i];
  cin >> q;
  t = new int[q];
  for(int i = 0; i < n; i++) cin >> t[i];
  solve();
  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    ll a;
    int b1,b2;
    scanf("%lld %d.%d",&a, &b1,&b2);
    int b=100*b1+b2;
    cout << (ll)(a*b)/100;
}


Measured memory_bytes: 3684
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			long k = sc.nextLong();
			
			ArrayList<Long> data = new ArrayList<>();
			HashMap<Long, Long> map = new HashMap<>();
			for(int i = 0; i < n;i++){
				long a = sc.nextInt();
				long b = sc.nextInt();
				if(map.containsKey(a)){
					map.put(a, map.get(a) + b);
				}
				else{
					map.put(a,b);
					data.add(a);
				}
			}
			Collections.sort(data);
			
			long sum = 0;
			for(long ind: data){
				long val = map.get(ind);
				sum += val;
				if(sum >= k){
					System.out.println(ind);
					break;
				}
			}

		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

using namespace std;
long long din[200005],n,i,v[200005];
long long abs1 (long long a)
{
    if (a<0)
    {
        return -a;
    }
    return a;
}
int main()
{
    #ifdef HOME
    ifstream cin("date.in");
    ofstream cout("date.out");
    #endif // HOME
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>v[i];
        din[i]=10000000005;
    }
    din[0]=10000000005;
    din[1]=0;
    for (i=2;i<=n;i++)
    {
        din[i]=min(din[i-1]+abs1(v[i-1]-v[i]),din[i-2]+abs1(v[i-2]-v[i]));
    }
    cout<<din[n]<<'\n';
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N; 
    map<char,int> m; 
    rep(i,N){
       string S; cin >> S;
       m[S[0]]++;
    }
    int A[5]={m['M'],m['A'],m['R'],m['C'],m['H']};
    ll ans = 0;
    rep(i,3){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans+=(ll)A[i]*A[j]*A[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#define maxn 1010
using namespace std;
int n,m,i,j,x,y,s,sa,sb;
char a[maxn][maxn];
int main()
{
	scanf("%d%d%d%d",&n,&m,&x,&y);
	for(i=1;i<=n;i++)
		for(j=1;j<=m;j++)
			a[i][j]='.';
	if(n*m&1)
	{
		s=n*m>>1;
		sa=n*(m>>1);
		sb=m*(n>>1);
		if(x+y>s||x>sa||y>sb)
		{
			puts("NO");
			return 0;
		}
		if((sa-x)%2==1&&(y==s-x)&&x>=2&&y>=2&&n>=3&&m>=3)
		{
			a[n-2][m-2]='<';a[n-2][m-1]='>';
			a[n-1][m-2]='^';a[n][m-2]='v';
			a[n-2][m]='^';a[n-1][m]='v';
			a[n][m-1]='<';a[n][m]='>';
			x-=2;y-=2;
			for(i=1;i<m-2;i+=2)
				if(x)
				{
					x--;
					a[n][i]='<';
					a[n][i+1]='>';
				}
			for(i=1;i<n-2;i+=2)
				if(y)
				{
					y--;
					a[i][m]='^';
					a[i+1][m]='v';
				}
			for(i=1;i<n;i+=2)
				for(j=1;j<m;j+=2)
				{
					if(i==n-2&&j==m-2)break;
					if(x>1)
					{
						a[i][j]='<';
						a[i][j+1]='>';
						a[i+1][j]='<';
						a[i+1][j+1]='>';
						x-=2;
					}else
					if(x==1)
					{
						a[i][j]='<';
						a[i][j+1]='>';
						//i--;
						x--;
					}else
					if(y>1)
					{
						a[i][j]='^';
						a[i][j+1]='^';
						a[i+1][j]='v';
						a[i+1][j+1]='v';
						y-=2;
					}else
					if(y==1)
					{
						a[i][j]='^';
						a[i+1][j]='v';
						//j--;
						y--;
					}
				}
					
			puts("YES");
			for(i=1;i<=n;i++)
			{
				for(j=1;j<=m;j++)
					putchar(a[i][j]);
				putchar('\n');
			}
			return 0;
		}
	}
	if(n&1)
		for(i=1;i+3<=m;i+=4)
		{
			if(x<2)break;
			a[n][i]='<';
			a[n][i+1]='>';
			a[n][i+2]='<';
			a[n][i+3]='>';
			x-=2;
		}
	if(n%2==1&&x%2==1&&i<m)
	{
		a[n][i]='<';
		a[n][i+1]='>';
		x--;
	}
	if(m&1)
		for(i=1;i+3<=n;i+=4)
		{
			if(y<2)break;
			a[i][m]='^';
			a[i+1][m]='v';
			a[i+2][m]='^';
			a[i+3][m]='v';
			y-=2;
		}
	if(m%2==1&&y%2==1&&i<n)
	{
		a[i][m]='^';
		a[i+1][m]='v';
		y--;
	}
	for(i=1;i<n;i+=2)
		for(j=1;j<m;j+=2)
		{
			if(x>1)
			{
				a[i][j]='<';
				a[i][j+1]='>';
				a[i+1][j]='<';
				a[i+1][j+1]='>';
				x-=2;
			}else
			if(x==1)
			{
				a[i][j]='<';
				a[i][j+1]='>';
				//i--;
				x--;
			}else
			if(y>1)
			{
				a[i][j]='^';
				a[i][j+1]='^';
				a[i+1][j]='v';
				a[i+1][j+1]='v';
				y-=2;
			}else
			if(y==1)
			{
				a[i][j]='^';
				a[i+1][j]='v';
				//j--;
				y--;
			}
		}
	if(x>0||y>0)
	{
		puts("NO");
		return 0;
	}
	puts("YES");
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
			putchar(a[i][j]);
		putchar('\n');
	}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<string> res;
  for (int i = 0; i < N; ++i) {
    string str;
    cin >> str;
    if (str == string(M, '.')) continue;
    res.push_back(str);
  }
  
  for (int j = 0; j < res[0].size(); ++j) {
    bool all = true;
    for (int i = 0; i < res.size(); ++i) {
      if (res[i][j] != '.') all = false;
    }
    if (all) {
      for (int i = 0; i < res.size(); ++i) {
       	res[i].erase(res[i].begin() + j); 
      }
      --j;
    }
  }
  for (int i = 0; i < res.size(); ++i) {
    cout << res[i] << endl;
  }
}
    

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s;
    cin >> s;
    size_t findex = s.find_first_of('A');
    size_t lindex = s.find_last_of('Z');
    cout << lindex - findex + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Collections;

/**
 * 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;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {

        PriorityQueue<int[]> all = new PriorityQueue<>((array1,array2)->-array1[0]+array2[0]);
        HashSet<Integer> kindset = new HashSet<>();
        PriorityQueue<Integer> next = new PriorityQueue<>();
        PriorityQueue<Integer> newkind = new PriorityQueue<>(Collections.reverseOrder());

        int N = in.nextInt();
        int K = in.nextInt();

        for (int i=0; i<N; i++) {
            int[] temp = new int[2];
            temp[1] = in.nextInt();
            temp[0] = in.nextInt();
            all.add(temp);

        }

        long dsum = 0;
        for (int i=0; i<=K-1; i++) {
            int[] temp = new int[2];
            temp = all.poll();

            dsum+=temp[0];

            if(kindset.contains(temp[1])){
                next.add(temp[0]);
            } else {
                kindset.add(temp[1]);
            }
        }
        long knum = kindset.size();

        for (int i=K; i<=N-1; i++) {
            int[] temp = new int[2];
            temp = all.poll();

            if(!kindset.contains(temp[1])){
                kindset.add(temp[1]);
                newkind.add(temp[0]);
            }
        }

        long ans = dsum + knum*knum;
        long temp = ans;
        while (newkind.size() != 0 && next.size() != 0){
            int p = newkind.poll();
            int m = next.poll();
            knum++;
            temp = temp + p - m + 2*knum - 1;
            ans = Math.max(ans, temp);
        }
        out.println(ans);
    }

}
}



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

#define INFTY (1 << 30);
typedef long long ll;

int main(void) {
  ll N;
  string S;
  cin >> S;
  N = S.size();

  char head = S[0];
  int counter_one = 0;
  int counter_zero = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '1')  {
      counter_one ++;
    } else {
      counter_zero++;
    }
  }
  if (counter_one > counter_zero)
    cout << counter_zero * 2 << endl;
  else
    cout << counter_one * 2 << endl;
  

  return 0;
}


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

int main(void){
	int H, W, M;
	cin >> H >> W >> M;
	int r[H], c[W];
	rep(i,H) r[i] = 0;
	rep(i,W) c[i] = 0;
	map<pair<int,int>,bool> b;

	vector<int> hv, wv;
	rep(i,M) {
		int hh, ww;
		cin >> hh >> ww;
		hh--; ww--;
		hv.push_back(hh); wv.push_back(ww);
		r[hh]++; c[ww]++;
		b[make_pair(hh,ww)] = true;
	}
	set<int> h(hv.begin(), hv.end()), w(wv.begin(), wv.end());

	int max_h = 0, max_w = 0;
	vector<int> hm, wm;
	for (int hh : h) {
		if (r[hh] > max_h) {
			max_h = r[hh];
			hm.clear();
			hm.push_back(hh);
		}
		else if (r[hh] == max_h) hm.push_back(hh);
	}
	for (int ww : w) {
		if (c[ww] > max_w) {
			max_w = c[ww];
			wm.clear();
			wm.push_back(ww);
		}
		else if (c[ww] == max_w) wm.push_back(ww);
	}

	int ans = max_h + max_w;
	bool flag = true;
	for (int hh : hm) {
		for (int ww : wm) {
			if (b[make_pair(hh,ww)]==false) {
				flag = false;
				break;
			}
			if (!flag) break;
		}
	}

	if (flag) ans--;
	cout << ans << endl;

		return 0;
}


Measured memory_bytes: 75976
#include <stdio.h>
#include <algorithm>
typedef long long ll;
int A[100000];
int B[100000];
int C[100000];
int N;
int main(){
        scanf("%d",&N);
        for(int j = 0; j < N; j++) scanf("%d",A+j);
        for(int j = 0; j < N; j++) scanf("%d",B+j);
        for(int j = 0; j < N; j++) scanf("%d",C+j);
        std::sort(A,A+N);
        std::sort(B,B+N);
        std::sort(C,C+N);

        ll ans = 0;
        for(int i = 0; i < N; i++){
                ans += (std::lower_bound(A,A+N,B[i])-A)*((C+N-std::upper_bound(C,C+N,B[i])));
        }
        printf("%lld\n",ans);

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll nCr(int n, int r)
{
    ll ans = 1;
    for (int i = n; i > n - r; --i)
    {
        ans = ans * i;
    }
    for (int i = 1; i < r + 1; ++i)
    {
        ans = ans / i;
    }
    return ans;
}

int main()
{
    int N;
    int ans = 0;
    cin >> N;
    vector<int> S(N);
    for (int i = 0; i < N;i++)
    {
        cin >> S[i];
        ans += S[i];
    }
    if(ans % 10 != 0){
        cout << ans << endl;
    }
    else{
        int minimum = 999;
        for (int i = 0; i < N; i++)
        {
            if(S[i] % 10 != 0){
                minimum = min(minimum, S[i]);
            }
        }
        if(minimum == 999){
            cout << 0 << endl;
        }
        else{
            cout << ans - minimum << endl;
        }
    }
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7
n = gets.to_i

h = Array.new(60,0)
bi = [1]
59.times {bi << bi[-1] * 2 % mod}

gets.split.each do |e|
    e = e.to_i
    e.bit_length.times {|i| h[i] += e[i]}
end

ans = 0
h.each_with_index do |v, i|
    ans = (ans + v * (n - v) * bi[i]) % mod
end

puts ans

Measured memory_bytes: 32412
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int H,W; cin >> H >> W;
    vector<vector<char>> A(H, vector<char>(W));
    rep(i,H) rep(j,W) cin >> A[i][j];

    vector<int> B(H+W-2,1);
    rep(i,H-1) B[i] = 0;
    do {
        vector<vector<char>> C(H, vector<char>(W,'.'));
        C[0][0] = '#';
        int x = 0;
        int y = 0;
        for (auto i : B) {
            if (i) {
                y++;
                C[x][y] = '#';
            } else {
                x++;
                C[x][y] = '#';
            } 
        }
        if (A == C) {
            cout << "Possible" << endl;
            return 0;
        }
    } while (next_permutation(all(B)));

    cout << "Impossible" << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var s = Integer.parseInt(readInputLine())
    
    // コラッツ予想では必ず 4 -> 2 -> 1 -> 4 -> ... のループに入るとなっている。
    // 最初に1 or 2 or 4が現れたときのn + 3がmとなる。

    var count = 1

    while (true) {
        if (s == 1 || s == 2 || s == 4) {
            println("${count + 3}")
            return
        }
        if (s % 2 == 0) {
            s /= 2
        } else {
            s = 3 * s + 1
        }
        count++
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 29856
def trial_divishion(n):
    factors = []
    while n % 2 == 0:
        factors.append(2)
        n //= 2
    
    f = 3
    while f * f <= n:
        if n % f == 0:
            factors.append(f)
            n //= f
        else:
            f += 2
            
    if n != 1:
        factors.append(n)
        
    return factors
    
a, b = map(int, input().split())
print(len(set(trial_divishion(a)) & set(trial_divishion(b))) + 1)

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

int main (){
    int A, B, price;
    cin >> A >> B;
    if (A >= 13)
    {
        price = B;
    }
    else if (5 < A && A < 13)
    {
        price = B / 2;
    }
    else
    {
        price = 0;
    }

    cout << price << endl;
    
    
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int, char**)
{
	long N, K;
	cin >> N >> K;
	long count = 0;
	for (long i = 0; i < N; ++i)
	{
		long h;
		cin >> h;
		if (h >= K)	++count;
	}
	cout << count << endl;
	return 0;
}


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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> X(N);
  for (auto& e : X)cin >> e;
  int ans = INT_MAX;
  for (int i = 1; i <= 100; ++i) {
    int sum = 0;
    for (auto& e : X)sum += (e - i) * (e - i);
    ans = min(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
num_list = [int(i) for i in input().split()]

result = 0

if num_list[0] < num_list[1]:
    A = num_list[0]
    B = num_list[1]
else:
    A = num_list[1]
    B = num_list[0]

while True:
    amari = A % B
    if amari == 0:
        break
    A = B
    B = amari

#最大公約数 B

#最小公倍数
result =  num_list[0] * num_list[1] // B

print(result)


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

using ll = long long int;

typedef pair<int, int> P;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;

ll l[MAX_N];
ll r[MAX_N];

pair<ll, ll> p[MAX_N];

ll min_r = INF;
ll max_l = -1L;

inline bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  return a.first < b.first || (a.first == b.first && a.second > b.second);
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lld %lld", &(l[i]), &(r[i]));
    max_l = max(max_l, l[i]);
    min_r = min(min_r, r[i]);
  }

  ll ans = 0L;

  // for case that a part of group is singleton
  for (int i = 0; i < n; ++i) {
    ans = max(ans, max(min_r - max_l + 1, 0LL) + r[i] - l[i] + 1L);
  }

  for (int i = 0; i < n; ++i) {
    p[i].first = max(min_r - l[i] + 1L, 0LL);   // first: fixed right
    p[i].second = max(r[i] - max_l + 1L, 0LL);  // second: fixed left
  }

  sort(p, p + n, cmp);

  ll part = p[0].second;
  for (int i = 1; i < n; ++i) {
    ans = max(ans, part + p[i].first);
    part = min(part, p[i].second);
  }

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

  return 0;
}


Measured memory_bytes: 3328
a = [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]
print(a[int(input()) - 1])

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

#define int long long
signed main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int bits[61];
    int pw[61];
    pw[0] = 1;
    for (int i = 1; i < 61; ++i)
        pw[i] = pw[i - 1] * 2;

    memset(bits, 0, sizeof bits);
    int ans = 0;
    int mod = 1000000007;
    for (int z = 0; z < n; ++z) {
        int i = a[z];
        for (int j = 0; j < 61; ++j) {
            if (pw[j] & i) {
                ans = (ans + (pw[j] % mod * (z - bits[j]) % mod)) % mod;
                bits[j]++;
            } else {
                ans = (ans + (pw[j] % mod * bits[j] % mod)) % mod;
            }
        }
    }
    cout << ans;
}




Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
       
    if(n==1||n==2||n==3||n==4||n==5||n==6||n==7||n==8||n==9||n==10||n==12||n==14||n==15||n==16||n==18||n==20||n==21||n==24||n==25||n==27||n==28||n==30||n==32||n==35||n==36||n==40||n==42||n==45||n==48||n==49||n==54||n==56||n==63||n==64||n==72||n==81){
        
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    }

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
struct pos3{
	double x;
	double y;
	double z;
	double r;
};
int main() {
	int n;
	while (cin >> n,n) {
		vector<pos3> cic(n);
		vector<pair<double, pii>> dis;
		REP(i, n)
			cin >> cic[i].x >> cic[i].y >> cic[i].z >> cic[i].r;
		REP(i,n-1)
			FOR(j, i + 1, n) {
			double d = sqrt((cic[i].x - cic[j].x)*(cic[i].x - cic[j].x) +
				(cic[i].y - cic[j].y)*(cic[i].y - cic[j].y) +
				(cic[i].z - cic[j].z)*(cic[i].z - cic[j].z))-cic[i].r-cic[j].r;
			dis.push_back({ d,{i,j}});
		}
		SORT(dis);
		UnionFind uf(n);
		double ans = 0.0;
		REP(i, dis.size()) {
			if (uf.find(dis[i].second.first) == uf.find(dis[i].second.second))
				continue;
			uf.unite(dis[i].second.first, dis[i].second.second);
			ans += max(0.0,dis[i].first);
			int cnt = 0;
			REP(j, n) {
				if (uf.find(0) == uf.find(j))
					cnt++;
			}
			if (cnt == n)break;
		}
		printf("%.3lf\n", ans);
	}
}

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

ll a, b, x;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> x;
    ll d = a % x;
    if (d) a += (x - d);
    if (a > b) {
		cout << 0;
		return 0;
	}
	
    ll ans = 1;
    ans += (b - a) / x;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int ans=0;
int n;
class Sumof4Integers{
    public:
        void solve(){ 
            dfs(0,0);
            printf("%d\n",ans);
        }
        void dfs(int d,int sum){ 
            if(d==4){
                if(n==sum)ans++;
                return;
            }
            for(int i=0;i<10;i++){
                dfs(d+1,sum+i);
            }
        }
};
int main(){ 
    Sumof4Integers inst;
    while(cin>>n){
        inst.solve();
        ans=0;
    }
}

Measured memory_bytes: 3064
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string s; cin >> s;
    bool ok = true;
    for(int i = 0; i < a; i++){
        if(!isdigit(s[i])){
            ok = false;
        }
    }
    if(s[a] != '-'){
        ok = false;
    }
    for(int i = 0; i < b; i++){
        if(!isdigit(s[a + 1 + i])){
            ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 256
n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for j in range(m)]

C = [[0 for k in range(l)]for i in range(n)]

for i in range(n) :
  for k in range(l) :
    for j in range(m) :
      C[i][k] = C[i][k] + A[i][j] * B[j][k]
for i in range(n):
  print(*C[i])


Measured memory_bytes: 7060
// finish date: 2018/08/13
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


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

    rep(i, 26) {
        rep(j, 15) {
            if (i * 4 + j * 7 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
N_str = str(input())
K = int(input())

digit_length = len(N_str)
topmost_digit = int(N_str[0])

C_table = [[0, 0, 0, 0] for _ in range(digit_length+10)]


def C(all, pick):
    if C_table[all][pick] == 0:
        count_child = 1
        count_parent = 1
        for i in range(pick):
            count_child *= all - i
            count_parent *= i + 1
        C_table[all][pick] = count_child // count_parent
    return C_table[all][pick]


def get_count(top_digit, digit_count, needed_nonzero):
    if needed_nonzero <= 0 or needed_nonzero > digit_count:
        return 0

    if digit_count == 1:
        if needed_nonzero == 1:
            return top_digit
        else:
            return 0

    if top_digit == 0:
        return get_count(int(N_str[digit_length - digit_count + 1]) ,digit_count - 1, needed_nonzero)

    if top_digit >= 1:
        count = C(digit_count - 1, needed_nonzero) * (9 ** needed_nonzero)
        if needed_nonzero == 1:
            count += 1

    if top_digit > 1:
        count += C(digit_count - 1, needed_nonzero - 1) * (9 ** (needed_nonzero - 1)) * (top_digit - 1)

    return count + get_count(int(N_str[digit_length - digit_count + 1]) ,digit_count - 1, needed_nonzero - 1)


print(get_count(topmost_digit, digit_length, K))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char a[105],b[105];
int o[205],ans=INT_MAX;
int main()
{
	scanf("%s",a);
	int l=strlen(a);
	for(int j=0;j<l;j++)o[a[j]]++;
	for(int i='a';i<='z';i++)
	{
		if(o[i]==0)continue;
		//printf("\\%c\n",i);
		for(int j=0;j<l;j++)b[j]=a[j];
		for(int op=0;op<l;op++)
		{
			bool p=true;
			for(int j=0;j<l-op;j++)if(b[j]!=i)p=false;
			if(p)
			{
				ans=min(ans,op);
				break;
			}
			for(int j=0;j<l-op-1;j++)
			{
				if(b[j+1]==i)b[j]=i;
			}
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int cnt=3,a,b,c;
	cin>>a>>b>>c;
	if(a==b)cnt--;
	if(b==c)cnt--;
	if(c==a)cnt--;
	cout<<max(1,cnt)<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]
ans=[]
for k in range(2**10,2**11):
    a=[]
    t = [0 for x in range(n)]
    s = bin(k)[3:]
    for i in range(10):
        if s[i]=='1':
            for j in range(n):
                if f[j][i]==1:
                    t[j]+=1
    if max(t)!=0:
        a = [p[i][t[i]] for i in range(n)]
        ans.append(sum(a))
print(max(ans))


Measured memory_bytes: 3064
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		long xx = scanLong();
		long x[] = new long[n];
		long xs[] = new long[n + 1];
		for (int i = 0; i < n; i++) {
			x[i] = scanLong();
			xs[i + 1] = xs[i] + x[i];
		}
		long ans = xx * n + 5 * xs[n];
		i: for (int i = 1; i < n; i++) {
			long cans = xx * i + 5 * (xs[n] - xs[n - i]);
			for (int j = 5, k = n - i; k >= 0; j += 2, k -= i) {
				if (cans > ans) {
					continue i;
				}
				cans += j * (xs[k] - xs[max(k - i, 0)]);
			}
			ans = min(ans, cans);
		}
		out.print(ans + xx * n);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

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

using namespace std;
const long long mod = 1e9+7;

int main()
{
    long long n,m;
    while(~scanf("%lld%lld",&n,&m)){
        if(abs(n-m) > 1) puts("0");
        else{
            long long ans = 1;
            for(long long i=2;i<=n;++i) ans = (ans * i) % mod;
            for(long long i=2;i<=m;++i) ans = (ans * i) % mod;
            ans = (ans * (1LL + (n==m))) % mod;
            printf("%lld\n",ans);
        }
    }
    return 0;
}


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

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

    printf("%.10f\n", 2 * R * acos(-1));

    return 0;
}


Measured memory_bytes: 3764
N, x = gets.split.map(&:to_i)
a = Array.new(N)
a = gets.split.map(&:to_i)

sorted_a = a.sort
len = a.size
count = 0
sum = 0
sorted_a.each.with_index do |e, i|
  if i == len - 1
    if e == x - sum
      count += 1
    end
    break
  end

  sum += e
  if sum <= x
    count += 1
  else
    break
  end
end
puts count


Measured memory_bytes: 1788
// Aizu Vol-5 0587: Tunnel
// 2017.8.30 bal4u@uu

#include <stdio.h>

int main()
{
	int n, m, a, b, ans;

	scanf("%d%d", &n, &m); ans = m;
	while (n-- > 0) {
		scanf("%d%d", &a, &b);
		m += a - b;
		if (m < 0) ans = 0;
		if (ans > 0 && m > ans) ans = m;
	}
	printf("%d\n", ans);
	return 0;
}

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

int H,W,N;
int a[201][201];
int A[201][201];


int calc(int h,int w,int H,int W){
  return A[H][W]-A[H][w]-A[h][W]+A[h][w];
}


bool solve(int h,int w,int H,int W,int N,int M){
  int res=0,total=calc(h,w,H,W);
  if(N==1)return (total>=M);
  
  for(int i=h+1;i<H;i++){
    if(calc(h,w,i,W)<M)continue;
    if(solve(i,w,H,W,N-1,M))return true;
    break;
  }
  
  for(int j=w+1;j<W;j++){
    if(calc(h,w,H,j)<M)continue;
    if(solve(h,j,H,W,N-1,M))return true;
    break;
  }

  for(int i=H-1;i>h;i--){
    if(calc(i,w,H,W)<M)continue;
    if(solve(h,w,i,W,N-1,M))return true;
    break;
  }

  for(int j=W-1;j>w;j--){
    if(calc(h,j,H,W)<M)continue;
    if(solve(h,w,H,j,N-1,M))return true;
    break;
  }
  return res;
}

bool check(int nv,int sv,int M){
  int ev=0,wv=0;
  while( calc(0,0,wv,nv) < M ){
    wv++;
    if(wv>=H)return false;
  }
  
  while( calc(0,nv,ev,W) < M ){
    ev++;
    if(ev>=H)return false;
  }

  if(sv<nv)ev=max(ev,wv);
  if(sv>nv)wv=max(ev,wv);
  
  if( calc(wv,0,H,sv) < M)return false;
  if( calc(ev,sv,H,W) < M)return false;

  return true;
}

bool check(int M){
  if(N==4){
    for(int nv=1;nv<W;nv++)
      for(int sv=1;sv<W;sv++)
        if(check(nv,sv,M))return true;
  }
  if( solve(0,0,H,W,N,M) )return true;
  return false;
}

int compute(){
  int L=0,R=2e8,M;
  while(R-L>1){
    M=(L+R)/2;
    if(check(M))L=M;
    else R=M;
  }
  return L;
}

int main(){
  scanf("%d %d %d",&H,&W,&N);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      scanf("%d",&a[i][j]);
      A[i+1][j+1]=a[i][j]+A[i+1][j]+A[i][j+1]-A[i][j];
    }
  }

  int ans=compute();
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3540
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    int x,y;
    cin>>x>>y;
    bool ok = false;
    for(int i=0;i<=x;i++){
        if(2*i + 4*(x-i) == y){
            ok = true;
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll



int main(){
  int n;cin>>n;
  bool sente = false;
  rep(i,n){
    int a;cin>>a;
    if(a%2==1)sente = true;
  }
  cout << (sente?"first":"second") << endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}



char f(char x) {
  if (x == 'A') return 'T';
  if (x == 'T') return 'A';
  if (x == 'G') return 'C';
  if (x == 'C') return 'G';
  return '?'  ;
}
int main2() {
  string s; cin >> s;
  REP(i, s.size()) {
    s[i] = f(s[i]);
  }
  cout << s << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())
Ds.sort()
MIN = Ds[N//2-1]
MAX = Ds[N//2]

if MIN==MAX:
    print(0)
else:
    print(MAX-MIN)

Measured memory_bytes: 84592
#include<stdio.h>
#include<math.h>
int A[20], n;
int solve(int, int);

main(){
  int i, q, B[200];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &B[i]);
  }
  for(i = 0; i < q; i++){
    if(solve(0, B[i]) == 1) printf("yes\n");
    else if(solve(0, B[i]) == 0) printf("no\n");
  }
  return 0;
}

int solve(int i, int m){
  if(m == 0) return 1;
  if(i >= n) return 0;
  if(solve(i+1, m) == 1 || solve(i+1, m-A[i]) == 1){
    return 1;
  }
  else return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <math.h>
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vvvl vector<vector<vector<ll> > >
#define vd vector<double>
#define vvd vector<vector<double> >
#define vvvd vector<vector<vector<double> > >
#define rep(i,a) for(ll i = 0;i<a;++i)
#define mod 1000000007
#define inf 11451419198
using namespace std;

int main(){
	ll n, m; cin >> n >> m;
	vl ngo(n,-1);
	bool isEnd = 0;
	rep(i, m){
		ll s, c; cin >> s >> c;
		s--;
		if (ngo[s] == -1) ngo[s] = c;
		else{
			if (ngo[s] != c){
				isEnd = 1;
			}
		}
	}
	if (isEnd){
		cout << -1 << endl;
		return 0;
	}
	if (ngo[0] == 0 && n != 1){
		cout << -1 << endl;
		return 0;
	}
	if (ngo[0] == -1 && n == 1){
		cout << 0 << endl;
		return 0;
	}
	if (ngo[0] == -1) ngo[0] = 1;
	for (ll i = 1; i < n; ++i) if (ngo[i] == -1) ngo[i] = 0;
	rep(i, n) cout << ngo[i];
	cout << endl;
	return 0;
}

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

    int n;
    int i,j;
    int row,col;
    int num;

    scanf("%d",&n);

    int matrix[MAX+1][MAX+1];

    for( i = 0 ; i <= n ; i++ ){
        for( j = 0 ; j <= n ; j++ ){
            matrix[i][j] = 0;
        }
    }

    for( i = 1 ; i <= n ; i++ ){

        scanf("%d",&row);
        scanf("%d",&col);

        for( j = 0 ; j < col ; j++ ){
            scanf("%d",&num);
            matrix[row][num] = 1;
        }

    }

    for( i = 1 ; i <= n ; i++ ){
        for( j = 1 ; j <= n ; j++ ){
            printf("%d",matrix[i][j]);

            if( j != n ){
                printf(" ");
            }

        }
    
       printf("\n");
    
    }


    return 0;

}

Measured memory_bytes: 636
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n;
	cin>>n;
	V<int> v;
	while(n){
		if(n%26){
			v.PB(n%26-1);
		}else{
			v.PB(25);n-=26;
		}
		n/=26;
	}
	reverse(ALL(v));
	for(auto u:v)cout<<(char)(u+'a');
	RE 0;
}




Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >>N;
  int X = N/1.08;
  if((int)(X*1.08)==N) cout << X;
  else if((int)((X-1)*1.08)==N) cout << X-1;
  else if((int)((X+1)*1.08)==N) cout << X+1;  
  else cout << ":(";
}


Measured memory_bytes: 256
#include <stdio.h>

int parent(int n){
  return ((double)1/2)*n;
}

int left(int n){
  return 2*n;
}

int right(int n){
  return 2*n+1;
}

int main() {
  int heap_size,i,H[250];

  scanf ("%d",&heap_size);
  for (i=1;i<=heap_size;i++){
    scanf ("%d",&H[i]);
  }

  for (i=1;i<=heap_size;i++){
    printf ("node %d: key = %d, ",i,H[i]);
    if (parent(i)>=1){
      printf ("parent key = %d, ",H[parent(i)]);
    }
    if (left(i)<=heap_size){
      printf ("left key = %d, ",H[left(i)]);
    }
    if (right(i)<=heap_size){
      printf ("right key = %d, ",H[right(i)]);
    }
    printf("\n");
  }

  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
const ul mod = 1000000007;

class com_permu {
  private:
    const ll mod = 1000000007;
    const ll com_max = 510000;
    vector<ll> fac, inv, finv;

  public:
    com_permu() {
        fac.resize(com_max);
        inv.resize(com_max);
        finv.resize(com_max);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;

        for (ll i = 2; i < com_max; i++) {
            fac[i] = fac[i - 1] * i % mod;
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    ll com(ll n, ll k) {
        if (n < k) {
            return 0;
        }
        if (n < 0 || k < 0) {
            return 0;
        }

        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    ll permu(ll n, ll k) {
        if (n < k) {
            return 0;
        }
        if (n < 0 || k < 0) {
            return 0;
        }
        return fac[n] * finv[n - k] % mod;
    }
};
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s;
    cin >> s;
    ll ans = 0;
    com_permu c;
    for (ll i = 1; i * 3 <= s; i++) {
        ll x = s - 3 * i;
        ans += c.com(x + i - 1, i - 1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 15076
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

long n;
vector<long> a;
map<long, long> m;
int main(void) {
  cin >> n;
  a = vector<long>(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (long i = 0; i < n; i++) {
    for (long d = -1; d <= 1; d++) {
      if (m.count(a[i]+d)) m[a[i]+d]++;
      else m[a[i]+d] = 1;
    }
  }
  long ans = 0;
  for (auto kv : m) {
    ans = max(kv.second, ans);
//    cout << kv.first << ": " << kv.second << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6912