akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

class Point{
public:
	long long x,y;
	Point():x(0),y(0){}
	Point(long long _x,long long _y):x(_x),y(_y){}
	Point operator-(const Point &o)const{return Point(x-o.x,y-o.y);}
};
bool above(Point a,Point b,Point c){
	b=b-a;c=c-a;
	return b.x*c.y-b.y*c.x>=0;
}

int main(){
	int n;
	scanf("%d",&n);
	vector<long long>a(n),b(n);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	for(int i=0;i<n;i++)scanf("%lld",&b[i]);
	int pos=0;
	for(int i=0;i<n;i++)if(a[i]>a[pos])pos=i;
	rotate(a.begin(),a.begin()+pos,a.end());
	rotate(b.begin(),b.begin()+pos,b.end());
	a.push_back(a[0]);
	b.push_back(b[0]);
	vector<long long>c(n+1,0);
	for(int i=2;i<=n;i++)c[i]=2LL*(c[i-1]+b[i-1])-c[i-2];
	vector<Point>st;
	for(int i=0;i<=n;i++){
		Point p(i,a[i]-c[i]);
		while(int(st.size())>=2&&above(st[int(st.size())-2],st.back(),p))
			st.pop_back();
		st.push_back(p);
	}
	long long ans=0;
	for(int i=1;i<int(st.size());i++){
		long long dx=st[i].x-st[i-1].x;
		ans+=st[i-1].y*(dx+1)+st[i].y*(dx-1);
	}
	for(int i=0;i<n;i++)ans+=2*c[i];
	printf("%.12lf\n",double(ans)/(2.0*n));
	return 0;
}

Measured memory_bytes: 14136
s = input()
t = input()
x = len(t)
y = len(s) - len(t) + 1
z = 0
for i in range(y):
    a = 0
    for j in range(x):
        if s[i + j] == t[j]:
            a += 1
    z = max(z, a)

print(x - z)

Measured memory_bytes: 9056
EPS = 0.0000000001

class Point:
    
    global EPS
    
    def __init__(self, x = 0, y = 0):
        self.x = x
        self.y = y
        
        
    def __add__(a, b):
        s = a.x + b.x
        t = a.y + b.y
        return Point(s, t)
        
    def __sub__(a, b):
        s = a.x - b.x
        t = a.y - b.y
        return Point(s, t)
            
    def __mul__(self, a):
        s = a * self.x
        t = a * self.y
        return Point(s, t)
        
    def __truediv__(self, a):
        s = self.x / a
        t = self.y / a
        return Point(s, t)
            
            
            
            
    def norm(self):
        return self.x * self.x + self.y * self.y
        
    def abs(self):
        return self.norm() ** 0.5
            
    
            
            
    def __eq__(self, other):
        return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS
            
            
            
    def dot(self, b):
        return self.x * b.x + self.y * b.y
        
    def cross(self, b):
        return self.x * b.y - self.y * b.x
    
    
class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

def project(s, p):
    base = s.p2 - s.p1
    hypo = p - s.p1
    r = hypo.dot(base) / base.norm()
    return s.p1 + base * r

def reflecton(s, p):
    return p + (project(s,p) - p) * 2


nums=list(map(int,input().split()))
s = Segment(Point(nums[0], nums[1]), Point(nums[2], nums[3]))

n = int(input())
for i in range(n):
    nums=list(map(int,input().split()))
    p = Point(nums[0], nums[1])
    x = reflecton(s, p)
    print(x.x, x.y)









Measured memory_bytes: 5648
#include<stdio.h>
int main(){
  int a,b,c,i=0,j;
  scanf("%d %d %d",&a,&b,&c);
  for(j=a;j<=b;j++){
    if(c%j==0){
      i++;
    }
  }
  printf("%d\n",i);
  return(0);
}

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

using namespace std;

typedef long long ll;

ll x, ans, d, r;

int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin>>x;
  d = x/11;
  r = x%11;
  ans = 2*d;
  if(r>6)
    ans +=2;
  else if(r>0)
    ans++;
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		double t=sc.nextDouble();
		int a=sc.nextInt();
		int h[]=new int [n];
		double tcand;
		int num=0;

		h[0]=sc.nextInt();
		tcand=Math.abs(a-(t-h[0]*0.006));

		for(int i=1;i<n;++i){
			h[i]=sc.nextInt();
			if (t-h[i]*0.006==a){
				num=i;
				break;
			}
			else if(Math.abs(a-(t-h[i]*0.006))<tcand){
				tcand=Math.abs(a-(t-h[i]*0.006));
				num=i;
			}
		}

		System.out.println(num+1);

	}
}

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

int main() {
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0; i<N; i++){
    cin>>a.at(i);
  }
  
  bool ans = true;
  for(int x : a){
    if(x%2 == 0 && x%3!=0 && x%5!=0){
      ans = false;
      break;
    }
  }
  if(ans) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

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

    vector<vector<ll>> C(N+1, vector<ll>(N+1));
    C[0][0] = 1;
    C[1][0] = 1;
    C[1][1] = 1;
    REP(i,2,N+1) {
        C[i][0] = 1;
        REP(j,1,i+1) {
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
        }
    }
    REP(i,1,K+1) {
        _PR(C[N-K+1][i]*C[K-1][i-1]%MOD);
    }

    return 0;
}

/*



*/

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

using namespace std;

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

        int a, b, c, k;

        cin >> a >> b >> c >> k;

        while(k--)
        {
                if(a >= b && a >= c)
                        a *= 2;
                else if(b >= a && b >= c)
                        b *= 2;
                else
                        c *= 2;
        }

        cout << a + b + c << endl;

        return 0;
}

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

int main(void){
char s[100];
scanf("%s",s);
for(int i=0;s[i]!='\0';i++){
    if(i%2==0){
        if(s[i]!='h'){printf("No\n");return 0;}
    }
    else{
        if(s[i]!='i'){printf("No\n");return 0;}
    }
    if(s[i]!='h'&&s[i]!='i'){printf("No\n");return 0;}
    if(s[strlen(s)-1]!='i'){printf("No\n");return 0;}
}

printf("Yes\n");
}


Measured memory_bytes: 128
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

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

    cout << a + b / 2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,a[105],len=0,res=0;
	cin>>n>>m;
	for (int i=0;i<n;i++)
	{
		cin>>a[i];
		res+=a[i];
	}
	for (int i=0;i<n;i++)
	{
		if (a[i]*m*4>=res)
		{
			len++;
		}
	}
	if (len>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>


using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, P> PP;


const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };


#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, k, q, a[2010], ans = INF2;

ll div(ll mini) {
	vector<ll>v, now;
	int cnt = 1;
	for (int i = 0;i < n;i++) {
		if (a[i] >= mini) {
			now.eb(a[i]);
			cnt++;
		}
		if (i == n - 1 && now.size() >= k) {
			if (now.size() == 0)continue;
			sort(ALL(now));
			for (int j = 0;j <= now.size() - k;j++)v.eb(now[j]);
			now.clear();
		}
		else if (now.size() < k&&a[i] < mini) {
			cnt = 1;
			now.clear();
		}
		else if (now.size() >= k && a[i] < mini) {
			cnt = 1;
			if (now.size() == 0)continue;
			sort(ALL(now));
			for (int j = 0;j <= now.size() - k;j++)v.eb(now[j]);
			now.clear();
		}
	}
	sort(ALL(v));
	if (v.size() < q)return INF2;
	return v[q - 1];
}

int main() {
	cin >> n >> k >> q;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	for (int i = 0;i < n;i++) {
		ans = min(ans, div(a[i]) - a[i]);
	}
	cout << ans << endl;
	return 0;
}



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

int main(){
	int n, a[100];
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	
	for(int i = n - 1; i >= 0; i--){
		cout << a[i];
		if(i != 0){
			cout << ' ';
		}
	}
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
# D - String Formation
s = input()
q = int(input())
f = ''
b = ''
c = 0
for i in range(q):
    query = input().split()
    if query[0]=='1': c += 1 #t1
    else: #t2
        if c%2: #odd:reverse
            if query[1]=='1': #f1
                b += query[2]
            else: #f2
                f += query[2]
        else: #even
            if query[1]=='1': #f1
                f += query[2]
            else: #f2
                b += query[2]

if c%2: print(b[::-1] + s[::-1] + f) #odd
else: print(f[::-1] + s + b) #even

Measured memory_bytes: 4468
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x != null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  printByPreorder(n = this.root) {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.map((line) => line.split(' ')).forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    default: tree.print();
    }
  });

})();



Measured memory_bytes: 269360
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int MAXN = (int) 1500 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int m,n;
int h[MAXN],w[MAXN];
int cnt[1500000 + 10];

void work(){
    while(scanf("%d%d",&n,&m)&&n&&m){
        for(int i=1;i<=n;i++) scanf("%d",&h[i]);
        for(int i=1;i<=m;i++) scanf("%d",&w[i]);
        for(int i=2;i<=n;i++) h[i]+=h[i-1];
        for(int i=2;i<=m;i++) w[i]+=w[i-1];
        for(int i=1;i<=1500000;i++) cnt[i]=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=n;j++){
                cnt[h[j]-h[i]]++;
            }
        }
        LL ans=0;
        for(int i=0;i<m;i++){
            for(int j=i+1;j<=m;j++) ans+=cnt[w[j]-w[i]];
        }
        printf("%lld\n",ans);
    }
}

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













Measured memory_bytes: 8576
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	private static Scanner in;
	private static int n;
	private static int[] h;
	private static long[] dp;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		n = in.nextInt();
		h = new int[n];
		
		for(int i=0; i<n; i++) {
			h[i] = in.nextInt();
		}
		dp = new long[n+1];
		
		Arrays.fill(dp, -1);
		
		System.out.println(solve(0));
		

	}
	
	private static long solve(int i) {
		if (i==n-1) return 0;
		
		if (dp[i]!=-1) return dp[i];
		
		return dp[i]=Math.min(Math.abs(h[i]-h[i+1])+solve(i+1), 
				(i+2<n?Math.abs(h[i]-h[i+2])+solve(i+2):(long)1e15));
	}

}


Measured memory_bytes: 66372
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  at,bt=map(int,input().split())
  a[i]=at
  b[i]=bt
temp=0
for i in range(n):
  a[n-1-i]=a[n-1-i]+temp
  if a[n-1-i]%b[n-1-i]!=0:
    temp=temp+b[n-1-i]-a[n-1-i]%b[n-1-i]
print(temp)

Measured memory_bytes: 21532
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        for(int i = 1; i < 4; i++){
            if(a * b * i % 2 == 1){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }
}


Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int k, s;
  cin >> k >> s;
  int ret = 0;
  for (int i = 0; i <= k; ++i) {
    for (int j = 0; j <= k; ++j) {
      int u = s - i - j;
      if (u >= 0 && u <= k) ++ret;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a=0,b=0,c = 0;
    int i;
    string s,t,q;
    cin >> s >> t;
    if(s.length()!=t.length()){
        cout << "No";
    }
    else{
        for(i=0; i<s.length(); i++){
            a = a + s[i];
            b = b + t[i];
        }
    }
    if(s == t){
        cout << "Yes";
    }
    else{
        if(a==b && a!=0){
            while(s!=t){
                q+= s[s.length()-1];
                for(i=0; i<s.length()-1; i++){
                    q+= s[i];
                }
                s = q;
                q = "";
                c++;
                if(c == 101){
                    cout << "No";
                    break;
                }
            }
            if(c<101){
                cout<<"Yes";
            }
        }
        else{
            cout << "No";
        }
    }

}

Measured memory_bytes: 256
import numpy as np

n = int(input())
num_list = [i for i in range(n)]
city_list = []
point_list = []

for _ in range(n):
  temp = input().split()
  city_list.append(temp[0])
  point_list.append(int(temp[1]))
  
city_set = list(set(city_list))
city_set.sort()

ans=[]
for name in city_set:
  temp = list(filter(lambda x:city_list[x]==name,range(n)))
  temp_num = [num_list[i] for i in temp]
  temp_point = [point_list[i] for i in temp]
  #print(temp_num)
  #print(temp_point)
  while len(temp_num)!=0:
    ans.append(temp_num[np.argmax(temp_point)]+1)
    #print(temp_num[np.argmax(temp_point)])
    del temp_num[np.argmax(temp_point)]
    del temp_point[np.argmax(temp_point)]
for i in ans:
  print(i)

Measured memory_bytes: 12244
using System;

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

            string str = Console.ReadLine();
            int q = int.Parse(Console.ReadLine());

            for (int i = 0; i < q; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[1]);
                int b = int.Parse(input[2]);

                switch (input[0])
                {
                    case "print":
                        Console.WriteLine(str.Substring(a, b - a + 1));
                        break;
                    case "reverse":
                        string copy = null;
                        for (int j = b; j >= a; j--)
                            copy += str[j];
                        Setstr(a, b, ref str, copy);
                        break;
                    case "replace":
                        Setstr(a, b, ref str, input[3]);
                        break;
                    default:
                        break;
                }
            }
        }

        static void Setstr(int a, int b, ref string str,string rep)
        {
            if (a == 0) str = rep + str.Substring(b + 1);
            else if (b == 0) str = str.Substring(0, a) + rep;
            else str = str.Substring(0, a) + rep + str.Substring(b + 1);
        }
    }
}

Measured memory_bytes: 9544
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define szxb 110
#define SG getchar()
using namespace std;
int n,a[szxb];
signed main()
{
	scanf("%d",&n),SG;a[0]=0;
	for(register int i(0);i^n;i++){a[i+1]=(a[i]+(((!(SG-'I'))?(1):(-1))));}
	printf("%d",(*max_element(a,a+n+1)));
	return putchar(10),0;
}

Measured memory_bytes: 256
from math import sqrt
class Factorizer:
    def __init__(self):
        self.primes_ceil = 5
        self.primes = [2,3]

    def find_primes(self, primes_ceil):
        if primes_ceil <= self.primes_ceil:
            return self.primes

        prev_primes_ceil, self.primes_ceil = self.primes_ceil, primes_ceil
        r, m = prev_primes_ceil//6, prev_primes_ceil%6
        if m <= 1:
            i = r*6 + 1
            mod_flag = True
        else:
            i = r*6 + 5
            mod_flag = False

        while i < self.primes_ceil:
            sieve = True
            for p in self.primes:
                if p*p > i:
                    break
                elif i % p == 0:
                    sieve = False
                    break
            if sieve:
                self.primes.append(i)
            if mod_flag:
                i += 4
                mod_flag = False
            else:
                i += 2
                mod_flag = True

        return self.primes

    def __call__(self, n):
        if (self.primes_ceil-1)**2 < n:
            self.find_primes(int(sqrt(n))+1)
        factors = []
        powers = []
        for p in self.primes:
            if p * p > n:
                break
            elif n % p == 0:
                n //= p
                k = 1
                while n % p == 0:
                    n //= p
                    k += 1
                factors.append(p)
                powers.append(k)
        if n > 1:
            factors.append(n)
            powers.append(1)
        return factors, powers

inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
S = sum(A)
factorize = Factorizer()

ft, pw = factorize(S)
n = len(ft)
denominators = [1]
for i in range(n):
    new_denominators = []
    for d in denominators:
        for p in range(pw[i]+1):
            new_denominators.append(d*(ft[i]**p))
    denominators = new_denominators
denominators.sort(reverse=True)

for d in denominators:
    mods = [a%d for a in A]
    mods.sort()
    Sm = sum(mods)
    h = Sm // d
    minK = min(d*(h+1)-sum(mods[N-h-1:]), sum(mods[:N-h]))
    if minK <= K:
        print(d)
        exit()

Measured memory_bytes: 43740
#include<iostream>
using namespace std;
int main(){
	string s;
	int mark[26];
	cin>>s;
	for(int i=0;i<26;i++)mark[i]=0;
	
	for(int i=0;i<s.length();i++)
	{
       mark[s.at(i)-'a']=1;
	}
	for(int i=0;i<26;i++)
		if(mark[i]==0)
		{
			char a = 'a'+i;
			cout<<a;
			return 0;
		}
	cout<<"None";
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x,y;
    cin >> x >> y;
    ll ans;
    if(x >= y){
        ans = min(x*a+y*b, min(c*y*2+(x-y)*a, c*x*2));
    }else{
        ans = min(x*a+y*b, min(c*x*2+(y-x)*b, c*y*2));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
prime =[3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]
count = 0
for i in range(N):
    if i+1 >= 105 and (i+1) % 2 == 1:
        tmp = 0
        for j in range(i+1):
            if (i+1) % (j+1) == 0:
                tmp += 1
        if tmp == 8:
            count += 1
print(count)
        


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int X,Y;
int f[20][20];
int dp[20][20];
int d[3]={1,0,-1};
int main()
{
	while(1)
	{
		int ans=0;
		memset(dp,0,sizeof(dp));
		memset(f,0,sizeof(f));
		scanf("%d %d",&Y,&X);
		if(X==0&&Y==0)break;
		for(int i=0;i<X;i++)
		{
			for(int j=0;j<Y;j++)
			{
				scanf("%d",&f[i][j]);
			}
		}
		for(int i=0;i<Y;i++)
		{
			if(f[0][i]==0)dp[0][i]=1;
			else dp[0][i]=0;
		}
		for(int i=0;i<X-1;i++)
		{
			for(int j=0;j<Y;j++)
			{
				if(f[i][j]==0)
				{
					for(int k=0;k<3;k++)
					{
						if(j+d[k]<0||j+d[k]>=Y)continue;
						if(f[i+1][j+d[k]]==2&&d[k]!=0)continue;
						//if(j==Y-1&&d[k]!=0)continue;
						dp[i+1][j+d[k]]+=dp[i][j];
					}
				}
				else if(f[i][j]==2)
				{
					dp[i+2][j]+=dp[i][j];
				}
			}
		}
		/*cout << endl;
		for(int i=0;i<=X+1;i++)
		{
			for(int j=0;j<Y;j++)
			{
				cout << dp[i][j] << ' ';
			}
			cout << endl;
		}*/
		for(int i=X-1;i<=X;i++)
		{
			for(int j=0;j<Y;j++)if(f[i][j]!=1)
			{
				ans+=dp[i][j];
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1188
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    XY = [list(map(int, input().split())) for _ in range(N)]
    P = []
    Q = []
    if N == 1:
        print(1)
        return
    for i in range(N - 1):
        for j in range(i + 1, N):
            p = XY[j][0] - XY[i][0]
            q = XY[j][1] - XY[i][1]
            P.append(p)
            Q.append(q)
    ans = float("inf")

    for p, q in zip(P, Q):
        a = N
        for i in range(N):
            x, y = XY[i][0], XY[i][1]
            if [x + p, y + q] in XY:
                a -= 1
        if a < ans:
            ans = a
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string s,t;
    cin>>s>>t;
    string a=t+t;
    REP(i,s.size()){
        REP(j,s.size()){
            if(s[j]!=a[j+i]){
                break;
            }
            if(j==s.size()-1){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

int bitn = 1, bit[200002];
int L[300002], R[300002];
void add(int l, int r){
	while(l <= bitn){
		bit[l]++;
		l += l&-l;
	}
	r++;
	while(r <= bitn){
		bit[r]--;
		r += r&-r;
	}
}
int get(int x){
	int res = 0;
	while(x > 0){
		res += bit[x];
		x -= x&-x;
	}
	return res;
}

vector<PP> v;
signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	rep(i,n)scanf("%lld%lld", &L[i], &R[i]);
	while(bitn < m)bitn *= 2;
	rep(i,n)v.push_back(PP(R[i]-L[i], P(L[i], R[i])));
	sort(all(v));
	
	int s = n, cnt = 0, ans = 0;
	rrep(i,m){
		while(cnt < n && i > v[cnt].fi){
			add(v[cnt].se.fi, v[cnt].se.se);
			cnt++;s--;
		}
		int sum = 0;
		rrep(j,m){
			if(i*j > m)break;
			sum += get(i*j);
		}
		printf("%lld\n", sum+s);
	}
	return 0;
}

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

using namespace std;

int main() {
    
    int A, B, C, D, E;
    int k;
    cin >> A >> B >> C >> D >> E >> k;
    
    vector<int> dist;
    dist.push_back(abs(A - B)); 
    dist.push_back(abs(A - C)); 
    dist.push_back(abs(A - D)); 
    dist.push_back(abs(A - E)); 
    dist.push_back(abs(B - C)); 
    dist.push_back(abs(B - D)); 
    dist.push_back(abs(B - E)); 
    dist.push_back(abs(C - D)); 
    dist.push_back(abs(C - E)); 
    dist.push_back(abs(D - E)); 

    bool p = true; 
    for (size_t i = 0; i < dist.size(); i++) {
        if (dist[i] > k)
            p = false;
    }
    cout << (p ? "Yay!" : ":(") << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    if(i%3==0){
      printf(" %d",i);
    }
    else{
      x=i;
      while(x>0){
        if(x%10==3){
          printf(" %d",i);
          break;
        }
        x/=10;
      }
    }
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2656
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int a,b,c;
int kq;

int main(){
  scanf("%d%d%d",&a,&b,&c);
  int z=min(c,a-b);
  //cout<<"Z= "<<z<<endl;
  cout<<(c-z);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::string s;std::cin>>s;
    lint ans=0;
    std::string t="RGB";
    std::sort(ALL(t));
    do {
        for(lint i=0,a=0,ab=0;i<n;i++){
            a+=s.at(i)==t.at(0);
            ab+=(s.at(i)==t.at(1))*a;
            ans+=(s.at(i)==t.at(2))*ab;
        }
        for(lint d=1;d<n;d++){
            for(lint i=0;i+2*d<n;i++){
                ans-=s.at(i)==t.at(0)&&s.at(i+d)==t.at(1)&&s.at(i+d+d)==t.at(2);
            }
        }
    } while(std::next_permutation(ALL(t)));
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 3664
#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)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

using pll = pair<ll, ll>;

int N;
vector<ll> X, Y;
vector<char> D;

inline double func2(ll xmind, ll xmaxd, ll mn[2], ll mx[2], double t) {
	pair<double, double> res;
	res.fi = min({ (double)xmind, mn[0] + t, mn[1] - t });
	res.se = max({ (double)xmaxd, mx[0] + t, mx[1] - t });
	return res.se - res.fi;
}

vector<double> func(vector<ll> &x, ll xmind, ll xmaxd, ll mn[2], ll mx[2], char inc, char dec) {
	// mn, mx : [0]'R', [1]'L'
	vector<double> res;
	res.push_back(0);
	res.push_back(INF);
	
	REP(i, N) if (D[i] == inc || D[i] == dec) {
		chmin(mn[D[i] == dec], x[i]);
		chmax(mx[D[i] == dec], x[i]);
	}
	
	if (xmind == INF) return res;
	if (mn[0] != INF) {
		if (mn[0] < xmind) res.push_back(xmind - mn[0]);
		if (mx[0] < xmaxd) res.push_back(xmaxd - mx[0]);
	}
	if (mn[1] != INF) {
		if (mx[1] > xmaxd) res.push_back(mx[1] - xmaxd);
		if (mn[1] > xmind) res.push_back(mn[1] - xmind);
	}
	return res;
}

int main() {
	cin >> N;
	X.resize(N);
	Y.resize(N);
	D.resize(N);
	REP(i, N) scanf("%lld %lld %c", &X[i], &Y[i], &D[i]);
	
	ll xmind = INF, xmaxd = -INF, ymind = INF, ymaxd = -INF;
	ll mn[2][2], mx[2][2];
	fill(mn[0], mn[2], INF);
	fill(mx[0], mx[2], -INF);
	
	REP(i, N) {
		if (D[i] != 'R' && D[i] != 'L') {
			chmin(xmind, X[i]);
			chmax(xmaxd, X[i]);
		}
		else {
			chmin(ymind, Y[i]);
			chmax(ymaxd, Y[i]);
		}
	}
	
	vector<double> T = func(X, xmind, xmaxd, mn[0], mx[0], 'R', 'L');
	vector<double> tmpv = func(Y, ymind, ymaxd, mn[1], mx[1], 'U', 'D');
	T.insert(T.end(), ALL(tmpv));
	
	REP(i, 2) REP(j, 2) REP(l, 2) {
		if (mx[i][j] != -INF && mn[i][l] != INF) T.push_back(abs(mx[i][j] - mn[i][l]) / 2.0);
		if (mn[i][j] != INF && mn[i][l] != INF) T.push_back(abs(mn[i][j] - mn[i][l]) / 2.0);
		if (mx[i][j] != -INF && mx[i][l] != -INF) T.push_back(abs(mx[i][j] - mx[i][l]) / 2.0);
	}
	
	sort(ALL(T));
	T.erase(unique(ALL(T)), T.end());
	
	double ans = longINF;
	REP(t, T.size() - 1) chmin(ans, func2(xmind, xmaxd, mn[0], mx[0], T[t]) * func2(ymind, ymaxd, mn[1], mx[1], T[t]));
	printf("%.15lf\n", ans);
	return 0;
}



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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

bool table[110][110];

int main(void){
	int n;
	while(cin >> n){
		if(n==0)
			break;
		rep(i,110)rep(j,110) table[i][j]=false;
		int w,h;
		cin >> w >> h;
		rep(i,n){
			int x,y;
			cin >> x >> y;
			x--,y--;
			table[x][y]=true;
		}
		int s,t;
		cin >> s >> t;
		int ans=0;
		rep(x,w-s+1)rep(y,h-t+1){
			int cur=0;
			rep(i,s)rep(j,t) cur+=table[x+i][y+j];
			ans=max(ans,cur);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
import sys

X, Y = map(int, input().split())
mod = 10 ** 9 + 7

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    # 整数解がない場合
    print(0)
    sys.exit()


m = (2 * X - Y) // 3
n = (2 * Y - X) // 3

# これか？
if m < 0 or n < 0:
    print(0)
    sys.exit()

u = m + n
fact = [1] * (u+1)

for i in range(1, u+1):
    fact[i] = (fact[i-1] * i) % mod

fact_inv1 = pow(fact[n], mod-2, mod)
fact_inv2 = pow(fact[m], mod-2, mod)

res = (((fact[u] * fact_inv1) % mod) * fact_inv2) % mod

print(res)

Measured memory_bytes: 29428
/*
THINGS TO DO
1) Check integer overflows
2) Check corner cases
3) Compile and run once on terminal
4) Code smart, not quick
*/

#ifndef ONLINE_JUDGE
	#define _GLIBCXX_DEBUG
	#include "debug.cpp"
#endif

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


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

	int h, w, m, i, j, r, c;
	cin >> h >> w >> m;
	vector<int> rows(h);
	vector<int> col(w);

	set<pair<int, int>>sp;

	for(i=0; i<m; i++){
		cin >> r >> c;
		r--; c--;
		sp.insert({r, c});
		rows[r] += 1;
		col[c] += 1;
	}

	// print(rows);
	// print(col);

	vector<int> arr1, arr2;
	int maxr = 0, maxc = 0;
	for(auto x: rows)
		maxr = max(maxr, x);
	for(auto x: col)
		maxc = max(maxc, x);

	for(i=0; i<rows.size(); i++){
		if(rows[i] == maxr)
			arr1.push_back(i);
	}
	for(i=0; i<col.size(); i++){
		if(col[i] == maxc)
			arr2.push_back(i);
	}

	// print(arr1);
	// print(arr2);

	int flag = 0;
	for(i=0; i<arr1.size(); i++){
		for(j=0; j<arr2.size(); j++){
			if(sp.find({arr1[i], arr2[j]}) == sp.end()){
				flag = 1;
				break;
			}
		}
		if(flag == 1)
			break;
	}
	if(flag == 1)
		cout << maxr+maxc << "\n";
	else
		cout << maxr+maxc-1 << "\n";


	// cout << maxr+maxc << "\n";


}

//Read the stuff at the top

Measured memory_bytes: 23824
n = int(input())
a = []
total = 0
for i in range(n):
  a.append(list(map(str,input().split())))
  if a[i][1]== "JPY":
    total += int(a[i][0])
  else:
    total += float(a[i][0])*380000.0
 
print(total)
    
  

Measured memory_bytes: 2940
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		int[] a = new int[n];
		int index = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			if (a[i] == 1)
				index = i;
		}
		int ans = 0;
		loop: while (true) {
			int i = 0;
			while (a[i] != 1)
				i++;
			if (i == 0) {
				while (i < n && a[i] == 1)
					i++;
				if (i == n) break loop;
				for (int j = i - 1; j < Math.min(i - 1 + k, n); j++)
					a[j] = 1;
			}
			else {
				int s = i - k + 1;
				if (s < 0) s = 0;
				else {
					while (s % (k - 1) != 0)
						s++;
				}
				for (int j = s; j < Math.min(s + k, n); j++) {
					a[j] = 1;
				}
			}
			ans++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 49388
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> XY(N);
    rep(i, N) {
        cin >> XY[i].first >> XY[i].second;
    }
    sort(all(XY));

    if (N == 1) {
        write(1);
        return 0;
    }

    int ans = INF;
    rep(i, 0, N) rep(j, 0, N) {
        if (i == j) continue;

        int p = XY[j].first - XY[i].first;
        int q = XY[j].second - XY[i].second;
        
        int cost = 1;
        rep(k, 0, N) {
            if (k == i || k == j) continue;

            int x = XY[k].first, y = XY[k].second;
            bool b = false;
            rep(l, 0, N) {
                if (l != k && (x - p == XY[l].first && y - q == XY[l].second)) {
                    b = true;
                }
            }
            cost += b ? 0 : 1;
        }

        chmin(ans, cost);
    }

    write(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl b(n - 1);
  rep(i, n - 1) cin >> b[i];
  reverse(all(b));
  ll ans = b[0];
  rep2(i, 1, n - 1) ans += min(b[i - 1], b[i]);
  ans += b.back();
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    for(int i=0;i<N-2;i++){
        if(S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C'){
                    res ++;
                }
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a;
    int b;
    int c;
    int ans;
    
    cin >> a;
    cin >> b;
    cin >> c;
    if(a + b <= b + c && a + b <= c + a){
        ans = a + b ;
    } else if (b + c <= c + a && b + c <= a + b){
        ans = b + c ;
    } else {
        ans = c + a ;
    };
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i<n;i++){
    cin >> v[i];
  }
  double dp[n+1][n+1];
  dp[0][0] = 1;
  for(int i = 1; i<=n;i++){
    dp[0][i] = dp[0][i-1]*(1-v[i-1]);
  }
  for(int i = 1;i<=n;i++){
    for(int j = 0; j<=n;j++){
      if(i>j){
	dp[i][j] = 1;
      }else if(i==j){
	dp[i][j] = dp[i-1][j-1]*v[j-1];
      }else{
	dp[i][j] = dp[i][j-1]*(1-v[j-1])+dp[i-1][j-1]*v[j-1];
      }
    }
  }
  double ans = 0;
  for(int i = n/2+1;i<=n;i++){
    ans+=dp[i][n];
  }
  cout << ans<<'\n';
  return 0;
}


Measured memory_bytes: 74108
using System;
using System.Collections.Generic;
class Program{
	static List<long> he1=new List<long>();
	static List<long> he2=new List<long>();
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
		long[] a1=new long[n*3];
		long[] a2=new long[n*3];
		for(int i=n*3-1;i>=n*2;i--){
			a2[n*2]+=s[i];
			heapa2(s[i]);
		}
		for(int i=n*2-1;i>=n;i--){
			heapa2(s[i]);
			a2[i]=a2[i+1]+s[i]-he2[0];
			heapr2();
		}
		for(int i=0;i<n;i++){
			a1[n-1]+=s[i];
			heapa1(s[i]);
		}
		long ans=a1[n-1]-a2[n];
		for(int i=n;i<n*2;i++){
			heapa1(s[i]);
			a1[i]=a1[i-1]+s[i]-he1[0];
			heapr1();
			ans=Math.Max(ans,a1[i]-a2[i+1]);
		}
		Console.WriteLine(ans);
	}
	static void heapa1(long a){
		he1.Add(a);
		int j=he1.Count-1;
		while(he1[j]<he1[(j-1)/2]){
			long v=he1[j];
			he1[j]=he1[(j-1)/2];
			he1[(j-1)/2]=v;
			j=(j-1)/2;
		}
	}
	static void heapr1(){
		he1[0]=he1[he1.Count-1];
		he1.RemoveAt(he1.Count-1);
		int j=0;
		while(true){
			if(j*2+2<he1.Count){
				if(he1[j*2+1]<he1[j*2+2]){j=j*2+1;}
				else{j=j*2+2;}
			}
			else if(j*2+1<he1.Count){j=j*2+1;}
			else{break;}
			if(he1[j]>=he1[(j-1)/2]){break;}
			long v=he1[j];
			he1[j]=he1[(j-1)/2];
			he1[(j-1)/2]=v;
		}
	}
	static void heapa2(long a){
		he2.Add(a);
		int j=he2.Count-1;
		while(he2[j]>he2[(j-1)/2]){
			long v=he2[j];
			he2[j]=he2[(j-1)/2];
			he2[(j-1)/2]=v;
			j=(j-1)/2;
		}
	}
	static void heapr2(){
		he2[0]=he2[he2.Count-1];
		he2.RemoveAt(he2.Count-1);
		int j=0;
		while(true){
			if(j*2+2<he2.Count){
				if(he2[j*2+1]>he2[j*2+2]){j=j*2+1;}
				else{j=j*2+2;}
			}
			else if(j*2+1<he2.Count){j=j*2+1;}
			else{break;}
			if(he2[j]<=he2[(j-1)/2]){break;}
			long v=he2[j];
			he2[j]=he2[(j-1)/2];
			he2[(j-1)/2]=v;
		}
	}
}

Measured memory_bytes: 45868
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        
        // 出力
        System.out.println(a*b);
    }
}

Measured memory_bytes: 35732
# Union Find 木
from sys import setrecursionlimit


def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


setrecursionlimit(10 ** 5)


N, M = map(int, input().split())
p = list(map(int, input().split()))

parent = [-1] * N
for _ in range(M):
    x, y = map(int, input().split())
    unite(parent, x - 1, y - 1)

result = 0
for i in range(N):
    if find(parent, i) == find(parent, p[i] - 1):
        result += 1
print(result)


Measured memory_bytes: 14008
global count


def merge(arr, l, mid, r):
    arr_copy = list(arr[l:r + 1])
    global count
    l_idx, r_idx = l, mid + 1
    for i in range(l, r + 1):
        if l_idx > mid:
            arr[i] = arr_copy[r_idx - l]
            r_idx += 1
        elif r_idx > r:
            arr[i] = arr_copy[l_idx - l]
            l_idx += 1
        elif arr_copy[l_idx - l] <= arr_copy[r_idx - l]:
            arr[i] = arr_copy[l_idx - l]
            l_idx += 1
        else:
            arr[i] = arr_copy[r_idx - l]
            count += mid - l_idx + 1
            r_idx += 1


def merge_sort(arr, l, r):
    if l >= r:
        return
    mid = (l + r) // 2
    merge_sort(arr, l, mid)
    merge_sort(arr, mid + 1, r)
    merge(arr, l, mid, r)


if __name__ == '__main__':
    n = int(input())
    arr = list(map(int, input().split()))
    count = 0
    merge_sort(arr, 0, n - 1)
    print(count)



Measured memory_bytes: 27472
#include <stdio.h>
#include <vector>
#include <queue>

std::vector<int> a6, a9;

int get6(int n) {
	int tmp = *a6.begin();
	for(auto itr = a6.begin();itr < a6.end();itr++) {
		if(*itr > n) {
			break;
		} else {
			tmp = *itr;
		}
	}

	return tmp;
}

int get9(int n) {
	int tmp2 = *a9.begin();
	for(auto itr = a9.begin();itr < a9.end();itr++) {
		if(*itr > n) {
			break;
		} else {
			tmp2 = *itr;
		}
	}
	
	return tmp2;
}

std::priority_queue<int, std::vector<int>, std::greater<int>> p_queue;

int getRec(int n, int count) {

	if(n < 6) {
		p_queue.push(n + count);
	} else if(n >= 6 && n < 9) {
		int t6 = get6(n);
		getRec(n - t6, count + 1);
	} else {
		int t6 = get6(n);
		int t9 = get9(n);
		getRec(n - t6, count + 1);
		getRec(n - t9, count + 1);
	}
}


int getRes(int n) {
	getRec(n, 0);

	return p_queue.top();
}

int main() {

	int n;
	scanf("%d", &n);


	int tmp = 6;
	while(tmp < 100000) {
		a6.push_back(tmp);
		tmp = tmp * 6;
	}

	tmp = 9;
	while(tmp < 100000) {
		a9.push_back(tmp);
		tmp = tmp * 9;
	}

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

	return 0;
}



Measured memory_bytes: 9964
#include <cstdio>
#include <algorithm>
using namespace std;
int players[11];
char cards[101];

int main() {
    int n, table, id;
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        fill(players, players+n, 0);
        table = id = 0;
        scanf("%s", cards);
        for (int i = 0; i < 100; i++) {
            if (cards[i] == 'M') { players[id]++; }
            else if (cards[i] == 'S') { table += players[id]+1; players[id] = 0; }
            else if (cards[i] == 'L') { players[id] += table+1; table = 0; }
            id = (id+1) % n;
        }
        sort(players, players+n);
        for (int i = 0; i < n; i++) {
            printf("%d ", players[i]);
        }
        printf("%d\n", table);
    }
    return 0;
}



Measured memory_bytes: 2764
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db long double
#define inf 5000001
#define INF (ll)1e15 
#define pi acos(-1)
#define mxbit 30
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;

struct edge{
	int y,nxt;
	edge(){}
	edge(int yy,int nn){
		y=yy,nxt=nn;
	}
}e[inf*2];
int head[inf],ecnt;

void addedge(int x,int y){
	ecnt++;
	e[ecnt]=edge(y,head[x]);
	head[x]=ecnt;
	return;
}

int p[inf],cnt[inf];

void dfs(int u,int last){
	p[u]=0;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].y;
		if (v!=last && cnt[u]>cnt[v]){
			dfs(v,u);
			if (!p[v]){
				p[u]=1;
				break;
			}
		}
	}
	return;
}

int main(){
	int n;
	rd(n)
	for (int i=1;i<=n;i++){
		rd(cnt[i])
	}
	int x,y;
	for (int i=1;i<n;i++){
		rd(x) rd(y)
		addedge(x,y);
		addedge(y,x);
	}
	for (int i=1;i<=n;i++){
		dfs(i,0);
		if (p[i]){
			printf("%d ",i);
		}
	}
	return 0;
}

Measured memory_bytes: 6400
def c_linear_approximation(N, A):
    import numpy
    B = numpy.array([a-k for k, a in enumerate(A)])
    b = int(numpy.median(B))
    ans = 0
    for b_k in B:
        ans += abs(b_k - b)
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(c_linear_approximation(N, A))

Measured memory_bytes: 29520
# tenka1-2018-beginnerB - Exchange
def main():
    a, b, k = list(map(int, input().rstrip().split()))
    for i in range(k):
        if i % 2 == 0:
            if a % 2 == 1:
                a -= 1
            a //= 2
            b += a
        else:
            if b % 2 == 1:
                b -= 1
            b //= 2
            a += b
    print(a, b)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

x,y=MI()
ans=1

a=x
for i in range(1000):
    a=a*2
    if a>y:
        break
    ans+=1
    
print(ans)




Measured memory_bytes: 38256
using System;

namespace AOJ.Volume5
{
    public class CardGame
    {
        public static int Main()
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                int point_a = 0;
                int point_b = 0;

                for (int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int a = int.Parse(input[0]);
                    int b = int.Parse(input[1]);

                    if (a > b) { point_a += a + b; }
                    else if (a == b)
                    {
                        point_a += a;
                        point_b += b;
                    }
                    else { point_b += a + b; }
                }

                Console.WriteLine(string.Format("{0} {1}", point_a, point_b));
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int main(){
	
	int w, h;
	
	while(true){
		cin >> w >> h;
		if(w * h == 0){
			break;
		}
		int map[80][80] = {};
		
		for(int i = 0; i < h * 2 - 1; i++){
			if(i % 2 == 0){
				for(int j = 1; j < w * 2 - 1; j += 2){
					cin >> map[j][i];
				}
			}else{
				for(int j = 0; j < w * 2 - 1; j += 2){
					cin >> map[j][i];
				}
			}
		}
		
		queue<P> que;
		
		P hoge;
		hoge.first = 0;
		hoge.second = 0;
		
		que.push(hoge);
		
		for(int loop = 1; loop < 1000; loop++){
			int N = que.size();
			if(N == 0){
				break;
			}
			for(int i = 0; i < N; i++){
				P p = que.front();
				que.pop();
				int x = p.first;
				int y = p.second;
				
				if(x < 0 || x >= w * 2 || y < 0 || y >= h * 2){
					continue;
				}
				if(map[x][y] != 0){
					continue;
				}
				
				map[x][y] = loop;
				
				if(x > 0 && !map[x - 1][y]){
					P p1;
					p1.first = x - 2;
					p1.second = y;
					que.push(p1);
				}
				if(y > 0 && !map[x][y - 1]){
					P p1;
					p1.first = x;
					p1.second = y - 2;
					que.push(p1);
				}
				if(!map[x + 1][y]){
					P p1;
					p1.first = x + 2;
					p1.second = y;
					que.push(p1);
				}
				if(!map[x][y + 1]){
					P p1;
					p1.first = x;
					p1.second = y + 2;
					que.push(p1);
				}
			}
		}
		/*
		for(int i = 0; i <= w * 2; i++){
			for(int j = 0; j <= h * 2; j++){
				cout << map[i][j] << " ";
			}
			cout << endl;
		}
		*/
		cout << map[w * 2 - 2][h * 2 - 2] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3132