akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s = S()
	if s.upper() == s:
		print('A')
	else:
		print('a')


if __name__ == '__main__':
    main()

Measured memory_bytes: 27100
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

/*
 * まず 7, 77, 777, ... という数列を考えるとき
 * (1) K が 7 の倍数であるとき、1, 11, 111, ... という数列に対して、初めて K / 7 の倍数が登場する状 況を考えれば良い
 * (2) K が 7 の倍数でないとき、1, 11, 111, ... という数列に対して、初めて K の倍数が登場する状況を 考えれば良い
 *
 * 「1 11 111 1111 約数」とググったところ、これはレピュニット数と呼ばれるもので、
 * 一般項は、Rn = (10^n - 1) / 9 で表すことができる。
 *
 * 以上から、以下のように問題を再定義できる。
 * K が 7 の倍数のとき L = 9 * K / 7、そうでないとき L = 9 * K とおき、10^n を L で割ったときに、余 りが 1 になるような最小の整数 n を求めよ。
 *
 * 「割って余りが 1 になる」という見た目から、フェルマーの小定理を思い出すことができると良い。
 * ただし、実際のところは、オイラーの定理が必要となる。
 * 　a^(φ(n)) ≡ 1 (mod n)
 * φ(n) はオイラー関数で、1 から n までの整数で、n と互いに素となるものの個数である。
 * この定理から、少なくとも n = L までには遅くとも求めるべき整数が見つかることが保証される。
 */

int main() {
        ll K;
        cin >> K;

        if (K % 2 == 0) {
                cout << "-1" << endl;
                return 0;
        }

        if (K % 7 == 0) K = 9 * K / 7;
        else K = 9 * K;

        ll remainder = 1;
        FOR(i, 1, K) {
                remainder = (remainder * 10) % K;
                if (remainder == 1) {
                        cout << i << endl;
                        return 0;
                }
        }

        cout << "-1" << endl;
        return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	static int check(int [] letters,int start,int type) {
		int len = 0;
		for(int i=start;i<letters.length && len<type;i++) {
			len += letters[i];
			if(len == type) {
				return i+1;
			}
		}
		return -1;
	}
	
	static boolean tanku(int [] letters, int start) {
		int [] ku = {5,7,5,7,7};
		for(int type:ku) {
			start = check(letters,start,type);
			if(start==-1) return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n==0) break;
			String [] words = new String[n];
			int [] letters = new int[n];
			for(int i=0;i<n;i++) {
				words[i] = sc.next();
				letters[i] = words[i].length();
			}
			int flag=0;
			for(int i=0;i<n && flag==0;i++) {
				if(tanku(letters,i)) {
					System.out.println(i+1);
					flag=-1;
					break;
				}
			}
		}

	}
}



Measured memory_bytes: 31420
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        var rgx = new Regex(@"^" + s + @".");
        var match = rgx.Match(t);

        string outstr = "No";
        if(match.Success)
        {
            outstr = "Yes";
        }

        Console.WriteLine(outstr);

    }
}

Measured memory_bytes: 26788
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int n,a[100100];
bool cmp(int a,int b){
    return a>b;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;i++){
        if(i+1>a[i+1]){
            int ans=0;
            for(int j=i+1;a[j]==i;j++)
                ans^=1;
            if(ans||((a[i]-i)&1))
                printf("First\n");
            else
                printf("Second\n");
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 512
// input: alds1_10_c.in
#include<iostream>
#include<algorithm>
#define MAX_X 1000
#define MAX_Y 1000
using namespace std;

int c[MAX_X+1][MAX_Y+1];

int lcs(string& a, string& b) {
  a = ' ' + a;
  b = ' ' + b;

  for(int i=0; i<a.length(); i++) {
    c[i][0] = 0;
  }
  for(int i=0; i<b.length(); i++) {
    c[0][i] = 0;
  }

  for(int i=1; i<a.length(); i++) {
    for(int j=1; j<b.length(); j++) {
      if(a[i] == b[j]) {
        c[i][j] = c[i-1][j-1] + 1;
      } else {
        c[i][j] = max(c[i][j-1], c[i-1][j]);
      }
    }
  }

  return c[a.length()-1][b.length()-1];
}

int main() {
  int n;
  string a, b;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a >> b;

    cout << lcs(a, b) << endl;
  }
}

Measured memory_bytes: 6956
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        long[] A = new long[N];
        long ans = 0;

        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        HashMap<Long, Integer> map = new HashMap<Long, Integer>();
        for(int i=0; i<N; i++){
            long L = A[i] + i + 1;
            if(map.containsKey(L)){
                map.put(L, map.get(L) + 1);
            }
            else{
                map.put(L, 1);
            }
        }
        for(int i=0; i<N; i++){
            long R = i + 1 - A[i];
            if(map.containsKey(R)){
                ans += map.get(R);        
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 67500
/*
 *  Created on: 26 / 4 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n)
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(20);
    Eslam__Waheed
        ll a, b, c, d; cin >> a >> b >> c >> d;
    bool f = 1;
    while (a > 0 && c > 0)
    {
        if (f)
        {
            c -= b;
            f = 0;
        }
        else
        {
            a -= d;
            f = 1;
        }
    }
    if (a > 0)
    {
        cout << "Yes";;
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 3652
#include <stdio.h>

int count = 0;
void merge(int arr[],  int left, int mid, int right)
{
    int i,j,k;
    int left_size = mid - left + 1;
    int right_size = right - mid;

    /*creat temp arrays*/
    int L[left_size], R[right_size];

    /*copy data to temp arrays L[] and R[]*/
    for(i=0; i<left_size; i++)
        L[i] = arr[left+i];
    for(j=0; j<right_size; j++)
        R[j] = arr[mid+1+j];
    /*merge two temp arrays*/
    i = 0; //initial index of first subarray
    j = 0; //initial index of second subarray
    k = left; //initial index of merged subarray

    while(i<left_size && j<right_size){
        if(L[i]<=R[j]){
            arr[k] = L[i];
            i++;
        }
        else{
            arr[k] = R[j];
            j++;
        }
        k++;
        count++;
    }

    while(i<left_size){
        arr[k] = L[i];
        i++;
        k++;
        count++;
    }
    while(j<right_size){
        arr[k] = R[j];
        j++;
        k++;
        count++;
    }
}
void mergesort(int A[], int left, int right)
{
    int mid;
    if(left<right){
        mid = left + (right-left)/2;
        mergesort(A, left, mid);
        mergesort(A, mid+1, right);
        merge(A, left, mid, right);
    }
}

int main(){
    /*int A[] = {8, 5, 9, 2, 6, 3, 7, 1, 10, 4};*/
    int n, A[500005];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    mergesort(A, 0, n-1);
    for(int i=0; i<n; i++){
        if(i!=n-1) printf("%d ", A[i]);
        else printf("%d\n", A[i]);
    }
    printf("%d\n", count);
}



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,K,Q;cin>>N>>K>>Q;
  std::vector<int> v(N,K-Q);
  while(Q--){
    int a;cin>>a;
    v[--a]++;
  }
  for(int i=0;i<N;i++){
    if(v[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int h,n;
	cin>>h>>n;
	vector<P> v(n);
	rep(i,n)cin>>v[i].first>>v[i].second;

	vector<int> dp(h+1e4+1,INF);
	repi(i,h,h+1e4+1) dp[i]=0;

	rep(i,n){
		repr(j,h,0){
			// if(j+v[i].first>h) continue;
			dp[j] = min(dp[j], dp[j+v[i].first]+v[i].second);
		}
	}

	cout<<dp[0]<<endl;

	return 0;
}

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

int main(){
    string S,T;
    cin >> S;
    bool a=1;
    int i,len = S.size();
    T = S.substr(0,(len-1)/2);
    for(i=0;i<len;i++){
        if(S.at(i) != S.at(len-i-1)){
            a = 0;
            break;
        }
    }
    if(a){
        int lent = T.size();
        for(i=0;i<lent;i++){
            if(T.at(i) != T.at(lent-i-1)){
                a = 0;
                break;
            }
        }
    }
if(a){
    cout << "Yes" << endl;
}else{
    cout << "No" << endl;
}
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int64_t X, Y;
	cin >> X >> Y;

	int result = 0;
	for( int64_t i = X; i <= Y; i += i ) {
		result += 1;
	}

	cout << result << endl;
	return 0;
}


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

using namespace std;

int N;
string S[100000];

int main(int argc, char* argv[]) {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }

  long long int nums[5] = {0, 0, 0, 0, 0};
  for (int i = 0; i < N; i++) {
    switch (S[i][0]) {
      case 'M':
        nums[0]++;
        break;
      case 'A':
        nums[1]++;
        break;
      case 'R':
        nums[2]++;
        break;
      case 'C':
        nums[3]++;
        break;
      case 'H':
        nums[4]++;
        break;
    }
  }

  long long int res = 0;
  for (int i = 0; i < 5; i++)
    for (int j = i + 1; j < 5; j++)
      for (int k = j + 1; k < 5; k++)
        res += nums[i] * nums[j] * nums[k];

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6756
import itertools
n = int(input())
p = [list(map(int,input().split())) for _ in range(n)]
order = list(itertools.permutations(range(n)))
length = 0

for o_list in order:
  start_x,start_y = p[o_list[0]]
  for o in o_list[1:]:
    x,y = p[o]
    length += ((start_x-x)**2+(start_y-y)**2)**(1/2)
    start_x,start_y = x,y
print(length/len(order))

    



Measured memory_bytes: 8180
n, m = map(int, input().split())
w = [list(map(int, input().split())) for _ in range(n)]


ws = [w[i][0]*1 + w[i][1]*1 + w[i][2]*1 for i in range(n)]
ws.sort()
ans = max(0, abs(sum(ws[0:m])))
ws = [w[i][0]*-1 + w[i][1]*1 + w[i][2]*1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))
ws = [w[i][0]*1 + w[i][1]*-1 + w[i][2]*1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))
ws = [w[i][0]*1 + w[i][1]*1 + w[i][2]*-1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))
ws = [w[i][0]*-1 + w[i][1]*-1 + w[i][2]*1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))
ws = [w[i][0]*-1 + w[i][1]*1 + w[i][2]*-1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))
ws = [w[i][0]*1 + w[i][1]*-1 + w[i][2]*-1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))
ws = [w[i][0]*-1 + w[i][1]*-1 + w[i][2]*-1 for i in range(n)]
ws.sort()
ans = max(ans, abs(sum(ws[0:m])))

print(ans)

Measured memory_bytes: 3316
N = int(input())
ans=0
x = N-1
for i in range(2,int(x**(1/2))+1):
  if x%i==0:
    ans+=2
  
if int(x**(1/2))**2==x:
  ans-=1


for i in range(2,int(N**(1/2))+1):
  a = N
  if a%i==0:
    while a%i==0:
      a//=i
    if a%i==1:
      ans+=1
      
    b = N//i
    if b==i:
      continue
    a = N
    while a%b==0:
      a//=b
    if a%i==1:
      ans+=1
    
print(ans+2)

Measured memory_bytes: 40172
//Name: Addition Game
//Level: 3
//Category: 数学,Math
//Note:

/*
 * 桁数が1つ減るとき、全体の合計は変化しない。
 * 桁数が変化しないとき、全体の合計は9だけ減る。
 * したがって、どのような順序で操作を行っても結果は常に同じになり、
 * ・桁数の減る操作が |S| - 1回
 * ・桁数の減らない操作が floor((Σs_i - 1) / 9) 回
 * 発生する。
 *
 * オーダーは O(|S|)。
 */
#include <iostream>
#include <string>

using namespace std;

void solve() {
    string s;
    cin >> s;

    int sum = 0;
    for(char c : s) {
        sum += c - '0';
    }
    int check = (int)s.size()-1 + (sum-1)/9;
    cout << (check % 2 ? "Fabre" : "Audrey") << " wins." << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    int N;
    cin >> N;
    while(N--) solve();
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FOR1(x,to) for(int x=1;x<(to);x++)
struct card{char suit,value;};
int selectionsort(int n,struct card a[]){
    int mini,res=0;
    FOR(i,n){
        mini=i;
        for(int j=i;j<n;j++){
            if(a[j].value<a[mini].value)mini=j;
        }
        swap(a[i],a[mini]);
        res++;
    }
    return res;
}

int bubblesort(int n,struct card a[]){
    int flag=1,res=0,i=0;
    while(flag){
        flag=0;
        for(int j=n-1;j>i;j--){
            if(a[j].value<a[j-1].value){
                swap(a[j],a[j-1]);
                flag=1;
                res++;
            }
        }
        i++;
    }
    return res;
}
void print(int n,struct card a[]){
    FOR(i,n){
        if(i>0)cout<<" ";
        cout<<a[i].suit<<a[i].value;
    }
    cout<<endl;
}

bool isstable(int n,struct card a[],struct card b[]){
    bool flag=true;
    FOR(i,n){
        if(a[i].suit!=b[i].suit) flag=false;
    }
    return flag;
}

int main()
{
    int n;cin>>n;
    card c1[100],c2[100];
    FOR(i,n){
        cin>>c1[i].suit>>c1[i].value;
    }
    FOR(i,n){
        c2[i]=c1[i];
    }
    bubblesort(n,c1);
    selectionsort(n,c2);
    print(n,c1);
    cout<<"Stable"<<endl;
    print(n,c2);
    isstable(n,c1,c2)?cout<<"Stable":cout<<"Not stable";
    cout<<endl;
}


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

using namespace std;

long long dp[101][100001];

int main()
{
	int n, ww; cin >> n >> ww;
	vector<long long> w(n), v(n);

	for (auto i = 0; i < n; i++) cin >> w[i] >> v[i];
 
	for (auto i = 1; i <= n; i++)
	{
		for (auto j = 0; j <= ww; j++)
		{
			if (w[i-1] > j) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i-1]] + v[i-1]);

		}
	}

	cout << dp[n][ww] << endl;
}

Measured memory_bytes: 78336
from collections import deque
h,w = map(int, input().split())
G = [['#']*(w+2)]
white = 0
for i in range(h):
    G.append(['#']+list(input()) + ['#'])
    white += G[i+1].count('.')
G.append(['#']*(w+2))

G[1][1] = 1
que = deque([[1,1]])
while que:
    y,x = que.popleft()
    d = G[y][x]
    for dy,dx in ((1,0),(-1,0),(0,1),(0,-1)):
        ny = y+dy
        nx = x+dx
        if G[ny][nx] == '.':
            G[ny][nx] = d+1
            que.append((ny,nx))
if G[h][w] == '.':
    print('-1')
else:
    ans = white - G[h][w]
    print(ans)


Measured memory_bytes: 39920
n,q = map(int, input().split())
s = input()
li = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == "AC":
        li[i+1] = li[i] + 1
    else:
        li[i+1] = li[i]

for i in range(q):
    l, r = map(int, input().split())
    print(li[r-1] - li[l-1])

Measured memory_bytes: 52824
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr double DINF =100000000000000000.0;
constexpr long long INF = 100000000000000000;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(), v.end());
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		if (*lower_bound(v.begin(), v.end(), a) != a) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			v.erase(lower_bound(v.begin(), v.end(), a));
		}
	}
	cout << "YES" << endl;
}

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

int main(){
int a,b,c;
cin>>a>>b>>c;
if (a+b>=c)
{
    /* code */
    cout<<"Yes"<<endl;
}

else
{
    cout<<"No"<<endl;
}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long double dp[302][302][302];
int n;

long double calculate(int i,int j,int k)
{
	if(i==0&&j==0&&k==0)
	{
		dp[i][j][k]=0;
		return 0;
		}
	if(dp[i][j][k]!=-1)
	{
		return dp[i][j][k];
	}
	long double a1=0;
	long double a2=0;
	long double a3=0;
	if(i>0)
	{
		a1=calculate(i-1,j,k);
	}
	if(j>0)
	{
		a2=calculate(i+1,j-1,k);
	}
	if(k>0)
	{
		a3=calculate(i,j+1,k-1);
	}
	dp[i][j][k]=(double)n/((double)(i+j+k))+a1*((double)i/(double)(i+j+k))+a2*((double)j/(double)(i+j+k))+a3*((double)k/(double)(i+j+k));
	return dp[i][j][k];
}
int main(void)
{
	cin >> n;
	for (int i = 0; i <=n; ++i)
	{
		for (int j = 0; j <=n; ++j)
		{
			for (int k = 0; k <=n; ++k)
			{
				dp[i][j][k]=-1;
			}
		}
	}
	int cnt1=0;
	int cnt2=0;
	int cnt3=0;
	for (int i = 0; i < n; ++i)
	{
		int temp;
		cin >> temp;
		if(temp==1)
		{
			cnt1++;
		}
		else if(temp==2)
		{
			cnt2++;
		}
		else
		{
			cnt3++;
		}
	}
	printf("%.10Lf\n",calculate(cnt1,cnt2,cnt3));
	// printf("%Lf\n",dp[0][0][0] );
	// printf("%Lf\n",dp[0][0][1] );
	// printf("%Lf\n",dp[0][1][0] );
	// printf("%Lf\n",dp[1][0][0] );
	// printf("%Lf\n",dp[1][0][0] );
	// printf("%Lf\n",dp[1][0][0] );
}

Measured memory_bytes: 430336
import math
H, W = map(int, input().split())
base = math.ceil(W / 2)
if H == 1 or W == 1:
    print(1)
    exit()
    
if W % 2 == 0:
    ans = base * H
else:
    if H % 2 == 1:
        ans = (base + base -1) * (H - 1) // 2 + base
    else:
        ans = (base + base -1) * H  // 2
    
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a,b;
  cin>>n>>m;
  vector<int> mp(n+1);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    mp[a]++,mp[b]++;
  }
  for(int i=1;i<=n;i++) cout<<mp[i]<<"\n";

  return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var first = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            var N = first[0];
            var M = first[1];
            var C = first[2];

            var bList = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            var success = 0;

            for (var i = 0; i < N; i++)
            {
                var tmpLine = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
                var total = 0;

                for (var j = 0; j < M; j++)
                {
                    total += bList[j] * tmpLine[j];
                }

                if (total + C > 0) success++;
            }
            Console.WriteLine(success);
        }
    }
}


Measured memory_bytes: 13268
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);

        while(true){
            int n = stdIn.nextInt();
            int x = stdIn.nextInt();

            if(n == 0 && x == 0){
                break;
            }

            int counter = 0;
            for(int i=1; i<=n-1; i++){
                for(int j=i+1; j<=n; j++){
                    if(x - (i + j) <= n && j < x - (i + j)){
                        counter++;
                        continue;
                    }
                }
            }

            System.out.println(counter);
        }
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int n;
double t, a, h, tt, ans;

int main() {
    cin >> n >> t >> a;
    int ti = 1;
    cin >> h;
    tt = t - h * 0.006;
    ans = abs(a - tt);
    for (int i = 2; i <= n; ++i) {
        cin >> h;
        tt = t - h * 0.006;
        if (abs(a - tt) < ans) {
            ans = abs(a - tt);
            ti = i;
        }
    }
    cout << ti << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<algorithm>
#include<set>
#include<iostream>
#include<cassert>
#include<complex>
#include<vector>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps = 1e-10;
typedef complex<double> P;
typedef vector<P> Polygon;
#define N 4002


double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

bool isp(P a,P b,P c){
  return abs(a-c)+abs(b-c)<abs(a-b)+eps;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  if ( isp(a1,a2,b1)||isp(a1,a2,b2)||isp(b1,b2,a1)||isp(b1,b2,a2))return true;
  if ( cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<0 &&
       cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<0)return true;
  return false;
}

P intersection_ls(P a1,P a2,P b1,P b2){
  P b=b2-b1;
  double d1=abs(cross(b,a1-b1));
  double d2=abs(cross(b,a2-b1));
  double t =d1/(d1+d2);
  return a1+(a2-a1)*t;
}


int make_data(Polygon &a,int y){
  int n = a.size();
  vector<pair<int,int> > block;
  rep(i,n){
    P a1=a[i],a2=a[(i+1)%n];
    P tmp[4];
    tmp[0].real()=-2001;
    tmp[0].imag()=y+1;
    tmp[1].real()=2001;
    tmp[1].imag()=y+1;
    tmp[2].real()=-2001;
    tmp[2].imag()=y;
    tmp[3].real()=2001;
    tmp[3].imag()=y;
    if (is_intersected_ls(a1,a2,tmp[0],tmp[1]) &&is_intersected_ls(a1,a2,tmp[2],tmp[3])){
      P b1=intersection_ls(a1,a2,tmp[0],tmp[1]);
      P b2=intersection_ls(a1,a2,tmp[2],tmp[3]);
      pair<int,int> ins=make_pair((int)floor(min(b1.real(),b2.real())),(int)ceil(max(b1.real(),b2.real())));
      block.push_back(ins);
    }

  }

  int ret=0;
  sort(block.begin(),block.end());

  if ( block.size()!=0){
    int prev=-10000;
    for(int i=0;i<block.size();i+=2){
      ret+=block[i+1].second-max(prev,block[i].first);
      prev=block[i+1].second;
    }
    //cout <<"end"<<endl;
  }
  return ret;
}


int solve(Polygon & a){
  int ret=0;
  int mini=10000,maxi=-10000;
  rep(i,a.size())mini=min(mini,(int)a[i].imag()),maxi=max(maxi,(int)a[i].imag());
  REP(i,mini,maxi+1)ret+=make_data(a,i);


  return ret;
}


main(){
  int n;
  while(cin>>n && n){
    Polygon a;
    P tmp;
    rep(i,n){
      cin>>tmp.real()>>tmp.imag();
      a.push_back(tmp);
    }
    cout << solve(a)<<endl;
  }
}

Measured memory_bytes: 988
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int a,b,max;
    cin>>a>>b;
    max=a+b;
    if(max<a-b)max=a-b;
    if(max<a*b)max=a*b;
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n = 5;
        vi a(n);
        rep(i,n)cin >> a[i];
        rep(i,n){
            if(a[i]==0){
                    cout<<i+1<<endl;
                    return 0;
            }
        }

return 0;
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}

const int nmax = 1003;
int N, K;
vector<int> A, B;
deque<int> D[nmax];
void input() {
  int i, j, k, x, y;
  string s;

  cin >> N;
  rep(i, 0, N - 1) {
    rep(j, 0, N - 2) {
      cin >> x;
      D[i].push_back(--x);
    }
  }
}
queue<int> Q;
int ans = 0;
void solve() {
  rep(i, 0, N - 1) { Q.push(i); }

  int M = N * (N - 1) / 2;
  bool impossible = false;
  bool ended = false;
  int count = 0;
  bool update = false;
  set<int> available;
  rep(i, 0, N - 1) { available.insert(i); }  // 前日に戦っていない人

  set<int> av;
  for (int xxx = 1; (not(impossible or ended)); ++xxx) {
    av.clear();
    update = false;
    set<int> next_available;
    // rep(i, 0, N - 1) {  // initialize.
    //   next_available.insert(i);
    // }
    // //debug(xxx);
    // available=next_available;

    for (auto i : available)
    /*
    rep(i,0,N-1)
    */
    {
      bool exsist_i = D[i].size() && av.find(i) == av.end();
      // if (not exsist_i) next_available.erase(i);
      int rival = D[i].front();
      bool exsist_rival = D[rival].size() && av.find(rival) == av.end();
      // if (not exsist_rival) next_available.erase(rival);
      if (exsist_i && exsist_rival && D[rival].front() == i)

      {
        // battle.
        // cout<<i+1 << " vs "<<rival+1<<endl;

        --M;
        // debug(M);
        update = true;
        D[i].pop_front();
        D[rival].pop_front();
        // next_available.erase(rival);next_available.erase(i);
        // available.erase(rival);available.erase(i);
        av.insert(i);
        av.insert(rival);
        // next_available.insert(i);
        // next_available.insert(rival);
      }
    }
    for (auto x : av) {
      next_available.insert(x);
    }
    available = next_available;
    if (M == 0) {
      ended = true;
      ans = xxx;
      impossible = false;
      break;
    }
    if (!update) {
      ended = true;
      ans = -1;
      impossible = true;
      break;
    }
  }
  cout << ans << endl;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
//#define int long long
using namespace std;
const int MOD=1e9+7;
int32_t main() {
    string s,t;
    cin>>s>>t;
    int ans=t.length();
    for(int i=0;i<s.length()-t.length()+1;i++){
        //if(s[i]==t[i]){
            int st=0;
            int d=0;
            for(;st<t.length();st++){
                if(t[st]!=s[i+st]){
                    d++;
                }
            }
            ans=min(ans,d);
        //}
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

std::int64_t factorial_prime_factorization(std::int64_t a, std::int64_t p){
  std::int64_t ret = 0, q = p;

  while(q <= a){
    std::int64_t t = a / q;

    ret += t;

    std::int64_t k;
    if(__builtin_smulll_overflow(q, p, (long long int*)&k)) break;
    
    q = k;
  }
  return ret;
}

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

    if(N % 2 == 0){
      N /= 2;
      LLI five = factorial_prime_factorization(N, 5);
      cout << five << endl;
    }else{
      cout << 0 << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> A(N+2, 0);
  rep(i, N) {
    cin >> A[i+1];
  }
  
  int sum = 0;
  vector<int> cost(N+2);
  for(int i = 1; i <= N; i++) {
    sum += std::abs(A[i] - A[i-1]);

    int diff1 = std::abs(A[i] - A[i-1]);
    int diff2 = std::abs(A[i+1] - A[i]);
    int diff3 = std::abs(A[i+1] - A[i-1]);

    if (diff1 + diff2 == diff3) {
      cost[i] = 0;
    } else if ((A[i] <= A[i-1] && A[i-1] <= A[i+1]) || (A[i+1] <= A[i-1] && A[i-1] <= A[i])) {
      cost[i] = 2 * std::abs(A[i] - A[i-1]);
    } else {
      cost[i] = 2 * std::abs(A[i+1] - A[i]);
    }
  }
  sum += std::abs(A[N]);

  for(int i = 1; i <= N; i++) {
    cout << sum - cost[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int N;
int a[100];
int main () {
  cin >> N;
  int hi = INT_MIN;
  int i1 = -1;
  int lo = INT_MAX;
  int i2 = -1;
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    if (a[i] > hi) {
      i1 = i;
      hi = a[i];
    }
    if (a[i] < lo) {
      i2 = i;
      lo = a[i];
    }
  }

  if (hi + lo >= 0) {
    // hi mod
    cout << 2 * N - 1 << endl;
    for(int i = 0; i < N; ++i) {
      cout << i1 + 1 << ' ' << i + 1 << endl;
    }
    for(int i = 0; i < N - 1; ++i) {
      cout << i + 1<< ' ' << i + 1 + 1 << endl;
    }
  } else {
    // lo mod
    cout << 2 * N - 1 << endl;
    for(int i = 0; i < N; ++i) {
      cout << i2 + 1 << ' ' << i + 1<< endl;
    }

    for(int i = N - 1; i > 0; --i) {
      cout << i + 1 << ' ' << i - 1  + 1<< endl;
    }
  }
}

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

const int N = 3005;

int n, m;
char s[N], t[N];
int f[N][N];
char res[N];
int cnt = 0;

void go(int u,int v) {
	if (u + v == 0) {
		return;
	}
	else if (u && f[u][v] == f[u - 1][v]) {
		go(u - 1, v);
	} else if (v && f[u][v] == f[u][v - 1]) {
		go(u, v - 1);
	} else {
		assert(s[u] == t[v]);
		go(u - 1, v - 1);
		res[++cnt] = s[u];
	}
}

int main() {
	scanf("%s %s", s + 1, t + 1);
	n = strlen(s + 1), m = strlen(t + 1);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			f[i][j] = max(f[i - 1][j], f[i][j - 1]);
			if (s[i] == t[j]) {
				f[i][j] = max(f[i][j], f[i - 1][j - 1] + 1);
			}
		}
	}
	go(n, m);
	printf("%s\n", res + 1);
}

Measured memory_bytes: 35456
(defun main ()
    (let ((x (read))
        (y (read))
        (ans "No"))
        (if (zerop (rem y 2))
            (loop for i below (+ 1 x)
                do (if (= y (+ (* i 2) (* (- x i) 4)) )
                (progn (setq ans "Yes")
                    (return))
                )
            )        
    
        )
    (format t "~A~%" ans)
    )
)
(main)

Measured memory_bytes: 23544
#include <stdio.h>
 
int dic(char c1[],char c2[]){
  int a=0,i=0;
  while(1){
    if(c1[i]<c2[i])return 1;
    if(c1[i]>c2[i])return 2;
    if(c1[i]=='\0'&&c2[i]=='\0')return 0;
    if(c1[i]=='\0')return 1;
    if(c2[i]=='\0')return 2;
    i++;
  }
  return 0;
}
 
int main(){
  int n,p1=0,p2=0,i,a;
  char c1[102],c2[102];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",&c1);
    scanf("%s",&c2);
    a=dic(c1,c2);
    if(a==0){
      p1+=1;
      p2+=1;
    }else if(a==1)p2+=3;
    else p1+=3;
  }
  printf("%d %d\n",p1,p2);
  return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define MOD 1e9+7
using namespace std;

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

template <typename T>
void cloneArray(T *a, T *b, int start, int end) {
    loop(i, start, end) {
        *(b+i)=*(a+i);
    }
}

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main(int argc, char const *argv[])
{   
    IOS;
    int n;
    cin >> n;
    int a[n];
    inputArray(a, 0, n-1);
    ll ans=0l;
    ll max=LLONG_MIN;
    loop(i, 0, n-1) {
        if(a[i]>max) max=a[i];
        else {
            ans+=(max-a[i]);
        }
    }
    cout << ans;
    //cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;
}

Measured memory_bytes: 4396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define rrep(i, n) for(ll i = 0; i <= (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    string c;
    cin >> c;
    //RR...RWW...Wとなる
    ll r = 0, w = 0, ans = 0;
    rep(i, N){
        if(c[i] == 'R') r++;
        else w++;
    }
    if(r == N || w == N){
        cout << 0;
        return 0;
    }

    ll left = 0, right = 0;
    rep(i, N){
        if(i < r){
            if(c[i] == 'W'){
                left++;
            }
        }else{
            if(c[i] == 'R'){
                right++;
            }
        }
    }
    ans = max(left, right);

    cout << ans;
}

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

int main() {
    int h, w, n, sr, sc;
    cin >> h >> w >> n >> sr >> sc;
    string s, t;
    cin >> s >> t;

    int nowU = sr, nowD = sr, nowL = sc, nowR = sc;
    for (int i = 0; i < n; i++) {
        if (s.at(i) == 'U') {
            if (nowU == 1) {
                cout << "NO" << endl;
                return 0;
            }
            else nowU--;
        }
        else if (s.at(i) == 'D') {
            if (nowD == h) {
                cout << "NO" << endl;
                return 0;
            }
            else nowD++;
        }
        else if (s.at(i) == 'L') {
            if (nowL == 1) {
                cout << "NO" << endl;
                return 0;
            }
            else nowL--;
        }
        else if (s.at(i) == 'R') {
            if (nowR == w) {
                cout << "NO" << endl;
                return 0;
            }
            else nowR++;
        }

        if (t.at(i) == 'U') {
            nowD = max(1, nowD - 1);
        }
        else if (t.at(i) == 'D') {
            nowU = min(h, nowU + 1);
        }
        else if (t.at(i) == 'L') {
            nowR = max(1, nowR - 1);
        }
        else if (t.at(i) == 'R') {
            nowL = min(w, nowL + 1);
        }
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   	long int a,b;
   	cin>>a>>b;

   	cout<<a*b;
   return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

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

char c[]={'y','u','i','o','p','h','j','k','l','n','m'};
string s;

int main(){
	while(cin>>s&&s!="#"){
		int ans=0,pre=2,l=s.size();
		rep(i,l){
			int r=0;
			rep(j,11)if(s[i]==c[j])r=1;
			if(r==0&&pre==1||r==1&&pre==0)ans++;
			pre=r;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int n;
  scanf("%d", &n);
  ll sum = -n;
  rep (i, n) {
    int a;
    scanf("%d", &a);
    sum += a;
  }
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 256
n, m, c = gets.chomp.split.map(&:to_i)
brr = gets.chomp.split.map(&:to_i)
cnt = 0
n.times do |i|
	arr = gets.chomp.split.map(&:to_i)
	sum = 0
	m.times do |j|
		sum += arr[j] * brr[j]
	end
	cnt += 1 if sum + c > 0
end
puts cnt




Measured memory_bytes: 14292
#include<iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N]; // 0 オリジンの隣接行列
	int n, u, k, v;
	
	cin >> n;
	
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) M[i][j] = 0;
	}
	
	for ( int i = 0; i < n; i++ ) {
		cin >> u >> k;
		u--; // 0 オリジンへ変換
		for ( int j = 0; j < k; j++ ) {
			cin >> v;
			v--; // 0 オリジンへ変換
			M[u][v] = 1; // u と v の間に辺を張る
		}
	}
	
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			if ( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	static int[] parent;

	public static void init(int N) {
		for (int i=0; i<N; i++) {
			parent[i] = i;
		}
	}

	public static int find(int x) {
		if (parent[x] == x) {
			return x;
		} else {
			return parent[x] = find(parent[x]);
		}
	}

	public static boolean same(int x, int y) {
		return find(x) == find(y);
	}

	public static void union(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) {
			return;
		}
		parent[y] = x;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();

		parent = new int[n];
		init(n);

		int[] com = new int[q];
		int[] x = new int[q];
		int[] y = new int[q];

		for (int i=0; i<q; i++) {
			com[i] = sc.nextInt();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}

		for (int i=0; i<q; i++) {
			if (com[i] == 0) {
				union(x[i], y[i]);
			} else {
				if (same(x[i], y[i])) {
					System.out.println(1);
				} else {
					System.out.println(0);
				}
			}
		}

		sc.close();
	}

}

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

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    ll v[n+1],x=0;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    ll l[n+2],r[n+2];
    for(int i=1;i<=n;i++){
        if(i==1)l[i]=v[i];
        else l[i]=__gcd(v[i],l[i-1]);
        if(n-i+1==n)r[n-i+1]=v[n-i+1];
        else r[n-i+1]=__gcd(v[n-i+1],r[n-i+2]);
    }
    for(int i=1;i<=n;i++){
        if(i==1)x=max(x,r[i+1]);
        else if(i==n)x=max(x,l[i-1]);
        else x=max(x,__gcd(l[i-1],r[i+1]));
    }
    cout<<x;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3 = x2 + y1 - y2;
    int y3 = y2 + x2 - x1;

    int x4 = x1 + y1 - y2;
    int y4 = y1 + x2 - x1;

    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << ' ' << endl;

}


Measured memory_bytes: 256
s = list(input())
l = ['K','I','H','B','R',-1]
j = 0
 
for i in range(len(s)):
    if s[i] == 'A':
        if i == 0:
            pass
        elif s[i-1] == 'A':
            print('NO')
            exit(0)
        elif j == 1 or j == 2:
            print('NO')
            exit(0)
        else:
            pass
    elif s[i] != l[j]:
        print('NO')
        exit(0)
    else:
        j += 1
 
if j == 5:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    heikin=sum(l)/n
    samunenum=100
    samune=10**18
    for i in range(n):
        x=abs(heikin-l[i])
        if x<samune:
            samunenum=i
            samune=x
    print(samunenum)
resolve()

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long sum = (long) N * T;
		for(int i=0;i<N-1;i++){
			if(Tc[i] + T > Tc[i+1]){
				sum -= Tc[i] + T - Tc[i+1];
			}
		}
		Console.WriteLine(sum);
		
		
		
	}
	int N;
	long[] Tc;
	long T;
	public Sol(){
		var d = ria();
		N = d[0]; T = d[1];
		Tc = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 28256