akhauriyash/Code-Regression huggingface dataset:
import sys
from itertools import accumulate
from collections import defaultdict

n, m, *a = map(int, sys.stdin.read().split())

def main():
    cumsum = list(accumulate(a))
    c = defaultdict(int)
    for s in cumsum:
        c[s % m] += 1

    res = 0
    res += c[0]
    for v in c.values():
        res += (1 + v - 1) * (v - 1) // 2
    
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 17548
from sys import stdin
input = stdin.readline
import copy as cp
from collections import deque

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

def Decimal(x):
  print("{0:.10f}".format(x))

class Pair:
  def __init__(self, x=0, y=0):
    self.first = x
    self.second = y

  def __repr__(self):
    return '{0} {1}'.format(self.first, self.second)

  def __lt__(self, pi):
    return self.first < pi.second

def POW(x, n):
  ret = 1
  while n:
    if n&1:
      ret *= x
    x *= x
    n >>= 1
  return ret

def Block(s):
  num = 1
  v1 = []
  v2 = []
  for i in range(len(s)):
    c = s[i]
    if i == 0:
      v1.append(c)
    elif c == s[i-1]:
      num += 1
    else:
      v2.append(num)
      v1.append(c)
      num = 1

    if i == len(s)-1:
      v2.append(num)
  return v1, v2

S = input().rstrip()
chs, num = Block(S)

print(len(chs)-1)






Measured memory_bytes: 51568
#include<stdio.h>


int main(void){
	
	double v;
	
	
	while(scanf("%lf", &v) != EOF){
		double t = v/9.8;
		double y = 4.9*t*t;
		int n = 1;
		while(1){
			if( y <= n*5-5 ){
				printf("%d\n", n);
				break;
			}
			n++;
		}
	}
	
	return 0;
}

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

using namespace std;
using ll = long long;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, M;
vector<vector<int>> v;
int dp[112345];

void init()
{
	cin >> N >> M;
	v.RS(N, vector<int>(0));
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		v[x].PB(y);
	}
	rep(i, 112345) {
		dp[i] = -1;
	}
}

int dfs(int x)
{
	int& res = dp[x];
	if (res != -1) return res;
	res = 0;
	for (int n : v[x]) {
		res = max(res, dfs(n) + 1);
	}
	return res;
}

void solve()
{
	int res = 0;
	rep(i, N) {
		res = max(res, dfs(i));
	}
	cout << res << endl;
}





Measured memory_bytes: 7936
#include<stdio.h>
int main(void)
{
	int n,m,i;
	scanf("%d %d %d",&n,&m,&i);
	if(n==0&&m==1&&i==0||n==1&&m==0&&i==0) printf("Close\n");
	else if(n==1&&m==1&&i==0||n==0&&m==0&&i==1) printf("Open\n");
	else if(n==0&&m==0&&i==0) printf("Close\n");
	return 0;
}


Measured memory_bytes: 2628
#include <stdio.h>
int main () {
  int x, i, j, n;
  scanf("%d", &x);
  for (i=1; i<=x; i++) {
    if (i%3 == 0) {
      printf(" %d", i);
    } else  {
      n = i;
      while (n>0) {
        if (n%10 == 3) {
          printf(" %d", i);
          break;
        }
        n = n/10;
      } 
    }
  }
  printf("\n");

  return 0;
}

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

const int maxn = 100010;
int n, m, dep[maxn];
bool vis[maxn];
vector<int> G[maxn];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1, u, v; i <= m; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    long long s1 = 0, s2 = 0, s3 = 0;
    vector<int> V1, V2;
    for (int i = 1; i <= n; i++) if (!vis[i]) {
        dep[i] = 1;
        int sz = 0, flag = 0;
        function<void(int)> dfs = [&](int v) {
            vis[v] = 1, sz++;
            for (int u : G[v]) {
                if (!vis[u]) dep[u] = dep[v] + 1, dfs(u);
                else if (!(dep[v] - dep[u] & 1)) flag = 1;
            }
        };
        dfs(i);
        if (sz == 1) { s3++; continue; }
        if (!flag) s1++;
        else s2++;
    }
    long long ans = 0;
    ans += 2 * s3 * n - s3 * s3;
    ans += 2 * s1 * s1 + s1 * s2;
    ans += s2 * (s1 + s2);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 16360
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];
    auto ss = new bool[](N);
    foreach (_; 0..K) {
        readln;
        foreach (i; readln.split.to!(int[])) ss[i-1] = true;
    }
    int r;
    foreach (s; ss) if (!s) ++r;
    writeln(r);
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
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(){
  char c;
  cin >> c;
  int m = c - 'A';
  if(0 <= m && m <= 26) cout << "A" << endl;
  else cout << "a" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

int main() {
    std::string S;
    std::cin >> S;
    S[3] = '8';
    std::cout << S << std::endl;
    return 0;
}


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

int main()
{
	int n, m;
	
	scanf("%d %d", &n, &m);
	
	int S = m;
	bool f = false;
	
	for (int i = 0; i < n; i++){
		int in, out;
		
		scanf("%d %d", &in, &out);
		m += in;
		m -= out;
		
		S = max(S, m);
		
		if (m < 0){
			f = true;
		}
	}
	
	if (f){
		puts("0");
	}
	else {
		printf("%d\n", S);
	}
	
	return 0;
}

Measured memory_bytes: 1024
n, m = gets.chomp.split.map(&:to_i)
hs = gets.chomp.split.map(&:to_i)
abs = m.times.map { gets.chomp.split.map(&:to_i) }

paths = []
n.times { paths << [] }

abs.each do |a, b|
    paths[a-1] << b-1
    paths[b-1] << a-1
end

gs = []
paths.each_with_index do |others, i|
    h = hs[i]
    g = true
    others.each do |x|
        if hs[x] >= h
            g = false
            break
        end
    end
    gs << i if g
end

puts gs.count


Measured memory_bytes: 31248
#include "bits/stdc++.h"

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

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

void Main() {
  int n, m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

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



Measured memory_bytes: 256
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define LOG
#define PRINT
#define LCERR
#include <iostream>
auto optimize_cpp_stdio = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
    return 0;
}();
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:

private:

};

int solve() {
    Solution solution;
    // handle IO here
    int N;
    cin >> N;
    vector<int> nums(N);
    for (int i = 0; i < N; ++i) {
        cin >> nums[i];
    }
    int misplaced_cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (nums[i] != i + 1) {
            misplaced_cnt += 1;
        }
    }
    if (misplaced_cnt == 0 || misplaced_cnt == 2) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 998244353;
                int arr[MAX];
            //Global Variables



                int main()
                {
                    int n , m;
                    scanf("%d%d",&n,&m);

                    string a[60],b[60];

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

                    for(int i = 0 ; i < n-m + 1 ; i++)
                    {
                        for(int j =  0; j < n-m + 1 ; j++)
                        {   bool flag = true;
                            for(int k = 0 ; k < m ; k++)
                            {   if(!flag)break;
                                for(int l = 0 ; l < m ; l++)
                                {
                                    int s = k + i;
                                    int t = l + j;
                                    if(b[k][l] != a[s][t])
                                    {
                                        flag = false;
                                        break;
                                    }
                                }
                            }
                            if(flag)
                            {
                                printf("Yes\n");
                                return 0;
                            }
                        }
                    }
                    printf("No\n");
                }


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,i,tmp,arr[100],cnt=0,flag=1;;
    
    scanf("%d",&n);
    if(n>100) exit(1);
    for(i=0;i<n;i++){
      scanf("%d",&arr[i]);
    }
    
    while(flag){
      flag=0;
        for(i=n-1;i>0;i--){
	  if(arr[i]<arr[i-1]){
	      tmp=arr[i];
                arr[i]=arr[i-1];
                arr[i-1]=tmp;
                cnt++;
                flag=1;
	    }
	}     
    }
    
    for(i=0;i<n;i++){
      if(i!=0) printf(" ");
        printf("%d",arr[i]);
    }
    printf("\n%d\n",cnt);
    
    return 0;
}



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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

const int di[] = {0,-1,0,1};
const int dj[] = {1,0,-1,0};

int main()
{
    ios::sync_with_stdio(false);

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

    queue<pii> q;
    vvi b(h, vector<int>(w, 1e9));

    int ini_kuro = 0;
    REP(i, h) REP(j, w) {
        if(s[i][j] == '#') ini_kuro++;
    }

    // startの設定
    q.emplace(0, 0);
    b[0][0] = 1;    // 塗れないので1手目とする．

    while(!q.empty()) {
        pii p = q.front(); q.pop();
        int i = p.first, j = p.second;

        // goalの設定
        if(i == h-1 && j == w-1) break;

        // update用関数
        auto update = [&](int i, int j, int x) {
            if(b[i][j] != 1e9) return;
            b[i][j] = x;
            q.push(pii(i,j));
        };
        
        // 全方向検索
        REP(dir, 4) {
            int ni = i + di[dir];
            int nj = j + dj[dir];
            if(ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
            
            // 壁の設定
            if(s[ni][nj] == '#') continue;
            update(ni, nj, b[i][j] + 1);
        }
    }
    int ans = -1;
    if(b[h-1][w-1] != 1e9) ans = h*w - ini_kuro - b[h-1][w-1];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#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)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n, k, x, ans = 0;
	cin >> n >> k;
	while (n--) {
		cin >> x;
		ans += min(abs(x - k), x) * 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
#define LL long long
inline int read()
{
    int res=0,f=1;
    char ch=getchar();
    while(ch!='-'&&(ch>'9'||ch<'0'))
        ch=getchar();
    if(ch=='-')
        f=-1,ch=getchar();
    while(ch>='0'&&ch<='9')
        res=(res<<1)+(res<<3)+(ch^48),ch=getchar();
    return res*f;
}
const int N=2e5+5;
int n,a[N],b[N];
bool check(int mid)
{
	for(RI i=1;i<2*n;++i)
		b[i]=1;
	for(RI i=1;i<2*n;++i)
	{
		if(a[i]>mid)
			b[i]=0;
	}
	bool flag=1;
	for(RI i=2;i<2*n;++i)
		if(b[i]==b[i-1])
			flag=0;
	/*printf("%d\n",mid);
	for(RI i=1;i<2*n;++i)
		printf("%d ",b[i]);
		printf("\n\n");*/
	if(flag)
		return b[1];
	int l=n,r=n;
	while(b[l]!=b[l-1]&&b[r]!=b[r+1])
	{
		l--,r++;
	}
	if(b[l]==b[l-1])
		return b[l];
	return b[r];
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	int l=0,r=0,ans=0;
	for(RI i=1;i<2*n;++i)
	{
		a[i]=read();
		r=max(r,a[i]);
	}
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			ans=mid;
			r=mid-1;
		}
		else
			l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1792
N,K=map(int,input().split())

mod=10**9+7
A=[0]*(N+1)

for i in range(N+1):
    if i==0:
        A[0]=N+1
    else:
        A[i]=A[i-1]+(N-2*i)
        A[i]%=mod

s=0
for i in range(K-1,N+1):
    s+=A[i]
    s%=mod

print(s)

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

int num999(unsigned long long int N);

int main(){
    unsigned long long int N;
    int sum=0;

    cin >> N;
    if(N<10){
        sum=N;
    }
    else{
        if(num999(N)){
            while(N>0){
                sum+=N%10;
                N/=10;
            }
        }
        else{
            while(N>=10){
                sum+=9;
                N/=10;
            }
            sum+=N-1;
        }
    }

    cout << sum << endl;
    return 0;

}

int num999(unsigned long long N){
    while(N>=10){
        int temp=N%10;
        if(temp!=9){
            return 0;
        }
        N/=10;
    }
    return 1;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

#define COMB_MAX (int)1e6 + 10
ll f[COMB_MAX], rf[COMB_MAX];
ll inv(ll x) {
	ll res = 1;
	ll k = mod - 2;
	ll y = x;
	while (k) {
		if (k & 1) res = (res * y) % mod;
		y = (y * y) % mod;
		k /= 2;
	}
	return res;
}
void init() {
	f[0] = 1;
	rep(i, 1, COMB_MAX) f[i] = (f[i - 1] * i) % mod;
	rep(i, 0, COMB_MAX) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
	if (k<0 || k>n || n < 0)return 0;
	ll a = f[n]; // = n!
	ll b = rf[n - k]; // = (n-k)!
	ll c = rf[k]; // = k!

	ll bc = (b * c) % mod;

	return (a * bc) % mod;
}
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	init();
	ll ans = 0;
	rep(r, 0, n)ans += a[r] * C(r, k - 1) % mod + mod - a[r] * C(n - r - 1, k - 1) % mod, ans %= mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 19368
S = input()
chk1 = 0
chk2 = 0
chk3 = 0
chk4 = 0
if S[0] == 'A':
    for i in range(1, len(S), 1):
        ord_c = ord(S[i])
        ###先頭2文字目が大文字なら
        if i == 1 and (65 <= ord(S[i]) and ord(S[i]) <= 90):
            chk1 = 1

        ###末尾が大文字なら
        if i == len(S)-1 and (65 <= ord(S[i]) and ord(S[i]) <= 90):
            chk2 = 1
        ###Cだったら
        elif ord_c == 67:
            chk3 += 1

        ###C以外の大文字があったら
        elif 65 <= ord_c and ord_c <= 90:
            chk4 = 1

    if chk3 == 1 and chk1 == 0 and chk2 == 0 and chk4 == 0:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3064
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include <string>

int kaijo(int n)
{
    int c = 1;

    for ( int _i = 1; _i <= n ; _i++ ) {
        c *= _i;
    }

    return c;
}

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> na(n);
    std::vector<int> nb(n);
    for ( int _n = 0; _n < n; _n++ ) {
        na[_n] = _n+1;
        nb[_n] = _n+1;
    }

    int a = 0;
    int b = 0;
    for ( int _n = 0; _n < n; _n++ ) {
        int p;
        std::cin >> p;
        auto it_a = std::find(na.begin(), na.end(), p);
        auto sz_a = std::distance(na.begin(), it_a);
        a += kaijo((n-_n)-1) * sz_a;
        na.erase(it_a);
    }
    for ( int _n = 0; _n < n; _n++ ) {
        int p;
        std::cin >> p;
        auto it_b = std::find(nb.begin(), nb.end(), p);
        auto sz_b = std::distance(nb.begin(), it_b);
        b += kaijo((n-_n)-1) * sz_b;
        nb.erase(it_b);
    }

    std::cout << std::abs(a-b) << std::endl;

    return 0;
}


Measured memory_bytes: 888
a,b=gets.chomp.split(" ").map{|s| s.to_i}
ans=0
if b-a>=8
  for i in a..a+(3-a%4)
    ans=ans^i
  end
  for j in b-(b%4)..b
    ans=ans^j
  end
else
  for k in a..b
    ans=ans^k
  end
end
puts ans

Measured memory_bytes: 1788
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}


#include <iostream>

int main()
{
    int a, b;
    cin >> a >> b;

    if (a % 2 == 1 && b % 2 == 1) { cout << "Odd" << endl; }
    else { cout << "Even" << endl; }

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

ll N, A, B;

int main() {
  cin >> N >> A >> B;
  ll X1, X2;
  cin >> X1;
  ll ans = 0;
  rep(i, 1, N) {
    cin >> X2;
    ans += min(B, A * (X2 - X1));
    X1 = X2;
  }
  cout << ans;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int acc1[5010][5010];
int acc2[5010][5010];

void add(int x, int y, int d){
  --acc1[x-d][y-d+1];
  ++acc1[x+1][y+2];
  
  ++acc2[x-d][y-d];
  --acc2[x+1][y-d];
}

int get(int x, int y){
  return acc1[x][y] + acc2[x][y];
}

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

  int N, M;
  cin >> N >> M;
  REP(i,M){
	int a, b, x;
	cin >> a >> b >> x;
	add(a+x, b+x, x);
  }

  REP(x,N+1) REP(y,N+1){
	acc1[x][y] += (x>=1&&y>=1? acc1[x-1][y-1]: 0) + (y>=1? acc1[x][y-1]: 0) - (x>=1&&y>=2? acc1[x-1][y-2]: 0);
	acc2[x][y] += (x>=1? acc2[x-1][y]: 0) + (y>=1? acc2[x][y-1]: 0) - (x>=1&&y>=1? acc2[x-1][y-1]: 0);
  }

  int ans = 0;
  for(int x=1;x<=N;++x){
	for(int y=1;y<=x;++y){
	  if(get(x,y) > 0)
		++ans;
	}
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 198936
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
typedef pair<int , int > P;
const int maxn=3005;
const LL INF=1e13+5;
 
int main()
{
    string arr;
    cin >> arr;
    int sum=0;
    for(int i=0;i<arr.length();i++)
        sum+=arr[i]-'0';
    if(sum%9)
        cout << "No";
    else
        cout << "Yes";
 
}

Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

int main()
{
	FASTIO
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll ans = max({a * c, b * d, a * d, b * c});
	cout << ans << endl;
}

Measured memory_bytes: 3696
#include <cstdio>  
#include <algorithm>  
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
#define maxn (int)1e5+500
int a[200];
int main()
{
	int n;
	while (~scanf("%d", &n))
	{
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		sort(a, a + n);
		int ans = 0;
		int x = 1;
		for (int i = n - 1; i >= 0; i--)
		{
			if (x==1)
				ans += a[i];
			else
				ans -= a[i];
			x *= -1;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main(){
    vector<int>X(5);
    for (int i = 0; i < 5; i++)
    {
        cin >> X[i];
        if (X[i] == 0)
        {
            cout << i+1 << endl;
            return 0;
        }
        
    }

    

}

Measured memory_bytes: 3620
#include <cstdio>

#define abs(x) (x > 0 ? (x) : -(x))

int main()
{
    int no_of_steps;
    scanf("%d", &no_of_steps);

    int is_possible = true;
    int last_time = 0;
    int last_x = 0, last_y = 0;

    while(no_of_steps--)
    {
        int time, x, y;
        scanf("%d %d %d", &time, &x, &y);

        int distance = abs(x - last_x) + abs(y - last_y);
        int interval = time - last_time;

        int excess_time = interval - distance;

        if(distance > interval || excess_time%2 == 1)
            is_possible = false;

        last_time = time;
        last_x = x, last_y = y;
    }

    printf(is_possible ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>A[i][j];
        }
    }
    int N;
    cin>>N;
    int B[N];
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<N;k++){
                if(A[i][j]==B[k]){
                    A[i][j]=0;
                }
            }
        }
    }
    for(int i=0;i<3;i++){
        if(A[0][i]==0&&A[1][i]==0&&A[2][i]==0){
            cout<<"Yes"<<endl;
            break;
        }
        if(A[i][0]==0&&A[i][1]==0&&A[i][2]==0){
            cout<<"Yes"<<endl;
            break;
        }
        if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0){
            cout<<"Yes"<<endl;
            break;
        }
        if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0){
            cout<<"Yes"<<endl;
            break;
        }
        if(i==2){
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

int main() {
    int K;
    cin >> K;
    vector<int> A(10);
    for (int i = 0; i < 10; i++) {
        A[i] = 0;
    }
    int max_digit = 0;
    long long ans = 0;
    for (int i = 0; i < K; i++) {
        bool updated = false;
        
        for (int j = 0; j < max_digit; j++) {
            if (A[j] < 9 && A[j] <= A[j + 1]) {
                A[j]++;
                while (j > 0) {
                    A[j - 1] = max(A[j] - 1, 0);
                    j--;
                }
                updated = true;
                break;
            }
        }
        if (updated) {
            continue;
        }
        
        if(A[max_digit] < 9) {
            A[max_digit]++;
        } else {
            max_digit++;
            A[max_digit] = 1;
        }
        int d = max_digit - 1;
        while (d >= 0) {
            A[d] = (A[d + 1] > 0 ? A[d + 1] - 1 : 0);
            d--;
        }
    }
    for (int i = max_digit; i >= 0; i--) {
        cout << A[i];
    }
}



Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int A[] = new int[n];
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		}
		int q = sc.nextInt();
		for(int i=0; i<q; i++){
			if(solve(A, 0, sc.nextInt())) System.out.println("yes");
			else                          System.out.println("no");
		}
	}
	static boolean solve(int A[], int offset, int m){
		if(m==0) return true;
		for(int i=offset; i<A.length; i++){
			if(m>=A[i]){
				if(solve(A, i+1, m-A[i])) return true;
			}
		}
		return false;
	}
}

Measured memory_bytes: 20136
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll train[555][555];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    REP(i,m){
        int l, r;
        cin >> l >> r;
        train[l][r]++;
    }

    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) train[i][j] += train[i][j-1];
    for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) train[i][j] += train[i-1][j];
    
    while(q--){
        int l, r;
        cin >> l >> r;
        cout << train[r][r] - train[l-1][r] - train[r][l-1] + train[l-1][l-1] << endl;
    }
}

Measured memory_bytes: 3072
#include <cstdio>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main(void) {
  int w, h, n;
  scanf("%d %d %d", &w, &h, &n);

  int a[n];
  vector< pair<int, int> > xy;

  for(int i = 0; i < n; i++) {
    int x, y;
    cin >> x;
    cin >> y;
    cin >> a[i];
    xy.push_back(pair<int, int>(x, y));
  }

  int white = w * h;
  int max1 = 0;
  int max2 = w;
  int max3 = 0;
  int max4 = h;
  
  for(int i = 0; i < n; i++) {
    if(a[i] == 1) {
      if(max1 < xy[i].first) {
	max1 = xy[i].first;
      }
    }
    else if(a[i] == 2) {
      if(max2 > xy[i].first) {
	max2 = xy[i].first;
      }
    }
    else if(a[i] == 3) {
      if(max3 < xy[i].second) {
	max3 = xy[i].second;
      }
    }
    else {
      if(max4 > xy[i].second) {
	max4 = xy[i].second;
      }
    }
  }

  white -= h * max1;
  white -= h * (w - max2);
  if(white < 0) {
    printf("0\n");
    return 0;
  }
  white -= (max2 - max1) * max3;
  white -= (max2 - max1) * (h - max4);
  if(white < 0) {
    printf("0\n");
    return 0;
  }
  else {
    printf("%d\n", white);
  }
  return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
      	int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
      	int sum = 0;
      	for(int i = 0; i < a; i++){
          sum += b+i;
        }
      
      	int answer = 0;
      	int small = b;
      
      	for(int j = 1; j < a; j++){
          if(System.Math.Abs(small) > System.Math.Abs(b+j)){
            small = b+j;
          }
        }
      
		Console.WriteLine(sum-small);
	}
}

Measured memory_bytes: 11220
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h1, h2, k1, k2, a, b, c, d;
    cin >> h1 >> h2;
    cin >> k1 >> k2;
    cin >> a >> b >> c >> d;
    
    int H,K;
    H = h1*a + (h1 / 10)*c + h2*b + (h2 / 20)*d;
    K = k1*a + (k1 / 10)*c + k2*b + (k2 / 20)*d;
    
    if(H > K){
        cout << "hiroshi" << endl;
    }else if(H == K){
        cout << "even" << endl;
    }else{
        cout << "kenjiro" << endl;
    }
}


Measured memory_bytes: 3112
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
  
#define mp make_pair
#define f first
#define s second
#define ll long long
#define pb push_back
#define popb pop_back
#define popf pop_front

using namespace std;

using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int inf = 2e9+7, mod=1e9+7;
const int N = 1e6+321, E=14e5;

ll xx[8]={1, 1, -1, -1, 1, -1, 0, 0};
ll yy[8]={1, -1, 1, -1, 0, 0, 1, -1};

string s[10];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	for(int i=0; i<5; i++){
		cin >> s[i];
		if (s[i]=="0")
			cout << i+1;
	}
    return 0;
}

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

int main(){
	vector<int> x(2);
	cin >> x.at(0) >> x.at(1);
	for(int i=0; i<2; i++){
		if(x.at(i)==2) x.at(i)=-2;
		if(x.at(i)==4 || x.at(i)==6 || x.at(i)==9 || x.at(i)==11) x.at(i)=-1;
		if(x.at(i)==1 || x.at(i)==3 || x.at(i)==5 || x.at(i)==7 || x.at(i)==8 || x.at(i)==10 || x.at(i)==12) x.at(i)=-10;
	}
	if(x.at(0)==x.at(1)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main() {
	int n;
	cin >> n;
	int p = 1 << n;
	vector<int> s(p);
	for (int i = 0; i < p; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end(), greater<int>());
	vector<bool> b(p, false);
	b[0] = true;
	bool ans = true;
	for (int i = 0; i < n; i++) {
		queue<int> q;
		for (int j = 0; j < p; j++) {
			if (b[j]) q.push(s[j]);
			else if (q.empty()) ;
			else if (q.front() > s[j]) {
				b[j] = true;
				q.pop();
			}
		}
		if (!q.empty()) {ans = false; break;}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main()
{
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  ll sum = 0;
  rep(i, A)
  {
    if (0 == K)
    {
      break;
    }
      
    sum++;
	K--;
  }
  
  rep(i, B)
  {
    if (0 == K)
    {
      break;
    }
      
	K--;
  }
  
  rep(i, C)
  {
    if (0 == K)
    {
      break;
    }
      
    sum--;
	K--;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}

ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){ if(b==0) return a; return gcd(b, a%b);}



int main(){
    fast_io

    string s;
    cin>>s;

    if((s=="AKIHABARA")||
    (s=="KIHABARA")||
    (s=="AKIHBARA")||
    (s=="AKIHABRA")||
    (s=="AKIHABAR")||
    (s=="KIHBARA")||
    (s=="AKIHBRA")||
    (s=="AKIHABR")||
    (s=="KIHABRA")||
    (s=="KIHABAR")||
    (s=="AKIHBAR")||
    (s=="KIHBRA")||
    (s=="AKIHBR")||
    (s=="KIHABR")||
    (s=="KIHBAR")||
    (s=="KIHBR")
    ) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from heapq import heappop, heappush

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

INF=10**11

G=[]

for i in range(10):
    G.append(list(map(int,input().split())))

d=[INF for i in range(10)]
d[1]=0

used=[False for i in range(10)]


heap=[]
heappush(heap,(d[1],1))

#それぞれのノードから1に行く最短距離を求めるダイクストラ
while heap:
    d_u, u = heappop(heap)
    used[u] = True
    if d[u] < d_u:
        continue
    for v in range(10):
        if v==u:
            continue
        if not(used[v]) and d_u + G[v][u] < d[v]:
            d[v] = d_u + G[v][u]
            heappush(heap,(d[v],v))

ans=0

for i in range(H):
    line=list(map(int,input().split()))
    for j in range(W):
        if line[j]!=-1:
            ans+=d[line[j]]

print(ans)

Measured memory_bytes: 3064
n = int(input())
sa,sb=[int(it) for it in input().split()]
for i in range(n-1):
  a,b=[int(it) for it in input().split()]
  r =  max( sa//a + (1 if sa%a!=0 else 0),sb//b+(1 if sb%b!=0 else 0) )
  sa = r*a
  sb = r*b
print (sa+sb)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
    int a=0,cmp;
    char S[99];

    gets(S);

    cmp=strcmp("SUN",S);
    if(cmp==0){
        a=7;
    }

    cmp=strcmp("MON",S);
    if(cmp==0){
        a=6;
    }

    cmp=strcmp("TUE",S);
    if(cmp==0){
        a=5;
    }

    cmp=strcmp("WED",S);
    if(cmp==0){
        a=4;
    }

    cmp=strcmp("THU",S);
    if(cmp==0){
        a=3;
    }

    cmp=strcmp("FRI",S);
    if(cmp==0){
        a=2;
    }

    cmp=strcmp("SAT",S);
    if(cmp==0){
        a=1;
    }

    printf("%d \n",a);

    return 0;
}

Measured memory_bytes: 128
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

dic_a={}
dic_b={}
for i in range(n):
    if a[i] in dic_a:
        print(0)
        exit()
    dic_a[a[i]]=1

for i in range(m):
    if b[i] in dic_b:
        print(0)
        exit()
    dic_b[b[i]]=1
# print(n*m)
ans=1
anum=0
bnum=0
for i in range(n*m):
    num=n*m-i
    if num in dic_a:
        if num in dic_b:
            bnum+=1
        else:
            ans*=bnum
        anum+=1
    else:
        if num in dic_b:
            ans*=anum
            bnum+=1
        else:
            ans*=anum*bnum-i
    ans%=mod
    # print(anum,bnum)
print(ans)

Measured memory_bytes: 74836
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>

using namespace std;

const long long INF = 9223372036854775806;

long long solve(long long a, long long b, long long c,long long d){
    long long myArray[4];
    myArray[0]=a; myArray[1]=b; myArray[2]=c; myArray[3]=d;
    sort(myArray,myArray+4);
    long long ret = myArray[3]-myArray[0];
    return ret;
}

int main(){
    int N;
    long long A[200000];
    vector<long long> sum;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i!=0){
            sum.push_back(A[i]+sum[i-1]);
        }else{
            sum.push_back(A[i]);
        }
    }
    long long ans=INF;
    long long total=sum[N-1];
    //cout<<"debug"<<endl;
    //cout<<total<<endl;
    for(int i=1;i<N-2;i++){//0からiまでが左2つの列に属する．
        long long left=sum[i];//左半分の和
        long long right=total-left;
        //cout<<left<<' '<<right<<endl;
        auto lower_left=lower_bound(sum.begin(), sum.end(), ((left+1)/2) );
        long long pattern1a, pattern1b, pattern2a, pattern2b;
        if(*lower_left != sum[i] && *lower_left != sum[0]){
            pattern1a=*lower_left;
            pattern1b=left-pattern1a;
            lower_left--;
            pattern2a=*lower_left;
            pattern2b=left-pattern2a;
        }else if(*lower_left == sum[i]){
            pattern1a=sum[i-1];
            pattern1b=left-pattern1a;
            pattern2a=INF;
            pattern2b=0;
        }else{
            pattern1a=A[0];
            pattern1b=left-pattern1a;
            pattern2a=INF;
            pattern2b=0;
        }
        auto lower_right=lower_bound(sum.begin(), sum.end(), (left+(right+1)/2) );
        long long pattern1c, pattern1d, pattern2c, pattern2d;
        if(*lower_right != total && *lower_right != sum[i+1]){
            pattern1c=*lower_right-left;
            pattern1d=right-pattern1c;
            lower_right--;
            pattern2c=*lower_right-left;
            pattern2d=right-pattern2c;
        }else if(*lower_right == total){
            pattern1c=sum[N-2]-left;
            pattern1d=right-pattern1c;
            pattern2c=INF;
            pattern2d=0;
        }else{
            pattern1c=A[i+1];
            pattern1d=right-pattern1c;
            pattern2c=INF;
            pattern2d=0;
        }
        //cout<<pattern1a<<' '<<pattern1b<<' '<<pattern1c<<' '<<pattern1d<<endl;
        //cout<<pattern2a<<' '<<pattern2b<<' '<<pattern2c<<' '<<pattern2d<<endl;
        ans=min(ans,solve(pattern1a,pattern1b,pattern1c,pattern1d));
        ans=min(ans,solve(pattern1a,pattern1b,pattern2c,pattern2d));
        ans=min(ans,solve(pattern2a,pattern2b,pattern1c,pattern1d));
        ans=min(ans,solve(pattern2a,pattern2b,pattern2c,pattern2d));
    }
    
    cout<<ans<<endl;
    
    return 0;
}


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

int main () {
  int N;
  cin >> N;
  vector<int> A(N);

  double x = 1;
  rep(i,N) {
    cin >> A[i];
    x *= A[i];
  }
  double y = 0;
  rep(i,N) y += x / A[i];

  cout << x / y << endl;
  return 0;
}


Measured memory_bytes: 256
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
if x[n - 1] < Y and X < y[0] and x[n - 1] < y[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
	int n; cin>>n;
	string word[n+2];
	for(int i=0;i<n;i++) cin>>word[i];
	 bool valid = true;
	 unordered_map<string,int>vis;
	for(int i=0;i<n and valid;i++){
		if(vis[word[i]])  valid = false;
		if(i>0){
			if(word[i][0]!=word[i-1][word[i-1].size()-1]) valid = false;
		}
		vis[word[i]] = 1;
	}
	printf("%s\n", valid ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int D, N;
  cin >> D >> N;
  if (D == 0) {
    if (N == 100) {
      cout << 101 << endl;
    } else {
      cout << N << endl;
    }
  }
  if (D == 1) {
    if (N == 100) {
      cout << 101 * 100 << endl;
    } else {
      cout << N * 100 << endl;
    }
  }
  if (D == 2) {
    if (N == 100) {
      cout << 101 * 10000 << endl;
    } else {
      cout << N * 10000 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  cout << (s[0] == '9' or s[1] == '9' ? "Yes" : "No") << '\n';
}

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

for i in range(N - 1):
    if A[i+1] - A[i] == 1:
        B.append(C[A[i] -1])

print(sum(B))

Measured memory_bytes: 3060