akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void){
  int i, n, a[110];
  cin >> n;
  for(i = 0;i < n;i++)cin >> a[i];
  for(i = n - 1;i > 0;i--)printf("%d ", a[i]);
  cout << a[0] << endl;

  return 0;
}

Measured memory_bytes: 1196
N, P = map(int, input().split())
S = list(map(int, input()))

if P==2 or P==5:
    ans = 0
    for i, s in enumerate(S):
        if s%P==0: ans+=i+1
    print(ans)
    exit()

R = [None]*N
k = 1
for i in range(N-1, -1, -1):
    R[i] = S[i]*k%P
    k = k*10%P

ans = 0
X = []
x = 0
for r in R:
    x  = (x+r)%P
    X.append(x)

D = [0]*P
D[0] = 1
for x in X:
    ans += D[x]
    D[x]+=1

print(ans)


Measured memory_bytes: 19728
N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

for i in range(N):
    if(i == 0):
        if(candy_list[0] > x):
            count_candy_eat += candy_list[0] - x
            candy_list[0] = x
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            if(x - candy_list[i-1] > 0):
                count_candy_eat += candy_list[i-1] + candy_list[i] - x
                candy_list[i] = x - candy_list[i-1]
            else:
                count_candy_eat += candy_list[i]
                candy_list[i] = 0


print(count_candy_eat)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
// (n, m) => 残りm個の数を残し、直前の条件に合致する数がn個の場合の数
const int64_t MOD = 1e9+7;

const int MAX_N = 3000;

struct MInt {
    static int64_t mod;
    int64_t v;
    MInt() {}
    MInt(const int64_t &x) : v(x) {}
    MInt operator+(const MInt &y) { return (v + y.v) % mod; }
    MInt operator-(const MInt &y) { return (v - y.v + mod) % mod; }
    MInt operator*(const MInt &y) { return (v * y.v) % mod; }
    void operator+=(const MInt &y) { *this = *this + y; }
    void operator-=(const MInt &y) { *this = *this - y; }
    void operator*=(const MInt &y) { *this = *this * y; }
    friend istream &operator>>(istream &ist, MInt &m) { return ist >> m.v; }
    friend ostream &operator<<(ostream &ost, MInt &m) { return ost << m.v; }
};
int64_t MInt::mod = MOD;

MInt dp[MAX_N + 10];
MInt s[MAX_N + 10];

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(int m = 1; m <= N; m++) {
        int i = N - m;
        int b = m % 2;
        for(int n = 1; n <= N; n++) {
            if(m == 1 && n == 1) {
                dp[n] = 1;
            } else if(n > m) {
                dp[n] = 0;
            } else {
                // m >= 2
                if(i > 0 && S[i - 1] == S[i]) {
                    dp[n] = s[n - 1];
                } else {
                    dp[n] = s[m];
                    if(m > n) dp[n] -= s[m - n - 1];
                }
            }
        }
        s[0] = 0;
        for(int n = 1; n <= N; n++) {
            s[n] = s[n - 1] + dp[n];
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
ll N;
void dfs(string s, ll used){
    if(s.length() == N){
        cout<<s<<endl; return;
    }
    REP(i, used){
        string snew = s;
        snew.push_back((char)('a'+i));
        dfs(snew, used);
    }
    string snew = s;
    snew.push_back((char)('a'+used));
    dfs(snew, used+1);
}

int main(){
    
    scanf("%lld",&N);
    string s;
    dfs(s, 0);
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define max(a, b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)
#define fori(i, n) for(ll i=0; i<n; ++i)
typedef long long ll;

ll n, d, a, x, h;
int main(){
	scanf("%lli%lli%lli", &n, &d, &a);
	d = 2*d;
	vector<pair<ll, ll> > mons, bombs;
	fori(i, n){
		scanf("%lli%lli", &x, &h);
		ll nh = h / a;
		if (h % a != 0) nh++;
		mons.emplace_back(x,nh);
	}
	sort(mons.begin(), mons.end());
	ll bi = 0;
	ll bt = 0;
	ll totB = 0;
	fori(i, n){
		while(bi<bombs.size() && mons[i].first - bombs[bi].first > d){
			bt -= bombs[bi].second;
			bi++;
		}
		mons[i].second -= bt;
		if (mons[i].second > 0){
			bombs.push_back({mons[i].first,mons[i].second});
			bt += mons[i].second;
			totB += mons[i].second;
		}
	}	
	printf("%lli\n", totB);
}

















Measured memory_bytes: 11856
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<list> 
#include<string>
#include<cstring>
#include<cmath>

#define vint vector<int>
#define vstr vector<string>
#define vll vector<long long>
#define ll long long
#define pf printf
#define sf scanf
#define sfd(n) scanf("%d", &n)
#define pfd(n) printf("%d", n);
#define pft	printf("\t")
#define pfn printf("\n")
#define pfk printf(" ")
#define N 200010
#define PI 3.1415926

using namespace std;

int main() {
	int n;
	sfd(n);
	ll* num = new ll[n];
	for( int i=0; i<n; i++ ) {
		sf("%lld", &num[i]);
	}
	ll cnt = 0;
	while( 1 ) {
		ll max = num[0];
		int pos = 0; 
		for( int i=0; i<n; i++ ) {
			if( max<num[i] ) {
				max = num[i];
				pos = i;
			}
		}
		if( num[pos]<n ) {
			break;
		}
		for( int i=0; i<n; i++ ) {
			if( i==pos ) {
				num[i] = max%n;
			}else {
				num[i] += max/n;
			}
		}
		cnt += max/n;
	}
	pf("%lld", cnt);
	
	return 0;
}


Measured memory_bytes: 256
fun main (args:Array<String>){
    val sLen = readLine()!!.toInt()
    var sStr = readLine()!!
    if(sLen % 2 != 0){
        print("No")
        return
    }
    val strSec = sStr.takeLast(sLen / 2)
    if(strSec + strSec == sStr){
        print("Yes")
    }
    else print("No")
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int r,c;
int get(int x, int y) {
	if (x == 0) return (r+c)*2-y;
	if (x == r) return r+y;
	if (y == 0) return x;
	if (y == c) return r*2+c-x;
	assert(0);
}

int main() {
    r = ri(), c = ri(); int n = ri();
	int a[n][4];
	FOR(i,n) FOR(j,4) a[i][j] = ri();
	vector<pair<int,int> > pts;
	FOR(i,n) {
		if ((a[i][0] == 0 || a[i][0] == r || a[i][1] == 0 || a[i][1] == c) &&
		    (a[i][2] == 0 || a[i][2] == r || a[i][3] == 0 || a[i][3] == c)) {
			int r0 = get(a[i][0], a[i][1]);
			int r1 = get(a[i][2], a[i][3]);
			if (r1<r0) swap(r0,r1);
			pts.push_back({r0,r1});
		}
	}
	sort(all(pts), [](const pair<int,int>&a, const pair<int,int>&b) {
		return a.fi < b.fi;
	});
	set<int> ses;
	bool res = true;
	for (auto &i : pts) {
		auto itr = ses.upper_bound(i.fi);
		if (itr != ses.end() && *itr < i.se) {
			res = false;
			break;
		}
		ses.insert(i.se);
	}
	
	cout << (res?"YES":"NO") << endl;
    return 0;
}


Measured memory_bytes: 7284
def j2b(S):
    rows = S.split("/")
    for i, row in enumerate(rows):
        cand = []
        for s in row:
            if s == "b":
                cand.append(s)
            else:
                cand.extend(["."] * int(s))
        rows[i] = cand
    return rows


def b2j(rows):
    ret = []
    for row in rows:
        r = []
        c = 0
        for s in row:
            if s == "b":
                if c:
                    r.append(str(c))
                r.append(s)
                c = 0
            else:
                c += 1
        if c:
            r.append(str(c))
        ret.append(''.join(r))
    return '/'.join(ret)


while True:
    S = input()
    if S == "#":
        break
    rows = j2b(S)
    a, b, c, d = [int(x) - 1 for x in input().split()]
    rows[a][b], rows[c][d] = rows[c][d], rows[a][b]
    print(b2j(rows))

Measured memory_bytes: 7748
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    n = in.ni();
    int w = in.ni();
    weight = new int[n];
    values = new int[n];
    int V = 0;
    for (int i = 0; i < n; i++) {
      weight[i] = in.ni();
      values[i] = in.ni();
      V += values[i];
    }
    dp = new Long[n][V + 1];
    long result = 0;
    for (int val = V; val >= 0; val--) {
      long weight = recurse(0, val);
      if (weight <= w) {
        result = val;
        break;
      }
    }
    out.println(result);
  }

  private int n;
  private int[] weight, values;
  private Long[][] dp;

  private Long recurse(int idx, int val) {
    long oo = (long) 1e18;
    if (idx == n) return val == 0 ? 0L : oo;

    if (dp[idx][val] != null) return dp[idx][val];

    long ans = recurse(idx + 1, val);
    if (values[idx] <= val) {
      ans = Math.min(ans, weight[idx] + recurse(idx + 1, val - values[idx]));
    }

    return dp[idx][val] = ans;
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


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

int main() {
    int N, K; cin >> N >> K;
    map<int, int> MAP;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        MAP[a] ++;
    }
    vector<int> num;
    int n = MAP.size();
    if (n <= K) {
        cout << 0 << endl; 
        return 0;
    }

    for (auto t : MAP) {
        num.push_back(t.second);
    }
    sort(num.begin(), num.end());
    ll ans = 0;
    for (int i = 0; i < n-K; i++) {
        ans += num[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 10748
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
Match=[0,2,5,5,4,5,6,3,7,6]
A.sort(reverse=True)
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
  for a in A:
    if i>=Match[a]:
      dp[i]|=dp[i-Match[a]]<<1

for k in range(N)[::-1]:
  if dp[N]&(1<<k):
    S=k
    break
ans=[]
m=0
for k in range(S):
  if N-Match[A[m]]>=0:
    if dp[N-Match[A[m]]]&(1<<(S-k-1)):
      ans.append(str(A[m]))
      N-=Match[A[m]]
    else:
      for l in range(m+1,len(A)):
        if N-Match[A[l]]>=0:
          if dp[N-Match[A[l]]]&(1<<(S-k-1)):
            m=l
            ans.append(str(A[m]))
            N-=Match[A[m]]
            break
  else:
    for l in range(m+1,len(A)):
      if N-Match[A[l]]>=0:
        if dp[N-Match[A[l]]]&(1<<(S-k-1)):
          m=l
          ans.append(str(A[m]))
          N-=Match[A[m]]
          break
print("".join(ans))


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

int main()
{
    int numa, numb, numc, numd, nume,numk;
    cin >> numa >> numb >> numc >> numd >> nume >> numk;

    if (nume-numa<=numk){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp);}

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

    int mul = 0;
    rep(i, n-1){
        if (a[i] == a[i+1]) mul++;
    }
    if (mul%2) mul++;
    cout << n-mul << endl;
}


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


int main(int argc, const char * argv[]) {
    string s,t;
    cin>>s;
    sort(s.begin(),s.end());
    cin>>t;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    
    if(s<t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
hash = {}
N.times do
    s = gets.chomp
    hash[s] = hash[s].to_i + 1
end
 M = gets.to_i
 M.times do
    s = gets.chomp
    hash[s] = hash[s].to_i - 1
 end
 puts [hash.values.max, 0].max

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N;

int main(void) {
    cin>>N;
    vector<int> a;
    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        a.push_back(temp);
    }

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

    int sum = 1;
    for(int i = 1;i < a.size();i++) {
        if(a[i] != a[i-1])
            sum++;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 384
def solve(A, i, m, n):
    """Return if it is possible to make value m with some elements in A.

    n is length of A.
    i is index.
    Using Divide-and-Conquer method.
    """

    if m == 0:
        return True
    if i >= n or m < 0:
        return False
    return solve(A, i + 1, m, n) or solve(A, i + 1, m - A[i], n)


import sys

n = int(sys.stdin.readline())
A = tuple(map(int, sys.stdin.readline().split()))
q = sys.stdin.readline()
M = tuple(map(int, sys.stdin.readline().split()))

s_A = sum(A)

ans = ''

for m in M:
    if s_A < m:
        ans += 'no\n'
    elif solve(A, 0, m, n):
        ans += 'yes\n'
    else:
        ans += 'no\n'

print(ans, end = '')

Measured memory_bytes: 7768
a,b = [int(x) for x in input().split()]
def extend(x,a,b,n):
  assert x>=1
  if x >= b:
    return n
  else:
    n += 1
    extended =  x - 1 + a
    return extend(extended, a, b, n)
print(extend(1, a, b, 0))

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

struct Node {
	Node() {}
	Node(long long val, int pos) : sum(val), ans(val), on(pos) {}
	Node(Node l, Node r) : sum(l.sum + r.sum), ans(std::max(l.ans, l.sum + r.ans)), on(r.on) {}
	long long sum, ans;
	int on;
};

const int ms = 5050;
const int me = 30;

int n, k;
int p[ms];
Node a[me][ms];


int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::cin >> n >> k;
	for(int i = 0; i < n; i++) {
		std::cin >> p[i];
		p[i]--;
	}
	for(int i = 0; i < n; i++) {
		int val;
		std::cin >> val;
		a[0][i] = Node(val, p[i]);
	}
	for(int i = 1; i < me; i++) {
		for(int j = 0; j < n; j++) {
			a[i][j] = Node(a[i-1][j], a[i-1][a[i-1][j].on]);
		}
	}
	long long ans = -1e9;
	for(int i = 0; i < n; i++) {
		Node cur(0, i);
		cur.ans = -1e9;
		for(int j = me-1; j >= 0; j--) {
			if(k & (1 << j)) {
				cur = Node(cur, a[j][cur.on]);
			}
		}
		ans = std::max(ans, cur.ans);
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 7160
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)5e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, a, b, c, d;
string s;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> a >> b >> c >> d;
   cin >> s;
   a --, b --, c --, d --;
   for (int i = a; i < c; i ++) {
      if (s.substr (i, 2) == "##") cout << "No", exit (0);
   }   
   for (int i = b; i < d; i ++) {
      if (s.substr (i, 2) == "##") cout << "No", exit (0);
   }
   if (c < d) cout << "Yes";
   else {
      bool ok = 0;
      for (int i = b; i <= d; i ++) {
         if (s.substr (i - 1, 3) == "...") ok = 1;
      }   
      if (ok) cout << "Yes";
      else cout << "No";
   }
}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) { 
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e5 + 2;
 
struct IOsetup{
  IOsetup(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); 
    cout.tie(nullptr);
    cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
  int n;
  cin >> n;
  int a, b;
  vector<int> p(n), q(n);
  vector<int> curr;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) curr.push_back(i);
  int cnt = 0;
  do{
    cnt++;
    if (curr == p) a = cnt;
    if (curr == q) b = cnt;
  } while (next_permutation(curr.begin(), curr.end()));
  int ret = abs(a - b);
  cout << ret << endl;
}

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

int main() {
  string sStr, tStr;
  cin >> sStr >> tStr;
  int res = 1000;
  int temp = 0;
  for(int i = 0; i <= (int)sStr.length() - (int)tStr.length(); i++) {
    temp = 0;
    for(int j = 0; j < (int)tStr.length(); j++) {
      if(sStr.at(j+i) != tStr.at(j)) temp++;
    }
    res = min(res, temp);
  }
  cout << res << endl;
}


Measured memory_bytes: 3596
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,ll k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int mod=1e9+7,maxn=1e3+5;
int n,m;
ll k;
char str[maxn][maxn],nstr[maxn][maxn];
struct mat{
	int a[2][2];
	mat(){memset(a,0,sizeof a);}
	friend mat operator*(mat A,mat B){
		mat C;
		rep2(i,0,2)rep2(j,0,2)rep2(k,0,2)C.a[i][j]=(C.a[i][j]+1ll*A.a[i][k]*B.a[k][j])%mod;
		return C;
	}
	friend mat Power(mat A,ll k){
		mat Res;rep2(i,0,2)Res.a[i][i]=1;
		for(;k;k>>=1,A=A*A)if(k&1)Res=Res*A;
		return Res;
	}
}Trans,Ans;
int flag1,flag2;
int main(){
	read(n);read(m);read(k);
	if(!k){
		puts("1");
		return 0;
	}
	rep(i,1,n)scanf("%s",str[i]+1);
	rep(i,1,n)if(str[i][1]=='#'&&str[i][m]=='#')flag1=1;
	rep(j,1,m)if(str[1][j]=='#'&&str[n][j]=='#')flag2=1;
	if(flag1&&flag2){
		puts("1");
		return 0;
	}
	if((!flag1)&&(!flag2)){
		int cnt=0;
		rep(i,1,n)rep(j,1,m)if(str[i][j]=='#')cnt++;
		printf("%d\n",power(cnt,k-1,mod));
		return 0;
	}
	if(flag2){
		rep(i,1,n)rep(j,1,m)nstr[j][i]=str[i][j];
		swap(n,m);
		rep(i,1,n)rep(j,1,m)str[i][j]=nstr[i][j];
	}
	rep(i,1,n)rep(j,1,m)if(str[i][j]=='#')Trans.a[0][0]++;
	rep(i,1,n)rep(j,1,m-1)if(str[i][j]=='#'&&str[i][j+1]=='#')Trans.a[0][1]--;
	rep(i,1,n)if(str[i][1]=='#'&&str[i][m]=='#')Trans.a[1][1]++;
	(Trans.a[0][1]+=mod)%=mod;
	Ans.a[0][0]=Ans.a[1][0]=1;
	Ans=Power(Trans,k-1)*Ans;
	printf("%d\n",Ans.a[0][0]);
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int d;
	i64 g;
	cin >> d >> g;
	vi p(d), c(d);
	rep(i, 0, d) cin >> p[i] >> c[i];

	int ans = INF;
	rep(bit, 0, 1 << d) {
		i64 score = 0;
		int cou = 0;
		rep(i, 0, d) {
			if (bit&(1 << i)) {
				score += p[i] * 100 * (i + 1) + c[i];
				cou += p[i];
			}
		}
		if (score >= g) {
			ans = min(ans, cou);
			continue;
		}
		for (int i = d - 1; i >= 0; --i) {
			if (bit&(1 << i)) continue;
			rep(j, 0, p[i]) {
				if (score >= g) break;
				score += 100 * (i + 1);
				cou++;
			}
		}
		ans = min(ans, cou);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
"""
N K
R S P
T
"""

ln1 = input().split()
ln2 = input().split()
ln3 = input().split()

N, K = int(ln1[0]), int(ln1[1])
R, S, P = int(ln2[0]), int(ln2[1]), int(ln2[2])
T = ln3[0]

point = 0
result = []

def janken_result(te):
    if te == "r":
        return P
    elif te == "s":
        return R
    elif te == "p":
        return S
    else:
        exit(-1)

for i in range(N):
    if i < K:
        point += janken_result(T[i])
        result.append(1)
    elif T[i] != T[i-K]:
        point += janken_result(T[i])
        result.append(1)
    else:
        if result[i-K] == 0:
            point += janken_result(T[i])
            result.append(1)
        else:
            result.append(0)

print(point)


Measured memory_bytes: 4212
n,m=map(int,input().split())
a=[input()for i in range(n)]
b=[input()for i in range(m)]
def match(x,y):
    for i in range(m):
        for j in range(m):
            if a[x+i][y+j]!=b[i][j]:
                return False
    return True
judge=False
for i in range(n-m+1):
    for j in range(n-m+1):
        if match(i,j):
            judge=True
if judge:
    print("Yes")
else:
    print("No")


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

const int N=100005;
int n,a,b,h[N];

bool check(int mid){
	int ret=mid;
	for(int i=0;i<n&&ret>=0;++i)
		if(h[i]>1ll*mid*b)ret-=(h[i]-mid*b-1)/(a-b)+1;
	return ret>=0;
}

int main(){
	scanf("%d%d%d",&n,&a,&b);
	for(int i=0;i<n;++i)scanf("%d",h+i);
	int l=1,r=1000000000;
	while(l<r){
		int mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int ans;
  if(S == "SUN"){
    ans = 7;
  }else if(S == "MON"){
    ans = 6;
  }else if(S == "TUE"){
    ans = 5;
  }else if(S == "WED"){
    ans = 4;
  }else if(S == "THU"){
    ans = 3;
  }else if(S == "FRI"){
    ans = 2;
  }else if(S == "SAT"){
    ans = 1;
  }
  cout << ans << endl;
}   

Measured memory_bytes: 256
// 2020-08-14 16:17:50
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
const int mod = 1000000007;
struct mint {
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % mod) {
    if (val < 0) val += mod;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = mod, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += mod;
    u %= mod;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += mod;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % mod;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % mod;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

const int MX = 55;
mint dp[MX][MX * MX], p[MX][MX * MX];
void answer() {
  int n, k_;
  cin >> n >> k_;
  dp[0][0] = 1;
  rep(i, n) {
    swap(dp, p);
    repc(j, i+1) repc(k, n*n) {
      dp[j][k] = 0;
      if(2*j <= k) {
        int pk = k-2*j;
        dp[j][k] += p[j][pk] * (2*j+1);
        dp[j][k] += p[j+1][pk] * (j+1) * (j+1);
        if(j > 0) {
          dp[j][k] += p[j-1][pk];
        }
      }
    }
  }
  cout << dp[0][k_] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6208
n,q=list(map(int,input().split()))
ls=[]
for i in range(n):
    a,b = input().split()
    ls.append([a,int(b)])
done=[]
t=0
while ls!=[]:
    task=ls.pop(0)
    if task[1]<= q:
        t+=task[1]
        done.append([task[0],t])
    else:
        task[1] -= q
        t+=q
        ls+=[task]

for i in range(n):
    print(*done[i])


Measured memory_bytes: 14668
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	int lower = S % 100;
	int upper = ((S - lower) / 100) % 100;

	bool lowerMMflag = true;
	if ( (lower > 12) || (lower < 1) ){
		lowerMMflag = false;
	}
	bool upperMMflag = true;
	if ( (upper > 12) || (upper < 1) ){
		upperMMflag = false;
	}

	if ( lowerMMflag ){
		if ( upperMMflag ){
			cout << "AMBIGUOUS" << endl;
		} else {
			cout << "YYMM" << endl;
		}
	} else {
		if ( upperMMflag ){
			cout << "MMYY" << endl;
		} else {
			cout << "NA" << endl;
		}
	}


	return 0;
}



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

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




Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<char,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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


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

	int a,b,c,d;cin>>a>>b>>c>>d;
	a+=b;c+=d;
	if(a>c) cout<<"Left"<<endl;
	else if(c>a) cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;

	return 0;
}


Measured memory_bytes: 256
using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] b = Console.ReadLine().Split();
            double T = double.Parse(b[0]); double X = double.Parse(b[1]);
            double a;
            a = T / X;
            Console.Write(a);
        }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
  string s;
  cin>>s;
  bool flag1,flag2;
  flag1 = flag2 = false;
  int A,B;
  A = (s[0]-'0') * 10 + (s[1]-'0');
  B = (s[2]-'0') * 10 + (s[3]-'0');
  if (A > 0 && A < 13) flag1 = true;
  if (B > 0 && B < 13) flag2 = true;
  if (flag1 && flag2) cout<<"AMBIGUOUS"<<endl;
  else if (flag1) cout<<"MMYY"<<endl;
  else if (flag2) cout<<"YYMM"<<endl;
  else cout<<"NA"<<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++)

int main() {
  int n, m;
  cin >>n>>m;
  if (n==1 and m==0) {
    cout << 0;
    return 0;
  }
  int an[n];rep(i,n)an[i]=-1;
  int s,c;
  rep(i,m){
    cin>>s>>c;
    if (an[s-1]==-1) {
      an[s-1] = c;
    } else if (an[s-1]!=c) {
      cout << -1;
      return 0;
    }
  }
  if (an[0]==0) {
    if (n==1) cout << 0;
    else cout << -1;
    return 0;
  }
  rep(i,n) {
    if (an[i]==-1) {
      if (i==0) an[i]=1;
      else an[i]=0;
    }
    cout << an[i];
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using P = pair<int, int>;

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

    vector<int> a(N);
    int ma = -10000000;
    int mi = 10000000;
    int manum = 0;
    int minum = 0;
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        if(ma < a[i]){
            ma = a[i];
            manum = i;
        }
        if(mi > a[i]){
            mi = a[i];
            minum = i;
        }
    }

    if(mi >= 0){
        cout << N - 1 << endl;
        for(int i = 1; i < N; ++i){
            cout << i << " " << i + 1 << endl;
        }
        return 0;
    }
    else if(ma <= 0){
        cout << N - 1 << endl;
        for(int i = N; i > 1; --i){
            cout << i << " " << i - 1 << endl;
        }
        return 0;
    }
    else {
        cout << N + N - 1 << endl;
        if(abs(ma) >= abs(mi)){
            for(int i = 1; i <= N; ++i){
                cout << manum + 1 << " " << i << endl;
            }
            for(int i = 1; i < N; ++i){
                cout << i << " " << i + 1 << endl;
            }
        }
        else {
            for(int i = 1; i <= N; ++i){
                cout << minum + 1 << " " << i << endl;
            }
            for(int i = N; i > 1; --i){
                cout << i << " " << i - 1 << endl;
            }
        }
    }
}

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

int main(){
  int N;
  std::cin >> N;
  std::vector<int> color(9, 0);
  for(int i = 0; i < N; i++){
    int temp;
    std::cin >> temp;
    if(temp > 3200) temp = 3200;
    color.at(temp/400)++;
  }
  int ansMin = 0, ansMax = 0;
  for(int i = 0; i < 9; i++){
    if(i != 8){
      if(color.at(i) != 0){
        ansMin++;
        ansMax++;
      }
    }else ansMax += color.at(i);
  }
  if(ansMin == 0) ansMin++;
  std::cout << ansMin << " " << ansMax << std::endl;
}

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

int main(){
  long long x,sum = 0;
  
  while(cin >> x){
    if(x==0){break;}
    sum = 0;

    double n = pow(x, 1.0/2);
    
    for(int i = 1; i< n; ++i){
	if(x % i == 0){
	  sum += i;
	  if(i != 1){sum+=x/i;}


	}
        if(i == n-1){sum += n;}
    }

 

    if(x > sum){
      cout << "deficient number" << endl;
    }else if(x < sum){
      cout << "abundant number" << endl;
    }else{
      cout << "perfect number" << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
int Z, W;
int a[2010];

const int inf = 2e9;

int main()
{
	read(n, Z, W);
	for(int i=1; i<=n; ++i) read(a[i]);
	if(n == 1){
		printf("%d\n", abs(a[1]-W));
	} else {
		printf("%d\n", max(abs(a[n]-W), abs(a[n]-a[n-1])));
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pp;

ll dp[101][100001];int n;
ll a[100001];
ll M=1000000007;

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


    ll k;
    cin>>n>>k;

    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll sum[k+1];
    for(int i=1;i<=n;i++)
    {

        for(int j=0;j<=k;j++)
        {
            if(i==1)
            {
            	if(a[i-1]>=j)
               dp[i][j]=1;
               else
               dp[i][j]=0;
               continue;
            }
            if(j==0)
            dp[i][j]=1;
            else
            {
            	ll len=min(a[i-1],j*1LL);
			 	if(j-len-1>=0)
                dp[i][j]=(sum[j]-sum[j-len-1]+M)%M;
                else
                dp[i][j]=sum[j];
            }
        }
        for(int j=0;j<=k;j++)
        {
            if(j==0)
            sum[j]=dp[i][j];
            else
            sum[j]=(sum[j-1]+dp[i][j])%M;
        }

    }
    cout<<dp[n][k]<<"\n";

}


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

using namespace std;

// ユークリッドの互除法
// 最大公約数を求める
long long CalcGCD(long long a, long long b)
{
	if (a < b) swap(a, b);
	if (b == 0) return a;
	return CalcGCD(a % b, b);
}

// 最大公倍数を求める
long long CalcLCM(long long a, long long b)
{
	return (a * b) / CalcGCD(a, b);
}

int main() {

	long long A,B,C,D;
	cin >> A >> B >> C >> D;

	//A未満でCで割り切れないもの
	long long underA_C = (A - 1) - ((A - 1) / C);
	//B以下でCで割り切れないもの
	long long underB_C = B - (B / C);


	//A未満でDで割り切れないもの
	long long underA_D = (A - 1) - ((A - 1) / D);
	//B以下でDで割り切れないもの
	long long underB_D = B - (B / D);

	//A未満でCDで割り切れないもの
	long long underA_CD = (A - 1) - ((A - 1) / CalcLCM(C,D));
	//B以下でCDで割り切れないもの
	long long underB_CD = B - (B / CalcLCM(C, D));


	// A~BでCで割り切れないもの
	long long CCC = underB_C - underA_C;
	// A~BでDで割り切れないもの
	long long DDD = underB_D - underA_D;

	long long CDCD = underB_CD - underA_CD;


	long long total = CCC + DDD;
	total -= CDCD;
	cout << total << endl;
	
	return 0;
}

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

using namespace std;
#define N 2005

int main()
{
    ios::sync_with_stdio(0);
    int n;
    long long a=2,b=1,c=1;
    cin>>n;
    for(int i=2;i<=n;++i){
        c=a+b;
        a=b;
        b=c;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
//ABC 050
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int a, b;
	string op;
	cin >> a >> op >> b;
	if (op == "+") cout << a + b << endl;
	else cout << a - b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

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

    int x, y;
    cin >> x >> y;
    int res = 0;
    if(x == 1 && y == 1)    res += 400000;
    if(x == 1)  res += 300000;
    else if(x == 2) res += 200000;
    else if(x == 3)    res += 100000;
    if(y == 1)  res += 300000;
    else if(y == 2) res += 200000;
    else if(y == 3) res += 100000;
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define int long long

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

int A,B,C;

signed main()
{
	A=read();B=read();C=read();
	if(A%2==0||B%2==0||C%2==0) printf("0\n");
	else printf("%lld\n",min(A*B,min(B*C,A*C)));
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> OP(N);
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		for (char c : S) {
			if (c == '(') OP[i].first++;
			if (c == ')') {
				if (OP[i].first > 0) OP[i].first--;
				else OP[i].second++;
			}
		}
	}
	sort(OP.begin(), OP.end(), [](auto& a, auto& b) {
		if (a.first == 0 && b.first != 0) return false;
		if (a.first != 0 && b.first == 0) return true;
		if (a.second == 0 && b.second != 0) return true;
		if (a.second != 0 && b.second == 0) return false;
		return a.first - a.second > b.first - b.second;
		});
	int now = 0;
	bool ans = true;
	for (int i = 0; i < N; i++) {
		now -= OP[i].second;
		if (now < 0) {
			ans = false;
			break;
		}
		now += OP[i].first;
	}
	if (now > 0) ans = false;
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 11128
a, b = map(int,input().split())

aS = []
bS = []
for i in range(a):
  bS.append(str(b))

for i in range(b):
  aS.append(str(a))

if ''.join(aS) > ''.join(bS):
  print(''.join(bS))
else:
  print(''.join(aS))


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

using namespace std;

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

int main() {
    int N,Q,i,l,r;
    string S;
    cin >> N >> Q;
    cin >> S;
    int sum[100001];
    sum[0]=0;

    for (i=1;i<N;i++){
        sum[i]=sum[i-1]+(S[i-1]=='A'&&S[i]=='C');
    }

    for (i=0;i<Q;i++){
        cin>>l>>r;
        cout<<sum[r-1]-sum[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    if(s1[s1.length() - 1] == s2[0] && s2[s2.length() - 1] == s3[0])
    	cout << "YES" << endl;
    else
    	cout << "NO" << endl;
}

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


if n < 600:
    print(8)
elif n < 800:
    print(7)
elif n < 1000:
    print(6)
elif n < 1200:
    print(5)
elif n < 1400:
    print(4)
elif n < 1600:
    print(3)
elif n < 1800:
    print(2)
else:
    print(1)


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
//const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}


int main() {
	ll N;

	cin >> N;

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {

			if (N == i * j) {
				cout << "Yes" << endl;
				return 0;
			}

		}


	}


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

Measured memory_bytes: 384
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb=new StringBuilder();
		String str=input.readLine();
		int n=Integer.parseInt(str);
		int b=0;
		int f=0;
		int r=0;
		int v=0;
		int bangou=0;
		int[] manshion=new int[300];
		for(int i=0;i<300;i++){
			if((i>=60&&i<=79)||(i>=140&&i<=159)||(i>=220&&i<=239)){	
				manshion[i]=99;//#
			}else if(i%2==0){
				manshion[i]=999;//??????
			}else{
				manshion[i]=0;
			}	
		}
		
		for(int i=0;i<n;i++){
			String str2=input.readLine();
			String[] arr =str2.split(" ");
			 b=Integer.parseInt(arr[0]);
			 f=Integer.parseInt(arr[1]);
			 r=Integer.parseInt(arr[2]);
			 v=Integer.parseInt(arr[3]);
			bangou=((b-1)*4+f)*20-(20-r*2);
			manshion[bangou-1]+=v;

		}
		for(int i=0;i<manshion.length;i++){
			if(manshion[i]==999){
				sb.append(" ");
			}else if(manshion[i]==99){
				sb.append("#");
			}else{
				sb.append(manshion[i]);
			}
			if((i+1)%20==0){
				sb.append("\n");
			}
		}
		
		System.out.print(sb);
	}
}

Measured memory_bytes: 24384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	for(int i = 0; i < s.size() - 1; i++) {
		if(s.substr(i, 2) == "AC") {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
		
	return 0;                                              
}
	


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

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long  a,b,c;
  long long  m;
  unsigned long long ans;

  cin >> a >> b >> c;

  if((a%2==1)&&(b%2==1)&&(c%2==1)){
     m = max(a,max(b,c));
    if(m == a){
      ans = b*c;
    }
    else if(m == b){
      ans = a*c;
    }
    else{
      ans = a*b;
    }  
  }
  else{
    ans = 0;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
n, a, b = map(int, input().split())

ret = 0
for i in range(1, n+1):
 d1 = i%10
 d2 = (i%10**2)//10
 d3 = (i%10**3)//10**2
 d4 = (i%10**4)//10**3
 d5 = i//10**4
 sum = d1+d2+d3+d4+d5
 if sum>=a and sum<=b:
  ret += i

print(ret)

Measured memory_bytes: 3064
function Main(raw: string) {
  const input = raw.split("\n");
  const ans = { A: "T", T: "A", G: "C", C: "G" };

  //出力
  console.log("%s", ans[input[0]]);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
w = input().rstrip()
dct = {}

for c in w:
    if c in dct:
        dct[c] += 1
    else:
        dct[c] = 1

values = list(dct.values())
result = 'Yes'

for i in values:
    if i % 2 != 0:
        result = 'No'
        break

print(result)

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  cout << (n%k > 0 ? 1 : 0) << endl;
}


Measured memory_bytes: 256