akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC_IHCA
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            long D = RL();
            long[] Ca = RLa(26);
            long[,] La = RLa(D, 26);


            long msum = 0;
            for (int j = 0; j < 26; ++j)
            {
                msum += Ca[j];
            }
            long[] minus = new long[26];
            /*
            for (int j = 0; j < 26; ++j)
            {
                minus[j] = msum - Ca[j];
            }
            */

            for (int i = 0; i < D; ++i)
            {
                Console.WriteLine(max(La, i, Ca, minus) + 1);
//                Console.WriteLine((i % 26) + 1);
            }

#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int max(long[,] La, int i, long[] Ca, long[] minus)
        {
            long m = long.MinValue;
            int midx = 0;
            for (int j = 0; j < 26; ++j)
            {
                if (La[i, j] + minus[j] > m)
                {
                    m = La[i, j] + minus[j];
                    midx = j;
                }
            }

            for (int j = 0; j < 26; ++j)
            {
                if (j == midx)
                {
                    minus[j] = 0;
                }
                else
                {
                    minus[j] += Ca[j];
                }
            }

            return midx;
        }

        static long RL()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] RLa(long n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            long[] la = new long[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = long.Parse(sa[i]);
            }
            return la;
        }

        static long[,] RLa(long r, long c)
        {
            long[,] la = new long[r, c];
            for (int i = 0; i < r; ++i)
            {
                string[] sa = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; ++j)
                {
                    la[i, j] = long.Parse(sa[j]);
                }
            }
            return la;
        }
    }
}


Measured memory_bytes: 28116
n = int(input())
s = 0

for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        i = "FizzBuzz"
    elif i % 3 == 0:
        i = "Fizz"
    elif i % 5 == 0:
        i = "Buzz"
    else:
        s += i
    #print(i)

print(s)

Measured memory_bytes: 9104
#include <iostream>
  #include <iomanip>
  #include <algorithm>
  #include <cmath>
  #include <queue>
  #include <list>
  #include <limits>
  #include <string>
  #include <vector>
  #include <stack>
  using namespace std;
  typedef unsigned long long ll;

  

  int main(){
    int t = 0;
    int x = 0;
    cin >> t >> x;
    double t_double = (double) t;
    double x_double = (double) x;
    cout << t_double/x_double << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((ll)(1e18))
using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int A, B, Q; cin >> A >> B >> Q;
	vector<ll> s(A, 0LL);
	rep (i, A) cin >> s[i];
	vector<ll> t(B, 0LL);
	rep (i, B) cin >> t[i];

	ll res = 0LL, curr = 0LL;
	rep (i, Q){
		ll x; cin >> x;
		int a[2] = {0};
		a[0] = lower_bound(ALL(s), x) - s.begin();
		a[1] = max(0, a[0] - 1);
		int b[2] = {0};
		b[0] = lower_bound(ALL(t), x) - t.begin();
		b[1] = max(0, b[0] - 1);
		res = INF;
		rep (j, 2){
			rep (k, 2){
				curr = abs(x - s[a[j]]) + abs(t[b[k]] - s[a[j]]);
				res = min(res, curr);
				curr = abs(x - t[b[k]]) + abs(s[a[j]] - t[b[k]]);
				res = min(res, curr);
			} // end rep
		} // end rep
		cout << res << endl;
	} // end rep
					
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int old = sc.nextInt();
    int money = sc.nextInt(); 
    int ans = 0;
    if(old <= 5) ans = 0;
    else if(old >= 13) ans = money;
    else ans = money / 2;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

vector<vector<int>> g;
vector<bool> visited;
vector<int> dp;

int f(int now) {
    if (visited[now]) return dp[now];
    visited[now] = true;
    if (g[now].size() == 0) return 0;
    int m = 0;
    for (int to : g[now]) {
        m = max(m, f(to) + 1);
    }
    return dp[now] = m;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    g.resize(N);
    visited.assign(N, false);
    dp.resize(N);
    REP(i, M) {
        int x, y; cin >> x >> y;
        x--; y--;
        g[x].emplace_back(y);
    }
    int ans = 0;
    REP(i, N) {
        if (!visited[i]) {
            ans = max(ans,f(i));
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 8192
import sys

def wfs(queue, S, step, goal):
    next_queue = set()
    for q in queue:
        if q == goal:
            return step+1

        i, j = q[0], q[1]
        S[i][j] = '#'

        if S[i+1][j] == '.':
            next_queue.add((i+1, j))
        if S[i-1][j] == '.':
            next_queue.add((i-1, j))
        if S[i][j+1] == '.':
            next_queue.add((i, j+1))
        if S[i][j-1] == '.':
            next_queue.add((i, j-1))

    if len(next_queue) == 0:
        return -1
    else:
        next_queue = list(set(next_queue))
        return wfs(next_queue, S, step+1, goal)


def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    S = []
    black = 0
    for _ in range(H):
        s = [c for c in input().strip()]
        black += sum([c == '#' for c in s])
        S.append(['#'] + s + ['#'])
    S = [['#'] * (W+2)] + S + [['#'] * (W+2)]
    init = set([(1, 1)])
    minstep = wfs(init, S, 0, (H, W))
    if minstep == -1:
        print(-1)
    else:
        print(H*W - minstep - black)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
use std::io;

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut n = String::new();
    io::stdin().read_line(&mut n).unwrap();
    n.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn main() {
    let n: Vec<i32> = read_vec();
    let w = n[0];
    let h = n[1];
    let x = n[2];
    let y = n[3];
    let r = n[4];
    println!(
        "{}",
        if x - r < 0 || x + r > w || y - r < 0 || y + r > h {
            "No"
        } else {
            "Yes"
        }
    )
}



Measured memory_bytes: 5024
import collections
def Comb(n,k):
    comb_ans=1
    for i in range(1,k+1):
        comb_ans*=(n-i+1)/i
    comb_ans=int(comb_ans)
    return comb_ans

N=int(input())
S=[''.join(sorted(input())) for i in range(N)]
T=collections.Counter(S)
ans=0
for i in T.most_common():
    ans+=Comb(i[1],2)
#print(S)
#print(T)
print(ans)

Measured memory_bytes: 24496
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{

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

    ll n = s.size();

    ll ans = 0;

    for (ll i = 0; i < n; i++)
    {
        if (s[i] != t[i])
            ans++;
    }

    cout << ans << endl;
}


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

const int N = 1e5 + 10;

int dp[3][N];

int main()
{
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			cin >> dp[j][i];
		}
	}
	
	for(int i = 2; i <= n; i++)
	{
		for(int j = 0; j < 3; j++)
		{
			dp[j][i] += max(dp[(j + 1) % 3][i - 1], dp[(j + 2) % 3][i - 1]);
		}
	}
	
	cout << max(dp[0][n], max(dp[1][n], dp[2][n]));
	
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	int num[5], sum, n, small, large;
	int i, j, k;
	
	while (scanf("%d", &n), n != 0){
		large = 0;
		small = 1000;
		for (k = 0; k < n; k++){
			sum = 0;
			for (j = 0; j < 5; j++){
				scanf("%d", &num[j]);
				sum += num[j];
			}
			if (large < sum){
				large = sum;
			}
			if (small > sum){
				small = sum;
			}
		}
		
		printf("%d %d\n", large, small);
	}
	
	return 0;
}

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

int main () {

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);

    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
        a[2] *= 2;
    }

    cout << a[0] + a[1] + a[2] << endl;

    return 0;
}

Measured memory_bytes: 888
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.chars();
    for e in s {
        if e == '7' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

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

int main()
{
	int a,b,c;
	scanf("%i%i%i",&a,&b,&c);
	int k=a+b;
	int l=a+c;
	int p=b+c;
	if(k<=l && k<=p)
	{
		printf("%i",k);
	}
	else if(l<=k && l<=p)
	{
		printf("%i",l);
	}
	else
	{
		printf("%i",p);
	}
    return 0;
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	ll n;
	cin >> n;
	vector<ll> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	ll ans = 0;
	for (int c = 0; c < n; c++) {
		set<ll> se;
		ll score = 0;
		for (int x = 0; x < n; x++) {
			ll a = n - 1 - x * c;
			ll b = a - c;
			if (a <= 0 || b <= 0) break;
			ll right = n - 1 - x * c;
			ll left  = x * c;
			if (right <= 0 || left >= n - 1 || left == right || se.find(right) != se.end() || se.find(left) != se.end()) break;
			se.insert(right);
			se.insert(left);
			score += s[left] + s[right];
			ans = max(ans, score);
		}
	}
	dump(ans);
	return 0;
}


Measured memory_bytes: 5760
/*
tarun360
IIT Indore
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl

string s,t;
ll dp[3005][3005];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>s>>t;
  s=" "+s;
  t=" "+t;
  ll n=s.size(),m=t.size();
  forn(i,1,n){
    forn(j,1,m){
      if(s[i]==t[j]) dp[i][j]=1+dp[i-1][j-1];
      else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  ll len=dp[n-1][m-1];
  string ans;
  --n;
  --m;
  while(n!=0 && m!=0){
    if(s[n]==t[m]){
      //debug1(s[n]);
      ans.pb(s[n]);
      --n;
      --m;
    }else{
      if(dp[n][m-1]<dp[n-1][m]){
        --n;
      }else{
        --m;
      }
    }
  }
  forn_d(i,len-1,0){
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

int main()
{
    int n, d, x, y, t;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> t >> x >> y;
        d = abs(x) + abs(y);

        if(d > t || (d - t) % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};


int main() {
    ll a,b;
    cin >> a >> b;
    ll n = gcd(a,b);
    map <ll,ll> mp;
    for(ll i = 2; i*i <= n; i++){
        if(n%i == 0){
            while(n%i == 0){
                n /= i;
                mp[i]++;
            }
        }
    }
    if(n > 1) mp[n]++;
    cout << mp.size()+1;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

N,M=MAP()
nodes=[[] for i in range(N)]
for i in range(M):
    u,v=MAP()
    nodes[u].append(v)
    nodes[v].append(u)

visited=[False]*N
timer=1
prenum=[0]*(N+1)
parent=[0]*(N+1)
lowest=[0]*(N+1)
def rec(cur, prev):
    global timer
    # curを訪問した直後の処理
    prenum[cur]=lowest[cur]=timer
    timer+=1

    visited[cur]=True
    for nxt in nodes[cur]:
        if not visited[nxt]:
            # curからvへ訪問する直前の処理
            parent[nxt]=cur
            rec(nxt, cur)
            # vの探索が終了した直後の処理
            lowest[cur]=min(lowest[cur], lowest[nxt])
        elif nxt!=prev:
            # cur -> v がback-edgeの場合の処理
            lowest[cur]=min(lowest[cur], prenum[nxt])

# 必要な各値の取得
rec(0, -1)

# 間接点
ap=set()
# ルートの子ノードの数
np=0
for i in range(1, N):
    p=parent[i]
    if p==0:
        np+=1
    # 条件2の確認
    elif prenum[p]<=lowest[i]:
        ap.add(p)
# 条件1の確認
if np>1:
    ap.add(0)

ap=sorted(ap)
for a in ap:
    print(a)



Measured memory_bytes: 19300
import itertools


def solve():

    N = int(input())

    num = str(N)
    com = []
    com.append(('3', '5', '7'))
    com.append(('3', '5', '7'))
    res = 0
    dig = len(num)
    for x in range(3, dig+1):
        com.append(('3', '5', '7'))

        temp = list(itertools.product(*com))

        tempanswer = [i for i in temp if all(i.count(k) for k in '753')]
        answer = [int("".join(y)) for y in tempanswer if int("".join(y)) <= N]

        res = len(answer) + res
    print(res)


solve()

Measured memory_bytes: 7404
# -*- coding: utf-8 -*-

D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(j) for j in input().split()])

for i, s_i in enumerate(s):
    print(s_i.index(max(s_i)) + 1)

Measured memory_bytes: 9404
from collections import Counter, defaultdict
import sys
N = int(input())
x = []
for i in range(N):
    a, b = map(int, input().split())
    x.append([a, b])
if N == 1:
    print(1)
    sys.exit()
x.sort()
cost = []
for i, y in enumerate(x):
    for j, z in enumerate(x):
        if i == j:
            continue
        else:
            num = 0
            a = z[0]-y[0]
            b = z[1]-y[1]
            for w in x:
                c = w[0]
                d = w[1]
                if [a+c, b+d] in x:
                    num += 1
            cost.append(N-num)
print(min(cost))

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

int main() {
    string s; cin >> s;
    int k; cin >> k;
    for (auto &x : s) if (x != 'a') {
        if ('z' - x + 1 <= k) {
            k -= 'z' - x + 1;
            x = 'a';
        }
    }
    k %= 26;
    s.back() += k;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	int n;cin>>n;
  	for(int i=1;i<=9;i++){
    	if(n<=i*100+i*10+i){
        	cout<<i*100+i*10+i<<endl;
          	return 0;
        }
    }
  }



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long
int n,k,m,a[25005],f[25005][405],g[25005][405],ls[405];
int Pow(int x,int y){
    int ans=1;
    while(y){
        if(y&1)ans=(LL)ans*x%mod;
        x=(LL)x*x%mod;y>>=1;
    }
    return ans;
}
int jc(int n){
    int ans=1;
    for(int i=1;i<=n;i++)ans=(LL)ans*i%mod;
    return ans;
}
int main(){
    scanf("%d%d%d",&n,&k,&m);
    for(int i=1;i<=m;i++)scanf("%d",&a[i]);
    int mx=0,now=0,tot=(LL)(n-m+1)*Pow(k,n-m)%mod;
    for(int i=1;i<=m;i++){
        now=min(now+1,i-ls[a[i]]);
        ls[a[i]]=i;mx=max(mx,now);
    }
    if(mx==k){
		printf("%d",tot);
		return 0;
	}
    if(mx==m){
        f[0][0]=1;
        for(int i=1;i<=n;i++){
            int s=0,t=0;
            for(int j=k-1;j>=1;j--){
                (s+=f[i-1][j])%=mod;
                (t+=g[i-1][j])%=mod;
                (f[i][j]+=(LL)f[i-1][j-1]*(k-j+1)%mod)%=mod;
                (g[i][j]+=(LL)g[i-1][j-1]*(k-j+1)%mod)%=mod;
                (f[i][j]+=s)%=mod;
                (g[i][j]+=t)%=mod;
                if (j>=m) (g[i][j]+=f[i][j])%=mod;
            }
        }       
	    int w=0;
        for(int i=1;i<=k;i++)(w+=g[n][i])%=mod;
        w=(LL)w*jc(k-m)%mod*Pow(jc(k),mod-2)%mod;
        printf("%d",(tot+mod-w)%mod);
    }
    else{
        int u=0,v=0;
        memset(ls,0,sizeof(ls));
        for(int i=1;i<=m;i++)
            if(!ls[a[i]]){
				u++;
				ls[a[i]]=1;
			}
            else break;
        memset(ls,0,sizeof(ls));
        for(int i=m;i>=1;i--)
            if(!ls[a[i]]){
				v++;
				ls[a[i]]=1;
			}
            else break;
        f[0][u]=g[0][v]=1;
        for(int i=1;i<=n;i++){
            int s=0,t=0;
            for(int j=k-1;j>=1;j--){
                (s+=f[i-1][j])%=mod;
                (t+=g[i-1][j])%=mod;
                (f[i][j]+=(LL)f[i-1][j-1]*(k-j+1)%mod)%=mod;
                (g[i][j]+=(LL)g[i-1][j-1]*(k-j+1)%mod)%=mod;
                (f[i][j]+=s)%=mod;
                (g[i][j]+=t)%=mod;
            }
        }
        for(int i=0;i+m<=n;i++){
            int s=0,t=0;
            for(int j=1;j<k;j++){
				(s+=f[i][j])%=mod;
				(t+=g[n-m-i][j])%=mod;
            }
			(tot+=mod-(LL)s*t%mod)%=mod;
        }
        printf("%d",tot);
    }
}

Measured memory_bytes: 82932
#include <stdio.h>

int main(void)
{
	int a, b, i, f, f2 = 0;
	
	while (1){
		scanf("%d %d", &a, &b);
		
		if (a == 0 && b == 0){
			break;
		}
		
		f = 0;
		
		if (f2 == 1){
			puts("");
		}
		f2 = 1;
		
		for (i = a; i <= b; i++){
			if (i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)){
				printf("%d\n", i);
				f = 1;
			}
		}
		
		if (f == 0){
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
 
ll M = pow(10,18);
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
int main(int argc, const char * argv[]) {

    ll A;
    cin >> A;
    
    string B;
    cin >> B;
    
    ll B_new = (B[0]-'0') * 100 + (B[2]-'0') * 10 + (B[3]-'0') * 1;
    
    cout << A*B_new/100 << endl;
    
    
    
    
    
}



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

int main() {
	char c;
	cin >> c;
	switch (c) {
		case 'a':
		case 'e':
		case 'i':
		case 'o':
		case 'u':
			cout << "vowel" << endl;
			break;
		default:
			cout << "consonant" << endl;
	}
}

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

int main(){

    string s;
    cin >> s;

    long long last = s.size();
    while(last != 0){
        if(last < 5){ 
            cout << "NO" << endl;
            return 0;
        }
        if(s.substr(last - 5, 5) == "dream" ){
            last -= 5;
        }
        else if(s.substr(last - 5, 5) == "erase" ){
            last -= 5;
        }
        else if(s.substr(last - 6, 6) == "eraser" ){
            last -= 6;
        }
        else if(s.substr(last - 7, 7) == "dreamer" ){
            last -= 7;
        }
        else{
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5;
pair<int, int> a[N];
int b[N];
bool used[N];

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

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i].second;
    }

    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
    }

    sort(a, a + n);

    for (int i = 0; i < n; i++) {
        b[i] = i;
    }

    sort(b, b + n, [](const int &x, const int &y) {
        return a[x].second < a[y].second;
    });

    for (int i = 0; i < n; i++) {
        if (a[b[i]].second > a[i].first) {
            cout << "No\n";
            return 0;
        }
    }

    int cyc_ct = 0;

    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            cyc_ct++;
            int x = i;
            while (!used[x]) {
                used[x] = true;
                x = b[x];
            }
        }
    }

    if (cyc_ct > 1) {
        cout << "Yes\n";
    }
    else {
        bool ok = false;
        for (int i = 0; i + 1 < n; i++) {
            if (a[b[i + 1]].second <= a[i].first) {
                ok = true;
                break;
            }
        }
        if (ok) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
    }

    return 0;
}

Measured memory_bytes: 1536
from itertools import*
s=input()


x=[len(list(v)) for k,v in groupby(s)]

n=len(x)

ans=0
if s[0]==">":
    ans+=(x[0]+1)*x[0]//2
    n-=1
    del x[0]
if s[-1]=="<":
    ans+=(x[-1]+1)*x[-1]//2
    n-=1
for i in range(0,n,2):
    ma=max(x[i],x[i+1])
    mi=min(x[i],x[i+1])
    ans+=ma*(ma+1)//2
    ans+=(mi-1)*mi//2
print(ans)

Measured memory_bytes: 8352
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    int diff = b - a;
    for(int i = 0; i <= n-1; i++){
        int min = c * i - d * (n - 1 - i);
        int max = d * i - c * (n - 1 - i);

        if(min <= diff && diff <= max){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define poq pop_back
#define tof ios_base :: sync_with_stdio(NULL);cin.tie(0);cout.tie(0)




using namespace std;


ll y[110000];


int main()
{
    ll n,m,a,b;
    cin>>n>>m;
    for (ll i=0;i<m;i++)
    {
          cin>>a>>b;
          y[a]++;
          y[b]++;
    }
    for (ll i=1;i<=n;i++)
    {
          if (y[i]&1)
          {
                cout<<"NO";
                return 0;
          }
    }
    cout<<"YES";


}


Measured memory_bytes: 1024
N = int(input())
S = input()

# 1を満たす数
# 1,~2を満たす数を求める

# def checkone(a,b,c):
# 	if (a!=b and b!=c and c!=a):
# 		return True
# 	else:
# 		return False

def check(i,j,N): # i,j,2j-iは違ったらTrue
	# i < jは保証
				# (0 > (2*i-j) or (2*i-j) >= N or checkone(S[i], S[j], S[2*i-j])) and
              	# (0 > (2*j-i) or (2*j-i) >= N or checkone(S[i], S[j], S[2*j-i])) #and
			  	# ( ((i+j)%2!=0) or checkone(S[i], S[j], S[abs(int((i+j)/2))]))
	if (0 > (2*j-i) or (2*j-i) >= N):
		# print("out of range")
		return False
	else:
		return (S[j] != S[2*j-i] and S[2*j-i] != S[i])
		# return checkone(S[i], S[j], S[2*j-i])
# 2j-i <N
# j < (N+i)/2

n_equal = 0
for i in range(N):
	for j in range(i+1, int((N+i)/2)+1):
		if( S[i]==S[j]):
			continue
		else:
			if(check(i,j,N)==True):
				n_equal+=1
				# print(i, j, 2*j-i)
				# print(S[i],S[j],S[2*j-i])
				# print("toukankaku")

# print("n_equal=",n_equal)

n_R = S.count('R')
n_G = S.count('G')
n_B = S.count('B')

n_all = n_R*n_G*n_B
# print("n_all=",n_all)

print(n_all-n_equal)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	int re=0;
	re+=n/(a+b)*(a);
	re+=min(n%(a+b),a);
	cout<<re<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001];
long long fun(int *a, int *b, int w, int i, int n)
{
    //cout<<a[i]<<" "<<w<<"\n";
    if(i==n)
    {
        return 0;
    }
    if(dp[i][w]!=-1)
    {
        return dp[i][w];
    }
    if(a[i]<=w)
    {
        long long k1=fun(a, b, w, i+1, n);
        long long k2=(long long)b[i]+fun(a, b, (w-a[i]), i+1, n);
        dp[i][w]=max(k1, k2);
    }
    else
    {
        dp[i][w]=fun(a, b, w, i+1, n);
    }
    //cout<<i<<" "<<dp[i]<<endl;
    return dp[i][w];
}
int main()
{
    int n, w;
    cin>>n>>w;
    int a[n], b[n];
    memset(dp, -1, sizeof(dp));
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    cout<<fun(a, b, w, 0, n)<<endl;
    return 0;

}



Measured memory_bytes: 79232
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
int main(){
  int r;cin>>r;
  cout<<r*r;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define pb push_back
#define endl "\n" // TODO: remove
#define int long long

const int N = (int)(1e6) + 322;
const long long inf = (long long)(2e18) + 322;
const int mod = (int)(1e9) + 7; // check modulo


void solve() {
    int x; cin >> x;
    if (x >= 30) cout << "Yes";
    else cout << "No";

}

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

    int test = 1;// cin >> test;
    for(int t = 1; t <= test; ++t) {
        solve();
    }
    return 0;
}



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

bool solve();

int main()
{
	if (solve()) puts("Yes");
	else puts("No");

	return 0;
}

bool solve()
{
	int N;
	std::string S;
	std::cin >> N >> S;
	if (N % 2 == 1) return false;
	for (int i{}; i < N / 2; i++)
		if (S[i] != S[i + N / 2])
			return false;
	return true;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
from copy import deepcopy

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

pairs = [0] * M
for i in range(M):
    pairs[i] = list(map(int, input().split()))


# N = 5
# pairs = [[1,2], [3,4], [5,1]]


class UnionFind:
    def __init__(self, N):
        self.r = [-1] * N

    def root(self, x):
        if self.r[x] < 0:
            return x
        self.r[x] = self.root(self.r[x])
        return self.r[x]


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.r[x] > self.r[y]:
            x, y = y, x

        self.r[x] += self.r[y]
        self.r[y] = x
        return True

    def size(self, x):
        return -self.r[self.root(x)]

uf = UnionFind(N)
for pair in pairs:
    a = pair[0] - 1
    b = pair[1] - 1
    uf.unite(a, b)

ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)


Measured memory_bytes: 50156
#include<stdio.h>
long long num=1,sum=0,H;
int main()
{
    scanf("%lld",&H);
    while(H>1e-10)
    {
        H=H/2;
        sum+=num;
        num*=2;
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  printf("%s\n", (abs(a - c) <= d || ((abs(a - b) <= d) && (abs(b - c) <= d))) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int h1 = Integer.parseInt(st.nextToken());
 		int m1 = Integer.parseInt(st.nextToken());
 		int h2 = Integer.parseInt(st.nextToken());
 		int m2 = Integer.parseInt(st.nextToken());
 		int k = Integer.parseInt(st.nextToken());
 		
 		int l = h2*60+m2-(h1*60+m1);
 		out.println(l-k);
 		out.close();
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25380
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int gcd(int a, int b) {
    if(a < b) return gcd(b, a);
    else if(b == 0) return a;
    else return gcd(b, a % b);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << A * B / gcd(A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-15
#define maxn 100010
#define maxm 200010
#define mod 1000000007
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{
    int a=read(),b=read(),c=read();
    if(a==b&&(a!=c))  puts("Yes");
    else if(a==c&&(a!=b))  puts("Yes");
    else if(b==c&&(a!=b))  puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
S = input()
R=[]
G=[]
B=[]
ans=0
for i, s in enumerate(S):
    if s == "R":
        R.append(i)
    elif s == "G":
        G.append(i)
    else:
        B.append(i)
blen=len(B)
for ri in range(len(R)):
    for gi in range(len(G)):
        x, y = sorted([R[ri], G[gi]])
        ans+=blen
        bi = bisect.bisect_left(B,2*y-x)
        if bi < blen and B[bi] == 2*y-x:
            ans -= 1
        bi = bisect.bisect_left(B,(x+y)/2)
        if bi < blen and B[bi] == (x+y)/2:
            ans -= 1
        bi = bisect.bisect_left(B, 2 * x - y)
        if bi < blen and B[bi] == 2 * x - y:
            ans -= 1
print(ans)

        
        

        


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

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

		int n = scanner.nextInt();
		int[] S = new int[n];

		for (int i = 0; i < n; i ++) {
			S[i] = scanner.nextInt();
		}

		scanner.close();

		long count = mergeSort(S, 0, n);

		System.out.println(count);
	}

	public static long merge(int[] A, int left, int mid, int right) {
		long count = 0;

		int n1 = mid - left;
		int n2 = right - mid;

		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];

		System.arraycopy(A, left, L, 0, n1);
		L[n1] = Integer.MAX_VALUE;
		System.arraycopy(A, mid, R, 0, n2);
		R[n2] = Integer.MAX_VALUE;

		int i = 0;
		int j = 0;

		for (int k = left; k < right; k ++) {
			if (L[i] <= R[j]) {
				A[k] = L[i];
				i ++;
			} else {
				count += n1 - i;
				A[k] = R[j];
				j ++;
			}
		}

		return count;
	}

	public static long mergeSort(int[] A, int left, int right) {
		long count = 0;

		if (left + 1 < right) {
			int mid = (left + right) / 2;
			count += mergeSort(A, left, mid);
			count += mergeSort(A, mid, right);
			count += merge(A, left, mid, right);
		}

		return count;
	}
} 



Measured memory_bytes: 102188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int nn = n;
        if(nn % 10 == 0) {
            nn /= 2;
        }
        char[] ch = Integer.toString(nn).toCharArray();
        int ans = 0;
        for (int i = 0; i < ch.length; i++) {
            int tmp = Integer.parseInt(Character.toString(ch[i]));
            ans += tmp;
        }if(n % 10 == 0) {
            ans *= 2;
        }
        System.out.println(ans);
    }
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<"\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <vector>
using namespace std;
string x;
int h;
int main(){
	getline(cin, x);
	for(int i = 0; i < x.length(); i++){
		h = (int)x[i];
		if(h >= 97 && h <= 122){
			h = h - 32;
			cout << char(h);
		}
		else
			cout << x[i];
	}
	cout << "\n";
	return 0;
}

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

string s;
int n;

long long dfs(int i, long long sum, long long cnt, int right){
  if(i == n){
    if(right == 1) return sum;
    else return 0;
  }
  long long res = cnt*10+(s[i]-'0');
  return dfs(i+1, sum, res, 0) + dfs(i+1, sum+res, 0, 1);
}

void solve(){
  n = s.length();
  long long ans = dfs(0, 0, 0, 1);
  cout << ans << endl;
}

int main(){
  cin >> s;
  solve();
  return 0;
}

Measured memory_bytes: 256
import sys
def f(h,i,j,k):
 z=(j-h)*(y-k)-(k-i)*(x-j);return([-1,1][z>0],0)[z==0]
for e in sys.stdin:
 p,q,r,s,t,u,x,y=map(float,e.split())
 g=[p,q,r,s,t,u]
 print(['NO','YES'][f(*g[:4])==f(*g[2:6])==f(*g[4:],*g[:2])])


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int ans=0;
  repo(i,n){
    if(s[i]!=s[i-1]) ans++;
  }


  cout << ans << endl;
}

Measured memory_bytes: 512
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Cat Snuke and a Voyage
	var N, M int
	fmt.Scanf("%d %d", &N, &M)

	sc.Split(bufio.ScanWords)
	var a, b int
	c := make(map[int]int, M)
	d := make(map[int]int, M)

	for i := 0; i < M; i++ {
		a = nextInt()
		b = nextInt()
		if a == 1 {
			c[b]++
		} else if b == N {
			d[a]++
		}
	}

	var flag int = 0
	for i := 0; i < N; i++ {
		if c[i] > 0 && d[i] > 0 {
			flag = 1
			break
		}
	}
	if flag == 1 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 13808
#include<iostream>
#include<algorithm>
#include<cstring>
#include<stack>
using namespace std;
typedef long long ll;
#define N 200005
int a[N];
ll s=0;

int main(){
    int n,i,f=0,m;
    cin>>n;
    m=n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    s+=a[n];m-=2;
    for(i=n-1;i>=1;){
        if(m<=0)
            break;
        s+=a[i];
        m--;
        f++;
        if(f==2){
            i--;
            f=0;
        }
    }
    cout<<s;
    
    return 0;
}


Measured memory_bytes: 4420
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <string> VS;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PIL> VPIL;


#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sort(c) sort((c).begin(),(c).end())

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

#define MAX_INT 2147483647

int main(){
	int n, r, p, c;
	VI deck, tmp_deck;
	while (1){
		cin >> n >> r;  
		if (!(n and r)) break;
		deck.resize(n);
		rep(i,n) deck[i] = n - i;
		rep(i,r){
			cin >> p >> c;
			tmp_deck.resize(p-1);
			rep(j,p-1) tmp_deck[j] = deck[j];
			rep(j,c) deck[j] = deck[j+p-1];
			rep(j,p-1) deck[j+c] = tmp_deck[j];
		}
		cout << deck[0] << endl;
	}
	return 0;
}

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

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }

using P = pair<int, int>;

const int MAX_N = 1e5+5;
const int INF = 1001001001;

vector<int> a, ans;
int dp[MAX_N][3];

ll modnum = 1e9+7;


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

    vector<vector<int>> dp(n, vector<int>(n,0));
    for(int i=n-1; i >= 0; i--) for(int j=n-1; j >= 0; j--) {
        if(s[i] == s[j]) {
            dp[i][j] += 1;
            if(i < n-1 && j < n-1) {
                dp[i][j] += dp[i+1][j+1];
            }
        } else {
            dp[i][j] = 0;
        }
    }

    int ans = 0;
    rep(i, n) rep(j, n) {
        if(i >= j) continue;
        int now = min(dp[i][j], (int)(j-i));
        ans = max(ans, now);
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 98176