akhauriyash/Code-Regression huggingface dataset:
s=list(input())

a_cnt=s.count("a")
b_cnt=s.count("b")
c_cnt=s.count("c")
cnt=[a_cnt,b_cnt,c_cnt]
cnt.sort()

patarn= len(s)%3

if patarn==0:
    if a_cnt==b_cnt and b_cnt==c_cnt:
        print("YES")
    else:
        print("NO")
elif patarn==1:
    if cnt[0]==len(s)//3 and cnt[1]==len(s)//3 and cnt[2]==len(s)//3+1:
        print("YES")
    else:
        print("NO")
else:
    if cnt[0]==len(s)//3 and cnt[1]==len(s)//3+1 and cnt[2]==len(s)//3+1:
        print("YES")
    else:
        print("NO")

        



Measured memory_bytes: 75400
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()
    n = len(S)
    if n % 2 == 0:
        l, r = n // 2, n // 2 - 1
        ans = n // 2
    else:
        l, r = n // 2, n // 2
        ans = n // 2 + 1

    while 0 < l and r < n - 1:
        l -= 1
        r += 1
        if S[l] != S[l + 1] or S[r] != S[r - 1]:
            break
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;main(){long long n ,m; cin >> n >> m;if(n == 1)return cout << (m == 1 ? 1 : m - 2) << '\n' ,0;else if(m == 1)return cout << n - 2 << '\n' ,0;return cout << (n-2)*(m-2) << '\n' ,0;}


Measured memory_bytes: 256
N, X = list(map(int, input().split()))
Y = list(map(int, input().split()))
Y.sort()


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


res = abs(X - Y[0])
for i in range(N - 1):
    res = gcd(res, Y[i + 1] - Y[i])
print(res)


Measured memory_bytes: 19944
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int dp[1001][1001];

signed main(){
    int h,w;
    string a[1000];
    cin>>h>>w;
    for(int i=0;i<h;i++)
        cin>>a[i];
    a[0][0]='#';
    dp[1][1]=1;
    for(int i=1;i<=h;i++)
        for(int j=1;j<=w;j++)
            if(a[i-1][j-1]=='.')
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    cout<<dp[h][w]<<endl;
}


Measured memory_bytes: 9088
use std::cmp::max;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut cur = 1;
    let mut ans = 1;
    for i in 1..n {
        if a[i - 1] < a[i] {
            cur = 1;
        } else {
            cur += 1;
        }
        ans = max(ans, cur);
    }
    println!("{}", ans - 1);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .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: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;
import java.util.Set;
import java.util.HashMap;
import java.util.Map;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer 降順ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        int [] c1 = inputval();
        int [] c2 = inputval();
        int [] c3 = inputval();
        int c1Sum = Arrays.stream(c1).sum();
        int c2Sum = Arrays.stream(c2).sum();
        int c3Sum = Arrays.stream(c3).sum();
        int b1row = c1[0] + c2[0] + c3[0];
        int b2row = c1[1] + c2[1] + c3[1];
        int b3row = c1[2] + c2[2] + c3[2];

        boolean isAcorrect = Math.abs(c2Sum-c1Sum) %3 == 0 && Math.abs(c3Sum-c1Sum) %3 == 0 && Math.abs(c3Sum-c2Sum) %3 == 0;
        boolean isBcorrect = Math.abs(b2row-b1row) %3 == 0 && Math.abs(b3row-b1row) %3 == 0 && Math.abs(b3row-b2row) %3 == 0;
        if (isAcorrect && isBcorrect){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

    }

}



Measured memory_bytes: 34324
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int n = std.nextInt();
        int h = std.nextInt();
        int w = std.nextInt();
        System.out.println((n - h + 1) * (n - w + 1));
    }
}

Measured memory_bytes: 23252
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);

		Console.WriteLine(Answer(nums)?"First":"Second");
	}

  static bool Answer(long[] nums)
  {
    int n = nums.Length;
    int evenCount = 0;
    int oddNum = 0;
    long oddMemo = 0;
    for(int i = 0; i < n; i++)
    {
      if(nums[i] % 2 == 0) evenCount++;
      else
      {
        oddNum = i;
        oddMemo = nums[i];
      }
    }

    if(evenCount % 2 == 1) return true;
    else if(evenCount != n-1 || oddMemo == 1) return false;
    else
    {
      nums[oddNum] = oddMemo-1;
      long gcd = nums[0];
      for(int i = 1; i < n; i++)
      {
        gcd = Gcd(gcd,nums[i]);
      }
      
      for(int i = 0; i < n; i++)
      {
        nums[i] /= gcd;
      }
      return !Answer(nums);
    }
  }

  static long Gcd(long a, long b) 
      {//引数a,bの最大公約数を返す
           if (a < b)
               return Gcd(b, a);//入れ替え
           while (b != 0) 
           {
               long changeTo = a % b;
               a = b;
               b = changeTo;
           }
           return a;
       }
  
}

Measured memory_bytes: 22752
#include <bits/stdc++.h>
using namespace std;
int x[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        scanf("%d",x+i);
    sort(x,x+n);
    int ans=0;
    for(int i=0;i<n;i++){
        if(x[i]>x[0]){
            ans=(n-i)/(k-1)+((n-i)%(k-1)==0?0:1);
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
long long n, a[(1<<20)];
int main () {
    cin  >> n;
    for ( long long i = 0 ; i < n ; i ++ ) { cin >> a[i]; }
    sort( a, a+n );

    long long maxx = 0, minn = 0;
    long long ans = 0;
    if ( n%2 ) {

        minn = 0; maxx = 0;
        for ( long long i = 0 ; i < n/2 ; i ++ ) { minn += a[i]; }
        for ( long long i = n/2 ; i < n ; i ++ ) { maxx += a[i]; }

        //cout << "pos " << maxx*2 - minn*2 - a[n/2] - a[n/2+1] << "\n";
        ans = max( maxx*2 - minn*2 - a[n/2] - a[n/2+1], ans );

        minn = 0; maxx = 0;
        for ( long long i = 0 ; i <= n/2 ; i ++ ) { minn += a[i]; }
        for ( long long i = n/2+1 ; i < n ; i ++ ) { maxx += a[i]; }

        //cout << "pos " << maxx*2 - minn*2 + a[n/2] + a[n/2-1] << "\n";
        ans = max( maxx*2 - minn*2 + a[n/2] + a[n/2-1], ans );

    }else {
        for (long long i = 0 ; i < n/2 ; i ++ ) { minn += a[i]; }
        for (long long i = n/2 ; i < n ; i ++ ) { maxx += a[i]; }

        //cout << "pos " << maxx*2 - minn*2 + a[n/2-1] - a[n/2]  << "\n";

        ans = max( maxx*2 - minn*2 + a[n/2-1] - a[n/2], ans );
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	mod = 1000003;
	fact f(2*mod+114,mod);
	int q; cin >> q;
	REP (i,q) {
		int x,d,n; cin >> x >> d >> n;
		if (d == 0) {
			cout << POW(x,n) << endl;
			continue;
		}
		if (n >= mod) {
			cout << 0 << endl;
			continue;
		}
		//fac[x/d+(n-1)] / fac[x/d-1] * d^n;
		int xd = x*POW(d,mod-2)%mod;
		int tmp = f.fac[xd+n-1] * f.inv[xd-1] % mod * POW(d,n) % mod;
		cout << tmp << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 32128
#include <cstdio>
#include <cmath>
#include <iostream>

#define ll long long
using namespace std;

const int MAXN = 3010;

int g[MAXN][MAXN],r,c,k;
ll f[MAXN][MAXN][4];

int main (){
    scanf("%d %d %d",&r,&c,&k);
    while(k--){
	int x,y,v;
	scanf("%d %d %d",&x,&y,&v);
	g[x][y] = v;
    }
    for(int i = 1;i <= r;i++)
	for(int j = 1;j <= c;j++){
	    f[i][j][0] = max(f[i-1][j][0],max(f[i-1][j][1],max(f[i-1][j][2],max(f[i-1][j][3],f[i][j-1][0]))));
	    f[i][j][1] = f[i][j-1][1];
	    f[i][j][2] = f[i][j-1][2];
	    f[i][j][3] = f[i][j-1][3];
	    if(g[i][j]){
//		f[i][j][0] += g[i][j];
		f[i][j][1] = max(f[i][j][1],f[i][j][0]+g[i][j]);
		f[i][j][2] = max(f[i][j][2],f[i][j-1][1] + g[i][j]);
		f[i][j][3] = max(f[i][j][3],f[i][j-1][2] + g[i][j]);
	    }
	}
    printf("%lld",max(f[r][c][0],max(f[r][c][1],max(f[r][c][2],f[r][c][3]))));
    return 0;
}


Measured memory_bytes: 321228
#include <stdio.h>
#include <string.h>

int main() {
	
	int a, b, strip=0;
	
	scanf("%d %d", &a, &b);
	
	
	char s[100];
	
	scanf("%s", &s);
	
	for(int i=0; i<=strlen(s); i++){
		if(s[i]=='-'){
			strip++;
		}
	}
	
	if(s[a]!='-'){
		printf("No");
		return 0;
	}
	
	
	else if(strip>>1){
		printf("No");
		return 0;
	}
	
	else if(strlen(s)!=a+b+1){
		printf("No");
		return 0;
	}
	
	else {
		printf("Yes");
		return 0;
	}
	
	return 0;
	
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll sum;
cin>>sum;
ll dp[2005];
memset(dp,0,sizeof(dp));
dp[0]=1;
dp[1]=0;
dp[2]=0;
for(int i=3;i<=sum;i++){
    for(int j=3;j<=i;j++)
        dp[i]=(dp[i]+dp[i-j])%mod;
}
cout<<dp[sum]<<endl;
}


Measured memory_bytes: 3664
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    char s;
    cin >> s;
    if (isupper(s)) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }
}


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

const int INF = 1e9;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    vector<vector<int>> A(h, vector<int>(w));
    rep(i,10)rep(j,10) cin >> c[i][j];
    rep(i,h) rep(j,w) cin >> A[i][j];
    //-1は無視
    //Floyd-Warshall
    rep(k,10) {
        rep(i,10) {
            rep(j,10) {
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    ll ans = 0;
    rep(i,h)rep(j,w){
        if(A[i][j]==-1) continue;
        ans+=c[A[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int dfs(long long n,int k){
    int c=0;
    while(n!=0){
        n/=k;
        c++;
    }return c;
}
int main() {
	int n;
	cin>>n;
int k;
cin>>k;
cout<<dfs(n,k);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>g[2222];
int dfs(int v,int f,int k)
{
	if(k==0)
	{
		return 0;
	}
	int ans=1;
	for(int i=0;i<g[v].size();i++)
	{
		if(g[v][i]!=f)
		{
			ans+=dfs(g[v][i],v,k-1);
		}
	}
	return ans;
}
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int bd=0,tl=1;
		for(int j=0;j<g[i].size();j++)
		{
			int t1=dfs(g[i][j],i,k/2),t2=dfs(g[i][j],i,(k+1)/2);
			tl+=t1;
			bd=max(bd,t2-t1);
		}
		ans=max(ans,tl+bd);
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 384
class Main
{
  public static void main(String[] args) {
    java.io.BufferedReader reader = null;
    try {
      reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
      String[] inputs = reader.readLine().split(" ");
      int a = Integer.parseInt(inputs[0]);
      int b = Integer.parseInt(inputs[1]);
      if (a < b) {
        System.out.println("a < b");
      } else if (a > b) {
        System.out.println("a > b");
      } else {
        System.out.println("a == b");
      }
    } catch (java.io.IOException e) {
     e.printStackTrace();
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (java.io.IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
}

Measured memory_bytes: 17036
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    C = [A[i] - B[i] for i in range(N)]
    sumA = sum(A)
    sumB = sum(B)
    addA, addB = 0, 0
    for i, c in enumerate(C):
        if c > 0: addB += c
        else: addA += (-1 * c + 1) // 2
    if addA > sumB - sumA or addB > sumB - sumA: print("No")
    else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 4596
import java.util.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        int count = 1;

        //AとBの最大公約数を求める
        long gcdAB = Main.gcd(A, B);

        //最大公約数を、「素数 or 1」になるまで素因数分解
        //新しい素数で割れた時にcountを増やす
        for(long i = 2 ; i <= Math.sqrt(gcdAB); i++){
            //自身の平方根より小さい数字で割り切れない場合、その数は素数である
            if(gcdAB % i == 0) count++;
            while(gcdAB % i == 0){
                gcdAB /= i;
            }
        }
        //gcdABが「素数 or 1」になっているので、素数の場合はcountを増やす
        if(gcdAB > 1) count++;

        System.out.println(count);

    }

    //gcd  = greateset common divisor
    public static long gcd(long A, long B){
        if(B == 0) return A;
        else return gcd(B, A % B);
    }




}







Measured memory_bytes: 23892
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a = 2;
    while ( n > 0 ) {
        int b = 1;
        if( a % 5 != 1 ) b = 0;
        for ( int i = 2 ; i * i <= a ; i++ ) {
            if ( a % i == 0 ) b = 0;
        }
        if ( b == 1 ) {
            n--;
            cout << a << ' ';
        }
        a++;
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include<bits/stdc++.h>
#define base 950527
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<P> res;
ll lh,ns,nt,LH,tmp=1,n,s[200005],t[200005],K[200005],S[200005],T[200005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>S[i];
    }
    for(int i=0;i<n;i++){
        cin>>T[i];
    }
    for(int i=0;i<n;i++){
        K[i]=S[i]^T[0];
    }
    for(int i=0;i<n;i++){
        s[i]=S[i]^S[(i+1)%n];
        t[i]=T[i]^T[(i+1)%n];
        //cout<<s[i]<<endl;
    }
    //cin>>s>>t;
    ns=n;
    nt=n;
    for(int i=0;i<nt;i++){
        lh=lh*base+(s[i]+'a');
        LH=LH*base+(t[i]+'a');
        tmp*=base;
    }
    if(lh==LH)res.push_back({0,K[0]});
    for(int i=0;i<ns-1;i++){
        lh=lh*base-tmp*(s[i]+'a');
        lh+=(s[i]+'a');
        //cout<<LH<<" "<<lh<<" "<<i<<endl;
        if(LH==lh)res.push_back({i+1,K[i+1]});
    }
    sort(res.begin(),res.end());
    for(auto x:res){
        cout<<x.first<<" "<<x.second<<endl;
    }
}


Measured memory_bytes: 14572
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

double deg_to_rad(double d) { return d * PI / 180.0; }

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double kakudo_jishin = 360.0 / 12 * h + 30 * m / 60;
    double kakudo_hunshin = 360 / 60 * m;
    double deg = kakudo_jishin - kakudo_hunshin;
    if (deg < 0) deg += 360;
    if (180 < deg) deg = 360 - deg;

    double rad = deg_to_rad(deg);
    double ans = sqrt(b * b + a * a - 2 * b * a * cos(rad));
    printf("%.15lf\n", ans);
}

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

signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  for(int i=0;i<N;i++){
    while(v[i]%2==0)ans++,v[i]/=2;
  }
  cout<<ans<<endl;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    string s, t;
    cin >> s >> t;

    vint index(t.size());
    vvint alpha(26);
    string ss = s + s;
    rep(i, ss.size())
    {
        alpha[ss[i] - 'a'].pb(i);
    }

    ll cnt = 0;
    ll tmp = -1;
    rep(i, t.size())
    {
        auto itr = upper_bound(ALL(alpha[t[i] - 'a']), tmp);
        if (itr == alpha[t[i] - 'a'].end())
        {
            M1;
            return;
        }

        tmp = *itr;
        if (tmp >= s.size())
        {
            ++cnt;
            tmp -= s.size();
        }
    }
    ll ans = cnt * s.size() + tmp + 1;
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2256
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

char s[105];
char t[105];

int s_hist[26];
int t_hist[26];

vector<pair<string,int> >vec;

int main(){

	scanf("%s",s);
	scanf("%s",t);

	int N=strlen(s);
	int M=strlen(t);

	int i,j;

	for(i=0;i<N;i++){
		s_hist[s[i]-'a']++;
	}
	for(i=0;i<M;i++){
		t_hist[t[i]-'a']++;
	}

	string str1="";
	string str2="";

	for(i=0;i<26;i++){
		for(j=0;j<s_hist[i];j++){
		str1+='a'+i;
		}
		for(j=0;j<t_hist[25-i];j++){
		str2+='a'+(25-i);
		}
	}

	if(str1==str2){
		printf("No\n");
		return 0;
	}

	vec.push_back(make_pair(str1,1));
	vec.push_back(make_pair(str2,2));

	sort(vec.begin(),vec.end());

	if(vec[0].second<vec[1].second){
	printf("Yes\n");
	}
	else{
	printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
string str;
int f(int k, string s) {
	if (k == str.size()) {
		if (s.size() % 2 == 1) {
			if (s[s.size() / 2] != 'i' && s[s.size() / 2] != 'w')return -1;
		}
		for (int i = 0; i < s.size() / 2; i++) {
			char a = s[i], b = s[s.size() - 1 - i];
			if (a == 'i'&&b != 'i')return -1;
			if (a == 'w'&&b != 'w')return -1;
			if (a == '('&&b != ')')return -1;
			if (a == ')'&&b != '(')return -1;
			if (a == '{'&&b != '}')return -1;
			if (a == '}'&&b != '{')return -1;
			if (a == '['&&b != ']')return -1;
			if (a == ']'&&b != '[')return -1;
		}
		return s.size();
	}
	if (str[k] == 'i' || str[k] == 'w')return f(k + 1, s + str[k]);
	else return max(f(k + 1, s), f(k + 1, s + str[k]));
}
signed main() {
	cin >> str;
	cout << f(0, "") << endl;
}


Measured memory_bytes: 3204
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define all(x) x.begin(),x.end()
ld pie=3.141592653589793238462643383279;
int mod=1e9+7;
int dx[]={-1,1,0,0};
int dy[]={0,0,1,-1};


int fact[2000005];
int infact[2000005];

int inv(int a){
  int y=mod-2;
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r;
}

int po(int a,int y){
  int r=1;
  while(y!=0){
    if(y&1){
      r*=a; r%=mod;
    }
    y/=2; a*=a; a%=mod;
  }
  return r; 
}

void facto(){
  fact[0]=1;
  f(i,1,2000005) {fact[i]=i*fact[i-1]; fact[i]%=mod;}
  f(i,0,2000005) infact[i]=inv(fact[i]); 
}

int nck (int n,int k){
  if(k<0 || k>n) return 0;
  int ret=fact[n]; ret*=infact[k]; ret%=mod;
  ret*=infact[n-k]; ret%=mod;
  return ret;
}

int n,m;

vector<int> adj[1000005];
bool vis[1000005];
bool vis2[1000005];
int ans[1000005];

bool poss=1;

int dfs(int c,int p){
  bool lp=1;
  int leaf=0;
  for(auto it : adj[c]){
    if(it!=p){
      lp=0;
      leaf+=dfs(it,c);
    }
  }
  if(lp) return 1;
  else{
    if(leaf<3) poss=0;
    return 0;
  }
  
}

void dfs2(int s,int val){
  if(vis2[s]) return ;
  vis2[s]=1; ans[s]=val;
  for(auto it : adj[s])
    dfs2(it,val);
}

int rev(int a){
  int r=0;
  while(a!=0){
    r+=a%10;
    r*=10;
    a/=10;
  }
  return r/10;
}
int32_t main(){ 

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int mx=0;
  int n,m,k; cin>>n>>m>>k;
  int a[n+1]={0};
  f(i,0,n) cin>>a[i+1];
  int b[m+1]={0};
  f(i,0,m) cin>>b[i+1];
  f(i,0,n) a[i+1]+=a[i];
  f(i,0,m) b[i+1]+=b[i];
  int low=0,high=n+1;
  while(low<=m && high>=0){
    int sp=a[high]+b[low];
    if(sp<=k){ mx=max(mx,low+high);
      ++low;
    }else --high;
  }
  cout<<mx;
  return 0;
}


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

vector<vector<int>> graph;

void DFS(int v, int parent_v, vector<int> &depth, vector<int> &parent){
    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        depth[child_v] = depth[v] + 1;
        parent[child_v] = v;
        DFS(child_v, v, depth, parent);
    }
}

int main(){
    int n, u, v;
    cin >> n >> u >> v;
    u -= 1;
    v -= 1;
    graph.resize(n);

    for(int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    vector<int> depth(n), parent(n);
    DFS(v, -1, depth, parent);

    int init = depth[u];
    int start = u;
    for(int i=0; i<(init-1)/2; i++){
        start = parent[start];
    }
    int dist = depth[start] - (init-1)/2;

    vector<int> depth2(n), parent2(n);
    DFS(start, parent[start], depth2, parent2);

    sort(depth2.begin(),depth2.end());
    reverse(depth2.begin(),depth2.end());

    cout << (init-1)/2 + (depth2[0] + dist - 1) << endl;
    return 0;
}

Measured memory_bytes: 13696
import sys

n, truck_num = map(int, input().split())
weights = [int(x) for x in map(int, sys.stdin)]


def main():
    # 最小値と最大値をもとに二分探索する
    print(binary_search(max(weights), sum(weights)))


def binary_search(left, right):
    """二分探索

    :param left: 最小値
    :param right: 最大値
    :return:
    """

    while left < right:
        # 真ん中の値を割り当てる
        middle = (left + right) // 2

        # 真ん中の値で一旦シミュレート
        if simulate(middle, weights, truck_num):
            # OKならば、最大値をシミュレートした値に
            right = middle
        else:
            # NGならば、最小値をシミュレートした+1に
            left = middle + 1

    return left


def simulate(mid, wei, t_num):
    """

    :param mid: 中央値
    :param wei: 荷物が格納されたリスト
    :param t_num: トラックの台数
    :return: シミュレートOKかNGか
    """
    count = 1
    tmp = 0
    for w in wei:
        tmp += w

        # 積載量(tmp)が求める答え(mid)より大きくなったら
        if mid < tmp:
            # tmpを次の積載物に初期化
            tmp = w
            count += 1
            if t_num < count:
                return False
    return True


if __name__ == '__main__':
    main()




Measured memory_bytes: 9588
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl
#define P pair<lint,lint>

int main() {
	lint N, A, B;
	cin >> N >> A >> B;
	vector<lint>X(N);
	rep(i, N) {
		cin >> X[i];
	}
	vector<lint>D;
	rep(i, N - 1) {
		D.push_back((X[i + 1] - X[i]) * A);
	}
	lint ans = 0;
	rep(i, N - 1) {
		ans += min(B, D[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

class CWhenIHitMyPocket {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll k,a,b;
	    in>>k>>a>>b;
	    ll ans=0;
	    if(k-1>=a && b>a){
	        ll ka=k-a+1;
	        ans=(ka/2)*(b-a);
	        ans+=a;
	        ka-=(ka/2)*2;
//	        out<<ka<<endl;
	        ans+=ka;
	    }
//	    out<<ans<<endl;
	    ans=max(ans,k+1);
	    out<<ans<<endl;

	}
};


int main() {
	CWhenIHitMyPocket solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize, A: usize, B: usize,
        X: [usize; N],
    }

    let mut ans = 0;

    for i in 0..N-1 {
        ans += min( A * (X[i+1] - X[i]),  B);
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
int nmax=200000; // 2*(10^5)
vvec g(nmax);



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k,c;
    cin>>n>>k>>c;
    string s;
    cin>>s;
    vec a(n);
    int cnt=1;
    rep(i,n){
        if(s[i]=='o'){
            a[i]=cnt;
            cnt++;
            i+=c;
            if(cnt==k+1) break;
        }
    }
    // rep(i,n) cout<<a[i]<<" "; cout<<endl;

    reverse(all(s));

    vec b(n);
    rep(i,n){
        if(s[i]=='o'){
            cnt--;
            b[i]=cnt;
            i+=c;
        }
    }

    reverse(all(b));
    // rep(i,n) cout<<b[i]<<" "; cout<<endl;

    rep(i,n){
        if(a[i]==b[i]&&a[i]!=0){
            cout<<i+1<<endl;
        }
    }
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);


main () {
    int n,m,a,b,ans=0,border=0;
    vector<pair<int,int>> v;
    cin >> n >> m;
    rep(i,m) cin >> a >> b,v.pb(make_pair(a,b));
    sort(all(v));
    border = v[0].se,v.pop_back();
    rep1(i,m-1) {
        if (v[i].fi>=border) ans++,border = v[i].se;
        border = min(border,v[i].se);
        v.pop_back();
    }
    ct(++ans)
}

Measured memory_bytes: 2420
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007
#define beg begin

int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	std::vector<int> p(n);
	for (int i = 0; i < n; ++i)	cin >> p.at(i);

	std::vector<int>::iterator iter = std::max_element(p.beg(), p.end());
	size_t index = std::distance(p.beg(), iter);
	p.at(index) /= 2;

	int sum = std::accumulate(p.beg(), p.end(), 0);
	OUT(sum) BR;
	RET;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }
  string str;
  for (int j = 0; j < W; j++) {
    str += ".";
  }
  int count = 0;
  for (int i = 0; i < a.size(); i++) {
    if (a.at(i) == str) {
      a.erase(a.begin() + i);
      i--;
      count++;
    }
  }
  int f = 1;
  for (int j = 0; j < a.at(0).size(); j++) {
    f = 1;
    for (int i = 0; i < H - count; i++) {
      if (a.at(i).at(j) == '#') {
        f = 0;
      }
    }
    if (f == 1) {
      for (int i = 0; i < H - count; i++) {
        a.at(i).erase(a.at(i).begin() + j);
      }
      j--;
    }
  }
  for (int i = 0; i < H - count; i++) {
    cout << a.at(i) << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if( a < 0 || a > 20) {
			System.err.println("a is not in [0,20]");
			System.exit(1);
		}
		int b = sc.nextInt();
		if( b < 0 || b > 20) {
			System.err.println("b is not in [0,20]");
			System.exit(1);
		}
		if( a <= 9 && b <= 9) {
			System.out.println( a * b );
		}
		else {
			System.out.println("-1");
		}
	}
}


Measured memory_bytes: 23636
//
//  main.cpp
//  Lucas Number
//
//  Created by wenhan on 2017/11/18.
//  Copyright © 2017年 wenhan. All rights reserved.
//

#include <iostream>
using namespace std;
int main() {
    
    int n;
    cin>>n;
    long long a=2,b=1,c;
    if(n==0)
        cout<<a<<endl;
    else if(n==1)
        cout<<b<<endl;
    else{
        for (int i=2; i<=n; i++) {
            c=a+b;
            a=b;
            b=c;
        }
        cout<<c<<endl;
    }
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    long long a, b;
    char s[6];
    scanf("%lld%s", &a, s);
    b = (s[0]-'0')*100 + (s[2]-'0')*10 + (s[3]-'0');
    printf("%lld\n", a*b/100);

    return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define map map<ll ,ll>
#define umap unordered_map<ll , ll>
#define endl "\n"
#define set set<ll> 
#define setC set<char>
#define all(x) x.begin() , x.end()
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)
#define ll long long int
const ll INF = 1e13+7;
const ll mod = 1e9+7;

vvi dp;

ll doSome(vvi &arr , int i , int j){
    int n = arr.size();
    int m = arr[0].size();

    if( i == n or j == m)
        return 0;
    
    if(dp[i][j] != -1){
        return dp[i][j];
    }
    if( i == n-1 and j == m-1){
        return dp[i][j] = 1;
    }

    ll res = 0;
    if(i+1 < n && arr[i+1][j] == 0 ){
        res =  (res + doSome(arr , i+1 , j))%mod;
    }
    if(j+1 < m and arr[i][j+1] == 0){
        res = (res + doSome(arr , i , j+1))%mod;
    }
    return dp[i][j] = res;
}

void solv(){
    ll n , m ;
    cin >> n >> m ;

    vvi arr(n+1 , vi(m+1 , 0));

    FOR(i , 1 , n){
        FOR(j , 1 , m){
            char c ;
            cin >> c;
            if(c == '#')
                arr[i][j] = 1;
        }
    }

    // assign dp
    dp.assign(n+1 , vi(m+1 , -1));

    ll  ans = doSome(arr , 1 , 1);
    cout << ans << endl;
}

int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}




Measured memory_bytes: 11232
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=500005;
char ch[MAXN];
int n,a[MAXN],b[MAXN],sta[MAXN],tp;
int main()
{
//	freopen("a.in","r",stdin);
	scanf("%s",ch+1);int len=strlen(ch+1);
	for(int i=1;i<=len;i++)a[i]=ch[i]-'0';
	for(int i=1;i<=len;i++)b[i]=a[i]-a[i-1];
	for(int i=len;i>1;i--)
	{
		if(a[i]<a[i-1])
		{
			a[i-1]--;b[i-1]--;
			a[i]+=10;b[i]+=11;
			if(!tp)
			{
				if(i!=len)b[i]--,b[len]++;
				if(b[len]>=10)sta[++tp]=len;
			}
			else
			{
				int u=sta[tp--];b[u]-=10;b[u-1]++;
				b[i]--;
				if(b[u-1]>=10)sta[++tp]=u-1;
			}
//			int u=i;
//			while(a[u]>a[u+1]&&u<len)a[u]--,a[u+1]+=10,++u;
//			n=a[len];
		}
	}
	for(int i=1;i<=len;i++)n+=b[i];	
	pr2((int)ceil((double)n/9));
	return 0;
}


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

string s;

int main(){
    cin>>s;
    string week[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i=0;i<7;i++){
        if(s==week[i]){cout<<7-i<<endl;break;}
    }
}

Measured memory_bytes: 256
# Solved by QBnewb
# Discretization
# off-line

q = int(input())
s = []
rs = [] # for discretization

# download the input
for i in range(q):
    s.append(list(map(int, input().split())))
    if s[i][0] == 3:
        rs.append(s[i][1])
        rs.append(s[i][2])
    else:
        rs.append(s[i][1])

rs.append(10**9 + 1)
rs = sorted(list(set(rs)))
index = {rs[i]:i for i in range(len(rs))} # discretization
counter = [0 for i in range(len(rs) + 1)] # count the number of every element in set
cnt = 0
for i in range(q):
    op, x = s[i][0], s[i][1]
    idx = index[x]
    if op == 0:
        cnt += 1
        counter[idx] += 1
        print(cnt)
    elif op == 1:
        print(counter[idx])
    elif op == 2:
        cnt -= counter[idx]
        counter[idx] = 0
    else:
        l = idx
        r = index[s[i][2]]
        for j in range(l, r+1):
            for k in range(counter[j]):
                print(rs[j])


Measured memory_bytes: 61784
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    str s_, t;
    std::cin >> s_ >> t;

    auto func = [](str s, str t, ll n) -> bool {
        for (ll i = 0; i < n; i++)
            if (s[i] != '?' && s[i] != t[i])
                return false;

        return true;
    };

    for (ll i = s_.length() - t.length(); i >= 0; i--)
        if (func(s_.substr(i, t.length()), t, t.length())) {
            for (ll j = 0; j < s_.length();)
                if (j == i) {
                    std::cout << t;
                    j += t.length();
                }
                else
                    std::cout << (s_[j] == '?' ? 'a' : s_[j]), j++;
            std::cout << '\n';
            return;
        }

    std::cout << "UNRESTORABLE" << '\n';
}


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

int main() {
    int N;
    int x[10], y[10];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];

    double di = 0;
    double sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int dx = x[i] - x[j];
            int dy = y[i] - y[j];
            di = sqrt(dx * dx + dy * dy);
            sum += di;
        }
    }
    sum *= 2;
    sum /= N;

    cout << fixed << setprecision(10) << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;

int _;

//========================================================================
ll pr[maxn];
void init()
{
  pr[0]=1;
  for(int i=1;i<=maxn;i++)
    {
        pr[i]=pr[i-1]*i%mod;
    }
}
ll fpow(ll a,ll b)
{
    a%=mod;
    ll ans=1;
    while(b)
    {
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans%mod;
}
ll c(ll a,ll b)
{
    if (a < b || a < 0 || b < 0) return 0;
    return pr[a]*fpow(pr[b]*pr[a-b]%mod,mod-2)%mod;
}
//========================================================================
int main()
{
    init();
    int n,m,k,ans=0;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=0;i<=k;i++)
    {
        ans=(ans+(m*c(n-1,i)%mod)*fpow(m-1,n-1-i)%mod)%mod;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 5360