akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var hs=new Dictionary<string,int>();
		int p=1;
		for(int i = 0;i<n;i++) {
			var e=sc.S;
			if(hs.ContainsKey(e)){
				hs[e]++;
				p=Max(p,hs[e]);
			}
			else{hs.Add(e,1);}
		}
		var li=new List<string>();
		foreach(var e in hs){
			if(e.Value==p){
				li.Add(e.Key);
			}
		}
		li.Sort(StringComparer.Ordinal);
		Console.WriteLine(String.Join("\n",li));
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

// LOOP
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
//

// DEBUG
#define format(x) << #x << ": " << (x)
#define com << ", "
#define ndl << "\n"
#define debug1(x) cerr format(x) ndl;
#define debug2(x, y) cerr format(x) com format(y) ndl;
#define debug3(x, y, z) cerr format(x) com format(y) com format(z) ndl;
void debug_out() { cerr << "\n"; }
template <typename H, typename... T> 
void debug_out(H h, T... t) { cerr << " " << (h); debug_out(t...); }
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
// 

void solve() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  char x = 'L', y = 'R';
  if (s[0] == x) swap(x, y);
  int res = n - 1;
  FOR(i, 1, n) {
    if (k and s[i] == x) {
      FOR(j, i, n) {
        if (s[j] == y) break;
        s[j] = y;
      }
      k--;
    }
    if (s[i] != s[i - 1]) res--;
  }
  cout << res << "\n";
  // read the question correctly (is y a vowel?)
  // look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie();
  //auto beginProgram = chrono::steady_clock::now();
  {
    solve();
  }
  //auto endProgram = chrono::steady_clock::now();

  return 0;
}




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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

int a, b;

int deg[233];

vector<int> e[233];

bool vis[233];

int s=0;

void dfs(int u)
{
	vis[u] = 1;++s;
	for (auto v : e[u]) if(!vis[v]) dfs(v);
}

int main()
{
	for (int i = 1; i < 4; ++i) gii(a,b),++deg[a],++deg[b],e[a].pb(b),e[b].pb(a);
	sort(deg+1,deg+5);
	if (deg[1] != 1 || deg[2] != 1 || deg[3] != 2 || deg[4] != 2) return puts("NO"), 0;
	//cerr<<"ok!"<<endl;
	dfs(1); 
	puts(s==4?"YES":"NO");
 } 


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int d, g;

int solve(vector<int> p, const vector<int>& c, int s){
    int ans = 0;
    int point = 0;

    rep(i, d){
        if((s >> i) % 2 == 0){
            continue;
        }
        ans += p[i];
        point += (i + 1) * 100 * p[i] + c[i];
        p[i] = 0;
    }

    while(point < g){
        for(int i = d - 1; i >= 0; i--){
            if(p[i] == 0){
                continue;
            }

            ans++;
            p[i]--;
            point += (i + 1) * 100;
            if(p[i] == 0){
                point += c[i];
            }
            break;
        }
    }

    return ans;
}

signed main(){
    cin >> d >> g;

    vector<int> p(d), c(d);
    rep(i, d) cin >> p[i] >> c[i];

    vector<int> cmp(d);
    rep(i, d){
        cmp[i] = (i + 1) * 100 * p[i] + c[i];
    }

    int ans = INF;
    rep(s, (1 << d)){
        int tmp = solve(p, c, s);
        if(ans > tmp){
            ans = tmp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
    [n, yen] <- map read . words <$> getLine
    let ans =
            [ [x, y, n - x - y]
            | x <- [0 .. n]
            , y <- [0 .. n - x]
            , 10000 * x + 5000 * y + 1000 * (n - x - y) == yen
            ]
    putStrLn . unwords . map show $ if null ans then [-1, -1, -1] else head ans


Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ss0 = br.readLine().trim().split(" ", 0);
		int N = Integer.parseInt(ss0[0]);
		long T = Integer.parseInt(ss0[1]);
		
		ss0 = br.readLine().trim().split(" ", 0);
		long[] t = new long[N];
		for(int i = 0; i < N; i++){
			t[i] = Long.parseLong(ss0[i]);
		}
		
		long ans = 0;
		for(int i = 0; i < N-1; i++){
			//System.out.println("t[i]=[" + t[i] + "], t[i+1]=[" + t[i+1] + "], ans=[" + ans + "]");
			if( (t[i] + T) > t[i+1] ) {
				ans += t[i+1] - t[i];
			} else {
				ans += T;
			}
			//System.out.println("t[i]=[" + t[i] + "], t[i+1]=[" + t[i+1] + "], ans=[" + ans + "]");
			//System.out.println("");
		}
		
		ans += T;
		
        System.out.println(ans);
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

Measured memory_bytes: 52140
from itertools import combinations

N = int(input())
cnt_dict = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for _ in range(N):
    tmp = input()
    if tmp[0] in cnt_dict:
        cnt_dict[tmp[0]] += 1

res = 0
for value in combinations(cnt_dict.values(), 3):
    res += (value[0]*value[1]*value[2])

print(res)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int N,K,Q;
    cin>>N>>K>>Q;
    int A[Q],Point[N];
    for(int i=0;i<Q;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        Point[i]=0;
    }
    for(int i=0;i<Q;i++){
        Point[A[i]-1]++;
    }
    for(int i=0;i<N;i++){
        if(Q-Point[i]>=K){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        int cnt2=0;

        for(int i =1;i<=n;i++){
            for(int j =1;j<=i;j++){
                if(i%j==0 && j%2==1){
                    cnt++;
                }
            }
            if(cnt==8){
                cnt2++;
                //System.out.println(i);
            }
            cnt=0;
        }

            System.out.println(cnt2);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(){
    ll n;;
    cin >> n;
    vector<ll> a;
    for(ll i = 0; i < n; ++i){
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    ll count1 = 0;
    ll count2 = 0;
    ll sum1 = 0;
    ll sum2 = 0;
    if(a[0]==0){
        count1++;
        sum1 = 1;
    }
    for(ll i = 0; i < n; ++i){
        if(i % 2 == 0){
            if (sum1 + a[i] > 0) sum1 += a[i];
            else {
                count1 += 1 - sum1 - a[i];
                sum1 = 1;
            }
        } else {
            if (sum1 + a[i] < 0) sum1 += a[i];
            else {
                count1 += 1 + sum1 + a[i];
                sum1 = -1;
            }
        }
    }
    
    if(a[0]==0){
        count2++;
        sum2 = -1;
    }
    for(ll i = 0; i < n; ++i){
        if(i % 2 == 0){
            if (sum2 + a[i] < 0) sum2 += a[i];
            else {
                count2 += 1 + sum2 + a[i];
                sum2 = -1;
            }
        } else {
            if (sum2 + a[i] > 0) sum2 += a[i];
            else {
                count2 += 1 - sum2 - a[i];
                sum2 = 1;
            }
        }
    }
    
    cout << min(count1,count2) << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int N;
int a[200001],b[200001];


int main (){
      cin>>N;
      rep0(i,N) cin>>a[i];
      rep0(i,N) cin>>b[i];
      int ans=0;
      for(int k=28;k>=0;k--){
            int hoge = 1<<(k+1);
            rep0(i,N) a[i]%=hoge;
            rep0(i,N) b[i]%=hoge;
            sort(b,b+N);
            int T = 1<<k;
            ll piyo=0;
            rep0(i,N){
                  ll huga=lower_bound(b,b+N,2*T-a[i])-lower_bound(b,b+N,T-a[i]);
                  ll mochi=lower_bound(b,b+N,4*T-a[i])-lower_bound(b,b+N, 3*T-a[i]);
                  piyo+=(huga+mochi);
            }
            ans=2*ans+(piyo%2);
      }
      cout<<ans<<endl;

      return 0;
}


Measured memory_bytes: 1792
#関数を持ってくる
from collections import deque

#入力(座標をリストで扱いやすいように-1する)
r,c = map(int,input().split())
c_list = [list(input()) for nesya in range(r)]
for hoge in c_list:
  hoge.insert(0,'#')
  hoge.append('#')
c_list.insert(0,['#']*(c+2))
c_list.append(['#']*(c+2))

ans = 0
for j in range(r+2):
  for i in range(c+2):
    #dequeオブジェクトを作る
    d = deque()
    #その座標を扱ったかを調べるためのリストを作る
    hoge_list = [[-1]*(c+2) for motsu in range(r+2)]
    if  c_list[j][i] == '#':
      continue
    else:
      #スタート位置をdに加え、到達時刻を0にする
      d.append((j,i))
      hoge_list[j][i] = 0

      #当該の座標から動かすためのリストを作る
      move =[[1,0],[-1,0],[0,1],[0,-1]]

      #座標に対して作業する
      while len(d) > 0:
        #今から扱う座標をcoordとする
        coord = d.popleft()
  
        #縦横に移動したときそれぞれのマスに作業する
        for k in range(4):
          #移動した後の座標
          x = coord[1] + move[k][1]
          y = coord[0] + move[k][0]
    
          #作業が終わっている座標であったら無視する
          if hoge_list[y][x] != -1:
            pass
          #マスが壁であった場合-2を代入して終わる
          elif c_list[y][x] == '#':
            hoge_list[y][x] = -2
          #作業するマス
          else:
            #当該座標から1移動したはずである
            hoge_list[y][x] = hoge_list[coord[0]][coord[1]] + 1
            ans = max(hoge_list[y][x],ans)
            #dequeに加える
            d.append((y,x))
    

#ゴールの移動回数を出力する
print(ans)


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

int main() {
	string str; int n;
	cin >> str; cin >> n;
	while(n--) {
		string op; int a, b;
		cin >> op; cin >> a >> b;
		if(op == "replace") {
			string p;
			cin >> p;
			for(int i = 0; i < b - a + 1; i++) str[a + i] = p[i];
		}
		else if(op == "reverse") {
			for(int i = 0; i < (b - a + 1) / 2; i++) {
				char ch = str[a + i];
				str[a + i] = str[b - i];
				str[b - i] = ch;
			}
		}
		else {
			for(int i = a; i <= b; i++) cout << str[i];
			cout << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3172
n = int(input())
p_list = [ int(v) for v in input().split() ]

ans = 0

for i in range(n-1):
    if p_list[i] == i+1 and p_list[i+1] == i+2:
        p_list[i], p_list[i+1] = p_list[i+1], p_list[i]
        ans += 1
        
for i in range(n-1):
    if p_list[i] == i+1 or p_list[i+1] == i+2:
        p_list[i], p_list[i+1] = p_list[i+1], p_list[i]
        ans += 1
print(ans)


Measured memory_bytes: 52460
def fact(n)
  (1..n).inject{|x,i| x*i%1000000007}
end

n, m = gets.split.map(&:to_i)

diff = (n - m).abs

if diff == 0
  puts fact(n) * fact(m) * 2 % 1000000007
elsif diff == 1
  puts fact(n) * fact(m) % 1000000007
else
  puts 0
end


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

int main(){
 
	ios_base::sync_with_stdio(false) ,cin.tie(nullptr);
  	char inp ;
	cin >> inp ;
  if (inp >= 'A' && inp <= 'Z')
   cout << 'A' ;
 else 
   cout << 'a';
 return 0 ;
 }

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,m;
    cin>>n>>m;
    vector<int> a(m);
    int total=0;
    rep(i,m){
        cin>>a[i];
        total+=a[i];
    }
    if(total>n) cout<<"-1"<<endl;
    else cout<<n-total<<endl;
}

Measured memory_bytes: 3660
#include<stdio.h>
#define INF 999999999;
typedef struct data{
  int r;
  int c;
}data;
data A[100];
void matrixchain(int*,int);
int min(int,int);
int main(){

  int i;
  int n;

  scanf("%d",&n);
  int p[n+1];
  for(i=0;i<n;i++){
    scanf("%d%d",&A[i].r,&A[i].c);
    if(i!=0) p[i+1]=A[i].c;
  }
  p[0]=A[0].r;
  p[1]=A[0].c;
  matrixchain(p,n);
  return 0;
}
void matrixchain(int *p,int n){
  int i,j,k,l,q;
  int res=0,m[n+1][n+1];
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
      }
      res=m[i][j];
    }
  }
  printf("%d\n",res);
}
int min(int m,int q){
  if(m>q) return q;
  return m;
}



Measured memory_bytes: 2104
import java.util.*;

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

        int n = sc.nextInt();
        String s = sc.next();
        int count = 0;
        for(int i = 0;i < s.length()-2;i++){
            String abc = s.substring(i, i+3);
            if(abc.equals("ABC"))
                count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void){
    int a, b, ans;
    scanf("%d%d", &a, &b);
    if(a >= 10 || b >= 10){
        ans = -1;
    }else{
        ans = a * b;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mem(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef pair<int,int> pii;

const int mn=1e3+5;
ll a,b,c;
ll x,y;

int main() {
	cin>>a>>b>>c;
	cin>>x>>y;
	ll ans=1e18;
	if (c+c<=a+b){
		int u=min(x,y);
		for(int i=u;i<=max(x,y);i++){
			ans=min(max(0ll,(x-i))*a+max(0ll,(y-i))*b+i*2*c,ans);
		}
	}
	else ans=x*a+y*b;
	cout<<ans;
	return 0;
}


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

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

    pair<int, int> p[m];
    for(int i = 0; i < m; i++){
        cin >> p[i].first >> p[i].second;
    }

    queue<int> que;
    map<int, int> n_que;
    for(int i = 0; i < m; i++){
        if(p[i].first == 1){
            que.push(p[i].second);
        }
        if(p[i].second == n){
            n_que[p[i].first]++;
        }
    }

    int flag = 0;
    int l = 0;
    while(!que.empty()){
        l = que.front();;
        que.pop();
        if(n_que[l] != 0){
            flag = 1;
            break;
        }
    }

    if(flag == 1){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
}

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

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  
  int cnt = 0;
  int res = 0;
  
  for(int i = 0; i < N-1; ++i){
    if(S.at(i) != S.at(i+1)){
      cnt++;
    }else{
      res++;
    }
  }
  
  if(cnt%2 == 0){
    res += min(cnt, K*2);
  }else{
    if(cnt/2 >= K){
      res += K*2;
    }else{
      res += cnt;
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
ll qpow(ll a,ll b){ll ans=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)ans=ans*a%mod;a=a*a%mod;}return ans;}
ll gcd(ll a,ll b){return b>0?gcd(b,a%b):a;}

int a[maxn];

int main(){
	int n,m,T;
	//cin>>T;
	cin>>n;
	ll sum=0;
    rep(i,0,n) scanf("%d",&a[i]),sum+=a[i];
    sort(a,a+n);
    //cout<<a[n-1]<<" "<<sum<<endl;
    if(sum-a[n-1]>a[n-1]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int i,v;
		for(;;){
			int h = scan.nextInt();
			int w = scan.nextInt();
			if(h == 0 && w == 0)
				break;
				for(i = 1; i <= h; ++i){
					for(v = 1; v <= w; ++v){
					if(i == h || i == 1){
						System.out.print("#");
					}
					else if(i != 1 || i != h){
						if(v == 1 || v == w){
							System.out.print("#");
						}
						else if(v != 1 || v != w){
							System.out.print(".");
						}
					}
				}
					System.out.println("");
		}
				System.out.println("");
	}
}
}

Measured memory_bytes: 32944
#include<iostream>
#include<cstdio>
#include<cstring>
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int inf = 100005;
int main()
{int t,a;a=0;
 cin>>t;
  for(int i=0;i<=25;i++)
    for(int j=0;j<=14;j++)
  {
      if(4*i+j*7==t){a=1;break;}
  }
  if(a)cout<<"Yes\n";
  else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    bool ok = true;
    ll n = s.size();
    if(n % 2 == 1)ok = false;
    rep(i,n){
        if(i & 1){
            if(s[i] != 'i')ok = false;
        }
        else{
            if(s[i] != 'h')ok = false;
        }

    }

    cout << (ok ? "Yes" : "No") << endl;
}

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

map<char,int>mp;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin>>a;
    for(int i=0;i<3;i++)
    {
        mp[a[i]]++;
    }
    if(mp['A']&&mp['B'])
        cout<<"Yes"<<'\n';
    else
        cout<<"No"<<'\n';






}











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

int main()
{
  int N,K;cin>>N>>K;
  vector<int> h(N);
  for (int i=0;i<N;i++)
    cin>>h[i];
  
  int count=0;
  for (int i=0;i<N;i++)
  {
    if (h[i]>=K)
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

ll tleft(function<ll(ll)> fn, ll lo, ll hi) {
  ll left = lo;
  ll right = hi;
  while (abs(right - left) >= 3) {
    ll r1 = (left * 2 + right) / 3;
    ll r2 = (left + right * 2) / 3;
    if (fn(r1) <= fn(r2)) {
      right = r2;
    } else {
      left = r1;
    }
  }
  if (left + 1 >= hi || fn(left) <= fn(left + 1)) {
    return left;
  }
  if (left + 2 >= hi || fn(left + 1) <= fn(left + 2)) {
    return left + 1;
  }
  return left + 2;
}

pair<ll, ll> lr(ll x, ll cnt, const vector<ll> &A) {
  ll l = tleft([&](ll l) { return max(abs(A[l + cnt - 1] - x), abs(A[l] - x)); }, 0, A.size() - cnt);
  return make_pair(l, l + cnt);
}

ll solve(ll x, const vector<ll> &A, const vector<ll> &gt_sum, const vector<ll> &lt_sum) {
  ll N = A.size();
  if (x > A[N - 2]) return lt_sum[N - 1];

  ll ok = 1;
  ll ng = N / 2 + 1;
  while (abs(ok - ng) > 1) {
    ll cnt = (ok + ng) / 2;
    ll l, r;
    tie(l, r) = lr(x, cnt, A);
    if (r <= N - cnt) {
      ok = cnt;
    } else {
      ng = cnt;
    }
  }
  ll cnt = ok;
  ll l, r;
  tie(l, r) = lr(x, cnt, A);
  if (r < N - cnt) {
    cnt++;
  }

  ll ans = 0;
  if (0 <= N - cnt && N - cnt < N) {
    ans += gt_sum[N - cnt];
  }
  if (0 <= N - cnt * 2 - 1 && N - cnt * 2 - 1 < N) {
    ans += lt_sum[N - cnt * 2 - 1];
  }
  return ans;
}

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, Q;
  cin >> N >> Q;
  vector<ll> A;
  rep (i, N) {
    ll v0;
    cin >> v0;
    A.push_back(v0);
  }
  vector<ll> X;
  rep (i, Q) {
    ll v0;
    cin >> v0;
    X.push_back(v0);
  }

  vector<ll> gt_sum(N);
  ll s = 0;
  rrep (i, N) {
    s += A[i];
    gt_sum[i] = s;
  }
  vector<ll> lt_sum(N);
  s = 0;
  reps (i, 0, A.size(), 2) {
    s += A[i];
    lt_sum[i] = s;
  }
  s = 0;
  reps (i, 1, A.size(), 2) {
    s += A[i];
    lt_sum[i] = s;
  }

  each (x, X) {
    cout << solve(x, A, gt_sum, lt_sum) << "\n";
  }
}

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

using namespace std;

int const maxn = 2e5 + 5;
int ans[maxn];

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x;
    cin >> n;
    for (int i = 2; i <= n; ++i) {
        cin >> x;
        ans[x]++;
    }
    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
    return 0;
}



Measured memory_bytes: 4444
# -*- coding: utf-8 -*-
n = int(input())

if n == 0:
    print(0)

else:
    s = ''
    cnt = 1
    while n != 0:
        s += str(1) if n % (-2)**cnt != 0 else str(0)
        n -= (-2)**(cnt - 1) if n % (-2)**cnt != 0 else 0
        cnt += 1
    print(s[::-1])


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

typedef vector<int> vi;
typedef vector<vi> vvi;

int n,m;
vi dp;
vvi graph;
int solve(int node) {
    if (dp[node] != -1) return dp[node];

    int ans=0;
    for (int i : graph[node]) {
        ans = max(
            ans,
            1 + solve(i)
        );
    }

    dp[node] = ans;
    return ans;
}

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

    cin>>n>>m;
    dp = vi(n+1, -1);
    graph = vvi(n+1);
    for (int i=0; i<m; i++) {
        int x,y; cin>>x>>y;
        graph[x].push_back(y);
    }

    for (int i=1; i<=n; i++)
        solve(i);
    
    int ans=0;
    for (int i : dp)
        ans = max(ans, i);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;

int main(void) {
	LL a, b, n, i, j, k, mi, ma, ans;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0 << endl;
		return 0;
	}
	mi = a*(n - 2);
	ma = b*(n - 2);
	ans = ma - mi;
	++ans;
	if (ans > 0) {
		cout << ans << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m,a,h,p,q,i;
main(){
  cin.sync_with_stdio(0);
  while(cin>>n>>m>>a,n){
    int x[1001][101]={};
    while(cin>>h>>p>>q,x[h][p]=q,x[h][q]=p,--m);
    for(i=1000;i--;x[i][a]&&(a=x[i][a]));
    cout<<a<<endl;
  }
}

Measured memory_bytes: 3484
#include <iostream>

using namespace std;

int main()
{
   int a , b , c ;
   cin >> a >> b >> c ;
   if ((( a + b ) == c ) || (( a + c ) == b ) ||  (( c + b ) == a ) )
   cout << "Yes" ;
        else
        cout << "No" ;

    return 0;
}


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

int N, M;
const int MAX_N = 50 + 10;
int a[MAX_N], b[MAX_N];

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> a[i] >> b[i];

    int ans[N + 1];
    for (int i = 1; i <= N; i++) ans[i] = 0;

    for (int i = 0; i < M; i++) {
        ans[a[i]]++;
        ans[b[i]]++;
    }

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

    return 0;
}


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

void solve(){
    int x,y;
    cin>>x>>y;
    int c=0,t=0;
    while(c<=x){
        if((4*x)-(2*c)== y){
            cout<<"Yes";
            return;
        }
        c++;
    }
    cout<<"No";
    return;

}

int main(){
   int t;
   t=1;
    while(t--){
        solve();
    }

}

Measured memory_bytes: 3608
defmodule Main do
  def main do
    [a, b] =
      IO.read(:line)
      |> String.trim
      |> String.split(" ")
    a = String.to_integer(a)
    b = String.to_integer(b)
    if (a <= b) do
    	IO.puts(a)
    else
    	IO.puts(a - 1)
    end
  end
end


Measured memory_bytes: 30592
import collections
N=int(input())
S=list(input())
l=[]
c=collections.Counter(S)
num=1
p=10**9+7
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#print(l)
for i in range(len(l)):
    num=num*(l[i][1]+1)
print((num-1)%p)



Measured memory_bytes: 49520
N=int(input())
def prime(n):
  cnt=0
  for s in range(1,n+1):
    if n%s==0:
      cnt+=1
    
  return cnt

ans=0
for i in range(1,N+1):
  if i%2==1 and prime(i)==8:
    ans+=1
print(ans)

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))

# 解法メモ
# ひとつでも山の雨の量がわかれば全て求まる
# 3つの山があり、1つめの山の値をxとしたとき
# 1つめ: x
# 2つめ：A1 - x
# 3つめ：A2 - (A1 - x)
# 1つめ：A3 - (A2 - (A1 - x))
# 1つめ２つを式にする
# x = A3 - (A2 - (A1 - x))
# x = A3 - A2 + A1 - x
# 2x = A3 - A2 + A1
summary = 0

for i in range(N):
    if i % 2 == 0:
        summary += A[i]
    else:
        summary -= A[i]

for i in range(N):
    print(summary)
    summary = (A[i] - (summary//2)) * 2


Measured memory_bytes: 63984
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;

void main() {
  auto N = readln.chomp.to!int;
  auto Vn = readln.split.to!(float[]).sort();

  auto sum = Vn[0];
  foreach(v; Vn[1..N]) {
    sum = (sum + v) * 0.5;
  }

  writefln("%.10f", sum);
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import Data.List.Split
import Data.Array

main = do
  xs <- input (map read . splitOn ",") :: IO [[Int]]
  mapM_ print $ solve xs

solve :: [[Int]] -> [Int]
solve xs = [length (filter (==0) rst), maximum rst]
  where rst = elems $ foldl inkdrop (listArray ((0,0),(9,9)) (repeat 0)) xs
        
    
inkdrop :: Array (Int, Int) Int -> [Int] -> Array (Int, Int) Int
inkdrop arr [x,y,s] = accum (+) arr $ map (\k -> (k,1)) rp
  where sp = [(x,y),(x+1,y),(x-1,y),(x,y+1),(x,y-1)]
        mp = sp ++ [(x+1,y+1),(x+1,y-1),(x-1,y+1),(x-1,y-1)]
        lp = mp ++ [(x+2,y),(x-2,y),(x,y+2),(x,y-2)]
        rp = if s == 1 then filter f sp
             else if s == 2 then filter f mp
                  else filter f lp
        f (i,j) = if i >= 0 && j >= 0 && i < 10 && j < 10 then True else False

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, 3) {
        if(s[i] == t[i])  cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
int main(void){
	int a,b,c;
	cin >> a >> b >> c;
	if(a<b){
		if(b<c){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import enum
class Direction(enum.Enum):
    N = "N"
    E = "E"
    W = "W"
    S = "S"

    @classmethod
    def value_of(cls, value):
        return [v for v in cls if v.value == value][0]


class Dice:
    def __init__(self, *value_list):
        self.__value_list = list(value_list)

    def rotate(self, direction):
        l = self.__value_list
        if  direction == Direction.N:
            l[0],l[1],l[5],l[4] = l[1],l[5],l[4],l[0]
        elif  direction == Direction.E:
            l[0],l[2],l[5],l[3] = l[3],l[0],l[2],l[5]
        elif  direction == Direction.W:
            l[0],l[2],l[5],l[3] = l[2],l[5],l[3],l[0]
        elif  direction == Direction.S:
            l[0],l[1],l[5],l[4] = l[4],l[0],l[1],l[5]

    def adjust_top_front(self, top_value, front_value):
        for _ in range(2):
            for _ in range(3):
                if self.front_value() == front_value:
                    break
                self.rotate(Direction.N)
            if self.front_value() == front_value:
                break
            self.rotate(Direction.E)
        
        for _ in range(3):
            if self.top_value() == top_value:
                break
            self.rotate(Direction.E)
    
    def is_same_dice(self, othere_dice):
        return (self.top_value() == othere_dice.top_value()
        and self.bottom_value() == othere_dice.bottom_value()
        and self.front_value() == othere_dice.front_value()
        and self.behind_value() == othere_dice.behind_value()
        and self.right_value() == othere_dice.right_value()
        and self.left_value() == othere_dice.left_value())

    def top_value(self):
        return self.__value_list[0]

    def bottom_value(self):
        return self.__value_list[5]

    def front_value(self):
        return self.__value_list[1]

    def behind_value(self):
        return self.__value_list[4]

    def right_value(self):
        return self.__value_list[2]

    def left_value(self):
        return self.__value_list[3]


is_all_different = True
for i in range(int(input())):
    dice_x = Dice(*input().split())
    if i == 0:
        dice1 = dice_x
    else:
        dice_x.adjust_top_front(dice1.top_value(), dice1.front_value())
        if dice1.is_same_dice(dice_x):
            is_all_different = False
            break

print("Yes" if is_all_different else "No")


Measured memory_bytes: 6352
N, K = map(int, input().split())

k = (N - 1) * (N - 2) // 2

if k < K:
  print(-1)
  exit()
  
answer = []
for i in range(2, N+1):
  answer.append([1, i])
# print(answer)

for i in range(2, N+1):
  for j in range(i+1, N+1):
    if k == K:
      print(len(answer))
      for a in answer:
        print(*a)
      exit()
    else:
      k -= 1
      answer.append([i, j])
print(len(answer))
for a in answer:
  print(*a)
exit()

Measured memory_bytes: 43376
N, M = map(int, input().split())

no = [0] * (N + 1)
ok = 0
x = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and no[p] != -1:
        ok += 1
        x += no[p]
        no[p] = -1
    elif s == 'WA' and no[p] != -1:
        no[p] += 1

print(ok, x)


Measured memory_bytes: 3828
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;

#define M 1000000
void mymain(){
    int a,b;
    cin >> a >> b;
    for(int i=max(b-a+1,-1ll*M);i<min(b+a,1ll*M);i++)
        cout << i <<" ";
    cout <<endl;
}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t;
t=1;
///cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};



int main(){
    IOS;
    make2(ll,n,k);
    makevec(ll,a,n);
    unordered_map <ll,ll> um;
    vector <ll> vec;
    fr(i,n) um[a[i]]++;
    for(auto x : um){
        vec.push_back(x.second);
    }
    sort(vec.begin(),vec.end());
    ll s=0;
    if(vec.size()<=k) cout<<"0 \n";
    else {
    fr(i,vec.size()-k) s+=vec[i];
    cout<<s<<endl;
    }


    return 0;
}


Measured memory_bytes: 15984
#include<bits/stdc++.h>
using namespace std;
int n,i,j;
long long sum,w,f;
long long a[100001];
int main()
{
	cin>>n>>w>>f;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=n-1;i++){
		//cout<<w*(a[i+1]-a[i])<<' '<<f<<endl;
		//cout<<min(w*(a[i+1]-a[i]),f)<<endl;
		sum+=min(w*(a[i+1]-a[i]),f);
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const int M = 1000000007;

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

	vector<pair<int, bool>> p(n * 2); //1 : PC, 0 : power supply
	rep(i,n){
		int a;
		cin >> a;
		p[i] = make_pair(a, true);
	}
	rep(i,n){
		int b;
		cin >> b;
		p[i + n] = make_pair(b, false);
	}

	sort(all(p));

	int pc = 0, power = 0;
	long long ans = 1;
	for(auto i : p){
		if(i.second){
			if(power != 0){
				ans *= power;
				power--;
			}else{
				pc++;
			}
		}else{
			if(pc != 0){
				ans *= pc;
				pc--;
			}else{
				power++;
			}
		}
		ans %= M;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
int c[N+N],a[N],n; 
void clear(){
	memset(c,0,sizeof c);
}
void update(int x){
//	cerr<<"update"<<x<<endl;
	for (; x<N+N; x+=x&-x) ++c[x];
}
int ask(int x){
//	cerr<<"ask"<<x<<endl;
	int ret=0;
	for (; x; x&=x-1) ret+=c[x];
	return ret;
}
void sett(int x){
	update(x+N);
}
int count(int x){
	return ask(x+N);
}
long long check(int v){
	int _d1=0;
	long long ret=0;
	clear();
	sett(0);
	for (int i=1; i<=n; ++i){
		if (a[i]<v) ++_d1; else --_d1;
		ret+=count(_d1-1);
		sett(_d1);
	}
	return ret;
}
int main(){
	int mx=0;
	scanf("%d",&n);
	for (int i=1; i<=n; ++i) scanf("%d",&a[i]),mx=max(mx,a[i]);
	int ret=0;
	for (int l=0,r=mx,mid=(l+r)>>1; l<=r; mid=(l+r)>>1)
		if (check(mid)>(1ll*n*(n-1)/2+n)/2) r=mid-1; else ret=mid,l=mid+1;
	cout<<ret;
}

Measured memory_bytes: 1408
#include<iostream>

int main(){
    int m, d, a = 0;

    std::cin >> m >> d;
    
    for(int b = 1; b <= m; b++){
        for(int c = 1; c <= d; c++){
            if(c >= 10){
                int e = c / 10;
                int f = c % 10;

                if(b == e * f && e >= 2 && f >= 2){
                    a += 1;
                }
            }
        }
    }

    std::cout << a << std::endl;

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int n,m;
    cin >> n >> m;

    char A[n][n], B[m][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            cin >> B[i][j];
        }
    }

    bool exist=false;
    for (int i = 0; i < n-m+1; i++) {
        for (int j = 0; j < n-m+1; j++) {
            bool truth=true;
            for (int k = 0; k < m; k++) {
                for (int l = 0; l < m; l++) {
                    if (A[i+k][j+l] != B[k][l]) {
                        truth=false;
                    }
                }
            }
            if (truth) exist=true;
        }
    }

    if (exist) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

int n;
char field[9][9];
int sx,sy;

void bomb(int x,int y){
	field[x][y]='0';
	for(int i=1;i<=3;i++){
		if(x+i>=8)break;
		if(field[x+i][y]=='1'){
			field[x+i][y]='0';
			bomb(x+i,y);
		}
	}
	for(int i=1;i<=3;i++){
		if(x-i<0)break;
		if(field[x-i][y]=='1'){
			field[x-i][y]='0';
			bomb(x-i,y);
		}
	}
	for(int i=1;i<=3;i++){
		if(y+i>=8)break;
		if(field[x][y+i]=='1'){
			field[x][y+i]='0';
			bomb(x,y+i);
		}
	}
	for(int i=1;i<=3;i++){
		if(y-i<0)break;
		if(field[x][y-i]=='1'){
			field[x][y-i]='0';
			bomb(x,y-i);
		}
	}
}

int main(void){
	cin >> n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<8;j++)cin >> field[j];
		cin >> sy >> sx;
		sx--;
		sy--;
		bomb(sx,sy);
		printf("Data %d:\n",i);
		for(int j=0;j<8;j++)cout << field[j] << endl;
	}
    return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, A, B; cin >> N >> A >> B;
  ll X[N]; FOR(i,0,N) cin >> X[i];
  ll ans = 0;
  FOR(i,0,N-1) {
    ans += min((X[i+1] - X[i]) * A, B);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int N = 0;
    int i;
    
    scanf("%d",&N);
    
    char S[N];
    char T[N];
    
    scanf("%s",S);
    scanf("%s",T);
    
    for(i=0;i<N;i++){
        printf("%c%c",S[i],T[i]);
    }
    
    return 0;
    
}


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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    int a, b;
    cin >> a >> b;
    int mn = min(a,b);
    if(mn==a){
        rep(i,b)cout << mn;
    }else
    {
        rep(i,a)cout << mn;
    }
    cout << endl;
    return 0;
    
}

Measured memory_bytes: 256