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 s=sc.La;
		var pf1=new Pf(s[0]);
		var pf2=new Pf(s[1]);
		int ans=1;
		pf1.Get((k,v)=>{
			if(pf2.hs.ContainsKey(k)){
				ans++;
			}
		});
		Console.WriteLine("{0}",ans);
	}
}
public class Pf{
	public Dictionary<long,int> hs=new Dictionary<long,int>();
	public Pf(long n){
		while(n%2==0){
			n>>=1;
			if(hs.ContainsKey(2)){hs[2]++;}
			else{hs.Add(2,1);}
		}
		long q=(long)Sqrt(n)+1;
		int i=3;
		while(n!=1&&i<q){
			if(n%i==0){
				n/=i;
				q=(long)Sqrt(n)+1;
				if(hs.ContainsKey(i)){hs[i]++;}
				else{hs.Add(i,1);}
				i=3;
			}
			else{i+=2;}
		}
		if(n!=1){
			if(hs.ContainsKey(n)){hs[n]++;}
			else{hs.Add(n,1);}
		}
	}
	public void Get(Action<long,int> f){
		foreach(var e in hs){f(e.Key,e.Value);}
	}
}

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 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: 13276
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

ll mod = 1e9+7;

ll dfs(int k, const vector<vector<int>> &graph,int now,int from){
    int can_use_color_num;
    if(from==-1){
        can_use_color_num = k-1;
    }
    else{
        can_use_color_num = k-2;
    }
    if(k<graph[now].size()){
        return 0;
    }
    else{
        ll case_num=1;
        for(auto e:graph[now]){
            if(e==from) continue;
            case_num*=can_use_color_num;
            can_use_color_num--;
            case_num%=mod;
        }
        for(auto e:graph[now]){
            if(e==from) continue;
            case_num *= dfs(k,graph,e,now);
            case_num%=mod;
        }
        return case_num;
    }
}

int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>> graph(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    ll answer = k*dfs(k,graph,0,-1);
    answer%=mod;
    cout << answer << endl;
 }

Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(int i=0; i<v; i++)
#define forj(v) for(int j=0; j<v; j++)
#define fork(v) for(int k=0; k<v; k++)
#define forl(v) for(int l=0; l<v; l++)
#define fort(v) for(int t=0; t<v; t++)
#define forz(v) for(int z=0; z<v; z++)
#define forx(v) for(int x=0; x<v; x++)
#define ll long long
#define lll __int128
#define MAX (int)(4*pow(10,3) + 100)
#define pb(a) push_back(a)
#define ch (int)(4*pow(10,4) + 100)
#define ld long double
// #define cout out
// #define cin in
ll inf = pow(10,18);
ll modulo = pow(10,9)+7 ;
double eps = 1e-9;
ifstream in;
ofstream out;
 


 
void deal(){
	ll a, b;
	cin>>a>>b;
	for(ll i = b*10 ; i<b*10 + 10; i++){
		if(i*8/100 == a){
			cout<<i;
			return;
		}
	}
	cout<<-1;
}
 
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
/* 
6 8 
1 2
2 3
3 4
4 1
2 5
3 5
1 6
4 6
*/

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int n = ri();
	int64_t keta_sum = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		int d = ri();
		int64_t a;
		std::cin >> a;
		keta_sum += a;
		sum += d * a;
	}
	std::cout << (keta_sum - 1) + (sum - 1) / 9 << std::endl;
	
	return 0;
}


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

using namespace std;

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

    // lyoka value
    vector<int64_t> L(N + 1);

    // initial value
    L.at(0) = 2;
    L.at(1) = 1;

    for (int i = 2; i <= N; i++) {
        L.at(i) = L.at(i - 2) + L.at(i - 1);
    }

    // output
    cout << L.at(N) << endl;
}


Measured memory_bytes: 256
a[1111],b[1111],c[1111],d[1111],p[333],i,j,x,y,z;main(){for(;scanf("%d%d%d",a,b,c)&&(*a+=*b+*c);){for(i=332;i;p[i--]=2);for(i=0,scanf("%d",p);i++<*p;scanf("%d%d%d%d",a+i,b+i,c+i,d+i));for(i=0;i++<*p;)for(j=0;j++<*p;d[j]?p[a[j]]=p[b[j]]=p[c[j]]=1:(x=p[a[j]]&1)&(y=p[b[j]]&1)?p[c[j]]=0:x&(z=p[c[j]])?p[b[j]]=0:y&z?p[a[j]]=0:0);for(i=0;i<*a;printf("%d\n",p[++i]));}return 0;}

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

int gcd(int a, int b) {
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}
int main(void) {
    int x,y;cin>>x>>y;
    cout << gcd(x, y) << endl;
    return 0;
}


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

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

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

    int[][] pts = new int[N][2];
    int[] x = new int[N];
    int[] y = new int[N];

    for (int i = 0; i < N; i++) {
      x[i] = scanner.nextInt();
      y[i] = scanner.nextInt();
      pts[i][0] = x[i];
      pts[i][1] = y[i];
    }

    Arrays.sort(x);
    Arrays.sort(y);

    long min = Long.MAX_VALUE;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        for (int k = 0; k < N; k++) {
          for (int l = k + 1; l < N; l++) {
            long left = x[i];
            long right = x[j];
            long bottom = y[k];
            long top = y[l];

            int count = 0;
            for (int m = 0; m < N; m++)
              if (pts[m][0] >= left
                  && pts[m][0] <= right
                  && pts[m][1] >= bottom
                  && pts[m][1] <= top) {
                count++;
              }
            if (count >= K) min = Math.min(min, Math.abs(right - left) * Math.abs(top - bottom));
          }
        }
      }
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 24404
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define M_PI       3.14159265358979323846
#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double t1=h*30+0.5*m,t2=6*m;
    t1-=t2;
    if(360-t1<t1) t1=360-t1;
    t1=2*M_PI*t1/360;
    double answer=sqrt(a*a+b*b-2*a*b*cos(t1));
    cout.precision(10);
    cout<<fixed;
    cout<<answer;

    return 0;
}


Measured memory_bytes: 4180
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
b = list(li())

ans = []
exist = True

res = n

while res > 0:
    cur = -1
    for i in range(len(b)):
        if b[i] == i+1:
            cur = i
            
    if cur == -1:
        exist = False
        break
    else:
        b = b[:cur] + b[cur+1:]
        ans.append(cur+1)
        
    res -= 1

if not exist:
    print(-1)
else:
    for ansi in ans[::-1]:
        print(ansi)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int n, m, atari, d;
bool check(vector<int> line, vector< vector<int> > sideline, int col=-1, int row=-1){
	int i,j;
	if(col!=-1 && row!=-1)sideline[col][row] = 1;
	for(i=0;i<d;i++){
		for(j=0;j<n-1;j++){
			if(sideline[i][j] == 1){
				swap(line[j], line[j+1]);
			}
		}
	}
	if(line[atari-1] == m){
		return true;
	}
	return false;
}
int main(){
	int i, j;
	bool flg;
	string str;
	while(true){
		cin>>n;if(n==0)break;
		cin>>m>>atari>>d;
		vector<int> line(n);
		for(i=0;i<n;i++) line[i] = i+1;
		vector< vector<int> > sideline(d, vector<int>(n-1));
		for(i=0;i<d;i++){
			cin>>str;
			for(j=0;j<n-1;j++){
				sideline[i][j] = str[j] - '0';
			}
		}
		if(check(line, sideline) == true){
			cout<<0<<endl;
			continue;
		}
		flg = false;
		for(i=0;i<d;i++){
			for(j=0;j<n-1;j++){
				if(j==0){
					if(sideline[i][j+1] != 1){
						flg = check(line, sideline, i, j);
					}
				}else if(0<j && j<n-2){
					if((sideline[i][j+1] != 1) && (sideline[i][j-1] != 1)){
						flg = check(line, sideline, i, j);
					}
				}else if(j==n-2){
					if(sideline[i][j-1] != 1){
						flg = check(line, sideline, i, j);
					}
				}
				if(flg)break;
			}
			if(flg)break;
		}
		if(flg){
			cout<<i+1<<" "<<j+1<<endl;
		}else{
			cout<<"1"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
import heapq
n,m = map(int,input().split())
a=  list(map(int,input().split()))
h = list(map(lambda x:-1*x,a))
heapq.heapify(h)
for i in range(m):
    heapq.heapreplace(h,-(-h[0]//2))
print(-1*sum(h))

Measured memory_bytes: 72044
#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal

#N=int(input())
A,V = map(int,input().split())
B,W = map(int,input().split())
T=int(input())
#A = list(map(int,input().split()))
#S=str(input())

if V<=W:
    print('NO')
else:
    L=abs(A-B)
    if L/(V-W)<=T:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 9080
#include <bits/stdc++.h>
const int MAX = 1e4 + 10;
typedef long long i64;
using namespace std;
const double EPS = 1e-6;

int dp[MAX + 1];
int last[MAX];
bool good(int n){
    bool seen[10] = {false};
    while(n > 0){
        if(seen[n % 10])return false;
        seen[n % 10] = true;
        n /= 10;
    }
    return true;
}

int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    //freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'


	i64 n, a, b, c, d; cin >> n >> a>>b>>c>>d;
	int top = b -  a;
	n -= 1;
	bool ans= false;
	for(int i = 0; i <= n; i++){
		i64 left = i * c - (n - i) * d;
		i64 right = i * d - (n - i) * c;
		if(left <= top && top <= right){
			//cout << i << endl;
			ans = true; break;
		}
	}
	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;







}



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

using namespace std;

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

	if (N == M) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}




}


Measured memory_bytes: 3600
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N,an=0;
	cin >> N;
	vector<ll> a(N);
	rep(i, N) {
		cin >> a.at(i);
	}
	rep(i, N) {
		if (a.at(a.at(i) - 1) == i+1) {
			an++;
		}
	}
	cout << an / 2 << endl;

}




Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  string str;cin>>str;
  if(str[0] == str[1] && str[1] == str[2])
  {
    cout<<"No"<<endl;
  }
  else
  {
    cout<<"Yes"<<endl;
  }
  
  
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (stdIn.hasNext()) {
			long a = stdIn.nextLong();
			long b = stdIn.nextLong();
			long c = 0;
			long d = a * b;
			if (a < b) {
				outside: for (;;) {
					c = b % a;
					if (c == 0)
						break outside;
					b = a;
					a = c;

				}
				c = a;
			} else {
				outside: for (;;) {
					c = a % b;
					if (c == 0)
						break outside;
					a = b;
					b = c;

				}
				c = b;
			}
			System.out.println(c + " " + d/c);
		}
	}
}

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

int main(){
	
	int c[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
	for(int i=1;i<=2;i++){
		for(int j=1;j<=2;j++){
			if(c[i][0]-c[0][0] != c[i][j]-c[0][j]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252];
ll dp[3][125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,3)REP(j,n)dp[i][j] = -830252521;
  dp[0][0] = 0;
  REP(i,n){
    REP(x,3){
      if(a[i]>=x){
        int r = a[i]-x;
        REP(y,3){
          CHMAX(dp[x][i+1],dp[y][i]+(r+y)/2);
        }
      }
    }
  }
  ll ans = 0;
  REP(i,3)CHMAX(ans,dp[i][n]);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 2944
import Control.Monad
import Data.List

data Katana = Throw 
            | Cut
            deriving (Show, Eq, Ord)

main = do
  [n, h] <- map read . words <$> getLine :: IO [Int]  

  print . solve 0 h . reverse . sort . concat =<< replicateM n (do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    return [(a, Cut), (b, Throw)])

solve :: Int -> Int -> [(Int, Katana)] -> Int
solve i h ((n, t): ns)
    | h <= 0     = i
    | t == Cut   = solve (i+1) (h-n) ((n, t):ns)
    | t == Throw = solve (i+1) (h-n) ns

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

int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  reverse(all(a));
  ll ans;
  rep(i,n-3){
    if(a[i]==a[i+1]){
        if(a[i]==a[i+3]){
          ans=a[i]*a[i];
          cout<<ans<<endl;
          break;
        }
       else{
          for(int j = i+2 ; j < n-1 ; j++ ){
            if(a[j]==a[j+1]){
              ans=a[i]*a[j];
              cout<<ans<<endl;
              break;
            }
          }
         break;
       }
      
      
      
    }
  }
  
 if(ans==0)  cout<<ans<<endl;
}




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

int main(){
  int dice[6]={1,2,4,3,5,6};
  string s;
  int n,temp,ans;

  while(cin >> n){
    ans=1;
    dice[0]=1;dice[1]=2;dice[2]=4;dice[3]=3;dice[4]=5;dice[5]=6;
    for(int i=0;i<n;i++){
      cin >> s;
      if(s=="North"){
	temp=dice[0];
	dice[0]=dice[1];
	dice[1]=dice[5];
	dice[5]=dice[4];
	dice[4]=temp;
	ans+=dice[0];
      }else if(s=="East"){
	temp=dice[0];
	dice[0]=dice[2];
	dice[2]=dice[5];
	dice[5]=dice[3];
	dice[3]=temp;
	ans+=dice[0];
      }else if(s=="West"){
	temp=dice[0];
	dice[0]=dice[3];
	dice[3]=dice[5];
	dice[5]=dice[2];
	dice[2]=temp;
	ans+=dice[0];
      }else if(s=="South"){
	temp=dice[0];
	dice[0]=dice[4];
	dice[4]=dice[5];
	dice[5]=dice[1];
	dice[1]=temp;
	ans+=dice[0];
      }else if(s=="Right"){
	temp=dice[1];
	dice[1]=dice[3];
	dice[3]=dice[4];
	dice[4]=dice[2];
	dice[2]=temp;
	ans+=dice[0];
      }else if(s=="Left"){
	temp=dice[1];
	dice[1]=dice[2];
	dice[2]=dice[4];
	dice[4]=dice[3];
	dice[3]=temp;
	ans+=dice[0];
      }
    }
    if(n!=0){
    cout << ans << endl;
    }
  }

}

Measured memory_bytes: 1208
import java.awt.*;
import java.io.*;
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new TestA().doIt();
	}
	class TestA{
		void doIt() {
			String S = sc.next();
			int length = S.length();
			if(S.substring(length-1, length).equals("s")) {
				System.out.println(S+"es");
			}else {
				System.out.println(S+"s");
			}
		}
	}
}

Measured memory_bytes: 38460
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n,p;
  cin>>n>>p;
  string s;
  cin>>s;
  if (p == 2 || p == 5) {
    string candi = p == 2 ? "02468" : "05";
    ll ans = 0;
    for(auto&& i:irange(0l,n)) {
      if (boost::find(candi, s[i]) != end(candi)) {
        ans += i+1;
      }
    }
    cout<<ans<<endl;
    return 0;
  }
  vecll cnt(p, 0);
  ll rem = 0;
  cnt[0] = 1;
  boost::reverse(s);
  ll p10 = 1;
  for(char c:s) {
    p10 *= 10;
    p10 %= p;
    rem += (c - '0') * p10;
    rem %= p;
    ++cnt[rem];
  }
  ll ans = 0;
  for(ll x:cnt) {
    ans += x * (x-1) / 2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string S, T;
	cin >> S >> T;

	string ans = "";


	int a = 0, b = 0;
	bool elf = true;
	while (b < n) {
		if (elf) {
			ans += S[a];
			a++;
			elf = false;
		}
		else {
			ans += T[b];
			b++;
			elf = true;
		}
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=200000+10;
const int INF=10000000;
int p1[N],p2[N];
map<pair<int,int>,int>m;
int find(int x,int *p)
{return p[x]==x?p[x]:p[x]=find(p[x],p);}
void cha(int x,int y,int *p){
	int px=find(x,p);
	int py=find(y,p);
	if(px!=py)p[px]=py;
}
int main(){
	int n,k,l;
	cin>>n>>k>>l;
	for(int i=1;i<=n;i++)
		p1[i]=i,p2[i]=i;
	for(int i=1;i<=k;i++){
		int x,y;
		scanf("%d%d,",&x,&y);
		cha(x,y,p1);
	}
	for(int i=1;i<=l;i++){
		int x,y;
		scanf("%d%d,",&x,&y);
		cha(x,y,p2);
	}
	for(int i=1;i<=n;i++)
		find(i,p1),find(i,p2);
	for(int i=1;i<=n;i++)
		m[make_pair(p1[i],p2[i])]++;
	for(int i=1;i<=n;i++)
		printf("%d ",m[make_pair(p1[i],p2[i])]);
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans = 0, tmp = 0;
    rep(i, s.size()) {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    ans = max(ans, tmp);
    cout << ans << endl;
}

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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0]==5&&a[1]==5&&a[2]==7){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}


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

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

  int i  = 0;
  int k = 0;
  while (i < N) {
    string color;
    cin >> color;
    if (color == "Y"){
      k ++;
      break;
    }
    i ++;
}
  if (k == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  mn=inf
  for i in range(n-k+1):
    a=l[i]
    b=l[i+k-1]

    if a<0 and b>0:
      mn=min(mn,abs(a)+abs(b)*2,abs(a)*2+abs(b))
    else:
      mn=min(mn,max(abs(a),abs(b)))

  return mn

print(main())


Measured memory_bytes: 17136
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll N;
ll M;
vl A;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> M;
    A = vl(M);
    for(int i = 0; i < M; ++i){
        cin >> A[i];
    }
    solve();
}

// 1 <= N <= 10^6
// 1 <= M <= 10^4
// 1 <= A_i <= 10^4

// ll N, ll M, vl A
// 高橋君が遊ぶことのできる日数、または、-1 を出力せよ。
void solve(){
    ll sum=0;
    rep(i,M)sum+=A[i];
    cout<<max(-1LL,N-sum)<<endl;
}


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

int main(void){
	
	while (true){
		double v,t,y;
		cin>>v;
		if (cin.eof()) break;
		t = v/9.8;
		y = v/2*t;
		int h = ceil(y/5)+1;
		cout<<h<<endl;
	}
	return 0;
}

Measured memory_bytes: 1232
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String[] s = br.readLine().split(" ");

		String[] s1 = s.clone();

		String[] bubblesort_return = bubblesort(s);

		StringBuilder sb = new StringBuilder();

		for (String str : bubblesort_return) {
			sb.append(str);
			sb.append(" ");
		}
		System.out.println(sb.toString().trim());
		System.out.println("Stable");

		String[] sellectsort_return = sellectesort(s1);

		StringBuilder sb2 = new StringBuilder();

		for (String str : sellectsort_return) {
			sb2.append(str);
			sb2.append(" ");
		}

		System.out.println(sb2.toString().trim());

		for(int i=0; i<s.length; i++){
			if(!(bubblesort_return[i].equals(sellectsort_return[i]))){
				System.out.println("Not stable");
				break;
			}
			if(i == s.length-1){
				System.out.println("Stable");
			}
		}

	}

	static String[] sellectesort(String[] nums) {

		int min;


		Boolean judge = false;

		for (int i = 0; i < nums.length-1; i++) {
			min = i;

			for (int k = i + 1; k < nums.length; k++) {
				if (Character.getNumericValue(nums[k].charAt(1)) < Character.getNumericValue(nums[min].charAt(1))) {
					min = k;
					judge = true;
				}
			}

			String num = nums[i];

			nums[i] = nums[min];

			nums[min] = num;

			judge = false;

		}

		return nums;

	}

	static String[] bubblesort(String[] nums) {
		boolean jeudge = true;

		while (jeudge) {
			jeudge = false;
			for (int k = nums.length - 1; k >= 1; k--) {

				if (Character.getNumericValue(nums[k].charAt(1)) < Character.getNumericValue(nums[k - 1].charAt(1))) {
					String a = nums[k];

					nums[k] = nums[k - 1];

					nums[k - 1] = a;

					jeudge = true;
				}
			}
		}
		return nums;
	}

}

Measured memory_bytes: 24376
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
using namespace std;

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

typedef long long ll;


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((a < b && b < c)?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//A
int main(void) {
  int n, k, i,a, cou=0, tmp;
  scanf("%d %d", &n,&a);
  printf("%d",n*n-a);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typedef(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!(c >= 48); c = getchar()) if (c == 45) f ^= 1;
	for (; (c >= 48); c = getchar()) x = x * 10 + c - 48;
	return f ? x : -x;
}

/*
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
struct Checker {
	bool grid[105][105];
	int n, m;
	void init(int _n, int _m, bool _grid[105][105]) {
		n = _n;
		m = _m;
		rep(i, n) rep(j, m) grid[i][j] = _grid[i][j];
	}
	bool used[105][105];
	void dfs(int x, int y) {
		used[x][y] = 1;
		rep(d, 4) {
			int nx = x + dx[d];
			int ny = y + dy[d];
			if (nx < 0 || ny < 0 || nx > n || ny > m) continue;
			if (used[nx][ny]) continue;
			if (grid[nx][ny] != grid[x][y]) continue;
			dfs(nx, ny);
		}
	}
	bool chk(int a, int b) {
		memset(used, 0, sizeof used);
		int cnta = 0, cntb = 0;
		rep(i, n) rep(j, m) {
			if (used[i][j]) continue;
			dfs(i, j);
			if (grid[i][j]) ++ cntb;
			else ++ cnta;
		}
		printf("%d %d\n", cnta, cntb);
		return cnta == a && cntb == b;
	}
} checker;
*/

int main() {
	int a, b;
	a = read(), b = read();
//	srand((unsigned ll) (new char));
//	a = rand() % 500 + 1, b = rand() % 500 + 1;
	int n = 100, m = 100;
	bool grid[105][105];
	memset(grid, 0, sizeof grid);
	bool swp = 0;
	if (a > b) swap(a, b), swp = 1;
	vector <pii> lft;
	vector <pii> cen;
	for (int i = 2; i + 2 < 100; i += 4) {
		for (int j = 2; j + 2 < 100; j += 4) {
			cen.pb(mp(i, j));
			lft.pb(mp(i - 1, j - 1));
			lft.pb(mp(i - 1, j + 1));
			lft.pb(mp(i + 1, j - 1));
		}
	}
	rep(i, a - 1) {
		int x = cen[i].first;
		int y = cen[i].second;
		grid[x - 1][y] = 1;
		grid[x][y - 1] = 1;
		grid[x][y + 1] = 1;
		grid[x + 1][y] = 1;
	}
	if ((a - 1) * 4 < b) {
		int cnt = (a - 1) * 4;
		for (int i = a - 1; cnt < b; ++ i) {
			int x = cen[i].first;
			int y = cen[i].second;
			if (cnt < b) {grid[x - 1][y] = 1; ++ cnt;}
			if (cnt < b) {grid[x][y - 1] = 1; ++ cnt;}
			if (cnt < b) {grid[x][y + 1] = 1; ++ cnt;}
		}
	} else {
		rep(i, (a - 1) * 4 - b) {
			grid[lft[i].first][lft[i].second] = 1;
		}
	}
	if (swp) {rep(i, n) rep(j, m) grid[i][j] = !grid[i][j]; swap(a, b);}
	printf("%d %d\n", n, m);
	rep(i, n) rep(j, m) {
		if (grid[i][j]) putchar('#');
		else putchar('.');
		if (j + 1 == m) putchar(10);
	}
//	printf("%d %d\n", a, b);
//	checker.init(n, m, grid);
//	return !checker.chk(a, b);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = []
if N ==2:
    print(B[0]*2)
else:
    A.append(B[0])
    for i in range(N-2):
        A.append(min(B[i], B[i+1]))
    A.append(B[N-2])
    print(sum(A))

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

	int n,k;
	cin >> n>>k;
	if (k==1) {
		cout << "0" << endl;
		return 0;
	}
	cout << n-k << endl;
}


Measured memory_bytes: 256
n = int(input())
h_list = list(map(int, input().split()))
for i in range(n - 2, -1, -1):
    if h_list[i] > h_list[i + 1]:
        h_list[i] -= 1
    if h_list[i] > h_list[i + 1]:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 14396
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll k; cin >> k;
    for(ll i = 2; i <= 50; ++i){
        if((i - 1) + k / i + (k % i ? i - k % i : 0) <= 1e16 + 1000 && (i - 1) + k / i + (k % i ? i - k % i : 0) >= i - 1){
            ll mod = k % i;
            cout << i << endl;
            for(int j = 0; j < i; ++j){
                cout << (i - 1) + k / i + (j < mod ? i - mod : -mod) << " ";
            }
            cout << endl;
            break;
        }
    }
    return 0;
}

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

int main() {
  bool yes = false;

  string s, t;
  cin >> s >> t;

  for(int i=0;i<s.size();i++) {
    if(s == t) {
      yes = true;
      break;
    }

    s.insert(0, 1, s[s.size()-1]);
    s.pop_back();
  }

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

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

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String A = sc.next();
        char[] a = A.toCharArray();
        Arrays.sort(a);
        long c = 1;
        long ans = 0;
        for (int i = 1; i < (long) A.length(); i++) {
            if (a[i] != a[i - 1]) {
                ans += (c * (c - 1)) / 2;
                c = 1;
            } else {
                c++;
            }
        }
        ans += (c * (c - 1)) / 2;
        System.out.println(((long) A.length() * ((long) A.length() - 1)) / 2 - ans + 1);
    }
}


Measured memory_bytes: 26832
object Main extends App {
  val Array(a,b,c,d,e,f) = readLine.split(" ").map{_.toInt}
  (for (x <- 0 to 30;
        y <- 0 to 30;
        z <- 0 to 100;
        w <- 0 to 100;
        if (x + y > 0 &&
            100*a*x+100*b*y+c*z+d*w <= f &&
            (c*z+d*w).toDouble / (100*a*x+100*b*y).toDouble <= e.toDouble / 100.0)
       ) yield {(x,y,z,w)}
  ).sortWith{
    case ((x1,y1,z1,w1),(x2,y2,z2,w2)) =>
       (c*z1+d*w1).toDouble / (100*a*x1+100*b*y1).toDouble >
       (c*z2+d*w2).toDouble / (100*a*x2+100*b*y2).toDouble
  }.head match {
    case (x,y,z,w) => println((100*a*x+100*b*y+c*z+d*w) + " " + (c*z+d*w))
  }                        
}

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

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	bool flag = false;
	rep(i,n){
		cin >> s[i];
		if(i > 0){
			if(s[i-1][s[i-1].size()-1] != s[i][0]) flag = true;
			rep(j,i){
				if(s[i] == s[j]) flag = true;
			}
		}
		if(flag){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
    
using namespace std;
    
int main(){
 int W, H, x, y, r;
 cin >> W;
 cin >> H;
 cin >> x;
 cin >> y;
 cin >> r;
 if (x-r >=0 && x+r<=W && y-r>=0 && y+r <=H) {
  cout << "Yes" <<endl;
 } else {
  cout << "No" <<endl;
 }
 return 0;
}


Measured memory_bytes: 3112
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static int cnt = 0;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			putCntMap(map, a);
		}
		sc.close();

		Integer[] k = map.keySet().toArray(new Integer[0]);
		if (k.length > 3) {
			System.out.println("No");
		} else if (k.length == 3) {
			Arrays.parallelSort(k);
			int v0 = map.get(k[0]);
			int v1 = map.get(k[1]);
			int v2 = map.get(k[2]);
			if (v0 == v1 && v1 == v2) {
				if ((k[0] ^ k[1]) == k[2]) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		} else if (k.length == 2) {
			Arrays.parallelSort(k);
			if (k[0] == 0) {
				int v1 = map.get(k[1]);
				if (v1 % 2 == 0) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				System.out.println("No");
			}
		} else if (k.length == 1) {
			if (k[0] == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

	static void putCntMap(Map<Integer, Integer> map, Integer key) {
		if (map.containsKey(key)) {
			map.put(key, map.get(key) + 1);
		} else {
			map.put(key, 1);
		}
	}
}


Measured memory_bytes: 59192
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end(),less<int>());

    int tmp = a[n-1]/2;
    auto lt = lower_bound(a.begin(),a.end(), tmp);
    auto lt2 = lt;
    lt2--;

    int c = *lt;
    if(abs(tmp-*lt) > abs(tmp-*lt2)) c = *lt2;

    if(a[n-1] == c)
        cout << a[n-1] << " " << a[n-2] << endl;
    else
        cout << a[n-1] << " " << c << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

//--------------------------

int main() {

  int n, k;
  cin >> n >> k;
  int h[n];
  rep(i, n) cin >> h[i];

  sort(h, h+n);

  ll sum = 0;
  rep(i, n-k) {
    sum += h[i];
  }

  cout << sum << endl;

  return 0;
}


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

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

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//C++14 (GCC 5.4.1)
int main() {
    int N;
    double T,A;
    cin >>N>>T>>A;

    vector<double> H(N);
    rep(i,N) cin >> H[i];
    
    //-----------------------------------
    int ans=1;
    double minrt=abs(A-T+H[0]*0.006);
    repd(i,1,N){
        if(chmin(minrt,abs(A-T+H[i]*0.006))){
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return (0);
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())

memo = defaultdict(int)

for _ in range(N):
    a = input()
    if "." in a:
        x, y = a.split(".")
        x = int(x) * (10 ** 9)
        y = y[::-1]
        y = y.zfill(9)
        y = y[::-1]
        y = int(y)
        val = x + y
    else:
        val = int(a) * (10 ** 9)
    c2 = 0
    c5 = 0
    while val and val % 2 == 0:
        val //= 2
        c2 += 1
    while val and val % 5 == 0:
        val //= 5
        c5 += 1
    memo[(c2, c5)] += 1

ans = 0
keys = list(memo.keys())
size = len(keys)

for i in range(size):
    a, b = keys[i]
    v1 = memo[(a, b)]
    for j in range(i, size):
        c, d = keys[j]
        v2 = memo[(c, d)]
        if a + c < 18 or b + d < 18:
            continue
        if i == j:
            ans += v1 * (v1 - 1) // 2
        else:
            ans += v1 * v2
print(ans)

Measured memory_bytes: 9460
import java.text.DecimalFormat;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        final int N = sc.nextInt();
        final int K = sc.nextInt();
        
        out.println((long)(K * Math.pow(K-1, N-1)));
        
        out.flush();
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22612
N = int(input())
X = [int(i) for i in input().split()]

indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: X[i])

for i in range(N):

    if X[i] <= X[sorted_indexes[int(N / 2)-1]]:
        print(X[sorted_indexes[int(N / 2)]])
    else:
        print(X[sorted_indexes[int(N / 2)-1]])

Measured memory_bytes: 27028
#include<iostream>
#include<string>
#include<memory.h>
using namespace std;
int main()
{
	//2004-1-1 Tuesday
	int a[370];
	string youbi[7] = {
		 "Monday", "Tuesday","Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
	int m[13] = { 0,0, 31,60 ,91,121, 152, 182,213 , 244, 274, 305, 335 };
	for (int i = 3; i <= 365+3; i++){
		a[i] = i % 7;
	}
	while (true){
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;
		cout << youbi[a[m[x] + y + 2]] << endl;
	}
}

Measured memory_bytes: 1192
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W, K = LI()
    c = [list(SS()) for _ in range(H)]

    ans = 0
    for i in range(2 ** H):
        for j in range(2 ** W):
            cnt = 0
            for k in range(H):
                for l in range(W):
                    if not ((i >> k & 1) or (j >> l & 1)):
                        if c[k][l] == '#':
                            cnt += 1
            if cnt == K:
                ans += 1

    print(ans)
                        



if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10124
import itertools

N, M = map(int, input().split())
adj_mtrx = [[0] * N for _ in range(N)]

# 隣接行列
for i in range(M):
    a, b = map(int, input().split())
    # 無向グラフなので両方1にする
    adj_mtrx[a-1][b-1] = 1
    adj_mtrx[b-1][a-1] = 1


cnt = 0

# itertools.permutations(list) リストから順列を生成、列挙
# 頂点を結ぶ結び方を全て列挙する（順列で列挙できる）
# 列挙したした中で頂点1から始まっているかつパスとして繋がっているものをカウントする
for each in itertools.permutations(range(N)):

    # 1からスタートしない場合break
    if each[0]!=0:
        break

    factor=1
    for i in range(N-1):
        # 隣接行列で繋がっていれば1、繋がっていなければ0なので
        # 一つでも繋がっていなければ、0になる
        factor *= adj_mtrx[each[i]][each[i+1]]
    cnt += factor

print(cnt)


Measured memory_bytes: 3064
import java.util.*;
public class Main
{
    static int n;
    static int dp[],m[];
    static int solve(int i)
    {
        if(i>n)
            return 2000000000;
        if(i==n)
            return 0;
        if(dp[i]!=-1)
            return dp[i];
        dp[i]=Math.min(Math.abs(m[i]-m[i+1])+solve(i+1),Math.abs(m[i]-m[i+2])+solve(i+2));
        return dp[i];
    }
    public static void main(String args[])
    {
        Scanner in=new Scanner(System.in);
        n=in.nextInt();
        dp=new int[n+5];
        m=new int[n+5];
        for(int i=1;i<=n;i++)
            m[i]=in.nextInt();
        Arrays.fill(dp,-1);
        System.out.println(solve(1));
        in.close();
    }
}


Measured memory_bytes: 76248
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi p(n);
	input(p);
	for (int i = 2; i < n; i++) {
		if (max({p[i-2],p[i-1],p[i]}) !=p[i-1] and min({p[i-2],p[i-1],p[i]}) !=p[i-1] ){
			ans++;
		}
	     }
	cout << ans << endl;
}

Measured memory_bytes: 3552