akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int answer = 0;
  for (int i=0; i<2; i++) {
    if (A < B) {
      answer += B;
      B--;
    }
    else {
      answer += A;
      A--;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 1000000007
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

ll k;
string s;
ll n;
ll dp[1000][4][2];

ll solve(ll idx, ll k, ll tight)
{
    if(idx == n)
    {
        if(k == 0)
            return 1;
        else
            return 0;
    }
    ll end = s[idx] - '0';
    if(tight)
    {
        end = 9;
    }
    ll &ans = dp[idx][k][tight];
    if(ans != -1)
        return ans;
    ans = 0;
    for(ll i = 0; i <= end; ++i)
    {
        if(i == 0)
        {
            if(i == end)
            {
                ans += solve(idx + 1, k, tight);
            }
            else
            {
                ans += solve(idx + 1, k, 1);
            }
        }
        else
        {
            if(k == 0)
                continue;
            if(i == end)
            {
                ans += solve(idx + 1, k - 1, tight);
            }
            else
            {
                ans += solve(idx + 1, k - 1, 1);
            }
        }
    }
    return ans;
}


int main()
{
    Minato_Namikaze
    
    memset(dp, - 1, sizeof dp);
    cin >> s >> k;
    n = (ll)s.size();
    ll ans = solve(0, k, 0);
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
// using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  string s;
  cin >> s;
  if (s[s.length() - 1] == 's')
    cout << s << "es" << endl;
  else
    cout << s << "s" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=3010,MOD=998244353;

int dp[N][N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a;i<=c;i++)
        for(int j=b;j<=d;j++)
            dp[i][j]=(dp[i][j]+
                      dp[i-1][j]*j+
                      dp[i][j-1]*i-
                      dp[i-1][j-1]*(i-1)*(j-1))%MOD;
    cout<<(dp[c][d]+MOD)%MOD;
}


Measured memory_bytes: 74156
def char_int(x):
	if x=='A':
		return 0
	elif x=='B':
		return 1
	else:
		return 2


cup=['A','B','C']
while True:
	try:
		a,b=map(str,input().split(','))
		x,y=char_int(a),char_int(b)
		cup[x],cup[y]=cup[y],cup[x]

	except EOFError:
		break

if cup[0]=='A':
	print('A')
elif cup[1]=='A':
	print('B')
else:
	print('C')

Measured memory_bytes: 7516
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int ans = 0;
    int even = n*(n-1);
    even = even/2;
    int odd = m*(m-1);
    odd = odd/2;
    ans = even + odd;
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a;
	set<int> st;
	for(int i = 0; i < n; i++)
	{
		cin >> a;
		st.insert(a);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 764
N = int(input())
isopen = [list(map(int,input().split())) for i in range(N)]
gain = [list(map(int,input().split())) for i in range(N)]

ans = -float('inf')
for i in range(1,2**10):
    tmp = 0
    for n in range(N):
        c = 0
        for b in range(10):
            if ((i >> b)&1) & isopen[n][b]:
                c += 1
        tmp += gain[n][c]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 3064
from bisect import bisect_left


def solve(string):
    a, b, q, *stx = map(int, string.split())
    s = [-10**10] + stx[:a] + [2 * 10**10]
    t = [-10**10] + stx[a:a + b] + [2 * 10**10]
    # x = dict([])
    ans = []
    i_s = 0
    i_t = 0
    for _x in stx[-q:]:
        """
        while s[i_s] < _x:
            i_s += 1
        while t[i_t] < _x:
            i_t += 1
        """
        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)
        ls, rs = _x - s[i_s - 1], s[i_s] - _x
        lt, rt = _x - t[i_t - 1], t[i_t] - _x
        r_max = max(rs, rt)
        l_max = max(ls, lt)
        """
        x[_x] = min([
            r_max - _x, _x - l_min, rt - ls + min(rt - _x, _x - ls),
            rs - lt + min(rs - _x, _x - lt)
        ])
        """
        ans.append(
            str(
                min(r_max, l_max, rt + ls + (rt if rt < ls else ls),
                    rs + lt + (rs if rs < lt else lt))))
    # return "\n".join([str(x[_x]) for _x in stx[-q:]])
    return "\n".join(ans)


if __name__ == '__main__':
    n, m, l = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, l) + '\n'.join([input() for _ in range(n + m + l)])))


Measured memory_bytes: 39524
// Author: Shusuke Ueda
// AOJ GRL_1_C (All Pairs Shortest Path)

#include <iostream>
#include <limits>
#include <vector>

namespace graph {
    template <typename T>
    class AdjacencyListGraph {
        int n;
        std::vector<std::vector<T>> cost;

        T inf = std::numeric_limits<T>::max() / 2;

      public:
        AdjacencyListGraph(int init_n): n(init_n) {
            cost.assign(n, std::vector<T>(n, inf));
            for (int i = 0; i < n; i++) {
                cost[i][i] = 0;
            }
        }

        void add_directed_edge(int u, int v, T c) {
            cost[u][v] = std::min(cost[u][v], c);
        }
        void add_undirected_edge(int u, int v, T c) {
            add_directed_edge(u, v, c);
            add_directed_edge(v, u, c);
        }
        void all_pairs_shortest_path() {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    for (int k = 0; k < n; k++) {
                        if (cost[j][i] != inf and cost[i][k] != inf) {
                            cost[j][k] = std::min(cost[j][k], cost[j][i] + cost[i][k]);
                        }
                    }
                }
            }
        }

        T get_inf() {
            return inf;
        }
        bool is_inf(int u, int v) {
            return cost[u][v] == inf;
        }
        T get_cost(int u, int v) {
            return cost[u][v];
        }
        bool has_negative_loop() {
            bool res = false;
            for (int i = 0; i < n; i++) {
                if (cost[i][i] < 0) {
                    res = true;
                    break;
                }
            }
            return res;
        }
        
        friend std::ostream& operator << (std::ostream& os, const AdjacencyListGraph g) {
            for (int i = 0; i < g.n; i++) {
                for (int j = 0; j < g.n; j++) {
                    if (j > 0) {
                        std::cout << " ";
                    }
                    if (g.cost[i][j] == g.inf) {
                        std::cout << "INF";
                    } else {
                        std::cout << g.cost[i][j];
                    }
                }
                if (i < g.n - 1) {
                    std::cout << std::endl;
                }
            }
            return os;
        }
    };
}

using lint = int_fast64_t;

int main() {
    int n, e;
    std::cin >> n >> e;
    graph::AdjacencyListGraph<lint> alg(n);
    for (int i = 0; i < e; i++) {
        int s, t;
        lint d;
        std::cin >> s >> t >> d;
        alg.add_directed_edge(s, t, d);
    }

    alg.all_pairs_shortest_path();

    if (alg.has_negative_loop()) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        std::cout << alg << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3276
/*
 *
 * Author: r3gz3n
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <utility>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
		int a, b, c, d;
		in >> a >> b >> c >> d;
		if (a*b < c*d) out << c*d << endl;
		else out << a*b << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}




Measured memory_bytes: 256
# div2019B - RGB Boxes
r, g, b, n = list(map(int, input().rstrip().split()))
cnt = 0
for i in range(n // r + 1):
    for j in range((n - r * i) // g + 1):
        if (n - i * r - j * g) % b == 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 40300
from collections import deque

n, m = map(int, input().split())
u = [[] for _ in range(n)] 

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    u[a].append(b)
    u[b].append(a)

q = deque([0])
ans = [-1] * n
count = 0

while len(q):
    p = q.popleft()
    for x in u[p]:
        if ans[x] == -1:
            ans[x] = p+1
            q.append(x)

ans[0] = 'Yes'

for i in range(n):
    print(ans[i])

Measured memory_bytes: 96864
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        q: usize,
        s: chars,
        lr: [(usize, usize);q],
    }

    let mut sum = vec![0; n];

    for i in 1..n {
        if s[i - 1] == 'A' && s[i] == 'C' {
            sum[i] = sum[i - 1] + 1;
        } else {
            sum[i] = sum[i - 1];
        }
    }

    for (l, r) in lr {
        println!("{}", sum[r - 1] - sum[l - 1]);
    }
}


Measured memory_bytes: 6908
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    string S;
    cin >> S;
    int n = S.size(), r_cnt = 1, l_cnt = 0, r_idx, l_idx;
    vector<int> ans(n, 0);
    char prev = 'R';
    for (int i = 1; i < n; i++) {
        if (S[i] == 'R') {
            if (prev == 'R') {
                r_cnt += 1;
            } else {
                ans[r_idx] += (r_cnt / 2 + r_cnt % 2) + (l_cnt / 2);
                ans[l_idx] += (l_cnt / 2 + l_cnt % 2) + (r_cnt / 2);
                r_cnt = 1, l_cnt = 0;
            }
        } else {
            l_cnt += 1;
            if (prev == 'R') {
                r_idx = i - 1;
                l_idx = i;
            }
            if (i == n - 1) {
                ans[r_idx] += (r_cnt / 2 + r_cnt % 2) + (l_cnt / 2);
                ans[l_idx] += (l_cnt / 2 + l_cnt % 2) + (r_cnt / 2);
            }
        }
        prev = S[i];
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << (i != n - 1 ? " " : "\n");
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int> 


int main(){
    long int x;
    cin >> x;
    long int ans = 0;
    long int c = 100;
    while(c < x){
        c += (c / 100);
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char S[7];

    //input
    cin >> S;

    if(S[2] == S[3] && S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import itertools
N = input()

ans = 0
brank = len(N) -1

S = list(itertools.product([0,1],repeat=brank))

ans = 0
for K in S:
    s = 0
    for i,value in enumerate(K):
        if value == 1:
            ans += int(N[s:i+1])
            s = i + 1
    ans += int(N[s:])
print(ans)

Measured memory_bytes: 39664
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int SIZE=100005;
const long long INF=1e9;
int n,a,b,h[SIZE];

bool check(long long times){
	long long t=times;
	for(int i=0;i<n;i++){
		if(times*b>=(long long)h[i]);
		else if(times*a>=(long long)h[i]){
			t-=(long long)ceil((double)((double)(h[i]-times*b))/((double)(a-b)));
			if(t<0) return false;
		}
		else return false;
	}
	return true;
}

int main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++) cin>>h[i];
	long long lb=-1,rb=INF;
	while(rb-lb>1){
		long long mid=(lb+rb)/(long long)2;
		if(check(mid)){
			rb=mid;
		}
		else{
			lb=mid;
		}
	}
	cout<<rb<<endl;
	return 0;
}


Measured memory_bytes: 640
mod = 1000000007
eps = 10**-9
inf = 10**16


def main():
    import sys
    input = sys.stdin.buffer.readline

    H, W, K = map(int, input().split())
    grid = [[0] * W for _ in range(H)]
    for _ in range(K):
        h, w, v = map(int, input().split())
        grid[h-1][w-1] = v

    dp0 = [[-inf] * W for _ in range(H)]
    dp1 = [[-inf] * W for _ in range(H)]
    dp2 = [[-inf] * W for _ in range(H)]
    dp3 = [[-inf] * W for _ in range(H)]
    dp0[0][0] = 0
    if grid[0][0] > 0:
        dp1[0][0] = grid[0][0]
    for h in range(H):
        for w in range(W):
            if w-1 >= 0:
                dp0[h][w] = max(dp0[h][w], dp0[h][w-1])
                dp1[h][w] = max(dp1[h][w], dp1[h][w - 1])
                dp2[h][w] = max(dp2[h][w], dp2[h][w - 1])
                dp3[h][w] = max(dp3[h][w], dp3[h][w - 1])
            if h-1 >= 0:
                dp0[h][w] = max(dp0[h][w], dp0[h-1][w], dp1[h-1][w], dp2[h-1][w], dp3[h-1][w])
            v = grid[h][w]
            if v > 0:
                if w-1 >= 0:
                    dp1[h][w] = max(dp1[h][w], dp0[h][w - 1] + v)
                    dp2[h][w] = max(dp2[h][w], dp1[h][w - 1] + v)
                    dp3[h][w] = max(dp3[h][w], dp2[h][w - 1] + v)
                if h-1 >= 0:
                    dp1[h][w] = max(dp1[h][w], dp0[h-1][w] + v, dp1[h-1][w] + v, dp2[h-1][w]+v, dp3[h-1][w]+v)
    print(max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1], dp3[-1][-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 423700
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define mod 1e9 + 7
#define ll long long
#define all(c) c.begin(), c.end()
#define peek(v)			\
    for (auto i : v) 	\
        cout << i << ' ';
#define rep(i, begin, end)		\
    for (__typeof(end)			\
    i = (begin) - ((begin) > (end));	\
    i != (end) - ((begin) > (end));		\
    i += 1 - 2 * ((begin) > (end)))

void solve() 
{
	int a,b;
	char op;
	cin >> a >> op >> b;
	if(op=='+') cout << a+b;
	else if(op=='-') cout << a-b;
	else cout << -1;
}

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

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

int main(){
  int n,m;
  cin>>n>>m;
  Graph G(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  int seen[n+100]={};
  for(int x:G[0]){
    seen[x]++;
  }
  for(int x:G[n-1]){
    seen[x]++;
    if(seen[x]==2){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 15708
n = int(input())
a = list(map(int,input().split()))

m = 10 ** 9
cnt = 0
SUM = 0
for i in a:
    if i < 0:
        cnt += 1
        SUM += - i
        if m > -i:m = -i
    else:
        SUM += i
        if m > i:m = i

if cnt % 2 == 0:
    print(SUM)
else:
    print(SUM - 2 * m)

Measured memory_bytes: 14212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	int x,n;
	cin>>x>>n;
	int a[102]={0};
	for(int i=0;i<n;i++){
		int y;
		cin>>y;
		a[y]=1;
	}	
	int mn=1e9,ind;
	for(int i=0;i<=101;i++){
		if(mn>abs(i-x)&&!a[i]){
			mn=abs(i-x);
			ind=i;
		}
	}
	cout<<ind<<endl;
}



Measured memory_bytes: 3580
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    p_list = list(map(int, input().split()))
    x = sorted(list(set(p_list)))
    max_num = 10**6

    dp = [0] * (max_num + 1)
    for j in p_list:
        dp[j] += 1

    for i in range(1,len(dp)):
        if dp[i]:
            for j in range(i*2, len(dp), i):
                dp[j] = 0

    print(dp.count(1))
   
   
if __name__ == "__main__":
    main()

Measured memory_bytes: 34024
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9

inline int gcd(int m, int n) {
  int temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

int main() {
  int N;
  cin >> N;
  
  int a;
  vector<int> A;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    cin >> a;
    A.emplace_back(a);
  }

  int t = A[0];
  for (int i = 1; i < N; i++) {
    t = gcd(t, A[i]);
  }
  cout << t << endl;
  
  return 0;
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int main() {
  int N; cin >> N;
  int Coin1; cin >> Coin1;
  
  int A = N % 500;
  if (Coin1 >= A) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

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

int ans[1024][1024];

void construct() {
	ans[1][1] = 1;
	for (int k = 1; k <= 9;k++) {
		rep(i, 1 << k) {
			rep(j, 1 << k) {
				ans[i][j + (1 << k)] = ans[i + (1 << k)][j] = ans[i][j];
				ans[i + (1 << k)][j + (1 << k)] = 1 ^ ans[i][j];
			}
		}
	}
}

signed main() {
	int n, m; cin >> n >> m;
	construct();
	rep(i, (1 << n)-1) {
		rep(j, (1 << m)-1) {
			cout << (ans[i+1][j+1]^ans[i][j+1]^ans[i+1][j]^ans[i][j]);
		}cout << endl;
	}
}

Measured memory_bytes: 9472
#include <stdio.h>
int main(void){
        int H,W,i,j;
    while(1){
        if(H==0&&W==0){
            break;
        }
        scanf("%d %d",&H,&W);
        for(i=0;i<H;i++){
            if((i%2)==0){
            for(j=0;j<W;j++){
                if((j%2)==0){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
            }
            else{
            for(j=0;j<W;j++){
                if((j%2)==0){
                    printf(".");
                }
                else{
                    printf("#");
                }}}
            
            printf("\n");
        }
        if(H!=0||W!=0){
        printf("\n");}
    }
    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    if(s.size() == 2) cout << s << endl;
    else {
        reverse(s.begin(), s.end());
        cout << s << endl;
    }
    return 0;
}

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

intl pow1(intl x,intl y){
	intl res=1;
	while(y){
		if(y%2){
			res*=x;
		}
		x*=x;
		y/=2;
	}
	return res;
}
intl k0,ans=0;

void fun(intl n,intl k,intl m){
	if(k==1){
		m+=n;
		k0-=1;
		if(k0==0){
			ans=m;
		}
		return;
	}
	else{
		intl k1=pow1(10,k-1);
		intl n1=n*k1;
		for(intl i=0;i<=9;i++){
			if(abs(n-i)<=1){
				fun(i,k-1,m+n1);
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,k;
	cin>>k0;
	for(i=1;;i++){
		for(j=1;j<=9;j++){
			fun(j,i,0);
			if(ans>0){
				break;
			}
		}
		if(ans>0){
			break;
		}
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
int n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  	int t;
    cin >> n>>t;
  	int mina=INF;
    for (int i = 0; i < n; i++)
    {
        int temp, temp1;
        cin >> temp>>temp1;
        if(temp1<=t) chmin(mina,temp);
    }
    if(mina==INF) return cout<<"TLE"<<"\n",0;
    cout << mina << "\n";
}



Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

#define int ll

signed main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n){
        cin >> a[i];
    }
    REP(i, n){
        cin >> b[i];
    }
    
    ll sumx = accumulate(a.begin(), a.end(), 0LL);
    ll sumx_now = accumulate(b.begin(), b.end(), 0LL);

    priority_queue<pii> pq;
    vector<int> now = b;
    int ans = 0;

    REP(i, n){
        pq.push(make_pair(b[i], i));
    }

    while(!pq.empty() && sumx_now > sumx){
        auto top = pq.top();
        pq.pop();

        int num_top = top.first;
        int idx_top = top.second;

        int num1 = now[(idx_top + 1) % n];
        int num2 = now[(idx_top + n - 1) % n];

        int second = max(num1, num2);

        int num12 = num1 + num2;
        int diff = num_top - second;


        // でかいやつが隣同士で2つのときはスキップ、二度とやらない
        if((num1==num_top || num2==num_top)){
            continue;
        }

        int timestosub = diff / num12 + 1;
        if(diff % num12 == 0)
            timestosub--;

        // 通り過ぎ防止
        if(num_top - (timestosub * num12) < a[idx_top]){
            timestosub = (num_top - a[idx_top]) / num12;
        }

        // もう引けない→二度とやらない
        if(timestosub == 0)
            continue;

        int num_new = num_top - (num12 * timestosub);

        ans += timestosub;
        pq.push(make_pair(num_new, idx_top));
        now[idx_top] = num_new;
        sumx_now = sumx_now - num_top + num_new;

    }

    cout << ((sumx_now == sumx && a == now) ? ans : -1) << endl;

    return 0;
}

Measured memory_bytes: 7156
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    xu = [list(input().split()) for _ in range(n)]
    ans = 0
    for i in range(n):
        if xu[i][1] == "JPY":
            ans += int(xu[i][0])
        else:
            ans += (float(xu[i][0]) * 380000)
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int d;
Int g;
vector<Int> p,c;
int main(){
  cin >> d >> g;
  p.resize(d);c.resize(d);
  rep(i,d) cin >> p[i] >> c[i];
  Int res = 1<<29;
  for(int bit=0;bit<(1<<d);bit++){
    Int sum = 0;
    Int num = 0;
    for(int i=0;i<d;i++){
      if(bit&(1<<i)) sum+=c[i]+p[i]*100*(i+1),num+=p[i];
    }
    if(sum>=g) res = min(res,num);
    else{
      for(int i=d-1;i>=0;i--){
        if(bit&(1<<i)) continue;
        for(int j=0;j<p[i];j++){
          if(sum>=g) break;
          sum+=100*(i+1);
          ++num;
        }
      }
      res=min(res,num);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = [Z() for _ in range(N)]
    output = 0

    def makeRun(i, s):
        #A[i]とA[i+1]でシュンツ作る
        if A[i] <= 0 or A[i+1] <= 0: return s
        A[i] -= 1
        A[i+1] -= 1
        s += 1
        return s

    def makeTriple(i, s):
        #A[i]でコーツ作る
        if A[i] < 0: return s
        s += A[i]//2
        A[i] %= 2
        return s

    for i in range(N-1):
        if A[i]%2: output = makeRun(i, output)
        output = makeTriple(i, output)
    output = makeTriple(N-1, output)
    print(output)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 13116
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    double ans=0;
    int n;cin>>n;
    vi v(n);cin>>v;
    for(int i:v){
        ans+=(1.0/i);
    }
    cout<<prec(10)<<1/ans;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n,m=map(int,input().split( ))
s1=set()
sn=set()
for _ in range(m):
    a,b=map(int, input().split( ))
    if a==1 and b not in s1:
        s1.add(b)
    elif b==1 and a not in s1:
        s1.add(a)
    if a==n and b not in sn:
        sn.add(b)
    elif b==n and a not in sn:
        sn.add(a)
if s1&sn:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 54236
#include <stdio.h>
#include <math.h>
  
#define ELEMENT_CNT_MIN (1)
#define ELEMENT_CNT_MAX (1000000)
#define ELEMENT_MIN     (0)
#define ELEMENT_MAX     (1000000000)
#define SHELL_SROT_CNT_MIN (1)
#define SHELL_SROT_CNT_MAX (100)
#define SUCCESS (0)
#define FAILURE (-1)
 
void shell_sort(int *p_arr, int size);
int insertion_srot(int *p_arr, int size, int interval);
void put_arr(const int *p_arr, int size);
int get_int_sequence(int *p_num, int min, int max, int size);
int get_int(int *p_num, int min, int max);
int judge_constraint(int test_num, int min, int max);
 
  
int main(void){
      
    int element_num;
    int element[ELEMENT_CNT_MAX];
      
    if(get_int(&element_num, ELEMENT_CNT_MIN, ELEMENT_CNT_MAX) == FAILURE)
    {
        return FAILURE;
    }
      
    if(get_int_sequence(&element[0], ELEMENT_MIN, ELEMENT_MAX, element_num) == FAILURE)
    {
        return FAILURE;
    }
     
    shell_sort(&element[0], element_num);
     
    put_arr(&element[0], element_num);
     
    return SUCCESS;
}
  
int insertion_srot(int *p_arr, int size, int interval)
{
    int cnt = 0;    /* calculation amount */
    int i;
    int j;
    int locator;
     
    for(i = interval; i < size; i++)
    {
        locator = p_arr[i];
        j = i - interval;
    	
        while(j >= 0 && p_arr[j] > locator)
        {
            p_arr[j + interval] = p_arr[j];
            j = j - interval;
            cnt++;
        }
        p_arr[j + interval] = locator;
    }
     
    return cnt;
}
 
void shell_sort(int *p_arr, int size)
{
   int cnt = 0;
   int interval = 1;    /* (pow(3, 0) - 1) / 2 == 0 */
   int i;
   int shell_sort_cnt = SHELL_SROT_CNT_MIN;
   int G[SHELL_SROT_CNT_MAX];
    
  for(i = shell_sort_cnt ;i <= SHELL_SROT_CNT_MAX; i++)
  {
      interval =  (int)((pow(3, i) - 1) / 2);
      if(interval > size)
      {
          shell_sort_cnt = i - 1;
          printf("%d\n",shell_sort_cnt);
          break;
      }
      G[i - 1] = interval;
  }
    
    
   for(i = shell_sort_cnt;;i--)
   {
       cnt += insertion_srot(p_arr, size, G[i - 1]);
       printf("%d ", G[i - 1]);
       if(G[i - 1] <= 1)
       {
           printf("\n");
           break;
       }
   }
    
   printf("%d\n", cnt);
    
   return;
}
  
void put_arr(const int *p_arr, int size)
{
    int i;
      
    for(i = 0; i < size; i++)
    {
        printf("%d\n", p_arr[i]);
    }
     
    return;
}
  
int get_int_sequence(int *p_num, int min, int max, int size)
{
    int i;
      
    for(i = 0; i < size; i++)
    {
        if(get_int(&p_num[i], min, max) == FAILURE)
        {
            return FAILURE;
        }
    }
      
    return SUCCESS;
}
  
int get_int(int *p_num, int min, int max)
{
    scanf("%d%*c", p_num);
      
    if(judge_constraint(*p_num, min, max) == FAILURE)
    {
        return FAILURE;
    }
      
    return SUCCESS;
}
int judge_constraint(int test_num, int min, int max)
{
    if((test_num < min) || (test_num > max))
    {
        return FAILURE;
    }
      
    return SUCCESS;
}

Measured memory_bytes: 5836
a,b=map(int,input().split())
h=100
w=100
g=h*w
A=[0 for i in range(g)]

a-=1
b-=1
ii=0
jj=0
for i in range(a):
   A[ii]=1
   ii+=2
   if i%(w//2)==w//2-1 :
       ii+=1+w
for i in range(b):
   A[-1*(jj+1)]=1
   jj+=2
   if i%(w//2)==w//2-1 :
       jj+=1+w

#print(A)
print("{} {}".format(h,w))
ans=""
for i in range(g):
    if i%w==0 and i!=0 :
        print(ans)
        ans=""
    
    if i>=g//2 :
        A[i]=(A[i]+1)%2
    if A[i]==1 :
        ans+="."
    else :
        ans+="#"

print(ans)


Measured memory_bytes: 3188
# coding:utf-8

import sys


input = sys.stdin.readline


def inpl(): return list(map(int, input().split()))


N = int(input())
X = inpl()
A = sorted(X)
mid = A[N//2]

for i in range(N):
    if X[i] < mid:
        print(A[N//2])
    else:
        print(A[N//2 - 1])


Measured memory_bytes: 26756
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,c=0,i;
  cin>>n;
  string s;
  cin>>s;
  for(i=0;i<n-1;i++)
  {
  if(s[i]!=s[i+1])
  {
    c++;
  }
  }
  cout<<(c+1)<<endl;
}

Measured memory_bytes: 3736
# -*- coding: utf-8 -*-

def main():

    N = int(input())

    ans = 0

    for i in range(1, N+1):
        if i % 2 == 1:

            count = 0

            for j in range(1, i+1):
                if i % j == 0:
                    count +=1
                if count == 8:
                    ans += 1
        
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define F first
#define S second
#define MP make_pair
#define PB push_back
 
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)
int main(){
	int n,sum=0;
	rd(n);
	VI a(n);
	fr(i,0,n){
		rd(a[i]);
		sum+=a[i];
	}
	int avg=ceil((double)sum/(double)n);
	//wd(avg);
	ll cost=0,ans=INT_MAX;
	fr(j,-100,101){
		cost=0;
	fr(i,0,n){
		cost+=pow(abs(j-a[i]),2);
	}
	ans=min(ans,cost);
}
	wl(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>

struct point {
  int x;
  int y;
};

using namespace std;

int main(void) {
  int W = 0;
  int H = 0;
  int N = 0;
  
  cin >> W >> H >> N;

  point start;
  
  cin >> start.x >> start.y;

  int cost = 0;
  
  for (int n = 1; n < N; n++) {
    point goal;

    cin >> goal.x >> goal.y;

    int distance = 0;

    if (((start.x < goal.x) && (start.y < goal.y) )
	       || ((goal.x < start.x) && (goal.y < start.y))) {
      point d = (point) {abs(goal.x - start.x), abs(goal.y - start.y)};

      distance = d.x + d.y;

      while ((d.x > 0) && (d.y > 0)) {
	d.x--;
	d.y--;
      
	distance--;
      }
    } else {
      distance = abs(goal.x - start.x) + abs(goal.y - start.y);
    }
    
    cost += distance;

    start.x = goal.x;
    start.y = goal.y;
  }
  
  cout << cost << endl;
  
  return 0;
}

Measured memory_bytes: 1160
from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
Graph =[[] for i in range(N)]
for i in range(M):
    L,R,D = map(int,input().split())
    Graph[L-1].append((R-1,D))
    Graph[R-1].append((L-1 ,-D))
visit=[False]*N
dist=[0]*N
for i in range(N):
    if visit[i]==False:
        visit[i]=True
        A = deque()
        A.append(i)
        while A:
            x = A.pop()
            for y,d in Graph[x]:
                if (visit[y] == True) and (dist[y]!=d+dist[x]):
                    print('No')
                    sys.exit()
                elif (visit[y] == False):
                    visit[y]=True
                    A.append(y)
                    dist[y]=d+dist[x] 
    
print('Yes')

Measured memory_bytes: 67096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair <int,int> ii ;
typedef vector < ii > vii ;
typedef vector < vii > viii ;
#define rep(i,n)                   for( ll i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++) 
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define db double 
#define fi first
#define se second
#define mod 1000000007

int g[1000][1000];
ll dp[1000][1000];

ll calc(int i, int j, int h, int w) {
	if(i==h && j==w) return 1;
	else if(i>h || j>w) return -1;
	if(dp[i][j]!=-1) return dp[i][j];
	ll c=0;
	ll x=calc(i+1,j,h,w);
	ll y=calc(i,j+1,h,w);
	if(x!=-1 && g[i+1][j]==1) c=(c%mod+x%mod)%mod;
	if(y!=-1 && g[i][j+1]==1) c=(c%mod+y%mod)%mod;
	dp[i][j]=c%mod;
	return c%mod;
}

int main() {
   int h,w; cin>>h>>w;
   rep(i,h) {
   		rep(j,w) {
   			char c; cin>>c;
   			if(c=='.') g[i][j]=1; else g[i][j]=0;
   		}
   }
   rep(i,1000) rep(j,1000) dp[i][j]=-1;
   cout<<calc(0,0,h-1,w-1)%mod;
}

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

const string weather[3] = {"Sunny","Cloudy","Rainy"};

int main(){
    string s;
    int i,k;
    cin >> s;
    for(i=0;i<3;i++){
        if(s==weather[i]){
            k=i;
            break;
        }
    }
    if (k==2){
        k=0;
    }else{
        k=k+1;
    }
    cout << weather[k];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

map<int, pair<int, int>> d;

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    REP(i, H) {
        REP(j, W) {
            int tmp;
            cin >> tmp;
            d[tmp] = make_pair(i, j);
        }
    }
    int Q;
    cin >> Q;
    vector<int> L(Q);
    vector<int> R(Q);
    REP(i, Q) { cin >> L[i] >> R[i]; }
    vector<int> acm(H * W);
    for(int i = 1; i <= H * W; i++) {
        if(i <= D) {
            acm[i] = 0;
        } else {
            int x1 = d[i].first;
            int y1 = d[i].second;
            int x2 = d[i - D].first;
            int y2 = d[i - D].second;
            acm[i] = acm[i - D] + abs(x2 - x1) + abs(y2 - y1);
        }
    }

    REP(i, Q) {
        if(L[i] == R[i] and R[i] == 0) {
            cout << 0 << endl;
        } else {
            cout << acm[R[i]] - acm[L[i]] << endl;
        }
    }
}

Measured memory_bytes: 7936
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

long long dp[51][51][3000]={};

int main(){

	int n,m;
	cin>>n>>m;

	vector<string> A(n),B(m);
	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;i++){
		for(int j=0;j<=n-m;j++){

			bool ok=true;

			for(int k=0;k<m && ok;k++){
				for(int l=0;l<m && ok;l++){
					if(A[i+k][j+l]!=B[k][l]) ok=false;
				}
			}

			if(ok){
				cout<<"Yes"<<endl;
				return 0;
			}

		}
	}

	cout<<"No"<<endl;
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{ 
  bool b;
  int n,ans=0,a[20],x[20][20],y[20][20];
  
  cin>>n;
  for(int i=1;i<n+1;i++){
    cin>>a[i];
    for(int u=1;u<a[i]+1;u++){
      cin>>x[i][u]>>y[i][u];
    }
  }
  for(int bit=1;bit<(1<<n);bit++){
    b=true;
    for(int i=1;i<n+1;i++){
      if(!(bit&(1<<(i-1))))continue;
      for(int u=1;u<a[i]+1;u++){
        if(((bit>>(x[i][u]-1))&1)^y[i][u])b=false;
      }
    }
    if(b){ans=max(ans,__builtin_popcount(bit));}
  }
  cout<<ans<<endl;
  return 0;
}



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

int c_neighbor[31];             // c???closed neighbor

// Check whether a set dset of size k is a dominating set of a graph
// of n vertices.
bool is_dominating_set(int dset, int n)
{
  int dominated = 0;
  for (int v=0;v<n;v++)
  {
    if (dset % 2)              // v???dset?????????
    {
      dominated |= c_neighbor[v];
    }
    dset = dset >> 1;
  }
  if (dominated == (1<<n)-1) return true;
  else return false;
}

int main()
{
  int n, m;
  int u, v;
  while (cin >> n >> m)
  {
    bool found = false;

    if (n == 0) return 0;
    for (int i=0;i<n;i++) c_neighbor[i]=1<<i;
    for (int i=0;i<m;i++)
    {
      cin >> u >> v;
      c_neighbor[u] |= (1<<v);
      c_neighbor[v] |= (1<<u);
    }

    int dset;
    for (int k=1;k<=n;k++)
    {
      // {0,...,n-1}?????¨???????????§????????????k??§???????????????????????????
      // ????????°???????????°????????????????????£??¬???????????????????????§
      dset = (1 << k) - 1;
      while (dset < 1<<n)
      {
        if (is_dominating_set(dset, n))
        {
          cout << k << endl;
          found = true;
        }
        if (found) break;

        int x = dset & -dset;
        int y = dset + x;
        dset = ((dset & ~y) / x >> 1) | y;
      }
      if (found) break;
    }
  }
}

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

int main()
{
	string s;
	cin >> s;

	if (s[2] == s[3] && s[4] == s[5])
	{
		std::cout << "Yes" << endl;
	}
	else
	{
		std::cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
S = input()
if S[0] == S[1] == S[2] == S[3]:
  print('No')
elif (S[0] == S[1] and S[2] == S[3]) or (S[0] == S[2] and S[1] == S[3]) or (S[0] == S[3] and S[1] == S[2]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    s,t = LI()
    e = collections.defaultdict(list)
    for _ in range(m):
        u,v,d = LI()
        e[u].append((v,d))
        e[v].append((u,d))

    def search(s,t):
        d = collections.defaultdict(lambda: inf)
        dc = collections.defaultdict(int)
        d[s] = 0
        dc[s] = 1
        q = []
        heapq.heappush(q, (0, s))
        v = collections.defaultdict(bool)
        while len(q):
            k, u = heapq.heappop(q)
            if v[u]:
                continue
            v[u] = True

            dc[u] %= mod
            if u == t:
                return (d,dc)

            uc = dc[u]

            for uv, ud in e[u]:
                if v[uv]:
                    continue
                vd = k + ud
                if d[uv] < vd:
                    continue
                if d[uv] > vd:
                    d[uv] = vd
                    dc[uv] = uc
                    heapq.heappush(q, (vd, uv))
                elif d[uv] == vd:
                    dc[uv] += uc

        return (d,dc)

    d1,dc1 = search(s,t)
    d2,dc2 = search(t,s)
    rd = d1[t]
    kk = rd / 2.0

    r = dc1[t] ** 2 % mod
    for k in list(d1.keys()):
        t = d1[k]
        c = dc1[k]
        if t > kk:
            continue
        if t == kk:
            if d2[k] == t:
                r -= pow(c,2,mod) * pow(dc2[k],2,mod) % mod
            continue

        for uv, ud in e[k]:
            if d2[uv] >= kk or t + ud + d2[uv] != rd:
                continue
            r -= pow(c,2,mod) * pow(dc2[uv],2,mod) % mod

    return r % mod




print(main())


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

#define ALL(a) (a).begin(), (a).end()

using namespace std;

int main(){
    while(true){
        int n; cin >> n;
        if(n == 0)break;
        vector<int> a(n);
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        sort(ALL(a));
        int ans = (int)1e9;
        for(int i = 0; i < n-1; i++){
            ans = min (a[i+1] - a[i], ans);
        }
        cout << ans << endl;
    }

    return 0;
}




Measured memory_bytes: 3156
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var s = Console.ReadLine();
        long count = 1;
        for (int i = 0; i < s.Length-1; i++)
        {
            if (s[i] != s[i+1])
            {
                count++;
            }
        }
        var ans = count - 1;
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13280