akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N = 1e6 + 10;
using namespace std;
int a,b;
int main() {
  ios::sync_with_stdio(false);
  cin>>a>>b;
  int c=abs(a-b);
  if(a<=8 && b<=8 && c>=0 && c<=2)  cout<<"Yay!"<<endl;
  else  cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  tmp0 = input[0].split(" ");
  N = Number(input[0]);

  var ans = 0;
  var lastA_cnt = 0;
  var firstB_cnt = 0;
  var firstB_lastA_cnt = 0;
  for (var i = 1; i <= N; i++) {
    var s = input[i];
    ab_cnt = (s.match(/AB/g) || []).length;
    ans += ab_cnt;
    if (s[0] === "B" && s[s.length - 1] === "A") {
      firstB_lastA_cnt++;
      continue;
    }
    ///
    if (s[0] === "B") {
      firstB_cnt++;
    }
    if (s[s.length - 1] === "A") {
      lastA_cnt++;
    }
  }
  if (firstB_lastA_cnt > 0) {
    ans += firstB_lastA_cnt - 1;
    if (lastA_cnt > 0) {
      firstB_cnt++;
    }
    if (firstB_cnt > 0) {
      lastA_cnt++;
    }
  }
  ans += Math.min(firstB_cnt, lastA_cnt);

  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main("1\nBA\n");


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

int main() {
  string n;
  cin >> n;
  
  int sum = 0;
  
  for (long i = 0; i < n.size(); i++) {
    sum += n[i]-'0';
  }
  
  if (sum % 9) cout << "No";
  else cout << "Yes";
  
  return 0;
}

Measured memory_bytes: 3752
import sys
from itertools import permutations

a = tuple(int(x) for x in sys.stdin.readline().split())

def main():
    for p in set(permutations([5, 5, 7], 3)):
        if a == p:
            return 'YES'
    return 'NO'

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

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
ll N,a,b,c,d,e;
int main(){
    cin >> N >> a >> b >> c >> d >> e;
    ll mn = min(a,min(b,min(c,min(d,e))));
    ll ex;
    if(N % mn == 0) ex = N/mn;
    else ex = N/mn + 1;
    cout << ex + 4 << endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char* argv[]){
  int n;
  std::cin >> n;
  std::vector<int> a;
  a.reserve(n);
  int c(0);
  for(int i = 0; i < n; i++){
    int a_i;
    std::cin >> a_i;
    a.push_back(a_i);
  }
  if (n == 2){
    if (a[0] == a[1]){
      std::cout << "1" << std::endl;
      return 0;
    }
  } else {
    if (a[n - 1] == a[n - 2]){
      a[n - 2] = a[n - 3] + a[n - 1];
      c++;
    }
  }

  for(int i = 1; i < n - 1; i++){
    if (a[i - 1] == a[i]){
      c++;
      if(a[i] == a[i + 1]){
        a[i] = a[i + 1] - 1;
      }
    }
  }

  std::cout << c << std::endl;
  return 0;  
}



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

typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int> > dp(n + 1, vector<int>(2));
  dp[0][0] = 1;
  for(int i = 0; i < n; i++) {
    { // a+b = 0
      if (s[i] == '0') {
        dp[i+1][0] = dp[i][0];
        dp[i+1][1] = dp[i][1];
      } else {
        dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod;
      }
    }
    { // a+b = 1
      if (s[i] == '0') {
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
      } else {
        (dp[i+1][0] += dp[i][0]*2 % mod) %= mod;
        (dp[i+1][1] += dp[i][1]*2 % mod) %= mod;
      }
    }
  }
  int ans = (dp[n][0]+dp[n][1]) % mod;
  cout << ans << endl;
  return 0;
}  

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

typedef long long ll;
typedef pair <int, int> pii;

const int MAXN = 1e5 + 5;

int N;
int a[MAXN], b[MAXN];
vector <pii> E[MAXN];
ll s[MAXN], sol[MAXN];
int subtree[MAXN];
int edge;
ll tot_sum;
int tot_cnt;

void load() {
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		scanf("%d%d", a + i, b + i);
		E[a[i]].push_back({b[i], i});
		E[b[i]].push_back({a[i], i});
	}
	for (int i = 1; i <= N; i++)
		scanf("%lld", s + i);
}

void dfs(int x, int p) {
	subtree[x] = 1;
	for (auto it : E[x])
		if (it.first != p) {
			dfs(it.first, x);
			subtree[x] += subtree[it.first];
			int diff = 2 * subtree[it.first] - N;
			if (diff)
				sol[it.second] = (s[x] - s[it.first]) / diff;
			else
				edge = it.second;
		}		
}

void go(int x, int p, ll sum, int cnt) {
	tot_sum += sum;
	tot_cnt += cnt;
	for (auto it : E[x])
		if (it.first != p)
			go(it.first, x, sum + sol[it.second], cnt + (it.second == edge));
}

void solve() {
	dfs(1, 0);
	
	if (edge) {
		go(a[edge], 0, 0, 0);
		sol[edge] = (s[a[edge]] - tot_sum) / tot_cnt;
	}
	
	for (int i = 1; i < N; i++)
		printf("%lld\n", sol[i]);
}

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

Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin>>S.at(i);
    }
    vector<vector<int>> L(H,vector<int>(W));
    vector<vector<int>> R(H,vector<int>(W));
    vector<vector<int>> D(H,vector<int>(W));
    vector<vector<int>> U(H,vector<int>(W));
    int result=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]=='#') L[i][j]=0;
            else if(j==0) L[i][j]=1;
            else L[i][j]=L[i][j-1]+1;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=W-1;j>-1;j--){
            if(S[i][j]=='#') R[i][j]=0;
            else if(j==W-1) R[i][j]=1;
            else R[i][j]=R[i][j+1]+1;
        }
    }
    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(S[i][j]=='#') U[i][j]=0;
            else if(i==0) U[i][j]=1;
            else U[i][j]=U[i-1][j]+1;
        }
    }
    for(int j=0;j<W;j++){
        for(int i=H-1;i>-1;i--){
            if(S[i][j]=='#') D[i][j]=0;
            else if(i==H-1) D[i][j]=1;
            else D[i][j]=D[i+1][j]+1;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            result=max(result,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
        }
    }
    cout<<result<<endl;
}

Measured memory_bytes: 67200
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    map<int,int> q;
    int n,m,ans=0,pe=0; cin>>n>>m;
    rep(i,m){
        int p;
        string s;
        cin>>p>>s;
        if(s=="AC"){
           if(q.count(p)){
               if(q[p]!=-1){
               pe+=q[p];
               q[p]=-1;
               ans++;
               }
           }
           else{
               q[p]=-1;
               ans++;
           }
        }
        else{
            if(q.count(p)==0){
                q[p]=1;
            }
            else{
                if(q[p]!=-1){
                    q[p]++;
                }
            }
        }
    }
    cout<<ans<<" "<<pe<<endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll n, k, c;

vector<ll> calc(string s) {
  ll p = 0;
  vector<ll> res(n + 1, 0);
  while (p < n) {
    if (s[p] == 'x') {
      res[p + 1] = res[p];
      p++;
      continue;
    }

    ll v = res[p] + 1;
    ll ub = p + c + 1;
    while (p < min(n, ub)) {
      res[p + 1] = v;
      p++;
    }
  }
  return res;
}

int main() {
  cin >> n >> k >> c;
  string s;
  cin >> s;
  vector<ll> l = calc(s);
  // REP(i, n + 1) { cout << l[i] << " \n"[i == n]; }
  string t = s;
  reverse(ALL(t));
  vector<ll> r = calc(t);
  // REP(i, n + 1) { cout << r[i] << " \n"[i == n]; }

  vector<ll> ans;

  FOR(i, 1, n + 1) {
    if (s[i - 1] == 'x') {
      continue;
    }
    if (l[i - 1] + r[n - i] < k) {
      ans.push_back(i);
    }
  }
  REP(i, SZ(ans)) { cout << ans[i] << endl; }
}

Measured memory_bytes: 6836
#include <cstdio>
#include <map>
#define I(M,A) for(i=0;i<M;i++){scanf("%d",&x);A[i+1]=A[i]+x;}
using namespace std;int main(){
for(int n[1501], m[1501],o,a,b,i,j,x;scanf("%d%d",&a,&b),a;printf("%d\n",o)){
  map<int,int>z;
  map<int,int>::iterator p;
  n[0]=m[0]=o=0;
  I(a,n)
  I(b,m)
  
  for(i=0;i<=a;i++){
    for(j=0;j<=b;j++){
	  z[n[i]+m[j]]++;
	}
  }
  
  for(p=z.begin();p!=z.end();p++){
	o+=(p->second)*((p->second)-1)/2;
  }
}
}

Measured memory_bytes: 18000
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int A,B,C;
  cin>>A>>B>>C;

  int ans = INF;
  for(int i=0;i<100;i++) //AB
    for(int j=0;j<100;j++) //BC
      for(int k=0;k<100;k++){ //CA
        int AB = i;
        int BC = j;
        int CA = k;
        
        int a = A + AB + CA;
        int b = B + AB + BC;
        int c = C + BC + CA;
        
        vector<int> arr({a,b,c});
        sort(arr.begin(),arr.end());
        int s = arr[2] - arr[0];
        int t = arr[2] - arr[1];
        if((arr[2] - arr[1])%2 || (arr[2] - arr[0])%2) continue;
        int cost = i + j + k + s / 2 + t / 2;
        Min(ans,cost);
      }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val C = Array<Int>(N) { 0 }
    for (i in N downTo 1) {
        var sum = 0
        for (n in i+i .. N step i) {
            sum = sum xor C[n - 1]
        }
        C[i - 1] = sum xor A[i - 1]
    }
    var ans = C.mapIndexed { index, v -> if (v == 0) 0 else index + 1 }.filter { it != 0 }
    println(ans.count())
    println(ans.joinToString(separator = " "))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


Measured memory_bytes: 79760
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
S = int(input())
MOD = 10**9+7
n = S // 3
fac = [1, 1]
inv = [0, 1]
finv = [1, 1]
#fac[i] = i! % MOD,finv[i] = (i!)^-1 % MOD
for i in range(2, S+5):
    fac.append(fac[-1] * i % MOD)
    inv.append(MOD - inv[MOD%i] * (MOD//i) % MOD)
    finv.append(finv[-1] * inv[-1] % MOD) 
def comb_mod(n, r, m):  #nCr mod m
    if (n<0 or r<0 or n<r): return 0
    r = min(r, n-r)
    return fac[n] * finv[n-r] * finv[r] % m

def chofuku(n,r): # nHr mod MOD の計算
    return comb_mod(n+r-1,r)
ans = 0
for i in range(1,n+1):
    if i == 1:
        ans += 1
    else:
        p = S-3*i
        ans += comb_mod(p+i-1,p,MOD)
        ans %= MOD
ans %= MOD
print(ans)


            








Measured memory_bytes: 10660
N, K = map(int, input().split(' '))
count = (N - 1) * (N - 2) // 2
is_connect = [[False for _ in range(N)] for _ in range(N)]
if K > count:
  print(-1)
else:
  for i in range(1, N):
    is_connect[0][i] = True
  i = 2
  j = 1
  for _ in range(count - K):
    is_connect[j][i] = True
    if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
  print(N - 1 + count - K)
  for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1))

Measured memory_bytes: 3332
/**
 * A - We Love Golf
 * https://atcoder.jp/contests/abc165/tasks/abc165_a
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // ジャンボ高橋君の目標は飛距離を K の倍数にすることですが、ジャンボ高橋君の出せる飛距離の範囲は A 以上 B 以下です。
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;

    // 目標の達成が可能であれば OK と、不可能であれば NG と出力せよ。
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            cout << "OK";
            return 0;
        }
    }

    cout << "NG";

}
 

Measured memory_bytes: 3580
c = [list(map(int,input().split())) for i in range(3)]
if not (c[1][0] - c[0][0]) == (c[1][1] - c[0][1]) == (c[1][2]-c[0][2]):
    print("No")
    exit()
if not (c[2][0]-c[1][0]) == (c[2][1]-c[1][1]) == (c[2][2] - c[1][2]):
    print("No")
    exit()

if not (c[2][0]-c[0][0]) == (c[2][1]-c[0][1]) == (c[2][2] - c[0][2]):
    print("No")
    exit()

if not (c[0][1]-c[0][0]) == (c[1][1]-c[1][0]) == (c[2][1] - c[2][0]):
    print("No")
    exit()

if not (c[0][2]-c[0][1]) == (c[1][2]-c[1][1]) == (c[2][2] - c[2][1]):
    print("No")
    exit()

if not (c[0][2]-c[0][0]) == (c[1][2]-c[1][0]) == (c[2][2] - c[2][0]):
    print("No")
    exit()

print("Yes")

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll count = 0;
    vll v(3);
    rep(i,3)cin >> v[i];
    if(v[0] != v[1])count++;
    if(v[0] != v[2])count++;
    if(v[1] != v[2])count++;
    if(count == 0)cout << '1' << endl;
    else cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll min=1000000000, max=0;
	for(int i=0; i<n; i++){
		ll a;
		cin >> a;
		if(min>a) min=a;
		if(max<a) max=a;
	}
	cout << max-min << endl;
	return 0;
}

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

using namespace std;
using llint = long long int ;

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
// c 回繰り返す

//////////////////////////クラス構造体///////////////////////////
class UnionFind
{//UnionFind木 Nの数に注意　0=<x<N　まで作られる
private:
    vector<int> par;
public:
    UnionFind(int N) : par(N,-1){}//初期化コンストラクタ 根を初期化
    //par[i]は根のとき負　それ以外非負　
    int root(int x){//データxの根を返す　root(i)は必ず非負
    if (par[x]<0) return x;//par[x]が負のときｘは木の根である
    return par[x]=root(par[x]);//経路圧縮
    }

    void unite(int x,int y){//xの根とyの根を同じにする
    int rx=root(x); int ry=root(y);
    if (rx==ry) return;//xの根とyの根が同じとき　なにもしない
    if (par[rx] > par[ry]) swap(rx,ry);//ランク処理
    par[rx]+=par[ry];
    par[ry]=rx;//違うとき　根をおなじにする
    }

    bool same(int x,int y){//根が同じとき TRUE
        return root(x)==root(y);
    }
    int size(int x) {return -par[root(x)];}//サイズを返す

};
///////////////////////////////////////////////////////////






int main(){
    int N,M,K;
    cin>>N>>M>>K;
    UnionFind frie(N);
    int count[100010];
    vector<int> v[100010];

    rep(i,M) {
        int A,B;
        cin>>A>>B;
        --A; --B;
        count[A]++; count[B]++;
        frie.unite(A,B);
    }
    rep(i,K) {
        int C,D;
        cin>>C>>D;
        --C; --D;
        v[C].push_back(D);
        v[D].push_back(C);
    }
    rep(i,N){
        int ans=frie.size(i)-1-count[i];
        for (int e:v[i])
        {
            if(frie.same(i,e))  --ans;
        }
        cout<<ans<<" ";
    }
    
    cout<<endl;


    return 0;
}



Measured memory_bytes: 6784
#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 n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  
  int cnt = 0;
  for(int i = 0; i < n; i++){
  	if(i+1 != p.at(i)) {
      cnt++;
    }
    if(2 < cnt) {
    	cout << "NO" << endl;
      	return 0;
    }
  }
  cout << "YES" << endl;
  return 0; 
}

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1) % LEN;
}
P dequeue(){
  P x = Q[head];
  head = (head+1)%LEN;
  return x;
}
int min(int a,int b){
  return a<b ? a:b;
}

int main(){
  int n,q;
  int time,c;
  int i;
  P que;
  
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s%d",Q[i].name,&Q[i].t);
  }

  head=1;
  tail=n+1;

  while(head!=tail){
    que=dequeue();
    c=min(q,que.t);
    que.t -= c;
    time += c;
    if(que.t>0){
      enqueue(que);
    }else{
      printf("%s %d\n",que.name,time);
    }
  }
  
  
  return 0;
}
  

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define for1(i,n) for(int i=1;i<=(int)n;i++)
#define ford(i, b, a) for (int i = (int)(b); i >= a; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int N = (int)1e5+77;
const int inf = (int) 1e9+77;
const ll mod = (ll) 998244353;
const ld pi = acos(-1);

int main() {
    fast;
    int n, k, h[N], dp[N];
    cin >> n >> k;
    forn(i, n) cin >> h[i], dp[i] = inf;
    dp[0] = 0;
    forn(i, n) {
        for1(j, k) {
            if (i + j < n) dp[i + j] = min(dp[i + j], abs(h[i + j] - h[i]) + dp[i]);
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' #use a string like this, instead of ord()
N = int(input().strip())
def shifttext(shift):
    S = str(input('').upper()) #Input text here
    data = []
    for i in S: #iterate over the text not some list
        if i.strip() and i in alphabet: #if the char is not a space ""
            data.append(alphabet[(alphabet.index(i) + shift) % 26])
        else:
            data.append(i) #if space the simply append it to data
    output = ''.join(data)
    return output
print(shifttext(N))

Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

class Pair< T1 extends Comparable<T1>, T2 extends Comparable<T2> >
    implements Comparable< Pair<T1, T2> > {
    
    public T1 first;
    public T2 second;
 
    Pair ( T1 first, T2 second ) {
        this.first = first;
        this.second = second;
    }

    public int compareTo( Pair<T1,T2> o ) {
	int r = first.compareTo( o.first );
	return r == 0 ? second.compareTo( o.second ) : r;
    }
}

class Main {

    static final int INF = (int)1e9 + 1;

    int n, q;
    int[] s = null;
    int[] f = null;
    
    int LowerBound( int v ) {
	int l = 0, r = n;
	while ( r - l > 1 ) {
	    int mid = ( l + r )/2;
	    if ( s[mid] >= v ) r = mid;
	    else l = mid;
	}
	return v <= s[l] ? l : r;
    }

    int UpperBound( int v ) { return LowerBound(v+1); }

    void solve(){

	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	q = sc.nextInt();

	ArrayList< Pair<Integer,Integer> > tmp = new ArrayList< Pair<Integer,Integer> >();
	for ( int i=0; i<n; ++i ) {
	    tmp.add( new Pair<Integer,Integer>( sc.nextInt(), i ) );
	}
	Collections.sort( tmp );

	s = new int[n];
	f = new int[n];
	for ( int i=0; i<n; ++i ) {
	    s[i] = tmp.get(i).first;
	    f[tmp.get(i).second] = i;
	}

	TreeSet<Integer> leader = new TreeSet<Integer>();
	while ( q-- > 0 ) {

	    String op = sc.next();
	    int arg = sc.nextInt();

	    if      ( op.equals("ADD") ) leader.add( f[arg-1] );
	    else if ( op.equals("REMOVE") ) leader.remove( f[arg-1] );
	    else {

		int fail_r = -1, succ_r = INF;//条件を満たさない最大のr と 満たす最小のr

		while ( succ_r - fail_r > 1 ) {
		
		    int mid = (succ_r + fail_r)/2;//新しいr

		    int count = 0; //リーダーによってカバーされる生徒の総数
		    int prev = -1; //リーダーのうちスコアが一つ下の人のインデックス
		    for ( int idx : leader ) {

			//全スコア中でリーダーからr引いたスコアの人のインデクス
			int l_idx = LowerBound( s[idx] - mid );

			//全スコア中でリーダーのスコアのすぐ下の人のインデクス
			int r_idx = UpperBound( s[idx] ) - 1;

			if ( l_idx <= prev ) l_idx = prev + 1;//一つ下のリーダーの手前まで

			count += r_idx - l_idx + 1;//カウントにリーダー自身を含める
		    
			prev = r_idx;
		    }

		    if ( n - count <= arg ) succ_r = mid;
		    else fail_r = mid;
		}

		if ( succ_r == INF ) System.out.println("NA");
		else System.out.println(succ_r);
	    }
	}
    }

    public static void main(String[] a) { new Main().solve(); }
}



Measured memory_bytes: 361660
#include <stdio.h>
int main(void) {
	int n, cnt = 0;
	scanf("%d", &n);
	int p[20];
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
	}

	for (int i = 1; i < n - 1; i++) {
		if ((p[i - 1] > p[i] && p[i + 1] < p[i]) || (p[i - 1]<p[i] && p[i + 1]>p[i])) {
			cnt++;
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    string S;
    cin>>S;
    int Q;
    cin>>Q;
    int Key=1;
  	string T;
  	T="";
    rep(i, Q){
        int j;
        cin>>j;
        if(j==1){
            Key*=-1;
            
        }
        if(j==2){
            int F;
            char C;
            cin>>F>>C;
          	
            if(F==1){
                if(Key==1){
                    T+=C;
                }
                else{
                    S+=C;
                }
            }
            if(F==2){
                if(Key==-1){
                    T+=C;
                }
                else{
                    S+=C;
                }
            }
            

        }

    }
  	if(Key==1){
      	int TSz=T.size();
      	rep(i, TSz){
          	cout<<T.at(TSz-1-i);
        }
      	cout<<S<<endl;
      	return 0;
    }
    if(Key==-1){
      	int Sz=S.size();
        rep(i, Sz){
          	cout<<S.at(Sz-1-i);
          	
        }
      	cout<<T<<endl;
      	return 0;
    }
    cout<<S<<endl;
    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  int x = a.back(), keep = a.front();
  for(int i = 0; i < n - 1; i++){
    if(x % 2 == 0){
      if(abs(x / 2 - keep) > abs(x / 2 - a.at(i))) keep = a.at(i);
    }
    else{
      if(min(abs(x / 2 - keep), abs((x + 1) / 2 - keep)) > min(abs(x / 2 - a.at(i)), abs((x + 1) / 2 - a.at(i)))) keep = a.at(i);
    }
  }
  
  cout << x << " " << keep << '\n';
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b){
		if (b < c){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
		}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
import heapq
import math

n, m = map(int, input().split())
a = [-1 * int(i) for i in input().split()]
heapq.heapify(a)
for _ in range(m):
    b = heapq.heappop(a)
    heapq.heappush(a, math.ceil(b / 2))
print(-1 * sum(a))

Measured memory_bytes: 97816
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cout << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cout<<endl; 
	}
	eni(!=) cout << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin >> n;
		ll int x[n + 1], y[n + 1];
		vi v1, v2, v3, v4;
		for(ll int i = 1; i <= n; i++)
		{
			cin >> x[i] >> y[i];
			v1.pb(x[i] + y[i]);
			v2.pb(x[i] - y[i]);
			v3.pb(-x[i] + y[i]);
			v4.pb(-x[i] - y[i]);
		}
		sort(all(v1));
		sort(all(v2));
		sort(all(v3));
		sort(all(v4));
		ll int maxi = max({v1[n - 1] - v1[0], v2[n - 1] - v2[0], v3[n - 1] - v3[0], v4[n - 1] - v4[0]});
		cout << maxi << endl;
	}
	return 0;
}

Measured memory_bytes: 12768
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int N, K;
	cin >> N >> K;

	vector<lint> V(N);
	for (int i = 0; i < N; i++) cin >> V[i];

	lint ans = 0;
	for (int i = 0; i <= min(K, N); i++) {

		lint sum = 0;
		for (int j = 0; j <= i; j++) {

			sum = 0;
			vector<lint> minus;
			for (int k = 0; k < j; k++) {
				sum += V[k];
				if (V[k] < 0) minus.emplace_back(V[k]);
			}
			for (int k = 1; k <= i - j; k++) {
				sum += V[N - k];
				if (V[N - k] < 0) minus.emplace_back(V[N - k]);
			}

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

			for (int l = 0; l < min((int)minus.size(), K - i); l++) sum -= minus[l];

			ans = max(ans, sum);

		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;
//const ll INF = (ll)1e18 + 1;

int main(){
  ll X; cin >> X;
  ll n = 0;
  ll now = 100;
  while(true){
    now *= 1.01;
    n++;
    if (now >= X) break;
  }
  cout << n << endl;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	height := scanIntSlice(n)

	plus := map[int][]int{}
	minus := map[int][]int{}

	for i := 1; i <= n; i++ {
		p := i + height[i-1]
		if _, ok := plus[p]; !ok {
			plus[p] = []int{}
		}
		plus[p] = append(plus[p], i)

		m := i - height[i-1]
		if _, ok := minus[m]; !ok {
			minus[m] = []int{}
		}
		minus[m] = append(minus[m], i)
	}

	count := 0
	for x, _ := range plus {
		count += len(plus[x]) * len(minus[x])
	}

	fmt.Printf("%d\n", count)
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


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

using namespace std;

long long lcm(long long A, long long B) {
  return A / __gcd(A, B) * B;
}

long long foo(long long X, long long C, long long D) {
  return X/C + X/D - X/lcm(C, D);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << B - A + 1 - foo(B, C, D) + foo(A-1, C, D) << "\n";
}


Measured memory_bytes: 256
A=[]
min=9
Sum=0
for i in range(5):
    tmp=int(input())
    A.append(tmp)


for i in range(5):
    if A[i]%10<min and A[i]%10!=0:
        tmp=A[i]
        min=A[i]%10
        
Sum=tmp
A.remove(tmp)

for i in range(4):
    if not A[i]%10==0:
        Sum+=10-A[i]%10
        
Sum+=sum(A)

print(Sum)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
const int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint powmod(lint a,lint b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}

int main(void){
    lint N,K;
    cin >> N >> K;
    lint ans[K+1]={};
    for(int i=K;i>=1;i--){
        lint bi=K/i;
        ans[i]=powmod(bi,N);
        for(int j=i*2;j<=K;j+=i) ans[i]=(ans[i]-ans[j]+MOD)%MOD;
    }
    lint sum=0;
    rep(i,K+1) (sum+=ans[i]*i)%=MOD;
    cout << sum << endl;
}

Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;

inline int distance(int a, int b, int c, int d) {
        return abs(a - c) + abs(b - d);
}

int main() {
        int N, M;
        cin >> N >> M;
        vector<int> a(N), b(N);
        vector<int> c(M), d(M);

        for (int i = 0; i < N; i++) {
                cin >> a[i] >> b[i];
        }
        for (int i = 0; i < M; i++) {
                cin >> c[i] >> d[i];
        }

        for (int i = 0; i < N; i++) {
                int min = 0x7fffffff;
                int num;
                for (int j = 0; j < M; j++) {
                        int dis = distance(a[i], b[i], c[j], d[j]);
                        if (min > dis) {
                                min = dis;
                                num = j;
                        }
                }
                cout << num + 1 << endl;
        }
        return 0;
}

Measured memory_bytes: 256
N,A,B=map(int,input().split())
vlist=list(map(int,input().split()))
#vlist.sort(reverse=True)

dp=[[(-1,-1)]*(N+1) for _ in range(N+1)]
dp[0][0]=(0,1)

for i in range(1,N+1):
  dp[i][0]=(0,1)
  for j in range(1,i+1):
    dp[i][j]=dp[i-1][j]
    if dp[i-1][j-1][0]+vlist[i-1]>dp[i][j][0]:
      dp[i][j]=(dp[i-1][j-1][0]+vlist[i-1],dp[i-1][j-1][1])
    elif dp[i-1][j-1][0]+vlist[i-1]==dp[i][j][0]:
      dp[i][j]=(dp[i][j][0],dp[i][j][1]+dp[i-1][j-1][1])
#print(dp)

max_value_avg=0
for j in range(A,B+1):
  #print(j,dp[N][j])
  value_avg=dp[N][j][0]/j
  max_value_avg=max(max_value_avg,value_avg)

answer=0
for j in range(A,B+1):
  value_avg=dp[N][j][0]/j
  if value_avg==max_value_avg:
    answer+=dp[N][j][1]
  
print(max_value_avg)
print(answer)

Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

int N;

struct List {
    struct ListI {
        ListI* next;
        ListI* prev;
        int value;

        ListI(ListI* n, ListI* p, int v) : next(n), prev(p), value(v) {}

        void* operator new(size_t, void* p) { return p; }

        static ListI* create(ListI* n, ListI* p, int v) {
            return new (malloc(sizeof(ListI))) ListI(n, p, v);
        }
    };

    ListI* first;
    ListI* last;

    List() : first(0), last(0) {}

    void insert(int x) {
        if (first == 0) {
            first = last = ListI::create(0, 0, x);
        } else {
            ListI* of = first;
            ListI* nf = ListI::create(of, 0, x);
            of->prev = nf;
            first = nf;
        }
    }

    void remove(int x) {
        if (first == 0) { return; }
        if (first == last && first->value == x) {
            free(first);
            first = last = 0;
            return;
        }

        if (first->value == x) {
            deleteFirst();
            return;
        }

        if (first->next != 0) {
            for (ListI* i = first->next; i != last; i = i->next) {
                if (i->value == x) {
                    ListI* p = i->prev;
                    ListI* n = i->next;
                    p->next = n;
                    n->prev = p;
                    free(i);
                    return;
                }
            }
        }

        if (last->value == x) {
            deleteLast();
        }
    }

    void deleteFirst() {
        if (first == 0) { return; }
        if (first == last) { free(first); first = last = 0; return; }

        ListI* f = first;
        first = first->next;
        first->prev = 0;
        free(f);
    }

    void deleteLast() {
        if (last == 0) { return; }
        if (first == last) { free(last); first = last = 0; return; }

        ListI* l = last;
        last = last->prev;
        last->next = 0;
        free(l);
    }

    void print() {
        if (first == 0) { cout << endl; return; }
        for (ListI* i = first; i != last; i = i->next) {
            cout << i->value << " ";
        }
        cout << last->value << endl;
    }
};

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

    cin >> N;
    List lis;
    for (int i = 0; i < N ;i++) {
        string mne;
        cin >> mne;
        if (mne == "insert") {
            int val;
            cin >> val;
            lis.insert(val);
        } else if (mne == "delete") {
            int val;
            cin >> val;
            lis.remove(val);
        } else if (mne == "deleteFirst") {
            lis.deleteFirst();
        } else if (mne == "deleteLast") {
            lis.deleteLast();
        }
    }
    lis.print();
    return 0;
}

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

Measured memory_bytes: 600
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#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};
const ll MOD = 1e9 + 7;

int main() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    int mi=1000000000;
    int p=0;

    rep(i,n){
        cin>>a[i];
        if(a[i]<mi){
            mi=a[i];
            p=i;
        }
    }
    int ans=0;
    while(n>0){
        if(n>k) {
            n -= k;
            ans++;
            n+=1;
        }else{
            ans++;
            break;
        }
        
        
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  vector<int> east(N);
  int counte=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='E')  counte++;
    east.at(i)=counte;
  }

  int ans=N;
  for(int i=0;i<N;i++){
    int count=0;
    count+=east.at(N-1)-east.at(i);
    if(i>0) count+=i-east.at(i-1);
    ans=min(ans,count);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    vector<char> S(A + B + 1);
    for (int i = 0; i < A+B+1; i++){
        cin >> S.at(i);
    }
    bool can = true;
    for (int i = 0; i < A+B+1; i++){
        if (i == A){
            if (S.at(i) != '-') can = false;
        }
        else{
            if (S.at(i) == '-') can = false;
        }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
H, W = map(int, raw_input().split())
a = [raw_input().strip() for _ in xrange(H)]
a = map(''.join, zip(*a))
ans = 0
def solve(a, c):
    shift = [[0] * (H+1) for _ in xrange(H+1)]
    for i in reversed(xrange(H)):
        for j in reversed(xrange(H)):
            shift[i][j] = shift[i+1][j+1] + int(a[H-1-i] == c[H-1-j])
    dp = [[float('inf')] * (H+1) for _ in xrange(H+1)]
    for i in xrange(H+1):
        for j in xrange(H+1):
            b = 2147483647
            if i == j == 0:
                b = 0
            if i > 0:
                b = min(b, dp[i-1][j] + shift[i-1][j])
            if j > 0:
                b = min(b, dp[i][j-1] + shift[i][j-1])
            dp[i][j] = b
    #print a, c, shift
    return dp[H][H]
for i in xrange(W-1):
    i1 = i
    i2 = i+1
    ans += solve(a[i1], a[i2])
print ans


Measured memory_bytes: 125468
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long c, long long d){
    if(d==0)return c;
    else return gcd(d,c%d);
}
long long lcm(long long c,long long d){
    return c/gcd(c,d)*d;
}
long long f(long long x, int c, int d){
    long long res = x;
    res -= x/c;
    res -= x/d;
    res += x/lcm(c,d);
    return res;
}
int main(){
    long long a,b;
    int c,d;
    cin>>a>>b>>c>>d;
    cout<<f(b,c,d)-f(a-1,c,d)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] sum = new long[n+1];
		sum[0] = 0;
		for(int i = 0; i < n; i++){
		    sum[i+1] = (sum[i] + sc.nextLong())%m;
		}
		
		// 計算
		long result = 0;
		HashMap<Integer, Integer> cnt = new HashMap<Integer, Integer>();
		for(int i = 0; i < n+1; i++){
		    result += cnt.getOrDefault((int)sum[i], 0);
		    cnt.put((int)sum[i], cnt.getOrDefault((int)sum[i], 0) + 1);
		}
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 61904
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 500005

int n, k;
ll sl[maxn], sr[maxn], a[maxn], sum[maxn];

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k;
    sum[0] = 0;
    For(i, 1, n){
    	cin >> a[i];
    	sum[i] = sum[i - 1] + a[i];
    }

    sl[0] = 0;
    For(i, 1, n){
    	sl[i] = sl[i - 1];
    	if(a[i] > 0) sl[i] += a[i];
    }
    sr[n + 1] = 0;
    Ford(i, n, 1){
    	sr[i] = sr[i + 1];
    	if(a[i] > 0) sr[i] += a[i];
    }

    ll res = 0;
    For(i, 1, n - k + 1){
    	ll ret = sl[i - 1] + sr[i + k];
    	ll A = sum[i + k - 1] - sum[i - 1];
    	if(A > 0) ret += A;
    	res = max(res, ret);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3456
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int h1,h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    m1 += h1*60;
    m2 += h2*60;
    dunk(max(m2-m1-k,0));
    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def main():
    n = int(input())
    if n < 105:
        print(0)
        exit()
    arr = [x for x in list(range(105, n+1)) if x % 2 != 0]

    cnt = 0
    for x in arr:
        if len(make_divisors(x)) == 8:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
from random import *
D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
X=[0]*26
XX=X[:]
Y=X[:]
YY=X[:]
P=[]
SC=0
N,M,L,O=0,0,0,0
for i in range(D):
  for j in range(26):
    X[j]+=C[j]
    XX[j]+=X[j]
  N,M=-1,-10**20
  L,O=N,M
  for j in range(26):
    if Y==-1:
      N,M=0,X[0]+S[i][0]
    if M<X[j]+S[i][j]:
      L,O=N,M
      N,M=j,X[j]+S[i][j]
    elif O<X[j]+S[i][j]:
      L,O=j,X[j]+S[i][j]
  XX[N]-=X[N]
  X[N]=0
  P.append([N,L])
  SC+=X[N]
SC2=0
for i in range(10**5):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d][0]=q
    XX=YY[:]
    SC=SC2
  elif randrange(0,10000)==0:
    if randrange(0,2):
      P[d][0]=q
      XX=YY[:]
      SC=SC2
    else:
      P[d][1]=q
for d in range(D):
  for q in range(26):
    SC2=SC
    SC2-=S[d][P[d][0]]
    SC2+=S[d][q]
    for j in range(26):
      Y[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      Y[P[d][0]]+=C[P[d][0]]
      Y[q]+=C[q]
      Y[Z]=0
      YY[P[d][0]]+=Y[P[d][0]]
      YY[q]+=Y[q]
    if SC2-sum(YY)>=SC-sum(XX):
      P[d][0]=q
      XX=YY[:]
      SC=SC2
for i in range(10**5):
  SC2=SC
  d,q=randrange(0,D),randrange(0,26)
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d][0]=q
    XX=YY[:]
    SC=SC2
  elif randrange(0,10000)==0:
    if randrange(0,2):
      P[d][0]=q
      XX=YY[:]
      SC=SC2
    else:
      P[d][1]=q
for d in range(D):
  for q in range(26):
    SC2=SC
    SC2-=S[d][P[d][0]]
    SC2+=S[d][q]
    for j in range(26):
      Y[j]=0
    YY[P[d][0]],YY[q]=0,0
    for j in range(D):
      if j==d:
        Z=q
      else:
        Z=P[j][0]
      Y[P[d][0]]+=C[P[d][0]]
      Y[q]+=C[q]
      Y[Z]=0
      YY[P[d][0]]+=Y[P[d][0]]
      YY[q]+=Y[q]
    if SC2-sum(YY)>=SC-sum(XX):
      P[d][0]=q
      XX=YY[:]
      SC=SC2
for i in range(D):
  SC2=SC
  d,q=i,P[i][1]
  SC2-=S[d][P[d][0]]
  SC2+=S[d][q]
  for j in range(26):
    Y[j]=0
  YY[P[d][0]],YY[q]=0,0
  for j in range(D):
    if j==d:
      Z=q
    else:
      Z=P[j][0]
    Y[P[d][0]]+=C[P[d][0]]
    Y[q]+=C[q]
    Y[Z]=0
    YY[P[d][0]]+=Y[P[d][0]]
    YY[q]+=Y[q]
  if SC2-sum(YY)>=SC-sum(XX):
    P[d]=P[d][::-1]
    XX=YY[:]
    SC=SC2
for i in range(D):
  print(P[i][0]+1)

Measured memory_bytes: 87336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c&&b!=c)
		cout<<"Yes"<<endl;
	else if(b==c&&a!=b&&a!=c)
		cout<<"Yes"<<endl;
	else if(a==c&&a!=b&&b!=c)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256