akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cerr << #x << " " << x << endl;
#define debl(x) std::cerr << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
//const ll LINF = 1001002003004005006ll;
//const int INF = 1001001001;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
constexpr int MOD = 1e9 + 7;
constexpr int mxN = 1000;
ll dp[mxN][mxN];
void solve(){
    int h, w;
    read(h,w);
    vector<vector<bool>> passable(h, vector<bool>(w, true));
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < w ;j++){
            char c;
            read(c);
            if( c == '#'){
                passable[i][j] = false;
            }
        }
    }
    dp[0][0] = 1;
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < w ; j++){
            if( i == 0 && j == 0){
                continue;
            }else if ( i == 0){
                if( passable[i][j] == false){
                    dp[i][j] = 0;
                }else{
                    dp[i][j] = dp[i][j-1];
                }
            }else if ( j == 0){
                if(passable[i][j] == false){
                    dp[i][j] = 0;
                }else{
                    dp[i][j] = dp[i-1][j];
                }
            }else{
                if( passable[i][j] == false){
                    dp[i][j] = 0;
                }else{
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];
                    if( dp[i][j] > MOD){
                        dp[i][j] = (dp[i][j] % MOD);
                    }
                }
            }
        }
    }
    cout << dp[h-1][w-1] << endl;

}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 11628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = input()
for i in range(3):
	if n[i] == '1':
		print(9, end = "")
	else:
		print(1, end = "")
print()

Measured memory_bytes: 5328
N,K=map(int,input().split())
D=[]
A=[]
S=set()
for i in range(K):
  D.append(int(input()))
  A.append(list(map(int,input().split())))
for i in range(len(A)):
  for j in range(len(A[i])):
    S.add(A[i][j])
ans=N-len(S)
print(ans)

Measured memory_bytes: 9156
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
#include<cctype>
const int INF=1e9;
using namespace std;

int main(){
    int a, b, c;
    cin>>a>>b>>c;
    cout<<(a+b+c)-max(max(a,b),c)<<endl;
}


Measured memory_bytes: 256
import numpy as np

MOD=998244353
N=int(input())
A=np.array([int(input()) for _ in range(N)])

TOTAL=pow(3,N,MOD)
ASum=np.sum(A)

# dp=[[0 for _ in range(ASum+1)] for _ in range(2)]
dp=np.zeros((2,ASum+1),dtype=np.int64)
dp[0][0] = 2
dp[0][A[0]] = 1

# dpOther=[[0 for _ in range(ASum+1)] for _ in range(2)]
dpOther=np.zeros((2,ASum+1),dtype=np.int64)
dpOther[0][0] = 1
dpOther[0][A[0]] = 1

prev=0
current=1
curMax=A[0]
# for n in range(1,N):
for n, a in enumerate(A):
	if n==0:
		continue
	# curMax += a
	current = n % 2
	prev = (n+1) % 2
	# for e in range(curMax+1):
	dp[current,:] = dp[prev,:]*2 % MOD
	dp[current,a:] += dp[prev,:-a]

	if ASum %2 == 0:
		dpOther[current,:] = dpOther[prev,:] % MOD
		dpOther[current,a:] += dpOther[prev,:-a]

sumStart = 0
plus = 0

if ASum % 2 == 0:
	# 合計が偶数
	sumStart=ASum//2
	plus = (dpOther[current][ASum//2]*3) % MOD
else:
	# 合計が奇数の場合、ceil
	sumStart=ASum//2+1

exceptCnt=0
for s in range(sumStart,ASum+1):
	exceptCnt = (exceptCnt + dp[current][s]*3) % MOD

exceptCnt -= plus

print((TOTAL - exceptCnt) % MOD )



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

#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string o, e;
	cin >> o >> e;
	for (int i = 0; i < o.size(); i++){
		if (i == o.size()-1 && o.size()>e.size()){
			cout << o[i];
		}
		else { cout << o[i] << e[i]; }
	} cout << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int n, x[100], y[100], i, t;
    double d1=0, d2=0, d3=0, di=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d",&x[i]);
    }
    for(i=0; i<n; i++){
        scanf("%d",&y[i]);
    }
    for(i=0; i<n; i++){
        t = x[i] - y[i];
        if(t<0)
            t = -t;
            d1 += t;
            d2 += t*t;
            d3 += t*t*t;
          if(di<t)
           di=t;
    }
    d2 = pow(d2,1./2);
    d3 = pow(d3,1./3);
    printf("%f %f %f %f",d1,d2,d3,di);
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
  int N, M;
  int X, Y;
  cin >> N >> M;
  cin >> X >> Y;
  vector<int> XP(N);
  vector<int> YP(M);
  REP(i, N) {
    cin >> XP[i];
  }
  REP(i, M) {
    cin >> YP[i];
  }
  for (int i = -99; i < Y; i++) {
    bool ok = true;
    if (i <= X || i > Y) {
      continue;
    }
    REP(j, N) {
      if (i <= XP[j]) {
        ok = false;
        break;
      }
    }
    REP(j, M) {
      if (i > YP[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  
  return 0;
}

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

int main() {
    char ch[1000];

    while(1){
        scanf("%s", ch);
        if (strcmp(ch, "0") == 0) break;

        int sum = 0;
        for (int i = 0; i < 1000; i++) {
            if (ch[i] == '\0') break;
            sum += ch[i] - '0';
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 1156
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

ll gcd(ll a,ll b){if(!b)return abs(a);return (a%b==0)?abs(b):gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  startupcpp();
  int i,j,N;
  cin>>N;
  pvec v(3),rv(3);
  rep(i,3){
    cin>>v[i].first;
    rv[i].second=v[i].first;
  }
  rep(i,3){
    cin>>v[i].second;
    rv[i].first=v[i].second;
  }
  vec dp(N+1);
  rep(i,N+1)dp[i]=i;
  rep(i,3)For(j,v[i].first,N+1){
    chmax(dp[j],dp[j-v[i].first]+v[i].second);
  }
  N=dp[N];
  dp.resize(N+1);
  rep(i,N+1)dp[i]=i;
  rep(i,3)For(j,rv[i].first,N+1){
    chmax(dp[j],dp[j-rv[i].first]+rv[i].second);
  }
  print(dp[N]);
}

Measured memory_bytes: 195584
def main():
    n = int(input())
    ab = []
    for _ in range(n):
        ab.append(tuple(map(int, input().split())))
    sorted_ab = sorted(ab, key=lambda x: x[1])
    now = 0
    for a, b in sorted_ab:
        now += a
        if now > b:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 83032
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool visted[55][55];
int n, m;
vector<string> vec;
int index(int x, int y){
	return x * m + y;
}
int main(){
	cin>>n>>m;
	vec.resize(n);
	for(int i = 0; i < n; ++i){
		cin>>vec[i];
	}
	vector<vector<int> > v(n * m + 1);
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			if(vec[i][j] == '#')continue;
			for(int k = 0; k < 4; ++k){
				int x = i + dx[k];
				int y = j + dy[k];
				if(x >= 0 && x < n && y >= 0 && y < m){
					if(vec[x][y] == '.'){
						v[index(i, j)].push_back(index(x, y));
					}
				}
			}
		}
	}
	map<int,int> dist;
	dist[0] = 0;
	queue<int> q;
	q.push(0);
	int res = index(n - 1, m - 1);
	bool ok = false;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = 0; i < v[u].size(); ++i){
			int vp = v[u][i];
			if(dist.find(vp) == dist.end()){
				dist[vp] = dist[u] + 1;
				q.push(vp);
				if(vp == res){
					ok = true;
					break;
				}
			}
		}
	}
	if(!ok){
		cout<<"-1"<<endl;
		return 0;
	}
	int x = dist[res];
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			if(vec[i][j] == '#')ans++;
		}
	}
	cout<<n * m - 1 - dist[res] - ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn calc(b: &[i64]) -> i64 {
    let n = b.len();
    let mut odd = 0;
    for i in 0..n {
        // Is C(n - 1, i) odd?
        if (i & (n - 1)) == i {
            odd ^= b[i] % 2;
        }
    }
    odd
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        a: chars,
    }
    let mut b = vec![0; n - 1];
    for i in 0..n - 1 {
        b[i] = (a[i] as u8 as i64 - a[i + 1] as u8 as i64).abs();
    }
    // b has only 0, 1 and 2.
    let odd = calc(&b);
    if odd == 1 {
        puts!("1\n");
        return;
    }
    // 0 or 2
    if b.iter().any(|&x| x % 2 == 1) {
        puts!("0\n");
        return;
    }
    let c: Vec<i64> = b.into_iter().map(|x| x / 2).collect();
    puts!("{}\n", calc(&c) * 2);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 28916
import numpy,math

a,b,h,m = map(lambda x: int(x) ,input().split(" "))

minutes = 60 * h + m

thetal = m * 6
thetas = minutes * 0.5

theta = float(abs(thetal - thetas))
if(theta > 180):
    theta = 360 - theta

dist = math.sqrt(a **2 + b **2 -2 * a * b * math.cos(math.radians(theta)))

print(dist)

Measured memory_bytes: 27204
#include <bits/stdc++.h>
using namespace std;
int main() { 
     string S;
     string T;
     cin >> S;
     cin >> T;
     int ans = 0;
     for(int i=0;i<S.length();i+=1){
          if(S[i]!=T[i]){
               ans+=1;
          }
     }
     cout << ans;
}


Measured memory_bytes: 3916
N = int(input())
A = list(map(int,input().split()))

answer = 0
a = True

while a:
	count = 0
	for i in range(N):
		if A[i] % 2 == 0:
			A[i] /= 2
			count += 1
	if count == N:
		answer += 1
	else:
		a = False
		break

print(answer)

Measured memory_bytes: 3060
def c():
    sx, sy, tx, ty = map(int, input().split())
    dx = tx - sx
    dy = ty - sy

    # Path 1
    print("U" * dy + "R" * dx, end='')

    # Path 2
    print("D" * dy + "L" * dx, end='')

    # Path 3
    print("D" + "R" * (dx+1) + "U" * (dy+1) + "L", end='')

    # Path 4
    print("U" + "L" * (dx+1) + "D" * (dy+1) + "R", end='')


if __name__ == '__main__':
    c()


Measured memory_bytes: 38384
from collections import Counter
N=int(input())
S=input()
C=Counter(S)
nr=C["R"]
ng=C["G"]
nb=C["B"]
ans=nr*ng*nb
for i in range(N-2):
    for j in range(i+1,N-1):
        k=j+j-i
        if k<N:
            if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                ans-=1

print(ans)

Measured memory_bytes: 9372
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(reader.readLine());
			v[i] = Integer.parseInt(st.nextToken());
			w[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		System.out.println(knapsack(n, W, v, w));
	}
	private int knapsack(int n, int W, int[] v, int[] w) {
		int[][] dp = new int[n+1][W+1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= W; j++) {
				if (j < w[i]) {
					dp[i+1][j] = dp[i][j];
				} else {
					dp[i+1][j] = Math.max(dp[i][j], Math.max(dp[i][j-w[i]] + v[i], dp[i+1][j-w[i]] + v[i]));
				}
			}
		}
		return dp[n][W];
	}
}



Measured memory_bytes: 29188
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
vector<int> g[114514];
bool used[114514];
int main() {
	IOS;
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> s(n + 1), t(n + 1);
	s[0] = t[0] = 0;
	REP(i, n) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
		t[i + 1] = t[i] + max((ll)0, a[i]);
	}
	ll ans = 0;
	REP(i, n - k + 1) {
		ll tmp = 0;
		tmp = max(s[i + k] - s[i], (ll)0) + t[i] - t[0] + t[n] - t[i + k];
		ans = max(tmp, ans);
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 5248
def solve(A,N):
    A.sort(reverse = True)
    ans = A[0]
    if N % 2 == 0:
        pt = N // 2 - 1
        for i in range(1,pt+1):
            ans += (2 * A[i])
    else:
        pt = (N-1) // 2
        for i in range(1,pt):
            ans += (2 * A[i])
        ans += A[pt]
    return ans

def main():
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A,N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 31436
#include <iostream>

const int MAXN = 100 + 5,MAXK = static_cast<const int>(1e5 + 5);

using namespace std;

int n,k,v[MAXN],dp[MAXN][MAXK],mars[MAXK];
const int MOD = static_cast<const int>(1e9 + 7);

void doMod (int &x) {
    if (x >= MOD) x-= MOD;
    if (x < 0) x += MOD;
}

int main()
{
    cin>>n>>k;
    for(int i = 1; i <= n; i++)
        cin>>v[i];
    for(int j = 0; j <= v[1]; j++)
        dp[1][j] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 0; j <= k; j++)
            mars[j] = 0;
        for(int j = 0; j <= k; j++){
            mars[j] += dp[i - 1][j];
            doMod(mars[j]);
            if (j + v[i] + 1 <= k) {
                mars[j + v[i] + 1] -= dp[i - 1][j];
                doMod(mars[j + v[i] +1]);
            }
        }
        for(int j = 0; j <= k; j++)
            mars[j] += mars[j - 1], doMod(mars[j]);
        for(int j = 0; j <= k; j++)
            dp[i][j] = mars[j];
    }
    cout<<dp[n][k];
    return 0;
}

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

using Lint=long long;

int main()
{
   int N; cin>>N;
   vector<int> P(N),Q(N);
   for(int i=0;i<N;i++) cin>>P[i];
   for(int i=0;i<N;i++) cin>>Q[i];

   vector<int> A(N);
   for(int i=0;i<N;i++) A[i]=i+1;

   int cnt=0,a,b;
   do{
      if(P==A) a=cnt;
      if(Q==A) b=cnt;
      cnt++;
   }while(next_permutation(A.begin(),A.end()));
   // cout<<a<<' '<<b<<endl;
   cout<<abs(a-b)<<endl;
   return 0;
}


Measured memory_bytes: 256
n = input()
s = list(n)
s[-1] = int(s[-1])
if s[-1] == 2 or s[-1] == 4 or s[-1] == 5 or s[-1] == 7 or s[-1] == 9:
    print('hon')
elif s[-1] == 3:
    print('bon')
else:
    print('pon')

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	vector <int> A(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>A[i];
	}
	long long int l = 2,r = 2;
	for (int i = n - 1; i >= 0; --i)
	{
		l = ((l + A[i] - 1)/A[i])*A[i];
		r = ((r/A[i])*A[i]) + (A[i] - 1);
		if(l > r)
		{
			cout<<"-1\n";
			return 0;
		}
	}
	cout<<l<<" "<<r<<"\n";
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
int a[maxn];
map<int, bool> vis;
int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    n = readint();
    int isok=1;
    repd(i, 1, n)
    {
        a[i] = readint();
        if (vis.count(a[i]))
        {
            isok = 0;
        }
        vis[a[i]] = 1;
    }
    if (isok)
    {
        printf("YES\n");
    } else
    {
        printf("NO\n");
    }

    return 0;
}




Measured memory_bytes: 10368
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to,cap,rev; 
	edge (int from, int to, int cap, int rev){
		this->from=from; this->to=to; this->cap=cap; this->rev=rev;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

string ban[60], pat[60];
int n, m;

bool match(int x, int y) {
	FORI(0, m) {
		FORJ(0, m) {
			if (ban[x + i][y + j] != pat[i][j])
				return false;
		}
	}
	return true;
}

int main(){

	cin >> n >> m;
	FORI(0, n)cin >> ban[i];
	FORI(0, m)cin >> pat[i];
	bool flg = false;
	FORI(0, n - m + 1) {
		FORJ(0, n - m + 1) {
			
			if (match(i, j)){
				flg = true;
			}
				
		}
	}
	cout << (flg ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n, k, s = MI()
    if s == 10 ** 9:
        ans = [s] * k + [1] * (n - k)
    else:
        ans = [s] * k + [s + 1] * (n - k)
    print(*ans)

main()


Measured memory_bytes: 6524
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <cstdio>
using namespace std;

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using vvvll = V<V<V<ll>>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vvpll = V<vpll>;
using vtpll = V<tpll>;
using vst = V<str>;
using vch = V<char>;
using vvch = V<vch>;
using qll = queue<ll>;
using vqll = V<qll>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin() 
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a) //
/*vvll v(n,vll(m)) n行m列  continue
A.erase(A.begin()+i); 配列Aのi番目を消せる
std::binary_search(v.bgn,v.en,a); 二分探索
abs(a,b)   pow(a,n)  to_string  stoll
auto Iter=lower_bound(v.bgn,v.en,a); v[i]>=aのv[i]
v.insert(lower_bound(v.bgn,v.en,a),b); bを入れられる
lower upper  co(*Iter) co(Iter-v.bgn) v[i]>=aとなる初のi
priority_queue<ll> pque; pque.push(ai); pque.top()→max(ai) 
vqll q(3);  q[0].push(0); q[0].push(2); q[0].push(1);
q[0].front()→0 q[0].back()→1 q[0].pop(); q[0].front()→2
que.pop() que.sz while(!que.empty())
*/

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void Comuse() {
    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;
    }
}
#define comuse Comuse()
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll pow_mod(ll a,ll n,ll m){
  ll res=1;
  for(;n>0;n/=2){
    if(n%2==1)res=(res*a)%m;
    a=(a*a)%m;
  }
  return res;
}


int main(){
  ll n,k;
  cin>>n>>k;
  vll v(n);
  ll c=0;
  FOR(i,0,n){
    cin>>v[i];
  }
  if((n-1)%(k-1)==0){
    co((n-1)/(k-1));
  }
  else{
    co((n-1)/(k-1)+1);
  }
}
  

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

int main(){
  char c;
  int q, p, n;
  cin >> q;

  ll lcount = 0;
  ll rcount = 0;
  
  while(q--){
    cin >> p >> c >> n;
    if(c == '('){
      lcount += n;
    }else{
      rcount += n;
    }
    cout << (lcount == rcount ? "Yes" : "No") << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll val[1010101][3];
ll dp[101010][3];
int main(){
    cin>>n;
    REP(i, 0, n) cin>>val[i][0]>>val[i][1]>>val[i][2];

    dp[0][0]=val[0][0];
    dp[0][1]=val[0][1];
    dp[0][2]=val[0][2];
    REP(i, 1, n){
        REP(j, 0, 3){
            REP(k, 0, 3){
                if(j==k) continue;
                dp[i][k]=max(dp[i][k], dp[i-1][j]+val[i][k]);
            }
        }
    }
    cout<<max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2])<<endl;
    return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll a[n+1]={};
    ll cnt[n+1]={};
    ll ans=0;
    ll ac=0;
    rep(i,0,m)
    {
        ll x; string s;
		cin>>x>>s;
		if(s=="WA"){
			if(!a[x])
				cnt[x]++;
		}
		else
			a[x]=1;
    }
    rep(i,1,n+1)
    {
        if( a[i]==1 )
        {
            ac++;
            ans+=cnt[i];
        }
    }
    cout<<ac<<" "<<ans<<endl;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline

H, W, K = map(int, input().split())

answer = 0
last_answer = 0
cnt  = 0
for h in range(H):
  a_list = [i for i in input()]
  try:
    a_list.remove('\n')
  except:
    True
  
  if '#' in a_list:
    row_list = []
    for w in range(W):
      if a_list[w] == '#':
        answer += 1
        row_list.append(answer)
      elif answer == last_answer:
        if answer == 0:
          row_list.append(1)
        else:
          #answer += 1
          row_list.append(last_answer + 1)
      else:
        row_list.append(answer)
    print(*row_list)
    if cnt != 0:
      for _ in range(cnt):
        print(*row_list)
      cnt = 0
  else:
    cnt += 1
    
  last_answer  = answer

    
if cnt != 0:
  for _ in range(cnt):
    print(*row_list)

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

int main() {
	string s;
	cin >> s;
	vector <char> ss;
	for (int i = 0; i < s.length(); i++) ss.push_back(s[i]);

	ss.pop_back();
	while (true) {
		if (ss.size() % 2 == 1) ss.pop_back();
		bool flag = true;
		for (int i = 0; i < ss.size() / 2; i++) {
			if (ss[i] != ss[i + ss.size() / 2]) {
				flag = false;
				break;
			}
		}
		if (flag) {
		cout << ss.size() << endl;
		break;
		}
		ss.pop_back();
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string p; cin>>p;
	int maks=0, temp=0;
	for(int i=0; i<p.length(); i++){
		if(p[i]=='A'||p[i]=='T'||p[i]=='G'||p[i]=='C')
			temp++;
		else{
			maks=max(maks, temp); temp=0;
		}
	}
	maks=max(maks, temp);
	cout<<maks<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input().strip())
XU = []
for i in range(N):
	XU.append(list(map(str, input().strip().split(' '))))	#[A][B]

kane = 0

for i in range(N):
    if(XU[i][1] == "BTC"):
        kane = kane + float(XU[i][0])*380000
    else:
        kane = kane + float(XU[i][0])

print(kane)

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

const char* color[] = {
	"black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white"
};

const int RGB[][ 3 ] = {
	{ 0, 0, 0 }, { 0, 0, 255 }, { 0, 255, 0 },
	{ 0, 255, 255 }, { 255, 0, 0 }, { 255, 0, 255 },
	{ 255, 255, 0 }, { 255, 255, 255 },
};

int xtod( char* c )
{
	int ret = 0;
	int mag = 16;
	for( int i = 0; i < 2; ++i, ++c ){
		int d = 0;
		if( *c >= '0' && *c <= '9' ){
			d = *c - '0';
		}else{
			d = *c - 'a' + 10;
		}
		ret += ( d * mag );
		mag /= 16;
	}
	return ret;
}

int distance( const int* o, int* x )
{
	int dd[ 3 ];
	for( int i = 0; i < 3; ++i ){
		dd[ i ] = x[ i ] - o[ i ];
		dd[ i ] *= dd[ i ];
	}
	return dd[ 0 ] + dd[ 1 ] + dd[ 2 ];
}

int main()
{
	char col[ 8 ];

	while( cin >> col && *col != '0' ){
		int n[ 3 ];
		for( int i = 0; i < 3; ++i ){
			n[ i ] = xtod( col + ( 1 + i * 2 ) );
		}
		int d[ 8 ];
		for( int i = 0; i < 8; ++i ){
			d[ i ] = distance( RGB[ i ], n );
		}
		int ans = 0;
		int ansD = 200000;
		for( int i = 0; i < 8; ++i ){
			if( d[ i ] < ansD ){
				ans = i;
				ansD = d[ i ];
			}
		}
		cout << color[ ans ] << endl;
	}

	return 0;
}

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

int main(){
  int cyo=0;
  int don=0;
  int ei=0;
  int count=0;

  for(int i=0;i<100;i++){
    int t[3];
    cin>>t[0]>>t[1]>>t[2];
    sort(t,t+3);

    if(t[0]+t[1]<=t[2])break;
    else {
      count++;
      t[0]=t[0]*t[0];
      t[1]=t[1]*t[1];
      t[2]=t[2]*t[2];
      if(t[0]+t[1]==t[2])cyo++;
      if(t[0]+t[1]<t[2])ei++;
      if(t[0]+t[1]>t[2])don++;
    }
  }
  cout<<count<<" "<<cyo<<" "<<don<<" "<<ei<<endl;

}
  



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N) {
        if (i % 2 == 0 && a[i] % 2 == 1) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for(int i=0;i<n;i++)
		cin >> p[i];
	sort(p.begin(),p.end());
	int ans=0;
	for(int i=0;i<k;i++)
		ans+=p[i];
	cout << ans << endl;




}

Measured memory_bytes: 3184
N = int(input())
S = input()
rs = []
gs = []
bs = []
for i,c in enumerate(S):
    if c=='R':
        rs.append(i)
    elif c=='G':
        gs.append(i)
    else:
        bs.append(i)
R,G,B = len(rs),len(gs),len(bs)
rt = set(rs)
gt = set(gs)
bt = set(bs)

ans = 0
ri = gi = bi = 0
for i in range(N):
    if ri < R and i==rs[ri]:
        ans += gi*(B-bi) + bi*(G-gi)
        for g in gs:
            if i+(i-g) in bt:
                ans -= 1
        ri += 1
    elif gi < G and i==gs[gi]:
        ans += ri*(B-bi) + bi*(R-ri)
        for r in rs:
            if i+(i-r) in bt:
                ans -= 1
        gi += 1
    else:
        ans += ri*(G-gi) + gi*(R-ri)
        for r in rs:
            if i+(i-r) in gt:
                ans -= 1
        bi += 1
print(ans)

Measured memory_bytes: 9452
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int dp[1001][1001] = {};
int main()
{
  int q;
  cin >> q;
  REP(i, q)
  {
    string x, y;
    cin >> x >> y;

    REP(i, x.length() + 1)
    {
      dp[i][0] = 0;
    }
    REP(j, y.length() + 1)
    {
      dp[0][j] = 0;
    }

    FOR(i, 1, x.length() + 1)
    {
      FOR(j, 1, y.length() + 1)
      {
        if (x[i - 1] == y[j - 1])
          dp[i][j] = dp[i - 1][j - 1] + 1;
        else
          dp[i][j] = max(dp[i - 1][j - 1], max(dp[i][j - 1], dp[i - 1][j]));
      }
    }
    cout << dp[x.length()][y.length()] << endl;
  }
}



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

int main() {
    double a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f) {
        double ans_y = (c*d-f*a)/(b*d-e*a);
        double ans_x = (c - b*ans_y) / a;
        ans_x = static_cast<int>((ans_x * 10000 + 0.5)) / 10000.0;
        ans_y = static_cast<int>((ans_y * 10000 + 0.5)) / 10000.0;
        cout << fixed << setprecision(3) << ans_x << " " << ans_y << endl;
    }
}

Measured memory_bytes: 3116
import java.util.*;

class Main { 
  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] a = new int[2][n];
      for(int i = 0; i < 2; i++){
          for(int j = 0; j < n; j++){
              a[i][j] = sc.nextInt();
          }
      }
      
      int maxCnt = 0;
      for(int i = 0; i < n; i ++){
          int tmp = 0;
          for(int j = 0; j <= i; j++){
              tmp = tmp + a[0][j];
          }
          for(int k = i; k < n; k++){
              tmp = tmp + a[1][k];
          }
          
          if(tmp > maxCnt) {
              maxCnt = tmp;
          }
      }
      
      System.out.println(maxCnt);
  }  
}

Measured memory_bytes: 23636
def main():
    n, a, b, c, d = map(int, input().split())

    for i in range(n):
        if c * (n-1-i) - d * i <= b - a <= -c * i + d * (n-1-i):
            print("YES")
            break
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int d[100][100];
struct st {
	int a, b, c;
};
vector<st>v;
int main() {
	int n, m; scanf("%d%d", &n, &m);
	memset(d, 0x3f, sizeof(d));
	rep(i, n)d[i][i] = 0;
	rep(i, m) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c); a--; b--;
		d[a][b] = d[b][a] = c;
		v.push_back({ a,b,c });
	}
	rep(k, n)rep(i, n)rep(j, n)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	int cnt = 0;
	for (st s : v) {
		if (d[s.a][s.b] != s.c)cnt++;
	}
	printf("%d\n", cnt);
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    string S, T;
    cin >> S >> T;

    if(S==T.substr(0, T.length()-1)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <queue>
#include <utility>
#include <map>
#include <cmath>
#include <string>
#include <stdio.h>
#include <sstream>

using namespace std;

int main(){
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1;i<x+k-1;i++) cout << i << ' ';
    cout << x+k-1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int n;
    int cnt =0;
    cin >> n;
    vector<int>L(n,0);
    rep(i, n) cin >> L[i];
    sort(L.begin(), L.end());
    //rep(i, n) cout << L[i];
    rep(i, n){
        rep(j, n){
            if(i !=j){
                if (i<j){
                    for(int k =j+1; k<n; k++){
                        if(L[i] +L[j]> L[k]) cnt +=1;
                    }
                    
                }
                    
            }
                
        }
    }
    cout << cnt;
}

Measured memory_bytes: 384
"""
愚直に考えると、
各文字について、部分列に入れるか入れないか判断し、できた部分列について重複がないか判定する。
部分列作成部分だけで2^Nかかるので、到底間に合わない。

同一の部分列であっても、切り出した位置が異なれば違うものとして扱うので、例えばaaabがあったとき、a__b, _a_b, __abはいずれもabだが、それぞれカウントする。
なので上の例のabについては、（aの個数）x（bの個数）という計算になる。
こんな感じで考えると、それぞれの文字について、
・文字XXXを部分列にいれるか入れないか
・入れるのであれば、どの位置のXXXをぶぶんれつにいれるか
の 個数＋１の選択肢があるから、これの累積積をMODの世界でとっていけばよい

いずれの文字についても選ばない場合（部分列が空文字になる）も存在するので、その分は除く
"""


N = int(input())
S = input()
MOD = 10**9 + 7
from collections import Counter
c = Counter(S)
ans = 1

for v in c.values():
    ans *= (v+1)
    ans %= MOD

print(ans-1)

Measured memory_bytes: 39280
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define sqr(x) ((x) * (x))
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;
                        
typedef unsigned long long ull;
typedef long double ld;

const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int N = (int)2e6+ 222;
const ll INF = (ll)1e18;
const int p = 997, p1 = 991;
const double eps = (double)1e-6;

int n, k;             
vector < pair <int, int> > v;
             
void solve () {                                                
	cin >> n >> k;
	int mx = n - 2;
	mx = (mx + 1) * mx / 2;
	if (mx < k) {
		cout << -1;
		return;
	}
	mx -= k;
	for (int i = 2; i <= n; ++i) {
		v.pb({1, i});	
	}
	int l = 2, r = 3;
	while (mx) {
		if (r != n + 1) {
			v.pb({l, r});
			r++;	
	  		mx--;
	  	} else {
	  		l++;
	  		r = l + 1;
		}	
	}
	cout << sz(v) << endl;
	for (auto to : v) {
		cout <<to.F << " " << to.S << endl;	
	}



}


signed main () {
    #ifdef Maga
        freopen("input", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);                                              
    int t = 1;
    while (t --) {
    	solve ();
    }
    return 0;
}





Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int n, dp[5][100005];
int main() {
    cin >> n;
    for (int i=1; i<=n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        dp[1][i] = max(dp[2][i-1], dp[3][i-1]) + a;
        dp[2][i] = max(dp[1][i-1], dp[3][i-1]) + b;
        dp[3][i] = max(dp[1][i-1], dp[2][i-1]) + c;
    }
    cout << max(dp[1][n], max(dp[2][n], dp[3][n])) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll h,w;
	cin>>h>>w;
	if(h==1 or w==1)
		cout<<"1"<<endl;
	else if(h%2==0 or w%2==0)
	{
		ll t=(h*w)/2;
		cout<<t<<endl;
	}
	else if(h%2!=0 or w%2!=0)
	{
		ll t=(h*w)/2;
		cout<<t+1<<endl;
	}
	return 0;
}


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

typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  for(int i=0; i<s.length(); i++){
    if(i==3) cout << "8";
    else cout << s[i];
  }
  cout << endl;
  return 0;
}


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

int main(){
    while(true){
        int n,l,r;
        int ans=0;
        std::cin>>n>>l>>r;
        if(n==0)break;
        std::vector<int> a;
        for (int i = 0; i < n; ++i) {
            int t;
            std::cin>>t;
            a.emplace_back(t);
        }
        for (int i = l; i <= r; ++i) {
            bool f=false;
            for (int j = 1; j <= n; ++j) {
                if(j%2==1){
                    if(i%a[j-1]==0){++ans;f= true;break;}
                }
                else {
                    if(i%a[j-1]==0){f= true;break;}
                }
            }
            if(!f&&n%2==0)++ans;
        }
        std::cout<<ans<<std::endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <stdio.h>

int main(){
    char s[3], t[3];
    int ans = 0, i;
    scanf("%s", s);
    scanf("%s", t);
    for(i = 0; i < 3; i++){
        if(s[i] == t[i]){
            ans++;
        }
    }
    printf("%d", ans);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LS()
    if a == b:
        print("H")
    else:
        print("D")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38512
MOD = 998244353
PROOT = 3
IPROOT = 665496235
roots  = [pow(PROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根
iroots  = [pow(IPROOT,(MOD-1)>>i,MOD) for i in range(24)] # 1 の 2^i 乗根の逆元

def fft_stockham(A,n,inv=False):
    N = 1<<n
    for i in range(n):
        nA = [0]*N
        a = 1<<i
        b = 1<<(n-i-1)
        wb = iroots[i+1] if inv else roots[i+1]
        for j in range(b):
            w = 1
            for k in range(a):
                nA[2*a*j+k]   = (A[a*j+k] + A[a*j+N//2+k]*w)%MOD
                nA[2*a*j+k+a] = (A[a*j+k] - A[a*j+N//2+k]*w)%MOD
                w = w*wb%MOD
        A = nA
    return A
  
def convolution(a,b):
    deg = len(a) + len(b) - 2
    n = deg.bit_length()
    N = 1<<n
    a += [0]*(N-len(a))
    b += [0]*(N-len(b))
    fa = fft_stockham(a,n)
    fb = fft_stockham(b,n)

    inv = pow(1<<n,MOD-2,MOD)
    for i in range(N):
      fa[i] = fa[i]*fb[i]%MOD*inv%MOD
    ab = fft_stockham(fa,n,True)
    return ab[:deg+1]

n,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = convolution(a,b)
print(*c)


Measured memory_bytes: 242620
#include <bits/stdc++.h>
using namespace std ;
const int mxN =3e3+3 ;
string s,t ;
int dp[mxN][mxN] ;
signed main(){	  
  cin >> s >> t ;
  int n = s.size(),m=t.size() ;
  for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
    	if(s[i-1]==t[j-1])
          dp[i][j]=1+dp[i-1][j-1] ;
      	else 
          dp[i][j]=max(dp[i-1][j],dp[i][j-1]) ;
    }
  }
  string ans ;
  int i=n,j=m ;
  while(i>0&&j>0){
  	if(dp[i][j]==dp[i-1][j])
      --i ;
   	else if(dp[i][j]==dp[i][j-1])
      --j ;
    else
      --i,--j,ans+=s[i] ;
  }
  reverse(ans.begin(),ans.end()) ;
  cout << ans << endl ;
}

Measured memory_bytes: 38824