akhauriyash/Code-Regression huggingface dataset:
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryA = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    aryA.insert(0, at: 0)
    aryA.append(0)
    
    var ans = 0
    for i in 1..<aryA.count {
        ans += abs(aryA[i] - aryA[i - 1])
    }
    
    for i in 2..<aryA.count {
        print(ans + abs(aryA[i - 2] - aryA[i]) - abs(aryA[i - 2] - aryA[i - 1]) - abs(aryA[i - 1] - aryA[i]))
    }
}
main()


Measured memory_bytes: 17696
N = int(input())

if (N < 600):
    print(8)
elif (N < 800):
    print(7)
elif (N < 1000):
    print(6)
elif (N < 1200):
    print(5)
elif (N < 1400):
    print(4)
elif (N < 1600):
    print(3)
elif (N < 1800):
    print(2)
else:
    print(1)

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,k; string s; cin>>n>>s>>k;
	for (int i=0; i<n; i++)
		if(s[i]!=s[k-1])
			s[i]='*';
	cout<<s<<"\n";
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		long sum = 0;
		for(int i = 1; i < n; i++) {
			sum += a[n-i/2-1];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 50648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N<=111){
    cout << 111 << endl;
  }
  else if (N<=222){
    cout << 222 << endl;
  }
  else if (N<=333){
    cout << 333 << endl;
  }
  else if (N<=444){
    cout << 444 << endl;
  }
  else if (N<=555){
    cout << 555 << endl;
  }
  else if (N<=666){
    cout << 666 << endl;
  }
  else if (N<=777){
    cout << 777 << endl;
  }
  else if (N<=888){
    cout << 888 << endl;
  }
  else if (N<=999){
    cout << 999 << endl;
  }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int w,h,x,y; cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(6)<<1.0*w*h/2<<" "s<<(w-x==x&&h-y==y?1:0)<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N, M, ans = INF;
ll A[300010], S[301000];

using namespace std;
int main() {
	//fill(begin(A), end(A), 0);
	fill(begin(S), end(S), 0);
	N = M = 0;
	std::ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> A[i];
		S[i] += A[i];
		S[i + 1] = S[i];
	}
	//a:右半分の区切り i:真ん中 b:左半分
	//s:右の和 t:左の和
	ll a = 0, b = 2, s, t;
	REP(i, N - 1) {
		if (i == b)b++;
		s = (S[i] - S[a]) - S[a];
		t = (S[N - 1] - S[b]) - (S[b] - S[i]);
		bool f = true;
		if (i == 0)continue;
		while (f) {
			f = false;
			if (a + 1 == i)continue;
			if (abs(s)>abs(s - A[a + 1] * 2)) {
				s -= A[a + 1] * 2;
				a++; f = true;
			}
		}
		f = true;
		while (f) {
			f = false;
			if (b + 1 == N - 1 || b == N - 1)continue;
			if (abs(t)>abs(t - A[b + 1] * 2)) {
				t -= A[b + 1] * 2;
				b++; f = true;
			}
		}
		ans = min(ans, (max({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })
			- min({ S[a],S[i] - S[a],S[b] - S[i],S[N - 1] - S[b] })));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d",&a,&b);
  c=(a+b)/2;
  if(c!=a&&1!=(a+b)%2){
    printf("%d", c);
    }
  else{
    printf("IMPOSSIBLE");
    }
  return 0;
  }

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t = sc.next();
        String result = "";
        for (int i = 0; i < n; i++) {
            result += String.valueOf(s.charAt(i)) + String.valueOf(t.charAt(i));
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  if(n==1&m==1) cout << 1;
  else if(n==1) cout << m-2;
  else if(m==1) cout << n-2;
  else cout << (long long)(n-2)*(m-2);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  if(max(a,b)>min(a,b)) {
    cout << max(a,b)+max(a,b)-1<< endl;
  }
  else {
    cout << max(a,b)*2 << endl;
  }
}



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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a)) 
#define all(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x;
	cin >> x;
	if(x==3||x==5||x==7) cout << "YES";
	else cout << "NO";
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

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

#define N 199
#define M 100
void push(int);
int pop(int);
int topb = 0;
char S[N];
int A[M];

int main(){
  int x,y;



  while(scanf("%s",S) != EOF){
    // printf("%s a\n",S);
    if(S[0] == '+'){
      x=pop(A[topb]);
      y=pop(A[topb]);
      push(y+x);
      // printf("%d b\n",A[topb]);
    }
    else if(S[0] == '-'){
      x=pop(A[topb]);
      y=pop(A[topb]);
      push(y-x);
      // printf("%d c\n",A[topb]);
    }
    else if(S[0] == '*'){
      x=pop(A[topb]);
      y=pop(A[topb]);
      push(y*x);
      // printf("%d d\n",A[topb]);
    }
    else{
      push(atoi(S));
      //printf("%d e\n",A[topb]);
    }
  }
  printf("%d\n",A[topb]);

  return 0;
}

void push(int a){
  topb+=1;
  A[topb]=a;
}

int pop(int a){
  topb-=1;
  return a;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

ld dfs(ld lb, ld ub, ld T, ld E, ld P, int K) {
	ld m = (lb + ub) / 2;
	if (K == 0) return T - E <= m && m <= T + E ? 1.0 : 0.0;
	if (T + E <= lb || ub <= T - E) return 0.0;
	if (T - E <= lb && ub <= T + E) return 1.0;
	if (m >= T) {
		return dfs(lb, m, T, E, P, K - 1) * (1 - P) + dfs(m, ub, T, E, P, K - 1) * P;
	}
	else {
		return dfs(m, ub, T, E, P, K - 1) * (1 - P) + dfs(lb, m, T, E, P, K - 1) * P;
	}
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	cout << fixed << setprecision(12);
	int K;
	ld R, L, P, E, T;
	cin >> K >> R >> L >> P >> E >> T;
	cout << dfs(R, L, T, E, P, K) << endl;
	return 0;
}



Measured memory_bytes: 3308
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<queue>
#include<math.h>
#include<ctime>
#include<deque>
#include<set>
#include<string.h>
#include<algorithm>
#include<map>
#include<stack>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ls rt<<1
#define rs rt<<1|1
#define mmm(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e17;
const double pi = acos(-1.0);
const int maxn = 1e6+5;
ll kase;
int n,m,p;
int f[maxn][2],vis[maxn];
string s;
void run(){
    cin>>s;
    n=s.size();
    if(s[n-1]=='s'){
        cout<<s<<"es";
    }else{
        cout<<s<<"s";
    }
}
int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
//    cin>>kase;
//    while(kase--)
        run();
    return 0;
}


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

int main(){
    int m,f,r;

    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1)break;
        if(m == -1 || f == -1){
            cout << 'F' << endl;
        }
        else if(m + f < 30 ){
            cout << 'F' << endl;
        }
        else if(m + f < 50){
            if(r >= 50){
                cout << 'C' << endl;
            }
            else{
                cout << 'D' << endl;
            }
        }
        else if(m + f < 65){
            cout << 'C' << endl;
        }
        else if(m + f < 80){
            cout << 'B' << endl;
        }
        else{
            cout << 'A' << endl;
        }
    }
    return 0;
}
    


Measured memory_bytes: 3088
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int64

()
|> readIntArray
|> fun [| a; b; x |] ->
    if a % x = 0L then (b / x) - (a / x) + 1L else (b / x) - (a / x)
    |> printfn "%d"


Measured memory_bytes: 29980
def main():
    n = int(input())
    array = list(map(int, input().split()))
    ans = 1
    re = 10 ** 18
    for i in range(n):
        if array[i] == 0:
            print(0)
            return 0
    for i in range(n):
        ans *= array[i]
        if ans > re:
            print(-1)
            return 0
    print(ans)
    return 0
        
main()


Measured memory_bytes: 21788
N, A, B = [int(i) for i in input().split()]
S = input()
a = 0
b = 0
for i in range(N):
    s = S[i]
    if s == 'a' and a + b < A + B:
        print('Yes')
        a += 1
    elif s == 'b' and a + b < A + B and b < B:
        print('Yes')
        b += 1
    else:
        print('No')

Measured memory_bytes: 4016
X, Y = map(int, input().split())
K = Y / 2 - X#48
T = 2 * X - Y / 2 #

if K.is_integer() and K>=0 and T.is_integer() and T>=0 and K * 4 + T * 2 == Y and K + T == X:
    print("Yes")
else:
    print('No')


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define lol long long
#define mp(x,y) make_pair(x,y)
using namespace std;

// const int mod=1e9+7;

/*  author: H3XoRuSH  */

lol N,W,a,b;
vector< pair<lol,lol> > x;
lol dp[101][100001];

lol solve(lol idx, lol cur){
    if(dp[idx][cur]==-1){
        if(idx>=N) dp[idx][cur]=0;
        else if(cur-x[idx].first<0) dp[idx][cur]=solve(idx+1,cur);
        else dp[idx][cur]=max(x[idx].second+solve(idx+1,cur-x[idx].first),solve(idx+1,cur));
    }
    return dp[idx][cur];
}

signed main() {
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp,-1,sizeof dp);
    cin >> N >> W;
    for(lol i=0; i<N; i++){
        cin >> a >> b;
        x.push_back(mp(a,b));
    }
    lol ans=solve(0,W);
    cout << ans;
    return 0;
}


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

using namespace std;

typedef long long ll;

template<typename T>
void _dump(const char* s, T&& head)
{
  cerr << s << "=" << head << endl;
}

template<typename T, typename... Args>
void _dump(const char* s, T&& head, Args&&... tail)
{
  while (*s != ',')
    cerr << *s++;
  cerr << "=" << head << ",";
  _dump(s + 1, tail...);
}

template<typename T>
void _dumpv(const char* s, T&& v)
{
  cerr << *s << "=";
  for (auto it = v.begin(); it != v.end(); it++) {
    cerr << *it << " ";
  }
  cerr << endl;
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__)
#define dumpv(...) _dumpv(#__VA_ARGS__, __VA_ARGS__)
// #define dump(...)
// #define dumpv(...)

const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("template.1", "r", stdin);

  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  int i;
  for (i = 0; i < N; i++) {
    cin >> L[i];
  }
  int ans = 1;
  int x = 0;
  // dump(N, X);
  for (i = 1; i <= N; i++) {
    x = x + L[i - 1];
    if (X < x) {
      break;
    }
    ans++;
    // dump(ans, x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/* ITP1_9_B */
import java.io.*;

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

      while((cards = br.readLine()).equals("-") == false){
        int shuffle = Integer.parseInt(br.readLine());

        for(int i = 0; i < shuffle; i++){
          int h = Integer.parseInt(br.readLine());
          StringBuilder sb = new StringBuilder();
          sb.append(cards.substring(h, cards.length()));
          sb.append(cards.substring(0, h));
          cards = sb.toString();
        }
        System.out.println(cards);
      }

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

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

const int N = 2005;
typedef long long ll;

int n, a[N], tot, ans;
bitset <N*N> f;

int main() {
	cin>>n;
	f[0] = 1;
	for(int i = 1; i <= n; i++) {
		cin>>a[i];
		f |= f<<a[i];
		tot += a[i];
	}
	ans = (tot + 1)/2;
	while(!f[ans]) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
string a;
int k;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C')
			k=1;
		if(a[i]=='F'&&k)
			k=2;
	}
	if(k==2)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int Y[]={1,0,-1,0};
  int X[]={0,1,0,-1};
  int i,j,y[200],x[200],t,r,c,ny,nx,k;
  char s[20][20]={};
  while(~scanf("%s",s[1]+1)){
    c=0;
    for(i=2;i<13;i++)scanf("%s",s[i]+1);
    for(i=1;i<13;i++){
      for(j=1;j<13;j++){
	if(s[i][j]=='0')continue;
	s[y[t=0]=i][x[0]=j]='0';
	c++;
	for(r=1;r-t;t++){
	  for(k=0;k<4;k++){
	    ny=y[t]+Y[k];
	    nx=x[t]+X[k];
	    if(s[ny][nx]-'1')continue;
	    s[y[r]=ny][x[r]=nx]='0';
	    r++;
	  }
	}
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 540
#include <stdio.h>

int main(void)
{
	int a = 100000;
	int b = 0;
	int c = 0;
	int i = 0;
	int n = 0;
	
	scanf("%d",&n);
	
	
	for(i = 0;i < n;i++){
		b = a * 0.05;				//bは5250になる 5550
		c = b % 1000;				//cは250になる 550

		if(c > 0){
			b = (b - c + 1000);		//bは6000になる 
		}
		a += b;					//aはになる
	}
	printf("%d\n",a);	
	
	return 0;
}

Measured memory_bytes: 1020
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::*;

fn main() {
    let a: i32 = read();
    let b: i32 = read();

    let m1 = max(a + b, a - b);

    println!("{}", max(m1, a * b));
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main() {
	int a, b, c, i, count;
	count = 0;
	cin >> a >> b >> c;
	
	for (i = a; i <= b; i++) {
		if (c%i == 0) {
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool yes = true;
    if(s[2] != s[3])yes = false;
    if(s[4] != s[5])yes = false;
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
/*input
5 2
1 1 2 2 5
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ll k;
	cin>>k;
	map<ll,ll>m;
	m.clear();
	ll foo;
	set<ll>s;
	while(n--)
	{
		cin>>foo;
		m[foo]++;
		s.insert(foo);
	}
	ll sz=s.size();
	if(sz<=k)
	{
		cout<<0<<endl;
		return 0;
	}
	vector<ll>v;
	for(map<ll,ll>::iterator i=m.begin();i!=m.end();i++)
	{
		v.push_back(i->second);
	}
	sort(v.begin(),v.end());
	n=v.size();
	ll mov=n-k;
	ll ans=0;
	for(ll i=0;i<mov;i++)
		ans+=v[i];
	cout<<ans<<endl;
}

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

int main() {
	ll n;
	cin >> n;
	vector<ll> num;
	
	int cond2 = 0;
	
	for(ll i = 0; i < n; i++){
	    ll x;
	    cin >> x;
	    if(x == 0){
	        cond2 = 1;
	    }
	    num.push_back(x);
	}
	
	if(cond2 == 1){
	    cout << 0 << endl;
	    return 0;
	}
	
	ll max = 1000000000000000000;
	ll res = 1;
	bool cond = true;
	
	for(ll i = 0; i < n; i++){
	    if(num[i] > 0 && res > max/num[i]){
	        cond = false;
	        break;
	    }else{
	        res = res * num[i];
	    }
	}
	
	if(cond){
	    cout << res << endl;
	}else{
	    cout << -1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4316
import java.util.Collections

import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val N = StdIn.readLine.toInt
    val L = StdIn.readLine.split(" ").map(l => l.toInt).sorted
    var ans = 0
    for (i <- 0 until N-2) {
      for (j <- i + 1 until N-1) {
        var low = j
        var high = N
        while(high - low > 1) {
          val mid = (high + low) / 2
          if (L(mid) < L(i) + L(j)) {
            low = mid
          } else {
            high = mid
          }
        }
        ans += low - j
      }
    }

    println(ans)
  }
}


Measured memory_bytes: 27580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;

ll n,q;
vector<set<ll> > st;
string str;

void build(ll id=1, ll l=0, ll r=n){
  if(r-l==1){
    st[id].insert(str[l]);
    return;
  }
  ll mid = (l+r)/2;
  build(2*id,l,mid);
  build(2*id+1,mid,r);
  st[id].insert(st[2*id].begin(),st[2*id].end());
  st[id].insert(st[2*id+1].begin(),st[2*id+1].end());
}

set<ll> ts;
void query(ll x, ll y, ll id=1, ll l=0, ll r=n){
  if(x>=r||y<=l){
		return;
	}
	if(x<=l&&y>=r){
    ts.insert(st[id].begin(),st[id].end());
    return;
	}
	ll mid=(l+r)/2;
  query(x,y,2*id,l,mid);
  query(x,y,2*id+1,mid,r);
  return;
}

void update(ll x,char y,ll id=1, ll l=0, ll r = n){
	if((r-l)<2){
    st[id].clear();
		st[id].insert(y);
		return;
	}
	ll mid=(l+r)/2;
	if(x<mid){
		update(x,y,2*id,l,mid);
	}
	else{
		update(x,y,2*id+1,mid,r);
	}
  st[id].clear();
	st[id].insert(st[2*id].begin(),st[2*id].end());
  st[id].insert(st[2*id+1].begin(),st[2*id+1].end());
}


int main(){
  cin >> n;
  cin >> str;
  cin >> q;
  st.resize(4*n);
  build();
  while(q--){
    ll a;
    cin >> a;
    if(a==1){
      ll b;
      char ch;
      cin >> b >> ch;
      update(b-1,ch);
    }
    else{
      ll c,d;
      cin >> c >> d;
      ts.clear();
      query(c-1,d);
      cout << ts.size() << endl;
    } 
  }
  // for(ll i=0;i<4*n;i++){
  //   cout << st[i].size() << " ";
  // }
  

}

Measured memory_bytes: 186872
import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): return sys.stdin.readline().rstrip()

N,M = map(int,S().split())
ab = [LI() for i in range(M)]

class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]  # 親のノード番号
        self.rank = [0]*(n+1)
    def find(self,x):  # xの根のノード番号
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def same_check(self,x,y):  # x,yが同じグループか否か
        return self.find(x) == self.find(y)
    def unite(self,x,y):  # x,yの属するグループの併合
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            x,y = y,x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x

ans = 0
for i in range(M):
    a,b = ab[i]
    unionfind = UnionFind(N)
    for j in range(M):
        if j == i:
            continue
        else:
            unionfind.unite(ab[j][0],ab[j][1])
    if not unionfind.same_check(a,b):
        ans += 1

print(ans)

Measured memory_bytes: 41708
#include<stdio.h>
int main(void){
  int i,sum = 700;
  char a[4];
  scanf("%s",a);
  for(i = 0; i < 3; i++){
    if(a[i] == 'o'){
      sum += 100;
    }
  }
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 128
import numpy as np

n,ma,mb=map(int,input().split())
L=10*n

dp=np.zeros((L+1,L+1),dtype="int64")
dq=np.zeros((L+1,L+1),dtype="int64")

inf=10**18
dp+=inf
dp[0][0]=0

for i in range(n):
    a,b,c=map(int,input().split())
    dq=dp.copy()
    dq[a:,b:]=np.minimum(dq[a:,b:],dp[:-a,:-b]+c)
    dp=dq
    
ans=inf
for i in range(1,401):
    if ma*i > L or mb*i > L:
        break
    ans=min(ans,dp[ma*i][mb*i])
if ans==inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 17540
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("outp.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    float s;
    s=n/3.0000000000000;
    s=s*s*s;
    printf("%.16f",s);
}

    


Measured memory_bytes: 3720
n=(int)(input())
a=[0 for i in range(10001)]
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      temp = (x * x) + (x * y) + (x * z) + (y * y) + (y * z) + (z * z)
      if temp <= 10000:
        a[temp] += 1

for i in range(n):
  print(a[i + 1])

Measured memory_bytes: 9432
'use strict'

function main(input) {
    input = input.split(/\n|\s/).map(v => ~~v)
    let A = input[0]
    let B = input[1]
    let C = input[2]

    const sum = A + B + C
    let goal = Math.max.apply(null, input) * 3

    if (sum % 2 == goal % 2) {
        // console.log(sum % 2, goal % 2)
    } else {

        goal += 3
    }

    const ans = Math.ceil((goal - sum) / 2)

    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const ll mod = 1e9 + 7;

int main() {
  string a, b;
  cin >> a >> b;
  int x = a == "H" ? 1 : 0, y = b == "H" ? 1 : 0;
  if (x == 0) y ^= 1;
  
  cout << (y ? "H" : "D") << endl;
  return 0;
}


Measured memory_bytes: 3580
#include "bits/stdc++.h"
#define INF 0x7fffffff
using namespace std;
vector<int> arr;
int n,A,B,C;
int dfs(int l,int a,int at,int b,int bt,int c,int ct)
{
    int ret=INF;
    if(l==n)
    {
	if(a==0||b==0||c==0)
	{
	    return INF;
	}
	ret=abs(a-A)+abs(b-B)+abs(c-C)+(at-1)*10+(bt-1)*10+(ct-1)*10;
	return ret;
    }
    ret=min(ret,dfs(l+1,a+arr[l+1],at+1,b,bt,c,ct));
    ret=min(ret,dfs(l+1,a,at,b+arr[l+1],bt+1,c,ct));
    ret=min(ret,dfs(l+1,a,at,b,bt,c+arr[l+1],ct+1));
    ret=min(ret,dfs(l+1,a,at,b,bt,c,ct));
    return ret;
}
int main()
{
    int i;
    scanf("%d %d %d %d",&n,&A,&B,&C);
    arr.resize(n+1);
    for(i=1;i<=n;i++)
    {
  	scanf("%d",&arr[i]);
    }
    printf("%d\n",dfs(0,0,0,0,0,0,0));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;

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

ll n,q,l,r;
ll p[100100];
ll sum[100100], len[100100];
bool use[100100];
const ll mod = 1e9+7;
ll par_sum[50][100100];

ll n_, c[1<<20];

void init(int n){
  n_ = 1;
  while(n_<n)n_*=2;

  for(int i=n_-1;i<2*n_-1;i++){
    if(i-n_+2<=n)c[i] = len[i-n_+2];
    else c[i] = 1;
  }

  for(int i=n_-2;i>=0;i--){
    c[i] = lcm(c[2*i+1],c[2*i+2]);
  }
}

ll query(int a,int b,int k,int l,int r){
  if(r<=a || b<=l)return 1;
  if(a<=l && r<=b)return c[k];
  ll vl = query(a,b,k*2+1,l,(l+r)/2);
  ll vr = query(a,b,k*2+2,(l+r)/2,r);
  return lcm(vl,vr);
}

int main(){
  cin >> n >> q;
  for(int i=1;i<=n;i++)cin >> p[i];

  memset(use,0,sizeof(use));

  for(int i=1;i<=n;i++){
    if(!use[i]){
      ll now = p[i];
      ll tmplen = 1, tmpsum = i;
     
      while(now!=i){
	tmplen++; (tmpsum += now) %= mod;
	now = p[now];
      }

      now = i;
      while(!use[now]){
	use[now] = true;
	len[now] = tmplen;
	sum[now] = tmpsum;
      }
    }
  }

  for(int i=1;i<=45;i++){
    par_sum[i][0] = 0;
    for(int j=1;j<=n;j++){
      if(len[j]==i)par_sum[i][j] = (par_sum[i][j-1] + sum[j]) % mod;
      else par_sum[i][j] = par_sum[i][j-1];
    }
  }

  init(n);

  for(int i=0;i<q;i++){
    cin >> l >> r;
    ll cycle = query(l-1,r,0,0,n_);

    ll res = 0;
    for(int i=1;i<=45;i++){
      res += (((cycle/i)%mod)*(((par_sum[i][r]-par_sum[i][l-1])%mod+mod)%mod))%mod;
      res %= mod;
    }

    cout << res << endl;
  }
}

Measured memory_bytes: 44764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		
		int n = sc.nextInt();
		
		int a[]= new int[n];
		int ans=0;
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        int min = a[0];
        
        for(int i=1; i<n; i++){
            if (min > a[i]){
                ans++;
                min = a[i];
            }
        }
		

        System.out.println(ans+1);
	}
}


Measured memory_bytes: 60252
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const ll MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    int N;
    cin>>N;
    vector<ll> A(N);
    map<ll,ll> mp;
    REP(i,N) cin>>A[i];
    REP(i,N){
        vector<pair<ll,ll>> fac=prime_factorize(A[i]);
        REP(i,fac.size()){
            mp[fac[i].first]=max(mp[fac[i].first],fac[i].second);
        }
    }
    ll L=1;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        L*=mod_pow(itr->first,itr->second,MOD);
        L%=MOD;
    }

    ll ans=0;
    REP(i,N){
        ans+=((L*mod_pow(A[i],MOD-2,MOD))%MOD);
        ans%=MOD;
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 896
N=int(input())
#people
li = list(map(int, input().split()))
Ave1=sum(li)//N
Ave2=sum(li)//N+1
S1=0
S2=0
for i in range(N):
  S1=S1+(Ave1-li[i])**2
for i in range(N):
  S2=S2+(Ave2-li[i])**2

if S1>S2:
  print(S2)
else:
  print(S1)

Measured memory_bytes: 9112
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<string>
using namespace std;
using pchar=pair<char, char>;
int simulate(const string& s, const vector<pchar>& td, int pos) {
	for (auto c : td) {
		if (s[pos] !=c.first) {
			continue;
		}
		if (c.second == 'L') {
			pos--;
		}
		else {
			pos++;
		}
		if (pos < 0) {
			return -1;//左に落ちる

		}
		if (pos >= (int)s.size()) {
			return 1;
		}
	}
	return 0;
}
int solve(int N, const string& s, const vector<pchar>& td) {
	//左側の境目
	int low = -1;
	int high = N;
	while (high - low > 1) {
		int mid = (high + low) / 2;
		if (simulate(s, td, mid) == -1) {
			low = mid;
		}
		else {
			high = mid;
		}
		
	}
	int left_fall = high;
	//右側の境目
	low = -1;
	high = N;
	while (high - low > 1) {
		int mid = (low + high) / 2;
		if (simulate(s, td, mid) == 1) {
			high = mid;
		}
		else {
			low = mid;
		}
	}
	int right_fall = N - 1 - low;
	
	return N - (left_fall + right_fall);
}


int main() {
	int N, Q;
	string s;
	cin >> N >> Q;
	cin >> s;
	vector<pchar>td(Q);
	for (int i = 0; i < Q; i++) {
		cin >> td[i].first >> td[i].second;
	}
	cout << solve(N, s, td) << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    string n;
    cin >> n;
    if(n.at(0) == '7' || n.at(1) == '7' || n.at(2) == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

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

			String S = scan.next();

			char[]s = S.toCharArray();

			int N = S.length()+1;
			int []a = new int[N];


			for(int i = 0;i<N-1;i++) {
				if(s[i]=='<') {
					a[i+1] = Math.max(a[i+1], a[i]+1);
				}
			}

			for(int i = N-2;i>=0;i--) {
				if(s[i]=='>') {
					a[i] = Math.max(a[i], a[i+1]+1);
				}
			}

			long goukei = 0;

			for(int i = 0;i<N;i++) {
				goukei+=a[i];
			}

			System.out.println(goukei);










		}


	}


}


Measured memory_bytes: 45200
#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>ll(b);i--)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
#define INF 1000000000000 
#define MOD 1000000007 
#define MAXR 100000 
#define PB push_back 
#define MP make_pair 
#define F first 
#define S second 
#define Umap unordered_map
#define Uset unordered_set


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    string alphabet = "abcdefghijklmnopqrstuvwxyz";
    string ans = "";
    while (N > 0) {
        ll mozi = N % 26;
        if (mozi==0) mozi = 26;
        ans.push_back(alphabet.at(mozi - 1));

        N -= mozi;
        N = N/26;
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int ans, var;
string s;
int main() {
	cin >> s;

	for (int i=0; i<s.size(); i++) {
		if (var==1) { var=0; ++ans; continue; }
		if (s[i] != s[i+1]) { ++ans; continue; }

		++i; ++ans;
		var = 1;
		continue;
	}

	cout << ans;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){


string S,T;
cin >> S >> T;
ll int s,t;
s= S.size();
t= T.size();
if(s==t && s==1){
	if(S[0]==T[0]){
		cout << "0";
		}
	else{
		cout << "1";
	}
	return 0;
}
else{}

ll int counter=0;
ll int ans = 1000000;

ll int n;
n=s-t;
for(ll int i=0;i<n+1;i++){
    
	for(ll int j=0;j<t;j++){
		if(S[i+j]!=T[j]){
			counter+=1;
		}
		else{}
	}
	if(counter<ans){
		ans = counter;
	}
	else{}
	counter=0;
}




cout << ans;









	return 0;

}



Measured memory_bytes: 3616
while True:
    num=int(input())
    if num==0:
        break
    else:
        li=[]
        d={}
        for i in range (num):
            info=list(map(int,input().split()))
            try:
                d[info[0]]+=info[1]*info[2]
            except:
                d[info[0]]=info[1]*info[2]
                li.append(info[0])
    answer=[]
    for i in li:
        if d[i] >=1000000:
            answer.append(i)
    if answer==[]:
        print("NA")
    else:
        for i in answer:
            print(i)
            
    
            
        

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a,b;
    cin >> a;
    int cou=0;
    REP(i,n-1){
        cin >> b;
        if(a==b){
            cou++;
            a=-1;
        }else{
            a=b;
        }
    }


    cout << cou << endl;
}


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

int f(int n){
	set<int> s; 
	int sum = 0 , maximum = 0;
	for(int i = 2 ; i*i <= n ; i++){
		if(n%i==0){
			s.insert(i);
			while(n%i==0){ n/=i; }
		}
	}
	if(n != 1) s.insert(n);
	
	for(set<int>::iterator it = s.begin(); it != s.end() ; ++it)
		sum += *it;
	
	return 2 * (*s.rbegin()) - sum;
}

int main(){
	int a,b;
	while(cin >> a >> b && a){
		if( f(a) > f(b) ){
			cout << 'a' << endl;
		}else{
			cout << 'b' << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef double dnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, c[3]; dnt f[305][305][305];
int main() {
	read(n);
	for (int i = 1, x; i <= n; i++)
		read(x), c[x-1]++;
	for (int s = 1; s <= n; s++) for (int i = s; ~i; i--)
		for (int j = s-i, k = 0; ~j; j--, k++) {
			f[i][j][k] = n;
			if (i) f[i][j][k] += f[i-1][j][k]*i;
			if (j) f[i][j][k] += f[i+1][j-1][k]*j;
			if (k) f[i][j][k] += f[i][j+1][k-1]*k;
			f[i][j][k] /= s;
		}
	return printf("%.12lf\n", f[c[0]][c[1]][c[2]]), 0;
}


Measured memory_bytes: 219392
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 1e9 + 7;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, k;
int dp[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	dp[n + 1] = 1;
	for(int i = 1;i < k;++i) {
		for(int j = n - i + 1;j >= 2;--j) {
			dp[j] += dp[j + 1] - mod, dp[j] += dp[j] >> 31 & mod;
		}
	}
	ll s = 0;
	rep(i, 2, n - k + 2) s += dp[i];
	if(k == 1) {
		s = 1;
	}
	cout << s % mod * pow(2, std::max(0, n - k - 1)) % mod << '\n';
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

s = []
s[0] = 0

1.upto(n) do |i|
  s[i] = s[i-1] + a[i-1]
end

h = Hash.new(0)
ans = 0

s.each do |val|
  h[val] += 1
  ans += h[val] - 1
end

p ans

Measured memory_bytes: 32588
//https://atcoder.jp/contests/abc146/tasks/abc146_a
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string x;
	cin>>x;
	if(x=="SUN")
	{
		cout<<"7"<<"\n";
	}
	else if(x=="MON")
	{
		cout<<"6"<<"\n";
	}
	else if(x=="TUE")
	{
		cout<<"5"<<"\n";
	}
	else if(x=="WED")
	{
		cout<<"4"<<"\n";
	}
	else if(x=="THU")
	{
		cout<<"3"<<"\n";
	}
	else if(x=="FRI")
	{
		cout<<"2"<<"\n";
	}
	else if(x=="SAT")
	{
		cout<<"1"<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3596
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	try{
	    BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
	    int[] x = new int[Integer.valueOf(sc.readLine())];
	    int p, a, b, t = Integer.valueOf(sc.readLine());
	    String st, u, v;
	    for(int i=0; i<x.length; i++)
		x[i]=i+1;
	    for(int i=0; i<t; i++){
		String[] parts = sc.readLine().split(",");
		a = Integer.valueOf(parts[0]);
		b = Integer.valueOf(parts[1]);
		p=x[a-1];
		x[a-1]=x[b-1];
		x[b-1]=p;
	    }
	    for(int i=0; i<x.length; i++)
		System.out.println(x[i]);
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
ll a;
  cin >> a;
  return a;
}

vi sub(vector<bool> fin,ll n) {
  vi ret;
  REP(i,n) {
    if(fin.at(i))continue;
    vector<bool> cp = fin;
    cp.at(i) = true;
    vi result = sub(cp,n);
    ret.insert(ret.end(),result.begin(),result.end());
  }
  return ret;
}

int main() {
  ll n;
  cin >> n;
  vi a(n);
  vi b(n);
  REP(i,n)cin >> a.at(i);
  REP(i,n)cin >> b.at(i);
  ll ans = 0;
  REP(i,n)if(a.at(i)>b.at(i))ans+=a.at(i)-b.at(i);
  cout << ans << endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<utility>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
// FIFO First in first out.
#include<deque>
// Either end of the line.
#include<cctype>
#include<list>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define debug(x) cout<<"[" << #x << " is: " << x << "] "<<endl;
#define rep(a,b,c) for(int i=a; i<b ;i++)
#define sora(v) sort(v.begin(), v.end())
#define sord(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define print(p) cout << p <<endl
#define yes puts("YES")
#define no puts("NO")
#define line cout <<endl;
//#define sizev(s) long long SIZE;  SIZE = s.size();
using namespace std;
int T;
double pi = acos(-1.0);
typedef long long ll;
int mod = 1e9 + 7;
vector<long long>v;
long long factorial(long long x) {
	long long total = 1;
	for (int i = 2; i <= x; i++)
		total *= i;
	return total;
}
//sieve algorithm. nlog(log(n)).
bool isprime(long long x) {
	vector<bool>prime(x + 1, 1);
	prime[0] = prime[1] = 0;
	for (long long i = 2; i * i <= x; i++)
		if (prime[i])
			for (long long j = i * i; j <= x; j += i)
				prime[j] = 0;
	return prime[x];

}
long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	else return gcd(b, a % b);
}
long long lcm(long long a, long long b)
{

	return (a * b) / gcd(a, b);
	//int lar = max(a, b);
	//int small = min(a, b);
	//for (int i = lar; ; i += lar) {
	//	if (i % small == 0)
		//	return i;
	//}
}
ll temp = 1;
ll fastpow(ll base, ll exponent) {

	if (exponent == 0) return 1;
	if (exponent == 1) return (temp * base);
	if (exponent % 2 == 0)
		return fastpow(base * base, exponent / 2);
	else {
		temp *= base;
		fastpow(base * base, exponent / 2);
	}
}
void fill(long long f) {
	v.clear();
	long long x;
	for (long long i = 0; i < f; i++) {
		cin >> x;
		v.push_back(x);
	}
}
void printv() {
	int size = v.size() - 1;
	for (int i = 0; i <= size; i++) {
		cout << v[i] << " ";
	}
	cout << endl;
}
inline void solve() {
//******************************************************************************
	long double a, b; 
	cin >> a >> b;
	print(ll(a * b));

////////////////////////////////////////////////////////////////////////////////
}int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//cin >> T; while (T--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>
long long a, b, c, d, e, f, m, n;
int x[3001];
int y[3001];
int main() {
	scanf("%lld%lld%lld%lld%lld%lld", &a, &b, &c, &d, &e, &f);
	x[0] = 1;
	y[0] = 1;
	for (int i = 0; i < f; i++) {
		if (x[i]) {
			if (i + 100 * a < f)x[i + 100 * a]++;
			if (i + 100 * b < f)x[i + 100 * b]++;
		}
		if (y[i]) {
			if (i + c < f)y[i + c]++;
			if (i + d < f)y[i + d]++;
		}
	}
	n = 1;
	for (long long i = 1; i <= f; i++) {
		for (long long j = 0; j <= f; j++) {
			if (x[i] && y[j] && i + j <= f && (i / 100 * e) >= j) {
				if (n * j >= m * i + m * j) {
					m = j;
					n = i + j;
				}
			}
		}
	}
	printf("%lld %lld\n", n, m);
}

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

#define mod 1000000007
#define ll long long

using namespace std;

ll fact(ll a){
	ll ans = 1;
	for(int i = 1; i <= a; i++){
		ans = (ans * i)%mod;
	}
	return ans;
}

int
main(void){
	ll a, b;
	cin >> a >> b;
	if(abs(a - b) > 1){
		cout << 0;
		return 0;
	} 
	ll ans = (fact(a) * fact(b))%mod;
	if(a == b){
		ans *= 2;
		ans %= mod;
		cout << ans;
		return 0;
	}
	cout << ans;
}

Measured memory_bytes: 256
import sys

def main():
    MOD = 10**6+3

    # preprocess
    fac = [None] * (MOD+1)
    fac[0] = fac[1] = 1
    for i in range(2, MOD+1):
        fac[i] = (fac[i-1] * i) % MOD

    Q = int(input())
    for i in range(Q):
        x, d, n = map(int, sys.stdin.readline().split())

        if d == 0:
            print(pow(x, n, MOD))
            continue
        
        xd = (x * pow(d, MOD-2, MOD)) % MOD
        if xd == 0 or xd + (n-1) >= MOD:
            print(0)
            continue

        print(pow(d, n, MOD) * fac[xd+(n-1)] * pow(fac[xd-1], MOD-2, MOD) % MOD)


if __name__ == "__main__":
    main()

Measured memory_bytes: 43488
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	parseProblem()
}

func parseProblem() {
	n := scanInt(sc)
	hs := nextIntSlice(sc, n)
	cur := 0
	for i := 0; i < len(hs); i++ {
		if !(cur <= hs[i]) {
			fmt.Println("No")
			return
		}
		if hs[i]-1 >= cur {
			cur = hs[i] - 1
		} else {
			cur = hs[i]
		}
	}
	fmt.Println("Yes")
	return
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4296
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static ArrayList<Integer>[] adj;
	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		adj=new ArrayList[n];
		for(int i=0;i<n;i++)
		{
			adj[i]=new ArrayList<Integer>();
		}
		for(int i=0;i<m;i++)
		{
			int u=scan.nextInt();
			int v=scan.nextInt();
			u--;v--;
			adj[u].add(v);
		}
//		System.out.println(adj[0].get(0));
		int dist[][]=new int[n][3];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<3;j++)
				dist[i][j]=Integer.MAX_VALUE-10;
		}
		Queue<fok> que=new LinkedList<fok>();
		int s=scan.nextInt()-1;
		int t=scan.nextInt()-1;
		que.add(new fok(s,0));
		dist[s][0]=0;
		while(!que.isEmpty())
		{
			
			fok cur=que.poll();
//			System.out.println(cur.a);
			int pos=cur.a;
			int rem=cur.b;
			for(int to:adj[pos])
			{
//				System.out.println("LOL");
				if(dist[to][(rem+1)%3]>dist[pos][rem]+1) {
					dist[to][(rem+1)%3]=dist[pos][rem]+1;
					que.add(new fok(to,(rem+1)%3));
				}
			}
			
		}
	
		if(dist[t][0]==Integer.MAX_VALUE-10) {
			dist[t][0]=-3;
		}
		System.out.println(dist[t][0]/3);
	}
}
class fok{
	int a;int b;
	fok(int x,int y)
	{
		a=x;
		b=y;
		
	}
}


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

int main(){
string s;
cin>>s;
int a[130]={0};
string m="";
for(int i=0;i<s.size();i++)
{
    if(a[ s[i]]==0)
    {
        m=m+s[i];
        a[ s[i] ]=1;

    }
}
    int k=m.size();
    if(k==2)cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}



Measured memory_bytes: 256
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
//ll ans[2*MAX];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,x,v1,v2,s=0;
    cin>>n;
    vll v;
    map <ll,ll> m;
    set <ll> res;
    set <ll>::iterator it;
   // map <ll,ll>::iterator it;
    for(i=0;i<n;++i){
    	cin>>x;
    	v.pb(x);
    	m[x]++;
    	res.insert(x);
	}
	for(it=res.begin();it!=res.end();++it){
		v1=m[*it];
		s+=v1*(v1-1)/2;
	}
	for(i=0;i<n;++i){
		v1=m[v[i]];
		cout<<(s-(v1-1))<<'\n';
	}
}

Measured memory_bytes: 17008