akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
const int N = 2e5 + 5;
#define PI acos(-1.0)
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> VI;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(ll a, ll b) { if (a < b)swap(a, b); return (((a%mod) - (b%mod) + mod) % mod); }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
signed main()
{
	fastio;
	int n, m;
	cin >> n >> m;
	vector<int>v(n);
	int sum = 0;
	rep(i, n) {
		cin >> v[i];
		sum += v[i];
	}
	float sum1 = (float)sum / (float)(4*m);
	int cnt = 0;
	rep(i, n) {
		if (v[i] >= sum1)cnt++;
	}
	if (cnt >= m) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


}

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

int main() {
    int n, k;
    cin >> n >> k;
    int d[k + 5];
    set < int > d1;
    d1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (int i = 0; i < k; i++) {
        cin >> d[i];
        d1.erase(d[i]);
    }
    while (true) {
        string s = to_string(n);
        bool flag = 1;
        for (int i = 0; i < s.size(); i++) {
            if (d1.find(s[i] - '0') == d1.end()) {
                flag = 0;
                break;
            }
        }
        if (flag) {
            cout << n << "\n";
            break;
        }
        n++;
    }
}

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

using namespace std;

int main(void){
  string S;
  cin >> S;
  vector<int> N(2,0);
  int i;
  for(i=0;i < S.size(); i++){
    N[S[i] == '0']++;
  }
  cout << 2*min(N[0],N[1]) << endl;
  return 0;
}

Measured memory_bytes: 512
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    mi = 10**18
    for i in range(ls-lt+1):
        nm = 0
        for j in range(lt):
            if s[i+j] != t[j]:
                nm += 1
        if nm < mi:
            mi = nm

    print(mi)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 70144
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
map<int, int> A;

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) {
    int a;
    cin >> a;
    A[a]++;
  }
  vector<int> xs;
  for (auto p : A) {
    while (p._2 >= 2) xs.pb(p._1), p._2-=2;
  }
  sort(all(xs), greater<int>());
  if (xs.size() < 2) cout << 0 << "\n";
  else cout<<1LL*xs[0]*xs[1]<<"\n";
  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#define MOD 1000000007
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 2005;
int f[MAXN][MAXN],n,k;
inline int ksm(int x,int k)
{
	int ret=1;
	while(k){
		if(k&1)ret=(long long)ret*x%MOD;
		x=(long long)x*x%MOD;
		k>>=1;
	}
	return ret;
}
int fac[MAXN*MAXN],inv[MAXN*MAXN];
inline void init(int n)
{
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=(long long)fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	inv[0]=1;
	for(int i=n-1;i;--i)
		inv[i]=(long long)inv[i+1]*(i+1)%MOD;
}
inline int C(int n,int m)
{
	return (long long)fac[m]*inv[m-n]%MOD*inv[n]%MOD;
}
inline void add(int &x,int a)
{
	x+=a;
	if(x>=MOD)x-=MOD;
}
int main()
{
	scanf("%d%d",&n,&k);
	if(k==1){puts("1");return 0;}
	init(n*k);
	f[0][0]=1;
	for(int i=0;i<=n;++i)
		for(int j=i;j<=n;++j){
			if(i>0)add(f[i][j],f[i-1][j]);
			if(i<j)add(f[i][j],(long long)f[i][j-1]*C(k-2,j*(k-1)-1+i)%MOD);
		}
	cout<<(long long)f[n][n]*fac[n]%MOD<<endl;
	return 0;
}


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

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

    long long over = 1000000007;
    vector<int> a(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }

    long long res = 0, tmp, sum_m;
    for (int i = 0; i < n-1; i++) {
        sum -= a.at(i);
        sum_m = sum % over;
        res += a.at(i) * sum_m;
        res = res % over;
    }

    cout << res << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	
	ll N;
	cin>>N;
	ll dp[N+1][4];
	for (int i = 1;i <= N;++i) {
		cin>>dp[i][1]>>dp[i][2]>>dp[i][3];
	}
	
	for (int i = 2;i <= N;++i)  {
		dp[i][1] += max(dp[i-1][2], dp[i-1][3]);
		dp[i][2] += max(dp[i-1][1], dp[i-1][3]);
		dp[i][3] += max(dp[i-1][1], dp[i-1][2]);
	}
	
	cout<<max(max(dp[N][1], dp[N][2]), dp[N][3])<<endl;
	return 0;
}


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	string s;
	cin >> s;
	if (s == "ABC")
		cout << "ARC" << endl;
	else
		cout << "ABC" << endl;
	return 0;
}

//!

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

int power(int x, int y){
  int n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}

int mod = 1e9+7;
int main() {
  int a;
  string  s;
  cin >> a;
  cin >> s;
  if(a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   double B = sc.nextInt();
   int hairetu[] = new int[A];
   double sum =0;
   int count = 0;
   for(int i=0; i<A; i++) {
   hairetu[i] = sc.nextInt();
   sum += hairetu[i];
   }

   double joken = sum/(4*B);
   for(int i=0; i<A; i++) {
	   if(hairetu[i] >= joken) {
		   count++;
	   }
   }

   if(count >= B) {
	   System.out.print("Yes");
   } else {
	   System.out.print("No");
   }

 }
}




Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    REP(i, 0, N) {
        cin >> A[i];
        if (A[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans = 1, maximum = pow(10, 18);
    REP(i, 0, N) {
        if (A[i] <= maximum / ans) {
            ans *= A[i];
        } else {
            cout << -1 << endl;
            return 0;

        }
    }

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

Measured memory_bytes: 4044
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    n, k = get_list()
    print("YES") if k<=(n+1)//2 else print("NO")

''' Pythonista fLite 1.1 '''
import sys
from collections import defaultdict, Counter
from bisect import bisect_left, bisect_right
#from functools import reduce
import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')


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

#define ll long long

using namespace std;

ll a, b, c;

int main()
{
    cin >> a >> b >> c;
    cout << min(min(a % 2 * b * c, b % 2 * a * c), c % 2 * a * b);
    return 0;
}


Measured memory_bytes: 256
using System;
 
class Program{
	public static void Main(){
		string s;
		while((s = Console.ReadLine()) != null){
			int[] n = Array.ConvertAll(s.Split(' '), int.Parse);
			int sum = n[0] + n[1];
			Console.WriteLine(sum.ToString().Length);
		}
	}
}

Measured memory_bytes: 9008
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x, y = map(int, read().split())

def f(x, y):
    # + のみ
    if x <= y:
        yield y - x
    # 反転、+
    if -x <= y:
        yield 1 + x + y
    # +、反転
    if x <= -y:
        yield 1 - x - y
    # 反転、+、反転
    if -x <= -y:
        yield 2 - y + x

x = min(f(x, y))
print(x)

Measured memory_bytes: 9160
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 400000;





int main() {
	
	double W, H, x, y;
	cin >> W >> H >> x >> y;

	cout << W * H / 2.0 <<" ";
	
	if (x == W / 2.0 && y == H / 2.0) {
		cout << 1;
	}
	else { cout << 0; }
	

	system("PAUSE");

}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int i,n;
	long long ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		if(a[i]<a[i+1])
			ans+=a[i+1]-a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

import math
import re
import numpy as np
import copy

#読み込む
S = input().split(' ')

a = int(S[0])
b = int(S[1])
c = int(S[2])
d = int(S[3])

ls = []

ls.append(a*c)
ls.append(a*d)
ls.append(b*c)
ls.append(b*d)

ans = max(ls)

print(ans)





Measured memory_bytes: 27208
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define mod 1000000007
int main() {
    int n;
    cin >> n;
    int k = 0, l = 0, m = 0;
    ll ret = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (k == a) {
            int count = 1;
            k++;
            if (l == a) count++;
            if (m == a) count++;
            ret = ret * count % mod;
        }
        else if (l == a) {
            int count = 1;
            l++;
            if (m == a) count++;
            ret = ret * count % mod;
        }
        else if (m == a) {
            m++;
        }
        else {
            ret = 0;
            break;
        }
    }
    cout << ret << endl;
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, b, a) for(int i = b; i >= a; --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

const int MOD = 1e9+7;
const int N = 1e5+10;
int n, m;
bool broke[N];
ll dp[N];
int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d%d", &n, &m);
  rep(i, 0, m){
    int idx;
    scanf("%d", &idx);
    broke[idx] = true;
  }
  dp[0] = 1;
  if(!broke[1]) dp[1] = 1;

  rep(i, 2, n+1){
    if(!broke[i-1]) dp[i] += dp[i-1];
    if(!broke[i-2]) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }
  printf("%lld\n", dp[n]);
}


Measured memory_bytes: 1152
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ll fac[100010],a[100010];
ll quick_mod(ll a, ll b, ll c){
    ll ans = 1;
    while(b){
        if(b & 1) ans = (ans*a)%c;
        b>>=1;
        a = (a*a)%c;
    }
    return ans;
}
void Get_Fac(ll m){
    fac[0] = 1;
    for(int i=1; i<=m; i++)
        fac[i] = (fac[i-1]*i) % mod;
}
ll Lucas(ll n, ll m, ll p){
    ll ans = 1;
    if(n==0) return 0;
    while(n && m){
        ll a = n % p;
        ll b = m % p;
        if(a < b) return 0;
        ans = ( (ans*fac[a]%p) * (quick_mod(fac[b]*fac[a-b]%p,p-2,p)) ) % p;
        n /= p;
        m /= p;
    }
    return ans;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:\\Users\\LENOVO\\Desktop\\in.txt","r",stdin);
#endif
	Get_Fac(100001);
	ll n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n);
	ll res=0;
	for(int i=1;i<=n;i++){
#ifdef WindCry1
	DEBUG(Lucas(i-1,k-1,mod));
	DEBUG(n-i);
	DEBUG(Lucas(n-i,k-1,mod));
	DEBUG(k-1);
	cout<<(Lucas(i-1,k-1,mod)-Lucas(n-i,k-1,mod)+mod)%mod<<endl;
#endif
		res=(res+(Lucas(i-1,k-1,mod)-Lucas(n-i,k-1,mod)+mod)*a[i])%mod;
#ifdef WindCry1
	DEBUG(res);
#endif
	}
	cout<<res<<endl;
	return 0;
}



Measured memory_bytes: 1792
<?php
while ($line = fgets(STDIN)) {
   $tmp[] = trim($line);
}

// 配列の各要素をさらに分解します
foreach ($tmp as $key => $value) {
  $array[] = explode(" ", $value);
}
//命名
$number_of_question = $array[0][0];
$number_of_submit = $array[0][1];
$count_of_correct = 0;
$count_of_penalty = 0;
$list_of_correct = array();
$tmp_wrong = array();
for ($t = 1;$t <= $number_of_submit;$t++) {
    $title_of_question = $array[$t][0];
    $bool = $array[$t][1];
    if (isset($list_of_correct[$title_of_question])) {
        continue;
    } elseif ($bool == 'WA') {
        if (isset($tmp_wrong[$title_of_question])) {
            $current_times = $tmp_wrong[$title_of_question];
            $current_times = $current_times + 1;
            $tmp_wrong[$title_of_question] = $current_times;
        } else {
            $tmp_wrong[$title_of_question] = 1;
        }
    } elseif ($bool == 'AC') {
        if (isset($tmp_wrong[$title_of_question])) {
            $current_times = $tmp_wrong[$title_of_question];
            $count_of_penalty = $count_of_penalty + $current_times;
        }
        $count_of_correct++;
        $list_of_correct[$title_of_question] = true;
    }
}
echo $count_of_correct.' '.$count_of_penalty;

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

ll n, h, w, a, b, ans;
int main() {
	cin >> n >> h >> w;
	while(n--) {
		cin >> a >> b;
		ans += (a>=h && b>=w);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define maxn 100
using namespace std;
int n, m;
template<class T>
inline void read(T &a){
	int s = 0, w = 1; char c;
	while(c < '0' || c > '9') {if(c == '-') w = -1; c = getchar();}
	while(c >= '0' && c <= '9'){s = (s << 1) + (s << 3) + (c ^ 48); c = getchar();}
	a = s*w;
}
int a[maxn], b[maxn];
int dfs(int n, int x){
if(x == 0) return 0;
	if(x == b[n]) return a[n];
    if(n == 0) return 1;
	if(x <= 1) return 0;
	if(x >= b[n-1]*2 + 2) return a[n-1] * 2 + 1;
	else{
		if(x >= b[n-1] + 2) return a[n-1] + 1 + dfs(n - 1, x - b[n-1] - 2);
			else{
				 return dfs(n - 1, x - 1);
			}
		}
}
signed main(){
	read(n); read(m);
	a[0] = b[0] = 1;
	for (int i = 1; i <= n; i++){
		a[i] = a[i-1] * 2 + 1;
		b[i] = b[i-1] * 2 + 3;
	}
	printf("%lld", dfs(n, m));
	return 0;
}


Measured memory_bytes: 256
tmp = []
cou = 1
while cou != 0
  i = gets.chomp
  tmp.push(i)
  cou = i.to_i
end
tmp.delete(tmp[-1])
tmpcount = 1
i = 0
num_of_case=1
loop do
  puts "Case #{num_of_case}: #{tmp[i]}"
  i += 1
  num_of_case += 1
  if tmp[i]==nil
    break
  end
end

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    int a[3];
    int mn =OO;
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    for(int i=0;i<3;i++){
       
        int j =0;
        int sum =0;
        for(j=0;j<3;j++){
            if(j!=i){
                sum+=a[j];
            }
        }
        mn=min(sum,mn);
    }
    printf("%d",mn);
    return 0;
}

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

int main(){
    locale l = locale::classic();
    string a, b, c;
    cin >> a >> b >> c;
    cout << toupper(a[0], l) << toupper(b[0], l) << toupper(c[0], l) << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
using namespace std;
int main(){
	string s;
	cin>>s;
	vector<vector<int> >dp(s.size(),vector<int>(13,0));

	if(s[0]=='?'){
		for(int i=0;i<=9;i++)
			dp[0][i]=1;
	}
	else{
		dp[0][s[0] - '0'] = 1;
	}
	for(int i=1;i<dp.size();i++)
	{
		// cout<<"for "<<i<<endl;
		if(s[i]=='?')
		{
			for(int j=0;j<dp[0].size();j++)
			{
				// if(dp[i-1][j]!=0)
				for(int k=0;k<=9;k++){
					dp[i][(j*10+k)%13]+=dp[i-1][j];
					dp[i][(j*10+k)%13]%=1000000007;
				}
			}
		}
		else{
			for(int j=0;j<dp[0].size();j++)
			{
				dp[i][(j*10+(s[i]-'0'))%13]+=dp[i-1][j];
				dp[i][(j*10+(s[i]-'0'))%13]%=1000000007;
			}
		}
	}
	// for(int i=0;i<dp.size();i++){
	// 	for(int j=0;j<dp[0].size();j++)
	// 		cout<<dp[i][j]<<" ";
		
	// 	cout<<endl;
	// }
	cout<< dp[dp.size()-1][5];
	return 0;
}

Measured memory_bytes: 8960
#include<stdio.h>
int main(void)
{
  char ch;
  while(1){
    scanf("%c",&ch);
    if(ch=='\n'){
      break;
    }
    if('a'<=ch&&ch<='z'){
      ch=ch-32;
      printf("%c",ch);
    }else if('A'<=ch&&ch<='Z'){
      ch=ch+32;
      printf("%c",ch);
    }else{
      printf("%c",ch);
    }
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 1924
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    string s[n];
    for(ll i = 0; i < n; i++)
        cin >> s[i];
    ll a = 0, b = 0, ab = 0;
    ll same = 0;
    for(ll i = 0; i < n; i++){
        for(ll j = 0; j < s[i].length()-1; j++){
            if(s[i][j]=='A' && s[i][j+1]=='B') ab++;
        }
        if(s[i][s[i].length()-1]=='A') a++;
        if(s[i][0]=='B') b++;
        if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A')
            same++;
    }
    //cout << a << " " << b << " " << ab  << " " << same<< endl;
    ll ans = ab+min(a, b);
    if(same==a&&same==b&&same!=0) ans--;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans;
  if (A > B)
    ans = 0;
  else if (N == 1 && A != B)
    ans = 0;
  else
    ans = (N - 2) * (B - A) + 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
count = defaultdict(int)
for _ in range(M):
    a, b = map(int, input().split())
    count[a] += 1
    count[b] += 1
flag = True
for k, v in count.items():
    if v % 2 == 1:
        flag = False
if flag:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 83488
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

int main()
{
  int x, y;

  cin >> x >> y;
  bool flag = false;
  for (int i = 0; i <= x; i++)
  {
    for (int j = 0; j < y; j++)
    {
      if (2 * i + 4 * (x - i) == y)
      {
        flag = true;
        break;
      }
    }
  }
  if (flag)
  {
    cout << "Yes\n";
  }
  else
  {
    cout << "No\n";
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	ll x,y;
	cin>>x>>y;
	cerr<<x*y<<endl;
	int ans;
	if(x == 0){
		if(y > 0){
			ans = y;
		}
		else{
			ans = abs(y) + 1;
		}
	}
	else if(y == 0){
		if(x > 0){
			ans = abs(x) + 1;
		}
		else{
			ans = abs(x);
		}
	}
	else if(x*y<0){
		ans = abs(abs(x)-abs(y))+1;
	}
	else if(x*y>0){
		if(y<x){
			ans = abs(abs(x)-abs(y)) + 2;
		}
		else{
			ans = abs(abs(x)-abs(y));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    
    cout << ((s.substr(0, 4) == "YAKI") ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
UF = UnionFind(n + m)
for i in range(n):
    kl = list(map(int, input().split()))
    l_s = kl[1:]
    for l in l_s:
        UF.union(i, l - 1 + n)

for i in range(1, n):
    if not UF.same(i, 0):
        print("NO")
        exit()
print("YES")



Measured memory_bytes: 15684
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,LL>
#define db double
#define fi first
#define se second
const LL N=5e5+10;
const LL inf=0x3f3f3f3f;
const LL mod=1e9+7;
const double eps=1e-9;
using namespace std;
template<typename tp> inline void read(tp &x)
{
    x=0; char c=getchar(); bool f=0;
    for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());
    for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());
    if(f) x=-x;
}
int n;
struct Node{double k,b;}node[N];
bool cmp(Node a,Node b){return a.b<b.b;}
double maxn[N],minn[N];
int find_L(int l,int r,double k,int ret)
{
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(maxn[mid]>k) ret=mid,r=mid-1;
		else l=mid+1;
	}
	return ret;
}
int find_R(int l,int r,double k,int ret)
{
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(minn[mid]<k) ret=mid,l=mid+1;
		else r=mid-1;
	}
	return ret;
}
int L[N],R[N],ri=0;
vector<int> vec[N];
LL sum[N],dp[N];
void solve()
{
	sum[0]=dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=(sum[i-1]-(ri?sum[ri-1]:0)+mod)%mod;
		sum[i]=(sum[i-1]+dp[i])%mod;
		for(int j=0;j<vec[i].size();j++)
			ri=max(ri,vec[i][j]);
	}
}
int main()
{
    read(n);
	for(int i=1;i<=n;i++) scanf("%lf %lf",&node[i].b,&node[i].k);
	sort(node+1,node+n+1,cmp);
	minn[n]=node[n].k;maxn[1]=node[1].k;
	for(int i=2;i<=n;i++) maxn[i]=max(maxn[i-1],node[i].k);
	for(int i=n-1;i>=1;i--) minn[i]=min(minn[i+1],node[i].k);
	for(int i=1;i<=n;i++) L[i]=find_L(1,i,node[i].k,i);
	for(int i=1;i<=n;i++) R[i]=find_R(i,n,node[i].k,i);
	// for(int i=1;i<=n;i++) cout<<maxn[i]<<" ";puts("");
	// for(int i=1;i<=n;i++) cout<<minn[i]<<" ";puts("");
	// for(int i=1;i<=n;i++)
		// printf("%lf %lf %d %d\n",node[i].k,node[i].b,L[i],R[i]);
	for(int i=1;i<=n;i++) vec[R[i]].push_back(L[i]);
	solve();
	printf("%lld\n",((sum[n]-(ri?sum[ri-1]:0))%mod+mod)%mod);
    return 0;
}


Measured memory_bytes: 40832
#include<stdio.h>
#include<math.h>

int main(void){
	int n=0;			// input; items num <= 1000;
	int S[1000]={0};	// input; data set, 0<=s[i]<=100
	int i=0;			// loop index
	int sum=0;
	double ave=0.0;
	double a_sum=0.0;
	double ans=0.0;

	scanf("%d", &n);
	while(n != 0){
		sum = 0;
		a_sum = ave = ans = 0.0;

		for(i=0;i<n;i++){
			scanf("%d", &S[i]);
			sum += S[i];
		}
		ave = (double)sum / (double)n;
		for(i=0;i<n;i++) a_sum += pow((double)S[i] - ave, 2);

		ans = sqrt(a_sum / (double)n);
		printf("%lf\n", ans);
		scanf("%d", &n);
	}
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9;
int main()
{
    int n;
    scanf("%d",&n);
    vector<int> h(n);
    for(int& i:h)
       {

        scanf("%d",&i);}
        vector<int> dp(n,inf);
        dp[0]=0;
        for(int i=0;i<n;i++)


        {

                for(int j :{i+1,i+2})
        {if(j<n)
        {dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));

        }

        }

        }
        cout<<dp[n-1]<<endl;


}

Measured memory_bytes: 4028
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
  int h,w;
  cin >> h >> w;
  vector<string> v;
  vector<int> p;
  rep(i,h){
    string s;
    cin >> s;
    bool f = true;
    rep(j,s.length()){
      if(s[j] == '#'){
        f = false;
      }
    }
    if(!f){
      v.pb(s);
    }
  }
  rep(i,w){
    string s = "";
    rep(j,v.size()){
      s = s + v[j][i];
    }
    bool f = true;
    rep(j,s.length()){
      if(s[j] == '#'){
        f = false;
      }
    }
    if(!f){
      p.pb(i);
    }
  }
  rep(i,v.size()){
    rep(j,p.size()){
      cout << v[i][p[j]];
    }
    cout << endl;
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n;
    cin>>n;
    ll a[n][3];
    ll dp[n][3];
    for(ll i=0;i<n;i++)
    for(ll j=0;j<3;j++)
    cin>>a[i][j];
    for(ll j=0;j<3;j++)
    dp[0][j]=a[0][j];
    for(ll i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            ll x=0;
            for(int k=0;k<3;k++)
            {
                if(j!=k)
                x=max(dp[i-1][k],x);
            }
            dp[i][j]=a[i][j]+x;
        }
    }
    ll ans=0;
    for(ll i=0;i<3;i++)
    ans=max(dp[n-1][i],ans);
    cout<<ans;
}


Measured memory_bytes: 4992
n, m, x = gets.split.map(&:to_i)

ca = n.times.map {gets.split.map(&:to_i)}

ans = 1 << 30
(2 ** n).times do |i|
    s = Array.new(m+1, 0)

    n.times do |j|
        if i[j] == 1
            (m+1).times {|k| s[k] += ca[j][k]}
        end
    end

    ans = s[0] if ans > s[0] && s[1..-1].all? {|e| e >= x}
end

puts ans == 1 << 30 ? -1 : ans

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

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	int ans0 = 0;
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int i = 0; i < n; i += 2) ans0 += a[i];
	for (int i = 1; i < n; i += 2) ans0 -= a[i];
	cout << ans0 << " ";
	int ans = ans0;
	for (int i = 0; i < n - 1; ++i) {
		ans = 2 * a[i] - ans;
		cout << ans << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	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;
	}
}

// 二項係数計算
long long COMB(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;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
int n;
signed main() {
	cin >> n;
	if (n % 10 == 3)puts("bon");
	else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)puts("pon");
	else puts("hon");
	ggr
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define str string
#define optimizator ios_base::sync_with_stdio(0);
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	str a;
	str b;
	for(int i=1; i<=n; i++){
		a+=m+'0';
	}
	for(int i=1; i<=m; i++){
		b+=n+'0';
	}
	if(n>m){
		cout<<a;
	}
	else{
		cout<<b;
	}
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(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;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,ans=0;
	cin >> n >> k;
	for(ll i=k;i<=n+1;i++){
		ans=(ans+n*(n+1)/2-(n-i)*(n-i+1)/2-i*(i-1)/2+1)%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s; cin >> s;
    ll ans = 0;
    int bc = 0;
    while (!s.empty()) {
        if (s.back() == '<') {
            bc++;
            s.pop_back();
        } else break;
    }
    ans += (ll)bc*(bc+1)/2;
    s += '<';
    int n = s.size();
    map<char,int> mp;
    rep(i,n-1) {
        mp[s[i]]++;
        if (s[i] == '>' && s[i+1] == '<') {
            int mx = max(mp['<'],mp['>']);
            int mn = min(mp['<'],mp['>']);
            ans += (ll)(1+mx)*mx/2;
            ans += (ll)mn*(mn-1)/2;
            mp['<'] = mp['>'] = 0;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int x, y, t;
	while(1){
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if ( x > y ){ t = x; x = y; y = t;}
		cout << x << " " << y <<  endl;
	}
	return 0;
}

Measured memory_bytes: 1160
<?php
fscanf(STDIN,'%d',$N);
$S=[];
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  $S[$i]=fgets(STDIN);
}
fscanf(STDIN,'%d',$M);
$T=[];
for ($i=0; $i <=$M-1 ; $i++) {
  // code...
  $T[$i]=fgets(STDIN);
}
$Scount = array_count_values($S);
$Tcount = array_count_values($T);
$countmax=0;
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  $word=$S[$i];
  if(isset($Tcount[$word])){
    $count=$Scount[$word]-$Tcount[$word];
  }else{
    $count=$Scount[$word];
  }
  if($count>$countmax){
    $countmax=$count;
  }
}
if($countmax>=0){
echo $countmax;
}else{
  echo 0;
}

 ?>


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

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long n;cin>>n;
    long dp[3]={0};
    long h[3]={0};
    for(int i=0;i<n;i++){
        long dp_new[3]={0};
        for(int j=0;j<3;j++){
            cin>>h[j];
        }
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k){
                    dp_new[k]=max(dp_new[k],dp[j]+h[k]);
                }
            }
        }
        for(int j=0;j<3;j++){
            dp[j]=dp_new[j];
        }

    }
    cout<<max(dp[0],max(dp[1],dp[2]));
}


Measured memory_bytes: 256
while True:
    h1 = int(input())
    if h1 == 0:
        break
    h = [h1] + [int(input()) for _ in range(4)]
    if len(set(h)) == 1 or len(set(h)) == 3:
        print(*[3]*5, sep="\n")
        continue
    for hi in h:
        print([2, 1][(hi%3)+1 in h])


Measured memory_bytes: 5608
class UnionFind:
    #要素数nで初期化
    #インスタンス変数の初期化
    def __init__(self, n):
        #root : 木の要素数
        #rnk : 木の高さ(rank)
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    
    """ノードxのrootノードを見つける"""
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x]) 
            return self.root[x]
    
    """木の合併"""
    def Union(self, x, y):
        #入力ノードの親を探索
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        
        #既に同じ木に所属する場合
        if (x==y):
            return 
        
        #異なる木に所属する場合 -> rnkから判断して合併する
        elif (self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            
            #rnkが同じ(深さが同じ)場合
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y] += 1
    
    """xとyが同じグループに所属するか"""
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
    
    """ノードxが属する木のサイズ"""
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
    """木(非連結成分)の数を数える"""
    #全連結成分にするために必要な橋の本数は、cnt - 1
    def Count_Unconnected_Component(self):
        cnt = 0
        for i in range(self.n):
            if self.root[i+1] < 0:
                cnt += 1
        return cnt
    
    def Members(self, x):
        r = self.Find_Root(x)
        return [i for i in range(self.n+1) if self.Find_Root(i) == r]


n,m = map(int,input().split())
uf = UnionFind(n)
p = list(map(int,input().split()))
for i in range(m):
    x,y = map(int,input().split())
    uf.Union(x,y)
res = 0
for i, x in enumerate(p):
    if uf.isSameGroup(i+1, x):
        res += 1
print(res)

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

int main() {
  ll xi, yi, d;
  int n, ans = 0;
  cin >> n >> d;
  d *= d;

  rep(i, n) {
    cin >> xi >> yi;
    ll di = xi * xi + yi * yi;
    if (d >= di) ans++;
  }

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


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

using namespace std;

int main() {
    // Input
    int N, M;
    vector<int> H, A, B;

    cin >> N >> M;
    H = vector<int>(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    A = vector<int>(M);
    B = vector<int>(M);
    for (int i = 0; i < M; i++) cin >> A[i] >> B[i];

    // Process
    vector<bool> flags(N, true);
    for (int i = 0; i < M; i++) {
        int a = H[A[i] - 1];
        int b = H[B[i] - 1];
        if (a <= b) flags[A[i] - 1] = false;
        if (b <= a) flags[B[i] - 1] = false;
    }

    int ans = 0;
    for (bool flag : flags) {
        if (flag) ans++;
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4528
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

cost = 0
for i in range(N - X):
  if X + i + 1 in A:
    cost += 1

COST = 0
for i in range(X):
  if X - i - 1 in A:
    COST += 1

print(min(cost, COST))

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	int P[200000];
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &P[i]);
	}
	
	int M[200000];
	int m = 200000000;
	for(int i = 0; i < N; i++){
		if(P[i] < m){
			m = P[i];
		}
		M[i] = m;
	}
	
	int count = 0;
	for(int i = 0; i < N; i++){
		if(P[i] <= M[i]){
			count++;
		}
	}
	
	printf("%d\n", count);
	
	return 0;
}

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

using namespace std;

int main (){

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif


	cin.tie(0);
	ios::sync_with_stdio(false);


	int n,b;
	cin>>b;

	n=b%10;
	if (n==2 || n==4 || n==5 || n==7 ||n==9)
		cout<<"hon\n";
		

	else if (n==1||n==0||n==6||n==8) cout<<"pon\n";

	else cout<<"bon\n";
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int INF = 2e9;
const ll INFLL = 4e18;
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
string s[7];
bool row_inc[7];
bool col_inc[7];
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	int k,h,w;
	cin >> h >> w >> k;
	for(int i = 0; i < h; i++) cin >> s[i];
	int ans=0,calc;
	for(int i = 0; i < (1<<h); i++){
		for(int j = 0; j < (1<<w); j++){
			calc=0;
			int x=i;
			for(int k = 0; k < h; k++){
				row_inc[k]=(x&1);
				x>>=1;
			}
			x=j;
			for(int k = 0; k < w; k++){
				col_inc[k]=(x&1);
				x>>=1;
			}
			for(int k = 0; k < h; k++){
				for(int l = 0; l < w; l++){
					if((row_inc[k])&&(col_inc[l])&&(s[k][l]=='#')) calc++;
				}
			}
			if(calc==k) ans++;
		}
	}
	cout << ans;
	return 0;
}

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

int main() {
    string A;
    cin>>A;
    vector<char> arr;
    map<char, long> map;
    for(int i=0;i<A.size();++i){
        if(map[A[i]]==0)arr.push_back(A[i]);
        map[A[i]]++;
    }
    long ans = A.size()*(A.size()-1)/2;
    for(int i=0;i<arr.size();++i){
        ans -= map[arr[i]]*(map[arr[i]]-1)/2;
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	ps := Primes(55555)

	i := 0
	as := make([]int, n)
	for _, p := range ps {
		if p%5 == 1 {
			as[i] = p
			i++
		}
		if i == n {
			break
		}
	}

	fmt.Print(as[0])
	for i := 1; i < n; i++ {
		fmt.Print(" ", as[i])
	}
	fmt.Println()
}

func Primes(max int) []int {
	primes := make([]int, 0)
	isNotPrime := make([]bool, max+1)
	isNotPrime[0] = true
	isNotPrime[1] = true
	n := 2
	for ; n*n <= max; n++ {
		if !isNotPrime[n] {
			primes = append(primes, n)
			for m := 2; n*m <= max; m++ {
				isNotPrime[n*m] = true
			}
		}
	}
	for ; n <= max; n++ {
		if !isNotPrime[n] {
			primes = append(primes, n)
		}
	}
	return primes
}


Measured memory_bytes: 896