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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define maxn 15

int gcd(int x, int y)
{
    if (x < y)
        swap(x, y);
    if (y == 0)
        return x;
    return gcd(x % y, y);
}

signed main()
{
    string S;
    cin >> S;
    int ans1[S.length()], ans2[S.length()];
    rep(i, S.length())
    {
        if (i % 2)
        {
            ans1[i] = 1;
            ans2[i] = 0;
        }
        else
        {
            ans1[i] = 0;
            ans2[i] = 1;
        }
    }
    int ch1 = 0;
    int ch2 = 0;
    rep(i, S.length())
    {
        if ('0' + ans1[i] != S[i])
        {
            ch1++;
        }
        if ('0' + ans2[i] != S[i])
        {
            ch2++;
        }
    }
    cout << ((ch1 < ch2) ? ch1 : ch2) << endl;
}


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

int main(){

  string s;
  string t;

  while(true){
    getline(cin,s);
    if(s == "END OF INPUT") break;
    t = "";

    for(int i=0;i<=s.size();i++){
      
      if(s[i] == ' '){
	cout << t.size();
	t = "";
      }

      else t += s[i];

    }

    cout << t.size()-1 << endl;

  }
}

Measured memory_bytes: 1184
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    String Ans="No";
    for(int x=1; x<10; x++){
      for(int y=1; y<10; y++){
        if(a==x*y){
          Ans="Yes";
        }
      }
    }
    System.out.println(Ans);
  }
}

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

using namespace std;

const int MAXN = 3010;
const int INF = 1e9;

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

	string s, t;
	cin >> s >> t;

	int N = s.size(), M = t.size();
	vector<vector<int>> dp(MAXN, vector<int>(MAXN, 0));

	for(int i=1; i<=N; i++){
		for(int j=1; j<=M; j++){
			if(s[i-1] == t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
			else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
		}
	}

	string ans = "";

	int i = N, j = M;
	while(i >= 1 && j >= 1){
//		cout << i << " " << j << "\n";
		if(s[i-1] == t[j-1]){
			ans += s[i-1];
			i--;
			j--;
		}
		else{
			if(dp[i][j-1] > dp[i-1][j])
				j--;
			else
				i--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}


Measured memory_bytes: 35840
#include<stdio.h>

int main(){

  int i,b,a[31]={0};
  for(i=0;i<28;i++){scanf("%d",&b);
    a[b]=1;}
  for(i=1;i<=30;i++){if(a[i]==0){
      printf("%d\n",i);
    }}

    return 0;
 }

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
const ll INF=1e17;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void  solve(){
  ll n,k;
     cin>>n>>k;
     ll a[n];
     for(int i=0;i<n;i++)cin>>a[i];
     int ct[n][60];
     memset(ct,0,sizeof(ct));
     for(int i=0;i<n;i++){
          ll t=a[i];
          for(int j=0;j<50;j++){
               ct[i][j]=t%2;
               t/=2;
          }
     }
     ll res=0LL,tmp=0LL;
     for(int j=59;j>=0;j--){
          int count1=0;
          for(int i=0;i<n;i++){if(ct[i][j]==1)count1++;}
          if(count1>=n-count1){
               res+=count1*(1LL<<j);
          }
          else{
               ll ty=(tmp+(1LL<<j));
               if(ty<=k){
                    tmp=ty;
                    res+=(n-count1)*(1LL<<j);
               }
               else{
                    res+=(count1)*(1LL<<j);
               }
          }
     }
     cout<<res;
}
int main(){
    optimizeIO();
    solve();
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long int a, b;
    cin >> a >> b;

    if (a == b){
        cout << a << '\n';
        return 0;
    }

    if (a % 2 == 0 && b % 2 == 0){
        if (((b - a) / 2) % 2 == 0)
            cout << b << '\n';
        else
            cout << (b ^ 1LL) << '\n';
    }
    else if (a % 2 == 0 && b % 2 == 1){
        if (((b - a + 1) / 2) % 2 == 0)
            cout << 0 << '\n';
        else
            cout << 1 << '\n';
    }
    else if (a % 2 == 1 && b % 2 == 0){
        if (((b - a - 1) / 2) % 2 == 0)
            cout << (a ^ b) << '\n';
        else
            cout << (a ^ b ^ 1LL) << '\n';
    }
    else if (a % 2 == 1 && b % 2 == 1){
        if (((b - a) / 2) % 2 == 0)
            cout << a << '\n';
        else
            cout << (a ^ 1LL) << '\n';
    }

    return 0;
}


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

double dtor(double d) {
    return d * acos(-1) / 180;
}

void solve() {
    double a, b, x;
    cin >> a >> b >> x;
    double V = a * a * b;
    double h = x / (a * a);
    auto isOK = [&](double d) -> bool {
        if(V > 2 * x) {
            double r = dtor(90 - d);
            double c = b * tan(r);
            double S = c * b / 2;
            return S >= a * h;
        } else {
            double r = dtor(d);
            double c = a * tan(r) / 2;
            return b - h >= c;
        }
    };
    double l = 0, r = 90;
    rep(_, 100)  {
        double mid = (l + r) / 2;
        if(isOK(mid)) l = mid;
        else r = mid;
    }
    printf("%.10lf\n", l);
}

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


Measured memory_bytes: 256
#include<stdio.h>
signed main(){
   int x[5],i;
   for(i=0;i<5;i++){
      scanf("%d",&x[i]);
   }
   for(i=0;i<5;i++){
      if(x[i]==0){
         printf("%d\n",i+1);
      }
   }
   return(0);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

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

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

using namespace std;
using ll = long long;

ll H, W;
vector<string> a(100);

int main(void)
{
  cin >> H >> W;
  rep(0, H) cin >> a.at(i);

  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int y = 0; y < H; ++y) {
    for (int x = 0; x < W; ++x) {
      if (a[y][x] == '#') {
        row[y] = true;
        col[x] = true;
      }
    }
  }

  for (int i = 0; i < H; ++i) {
    if(row[i]) {
      for (int j = 0; j < W; ++j) {
        if (col[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, k;
    cin >> n >> k;
    vec<P> dt(n);
    REP(i, n) {
        ll d, t;
        cin >> t >> d;
        dt[i] = {d, t};
    }
    sort(all(dt), greater<P>());
    priority_queue<ll> que;
    set<ll> st;
    ll sum = 0;
    REP(i, k) {
        auto [d, t] = dt[i];
        if(st.count(t))
            que.push(-d);
        else {
            st.insert(t);
        }
        sum += d;
    }
    ll x = st.size();
    ll ans = sum + x * x;
    rep(i, k, n) {
        auto [d, t] = dt[i];
        if(st.count(t))
            continue;
        st.insert(t);
        x++;
        if(!que.size())
            break;
        ll pre = que.top();
        que.pop();
        sum += d + pre;
        chmax(ans, sum + x * x);
    }

    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


Measured memory_bytes: 8180
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int h,w; cin >> h >> w;
	vector<string> mp;
	string str;
	for (int i = 0; i < h ; i++) {
		cin >> str;
		mp.push_back(str);
	}
	for (int i = -1; i < h + 1; i++) {
		for (int j = -1; j < w + 1; j++) {
			if (j == -1 || j == w  || i == -1 || i == h ) {
				cout << '#';
			}
			else {
				cout << mp[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

char red[500][500];
char blue[500][500];
char purple[500][500];

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

  FOR(i,0,h-1){
    FOR(j,0,w-1){
      red[i][j] = '.';
      blue[i][j] = '.';
    }
  }

  FOR(i,0,h-1){
    if(i%2==0){
      FOR(j,0,w-2){
        red[i][j] = '#';
      }
      blue[i][w-1] = '#';
    }
    else{
      red[i][0] = '#';
      FOR(j,1,w-1){
        blue[i][j] = '#';
      }
    }
  }

  FOR(i,0,h-1){
    string s;
    cin >> s;
    FOR(j,0,w-1){
      if(s[j]=='#'){
        red[i][j] = '#';
        blue[i][j] = '#';
      }
    }
  }

  FOR(i,0,h-1){
    FOR(j,0,w-1){
      cout << red[i][j];
    }
    cout << endl;
  }
  cout << endl;
  FOR(i,0,h-1){
    FOR(j,0,w-1){
      cout << blue[i][j];
    }
    cout << endl;
  }
  
}



Measured memory_bytes: 1280
N, K, Q = map(int, input().split())
n_AC = [0] * (N+1)
point = [K] * (N+1)
for i in range(Q):
  n_AC[int(input())] += 1

for i in range(1, N+1):
  point[i] = point[i] - (Q - n_AC[i])
  if point[i] > 0:
    print('Yes')
  else:
    print('No')
    

Measured memory_bytes: 8520
// C - Fennec vs Monster
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N,K;
	int H[200000];
	cin>>N>>K;
	long long ans = 0;
	if(N > K){
		rp(i,0,N) cin>>H[i];
		sort(H, H+N);
		reverse(H, H+N);
		rp(i,K,N) ans += H[i];
	}
	cout<< ans <<endl;
}

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

using namespace std;

int main(void)
{
	long long n,a,b; cin>>n>>a>>b;
	long long x[n]; for(int i = 0; i < n; i++) cin>>x[i];
	
	int now = x[0];
	long long ans = 0;
	long long w;
	for(int i = 1; i < n; i++){
		w = (x[i] - x[i-1]) * a;
		if(w < b){
			ans+=w;
		}
		else{
			ans+=b;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    string str_blue[n];
    for(int i=0;i<n;i++)cin >> str_blue[i];

    int m;
    cin >> m;
    string str_red[m];
    for(int i=0;i<m;i++)cin >> str_red[i];

    int ans = 0;
    for(int i=0;i<n;i++){
        int ans_tmp = 1;
        for(int j=i+1;j<n;j++){
            if(str_blue[i]==str_blue[j])ans_tmp++;
        }

        for(int j=0;j<m;j++){
            if(str_blue[i]==str_red[j])ans_tmp--;
        }
        if(ans<ans_tmp)ans = ans_tmp;
    }
    cout << ans << endl;
}


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

using namespace std;

int n;

void fun(int i,char c,string s){
    if(i>n) {
        cout<<s<<endl;
        return;
    }
    // if(i==1) printf("a");
    for(char ch='a';ch<=c;ch+=1) fun(i+1,c,s+ch);
    if(i>1) fun(i+1,c+1,s+=c+1);
}

int main(void)
{
    cin>>n;
    fun(1,'a',"");
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    if(n%2==1){
        cout<<0<<endl;
    }else{
        ll divide = 10;
        while(n>=divide){
            ans += n/divide;
            divide *= 5;
        }
        cout<<ans<<endl;

    }
    

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    int a ,n, x ;
    cin>> n;
    cin>> a;
    if (n>500 ){
        x = n%500;
        if (x<=a) {
        cout<< "Yes";
        }
        else{
            cout<< "No";
        }
    }
    else if(a>0 && n<=a){
        cout<< "Yes";
    }
    else{
        cout<< "No";
    }
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
int main(void)
{
    int n,a,b;
    cin >> n >> a >> b;
    int c = a*n;
    pr(c>b?b:c);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;

void solve() {
  char s[10];
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes\n" : "No\n");
}

int main(int argc, char *argv[]) {
  int o_o = 1;
  if (!o_o) cin >> o_o;
  for (; o_o; --o_o) solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
    ll n, limit;
    cin >> n >> limit;
    vector<pair<ll, ll>> luggage(n);
    ll quota_max = 0;
    for (int i = 0; i < n; ++i) {
        cin >> luggage[i].first >> luggage[i].second;
        quota_max += luggage[i].second;
    }
    vector<vector<ll>> dp(110, vector<ll>(300300, 1001001001001001));
    dp[0][0] = 0;
    for (int i = 0; i <= n; ++i) {
        ll new_w = luggage[i].first;
        ll new_v = luggage[i].second;
        for (int j = 0; j <= quota_max; ++j) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + new_v] = min(dp[i + 1][j + new_v], dp[i][j] + new_w);
        }
    }
    ll ans = 0;
    // cout << limit << "here "<<endl;
    for (ll k = 0; k <= quota_max; ++k) {
        // if(k==3583)cout << dp[n][k] << "yyooo\n";
        if (dp[n][k] <= limit) ans = max(ans, k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 260992
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int a,b,c,x;
  cin >> a >> b >> c >> x;

  int count = 0;
  for(int i = 0; i <= a; i++) {
    for(int j = 0; j <= b; j++) {
      for(int k = 0; k <= c; k++) {
        if(x == 500*i+100*j+50*k) count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3596
import itertools
import numpy as np

def solve(n, x, y):
    total, num = 0, 0
    x, y = np.asarray(x), np.asarray(y)
    for p in itertools.permutations(range(n)):
        num += 1
        p = np.array(p, dtype=int)
        dx = x[p[1:]] - x[p[:-1]]
        dy = y[p[1:]] - y[p[:-1]]
        total += np.sum(np.sqrt(dx**2 + dy**2))
    return total / num

n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())
print(solve(n, x, y))

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

bool sosu[500000];

int main(){
	for(int i = 0; i < 500000; i++) sosu[i] = true;
	sosu[0] = sosu[1] = false;
	for(int i = 2; i * i <= 500000; i++){
		if(sosu[i])
			for(int k = 2; i * k <= 500000; k++)
				sosu[i*k] = false;
	}
	int n;
	while(cin >> n && n != 0){
		int count = 0;
		int i = 2;
		while(n - i >= i){
			if(sosu[i] && sosu[n-i]) count++;
			i++;
		}
		cout << count << endl;
	}
	return 0;
}

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

// in-short-use macros

#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010



//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld pi = acos(-1);
    ld  j = h*(30) + m*(0.5), k = m*6;
    ld C = min(360-abs(j-k),abs(j-k));
    ld ans = a*a + b*b -2*a*b*cosl(C*pi/180.0);
    cout<<fixed<<setprecision(12)<<sqrtl(ans)<<"\n";
    return 0;
}

Measured memory_bytes: 4176
S = input()
T = input()
ls = len(S)
lt = len(T)

for i in range(ls-lt,-1,-1):
  for j in range(lt):
    if S[i+j] != T[j] and S[i+j] != '?':
      break
  else:
    print((S[:i] + T + S[i+lt:]).replace('?','a'))
    break
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
using namespace std;

int prime(int i){
	int j,k;
		k=0;
		for(j=3;j<=sqrt(i);j+=2)
		{
			if(i%j==0)
			{
				k=1;
				break;
			}
		}
		
		if(k==0){
          return i;
        }
		else return 0;
}

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

	int i,j,k,a=0;

	cin>>i;
    if(i!=2 && i%2==0)i++;
	while(a==0){
		a = prime(i);
		i+=2;
	}

	cout<<a;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
    int n;
    cin>>n;
  	string str;
  	cin>>str;
  	if(str.length()<=n)cout<<str;
  	else {
  		for(int i=0;i<n;i++){
  			cout<<str[i];
		}
		cout<<"...";
	}
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;

int main(void) {
	int n, k;
	cin >> n >> k;
	if (n % k == 0) cout << "0" << endl;
	else cout << "1" << endl;
	
	return 0;
}




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

int main() {
	string  S,T,U;
	int A,B;

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if(S == U){
		A--;
	}else if(T == U){
		B--;
	}

	cout << A << ' ' <<  B;

}

Measured memory_bytes: 256
import sys
from collections import defaultdict
from queue import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def egcd(a: int, b: int):
    """
    A solution of ax+by=gcd(a,b). Returns
    (gcd(a,b), (x, y)).
    """
    if a == 0:
        return b, 0, 1
    else:
        g, x, y = egcd(b % a, a)
        return g, y - (b // a) * x, x


def modinv(a: int, mod: int = 10**9 + 7):
    """
    Returns a^{-1} modulo m.
    """
    g, x, y = egcd(a, mod)
    if g > 1:
        raise Exception('{}^(-1) mod {} does not exist.'.format(a, mod))
    else:
        return x % mod


def main():
    N, S = geta(int)
    A = list(geta(int))
    A.sort()
    mod = 998244353

    inv2 = modinv(2, mod)

    dp = [[0] * (S + 1) for _ in range(N + 1)]
    for s in range(S + 1):
        dp[0][s] = 0

    _t = pow(2, N, mod)
    for n in range(N + 1):
        dp[n][0] = _t

    for i in range(1, N + 1):
        for j in range(1, S + 1):
            if j >= A[i - 1]:
                dp[i][j] = dp[i - 1][j - A[i - 1]] * inv2 + dp[i - 1][j]
            else:
                dp[i][j] = dp[i - 1][j]

            dp[i][j] %= mod

    print(dp[N][S])


if __name__ == "__main__":
    main()

Measured memory_bytes: 135952
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;
//ll dp[2000001];

int main(void) {
    int i, j;
    ll N, A;
    cin >> N >> A;
    ll ans = N;
    REP (i,1,ceil(log(N)/log(2))) {
        ll l = 1, r = sqrt(N)+1;
        while (l + 1 < r) {
            ll m = (l + r) / 2;
            ll pro = 1;
            REP (j,i+1) {
                pro *= m;
                if (pro > N) break;
            }
            if (j == i+1) l = m;
            else r = m;
        }
        ll x = 1;
        REP (j,i+1) x *= l;
        int sum = l*(i+1);
        while (x < N) {
            x = x / l * (l+1);
            sum++;
        }
        ans = min(ans,sum+A*i);
    }
    cout << ans << endl;


    /*
    assert(N <= 1e6);
    REP (i,0,2*N) dp[i] = i;
    REP (i,1,N) for (int j = 2*i; j <= 2*N; j+=i) {
        dp[j] = min(dp[j],dp[i]+A+j/i);
    }
    ll ans = 1e13;
    REP (i,N,2*N) ans = min(ans,dp[i]);
    cout << ans << endl;
    */
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import floor
def main():
    a, b, n = map(int, input().split())
    if n < b:
        x = n
    else:
        x = b - 1
    r = floor(a * x / b) - a * floor(x / b)
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
from itertools import product
N = int(input())
S = input()
r = [0, 1]
ans = 0
d = [{} for i in range(N+1)]
for p in product(r, repeat=N):
    s = []
    for i in range(N):
        if p[i]:
            s.append(S[i])
    for i in range(N-1, -1, -1):
        if p[i] == 0:
            s.append(S[i])
    l = sum(p)
    s = "".join(s)
    d[l][s] = d[l].get(s, 0) + 1
for p in product(r, repeat=N):
    s = []
    for i in range(N-1, -1, -1):
        if p[i]:
            s.append(S[i+N])
    for i in range(N):
        if p[i] == 0:
            s.append(S[i+N])
    l = sum(p)
    s = "".join(s)
    ans += d[l].get(s, 0)
print(ans)


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

#define ll long long

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll buf = C*D/GCD(min(C,D), max(C,D));
    cout << B-A+1-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/buf-(A-1)/buf) << endl;
    return 0;
}

Measured memory_bytes: 3636
s=input()
ans=0
for i in range(len(s)):
  for j in range(len(s)):
    s2=s[i:len(s)-j]
    if len(s2)==s2.count("A")+s2.count("T")+s2.count("C")+s2.count("G"):
      if len(s2)>ans:
        ans=len(s2)
print(ans)

Measured memory_bytes: 9028
def count_ac_wa(n, p, s)
	acs = []
	was = []
	(0...n).each do
		acs.push(false)
		was.push(0)
	end
	p.each_with_index do |pi, index|
		if s[index] == "AC"
			acs[pi - 1] = true
		end
		if s[index] == "WA" and !acs[pi - 1]
			was[pi - 1] += 1
		end
	end
	ac_count = acs.count(true)
	wa_count = 0
	(0...n).each do |i|
		if acs[i]
			wa_count += was[i]
		end
	end
	[ac_count, wa_count].join(' ')
end

n, m = gets.chomp.split(' ').map(&:to_i)
p = []
s = []
(0...m).each do
	pi, si = gets.chomp.split(' ')
	p.push(pi.to_i)
	s.push(si)
end
puts count_ac_wa(n, p, s)


Measured memory_bytes: 12040
#include<stdio.h>
#define SIZE 100

int main(void)
{
    int i, j, n, tmp, cnt, a[SIZE];
    
    scanf("%d", &n);
    for ( i=0; i<n; ++i)
        scanf("%d", &a[i]);
    
    cnt = 0;
    for ( i=0; i<n; ++i) {
        for ( j=n-1; j>i; --j) {
            if ( a[j-1] > a[j]) {
                tmp = a[j-1];
                a[j-1] = a[j];
                a[j] = tmp;
                ++cnt;
            }
        }
    }
    
    for ( i=0; i<n; ++i) {
        printf("%d", a[i]);
        if ( i != n-1)
            putchar(' ');
    }
    putchar('\n');
    printf("%d\n", cnt);
    
    return 0;
}


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

using ll = long long;
using P = pair<ll, int>;    // (大きさ, 色)

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

    vector<ll> cum_a(n);
    vector<P> pairs(n);
    vector<bool> valid(n);

    for (int i = 0; i < n; i++) {
        cin >> pairs[i].first;
        pairs[i].second = i;
    }

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

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += pairs[i].first;
        if (i + 1 < n) {
            valid[i] = pairs[i + 1].first <= 2 * sum;
        } else {
            valid[i] = true;
        }
    }

    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (i + 1 < n) {
            valid[i] = valid[i] & valid[i + 1];
        }
        if (valid[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
double fonk(double x, double y){
	return x*x + y*y;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, x, y; cin>>n>>x>>y;
	cout<<(n / (x+y)) * x + min(n % (x+y), x)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc093/tasks/abc093_b

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

    set<int> st;

    for (int i = A; i < A+K && i <= B; i++) {
        st.insert(i);
    }

    for (int i = B; i > B-K && i >= A; i--) {
        st.insert(i);
    }

    for (int t : st) {
        cout << t << "\n";
    }



    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

pat = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total = 500 * a + 100 * b + 50 * c
            if total == X:
                pat += 1

print(pat)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    int n; cin >> n;
    char b[9][5] = {{'.',',','!','?',' '},
                    {'a','b','c'},
                    {'d','e','f'},
                    {'g','h','i'},
                    {'j','k','l'},
                    {'m' ,'n' ,'o'},
                    {'p', 'q' ,'r' ,'s'},
                    {'t' ,'u', 'v'},
                    {'w','x','y','z'}};
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        int m = s.size();
        int cnt = 0;
        for(int j = 0; j < m; j++){
            if(s[j] != '0'){
                cnt++;
            }else{
                int x;
                if(cnt == 0) continue;
                if(s[j-1] == '1'){
                    x = 5;
                }else if(s[j-1] == '7' || s[j-1] == '9'){
                    x = 4;
                }else{
                    x = 3;
                }
                int y = (cnt-1) % x;
                cout << b[s[j-1]-'1'][y];
                cnt = 0;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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 * b / gcd(a, b);
};


int main() {
	int N;
	string S;
	cin >> N >> S;
	char tmp;
	int a;
	rep(i, S.size()) {
		tmp = S[i];
		if ((int)S[i] + N < 91) {
			tmp = tmp + N;
		}
		else {
			tmp = tmp + N - 26;

		}
			cout << tmp;
	}

}


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

typedef long long LL;

const int N=500;
const LL INF=(1LL<<50)-1;

int n,a[N+9][N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	for (int j=1;j<=n;++j)
	  if (i^j) scanf("%d",&a[i][j]);
}

LL sum[N+9][N+9][2];

void Get_sum(){
  for (int i=1;i<=n;++i){
	for (int j=1;j<=n;++j){
	  if (i^j) i<j?sum[i][j][0]=a[i][j]:sum[i][j][1]=a[i][j];
	  for (int k=0;k<2;++k) sum[i][j][k]+=sum[i][j-1][k];
	}
    for (int j=1;j<=n;++j)
	  for (int k=0;k<2;++k) sum[i][j][k]+=sum[i-1][j][k];
  }
}

LL Get_sum(int id,int x0,int y0,int x1,int y1){return sum[x1][y1][id]-sum[x1][y0-1][id]-sum[x0-1][y1][id]+sum[x0-1][y0-1][id];}

LL dp[N+9][N+9],ans;

void Get_dp(){
  for (int i=0;i<=n;++i)
	for (int j=0;j<=n;++j) dp[i][j]=INF;
  dp[0][0]=0;
  for (int i=0;i<=n;++i)
	for (int j=0;j<max(i,1);++j)
	  for (int k=i+1;k<=n;++k){
		LL t=dp[i][j]+Get_sum(1,k+1,j+1,n,i)+Get_sum(0,i+1,i+1,k,k);
		dp[k][i]=min(dp[k][i],t);
	  }
  ans=INF;
  for (int i=1;i<=n;++i) ans=min(ans,dp[n][i]);
}

void work(){
  Get_sum();
  Get_dp();
}

void outo(){
  printf("%lld\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 7296
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt(), w = in.nextInt();
		int[][] a = new int[h][w];
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				a[i][j] = in.nextInt();
			}
		}
		List<Grids> list = new ArrayList<>();
		for(int y = 0; y < h; y++) {
			for(int x = 0; x < w - 1; x++) {
				if(a[y][x] % 2 == 1) {
					list.add(new Grids(y, x, y, x + 1));
					a[y][x]--;
					a[y][x + 1]++;
				}
			}
		}
		for(int y = 0; y < h - 1; y++) {
			if(a[y][w - 1] % 2 == 1) {
				list.add(new Grids(y, w - 1, y + 1, w - 1));
				a[y][w - 1]--;
				a[y + 1][w - 1]++;
			}
		}
		System.out.println(list.size());
		list.forEach(System.out::println);
	}

}

class Grids {
	int fy, fx, ty, tx;
	public Grids(int fy, int fx, int ty, int tx) {
		this.fy = fy + 1; this.fx = fx + 1; this.ty = ty + 1; this.tx = tx + 1;
	}
	public String toString() {
		return fy + " " + fx + " " + ty + " " + tx;
	}
}


Measured memory_bytes: 95836
#include<stdio.h>
#include<string.h>
int main(){
    int n=0;
    float money=0.0f;
    scanf("%d",&n);
    int i=0;
    for(i=0; i<n; i++){
        char s[101];
        float f=0;
        scanf("%f %s",&f,s);
        if(strcmp(s,"JPY")==0){money+=f;}
        else money+=f*380000.0;

        
    }
    printf("%f",money);

    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize 2
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define pb push_back
#define mp make_pair
#define IT set<int> :: iterator 
#define pa pair<int,int>
#define fir first
#define sec second


using namespace std;

inline ll read()
{
	ll t=0,dp=1;char c=getchar();
	while(!isdigit(c))	{if(c=='-')	dp=-1;c=getchar();}
	while(isdigit(c))	t=t*10+c-48,c=getchar();
	return t*dp;
}
inline void write(ll x){if(x<0)	{putchar('-');x=-x;}	if(x>=10)	write(x/10);putchar(x%10+48);}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}
/*------------------------------------------------------------------------------------------------------*/

const int N=100005;
int n,Fa[N];
set<int> to[N];
map<pa,int> cnt;
queue<pa> que;
inline int Get(int x){return x==Fa[x]?Fa[x]:Fa[x]=Get(Fa[x]);}
int main()
{
	n=read();
	For(i,1,n)	Fa[i]=i;
	For(i,1,2*(n-1))
	{
		int x=read(),y=read();
		to[x].insert(y);to[y].insert(x);
		cnt[mp(x,y)]++;cnt[mp(y,x)]++;
		if(cnt[mp(x,y)]==2)	que.push(mp(x,y));
	}	
	while(!que.empty())
	{
		pa tmp=que.front();que.pop();
		int x=tmp.fir,y=tmp.sec;
		int tx=Get(x),ty=Get(y);
		x=tx;y=ty;
		to[x].erase(y);to[y].erase(x);
		if(to[x].size()<to[y].size())	swap(x,y);//x<-y
		IT it;
		for(it=to[y].begin();it!=to[y].end();++it)
		{
			int mid=(*it);
			cnt[mp(mid,y)]=0;cnt[mp(y,mid)]=0;
			to[mid].erase(y);
			cnt[mp(mid,x)]++;cnt[mp(x,mid)]++;
			to[mid].insert(x);to[x].insert(mid);
			if(cnt[mp(mid,x)]==2)	que.push(mp(mid,x));
		}
		Fa[y]=x;
		to[y].clear();
	}
	int sum=0;
	For(i,1,n)	if(Fa[i]==i)	++sum;
	if(sum==1)	puts("YES");else	puts("NO");
}

Measured memory_bytes: 56192
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    def divisor(m):
        arr = [1, m]
        i = 2
        while i*i <= m:
            if m%i == 0:
                arr.append(i)
                if m//i != i:
                    arr.append(m//i)
            i+= 1
        arr.sort()
        return arr   

    n, m = map(int, input().split())
    a = divisor(m)
    for x in a:
        if x >= n:
            print(m//x)
            return
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  cin >> n >> k;

  vec a(3);
  REP(i,3) cin >> a[i];

  string s;
  cin >> s;

  map<char,int> id;
  id['s'] = 0; id['p'] = 1; id['r'] = 2;
  int ans = 0;
  vec b(n);

  REP(i,n){
    int j = id[s[i]];
    if(i<k || b[i-k]!=j){
      b[i] = j;
      ans += a[j];
    }
    else{
      b[i] = -1;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 1232
a = input()
l = list(a)
num = len(l)
TorF = True

if num % 2 == 0:
    b = int(num/2)
    for i in range(b):
        if not (a[2*i] == 'h' and a[2*i + 1] == 'i'):
            TorF = False
            break
else:
    TorF = False

if TorF == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main( void ) {

    int N, A;
    cin >> N;
    cin >> A;

    N %= 500;

    if (N <= A) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;   
}

Measured memory_bytes: 256
N, K = map(int, input().split())
MOD = 998244353

l = [0] * K
r = [0] * K

for i in range(K):
	l[i], r[i] = map(int, input().split())
	
dp = [0] * (N+1)
dp[1] = 1

dpsum = [0] * (N+1)
dpsum[1] = 1

for i in range(2, N+1):
	for j in range(K):
		li = i - r[j]
		ri = i - l[j]
		if li <= 0:
			dp[i] = dp[i] + dpsum[ri]
			dp[i] %= MOD
		else:
			dp[i] = dpsum[ri] - dpsum[li-1] + dp[i]
			dp[i] %= MOD
			
			
	dpsum[i] = dp[i] + dpsum[i-1]
	dpsum[i] %= MOD
	
print(dp[N] % MOD)

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    int n;
    cin >> n;
    vector<llong> A(3 * n);
    priority_queue<llong, vector<llong>, greater<llong> > PQ1;
    priority_queue<llong> PQ2;
    llong sub_sum1 = 0, sub_sum2 = 0;
    rep(i, 3 * n) {
        cin >> A[i];
        if (i < n) PQ1.push(A[i]), sub_sum1 += A[i];
        if (i > 2 * n - 1) PQ2.push(A[i]), sub_sum2 += A[i];
    }

    vector<llong> S1;
    S1.push_back(sub_sum1);
    for (int i = n; i < 2 * n; ++i) {
        PQ1.push(A[i]);
        sub_sum1 = sub_sum1 + A[i] - PQ1.top();
        PQ1.pop();
        S1.push_back(sub_sum1);
    }

    vector<llong> S2;
    S2.push_back(sub_sum2);
    for (int i = 2 * n - 1; i >= n; --i) {
        PQ2.push(A[i]);
        sub_sum2 = sub_sum2 + A[i] - PQ2.top();
        PQ2.pop();
        S2.push_back(sub_sum2);
    }

    llong ans = -INF;
    int k = S1.size();
    rep(i, k) {
        ans = max(ans, S1[i] - S2[k - i - 1]);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    string s, p;
    cin >> s >> p;
    bool ring;
    int a;
    for (int i = 0; i < s.size() + p.size(); i++) {
        ring = false;
        for (int j = i; j < i + p.size(); j++) {
            if (j >= s.size()) {
                a = j - s.size();
            }
            else {
                a = j;
            }
            if (s[a] == p[j - i]) {
                ring = true;
            }
            else {
                ring = false;
                break;
            }
        }
        if (ring == true) {
            cout << "Yes" << endl;
            break;
        }
    }
    if (ring == false) {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3228
# abc95 c
a,b,c,x,y = map(int, input().split())
cost = 0
# 両方のピザをmin(x,y)枚買うー＞足りない方をabs(x-y)枚買う
if a+b >= 2*c:
    cost += 2*c*min(x,y)
else:
    cost += (a+b)*min(x,y)

if x-y == 0:
    print(cost)
else:
    if x-y >0:
        if a > 2*c:
            cost += 2*c*(x-y)
        else:
            cost += a*(x-y)
    else:
        if b > 2*c:
            cost += 2*c*abs(x-y)
        else:
            cost += b*abs(x-y)
        
    print(cost)
    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cctype>
#include<cstdio>
using namespace std;

int main(){
  string a,b,c,d;
  cin>>a>>b>>c;
  char dif='A'-'a';
  printf("%c%c%c\n",a[0]+dif,b[0]+dif,c[0]+dif);
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#複数入力
a,b=(int(x) for x in input().split())
if b==1:
    print(0)
    exit(0)
c=a
ans=1
while True:
    if c>=b:
        break
    c+=(a-1)
    ans+=1
print(ans)

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


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

  int n; cin >> n;
  vpi a(n);

  rep(i, n) {
    int x, l; cin >> x >> l;
    a[i].fi = x - l;
    a[i].se = x + l;
  }

  sort(all(a),[](pii x, pii y) {
    return x.se < y.se;
  });

  int fin = a[0].se, cnt = 0;
  rep2(i, 1, n-1) {
    if (fin > a[i].fi) ++cnt;
    else fin = a[i].se;
  }

  cout << n - cnt << endl;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif

    int x , t;
    sfi2(x,t);
    printf("%d\n",max(0,x-t));

    return 0;
}


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

// function for finding max area
long findArea(long arr[], int n)
{
    // sort array in non-increasing order
    sort(arr, arr + n, greater<long>());

    // Initialize two sides of rectangle
    long dimension[2] = { 0, 0 };

    // traverse through array
    for (int i = 0, j = 0; i < n - 1 && j < 2; i++)

        // if any element occurs twice
        // store that as dimension
        if (arr[i] == arr[i + 1])
            dimension[j++] = arr[i++];

    // return the product of dimensions
    return (dimension[0] * dimension[1]);
}
// driver function
int main()
{
    int numv;
    cin >> numv;
    long arr[numv+1];
    for(int i=0;i<numv;i++){
        cin >> arr[i];
    }

    int n = sizeof(arr) / sizeof(arr[0]);
    cout << findArea(arr, n);
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#define mod 1000000007

using namespace std;
typedef long long ll;
const int maxn = 1e5+10;

ll a[2*maxn];

int main() {
	int n,x;
	ll sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		sum+=x;//总和 
		a[i]=a[i-1]+x;//前i个数之和； 
	}
//	for(int i=1;i<=n;i++){
//		printf("%d ",a[i]); 
//	}
//	cout<<endl;
	ll mn=fabs(a[1]-(sum-a[1]));//第一个数和后n-1个数绝对值之差 
	ll k;
	for(int i=2;i<n;i++){
		k=fabs(a[i]-(sum-a[i]));
		if(k<mn){
			mn=k;
		}
	} 
	printf("%d\n",mn);
	return 0;
}


Measured memory_bytes: 1792