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

using namespace std;

//#define double long double

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
typedef pair<int,ii> iii2;
typedef pair<ii,ii> iiii;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;



int main(){

	int k,a,b;
	cin>>k>>a>>b;

	if(b<=a+2){
		cout<<k+1<<endl;
		return 0;
	}

	long long t = 1;
	int temp = min(k,a-1);
	t+=temp;
	k-=temp;

	if(k==0){
		cout<<t<<endl;
		return 0;
	}

	if(k%2){
		k--;
		t++;
	}

	t+=1ll*(b-a)*k/2;

	cout<<t<<endl;


	return 0;
}


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

int main(){
  int n; cin >> n;
  long long int fib[n];
  fib[0]=1; fib[1]=1;
  for(int i=2; i<=n; i++){
    fib[i]=fib[i-1]+fib[i-2];
  }

  cout << fib[n] << endl;

  return 0;
}



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

int main() {
  int N, Y;
  cin >> N >> Y;
  
  for(int i=0 ; i<=N ; i++)
    for(int j=0 ; j<=N-i ; j++){
      int k=N-i-j;
      if(k<0)
        continue;
      if(i*10000 + j*5000 + k*1000 == Y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  
  cout << "-1 -1 -1" << endl;
  return 0;
}

Measured memory_bytes: 3652
#!/usr/bin/env python3

x, y = list(map(int, input().split()))

# a+b = x
# 2*a+4*b = y

a = (4*x-y)//2
b = (y-2*x)//2


if a < 0 or b < 0:
    print("No")
    exit()
if a == 0 and b == 0:
    print("No")
    exit()
if a+b != x or 2*a+4*b != y:
    print("No")
    exit()

print("Yes")


Measured memory_bytes: 9112
#include <bits/stdc++.h>
  #include <vector>
  #include <math.h>
  #include <string>
  #include <algorithm>
  #include <stack>
  #include <queue>
  #include <ctype.h>
  #include <unordered_map>
  #include <set>
  #include <iterator>
  #include <deque>
  #include <string.h>
  using namespace std;

  typedef long long int lli;


  #define MOD (lli)(1e9+7)
  #define endl "\n"
  #define pb push_back
  #define TEST_CASES  lli t;cin >> t;while(t--)
  #define forn(i,n) for (int i = 0; i < n; ++i)
  
  int pow(lli x,lli y){
    
    lli res = 1;
    while(y > 0){
      if(y & 1)
        res = (res*x);
      x = (x*x);
      y = y>>1;
    }
    return res;
  }

  

  int main()
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double r;
    cin>>r;
    double pi = 3.14159265;
    cout<<fixed<<pi*2*r<<endl;

    
  }


Measured memory_bytes: 3720
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

vector<string> bo(10);
int f;

void cookie(int t){
	int d[8][2]={{-1,-1},{-1,0},{-1,1},
		{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	int x=9, y=9, ma=0, nx, ny, ins, sum, i ,j;
	string co="ox";
	for(int ii=1;ii<=8;ii++){
		if(t==0) i = ii;
		else i = 9 - ii;
		for(int jj=1;jj<=8;jj++){
			if(t==0) j = jj;
			else j = 9 - jj;
			sum = 0;
			if(bo[i][j]=='.'){
				REP(a,8){
					ins = 0;
					nx = i;
					ny = j;
					while(bo[nx+d[a][0]][ny+d[a][1]]==co[1-t]){
						ins++;
						nx += d[a][0];
						ny += d[a][1];
					}
					//cout << nx <<"=" << ny <<endl ;
					if(ins && bo[nx+d[a][0]][ny+d[a][1]]==co[t]) sum += ins;
				}
				if(ma < sum){
					x = i;
					y = j;
					ma = sum;
				}
				//cout << ma << endl;
			}
		}
	}
	if(ma){
		f++;
		//cout << co[t] << ":" << x << "," << y << endl;
		REP(a,8){
			bo[x][y] = co[t];
			nx = x;
			ny = y;
			while(bo[nx+d[a][0]][ny+d[a][1]]==co[1-t]){
				nx += d[a][0];
				ny += d[a][1];
			}
			if(bo[nx+d[a][0]][ny+d[a][1]] == co[t]){
				while(nx!=x||ny!=y){
					bo[nx][ny] = co[t];
					nx -= d[a][0];
					ny -= d[a][1];
				}
			}
		}
	}
}

int main(){
	int i, j;
	string ins;
	REP(a,8){
		cin >> ins;
		bo[a+1] = "z" + ins + "z";
	}
	bo[0] = "zzzzzzzzzz";
	bo[9] = "zzzzzzzzzz";
	f = 1;
	while(f>0){
		f = 0;
		//mami
		cookie(0);
		//charl
		cookie(1);
	}
	//cout << "ok" << endl;
	REP(a,8) cout << bo[a+1].substr(1,8) << endl;
	return 0;
}

Measured memory_bytes: 1192
n=int(input())
a=list(map(int,input().split()))
s=0
b=[]
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if a[i]!=a[j] and a[j]!=a[k] and a[k]!=a[i] and a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i]:
                s+=1

print(s)


Measured memory_bytes: 68184
#include <bits/stdc++.h>
#define N 55
#define int long long
using namespace std;
const int s = ('a'-1);
const int mod = (1e9)+7;
int n;
string str[N];

int calc(int y,int x,int ch){
  if(x>=(int)str[y].size() || ch>=27) return 0;
  int k = 0;
  if(str[y][x] != '?') k = 1;
  if(str[y][x] == '?') k = 27 - ch;
  if(k == 0) return 0;
  int res = 1;
  for(++x;x<(int)str[y].size();x++) if(str[y][x]=='?') res = (res*26)%mod;
  return (res*k)%mod;
}


bool check(int u,int d,int x,char ch){
  for(int y=u;y<=d;y++) if(str[y][x] != '?' && str[y][x] != ch) return 0;
  return  1;
}

int mem[N][N][22][30],used[N][N][22][30];
int dfs(int u,int d,int x,int c){
  if(u > d) return 1;
  if(u == d) return calc(u,x,c);
  if(x >= 21) return 0;
  if(c > 26) return 0;
  if(str[u][x] == s) return (c == 1 && str[u+1][x] != s ? dfs(u+1,d,x,c):0);
  if(used[u][d][x][c]++) return mem[u][d][x][c];

  vector<int> mnc(N,30);
  for(int y=d;y>=u;y--)mnc[y] = min(mnc[y+1],str[y][x]=='?'? 30:str[y][x] - s);  
  
  int res = dfs(u,d,x,c+1); 
  //[u,y]?????????????????????????????????????????????
  for(int y=u;y<=d;y++){
    if(mnc[y+1] <= c || !check(u,y,x,c+s)) continue;
    res = (res+(dfs(u,y,x+1,1)*dfs(y+1,d,x,c+1))%mod)%mod;
  }
    return mem[u][d][x][c] = res;
}


signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>str[i];
    while(str[i].size()<21) str[i]+=s;
  }
  cout<<dfs(0,n-1,0,1)<<endl;
  return 0;
}

Measured memory_bytes: 16272
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 int H;
 cin >> H >> N;
 int a[N];
 int i;
 long long int sum =0;
 for(i=0;i<N;++i){
   cin >> a[i];
   sum += a[i];
   if(sum>=H){
       cout << "Yes" << endl;
       break;
   }
   }
if(sum<H)cout << "No" << endl;
 }

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cctype>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

#define ll long long
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MD 1000000007

char sep[3] = " \n";
int i, j, k, l, m, n;
double PI = acos(-1);


int main() {
  int s[1010];

  while(true) {
    cin >> n;
    if (n == 0) break;
    double mean = 0.0;
    rep(i,n) cin >> s[i], mean+=s[i];
    mean/=n;
    double sigma = 0.0;
    rep(i,n) sigma += (s[i]-mean)*(s[i]-mean);
    sigma = sqrt(sigma/n);
    printf("%.5f\n", sigma);
  }

  return 0;
}
  

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

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 1;
	for(int i = 0; i < n - 1; i++){
		if(s[i] != s[i+1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

ll k(ll n){
ll p=0;
while(n%2==0){
    p++;n/=2;
}
return p;

}

int main() {

    int n;
    cin>>n;
    int e=0;
    for(ll i=1;i<=n;i++){
        ll temp;
        cin>>temp;
        e+=k(temp);

    }
cout<<e;
 return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
a=[]
for i in range(h):
    b = input()
    f = False
    for j in range(len(b)):
        if b[j] == '#':
            f = True
    if f:
        a.append(list(b))

f = True
cnt = 0
for i in range(len(a[0])):
    for j in range(len(a)):
        if(a[j][i-cnt] == '#'):
            f = False
    if f:
        for j in range(len(a)):
            del a[j][i-cnt]
        cnt += 1
    f = True

for i in range(len(a)):
    for j in range(len(a[0])):
        print(a[i][j],end="")
    print()

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

using namespace std;

const int N = 55;
int n;
pair<double, double> arr[N];

double distan(pair<double, double> a, pair<double, double> b){
    double dist = (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
    return sqrt(dist);
}

pair<double, double> cent(pair<double, double> a, pair<double, double> b, pair<double, double> c){
    double bawah = 2 * (a.first * (b.second - c.second) - a.second * (b.first - c.first) + b.first * c.second - c.first * b.second);
    double atasx = distan(a, {0, 0}) * distan(a, {0, 0}) * (b.second - c.second) + distan(b, {0, 0}) * distan(b, {0, 0}) * (c.second - a.second) + distan(c, {0, 0}) * distan(c, {0, 0}) * (a.second - b.second);
    double atasy = distan(a, {0, 0}) * distan(a, {0, 0}) * (c.first - b.first) + distan(b, {0, 0}) * distan(b, {0, 0}) * (a.first - c.first) + distan(c, {0, 0}) * distan(c, {0, 0}) * (b.first - a.first);
    return {atasx / bawah, atasy / bawah};
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n;
    for(int i = 1; i <= n; i++){
        double a, b;
        cin >> a >> b;
        arr[i] = {a, b};
    }

    if(n == 2){
        cout << fixed << setprecision(9) << distan(arr[1], arr[2]) / 2 << '\n';
        return 0;
    }
    double ans = 1000000000;
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            double centerx = (arr[i].first + arr[j].first) / 2.0;
            double centery = (arr[i].second + arr[j].second) / 2.0;
            pair<double, double> aa = {centerx, centery};
 
            double r = distan(arr[i], arr[j]) / 2.0;
            bool can = true;
            for(int k = 1; k <= n; k++){
                if(k != i && k != j){
                    double te = distan(arr[k], aa);
                    if(te > r){
                        can = false;
                        break;
                    }
                }
            }
            if(can){
                if(r < ans){
                    ans = r;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            for(int k = j + 1; k <= n; k++){
                pair<double, double> center = cent(arr[i], arr[j], arr[k]);
                double r = distan(center, arr[i]);
                bool can = true;

                for(int l = 1; l <= n; l++){
                    if(l != i && l != j && l != k){
                        double teh = distan(center, arr[l]);
                        if(teh > r){
                            can = false;
                            break;
                        }
                    }
                }
                if(can){
                    if(r < ans){
                        ans = r;
                    }
                }
            }
        }
    }
    cout << fixed << setprecision(9) << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        s: String,
        t: String,
    }

    let s = s.chars().collect::<Vec<_>>();
    let t = t.chars().collect::<Vec<_>>();

    if s.len() + 1 != t.len(){
        println!("No");
        return;
    }
    for (a, b) in s.iter().zip(t.iter()) {
        if a != b {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

Measured memory_bytes: 2168
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (a >= b && b >= c)
        cout << c << " " << b << " " << a << endl;
    else if (a >= c && c >= b)
        cout << b << " " << c << " " << a << endl;
    else if (c >= a && a >= b)
        cout << b << " " << a << " " << c << endl;
    else cout << c << " " << a << " " << b << endl;
        
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int X, A, B;
    cin >> X >> A >> B;
    X -= A;
    cout << X % B << endl;

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		double x1 = scanner.nextDouble();
		double x2 = scanner.nextDouble();
		double y1 = scanner.nextDouble();
		double y2 = scanner.nextDouble();

		System.out.println(Math.sqrt(Math.pow(y1 - x1, 2)
				+ Math.pow(y2 - x2, 2)));
	}
}

Measured memory_bytes: 18340
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double PI=3.1415926535897932;
const double LIT=0.000000000001;

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod
#define MUL(a,b) a=(a*b)%mod

vec d(110,0);




vec Sosu;

void yaku(ll a){
    ll A=a;
    int i=0;
    while(true){
        ll k=Sosu[i];
        if(k*k>A) break;
        if(!(A%k)){
            ll Count=0;
            while(true){
                if(A%k) break;
                Count++;
                A/=k;
            }
            d[k]+=Count;
        }
        i++;
    }
    if(A==1) return;
    d[A]++;
    return;
}

int main(){
    ll N; cin>>N;
    Sosu.pb(2);
    Sosu.pb(3);
    Sosu.pb(5);
    Sosu.pb(7);
    Sosu.pb(11);
    REP(i,2,N+1) yaku(i);
    ll A=0, B=0,C=0,D=0,E=0;
    REP(i,2,N+1){
        //cout<<i<<' '<<d[i]<<endl;
        if(d[i]>=4) A++;
        else if(d[i]>=2) B++;
        if(d[i]>=14) C++;
        if(d[i]>=24) D++;
        if(d[i]>=74) E++;
    }
    ll ans=0;
    ans+=A*(A-1)*(A-2)/2;
    ans+=B*A*(A-1)/2;
    ans+=C*(A-1);
    ans+=D*(A+B-1);
    ans+=E;
    cout<<ans<<endl;

}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        
        //int x = stdIn.nextInt();
        int a[] = new int[n];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        for(int i = 0; i < n; i++){
            a[i] = stdIn.nextInt();
        }
        
        
        int q = stdIn.nextInt();

        for(int i = 0; i < q; i++){
            int b = stdIn.nextInt();
            int e = stdIn.nextInt() - 1;
            
            for(int j = 0; j < (e - b + 1) / 2 ; j++){
                int tmp = a[b + j];
                a[b + j] = a[e - j];
                a[e - j] = tmp;
            }
            
        }
        
        for(int i = 0; i < n - 1; i++){
            System.out.print(a[i] + " ");
        }
        System.out.println(a[n - 1]);

        //System.out.println();
        //System.out.print();

        stdIn.close();
    }
}




Measured memory_bytes: 34856
n  = int(input())
b = list(map(int,input().split()))

# print(b)

can_make = True
com_list = []
while len(b) > 0 :
    insert_list = []
    for i in range(len(b)):
        if b[i] == i+1:
            insert_list.append(i)
    if not insert_list:
        can_make = False
        break
    com_list.append(b[insert_list[-1]])
    del b[insert_list[-1]]

if can_make:
    for x in reversed(com_list):
        print(x)
else:
    print(-1)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
      int k = scan.nextInt();
      String s = scan.next();
      String str = s.substring(k-1, k).toLowerCase();
      s= s.substring(0,k-1) + str +s.substring(k);
		System.out.println(s);
	}
}

Measured memory_bytes: 22612
#abc047_b

w,h,n=map(int,raw_input().split())
xmax=ymax=0
xmin=w
ymin=h
for i in range(n):
 x,y,a=map(int,raw_input().split())
 if a==1:
  xmax=max(xmax,x)
 elif a==2:
  xmin=min(xmin,x)
 elif a==3:
  ymax=max(ymax,y)
 elif a==4:
  ymin=min(ymin,y)

if xmin<=xmax:
 res=0
elif ymin<=ymax:
 res=0
else:
 res=(xmin-xmax)*(ymin-ymax)
print res


Measured memory_bytes: 2568
// Author:: Mohammad Faisal
// Beginning with the name of ALMIGHTY GOD ALLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
    cin >> s;
    int l = s.length();
  	map<char,int> mp;
  	for(int i=0;i<l;i++)
      mp[s[i]]++;
 	int len = mp.size();
    int flag = true;
   if(len == 2)
   {
  	for(auto &k: mp)
    {
      if(k.second!=2)
      {
        flag = false;
      }
    }
   }
   (len==2 && flag==true) ? cout<<"Yes": cout<<"No";
   return 0;
}
        
        
        
       

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
	int a;
	double sum = 0;
	cin >> a;
	
	REP(i, a){
		double p;
		string c;
		cin >> p >> c;
		if (c == "JPY"){
			sum = sum + p;
		} else {
			sum = sum + ( p * 380000);
		}
	}
	
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
def middle(a)
    (a.size % 2).zero? ? a[a.size/2 - 1, 2].inject(:+) / 2.0 : a[a.size/2]
end

n = gets.to_i
a = (1..n).map{ gets.split(' ').map(&:to_i) }
at = a.transpose
a1 = middle(at[0].sort)
a2 = middle(at[1].sort)
if n.odd? then
    p (a2 - a1 + 1).to_i
else
    p ((a2 - a1)*2 + 1).to_i
end


Measured memory_bytes: 36260
import java.io.InputStreamReader
import java.lang.Math.pow

fun main(args: Array<String>) {
    problem(InputStreamReader(System.`in`).useLines { block ->
        block.takeWhile {
            it.isNotEmpty()
        }.toList()
    })
}

fun problem(lines: List<String>) {
    val data: List<List<Int>> = lines.subList(1, lines.size).map { it.split(" ").map { it.toInt() } }
    var count = 0
    for (point1Index in 0 until data.size) {
        for (point2Index in (point1Index + 1) until data.size) {
            val point1 = data[point1Index]
            val point2 = data[point2Index]
//            println(point1 + ""+ point2)
            val sums = point2.mapIndexed { index, value ->
                pow(value.toDouble() - point1[index], 2.0)
            }.sum()
            val distance = Math.sqrt(
                sums
            )
            if ((distance == Math.floor(distance)) && !distance.isInfinite()) {
                count++
            }
        }
    }
    println(count)
}





Measured memory_bytes: 34356
#include <iostream>
#include <string>
using namespace std;
int main(){

int a,b[100],c,min;
min=100;
c=0;
cin>>a;
	for(int i=0;i<a;i++){
		cin>>b[i];
		c=c+b[i];
	}
	
	if(c%10>0){
		cout<<c<<endl;
	}
		for(int k=0;k<a;k++){
			if(min>b[k] && b[k]%10>0){
				min=b[k];
			}
		}
	if(min==100){
	cout<<0<<endl;
	}
	if(c%10==0 && min<100){
	cout<<c-min<<endl;
	}
}

Measured memory_bytes: 256
N = gets.to_i
H = gets.split.map(&:to_i)

D = Array.new(N, 0)

H.each_with_index do |h, idx|
  if idx == 0
    next
  end

  D[idx] = D[idx - 1] + 1 if H[idx - 1] >= h
end

p D.max


Measured memory_bytes: 9348
import           Control.Monad
import           Control.Applicative

main = do
    [h, w] <- map read . words <$> getLine
    sss    <- replicateM h getLine
    if existsSoloist sss w then putStrLn "No" else putStrLn "Yes"

--solver :: [[Char]] -> Int -> [[Bool]]
existsSoloist sss w =
    any2x (True ==)
        .   zipWith2x isTarget sss
        .   foldl1 (zipWith2x (+))
        $   shifters
        <*> [map2x (fromEnum . ('#' ==)) sss]
  where
    shifters = [shiftRight, shiftLeft, shiftUp, shiftDown]
    zeros    = replicate w 0
    shiftFront x xs = x : init xs
    shiftBack x xs = tail xs ++ [x]
    shiftRight = map $ shiftFront 0
    shiftLeft  = map $ shiftBack 0
    shiftUp    = shiftBack zeros
    shiftDown  = shiftFront zeros
    any2x :: (a -> Bool) -> [[a]] -> Bool
    any2x = any . any
    isTarget c x = c == '#' && x == 0
    zipWith2x = zipWith . zipWith
    map2x     = map . map


Measured memory_bytes: 1020
#include <stdio.h>


int main(void){
	int i,j,k;
	int n,m,l;
	double a[100][100],b[100][100];
	double c[100][100]={0};

	scanf(" %d %d %d",&n,&m,&l);
	for(i = 0;i < n;i++){
		for(j = 0;j < m;j++){
			scanf("%lf",&a[i][j]);
		}
	}
	for(i = 0;i < m;i++){
		for(j = 0;j < l;j++){
			scanf("%lf",&b[i][j]);
		}
	}
	
	for(i = 0;i < n;i++){
		for(j = 0;j < l;j++){
			for(k = 0;k < m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(i = 0;i < n;i++){
		for(j = 0;j < l;j++){
			printf("%.0f",c[i][j]);
			if(j != l-1) printf(" ");
			else printf("\n");
		}
		
	}
	return 0;
}

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

const int maxn=100005;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        string s;
        cin>>s;
        int cnt=0;
        int ans=0;
        for(int i=0;i<3;i++)
        {
            if(s[i]=='R')
            {
                cnt++;
            }
            else
            {
                ans=max(cnt,ans);
                cnt=0;
            }
        }
        ans=max(ans,cnt);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];
bool vis[N];
vector<int> tlist;

void dfs(int v){
    if(vis[v]) return;
    vis[v] = true;
    for(int e:G[v]){
        dfs(e);
    }
    tlist.pb(v);
}

int main(){
    int n,m;
    scanf(" %d %d", &n, &m);
    rep(i,m){
        int from,to;
        scanf(" %d %d", &from, &to);
        --from;
        --to;
        G[from].pb(to);
    }

    rep(i,n) dfs(i);
    reverse(all(tlist));

    int ans = 0;
    vector<int> dp(n);
    for(int i:tlist){
        for(int e:G[i]) dp[e] = max(dp[e], dp[i]+1);
        ans = max(ans, dp[i]);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}

int main(){
	int N,ans=0;
	cin >> N;
	vector<int> a(N),gcdb(N),gcdf(N);
	FOR(i,0,N)cin>>a[i];
	gcdf[0] = a[0];
	FOR(i,1,N){
		gcdf[i] = gcd(a[i],gcdf[i-1]);
	}
	gcdb[N-1] = a[N-1];
	FORR(i,0,N-1){
		gcdb[i] = gcd(a[i],gcdb[i+1]);
	}
	ans = max(gcdb[1],gcdf[N-2]);
	FOR(i,1,N-1){
		ans = max(ans,gcd(gcdb[i+1],gcdf[i-1]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int h,c=0;
	cin>>h;
	if (h%10==7)  c=1;
	h/=10;
	if (h%10==7)  c=1;
	h/=10;
	if (h==7)  c=1;
	if (c==0)  cout<<"No";
	else  cout<<"Yes";
	re 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>     
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define rev(i,n) for(ll i=n-1;i>=0;--i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
//cout << fixed << setprecision(10) << num << endl;
int a[110], b[110];
signed main() {
	int n;
	cin >> n;
	rep(i, n-1) {
		cin >> b[i];
	}
	int ans = 0;
	rep(i, n) {
		if (i == 0) {
			a[i] = b[i];
		}
		elif (i == n - 1) {
			a[i] = b[i - 1];
		}
		else {
			a[i] = min(b[i], b[i - 1]);
		}
		ans += a[i];
	}
	cout << ans << endl;
}

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

int power(int n);

int main() {
    int N;
    cin >> N;
    int num = 1000000007;
    //int back = 0;
    //back = N/15;
    long long result = 1;
    for(int i=1; i<=N; i++){
        result = (result*i)%num;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200001
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf(x) push_front((ll)(x))
#define nl cout << "\n";
 
//void ini(){
//	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
//		freopen("output.txt","w",stdout);
//	#endif
//}

string s1,s2;
ll dp[3005][3005];

string lcsStr(ll n,ll m){
	if(n==0 || m==0){
		return string("");
	}

	if(s1[n-1]==s2[m-1]){
		return lcsStr(n-1,m-1)+s1[n-1];
	}

	if(dp[n-1][m]>dp[n][m-1]){
		return lcsStr(n-1,m);
	}

	return lcsStr(n,m-1);
}

void lcs(ll n,ll m){
	f(i,1,n+1){
		f(j,1,m+1){
			if(s1[i-1]==s2[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}else{
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			}
		}
	}
}

int main(){
	//ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	cin >> s1 >> s2;

	lcs(s1.size(),s2.size());
	// f(i,1,s1.size()+1){
	// 	f(j,1,s2.size()+1){
	// 		cout << dp[i][j]<<" ";
	// 	}
	// 	nl;
	// }

	cout <<lcsStr(s1.size(),s2.size());
}

Measured memory_bytes: 71040
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
int main()
{
	int t,k,x,ans=0;
	cin>>t>>k;
	for(int i=0;i<t;i++)
	{
		scanf("%d",&x);
		if(x>=k)
			ans++;
	}
	printf("%d",ans);
	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();
        long[] a = new long [n];
        long total = 0l;
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextLong();
            total += a[i];
        }
        long ans = Long.MAX_VALUE;
        long total2 = 0l;
        for (int i = 0; i < a.length - 1; i++) {
            total2 += a[i];
            total -= a[i];
            ans = Math.min(ans, Math.abs(total2 - total));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62008
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
#include <queue>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll inf=(1e14);
ll solve(){
    int n;
    cin>>n;
    int a[n];
    for(int &i:a) cin>>i;
    sort(a,a+n);
    ll ans=0;
    priority_queue<ll> pq;
    pq.push(a[n-1]);
    for(int i=n-2;i>=0;i--){
        ans+=pq.top();
        pq.pop();
        pq.push(a[i]);
        pq.push(a[i]);
    }
    return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 6128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[n], c = 0, max = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (max <= a[i] || i == 0) {
      c++;
    }
    if (max < a[i]) {
      max = a[i];
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int INF=0x3f3f3f3f;
//vector<int>v[maxn];
//map<int,string>mp[maxn];
//queue<int>q[maxn];
int	a[5];
int main()
{
	int i,j,k,ans=0;
	for(i=0;i<5;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<5;i++)
	{
		if(a[i]==0)
			cout<<i+1<<" ";
	}
	return 0;
}


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

int main() {
    long mod = 1e9+7;
    long N;
    cin>>N;
    long A[N];
    for(long i=0;i<N;++i){
        cin>>A[i];
    }
    long ans = 0;
    long two = 1;
    for(long i=0;i<62;++i){
        long tmp = 0;
        for(long j=0;j<N;++j){
            tmp += A[j]>>i&1;
        }
        ans += two * tmp%mod * (N-tmp) % mod;
        ans %= mod;
        two *= 2;
        two %= mod;
        //cout<<i<<" "<<tmp<<endl;
    }
    cout<<ans<<endl;
}


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


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

int A = a.size();
int B = b.size();

for(int i = 0;i < min(A,B);i++){
	cout << a[i] <<b[i];
}

if(A != B){
	cout << a[A-1] <<endl;
}
else{
	cout <<endl;
}
}


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

using namespace std;

int main()
{
    // 入力
    int n;
    cin >> n;
    vector<int> v(2*n);
    for(int i = 0; i < 2*n; i++) {
        cin >> v[i];
    }
    
    // 長さをソート
    sort(v.begin(), v.end());
    
    // 2本の串のうち短いほうの長さの総和を計算
    int ans = 0;
    for(int i = 0; i < 2*n; i += 2) {
        ans += v[i];
    }
    
    // 答えを出力
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
typedef struct{int x,l,e;}robot;
using namespace std;
int main(){
    int n,ans=1,t;
    cin>>n;
    vector<robot>r(n);
    for(int i=0;i<n;i++){
        cin>>r[i].x>>r[i].l;
        r[i].e=r[i].x+r[i].l;
    }
    sort(r.begin(),r.end(),[](const auto &x,const auto &y){return x.e<y.e;});

    t=r[0].e;
    for(int i=1;i<n;i++){
        if(t<=r[i].x-r[i].l){
            ans++;
            //cout<<ans<<endl;
            //cout<<"+"<<endl;
            t=r[i].e;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
const int N = 1e5 + 7;

int n, k, a[N], f[N];

int main() {
	scanf("%d%d", &n, &k);
	rep(i, 1, n) {
		scanf("%d", &a[i]);
	}
	rep(i, 2, n) { f[i] = 0x3f3f3f3f;
		rep(j, max(i - k, 1), i - 1) {
			f[i] = min(f[i], f[j] + abs(a[i] - a[j]));
		}
	}
	
	printf("%d\n", f[n]);
	return 0;
}


Measured memory_bytes: 1024
import sys

n=int(sys.stdin.readline())
M = []
for i in range(n):
    a,b = map(int,sys.stdin.readline().split())
    M.append([a,b])

M = sorted(M,key=lambda x:sum(x), reverse=True)
cnt = 0
for i in range(n):
    if i%2==0:
        cnt += M[i][0]
    else:
        cnt -= M[i][1]
print(cnt)


Measured memory_bytes: 25244
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int max(int a, int b) {

	if (a > b)return a;
	else return b;

}
int main() {

	int N, K, X, Y, ans;

	cin >> N >> K >> X >> Y;

	if (N <= K) {

		ans = N*X;

	}
	else {

		ans = K*X + (N - K)*Y;

	}

	cout << ans << endl;

	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int MOD = 1e9 + 7;
const int INV2 = (MOD+1)/2;
const int N = 3030;

int n, a[N], m[N][N];

void print() {
    forn(i,n) { forn(j,n) cerr << m[i][j] << ' '; cerr << endl; }
    cerr << string(120,'=') << endl;
}

void process(int i, int j, int x, int y) {
    int ni = i, nj = j;

    if (i == x) ni = y;
    else if (i == y) ni = x;

    if (j == x) nj = y;
    else if (j == y) nj = x;

    if (mp(i,j) < mp(ni,nj)) m[ni][nj] = m[i][j] = ll(m[i][j] + m[ni][nj]) * INV2 % MOD;
}

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

    int q;
    cin >> n >> q;
    forn(i,n) cin >> a[i];
    forn(i,n) forn(j,n) if (a[i] > a[j]) m[i][j]++;

    ll mul = 1;
    forn(_,q) {
        mul = 2LL*mul%MOD;
        int i,j; cin >> i >> j;
        i--; j--;
        forn(k,n) if (k != i && k != j) {
            process(i,k,i,j);
            process(j,k,i,j);
            process(k,i,i,j);
            process(k,j,i,j);
        }
        for (auto ii : vi{i,j})
        for (auto jj : vi{i,j}) 
            process(ii,jj,i,j);
    }
    ll ans = 0;
    forn(j,n) forn(i,j) ans += m[i][j];
    cout << mul*(ans%MOD)%MOD;

    return 0;
}


Measured memory_bytes: 35840
import math
a, b, h, m = map(float, input().split())
ji = ((60 * h + m) / 720) * 2 * math.pi
hu = (m / 60) * 2 * math.pi
kaku = abs(ji - hu)
ans = (a ** 2 + b ** 2 - 2 * a * b * math.cos(kaku)) ** (1/2)
print(ans)

Measured memory_bytes: 9568
#================================================
from collections import deque

N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())
A.sort()
#=====================
Q=deque(range(1,N))
R=deque([0])
for i in range((N-1)//2):
    if i%2:
        x=Q.popleft()
        y=Q.popleft()
    else:
        x=Q.pop()
        y=Q.pop()

    R.appendleft(x)
    R.append(y)

if Q:
    x=Q.pop()
    R.appendleft(x)

X=[0]*N
Y=[0]*N
for i in range(N):
    X[i]=A[R[i]]
    Y[i]=A[-(R[i]+1)]

alpha=0
beta=0

for i in range(N-1):
    alpha+=abs(X[i+1]-X[i])
    beta +=abs(Y[i+1]-Y[i])
print(max(alpha,beta))


Measured memory_bytes: 77892
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
string str;
char lst;
long long k,ans,cnt;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>str>>k;
    int len=str.length();
    if(len==1){
    	printf("%lld\n",k/2);
    	return 0;
    }
    lst=str[0];cnt=1;
    for(int i=1;i<len;i++){
    	if(str[i]==lst)cnt++;
    	else ans+=k*(cnt/2),cnt=1,lst=str[i];
    }
    ans+=k*(cnt/2);
    if(str[len-1]==str[0]){
    	int cnts=0,cntt=0;
    	for(int i=0;i<len;i++){
    	    if(str[i]==str[0])cnts++;
    	    else break;
    	}
    	for(int i=len-1;i>=0;i--){
    	    if(str[i]==str[len-1])cntt++;
    	    else break;
    	}
    	if(cnts==len){
    	    printf("%lld\n",len*k/2);
    	    return 0;
    	}
    	if(cnts%2&&cntt%2)ans+=(k-1);
    }
    if(str[len-1]==str[0]&&str[len-2]!=str[len-1])ans+=(k-1);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int sum = 0;
  rep(i, n) sum += a[i];
  cout << (sum >= h ? "Yes" : "No") << endl;


  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string flag = "APPROVED";
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(a % 2 == 0){
      if(a % 3 == 0 || a % 5 == 0) continue;
      else{
		flag = "DENIED";
        break;
      }
    }else continue;
  }
  cout << flag << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, dp[100009]={}, h[100009], i, cnt;
	cin >> n;
	for (i=0; i<n; i++)
		cin >> h[i];

	dp[1] = abs(h[1] - h[0]);
	for(i=2; i<n; i++){
		dp[i] = min(abs(h[i]-h[i-1])+dp[i-1], abs(h[i]-h[i-2])+dp[i-2]);	
	}

	cout << dp[n-1] << endl;
	return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N; cin >> N;
  vector<int> a(N); rep(i, 0, N){ cin >> a[i]; }
  double ave=accumulate(all(a),0.0)/N;
  dump(ave);
  int idx=0;
  rep(i,0,N){
    if(abs(ave-a[i])<abs(ave-a[idx])){
      idx=i;
    }
  }
  cout<<idx<<endl;

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	
	for(int i = 1; i < s.size(); i++){
		if(s[i] == s[i-1]){
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

ans = 0

for i in range(n):
    ans += bisect_left(A, B[i]) * (n - bisect_right(C, B[i]))

print(ans)


Measured memory_bytes: 29348
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s; cin >> s;
    int n = s.size();

    int ans = INT_MAX;
    for (int i = 0; i < n-2; i++) {
        int num = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
        ans = min(ans, abs(753 - num));
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
//#include <math.h>
using namespace std;
typedef long long LL;

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

	auto vec = vector<int>(N);
	for (int i = 0; i < N; i++)
		cin >> vec[i];

	sort(vec.begin(), vec.end(), greater<int>());
	
	int A = 0, B = 0;
	for (int i = 0; i < N; i++)
		((i & 1) ? B : A) += vec[i];

	cout << A - B << endl;

	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

# a % k == x である場合、 b % k == c % k == (k - x)、
# なぜなら (a+b)%k == (a+c)%k == 0だから。
# あれ、でも (b+c)%k == 0でもあるんだから、
# x == 0 か、あるいは x == k/2じゃないとダメじゃね？
# しかも k/2ってことは、これはkが偶数のときのみ有効ってことか。
# kが奇数ならx==0の場合のみ、
# kが偶数ならx==0の場合とx==k/2の場合の2種類。
# これらを考えればいいってことか。
# それで、最終的に必要なのは個数なんだから
# すべてのパターンを書き出す必要まではないのか。
# x==0の場合は、n/kの**3か？
# x==k/2はある程度算出しないとダメそうだな。
sum = (n/k)**3

if k.even?
  i = 0
  count = 0
  until i*k+k/2 > n
    count += 1
    i += 1
  end
  sum += count**3
end

puts sum


Measured memory_bytes: 1788
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N;
    cin >> N;
    veci A(N);
    vecl s(N+1);
    REP(i,N) cin >> A[i];
    REP(i,N) s[i+1] = s[i] + A[i];
    ll ans = 200000000000010;
    for(int i = 1; i < N; i++) {
        chmin(ans,(ll)abs(s[i]-(s[N]-s[i])));
    } 
    cout << ans << endl;
}

Measured memory_bytes: 2560
package main
 
import (
	"fmt"
)
 
func main() {
  var (
    n int
    a int
	b int
	c int
	d int
	s string
  )
  fmt.Scan(&n)
  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)
  fmt.Scan(&d)
  fmt.Scan(&s)
  ans := "No"
 
  if c < d {
    sharpTwoFlg := false
    sc := 0
    for i := a; i < c; i++ {
      // 2回連続で不可能なのでNo判定
      if s[i] == '#' {
        sc++
        if sc >= 2 {
          sharpTwoFlg = true
          break
        }
        continue
      }
      sc = 0
    }
 
    sc = 0
    for i := b; i < d; i++ {
      if s[i] == '#' {
        sc++
        if sc >= 2 {
          sharpTwoFlg = true
          break
        }
      } else {
	      sc = 0
      }
    }
    
    if sharpTwoFlg {
      ans = "No"
    } else {
      ans = "Yes"
    }
    
  } else {
    dotThreeFlg := false
    sharpTwoFlg := false
 
    dc := 0
    sc := 0
    for i := b - 2; i <= d; i++ {
      if s[i] == '.' {
        dc++
        if dc >= 3 {
          dotThreeFlg = true
        }
        sc = 0
      } else {
        sc++
        if sc >= 2 {
          sharpTwoFlg = true
          break
        }
        dc = 0
      }
    }
    
    sc = 0
    for i := a; i < c; i++ {
      if s[i] == '#' {
        sc++
        if sc >= 2 {
          sharpTwoFlg = true
          break
        }
      } else {
	      sc = 0
      }
    }
 
    if !sharpTwoFlg && dotThreeFlg {
      ans = "Yes"
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
int main()
{
	ll A,B,C;
	cin>>A>>B>>C;
	if(A==B && B==5 && C==7) cout<<"YES";
	else if(A==C && C==5 && B==7) cout<<"YES";
	else if(B==C && C==5 && A==7) cout<<"YES";
	else cout<<"NO";
	
	
	
}

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

bool isPrime(int x){
  if(x<=1)return false;
  for(int i=2;i*i<=x;i++)
    if(x%i==0)return false;
  return true;
}

int main(){
  int a,d,n;
  
  while(cin >> a >> d >> n,a){
    int cnt = 0;
    for(int i=a;;i+=d){
      if(isPrime(i))cnt++;
      if(cnt == n){
	cout << i << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;
using P = std::pair<int, int>;
using PP = std::pair<int, P>;

struct St {
  ll prod;
  ll p, q, r;

  bool operator< ( const St &s ) const
  { return prod < s.prod; }
};

ll X, Y, Z, K;
ll A[1010], B[1010], C[1010];
std::priority_queue<St> pque;
std::set<PP> used;

int main()
{
  scanf( "%lld%lld%lld%lld", &X, &Y, &Z, &K );
  rep( i, X )
    scanf( "%lld", A+i );
  rep( i, Y )
    scanf( "%lld", B+i );
  rep( i, Z )
    scanf( "%lld", C+i );
  
  std::sort( A, A+X );
  std::sort( B, B+Y );
  std::sort( C, C+Z );

  ll cnt = 0;

  pque.push( St{ A[X-1]+B[Y-1]+C[Z-1], X-1, Y-1, Z-1 } );

  while( cnt < K )
  {
    St st = pque.top(); pque.pop();

    ++cnt;

    printf( "%lld\n", st.prod );

    if( cnt == K )
      return 0;

    if( st.p > 0 && !used.count( PP( st.p-1, P( st.q, st.r ) ) ) )
      pque.push( St{ A[st.p-1]+B[st.q]+C[st.r], st.p-1, st.q, st.r } ), used.insert( PP( st.p-1, P( st.q, st.r ) ) );
    if( st.q > 0 && !used.count( PP( st.p, P( st.q-1, st.r ) ) ) )
      pque.push( St{ A[st.p]+B[st.q-1]+C[st.r], st.p, st.q-1, st.r } ), used.insert( PP( st.p, P( st.q-1, st.r ) ) );
    if( st.r > 0 && !used.count( PP( st.p, P( st.q, st.r-1 ) ) ) )
      pque.push( St{ A[st.p]+B[st.q]+C[st.r-1], st.p, st.q, st.r-1 } ), used.insert( PP( st.p, P( st.q, st.r-1 ) ) );
  }

  return 0;
}

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

int main()
{
	ll w,h,x,y;
	cin >> w >> h >> x >> y;
	double ans = 0;
	ans = max(ans,(double)h*min((double)x,(double)w-x));
	ans = max(ans,(double)w*min((double)y,(double)h-y));
	printf("%.15lf ",(double)h*w/2);
	if(w==x*2&&h==y*2)cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 3752