akhauriyash/Code-Regression huggingface dataset:
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (inputs[0] <= inputs[1]+inputs[2])
            {
                Console.WriteLine(inputs[2] - (inputs[0] - inputs[1]));
            }
            else
            {
                Console.WriteLine(0);

            }
        }
    }
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <iostream>
#include <string>
int main(void)
{
	int A, B, C, D,a,b;
	std::cin >> A >> B >> C >> D;
	a = A * B;
	b = C * D;
	if (a > b)
	{
		std::cout << a;
	}
	else if (b > a)
	{
		std::cout << b;
	}
	else
	{
		std::cout << a;
	}
	return 0;
}
	

		
	

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

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

  int ans=0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      if(x+y+K>=S && x+y<=S) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 55;
long long dp[2][1 << 20];
vector<int> G[N];
pair<int,int> restriction[N];
int n,m;
int level[N], par[N];
int ok[N];
void dfs(int u, int pre){
	par[u] = pre;
	for (auto v : G[u]){
		if (v == pre) continue;
		level[v] = level[u] + 1;
		dfs(v, u);
	}
}
void travel(int id,int u, int v){
	while (level[u] > level[v]) {
		ok[u] |= (1 << id);
		u = par[u];
	}
	while (level[v] > level[u]){
		ok[v] |= (1 << id);
		v = par[v];
	}
	while (u != v){
		ok[u] |= (1 << id);
		ok[v] |= (1 << id);
		u = par[u];
		v = par[v];
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=1;i<n;++i){
		int u,v; cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, 0);
	cin >> m;
	for(int i=0;i<m;++i){
		int u, v; cin >> u >> v;
		restriction[i] = {u, v};
		travel(i, u, v);
	}
	dp[1][0] = 1;
	for(int i=1;i<n;++i){
		for(int mask = 0; mask < (1 << m);++mask)	dp[(i+1) & 1][mask] = 0;
		for(int mask = 0; mask < (1 << m);++mask){
			if (dp[i & 1][mask]){
				dp[(i+1) & 1][mask] += dp[i & 1][mask];
				dp[(i+1) & 1][mask | ok[i+1]] += dp[i & 1][mask];
			}
		}
	}
	cout << dp[n & 1][(1 << m) - 1];

}

Measured memory_bytes: 20040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
ll T[1000],A[1000];

void solve(){
    ll t = T[0];
    ll a = A[0];
    for(int i=1;i<N;i++){
        if(T[i]<A[i]){
            if(t%T[i]!=0) t+=T[i]-t%T[i];
            if ((t/T[i]) * A[i] >= a);
            else{
                t += T[i]*((a - (t/T[i])*A[i])/A[i]);
                if((a - (t/T[i])*A[i])%A[i]!=0)t+=T[i];
            }
            a = (t/T[i])*A[i];
        }else if(T[i]==A[i]){
            a = max(a,t);
            t = max(a,t);
        }
        else{
            if(a%A[i]!=0) a+=A[i]-a%A[i];
            if ((a /A[i])* T[i] >= t);
            else{
                a += A[i]*((t - (a/A[i])*T[i])/T[i]);
                if((t - (a/A[i])*T[i])%T[i]!=0) a+=A[i];
            }
            t = (a/A[i])*T[i];
        }
    }
    cout << a+t << endl;
}

int main() {
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> T[i] >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()

k = int(input())
s = input()
if k < len(s):
    print(s[:k]+"...")
else:
    print(s)

Measured memory_bytes: 9196
fun main(args: Array<String>){
    val line: String = readLine() as String
    val nm=line.split(" ")
    val n = nm[0].toLong()
    val m = nm[1].toLong()
    if (n==1L&&m==1L){
        print(1)
    }else if(n==1L||m==1L){
        print(n*m-2)
    }else print((n-2)*(m-2))

}

Measured memory_bytes: 37732
r, c = map(int, input().split())
x = [[0 for i in range(c + 1)] for j in range(r + 1)]
for i in range(r):
    a = list(map(int, input().split()))
    for j in range(c): x[i][j] = a[j]
    x[i][c] = sum(a)
for j in range(c + 1):
    s = 0
    for i in range(r):
        s += x[i][j]
    x[r][j] = s
for i in range(r + 1):
    for j in range(c + 1):
        if j == c:
            print(x[i][j])
        else:
            print(x[i][j], "", end = "")


Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a,b,nseki=1,aseki=1,bseki=1;
  cin >> n >> a >> b;
  if(a>b) cout << 0 <<endl;
  else if(a==b)cout << 1 <<endl;
  else{
  	if (n==1)cout << 0 <<endl;
  	else if (n==2)cout << 1 <<endl;
  	else{
  		cout << (b-a)*(n-2)+1 <<endl;
  	}
  }
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

def gcd(x,y):
    while y != 0:
        x, y = y, x%y
    return(x)

CD = (C*D)//gcd(C,D)

Ac = (A-1)//C
Ad = (A-1)//D
Acd = (A-1)//CD
a = (A-1)-(Ac+Ad-Acd)

Bc = B//C
Bd = B//D
Bcd = B//CD
b = B-(Bc+Bd-Bcd)

print(b-a)

Measured memory_bytes: 38356
using System;

namespace question1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);

            int res = -1000;

            if (res <= (A + B)) res = A + B;
            if (res <= (A - B)) res = A - B;
            if (res <= (A * B)) res = A * B;

            Console.WriteLine(res.ToString());

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
 
#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second
#define pb push_back 
#define pf push_front 
#define ppb pop_back 
#define ppf pop_front
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
int z , o ;

string ans = "No" ;
 
int main(){ skorost ;

	string s ;

	cin >> s ;

	int n = s.size() ;

	string t = s ;

	reverse( t.begin() , t.end() ); 

	string y ; 

	for( int i = 0 ; i < ( n - 1 ) / 2 ; i ++ ){

		y += s[i] ;

	} 

	string f = y ;

	reverse( f.begin() , f.end());


	string h ;

	for( int i = ( ( n + 3 ) / 2 ) - 1 ; i < n ; i ++ ){

		h += s[i] ;

	}

	string e = h ;

	reverse( e .begin() , e.end()) ;

	if( s == t && y == f && h == e ){

		cout << "Yes" << endl ;

	}

	else{

		cout << "No" << endl ;

	}
 
}

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

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


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

int main()
{
  int x;

  cin >> x;

  if(x>=30)
    cout << "Yes";
  else
  {
    cout << "No";
  }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}


bool solve() {
	int l,r; cin >> l >> r;
	int dif = r - l;
	if (dif > 2019) {
		cout << 0 << endl;
		return 0;
	}
	l %= 2019; r = l + dif;
	int ans = INF;
	FOR (i,l,r+1) {
		FOR (j,i+1,r+1) {
			ans = min(ans,i*j%2019);
		}
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int A1, A2, A3; cin >> A1 >> A2 >> A3;
	int ans = max({ A1, A2, A3 }) - min({ A1, A2, A3 });
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;

    constexpr int64_t mpow(int64_t a, int64_t b, int64_t mod = 1000000007) {
        if (b <= 0) return 1; if (b == 1) return a % mod; if (b == 2) return (a * a) % mod;
        return (max(a * (b & 1), (int64_t)1) * mpow(mpow(a, b / 2, mod), 2, mod)) % mod;
    }
    constexpr int64_t mdiv(int64_t a, int64_t b, int64_t mod = 1000000007) {
        return (a * mpow(b, mod - 2, mod)) % mod;
    }
}

int main() {
    int n; cin >> n;
    cout << (n - 2) * 180 << endl;
}



Measured memory_bytes: 3472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  vl kids(sz(s), 0);
  ll tmp = 0;
  rep(i, sz(s)){
    if(s[i]=='R'){
      tmp++;
    }
    else{
      kids[i-1] += (tmp + 1) / 2;
      kids[i] += tmp / 2;
      tmp = 0;
    }
  }
  for (ll i = sz(s) - 1; i >= 0;i--){
    if(s[i]=='L'){
      tmp++;
    }
    else{
      kids[i+1] += (tmp + 1) / 2;
      kids[i] += tmp / 2;
      tmp = 0;
    }
  }
  rep(i,sz(s)){
    cout << kids[i] << " ";
  }
  cout << endl;
}

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

int main(){
    int n, i, a, b, c;
    cin >> n;
    for (i = 0; i < n; i++){
        cin >> a >> b >> c;
        if (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 2972
#include <iostream>

using namespace std;

int main(){
    int N, L;
    cin >> N >> L;
    int out = 0;

    for(int i=0; i<N; i++){
        out += L + i;
    }

    if(L>0){
        out -= L;
    }else if(L+N-1<0){
        out -= L+N-1;
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int m;
	long long k;
	cin >> m >> k;
	if(m==1){
		if(k>=1)	cout << -1 << endl;
		else		cout << "0 0 1 1\n";
		return 0; 
	}
	long long max = pow(2,m);
	if(k >= max)	cout << -1 << endl;
	else{
		for(int i=0;i<max;i++){
			if(i!=k)	cout << i << ' ';
		}
		cout << k << ' ';
		for(int i=max-1;i>=0;i--){
			if(i!=k)	cout << i << ' ';
		}
		cout << k << '\n';
	}
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    A = [0]
    def rb(i=0):
        if i < N:
            ans = 0
            for j in range(1, M + 1):
                if j >= A[-1]:
                    A.append(j)
                    ans = max(ans, rb(i + 1))
                    A.pop()
            return ans
        else:
            return sum(d[j] for j in range(Q) if A[b[j]] - A[a[j]] == c[j])
    print(rb())


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)

if __name__ == '__main__':
    main()


Measured memory_bytes: 70652
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;



int n, m, x;

int main() {
	
	cin >> n >> m >> x;
	int c[12], a[12][12], sum[12] = { 0 };
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			sum[j] += a[i][j];
		}
	}
	bool tf = true;
	for (int i = 0; i < m; i++) {
		if (sum[i] < x)tf = false;
	}
	if (tf) {
		int mini = 2000000, fee;
		bool ft = true;
		for (int bit = 0; bit < (1 << n); bit++) {
			int wa[12] = { 0 };
			fee = 0;
			ft = true;
			for (int i = 0; i < n; i++) {
				
				if (bit & (1 << i)) {
					for (int j = 0; j < m; j++) {
						wa[j] += a[i][j];
						
					}
					fee += c[i];
					
				}
				
				
			}
			for (int i = 0; i < m; i++) {
				if (wa[i] < x)ft = false;
			}
			if (ft) {
				if (fee < mini && fee != 0)mini = fee;
			}
		}
		cout << mini;


	}
	else {
		cout << -1;
	}

	return 0;
}


Measured memory_bytes: 3640
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
	 long a = 0;
	 long b = 0;
	 long c = 0;
	cin >> a;

	for (long i = 1; i <= a; i++)
	{

		if ((i % 3 != 0) && (i % 5 != 0)) {
			b += i;
			/*printf("\n");
			printf("%.0f", b);
			printf(">>>%d\n", i);*/
			continue;
		}
		
		/*
		if (i % 3 == 0)
		{
			printf("fizz");
		}
		if (i % 5 == 0)
		{
			printf("buzz");
		}*/
	}

	printf("%ld", b);
	cin >> b;
	return 0;
}

Measured memory_bytes: 3760
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <memory>
#include <unordered_map>

struct Node {
public:
    Node(int key_in) :
        parent(nullptr),
        left(nullptr),
        right(nullptr),
        key(key_in)
    {}

public:
    Node* parent;
    Node* left;
    Node* right;
    int   key;
};

struct Tree {
public:
    Tree() :
        root(nullptr)
    {}

    Node* root;
};

void insert(Tree& t, Node* z)
{
    Node* y = nullptr;
    Node* x = t.root;
    while (x != nullptr) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;

    if (y == nullptr) {
        t.root = z;
    } else if (z->key < y->key) {
        y->left = z;
    } else {
        y->right = z;
    }
}

void printInOrder(Node* node)
{
    if (node->left != nullptr) {
        printInOrder(node->left);
    }

    std::printf(" %d", node->key);

    if (node->right != nullptr) {
        printInOrder(node->right);
    }
}

void printPreorder(Node* node)
{
    std::printf(" %d", node->key);

    if (node->left != nullptr) {
        printPreorder(node->left);
    }

    if (node->right != nullptr) {
        printPreorder(node->right);
    }
}

void print(Tree& t)
{
    Node* root = t.root;
    if (root == nullptr) {
        return;
    }

    printInOrder(root);
    std::cout << std::endl;
    printPreorder(root);
    std::cout << std::endl;
}

int main()
{
    Tree t;

    int n;
    std::cin >> n;

    std::string str;
    int key;
    for (int i = 0; i < n; ++i) {
        std::cin >> str;
        if (str == "insert") {
            std::cin >> key;
            Node* node = new Node(key);
            insert(t, node);
        } else if (str == "print") {
            print(t);
        } else {
            return -1;
        }
    }

    return 0;
}


Measured memory_bytes: 26680
#include<stdio.h>

int main(void){
  int n,i,c;
  int a[105];
  c=0;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        printf("DENIED");
        c = 1;
        break;
      }
    }
  }
  
  if(c==0)
    printf("APPROVED");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace std;

string s;

signed main () {
  cin >> s;
  string t = "";
  string r = "";
  for (int i = 0; i < s.size(); i++) {
    if (i & 1) {
      t += '1';
      r += '0';
    } else {
      t += '0';
      r += '1';
    }
  }
  int a = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    a += (s[i] != t[i]);
    b += (s[i] != r[i]);
  }
  cout << min (a, b) << endl;
  return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

char ch[301][301];
int N;

void solve() {
	cin >> N;
	REP(i, N) cin >> ch[i];
	int ans = 0;
	for (int k = 0; k < N; k++) {
		bool flag = true;
		for (int i = 1; i < N; i++) {
			for (int j = 0; j != i; j++) {
				if (ch[(i + k) % N][j] != ch[(j + k) % N][i]) {
					flag = false;
				}
			}
		}
		if (flag) ans++;
	}
	ans = ans * N;
	cout << ans << endl;
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)


int main()
{
	cin.tie( 0 ); ios::sync_with_stdio( false );
	ll l,r;cin>>l>>r;

	if(l+2018<=r)
	{
		cout<<0<<endl;
	}
	else
	{
		ll minn = 2019;
		for(ll i = l; i <= r; ++i)
		for(ll j = l; j <= r; ++j)
		if(i<j)
			minn = min( minn, i*j%2019ll );
		cout << minn << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// D - Lazy Faith
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define INF (10000000000*2)

int binarysearch(vl &v, ll x){
	int ok = 0, ng = v.size();
	while(abs(ok - ng) > 1){
		int mid = (ok + ng) / 2;
		if(v[mid] < x) ok = mid; else ng = mid;
	}
	return ok;
}

ll calc(vl &s, vl &t, ll x){//s,t -inf~+inf
	ll mini = INF;

	for(int j=0; j<2; ++j){
		int ia = binarysearch(s, x) + j;
		ll ax = s[ia];
		for(int k=0; k<2; ++k){
			int ib = binarysearch(t, ax) + k;
			ll bx = t[ib];
			mini = min(mini, abs(x-ax) + abs(ax-bx));
		}
	}

	for(int j=0; j<2; ++j){
		int ia = binarysearch(t, x) + j;
		ll ax = t[ia];
		for(int k=0; k<2; ++k){
			int ib = binarysearch(s, ax) + k;//k: 0->left, 1->right
			ll bx = s[ib];
			mini = min(mini, abs(x-ax) + abs(ax-bx));
		}
	}

	return mini;
}

int main(){
	int A,B,Q; cin>>A>>B>>Q;

	vl S(A+2, INF), T(B+2, INF);
	for(int i=1; i<=A; ++i) cin>>S[i];S[0] = -INF;
	for(int i=1; i<=B; ++i) cin>>T[i];T[0] = -INF;

	for(int i=0; i<Q; ++i){
		ll x; cin>>x;
		cout<< calc(S, T, x) <<endl;
	}
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

const int NUM_SEATS = 100000;
const int N_MAX = 1000;

int N;
int l, r;

int main() {
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
(defun main ()
  (let ((a (read))
        (v (read))
        (b (read))
        (w (read))
        (t1 (read))
        (ans "NO"))
    (cond
      ((> a b)
         (setf b (- b (* t1 w)))
         (setf a (- a (* t1 v)))
       (if (<= a b)
           (setf ans "YES")))
      (t
         (setf b (+ b (* t1 w)))
         (setf a (+ a (* t1 v)))
       (if (>= a b)
           (setf ans "YES"))))
    (format t "~a~%" ans)))

(main)


Measured memory_bytes: 23488
N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(N)]

ans = 0
for i in range(1 << 3):
    x = bin(i)[2:]
    while len(x) < 3:
        x = '0' + x
    op = ''
    for j in x:
        if j == '1':
            op += '+'
        else:
            op += '-'
    B = []
    for j in range(N):
        B.append(eval(op[0] + str(A[j][0]) + op[1] + str(A[j][1]) + op[2] + str(A[j][2])))
    B.sort(reverse = True)
    ans = max(ans, sum(B[:M]))
    
print(ans)

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

struct Segment_tree{
    using T=ll;

    int n;
    vector<T> data;
    const T out=(1LL<<31)-1;

    inline T vmerge(T l,T r){return min(l,r);}

    Segment_tree(int n):n(n){data.assign(2*n,out);}

    void update(int p,T x) {  // set value at position p
        for(data[p+=n]=x; p > 1; p >>= 1) data[p>>1]=vmerge(data[p],data[p^1]);
    }

    T query(int l, int r) {  // sum on interval [l, r)
        T resl = out,resr = out;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l&1) resl = vmerge(data[l++], resl);
            if (r&1) resr = vmerge(resr, data[--r]);
        }
        return vmerge(resl,resr);
    }
};

int main(void){
	int n,q;
	cin >> n >> q;

	Segment_tree rmq(n);

	rep(loop,q){
		int com,x,y;
		cin >> com >> x >> y;
		if(com)
			cout << rmq.query(x,y+1) << endl;
		else
			rmq.update(x,y);
	}
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void) {
	char ref[5], ans[5];
	
	while(1){
		scanf("%s %s", ref, ans) ;
		
		if(ref[0] == '0' && ans[0] == '0') break;
		
		int i, j, hit=0, blow=0;
		
		for(i=0; i<4; i++) {
			for(j=0; j<4; j++) {
				if(i==j && ref[i] == ans[j]) hit++;
				else if(i!=j && ref[i] == ans[j]) blow++;
			}
		}
		
		printf("%d %d\n", hit, blow);
		
	}
	
	return 0;
}

Measured memory_bytes: 536
#n=int(input())
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

l.sort(key=lambda x: x[0])

#print(l)
money=0
count=0
for i in range(n):
    a=l[i][0];b=l[i][1]
    if (m-count)>b :
        count+=b
        money+=a*b
    else:
        money+=a*(m-count)
        count+=(m-count)
        break
print(money)


Measured memory_bytes: 29028
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;

struct Problem{
    string s;
    void solve(){
        cin >> s;
        vector<int> c(3);
        for(int i=0; i<(int)s.size(); ++i){
            c[s[i]-'a']++;
        }
        sort(c.begin(),c.end());
        if(c[2]-c[0]>=2)cout <<"NO" <<"\n";
        else cout << "YES" <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    Problem p;
    p.solve();
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  ll cn[5]={};
  for(int i=0;i<n;i++){
    string s;cin>>s;
    if(s[0]=='M')cn[0]++;
    else if(s[0]=='A')cn[1]++;
    else if(s[0]=='C')cn[2]++;
    else if(s[0]=='R')cn[3]++;
    else if(s[0]=='H')cn[4]++;
  }
  ll cnt=0;
  for(int i=0;i<5;i++)
    if(cn[i])cnt++;
  ll ans=0;
  if(cnt>=3){
    if(cnt==3){
      ans=1;
      //cout<<"!"<<endl;
      for(int i=0;i<5;i++)
	if(cn[i])ans*=(ll)cn[i];
    }else if(cnt==4){
      vector<ll>cc;
      for(int i=0;i<5;i++)
	if(cn[i])cc.pb(cn[i]);
      ans+=cc[0]*cc[1]*cc[2];
      ans+=cc[0]*cc[1]*cc[3];
      ans+=cc[0]*cc[2]*cc[3];
      ans+=cc[1]*cc[2]*cc[3];
    }else{
      ans+=cn[0]*cn[1]*cn[2];
      ans+=cn[0]*cn[1]*cn[3];
      ans+=cn[0]*cn[1]*cn[4];
      ans+=cn[0]*cn[2]*cn[3];
      ans+=cn[0]*cn[2]*cn[4];
      ans+=cn[0]*cn[3]*cn[4];
      ans+=cn[1]*cn[2]*cn[3];
      ans+=cn[1]*cn[2]*cn[4];
      ans+=cn[1]*cn[3]*cn[4];
       ans+=cn[3]*cn[2]*cn[4];
   }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
def b_exchange(A, B, K):
    takahashi_cookie = A
    aoki_cookie = B
    turn = 0
    while turn < K:
        if turn % 2 == 0:
            if takahashi_cookie % 2 == 1:
                takahashi_cookie -= 1
            takahashi_cookie //= 2
            aoki_cookie += takahashi_cookie
        else:
            if aoki_cookie % 2 == 1:
                aoki_cookie -= 1
            aoki_cookie //= 2
            takahashi_cookie += aoki_cookie
        turn += 1
    ans = '{0} {1}'.format(takahashi_cookie, aoki_cookie)
    return ans

A, B, K = [int(i) for i in input().split()]
print(b_exchange(A, B, K))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

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


}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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;
}
int main(){
    ll n;cin >> n;
    ll ans=0;
    while(n>0){
        n--;ans+=n;
    }
    cout <<ans <<endl;
}


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

MOD = 10**9+7

NN = [0 for _ in range(1001)]
AA = [0 for _ in range(1001)]


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        # if NN[temp] != 0:
        #     arr.append(NN[temp][0])
        #     return arr
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

ans = 1
for i in range(1, N+1):
    chin = factorization(i)
    # NN[i] = chin
    # print(chin)
    for x,y in chin:
        AA[x] += y
for i in range(2, N+1):
    if AA[i] > 0:
        # print(i, AA[i])
        ans *= (AA[i]+1) % MOD
        ans %= MOD
print(ans)


Measured memory_bytes: 3188
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void factoring(ll n, map<ll, ll>& mp) {
    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,sum=1;
    cin>>n;
    map<ll,ll> mp;
    rrep(j,n) factoring(j,mp);
    for(auto p:mp){
        sum*=(p.second+1);
        sum%=mod;
    }
    cout<<sum%mod<<endl;
    return 0;
}


Measured memory_bytes: 256
P=1000000007
def power(x,p):
  if(p==0):
    return 1;
  if(p%2):
    return power(x,p-1)*x%P;
  a=power(x,p//2);
  return a*a%P;
def inv(x):
  return power(x,P-2);
N=int(input());A=list(map(int,input().split()));
#N=10000;A=[1000000 for i in range(N)];
L=[0 for i in range(max(A)+1)]
for a in A:
  t=a;i=2;
  while(i**2<=a):
    c=0;
    while(t%i==0):
      t//=i;c+=1;
    L[i]=max(L[i],c)
    i+=1;
  if(t!=1):
    L[t]=max(L[t],1)
    
l=1;
for i in range(2,len(L)):
  l=l*power(i,L[i])%P;
b=0;
for a in A:
  b=(b+inv(a))%P
print(l*b%P)

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

using namespace std;

using ll = long long;

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

    string s, p;
    cin >> s;

    for (auto c : s) {
        if (c != 'B') p.push_back(c);
        else if (!p.empty()) p.pop_back();
    }
    cout << p << endl;

    return 0;
}


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

int main ()
{
	int h, w;
	cin >> h >> w;
	vector<vector<int>> neighbour(h);

	for (int i=0; i<h; ++i)
	{
		neighbour[i].resize(w);

		for (int j=0; j<w; ++j)
		{
			neighbour[i][j] = 1;
		}
	}

	char c;
	for (int i=0; i<h; ++i)
	{
		for (int j=0; j<w; ++j)
		{
			cin >> c;

			if ('#' == c)
			{
				if (0 < i) neighbour[i-1][j] <<= 1;
				if (i+1 < h) neighbour[i+1][j] <<= 1;
				if (0 < j) neighbour[i][j-1] <<= 1;
				if (j+1 < w) neighbour[i][j+1] <<= 1;
			}
			else
			{
				neighbour[i][j] = 0;
			}
		}
	}

	bool hasIsolatedPoint = false;

	for (auto &row : neighbour)
	{
		for (int count : row)
		{
			if (1 == count)
			{
				hasIsolatedPoint = true;
				goto LoopEnd;
			}			
		}
	}

	LoopEnd:

	cout << (hasIsolatedPoint ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, K, Max = 0;
    cin >> N >> K;
    vll V(N);
    rep(i, N)
    {
        cin >> V[i];
    }

    for (int a = 0; a <= min(N, K); a++)
    {

        for (int b = 0; a + b <= min(N, K); b++)
        {
            vll q;
            ll sumB = 0;
            ll sumA = 0;
            for (size_t i = 0; i < a; i++)
            {
                sumA += V[i];
                if (V[i] < 0)
                    q.push_back(V[i]);
            }
            for (size_t i = 0; i < b; i++)
            {
                sumB += V[N - i - 1];
                if (V[N - i - 1] < 0)
                    q.push_back(V[N - i - 1]);
            }
            ll tmp = 0;
            sort(all(q));
            for (size_t i = 0; i < K - (a + b) and i < q.size(); i++)
            {
                tmp += q[i];
            }

            chmax(Max, sumA + sumB - tmp);
        }
    }
    cout << Max;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
using veci = vector<int>;
using veci = vector<int>;
using veci = vector<int>;
using veci = vector<int>;
using G = vector<vector<int>>;
using ll = long long;
int INF = 10101010;
int main(){
   int n, m;
   cin >> n >> m;
   G a(n, veci(m));
   G b(m, veci(1));
   rep(i, n){
       rep(j, m){
           cin >> a.at(i).at(j);
       }
   }
   rep(i, m){
       cin >> b.at(i).at(0);
   }
   G ans(1, veci(m, 0));
   rep(i, n){//行列の行の固定
       ll ans1 = 0;
       rep(j, m){
           ans1 += a.at(i).at(j) * b.at(j).at(0);
       }
       cout << ans1 << endl;
   }
}


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

tt = list(map(int, input().split()))
v = list(map(int, input().split()))

time = sum(tt);
INF = 999999
border = [0] *(n+1)
start_v = [0] *(n+1)
end_v = [0] *(n+1)

temp = 0
for i in range(n):
	temp += tt[i]
	border[i+1] = temp
	start_v[i] = v[i]
	end_v[i+1] = v[i]

t = 0
idx = 0
ans = 0
vlast = 0
v0 = 0
new_interval = False
limitation_front =0 # 最初の計算に必要

# print (border)
while t < time :
	t += 0.5
	new_interval = False

	#直接制約
	v0 = v[idx]
	if t == border[idx+1]:
		idx += 1
		new_interval = True
#		v0 = min(v0, v[idx])

	if(not new_interval):
		limitation_front += 0.5
		if v0 > limitation_front:
			v0 = limitation_front
	
	if new_interval: 
		limitation_front = INF
		for j in range(n+1):
			if border[j] <= t:
				#前の時刻からの制約
				temp = end_v[j] + (t - border[j])
				if v0 > temp:
					v0 = temp
				if limitation_front > temp:
					limitation_front = temp
			else:
				break
			#print (limitation_front)


	for j in range(n+1):
		if border[j] >= t:
			#後ろの時刻からの制約
			temp = start_v[j] + (border[j] - t)
			if v0 > temp:
				v0 = temp

	#print(v0)

#	ans += 0.5 * (vlast + v0) / 2
	ans += (vlast + v0)
	vlast = v0

ans /= 4.0
print (ans)



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

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

int a[210];
int main(){
	int n;
	cin >> n;
	rep(i,0,n*2) cin >> a[i];
	sort(a, a+2*n);
	int ans = 0;
	for(int i=0; i<2*n; i+=2) ans += a[i];
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int m1,m2,d1,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1==1 && d1==31)cout << 1 << endl;
  else if(m1==2 && d1==28)cout << 1 << endl;
  else if(m1==3 && d1==31)cout << 1 << endl;
  else if(m1==4 && d1==30)cout << 1 << endl;
  else if(m1==5 && d1==31)cout << 1 << endl;
  else if(m1==6 && d1==30)cout << 1 << endl;
  else if(m1==7 && d1==31)cout << 1 << endl;
  else if(m1==8 && d1==31)cout << 1 << endl;
  else if(m1==9 && d1==30)cout << 1 << endl;
  else if(m1==10 && d1==31)cout << 1 << endl;
  else if(m1==11 && d1==30)cout << 1 << endl;
  else if(m1==12 && d1==31)cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 3572
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <cctype>
using namespace std;
const int64_t INF=10000000000000000;
int main(){
    double ans=0;
    long long int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int cont=0;
        long long int score = i;
        while(true){
            if(score>=k){
                break;
            }else{
                cont++;
                score = score*2;
            }
        }
        ans += (1.0/n)*pow(0.5,cont);
    }
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int H,W,h,w;

	while(1){
		cin >> H >> W;
		if(H==0 && W==0)break;

		for(h=1 ; h<=H ; h++){
			for(w=1 ; w<=W ; w++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
int main(){
  int x=0,y=0,i=0;
  char s[MAX];
  int sgym[MAX];
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){

      i--;
      sgym[i-1]+=sgym[i];
     } else if ( s[0] == '-' ){
      i--;
      sgym[i-1] -= sgym[i];
     } else if ( s[0] == '*' ){
 i--;
      sgym[i-1] *= sgym[i];
    } else {
      sgym[i] = atoi(s);
      i++;
    }
  }
  printf("%d\n",sgym[0]);
  return 0;
}

Measured memory_bytes: 548
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cmath>
#include <algorithm>
using namespace std;
using LL = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = numeric_limits<int>::infinity();
const int E = numeric_limits<int>::min();

int main(void)
{
    char T[200000];
    cin >> T;

    for (int i = 0; T[i] != '\0'; i++){
        if (T[i] == '?'){
            if (T[i+1] == '\0'){
                T[i] = 'D';
            }else if (T[i-1] == 'P'){
                T[i] = 'D';
            }else if (T[i+1] == '?'){
                T[i] = 'P';
                T[i+1] = 'D';
            }else if (T[i+1] == 'D'){
                T[i] = 'P';
            }else{
                T[i] = 'D';
            }
        }
        cout << T[i];
    }
    cout << endl;

    return 0;
}

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

int main() {
    ll a[3];rep(i,3)cin>>a[i];
    rep(i,3)if(a[i]%2==0){
        cout<<0<<endl;
        return 0;
    }
    sort(a,a+3);
    ll m1 = a[2]/2;
    ll m2 = a[2]-m1;
    ll ans = (m2-m1)*a[0]*a[1];
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/ruby
input = STDIN.readlines
n, k = input.map{|l| l.chomp.split(/\s+/).map{|m| m.to_i}.flatten}.flatten

num = 1
n.times do |i|
  if num*2 < (num+k)
    num *= 2
  else
    num += k
  end
end
puts num


Measured memory_bytes: 1916
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int N;
int a[555][555];
//[x,x+k)まで
void solve(int x, int k, int L) {
	if (k == 1)return;
	int x1 = x;
	int k1 = k / 2;
	int x2 = x1 + k1;
	int k2 = k - k1;
	for (int i = x1; i < x1 + k1; ++i) {
		for (int j = x2; j < x2 + k2; ++j) {
			a[i][j] = L;
		}
	}
	solve(x1, k1, L + 1);
	solve(x2, k2, L + 1);
}

int main() {
	cin >> N;
	solve(0, N, 1);
	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			cout << a[i][j] << " \n"[j == N - 1];
		}
	}
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
using namespace std;
#include<algorithm>
#define MAX_N 505
#define MAX_M 2 * 100001
#define MAX_Q 100001
int grid[MAX_N][MAX_N];

int main() {
    int N, M, Q;

    cin >> N >> M >> Q;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            grid[i][j] = 0;
        }
    }

    int L, R;
    for (int i = 0; i < M; i++) {
        cin >> L >> R;
        grid[L][R]++;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 2; j <= N; j++) {
            grid[i][j] += grid[i][j - 1];
        }
    }
    int p, q;
    for (int i = 0; i < Q; i++) {
        cin >> p >> q;
        int count = 0;
        for (int j = p; j <= q; j++) {
            count += grid[j][q] - grid[j][p - 1];
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 998244353;
int N, X;
int comb[3001][6001];
int f[3001][6001];
int tate[3002][6002];
int yoko[3002][6002];

int F(int a, int b) {
	if (a < 0 || b < 0) return 0;
	return f[a][b];
}

int Tate(int a, int b) {
	if (a < 0 || b < 0) return 0;
	return tate[a][b];
}

int Yoko(int a, int b) {
	if (a < 0 || b < 0) return 0;
	return yoko[a][b];
}

int calc(int n, int i) {
	int j;
	int res = 0;
	
	int a = Tate(n - i, X - 2 - 2 * i);
	int b = Tate(n - 2 * i - 1, X - 2 - 2 * i);
	int c = Yoko(n - i - 1, X - 2 - 2 * i);
	res = (a - b + mod + c) % mod;
	
	//cout << "calc(" << n << ", " << i << ") = " << res << endl;
	return res;
}

int solve(int n) {
	int i;
	int ret = 0;
	
	for (i = 0; i < n; i++) {	//22…2, i個 + 1 + 何か
		ret += calc(n, i);
		ret %= mod;
	}
	
	//全部2の場合は個別に計算
	if (X % 2 == 0) ret += (n * 2 < X);
	else ret++;
	
	ret %= mod;
	return ret;
}

signed main() {
	int i, j;
	
	comb[0][0] = 1;
	for (i = 1; i < 3001; i++) {
		comb[i][0] = 1;
		for (j = 1; j < 6001; j++) {
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			comb[i][j] %= mod;
		}
	}
	
	for (i = 0; i < 3001; i++) {
		for (j = i; j <= 2 * i; j++) {
			f[i][j] = comb[i][j - i];
		}
	}
	
	for (j = 0; j < 6001; j++) {
		tate[0][j] = 0;
		for (i = 1; i < 3002; i++) {
			tate[i][j] = tate[i - 1][j] + f[i - 1][j];
			tate[i][j] %= mod;
		}
	}
	
	for (i = 0; i < 3001; i++) {
		yoko[i][0] = 0;
		for (j = 1; j < 6002; j++) {
			yoko[i][j] = yoko[i][j - 1] + f[i][j - 1];
			yoko[i][j] %= mod;
		}
	}
	
	cin >> N >> X;
	
	int ans = 0;
	for (i = 0; i <= N; i++) {	//zero
		int res = comb[N][i] * solve(N - i);
		res %= mod;
		ans += res;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 563200
N, M = map(int,input().split())
A = [str(input()) for _ in range(N)]
B = [str(input()) for _ in range(M)]
 
res = "No"

for i in range(N-M+1):
  for j in range(N-M+1):
    for k in range(M):
      if(A[i+k][j:j+M] != B[k]):
        break
      if(k==M-1):
        res="Yes"
          
print(res)

Measured memory_bytes: 3064