akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
  ll n,m;
  cin >> n >> m;
  
  ll l[m],r[m];
  rep(i,m) cin >> l[i] >> r[i];
  
  ll left = 0, right = n;
  rep(i,m)
  {
    if(l[i] > left)
    {
      left = l[i];
    }
    if(r[i] < right){
      right = r[i];
    }
  }
  
  if(right - left < 0)
  {
    cout << 0 << endl;
  }else{
    cout << right - left + 1 << endl;
  }
  
}

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<max((ll)0,c-(a-b));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=16;
int dp[1<<N],a[N][N],n;
int calc(int s)
{
	int sum=0;
	for(int i=0;i<n;i++)
	{
		if(!(s&(1<<i)))
			continue;
		for(int j=i+1;j<n;j++)
			if(s&(1<<j))
				sum+=a[i][j];
	}
	return sum;
}
int dfs(int s)
{
	if(dp[s]!=-1)
		return dp[s];
	if(s==0)
		return dp[s]=0;
	dp[s]=0;
	int p;
	for(int i=0;i<n;i++)
	{
		if(s&(1<<i))
		{
			p=i;
			break;
		}
	}
	for(int t=s;t;t=s&(t-1))
	{
		int nt=t|(1<<p);
		dp[s]=max(dp[s],calc(nt)+dfs(s^nt));
	}
	return dp[s];
}
main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>a[i][j];
	memset(dp,-1,sizeof(dp));
	cout<<dfs((1<<n)-1)<<endl;
	return 0;
}

Measured memory_bytes: 896
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll t=in();
    if(t==0){
        cout<<0<<endl;
    }else{
        ll ans=t/3+(t%3==0?2:t%3);
        ll num_of=(t-1)/3;
        while(num_of>=5){
            num_of=(num_of-2)/3;
            ans-=num_of*2;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int M=1e5+10;
typedef pair<int,int> P;
int n,m;
P a[M];
bool cmp(P x,P y){
    if(x.fi==y.fi) return x.se>y.se;
    return x.fi<y.fi;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d%d",&a[i].fi,&a[i].se);
    sort(a,a+n,cmp);
    priority_queue<int> q;
    int now=0,ans=0;
    for(int i=1;i<=m;i++)
    {
        while(now<n && a[now].fi<=i) q.push(a[now].se),now++;
        //printf("%d\n",q.top());
        if(!q.empty())
        {
            ans+=q.top();
            q.pop();
        }
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 1660
import sys


def input():
    return sys.stdin.readline()[:-1]


# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))

n, k = map(int, input().split())
s = str(input())
l = str(1)
for i in range(n):
    if i == k - 1:
        l += s[i].lower()
    else:
        l += s[i]
print(l[1:])

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int rec(int n){
    if(n==1) return 0;
    if(n==2) return 1;

    if(n%3){
        return rec(n/3+1)+1;
    }else{
        return rec(n/3)+1;
    }
}

int main(){
    int N;
    cin>>N;
    cout<<rec(N)<<endl;

    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return vec<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec


using namespace std;

string solve() {
    ll n, m;
    cin >> n >> m;
    vec<pll> sc(m);
    for (auto &&e : sc) {
        ll s, c;
        cin >> s >> c;
        e = pll(s - 1, c);
    }
    for (ll i = 0; i <= 1e4; i++) {
        string s = to_string(i);
        if (s.size() != n) continue;
        bool ok = true;
        for (auto &&e : sc) {
            ll j, c;
            tie(j, c) = e;
            ll n = s[j] - '0';
            if (n != c) ok = false;
        }
        if (ok) return s;
    }
    return "-1";
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = [0]*k
a = [[] for _ in range(k)]
for i in range(k):
    d[i] = int(input())
    a[i] = list(map(int, input().split()))
sunuke = [0]*n
print()
for i in range(k):
    for j in range(d[i]):
        for r in range(n):
            if r == a[i][j]-1:
                sunuke[r] += 1
print(sunuke.count(0))


Measured memory_bytes: 67996
#include <stdio.h>
#include <array>

constexpr int N = 8;
constexpr int inf = 2e9;
std::array<int, N> A;

int main(void){
    int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c);
    for(int i = 0; i < n; ++i) scanf("%d", &A[i]);
    int N = (1 << n) << n;
    int res = inf;
    for(int i = 0; i < N; ++i){
        int val = i;
        int aa = 0, cna = 0,
            bb = 0, cnb = 0,
            cc = 0, cnc = 0;
        for(int j = 0; j < n; ++j){
            int d = val & 3; val >>= 2;
            switch(d){
                case 1: aa += A[j]; cna++; break;
                case 2: bb += A[j]; cnb++; break;
                case 3: cc += A[j]; cnc++; break;
            }
        }
        if(cna == 0 or cnb == 0 or cnc == 0) continue;
        int cost = (a > aa ? a - aa : aa - a) + (b > bb ? b - bb : bb - b) + (c > cc ? c - cc : cc - c);
        cost += 10 * (cna + cnb + cnc - 3);
        if(cost < res) res = cost;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 128
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#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...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  vector<int> vec;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> v;
    vec.pb(v);
  }
  sort(allr(vec));
  ll ans = vec[0];
  int ind = 1;
  for (int i = 1; ind < n - 1; i++) {
    if (ind + 1 == n - 1) {
      ans += vec[i];
    } else {
      ans += vec[i] * 1ll * 2;
    }
    ind += 2;
  }  
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  char S[100000], T[100000];
  scanf("%s%s", S, T);
  
  // 最大公約数を計算
  int g = gcd(N, M);
  int stepS = N / g;
  int stepT = M / g;
  for (int i = 0; i < g; ++i) {
    if (S[stepS * i] != T[stepT * i]) {
      printf("-1");
      return 0;
    }
  }
  printf("%lld", 1ll * N / g * M);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define M 1000000007
//#define M 998244353
const int inf=4e18;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int k,a,b;cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK\n";
			return 0;
		}
	}
	cout<<"NG\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    int ans = 0;
    rep(i, 0, 6){
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
    return 0;
}
 


Measured memory_bytes: 256
K = int(input())

lunlun = [[0] * 10 for _ in range(10)]

for i in range(10):
    lunlun[0][i] = 1
for i in range(1, 10):
    for j in range(10):
        if j != 0 and j != 9:
            lunlun[i][j] = lunlun[i-1][j-1] + lunlun[i-1][j] + lunlun[i-1][j+1]
        if j == 0:
            lunlun[i][0] = lunlun[i-1][0] + lunlun[i-1][1]
        if j == 9:
            lunlun[i][9] = lunlun[i-1][8] + lunlun[i-1][9]

count = 0
digit = 0
ans = 0
k = 0
for i in range(10):
    for j in range(1, 10):
        if count + lunlun[i][j] < K:
            count += lunlun[i][j]
        else:
            k = K - count
            ans = j * (10 ** i)
            digit = i
            last_digit = j
            break
    if ans != 0:
        break

while(digit > 0):
    digit -= 1
    count = 0
    if last_digit != 0:
        if count + lunlun[digit][last_digit-1] < k:
            count += lunlun[digit][last_digit-1]
        else:
            k = k - count
            ans += (last_digit-1) * (10 ** digit)
            last_digit = last_digit - 1
            continue
    if count + lunlun[digit][last_digit] < k:
        count += lunlun[digit][last_digit]
    else:
        k = k - count
        ans += last_digit * (10 ** digit)
        last_digit = last_digit
        continue
    if last_digit != 9:
        if count + lunlun[digit][last_digit+1] < k:
            count += lunlun[digit][last_digit+1]
        else:
            k = k - count
            ans += (last_digit+1) * (10 ** digit)
            last_digit = last_digit + 1
            continue


print(ans)


Measured memory_bytes: 38480
#include <iostream>
using namespace std;
// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long A, long long B){
    if (A - B * 2 >= 0) print(A - B * 2);
    else print(0);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
bool selector(int a,int b){
	if(a>b)
		return true;
	return false;
}
int main(){
	int n;
	int kcost,kcal;
	int cost;
	int *cal;
	int max=0;

	scanf("%d",&n);
	cal = new int [n];
	scanf("%d %d",&kcost,&cost);
	scanf("%d",&kcal);
	for(int i=0;i<n;i++){
		scanf("%d",&cal[i]);
	}
	sort(cal,cal+n,selector);
	for(int i=0;i<n;i++){
		int scal=kcal;
		int scost=kcost;
		for(int j=0;j<=i;j++){
			scal+=cal[j];
		}
		scost += (i+1)*cost;
		if(scal/scost>max){
			max=scal/scost;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 1040
from sys import stdin
import heapq

N, M = [int(x) for x in stdin.readline().rstrip().split()]
B = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(M)]

graph = [[] for _ in range(N)]
for i in range(1, N):
    graph[i].append((0, i - 1))
for m in B:
    graph[m[0] - 1].append((m[2], m[1] - 1))

d = [(0, 0)]
distance = [10 ** 15] * N
distance[0] = 0
color = ['white'] * N
heapq.heapify(d)

while len(d) > 0:
    temp, u = heapq.heappop(d)
    color[u] = 'black'
    if distance[u] < temp:
        continue
    for v in graph[u]:
        if color[v[1]] != 'black':
            if distance[u] + v[0] < distance[v[1]]:
                distance[v[1]] = distance[u] + v[0]
                color[v[1]] = 'gray'
                heapq.heappush(d, (distance[v[1]], v[1]))

if distance[N - 1] == 10 ** 15:
    print(-1)
else:
    print(distance[N - 1])

Measured memory_bytes: 89308
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;

int main(){
    cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    ll mon=1000;
    ll stock=0;

    rep(i,0,n){
        if(i<n-1){
            if(a[i]<a[i+1]){
                if(mon>=a[i]){
                    stock+=mon/a[i];
                    ll now=mon/a[i];
                    mon-=now*a[i];
                }
                
            }
            else if(a[i]>a[i+1]){
                mon+=stock*a[i];
                stock=0;
            }
        }
        else mon+=stock*a[i];
        //cout<<mon<<"\n";
    }
    cout<<mon<<"\n";
    return 0;
}


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

int main()
{
  int rate;

  cin >> rate;

  if(rate < 1200)
  {
    cout << "ABC" << endl;
  }
  else if(rate < 2800 && rate >= 1200)
  {
    cout << "ARC" << endl;
  }
  else
  cout << "AGC" << endl;
}


Measured memory_bytes: 3620
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	char ch;
	
	cin >> ch;
	
	ch++;
	
	cout << ch << endl;
	
	return 0;
} 

Measured memory_bytes: 256
import os
import math

def main():
    num = int(input())
    x_list = list(map(int, input().split()))
    min_num = 10**10    
    for i in range(100):
        result = 0  
        for j in x_list:
            result += pow((i - j), 2)
        
        if result < min_num:
            min_num = result
    print(min_num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
def main():
    n,k=map(int,input().split())
    h=sorted(int(input()) for _ in range(n))
    hs = []
    for i in range(n-k+1):
        hs.append(h[i+k-1] - h[i])
    print(min(hs))
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 16968
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

int a, b, i, vis[N], tab[N], d, w, ind, fa[N], n, m, pos[N];
VI graf[N], back[N];

void dfs(int w) {
	vis[w] = 1;
	for (auto& w2 : graf[w]) if (!vis[w2]) dfs(w2);
	tab[d++] = w;
}

int main() {
scanf("%d %d", &n, &m);
for (i=1;i<=n;i++) {
	graf[i].clear();
	back[i].clear();
	vis[i] = 0;
}
for (i=0;i<n + m - 1;i++) {
	scanf("%d %d", &a, &b);
	graf[a].pb(b);
	back[b].pb(a);
}
d = 0;
for (i=1;i<=n;i++) if (!vis[i]) dfs(i);
for (i=d-1;i>=0;i--) {
	w = tab[i];
	ind = 0;
	for (auto& w2 : back[w]) if (ind == 0 || pos[w2] < pos[ind]) ind = w2;
	pos[w] = i;
	fa[w] = ind;
}
for (i=1;i<=n;i++) printf("%d\n", fa[i]);
return 0;
}

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

using namespace std;

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

  vector <vector<int>> mapping(10, vector<int>(10));
  for (int i = 1; i <= n; i++)
  {
    int num_digit = std::to_string(i).length();
    int head = i / (int) pow(10, num_digit - 1);
    int tail = i % 10;
    mapping[head][tail]++;
  }


  long cnt = 0;
  for (int i = 1; i <= n; i++)
  {
    int num_digit = std::to_string(i).length();
    int head = i / (int) pow(10, num_digit - 1);
    int tail = i % 10;
    cnt += mapping[tail][head];
  }

  cout << cnt << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main() {
	int N;
	int i;
	int a, b, c;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if (a > b && a > c) {
			if (a * a == b * b + c * c)
				printf("YES\n");
			else
				printf("NO\n");
		} else if (b > a && b > c) {
			if (b * b == a * a + c * c)
				printf("YES\n");
			else
				printf("NO\n");
		} else {
			if (c * c == a * a + b * b)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
	return 0;
}


Measured memory_bytes: 580
n, m = map(int, input().split()) #n:問題数 ,m:提出回数

check_ac = [0]*n #ACかどうか
cnt_wa = [0]*n #WAの回数

for i in range(m):
    p, s = map(str, input().split())
    p = int(p)-1
    if s == "AC": #正解
        if check_ac[p]==0:
            check_ac[p] = 1
    else:
        if not check_ac[p]:
            cnt_wa[p] += 1

for i in range(n):
    if not check_ac[i]:
        cnt_wa[i]=0

print(sum(check_ac), sum(cnt_wa))


Measured memory_bytes: 4596
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N; cin >> N;
    cout << N*(N+1)/2 << endl;
    return 0;
}

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

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

int main(){
    vector<vector<int>> c(3, vector<int>(3,0));

    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
    int d1, d2;
    for(int i=0;i<3;i++){
        if(i==0){
            d1 = c[i][0] - c[i][1];
            d2 = c[i][1]-c[i][2];
        }else{
            if(d1 != c[i][0] - c[i][1]){
                cout << "No" << endl;
                return 0;
            }
            if(d2 != c[i][1] - c[i][2]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,i,j;
int main(){
	while(1) {
		cin >> n >> i >> j;

		if(n == 0)
			break;
		i--;j--;
		char ans[1000];
		ans[n] = '\0';

		RREP(k,n) {
			//cout << i << " " << j << endl;
			if((i ^ j) & 1) {
				ans[k] = 'R';
			}else {
				ans[k] = 'L';
			}

			if(i < (1ll << k)) {
				i = (1ll << k) - i - 1;
			}else{
				i -= (1ll << k);
			}
			j /= 2;
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3024
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	list<int> b;
	rep(i, n) {
		int t;
		cin >> t;
		b.push_back(t);
	}

	deque<int> ans;
	while (!b.empty()) {
		int num = b.size() - 1;
		
		bool ok = false;
		for (auto itr = b.rbegin(); itr != b.rend(); ++itr) {
			if (*itr == num + 1) {
				ans.push_front(*itr);
				b.erase((++itr).base());
				ok = true;
				break;
			}

			--num;
		}

		if (!ok) {
			cout << -1 << "\n";
			return 0;
		}
	}

	while (!ans.empty()) {
		cout << ans.front() << "\n";

		ans.pop_front();
	}

	return 0; 
}


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

int main(){
    int n;
    long long zmi=2e9,zma=-2e9,wmi=2e9,wma=-2e9;
    cin>>n;
    while(n--){
	    long long x,y;
	    cin>>x>>y;
	    zmi=min(zmi,x+y);
	    zma=max(zma,x+y);
	    wmi=min(wmi,x-y);
	    wma=max(wma,x-y);
    }
    cout<<max(zma-zmi,wma-wmi)<<"\n";
}




Measured memory_bytes: 3576
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll kobai(ll a,ll b){
    ll k;
    if(a%b==0){
        k=a;
    }else if(b%a==0){
        k=b;
    }else{
        if(b>a){
            swap(a,b);
        }
        ll aa=a;
        while(true){
            a+=aa;
            if(a%b==0){
                k=a;
                break;
            }
        }
    }
    
    return k;
}


int main(){
    
    int n;
    cin>>n;
    vector<ll> td(n);
    rep(i,n){
        cin>>td[i];
    }
    
    sort(td.begin(),td.end());
    ll pre=td[0];
    for(int i=1;i<n;i++){
        pre=kobai(pre,td[i]);
    }
    cout<<pre<<endl;
    
    
    
    
    

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<10)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<2*n<<endl;
    return 0;
}


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

int main() {
  int N;
  int L;
  int R;
  int Total = 0;
  
  cin >> N;

  for(int i = 0; i < N; i++){
	cin >> L >> R;
    
    Total = Total + ( R - L + 1 );
  }
    
  cout << Total << endl;
    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  vector<int> alpha(26, 0);
  string s;
  while (getline(cin, s)){
  rep(i, s.size()){
    char c = s[i];
    if ('a' <= c && c <= 'z') alpha[c - 'a']++;
    if ('A' <= c && c <= 'Z') alpha[c - 'A']++;
  }
  }
  rep(i, 26){
    cout <<(char)(i + 'a') <<" : " <<alpha[i] <<endl;
  }
}



Measured memory_bytes: 3160
N,Q=map(int,input().split())
S=input()
A=[0]*(N+1)
C=[0]*(N+1)
for i in range(N-1):
  if S[i:i+2]=='AC':
    A[i+1]=1
    C[i+2]=1
import itertools
A=list(itertools.accumulate(A))
C=list(itertools.accumulate(C))
for q in range(Q):
  l,r=map(int,input().split())
  print(C[r]-A[l-1])

Measured memory_bytes: 12540
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL a,b,i,j,k,m,n,s,sz,t,u,w[200040],z[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)
	{
		cin>>z[i];
		w[z[i]]++;
	}
	for(i=0;i++<n;)
	{
		s+=w[i]*(w[i]-1)/2;
	}
	for(i=0;i++<n;)
	{
		cout<<s-w[z[i]]*(w[z[i]]-1)/2+(w[z[i]]-1)*(w[z[i]]-2)/2<<endl;
	}
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
//#define all(v) v.begin(), v.end()
//bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
//bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
//const ll MAX_N=500010;
ll a, b, c, d, e, f, h, k, l, m, n, p, q, r, t, w, x, y, z, ans;
int main() {
  string S;
  cin >> S;
  if(S=="hi"||S=="hihi"||S=="hihihi"||S=="hihihihi"||S=="hihihihihi") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main() {
	// your code goes here
int a,n,min,max;
cin>>n;
long long sum ;
min=2147483467;
max=-2147483467;
sum=0;
for(int i=1;i<=n;i++){
	cin>>a;
    if(min>a){
		min=a;
    }
	    if(max<a){
	  	max=a;
	   	}
	   	sum+=a;
}
cout<<min<<" "<<max<<" "<<sum<<endl;

	return 0;
}

Measured memory_bytes: 3124
# edpc b

import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7

# ここから書き始める
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [INF] * n
dp[0] = 0
for i in range(1, n):
    for j in range(1, k + 1):
        if 0 <= i - j < n:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
print(dp[n - 1])




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

using namespace std;

int main(int argc, char const *argv[]) {
	int n,h,tempa,tempb;
	std::cin >> n >> h;
	std::vector<int> a;
	std::vector<int> b;
	for (size_t i = 0; i < n; i++) {
		std::cin >> tempa >> tempb;
		a.push_back(tempa);
		b.push_back(tempb);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());

	int counter = 0;
	// 投げつけるだけで殺せるパターン
	for (size_t i = 0; i < b.size(); i++) {
		// 剣を振ったときの攻撃力より高いやつだけを投げる
		if (a[0] > b[i]) {
			break;
		}
		if (h <= 0) {
			std::cout << counter << '\n';
			return 0;
		}
		h -= b[i];
		counter++;
	}
	if (h <= 0) {
		std::cout << counter << '\n';
		return 0;
	}
	counter = counter + (h / a[0]);
	if (h % a[0] != 0) {
		counter++;
	}
	std::cout << counter << '\n';
	return 0;
}


Measured memory_bytes: 1276
#include <set>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string S; int n;
    
    set<string> T;
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> S;
        
        if(i % 20 == 0 || i % 20 == 1 || i % 20 == 2)
        {
            printf("1\n");
        }
        else if(i % 20 == 4)
        {
            printf("72\n");
        }
        else if(i % 20 == 5)
        {
            printf("420\n");
        }
        else
        {
            T.clear();
            
            for(int j = 1; j < S.size(); j++)
            {
                string A = S.substr(0, j);
                string B = S.substr(j, S.size() - j);
                
                string C = A; reverse(C.begin(), C.end());
                string D = B; reverse(D.begin(), D.end());
                
                T.insert(A + B);
                T.insert(B + A);
                T.insert(A + D);
                T.insert(D + A);
                T.insert(C + B);
                T.insert(B + C);
                T.insert(C + D);
                T.insert(D + C);
            }
            
            printf("%d\n", T.size());
        }
    }
    
    return 0;
}

Measured memory_bytes: 3396
#include<bits/stdc++.h>
int a[100005];

int main(){
	int n,x;
  	scanf("%d",&n);
  for(int i=1;i<=n;i++){
  	scanf("%d",&x);
    a[x]=i;
  }
  for(int i=1;i<=n;i++){
  	printf("%d ",a[i]);
  }
}


Measured memory_bytes: 1152
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    ll n;
    cin>>n;
    if(n<=26)
    {
        char ans=n+'a'-1;;
        cout<<ans;
    }
  else
  {
    string s="";
    while(n>=1)
    {
        ll temp=n%26;
        if(temp==0)
        {
            temp=26;
        }
        s+='a'+temp-1;
        n=n/26;
        if(temp==26)
        {
            n--;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
  }
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int h,w;
    while(cin >> h >> w, h||w){
        rep(i,h){
            rep(j,w){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
using System;
using System.Linq;
using System.Collections.Generic;


namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] abk = sc.intarr;
            int a = abk[0];
            int b = abk[1];
            int k = abk[2];

            if(a==b)
            {
                wr.wri(a);
                return;
            }

            if((b - a + 1)/2 < k)
            {
                for(int i=a; i<=b; i++)
                {
                    wr.wri(i);
                }
                return;
            }
            List<int> ans = new List<int>();

            for (int i = 0; i < k; i++)
            {
                ans.Add(a + i);
            }

            for (int i = k - 1; i >= 0; i--)
            {
                ans.Add(b - i);
            }

            foreach (var num in ans)
            {
                wr.wri(num);
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back

using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[2][n];
	int sum1[n]={0};
	int sum2[n]={0};
	
	for(int i=0;i<2;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	sum1[0]=a[0][0];
	sum2[0]=a[1][0];
	
	for(int i=1;i<n;i++)
	{
		sum1[i]=sum1[i-1]+a[0][i];
	}
	for(int i=1;i<n;i++)
	{
		sum2[i]=sum2[i-1]+a[1][i];
	}
	
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ll k=sum1[i]+sum2[n-1]-sum2[i-1];
		if(k>ans)ans=k;
	}
	
	cout<<ans<<endl;
}


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

int main(){
  int N,K,C;
  string schedule;
  cin >> N >> K >> C >> schedule;

  vector<int> before(N); // [0,i)で働ける日数のmax
  vector<int> after(N);  // (i,N)で働ける日数のmax

  for(int i=1; i<N; i++){
    int id_prev= max((i-1)- C, 0);
    before.at(i)= (schedule.at(i-1)=='o') ? max(before.at(i-1), before.at(id_prev)+ 1)
                                          : before.at(i-1);
  }
  for(int i=N-2; i>=0; i--){
    int id_prev= min((i+1)+ C, N-1);
    after.at(i)= (schedule.at(i+1)=='o') ? max(after.at(i+1), after.at(id_prev)+ 1)
                                         : after.at(i+1);
  }

  for(int i=0; i<N; i++){
    if(before.at(i)+ after.at(i) < K){
      cout << i+1 << endl;
    }
  }
}

Measured memory_bytes: 3332
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	string s;
	while (getline(cin, s)) {
		if (s == "END OF INPUT")return 0;
		int num = 0;
		for (int i = 0; i < s.size(); i++){
			if (s[i] == ' ') {
				cout << num;
				num = 0;
			}
			else if (i == s.size() - 1){
				cout << num + 1;
			}
			else num++;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3152
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = sum(B)
for i, a in enumerate(A):
    if i >= len(A) - 1:
        break
    if a + 1 == A[i+1]:
        ans = ans + C[a-1]
print(ans)

Measured memory_bytes: 9056
R, G, B, N = [int(x) for x in input().split()]
 
l = [R, G, B]
l.sort()
low, mid, top = l[0], l[1], l[2]
count = 0
for a in range(N//top + 1):
  temp = N - a * top
  for b in range(temp//mid + 1):
    temp_2 = temp - b * mid
    if temp_2 % low == 0:
      count += 1
print(count)

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

int main() {
 string S, T;
 int count, ans;
 cin >> S >> T;
count = 0;
  ans = 0;
int a, b;
a = S.size();
b = T.size();
 for(int i = 0; i < a - (b -1); i++){
   for (int j = 0; j < b; j++){

   
    if (S[i+j] == T[j] ){
      count++;
    }
    
    
    }

   if(count > ans){
     ans = count;
   }
    count=0;
  }

  cout << b - ans << endl;

   } 
  
 




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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[1010][1010];
string s[1010];

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

  ll h,w;
  cin>>h>>w;
  REP(i,h)cin>>s[i];

  dp[0][0]=1;
  REP(i,h){
    REP(j,w){
      if(s[i][j]=='.'){
        dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
        dp[i][j+1]=(dp[i][j]+dp[i][j+1])%MOD;
      }
    }
  }

  cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 9216
N = int(input())
num = [0,0,0,0]
# AC, WA, TLE, RE
for i in range(N):
  S = input()
  if(S == "AC"):
    num[0] += 1
  elif(S == "WA"):
    num[1] += 1
  elif(S == "TLE"):
    num[2] += 1
  else:
    num[3] += 1

print("AC x %d"%num[0])
print("WA x %d"%num[1])
print("TLE x %d"%num[2])
print("RE x %d"%num[3])

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

#define rep(i, ss, ee) for (int i = ss; i < ee; ++i)
using namespace std;

int k;
void input() { cin >> k; }

void exit_end(int ans) {
  cout << ans << endl;
  exit(0);
}

//set version
void solve() {
  set<int> s;
  if (k % 2 == 0) exit_end(-1);
  int x = 7 % k;
  int i = 1;
  while (s.count(x) == 0) {
    if (x == 0) exit_end(i);
    s.emplace(x);
    x = (x * 10 + 7) % k;
    i++;
  }
  exit_end(-1);
}

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

Measured memory_bytes: 50448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(string s){
	ll l = 0, r = s.length()-1, res = 0;
	while (r-l>0) {
		if (s[l] == 'x' && s[r] != 'x') {
			l++;
			res++;
		} else if (s[l] != 'x' && s[r] == 'x') {
			r--;
			res++;
		} else if (s[l] == s[r]) {
			l++;
			r--;
		} else {
			res = -1;
			break;
		}
		// cout << l << " " << r << endl;
		// cout << s[l] << " " << s[r] << endl;
	}
	cout << res << endl;
	
}

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



Measured memory_bytes: 512
/**
 * C - Attack Survival
 * https://atcoder.jp/contests/abc141/tasks/abc141_c
 **/
#include<iostream>

using namespace std;

const int MAX_N = 100000;
const int MAX_Q = 100000;

int N, K, Q, W[MAX_N+1], A[MAX_Q+1];

void solve() {
    for(int i=1; i<Q+1; i++) {
        W[A[i]] += 1;
    }
    for(int j=1; j<N+1; j++) {
        if(Q-W[j]<K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return;
}

int main() {
    cin >> N >> K >> Q;
    for (int i=1; i<Q+1; i++) {
        int tmp;
        cin >> tmp;
        W[tmp] += 1;
    }
    for(int j=1; j<N+1; j++) {
        if(Q-W[j]<K) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}

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

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

int main(){
 int n,a,b;
 cin >> n;
 cin >> a;
 for(int i=0;i<n-1;i++){
   cin >> b;
   a=gcd(a,b);
 }
 cout << a << endl;
}

Measured memory_bytes: 256
package main

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

// go run ./ABC168/A\ -\ ∴\ \(Therefore\)/main.go < in

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var inputLastStr string
	for i := 0; i <= 0; i++ {
		sc.Scan()
		inputs := strings.Split(sc.Text(), "")
		inputLastStr = inputs[len(inputs)-1]
	}
	input, _ := strconv.Atoi(inputLastStr)

	judge(input)
}

func judge(callTarget int) {
	if callTarget == 2 || callTarget == 4 || callTarget == 5 || callTarget == 7 || callTarget == 9 {
		fmt.Println("hon")
	} else if callTarget == 0 || callTarget == 1 || callTarget == 6 || callTarget == 8 {
		fmt.Println("pon")
	} else if callTarget == 3 {
		fmt.Println("bon")
	}
}


Measured memory_bytes: 1756
#include <iostream>

int main () {
    int a,b;
    std::cin >> a >> b;
    if (a < b){
        std::cout << "a < b" << std::endl;
    }
    if (a > b){
        std::cout << "a > b" << std::endl;
    }
    if (a == b){
        std::cout << "a == b" << std::endl;
    }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int M,D;
    cin>>M>>D;
    int count = 0;
    for(int i = 1;i<= M;i++){
        for(int j = 1;j<= D;j++){
            int d1,d10;
            d1 = j%10;
            d10 = j/10;
            if(i==d1*d10 && d1>=2 && d10>=2){
                count++;
            }
        }
    }
    cout<<count<<endl;
}




Measured memory_bytes: 3628
H, W = map(int, input().split())

# 番兵
grid = [["."] + list(input()) + ["."] for _ in range(H)]
grid = ["."*(W+2)] + grid + ["."*(W+2)] # 上下に番兵

for i in range(1, H+1):
  for j in range(1, W+1):
    if grid[i][j] == ".":
      continue
    if grid[i][j-1] == grid[i][j+1] == grid[i+1][j] == grid[i-1][j] == ".":
      print("No")
      exit()
print("Yes")      
      

Measured memory_bytes: 3064
S = input()

if S=="SUN":
	print(7)
elif S=="MON":
	print(6)
elif S=="TUE":
	print(5)
elif S=="WED":
	print(4)
elif S=="THU":
	print(3)
elif S=="FRI":
	print(2)
elif S=="SAT":
	print(1)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

#define int long long

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    
    cin >> n;
    
    map<int, int> m;
    
    int in, sum = 0;
    
    int ans = 0;
    m[0] = 1;
    for(int i = 0; i < n; ++i)
    {
        cin >> in;
        sum += in;
        ans += m[sum]++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 12800
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  for (let i = 97; i <= 122; i++) {
    const char = String.fromCodePoint(i);

    if (!S.includes(char)) {
      return char;
    }
  }

  return "None";
};

console.log(main(read()));


Measured memory_bytes: 29736