akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll x[100000],y[100000];
int main()
{
    ll i,j,k;
    ll n,m;
    ll conx=(ll)0,cony=(ll)0;
    scanf("%lld %lld",&n,&m);
    for(i=0;i<n;i++)
        scanf("%lld",&x[i]);
    for(i=0;i<m;i++)
        scanf("%lld",&y[i]);
    for(i=0;i<n-1;i++){
        conx=(conx+((x[i+1]-x[i])*((i+1)*(n-i-1))%mod)%mod)%mod;
    }
    //prllf("%d %d\n",conx,cony);
    for(i=0;i<m-1;i++){
        cony=(cony+((y[i+1]-y[i])*((i+1)*(m-i-1))%mod)%mod)%mod;
    }
    printf("%lld",(conx*cony)%mod);
}


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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    vector<vector<int>> dp(h, vector<int>(w, h * w));
    dp[0][0] = (s[0][0] == '.' ? 0 : 1);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i + 1 < h) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i][j] == s[i + 1][j] || s[i + 1][j] == '.' ? 0 : 1));
            }
            if (j + 1 < w) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j] == s[i][j + 1] || s[i][j + 1] == '.' ? 0 : 1));
            }
        }
    }

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


Measured memory_bytes: 256
n = int(input())
C = list(map(int,input().split()))
C.sort(reverse = True)
mod = 10**9 + 7

pow2 = [1]*(n+1) + [1]
for i in range(n):
    pow2[i+1] = (pow2[i] * 2)%mod

ans = 0

for i,c in enumerate(C):
    ans += (c*(i*pow2[i-1]%mod + pow2[i])%mod)*pow2[n-i-1]
    ans %= mod

ans *= pow2[n]
ans %= mod
print(ans)


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


int main()
{
	int n, d;
	
	cin >> n >> d;
	
	int val = n / (2*d + 1);
	if(n%(2*d + 1)) val++;
	
	cout << val << "\n";
	
	return 0;
}


Measured memory_bytes: 256
import collections

mod = 2019

def main():
    S = list(input())
    lenS = len(S)
    Smod2019 = [0] * lenS
    tmp = 0
    for i in range(lenS):
        tmp += (pow(10, i, mod)*int(S[-(i+1)]))%mod
        Smod2019[i] = tmp%mod
    
    cnt = collections.Counter(Smod2019)
    cntitems = cnt.items()
    ans = 0
    #print(cntitems)
    for c in cntitems:
        if c[0] == 0:
            ans += c[1]
        ans += (c[1]*(c[1]-1))//2
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 17964
#include<bits/stdc++.h>
using namespace std;
int a[200],n,s=0;
int z,ans=1000000;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        z+=a[i];
    }
    for(int i=0;i<n;i++) {s+=a[i];ans=min(ans,abs(z-s*2));}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int h,w;
    cin >> h >> w;
    VS s(h);
    REP(i,0,h) cin >> s[i];
    int cnt = 0;
    REP(i,0,h) REP(j,0,w) if (s[i][j] == '.') ++cnt;
    VVI d(h,VI(w,3000));
    d[0][0] = 1;
    deque<PII> q;
    q.emplace_back(0,0);
    int dx[] = {0,-1,0,1};
    int dy[] = {-1,0,1,0};
    while (!q.empty()) {
        //auto [x,y] = q.front();
        auto p = q.front();
        int x = p.first, y = p.second;
        q.pop_front();
        REP(i,0,4) {
            if (x+dx[i] >= 0 && x+dx[i] < h && y+dy[i] >= 0 && y + dy[i] < w) {
                if (s[x+dx[i]][y+dy[i]] == '.') {
                    if (d[x+dx[i]][y+dy[i]] > d[x][y] + 1) {
                        d[x+dx[i]][y+dy[i]] = d[x][y] + 1;
                        q.emplace_back(x+dx[i], y+dy[i]);
                    }
                }   
            }
        }
    }
    if (d[h-1][w-1] == 3000) cout << -1 << endl;
    else cout << cnt - d[h-1][w-1] << endl;
}

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

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
n=7**7
d=[0]*n*2
for a in a:
    l,r=max(0,a-k)+n,a+k-~n
    a+=n
    while l<r:
        if l&1:
            d[a]=max(d[a],d[l]+1)
            l+=1
        if r&1:
            r-=1
            d[a]=max(d[a],d[r]+1)
        l>>=1
        r>>=1
    while a:
        a>>=1
        d[a]=max(d[a+a],d[a-~a])
print(max(d))

Measured memory_bytes: 126440
import java.util.Scanner;
import java.util.ArrayList;


class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		int a = 1;
		int b = 1;
		
		ArrayList<Integer> array = new ArrayList<Integer>();
		
		String str1 = "+";
		String str2 = "-";
		String str3 = "*";
		String str4 = "/";
		String str5 = "?";
		
		if(0 <= a && b <= 20000){
			while(true){
				
				a = sc.nextInt();
				String enzan = sc.next();
				b = sc.nextInt();
				int c = 0;
				
				
				
				if(enzan.equals(str1)){
					c = a + b;
					array.add(c);
				}
				else if(enzan.equals(str2)){
					c = a - b;
					array.add(c);
				}
				else if(enzan.equals(str3)){
					c = a * b;
					array.add(c);
				}
				else if(enzan.equals(str4)){
					c = a / b;
					array.add(c);
				}
				else if(enzan.equals(str5))
					break;
			
			}
		
		}
		
		for(int i = 0; i<array.size(); i++){
			
			System.out.println(array.get(i));
		}
	}

}

Measured memory_bytes: 26184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  if(N>=64){
    cout << 64 << endl;
  }
  if(N<64 && N>=32){
    cout << 32 << endl;
  }
  if(N<32 && N>=16){
    cout << 16 << endl;
  }
  if(N<16 && N>=8){
    cout << 8 << endl;
  }
  if(N<8 && N>=4){
    cout << 4 << endl;
  }
  if(N<4 && N>=2){
    cout << 2 << endl;
  }
  if(N==1){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, k = Is()
P = LI()
P_ = [(x+1)/2 for x in P]

ans = sum(P_[0:k])
tmp = ans
for i in range(n-k):
    tmp -= P_[i]
    tmp += P_[i+k]
    ans = max(tmp, ans)

print(ans)


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

const int mod = 1000*1000*1000+7;

int N;
vector<int> A, B;

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

    A.resize(N);
    B.resize(N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    for(int i = 0; i < N; i++) {
        scanf("%d", &B[i]);
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    int ans = 1;

    for(int i = N - 1; i >= 0; i--) {
        int s = i + 1, e = N - 1;
        int p = i;

        while(s <= e) {
            int m = (s + e)>>1;

            if(A[m] <= B[i]) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }
        s = i + 1, e = N - 1;
        int q = i;
        while(s <= e) {
            int m = (s + e)>>1;
            
            if(B[m] <= A[i]) {
                q = m;
                s = m + 1;
            }
            else e = m - 1;
        }

        ans = 1LL * ans * (max(p, q) - i + 1) % mod;
    }

    cout << ans;
}


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

void solve() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size(), res = INT_MAX;
	for (int i = 0; i <= n - m; i++) {
		int cnt = 0;
		for (int j = i; j < i + m; j++) {
			cnt += (s[j] != t[j - i]);
		}
		res = min(res, cnt);
	}
	cout << res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		solve();
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <vector>
#include <fstream>

using namespace std;

typedef long long ll;

struct P{
    int x, y;
};
int N;

int main(){
    while(1){
        N = 0;
        cin >> N;
        if(!N) break;
        // origin
        vector<P> ps;
        // cout << " asdfasdf"<< endl;
        int o_m; cin >> o_m;
        int ori_x, ori_y;
        for(int i=0; i<o_m; i++){
            int x, y; cin >> x >> y;
            // cout << "asdfa"<< endl;
            ps.push_back({x, y});
            if(!i){
                ori_x = x; ori_y = y;
            }
            ps[i].x -= ori_x; ps[i].y -= ori_y;
        }
        // cout << "111" << endl;
        vector<vector<P> > res(8);
        res[0] = ps;
        for(int i=1; i<4; i++){
            for(P u : res[i-1]){
                P nU = {u.y * -1, u.x};
                res[i].push_back(nU);
            }
        }
        for(int i=4; i<8; i++){
            for(P u : res[i-4]){
                P last = res[i-4][res[i-4].size()-1];
                P nU = {u.x - last.x, u.y - last.y};
                res[i].push_back(nU);
            }
            reverse(res[i].begin(), res[i].end());
        }   

        // if(N== 4)
        // for(int i=0; i<8; i++){
        //     for(P u : res[i]){
        //         cout << u.x << " " << u.y << endl;
        //     }
        //     cout << endl;
        // }

        // cout <<"--------" << endl;
        // cout << N;

        // cout << "111" << endl;

        for(int _=0; _<N; _++){
            // cout << "a" << endl;
            int m; cin >> m;
            int ori_x2, ori_y2;
            vector<P> ps2;
            for(int i=0; i<m; i++){
                int x, y; cin >> x >> y;
                ps2.push_back({x, y});
                if(!i){
                    ori_x2 = x; ori_y2 = y;
                }
                ps2[i].x -= ori_x2; ps2[i].y -= ori_y2;
            }
            // cout << "a"<< endl;
            // if(N== 4)
            // for(P u : ps2){
            //     cout << u.x << " " << u.y << endl;
            // }
            // cout << endl;
            if(m != o_m) continue;
            bool ok = true;
            for(int j=0; j<8; j++){
                for(int i=0; i<m; i++){
                    if(res[j][i].x != ps2[i].x) ok = false;
                    if(res[j][i].y != ps2[i].y) ok = false;
                    if(!ok) break;
                }
                if(ok){
                    cout << _+1 << endl;
                    break;
                }
                ok = true;
            }
        }

        cout << "+++++" << endl;
        // if(N == 4) break;
        // int a; cin >> a; cout << a << endl;
        // break;
    }

    return 0;
}

/*
5
5
0 0
2 0
2 1
4 1
4 0
5
0 0
0 2
-1 2
-1 4
0 4
5
0 0
0 1
-2 1
-2 2
0 2
5
0 0
0 -1
2 -1
2 0
4 0
5
0 0
2 0
2 -1
4 -1
4 0
5
0 0
2 0
2 1
4 1
4 0
*/


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

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

    int n, k;
    cin >> n >> k;
    int a[n], pre[n + 1] = {};
    bool ok = false;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pre[max(i - a[i], 0)]++;
        pre[min(i + a[i] + 1, n)]--;
        ok |= (a[i] < n);
    }

    while (k-- && ok) {
        ok = false;
        int cur = 0;
        for (int i = 0; i < n; i++)
            cur += pre[i], a[i] = cur, ok |= (a[i] < n);

        memset(pre, 0, sizeof pre);
        for (int i = 0; i < n; i++) {
            pre[max(i - a[i], 0)]++;
            pre[min(i + a[i] + 1, n)]--;
        }
    }

    for (int x : a)
        cout << x << ' ';
    cout << '\n';
}

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

int main() {
	string s;
	cin>>s;
	int count=0;
	for(int i=0;i<3;i++)
	  {
	  	  if(s[i]=='o')
	  	     ++count;
	  }
	 cout<<700+count*100<<"\n"; // your code goes here
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h.at(n-1-i);
    }
    /*
    for(int i=0;i<n;i++){
        cout << h.at(i) << endl;
    }
    */
    int ans=0;
    int temp=0;
    for(int i=1;i<n;i++){
        if(h.at(i-1)<=h.at(i)){
           temp++; 
        }else{
            //cout << temp << endl;
            temp = 0;
        }
        ans=max(temp,ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int a[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int K;
    cin >> K;
    cout << a[K - 1] << endl;
}


Measured memory_bytes: 256
import math
n, q = map(int, input().split())
l = 1 << math.ceil(math.log(n, 2))
inf = 2**31-1
a = [inf]*(2*l-1)

def set_value(i, num):
    k = l-1+i
    a[k] = num
    while k > 0:
        k = (k-1)//2
        num = min(a[2*k+1], a[2*k+2])
        if a[k] == num:
            break
        else:
            a[k] = num
            
def get_minimum(x, y, k=0, l=0, r=l-1):
    if x == l and r == y:
        return a[k]
    elif not l <= x <= y <= r:
        return inf
    mid = (l+r)//2
    left_value = get_minimum(x, min(mid, y), 2*k+1, l, mid)
    right_value = get_minimum(max(mid+1, x), y, 2*k+2, mid+1, r)
    return min(left_value, right_value)
    
ans = []
for _ in [None]*q:
    c, x, y = map(int, input().split())
    if c == 0:
        set_value(x, y)
    else:
        ans.append(get_minimum(x, y))
print("\n".join([str(n) for n in ans]))

Measured memory_bytes: 14792
(function () {
  function main () {
    var i, j;

    for (i = 1; i < 10; i += 1) {
      for (j = 1; j < 10; j += 1) {
        console.log(i + 'x' + j + '=' + i * j);
      }
    }
  }

  main();
}());

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const ll mod = 1777777777ll;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main()
{
  int s; cin >> s;
  combination C(100000);
  auto H = [&](int n, int r) {
    return C(n+r-1, r);
  };
  mint ans = 0;
  for(int i = 1; 3*i <= s; ++i) {
    ans += H(i, s-3*i);
  }
  cout << ans.x << endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;
    vector<ll> a(k);
    for(ll i = 0; i < k; i++) {
        cin >> a[i];
    }

    ll mn=2;
    ll mx=2;
    for(ll i = 0; i < k; i++) {
        ll m=a[k-1-i];
        if(mx/m-(mn-1)/m<=0){
            cout << "-1" << "\n";
            return 0;
        }
        mn=m*((mn+m-1)/m);
        mx=m*(mx/m)+m-1;
    }
    cout << mn << " " << mx << "\n";

    return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{
		String S = nextString();
		if(S.replaceAll("A", "").length()==3||S.replaceAll("A", "").length()==0){
			System.out.println("No");
		}else{
			System.out.println("Yes");

		}
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22864
// atcoder/abc156/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> v(n);
    cin >> v;
    lli mn = 1LL << 60;
    for (int k = 0; k < 200; ++k) {
      lli sum = 0;
      each (i, v) {
        lli y = (k - i);
        sum += y * y;
      }
      setmin(mn, sum);
    }
    cout << mn << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// ABC157E - Simple String Queries

#include <bits/stdc++.h>
using namespace std;

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

	vector< set<int> > alpha(26);

	string S;
	cin >> S;

	for (int i = 0; i < N; i++) {
		alpha.at(S[i] - 'a').insert(i + 1);
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int op;
		cin >> op;
		if (op == 1) {
			int iq;
			char cq;
			cin >> iq >> cq;

			alpha.at(S[iq - 1] - 'a').erase(iq);
			alpha.at(cq - 'a').insert(iq);
			S[iq - 1] = cq;
		} else if (op == 2) {
			int l, r;
			cin >> l >> r;

			int answer = 0;
			for (int j = 0; j < 26; j++) {
				set<int>::iterator it;
				it = alpha.at(j).lower_bound(l);
				if ((it != alpha.at(j).end())&&(*it <= r)) {
					answer++;
				}
			}
			cout << answer << endl;
		}
	}
}


Measured memory_bytes: 24196
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

int main()
{
	cio;
	int x;
	cin >> x;

	cout << 10 - (x / 200);
}


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

int main(void){
	int a,b,c,d,e,f;
	int ma=0, mb=0, mc=0, md=0;
	cin >> a>>b>>c>>d>>e>>f;
	float ms, x, mx=0;
	ms = 10000*e / (100 + e);
	if (100 * a + c > f || 100 * a + d > f){
		cout << 100 * a << endl;
		return 0;
	}
	for (int i = 0; i <= f / (100 * a); i++){
		for (int j = 0; j <= f / (100 * b); j++){
			for (int p = 0; p < f / c; p++){
				for (int q = 0; q < f / d; q++){
					if (i == 0 && j == 0){

					}
					else if (100 * i* a + 100 * j* b + c*p + d*q <= f){
						x = 10000*(c*p + d*q) / (100 * i* a + 100 * j* b + c*p + d*q);
						if (x <= ms&&x>=mx){
							mx = x;
							ma = i;
							mb = j;
							mc = p;
							md = q;
						}
					}

				}
			}
		}
	}
	cout << 100 * ma* a + 100 * mb* b+(c*mc + d*md) <<endl;
cout<< c*mc + d*md <<endl;

}

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

int N,K;
int dp[2][1001][1001];
int dm[2][1001][1001];
int a[1000];

int main(){
  scanf("%d %d",&N,&K);
  for(int i=0;i<N;i++)scanf("%d",&a[i]);
  sort(a,a+N);
  fill( (int*)dp[0], (int*)dp[1], 1e9);
  int ans=1e9;
  for(int T=1;T<=K;T++){
    int t=T%2;
    int u=1-t;
    for(int i=0;i<N;i++){
      dp[0][i][i+1]=0;
      dp[1][i][i+1]=0;
    }
    for(int w=2;w<=N;w++){
      for(int i=0;i+w<=N;i++){
        int j=i+w;
        int si=i+1;
        int ti=j-1;
        if(w>2){
          si=dm[t][i][j-1];
          ti=dm[t][i+1][j];
        }
        dp[t][i][j]=1e9;
        for(int k=si;k<=ti;k++){
          if(dp[t][i][j] > dp[u][i][k]+dp[u][k][j]+a[j-1]-a[k-1]){
            dp[t][i][j]=dp[u][i][k]+dp[u][k][j]+a[j-1]-a[k-1];
            dm[t][i][j]=k;
          }
        }
      }
    }
  }
  printf("%d\n",dp[K%2][0][N]);
  return 0;
}

Measured memory_bytes: 18384
cnt = 0
output = []
idx = []
while(True):
    a = input()
    if(a == "-"):
        break
    output.append(list(a))
    n = int(input())
    mvp = 0
    for i in range(n):
        mvp += int(input())
    idx.append(mvp)
for i in range(len(output)):
    print("".join(output[i][idx[i]%len(output[i]):]),end="")
    print("".join(output[i][:idx[i]%len(output[i])]))


Measured memory_bytes: 5604
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000


int main(){
  unsigned short *A,*B;
  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<=VMAX;i++)C[i]=0;

  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);

  }
  
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

template<typename T>
struct edge{
  int to;
  T cost;
  edge(int to,T cost):to(to),cost(cost){}
};

vector<int>pre;

template<typename T>
vector<T> dijkstra(vector<vector<edge<T>>> &g,int s){//sは始点
  const auto INFTY=numeric_limits<T>::max();
  vector<T>dist(g.size(),INFTY);
  pre.resize(g.size(),-1);
  using P=pair<T,int>;//firstは最短距離,secondは頂点の番号
  priority_queue<P,vector<P>,greater<P>>pq;
  dist[s]=0;
  pq.emplace(dist[s],s);

  while(!pq.empty()){
    auto x=pq.top();pq.pop();
    int v=x.second;
    if(dist[v]<x.first)continue;//最短距離でなければ飛ばす
    for(auto e:g[v]){
      if(dist[e.to]>dist[v]+e.cost){
        pre[e.to]=v;
        dist[e.to]=dist[v]+e.cost;
        pq.emplace(dist[e.to],e.to);
      }
    }
  }
  return dist;
}

template<typename T>
vector<T>get_path(int t){//頂点tへの最短経路
    vector<T>path;
    for(;t!=-1;t=pre[t]){
      path.push_back(t);
    }
    reverse(path.begin(),path.end());
    return path;
}


void solve(){
    int n,m;
    cin>>n>>m;
    vector<vector<edge<ll>>>g(n);
    rep(i,n-1)g[i+1].eb(i,0LL);//i+1→iの方向で張る
    rep(i,m){
        int l,r;
        ll c;
        cin>>l>>r>>c;
        l--;r--;
        g[l].eb(r,c);//両方向に張る
        g[r].eb(l,c);
    }
    vector<ll>v=dijkstra(g,0);
    if(v[n-1]!=numeric_limits<ll>::max())cout<<v[n-1]<<"\n";
    else cout<<-1<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 13428
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<vector<char>>c(H, vector<char>(W));
    rep(i, H) {
        string S; cin >> S;
        rep(j, W)c[i][j] = S.at(j);
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << (H + W)); bit++) {
        vector<bool>A(H + W);
        for (int i = 0; i < (H + W); i++) {
            if (bit & (1 << i))A[i] = false;
            else A[i] = true;
        }
        int count = 0;
        rep(i, H) {
            rep(j, W) {
                if (A[i] && A[H + j] && c[i][j] == '#')count++;
            }
        }
        if (count == K)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)



int main(){
    int i;
    cin >> i;
    if (i == 1){
        printf("Hello World\n");
    } else{
        int a, b;
        cin >> a >>b;
        cout << a+b<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,X;
  int i,j,b=0;;
  int minj;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N;++i){
    minj=i;
    for(j=i;j<N;++j){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(i!=minj){
    X=A[i];
    A[i]=A[minj];
    A[minj]=X;
    b++;
    }
  }
  
    
    for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i==N-1){
      break;
    }
    printf(" ");

  }
  printf("\n%d\n",b);

  return 0;
}



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

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        String[] S = new String[(int)(N)];
        long[] P = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                S[i] = sc.next();
                P[i] = sc.nextLong();
        }
        solve(N, S, P);
    }

    static void solve(long N, String[] S, long[] P){
	List<R> list = new ArrayList<>();
	for(int i = 0; i < (int)N; i++) {
	    list.add(new R(i + 1, S[i], P[i]));
	}
	list.stream()
	    .sorted((r1, r2) -> r1.name.equals(r2.name) ? r1.point - r2.point < 0 ? 1 : -1 : r1.name.compareTo(r2.name))
	    .map(R::getId)
	    .forEach(System.out::println);
    }
}

class R {
    int id;
    String name;
    long point;

    public R(int id, String name, long point) {
	this.id = id;
	this.name = name;
	this.point = point;
    }

    public int getId() {
	return this.id;
    }
}


Measured memory_bytes: 26580
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>N>>M;
    cout<<N - (N > M)<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

void solve()
{
	int n;
	cin>>n;
	
	float d;
	cin>>d;
	
	float a,b;
	
	int t = 0;
	
	for(int i=0; i<n; i++)
	{
		cin>>a>>b;
		if(sqrt((pow(a,2)) + pow(b,2)) <= d)
		{
			t++;
		}
	}
	
	cout<<t<<endl;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

//	int t;
//	cin>>t;
//	while(t--)
//	{
//		solve();
//	}

	solve();

	return 0;
}

Measured memory_bytes: 3856
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int c=a.size();
    for(int i=0;i<c;i++){
        if(a[i]=='9'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

ans = A * X + B * Y

if X>=Y:
    ans1 = C * Y *2 + A * (X-Y)
    ans2 = C * X * 2
else:
    ans1 = C * X * 2 + B * (Y-X)
    ans2 = C * Y *2

print(min(ans, ans1,ans2))

Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;
    
    if(a%2 == b%2) {
        cout << (b-a)/2 << endl;
    } else {
        ll vl = a + (b-a-1)/2;
        ll vr = n-b+1 + (b-a-1)/2;
        cout << min(vl, vr) << endl;
    }

    return 0;
}

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

bool is_palin(string s){
	int n=s.length();
	for(int ii=0;ii<n/2;ii++){
		if(s[ii]!=s[n-ii-1]) return false;
	}
	return true;
}
int main(){
	
	string s; cin>>s;
	string s1="",s2="";
	int n = s.size();
	int f = (n-1)/2;
	int e = (n+3)/2;
	for(int i=0;i<f;i++) { s1+=s[i]; }
	for(int i=e-1;i<n;i++) { s2+=s[i]; }
	//cout<<s1<<" "<<s2<<endl;
	if(is_palin(s) && is_palin(s1) && is_palin(s2)) cout<<"Yes";
	else  cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int N;
   cin >> N;
   int A[N];
   for(int i = 0 ; i< N; i++) cin >> A[i];
   vector<pair<long long,int>> v;
   for(int i=0;i<N;i++) v.emplace_back(A[i],i);
   long long ans=0;
   sort(v.begin(),v.end());
   reverse(v.begin(),v.end());
   long long dp[N+1][N+1];
   for(int i = 0 ; i <= N ; i++)for(int j = 0 ; j <=N; j++) dp[i][j]=0;

   for(int i=0; i< N; i++){
      for(int l = 0 ; l <= i; l++){
         // int cur = dp[l][i-l];
         int r = i-l;
         dp[l+1][r] = max(dp[l+1][r],dp[l][r]+abs(l-v[i].second)*v[i].first);
         dp[l][r+1] = max(dp[l][r+1],dp[l][r]+abs((N-1-r)-v[i].second)*v[i].first);
         //cout << l << ", " << r << ", " << dp[l][r]  << (N-1-r) << "- " << v[i].second<<endl;
      }
   }
   for(int l = 0 ; l <=N; l++){
      //cout << l << ", " << N-l << ", " << dp[l][N-l] << endl;
      ans=max(ans,dp[l][N-l]);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 34976
# coding: utf-8
# Your code here!
import numpy as np
X,Y,A,B,C = list(map(int,input().split()))
p =list(map(int,input().split()))
p.append(0)
p.sort(reverse = True)
# print(p)
q=list(map(int,input().split()))
q.append(0)
q.sort(reverse = True)
r = list(map(int,input().split()))
r.append(0)
r.sort(reverse = True)
 
p = np.array(p)
q = np.array(q)
r = np.array(r)
kotae = 0
a,b,c = 0,0,0
d,e =False,False
for i in range(X+Y):
    if a >= X:
        if d == False:
            p = p* 0
            d = True
    if b >= Y:
        if e == False:
            q = q*0
            e = True
    if p[a] > q[b]:
        if p[a] > r[c]:
            kotae += p[a]
            a +=1
        else:
            kotae += r[c]
            c += 1
    else:
        if q[b] > r[c]:
            kotae += q[b]
            b +=1
        else:
            kotae += r[c]
            c += 1
    # print(kotae)
print(kotae)

Measured memory_bytes: 31264
// DP

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

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

ll dp[100010][3];
ll A[100010][3];

int main() {
  int n; cin >> n;
  rep(i,n){ rep(j,3) cin >> A[i][j]; }
  
  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
        if(j == k) continue;
        chmax( dp[i+1][k], dp[i][j] + A[i][k] );
      }
    }
  }
  ll ans = 0;
  rep(j,3) chmax(ans, dp[n][j]);
  cout << ans << endl;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> l(n);
    for(int i = 0 ;i<n;i++)
    {
        cin>>l[i];
    }
    sort(l.begin(),l.end());
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j = i+1;j<n;j++)
        {
            auto it = lower_bound(l.begin()+j,l.end(),l[i]+l[j]);
            ans+=distance(l.begin()+j,it-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  vector<queue<char>> vec(3);
  rep(i, 3){
    string str;
    cin >> str;
    rep(j, str.length()){
      vec[i].push(str[j]);
    }
  }
  int current = 0;
  while(!vec[current].empty()){
    char c = vec[current].front();
    vec[current].pop();
    if(c == 'a') current = 0;
    else if(c == 'b') current = 1;
    else current = 2;
  }
  if(current == 0) cout << "A" << endl;
  else if(current == 1) cout << "B" << endl;
  else cout << "C" << endl;
  return 0;
}
  
  

Measured memory_bytes: 3608
N,M = map(int, raw_input().split())
A = [raw_input() for _ in range(N)]
B = [raw_input() for _ in range(M)]
for y in range(N-M+1):
  for x in range(N-M+1):
    ok = True
    for yy in range(M):
      for xx in range(M):
        if A[y+yy][x+xx] != B[yy][xx]:
          ok = False
    if ok:
      print "Yes"
      exit(0)
print "No"


Measured memory_bytes: 2568
// AtCoder ABC136: A - Transfer
// 2019.8.26 bal4u

#include <stdio.h>
 
int main()
{
	int a, b, c;
	
	scanf("%d%d%d", &a, &b, &c);
	a -= b;
	if (a < c) c -= a;
	else c = 0;
	printf("%d\n", c);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  long long int sum = 0;

  for (int i = 1; i <= N; i++) {

    if (i%3 != 0 && i%5 != 0) {
      sum += i;
    }
/*    else {
      continue;
    }*/
  }

    cout << sum << endl;

}

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

int main(){
    int n, k, s;
    cin >> n >> k >> s;
    int cnt = 0;

    rep(i, n) {
        if(cnt < k) {
            cout << s << " ";
            cnt++;
        } else {
            if(s == 1000000000) cout << 1 << " ";
            else cout << s + 1 << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
sS = input().rstrip()
iL = len(sS)
if iL == 2:
    if sS[0] == sS[1]:
        print ("1 2")
    else:
        print("-1 -1")
    exit()
for i in range(iL-2):
    if sS[i] == sS[i+1] or sS[i] == sS[i+2]:
        print(i+1,i+3) #あぁ..
        exit()
print("-1 -1")


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <algorithm>
#include <sstream>
using namespace std;

int toInt(const char *s){
	stringstream ss;int x;
	ss<<s;
	ss>>x;
	return x;
}

int main(void){
  int n,a,b;
  string num;
  cin>>n;
  while(n--){
  	char *s=(char *)malloc(9*sizeof(char));
  	cin>>num;
  	while(num.size()!=8) num="0"+num;
  	s=strcpy(s,num.c_str());
  	sort(s,s+8);
  	a=toInt(s);
  	sort(s,s+8,greater<char>());
  	b=toInt(s);
  	cout<<b-a<<endl;
  	free(s);
  }
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 ll n,m=1000000000000000; cin>>n;
rep(i,5){
ll t; cin>>t;
  m=min(m,t);
}
  cout<<4+(n+m-1)/m<<endl;
}

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

int main()
{
	string s;
	char c;
	int q;
	int t, f;
	int cnt = 0;
	
	cin >> s;
	cin >> q;
	
	for(int i = 1; i <= q; i++)
	{
		cin >> t;
		if(t == 1)
		{
			cnt++;
		}
		if(t == 2)
		{
			cin >> f >> c;
			if(!(cnt % 2))
			{
				if(f == 1)
					s.insert(s.begin(), c);
				if(f == 2)
					s.insert(s.end(), c);
			}
			else
			{
				if(f == 1)
					s.insert(s.end(), c);
				if(f == 2)
					s.insert(s.begin(), c);
			}
		}
	}
	if(cnt % 2)
		reverse(s.begin(), s.end());
	cout << s << endl;
	
	return 0;
}

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

int main()
{
    long long A, B, K;
    cin >> A >> B >> K;

    if (A >= K)
    {
        A -= K;
    }

    else
    {
        B = B - K + A;
        A = 0;
    }

    if (B <= 0)
    {
        cout << A << " " << 0 << endl;
    }

    else
    {

        cout << A << " " << B << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define ll  long long
    #define mod 1000000007
    #define pb push_back
 
    
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
 
       
 
        ll i,n,n2,m,t,j,l,pos,mpos,f=0,k,p,n1,d,z,q,x,y,x1,y1,x2,y2;
      
        /*cin>>t;
        
      
       while(t--)
    {
 
        
    }*/
        string s1,s2,s3;
        cin>>s1>>s2;
        s3=s2.substr(0,s1.length());
        if(s1==s3)
            cout<<"Yes\n";
        else
            cout<<"No\n";
      return 0;
   }

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

typedef long long lint;

int main(){
    string s;
    cin >> s;
    int l=s.size();
    if((l%2==0)==(s[0]==s[l-1])) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<ll> divisor(ll n) {
	vector<ll> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll mod = 1e9 + 7;
	ll array[n + 1];
	memset(array, 0, sizeof(array));
	rep(i, 1, n + 1) {
		map<int, int> m = prime_factor(i);
		rep(j, 2, n + 1) {
			array[j] += m[j];
		}
	}

	ll ans = 1;
	rep(i, 2, n + 1) {
		ans = ans * (array[i] + 1) % mod;
	}
	cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//priority_queue<int, vector<int>, greater<int>> min_heap;
//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() { // 골드 1, 플레 1, 네트워크 유량(디닉 알고리즘), 

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int a, b; cin >> a >> b;
	int l = 0;
	int r = 511;
	while (l <= r) {
		int mid = (l + r) / 2;
		int cnt = mid * a - mid + 1;
		if (cnt >= b) {
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}

	cout << l << '\n';






}


Measured memory_bytes: 256