akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAX = 400;
static const int INF = 1<<20;

string S[20];
int d[400][400];
int n, H, W;

void warshall_floyd() {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
    cin >> H >> W;
    rep(i,H){
        cin >> S[i];
    }
    n = H*W;
    rep(i,n)rep(j,n){
        if(i == j) d[i][j] = 0;
        else d[i][j] = INF;
    }

    rep(i,H){
        rep(j,W){
            if(S[i][j] == '.'){
                if(i+1 < H && S[i+1][j] == '.'){
                    d[i*W+j][(i+1)*W+j] = 1;
                    d[(i+1)*W+j][i*W+j] = 1;
                }
                if(j+1 < W && S[i][j+1] == '.'){
                    d[i*W+j][i*W+j+1] = 1;
                    d[i*W+j+1][i*W+j] = 1;
                }
            }
        }
    }
    warshall_floyd();

    int ans = 0;
    rep(i,n)rep(j,n){
        if(d[i][j] != INF)ans = max(ans, d[i][j]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s,t;
    cin>>s>>t;
    map<char,int> S;
    map<char,int> T;
    for(int i=0;i<s.size();i++){
        if((S[s[i]]!=0 && S[s[i]]!=t[i]-'a')||(T[t[i]]!=0 && T[t[i]]!=s[i]-'a')){
            cout<<"No"<<endl;
            return 0;
        }
        S[s[i]]=t[i]-'a';
        T[t[i]]=s[i]-'a';
    }
    cout<<"Yes"<<endl;
}


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

using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 1e5 + 2;

string to_string(string s) {
	return '"' + s + '"';
}
string to_string(const char* s) {
	return to_string((string) s);
}
string to_string(bool b) {
	return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
	bool first = true;  string res = "{";
	for (const auto &x : v) {
		if (!first) { res += ", "; }
		first = false; res += to_string(x);
	}
	res += "}";	  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define TRACE

#ifdef TRACE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

char oth(char x, char y){
     for(char c : {'R', 'G', 'B'} ) {
           if (x != c and y != c) return c;
     }
}

map<char, int> cnt[4002];

void solve() {
      int i = 0, j = 0, k = 0, n = 0, m = 0; 
      cin >> n;
      string s;
      int ans = 0;
      cin >> s;
      cnt[n-1][s[n-1]] = 1;
      for(i = n-2; i >= 0; i--) {
            for(char c : {'R', 'G', 'B'}) {
                  cnt[i][c] = cnt[i + 1][c];
            }
            cnt[i][s[i]]++;
            // debug(i, cnt[i]);
      }

      fr(i, 0, n-1) {
            fr(j, i + 1, n-1) {
                  if(s[j] == s[i]) continue;
                  char other = oth(s[i], s[j]);
                  ans += cnt[j + 1][other];
                  if(j + j - i < n) ans -= (s[2*j - i] == other);
            }
      }
      cout << ans << el;
}

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

      return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

using namespace std;

int main(){
  int a, b;
  char op; cin >> a >> op >> b;
  if (op=='+') cout << a+b << endl;
  else cout << a-b << endl;
  return 0;
}

Measured memory_bytes: 256
def abc141c():
    n, k, q = map(int, input().split())
    cnt = [0] * n
    for _ in range(q):
        cnt[int(input())-1] += 1
    for item in cnt:
        if k - (q-item) > 0:
            print('Yes')
        else:
            print('No')
abc141c()

Measured memory_bytes: 76472
//制限をよく見る。この場合、intでなくlong longを使う。
#include <bits/stdc++.h>
using namespace std;
long long res[3];
 
  
 
int main() {
for (int i = 0; i < 3; i++) cin >> res[i];
 
if (res[0]%2==0 || res[1]%2==0 || res[2]%2==0) cout << 0 << endl;
  else {
    sort (res, res+3);
    cout << res[0]*res[1] << endl;
  }
 
}
  
    

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

using namespace std;

int main() {
    int N;
    cin>>N;
    double v[N];
    REP(i,N){
        cin>>v[i];
    }
    sort(v,v+N);
  
    double bunsi=v[0]+v[1];
    for(int i=2;i<N;i++){
        bunsi+=pow(2,i-1)*v[i];
    }
    double ans;
    ans=bunsi/pow(2,N-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std; 
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin>>s;
    int l=0;
    for(int i=0; i<s.size(); i++){
    	l=l+(s[i]-'0');
	}
	if(l%9==0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3768
#![allow(unused_imports)]
#![allow(unused_variables)]

use proconio::{fastout, input};
use std::cmp::{max, min};

#[fastout]
fn main() {
  input! {
    n: usize,
    h: [i32; n],
  }
  let mut dp = vec![1001001001; n];
  dp[0] = 0;
  for i in 0..n {
    let ni = i + 1;
    if ni >= n {
      continue;
    }
    dp[ni] = min(dp[ni], dp[i] + (h[i] - h[ni]).abs());
    let ni = i + 2;
    if ni >= n {
      continue;
    }
    dp[ni] = min(dp[ni], dp[i] + (h[i] - h[ni]).abs());
  }
  println!("{}", dp[n - 1]);
}


Measured memory_bytes: 3208
#include <iostream>
#include <queue>
using namespace std;
#define N 100
#define INF (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define rep(i, n) for(int i = 0; i < (n); ++i)

int n, M[N][N];
int color[N], d[N];


void bfs(int r)
{
    //initialization
    rep(i, n) color[i] = WHITE;
    rep(i, n) d[i] = INF;

    queue<int> Q;
    Q.push(r);
    color[r] = GRAY;
    d[r] = 0;

    int u;
    while(!Q.empty()){
        u = Q.front(); Q.pop();
        for (int v = 0; v < n; ++v){
            if (M[u][v] != 0 && d[v] == INF){
                d[v] = d[u] + 1;
                Q.push(v);
            }
        }
    }
    for(int i = 0; i < n; ++i){
        cout << i+1 << " " << ((d[i] == INF)? -1 : d[i]) << endl;
    }

}

int main()
{
    int u, k, v;

    scanf("%d", &n);
    for(u = 0; u < n; ++u){
        scanf("%d %d", &u, &k);
        --u;
        for(int j = 0; j < k; ++j){
            scanf("%d", &v);
            --v;
            M[u][v] = 1;
        }
    }

    bfs(0);

    return 0;
}


Measured memory_bytes: 3228
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

signed main()
{
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  REP(i, N)
  {
    cin >> A[i];
  }

  int all = accumulate(ALL(A), 0);
  double tmp = (double)all / (4.0 * M);

  int cnt = 0;
  REP(i, N)
  {
    if (A[i] < tmp)
    {
      // nop
    }
    else
    {
      cnt++;
    }
  }
  bool ans = false;
  if (cnt >= M)
  {
    ans = true;
  }
  cout << (ans == true ? "Yes" : "No") << endl;
}


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

using ll=int64_t;

int main(){
  ll H,W; cin >>H >>W;
  if (!(H%3) or !(W%3)) {
    cout <<0 <<endl;
    return 0;
  }
  ll A,B;
  ll ans=H*W;
  if (!(H%2)) {A=H/2; B=H/2;}
  else {A=H/2+1; B=H-A;}
  rep(i,1,W) {
    ll S1=A*i;
    ll S2=B*i;
    ll S3=(W-i)*H;
    ll SMaxMin=max({S1,S2,S3})-min({S1,S2,S3});
    ans=min(ans,SMaxMin);
  }
  if (!(W%2)) {A=W/2; B=W/2;}
  else {A=W/2+1; B=W-A;}
  rep(i,1,H) {
    ll S1=A*i;
    ll S2=B*i;
    ll S3=(H-i)*W;
    ll SMaxMin=max({S1,S2,S3})-min({S1,S2,S3});
    ans=min(ans,SMaxMin);
  }
  if (H>=3) ans=min(ans,W);
  if (W>=3) ans=min(ans,H);
  cout<<ans<<endl;
}


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

ans = 0
for i in range( A+1 ):
    for j in range( B+1 ):
        for k in range( C+1 ):
            if 500*i + 100*j + 50*k == X:
                ans += 1

print( ans )

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  ll K;
  std::cin >> N >> K;
  std::vector<int> A(N);
  rep(i, N) {
    std::cin >> A[i];
    --A[i];
  }

  std::vector<int> last(N, -1), hist;
  last[0] = 0;
  hist.push_back(0);
  int pos = 0, cnt = 0;
  while(K > 0) {
    int next = A[pos];
    --K;
    pos = next;
    if(last[pos] >= 0) break;

    ++cnt;
    last[pos] = cnt;
    hist.push_back(pos);
  }

  int i0 = last[pos];
  std::cout << hist[i0 + K % (hist.size() - i0)] + 1 << '\n';
}


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

using namespace std;

int main(){
    int64_t a;
    double b;
    int64_t b_int;

    cin >> a >> b;

    b_int = b*100 + 0.1;

    if(a==0||b_int==0){
        cout << 0 << endl;
        return 0;
    }

  	cout << a*b_int/100 << endl;

    return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rp(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep(i, x, n) for (int i = (x); i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

#define TRACE(x...)
#define PRINT(x...)
#define WATCH(x) TRACE(cout << #x << " = " << x << endl )

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const int MAXN = 100010;
ll dp[MAXN][3];
ll mat[MAXN][3]; 

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    rp(i,n) rp(j,3) cin >> mat[i][j];
    
    rp(j,3) dp[0][j] = mat[0][j];    
    rep(i,1,n) {
    	rp(j,3) {
    		dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + mat[i][j];
    	}
    }
    
    ll resp = 0;
    rp(j,3) resp = max(dp[n-1][j], resp);
    cout << resp << '\n';
      
    return 0;
}

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

signed main(){
    //A
    /*
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
    */
   //B
   /*
   ll x;
   cin>>x;
   ll p=100;
   int c=0;
   while(p<x){
       p=ll(p+p*0.01);
       c++;
   }
   cout<<c<<endl;
   */
  //C
  /*
  int n,m,q;cin>>m>>n>>q;
  vector<int> a(q),b(q),c(q),d(q);
    rep(i,0,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
*/ 
  //D
  ll a,b,n;cin>>a>>b>>n;
  cout<<ll(a*(min(n,b-1))/b)<<endl;
/*
vector<int> a(3,7);
a.back()++;
cout<<a.back()<<endl;
*/

}
/*
int n,m,q;//計算量19C9・・・見積もり方はよう分からん
vector<int> a,b,c,d;
int ans;

void dfs(vector<int> A){
    if(A.size()==n+1){
        int now=0;
        rep(i,0,q){
            if(A[b[i]]-A[a[i]]==c[i]) now+=d[i];
        }
        ans=max(ans,now);
        return;
    }
    rep(i,0,A.size()){
        cout<<A[i]<<" ";
    }
    cout<<endl;
    A.push_back(A.back());
    cout<<"appended ";
     rep(i,0,A.size()){
        cout<<A[i]<<" ";
    }
    cout<<endl;
    cout<<A.size()<<endl;
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
    cout<<"end"<<endl;
    cout<<"ended ";
     rep(i,0,A.size()){
        cout<<A[i]<<" ";
    }
    cout<<endl;//ここまで来たら一個前の段階で入ったwhileの次のフェーズへ行く。popしてるわけじゃない
    //このdfsにより長さnで１から始まる数列Aを全列挙して探索できる
    //なぜ１から始まるAで良いのか？考えうる最小値だからじゃないすかね。１からで答えの最大値が確実に求まる理由はよく分からん
}
int main(){
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q);
    rep(i,0,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(vector<int>(1,1));
    cout<<ans<<endl;
    return 0;
}
*/

Measured memory_bytes: 3588
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    d = []
    for _ in range(n):
        a, b = ns()
        d.append((a + b, a, b))

    d.sort(reverse=True)
    turn = 1
    taka = 0
    ao = 0
    for i in range(n):
        if turn:
            taka += d[i][1]
        else:
            ao += d[i][2]
        turn ^= 1
    print(taka - ao)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82264
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

S = sorted(list(raw_input()))
print "Yes" if S[0] == S[1] and S[1] != S[2] and S[2] == S[3] else "No"

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

int main(){
  int n;
  cin>>n;
  int c1=0;
  int c2=0;
  int c3=0;
  int c4=0;
  vector<string>s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(s[i]=="AC"){
      c1++;
    }else if(s[i]=="WA"){
      c2++;
    }else if(s[i]=="TLE"){
      c3++;
    }else{
      c4++;
    }
  }
  cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
  cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
  cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
  cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;
  return 0;
}

Measured memory_bytes: 6372
// 二つの正整数aとbの積が偶数か奇数か判定する
function Main(input){
  	var args = input.split(" ");
  	var a = parseInt(args[0], 10); // 10進数
  	var b = parseInt(args[1], 10);
	if(a*b%2==0){
   		console.log("Even");
	}else{
   		console.log("Odd");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    long money = 1000;
    long stock = 0;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    for(int i=0; i<n; i++){

        if(a[i-1] <= a[i] && i > 0){
            stock = money / a[i-1];
            money %= a[i-1];
 
            money += stock * a[i];
            stock = 0;
        }
        // cout << money << " ";
        // if(a[i] <= a[i+1] && i < n-1){
        //     stock += money / a[i];
        //     money %= a[i];  
        // }
        // cout << money << " " << stock << endl;
        // if(i == n-1){
        //     money += a[i] * stock;
        //     stock = 0;
        // }
    }
    cout << money << endl;
}

Measured memory_bytes: 3604
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    map<long long, long long> last;
    long long s, j = 0; cin >> s;

    last[s] = ++j;

    auto f = [&](long long n) {
        if(n & 1) return 3 * n + 1;
        else return n / 2;
    };

    long long prev = s, cur;
    while(true) {
        cur = f(prev);
        if(last.find(cur) != last.end()){
            return cout << ++j, 0;
        }
        else {
            last[cur] = ++j;
        }
        prev = cur;
    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define MAXN 3005
const long long a = 998244353;
long long w[MAXN];
long long f[MAXN];
using namespace std;
long long n;
long long m;
long long sum = 0;

void dfs()
{
	memset(f, 0, sizeof(f));
	f[0] = 1;
	for (int i = 1;i <= n; i++)
	{
		for (int j = m;j >= w[i];j--)
		{
			f[j] = (f[j] + f[j - w[i]]) % a;
		}
		sum = (sum + f[m]) % a;
		f[0]++;
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		cin >> w[i];
	}
	dfs();
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
int ans,n;
char s[100005];
int main(void){
    cin>>s;
    n=strlen(s);
    for(int i=0;i<n-1;i++)if(s[i]!=s[i+1])ans++;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 384
using System;
using System.Security.Cryptography;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int k = int.Parse(Console.ReadLine());
            string str = Console.ReadLine();
            int redCount = 0;
            int specialWhiteCount = 0;
            foreach (var s in str)
            {
                if (s == 'R')
                {
                    redCount++;
                }
            }
            for (int i = 0; i < redCount; i++)
            {
                if (str[i] == 'W')
                {
                    specialWhiteCount++;
                }
            }
            Console.WriteLine(specialWhiteCount);
        }
    }
}


Measured memory_bytes: 28192
#include<stdio.h>
#include<string.h>
int main()
{
    char s[52][53];
    int a,b;
    int i,j;
    scanf("%d%d",&a,&b);
    memset(s,0,sizeof(s));
    getchar();
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            scanf("%c",&s[i][j]);
        }
        getchar();
    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            if(s[i][j]=='.')
            {
                s[i][j]=48;
            }
        }
    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b+1;++j)
        {
            if(j==b+1)
            {
                continue;
            }
            if(s[i][j]=='#')
            {
                if(s[i][j-1]!='#')
                {
                    s[i][j-1]++;
                }
                if(s[i][j+1]!='#')
                {
                    s[i][j+1]++;
                }
                if(s[i-1][j]!='#')
                {
                    s[i-1][j]++;
                }
                if(s[i-1][j-1]!='#')
                {
                    s[i-1][j-1]++;
                }
                if(s[i-1][j+1]!='#')
                {
                    s[i-1][j+1]++;
                }
                if(s[i+1][j]!='#')
                {
                    s[i+1][j]++;
                }
                if(s[i+1][j+1]!='#')
                {
                    s[i+1][j+1]++;
                }
                if(s[i+1][j-1]!='#')
                {
                    s[i+1][j-1]++;
                }
            }
        }
    }
    for(i=1;i<=a;i++)
    {
        for(j=1;j<=b;j++)
        {
            printf("%c",s[i][j]);
        }
        printf("\n");

    }
}


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

using namespace std;

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

int main() {
  int n,k; cin >> n >> k;
  string ipt; cin >> ipt;
  int tot = 0;
  vector<int> itm;
  /* vector<int> cot; */
  rep(i,n) {
    if (i == 0) tot++;
    else if (ipt[i-1] == ipt[i]) tot++;
    else {
      itm.push_back(tot);
      tot = 1;
    }
  }
  itm.push_back(tot);

  int start;
  int tmp = 0;
  vector<int> wa(itm.size());
  wa[0] = itm[0];
  rep(i,itm.size()-1) wa[i+1] = wa[i] + itm[i+1];
  int ans = 0;

  if (ipt[0] == '0'){

    // start input with 0
    for (ll i = 0; i < wa.size(); i++) {
      if (i < 2 * k) 
        tmp = wa[i];

      else if (i % 2 == 0){
        tmp = wa[i] - wa[i - 2 * k];
      } 
      else 
        tmp = wa[i] - wa[i - 2 * k - 1];
      if (ans < tmp) ans = tmp;
    }
  } else {
    //start input with 1
    for (ll i = 0; i < wa.size(); i++) {
      if (i < 2 * k + 1)
        tmp = wa[i];
      else if (i % 2)
        tmp = wa[i] - wa[i - 2 * k];
      else
        tmp = wa[i] - wa[i - 2 * k - 1];
      if (ans < tmp)
        ans = tmp;
    }
  }
  cout << ans << endl;

  return 0;
 }

Measured memory_bytes: 1272
n = int(input())
nums = list(map(int, input().split()))

values = {}
for i in nums:
  if i in values: values[i] += 1
  else: values[i] = 1

sums={} # 各値ごとの組み合わせ数
subsums={} # 各値ごとの組み合わせ数（ボールがないとき版
allsum = 0
for k,v in values.items():
  sums[k] = v * (v - 1) / 2
  undersum = (v - 2) * (v - 1) / 2 if v > 1 else 0
  subsums[k] = sums[k] - undersum
  allsum += sums[k]

# res={} # 各値のない時版 + 他の合計
# for k,v in sums.items():

for i in nums:
  print(int(allsum - subsums[i]))


Measured memory_bytes: 43516
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
typedef long long ll;
typedef long double ld;

int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

typedef long long ll;
ll MOD = 1e9+7;

ll dp[101][100001];
ll w[100];
ll v[100];

int main()
{
	int n,mw;
	ll ans=0;
	cin>>n>>mw;
	for(int i=0;i<n;i++)
		cin>>w[i]>>v[i];
	fill(dp[0],dp[101],-1);
	dp[0][0]=0;
	for(int i=1;i<n+1;i++)
	{
		for(int j=0;j<100001;j++)
		{
			if(dp[i-1][j]!=-1)
			{
				dp[i][j]=max(dp[i-1][j],dp[i][j]);
				if(j+w[i-1]<100001)
				{
					dp[i][j+w[i-1]]=max(dp[i][j+w[i-1]],v[i-1]+dp[i-1][j]);
				}
			}
		}
	}
	for(int i=0;i<mw+1;i++)
	{
		ans=max(ans,dp[n][i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
using P = pair<int, int>;

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

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

	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
vector<P> G[114514];
int dist[114514];
int idx;
void dfs(int v,int p,int d){
  dist[v]=d;
  if(dist[idx]<dist[v]) idx=v;
  for(P e:G[v]){
    if(e.first==p) continue;
    dfs(e.first,v,d+e.second);
  }
}
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n-1;i++){
    int s,t,w;
    cin>>s>>t>>w;
    G[s].push_back(P(t,w));
    G[t].push_back(P(s,w));
  }
  idx=0;
  memset(dist,0,sizeof(dist));
  dfs(0,-1,0);
  memset(dist,0,sizeof(dist));
  dfs(idx,-1,0);
  cout<<dist[idx]<<endl;
  return 0;
}

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

int main(){
    int N;
    int A[100];
    int MAX=0;
    int MIN=1e9;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    for(int i=0;i<N;i++){
        MAX=max(MAX,A[i]);
        MIN=min(MIN,A[i]);
    }
    cout<<MAX-MIN<<endl;

    return 0;
}

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

std::vector<int> KMP_all(const std::string& S, const std::string& W){
  std::vector<int> T(W.size());
  T[0] = -1;
  int i = 2, j = 0;
  while(i < W.size()){
    if(W[i-1] == W[j]){
      T[i] = j+1;
      i++;
      j++;
    }else if(j > 0){
      j = T[j];
    }else{
      T[i] = 0;
      i++;
    }
  }
  i = 0;
  int m = 0;
  int ns = S.size();
  std::vector<int> ans(ns);
  while(m < ns){
    if(W[i] == S[(m+i)%ns]){
      i++;
      if(i == W.size()){
        i--;
        ans[m] = 1;
        m = m+i-T[i];
        if(i > 0) i = T[i];
      }
    }else{
      m = m+i-T[i];
      if(i > 0) i = T[i];
    }
  }
  return ans;
}

int main(){
  std::string S,T;
  std::cin >> S;
  std::cin >> T;

  int ns = S.size(), nt = T.size();
  std::vector<int> f_arr = KMP_all(S, T);
  std::vector<int> l_arr(ns);
  int ans = 0;
  for(int ni = 0; ni < ns; ni++){
    if(f_arr[((ni-nt)%ns+ns)%ns] == 1) continue;
    int n = ni, i = 0;
    while(true){
      l_arr[n] = 1;
      if(f_arr[n] == 0) break;
      n = (n+T.size())%S.size();
      i++;
    }
    ans = std::max(ans, i);
  }
  for(int i = 0; i < ns; i++){
    if(l_arr[i] == 0){
      std::cout << -1 << std::endl;
      return 0;
    }
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 5256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int a2 = a+k-1;
    int b2 = b-k+1;
    if(a2 < b2){
        for(int i = a; i <= a2; i++){
            cout << i << endl;
        }
        for(int i = b2; i <= b; i++){
            cout << i << endl;
        }
    }else{
        for(int i = a; i <= b; i++){
            cout << i << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
N=int(input())
X=input()
Y=int(X,2)

J=X.count("1")

Q,R=divmod(Y,J+1)
if J>1:
    S,T=divmod(Y,J-1)
else:
    S=T=0
    
A=[0]*N;A[-1]=1
for i in range(2,N+1):
    A[-i]=(A[-(i-1)]*2)%(J+1)

B=[0]*N
if J>1:
    B[-1]=1
    for j in range(2,N+1):
        B[-j]=(B[-(j-1)]*2)%(J-1)

H=[0]*N

for i in range(N):
    if X[i]=="0":
        U=(R+A[i])%(J+1)
    else:
        if J==1:
            continue
        U=(T-B[i])%(J-1)
        
    I=1
    while U>0:
        U=U%bin(U).count("1")
        I+=1
    H[i]=I

print("\n".join(map(str,H)))


Measured memory_bytes: 97308
from sys import stdin
n = int(stdin.readline().rstrip())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
point = 0
for i in range(101):
    for j in range(101):
        flag = True
        kizyun = False
        count = 0
        for a,b,c in li:
            if c != 0:
                count += 1
                if kizyun == False:
                    h = c+abs(a-i)+abs(b-j)
                    ha = a
                    hb = b
                    hc = c
                    kizyun = True
                else:
                    k = c+abs(a-i)+abs(b-j)
                    if h != k:
                        flag = False
        if count == 1:
            print(ha,hb,hc)
            exit()
        if flag == True:
            point += 1
            print(i,j,h)

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

using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else if (a + b > c + d) {
    cout << "Left" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int dp[100005];
int main() {
    int n; cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < 100005; i++) {
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    dp[1] = abs(v[1]-v[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i],dp[i-1]+abs(v[i]-v[i-1]));
        dp[i] = min(dp[i],dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout << dp[n-1] << endl;

}


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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin>>s;
	ll cnto=0,cnte=0;
	rep(i,0,s.size()){
		if(i%2){
			if(s[i]=='1')
				cnte++;
		}
		else{
			if(s[i]=='0')
				cnte++;
		}
	}
	rep(i,0,s.size()){
		if(i%2&&s[i]=='0'){
			cnto++;
		}
		else if(i%2==0&&s[i]=='1'){
			cnto++;
		}
	}
	ll p=min(cnto,cnte);
	cout<<p;
	
	
	return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll A, B, M; cin >> A >> B >> M;
  vector<ll> vecA(A), vecB(B);
  ll minA = (ll)1e9;
  ll minB = (ll)1e9;
  for (ll i = 0; i < A; i++) {
    ll a; cin >> a;
    minA = min(minA, a);
    vecA.at(i) = a;
  }
  for (ll i = 0; i < B; i++) {
    ll b; cin >> b;
    minB = min(minB, b);
    vecB.at(i) = b;
  }
  ll ans = minA + minB;
  for (ll i = 0; i < M; i++) {
    ll x, y, c; cin >> x >> y >> c; x--; y--;
    ll val = vecA.at(x) + vecB.at(y) - c;
    ans = min(ans, val);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll      long long
#define pb      push_back
#define mp      make_pair
#define orz     1000000007
using namespace std;
int n,l,t,x[100005],w[100005];
ll ans;
int main(){
	scanf("%d%d%d",&n,&l,&t);
	for(int i=1;i<=n;++i)scanf("%d%d",x+i,w+i);
	for(int i=1;i<=n;++i){
		if(w[i]==1){
			ans+=(x[i]+t)/l;
			(x[i]+=t)%=l;
		}
		else{
			ans+=(x[i]-t)/l;
			(x[i]-=t)%=l;
			if(x[i]<0)x[i]+=l,--ans;
		}
	}
	ans=(ans%n+n)%n+1;
	sort(x+1,x+n+1);
	for(int i=ans;i<=n;++i)printf("%d\n",x[i]);
	for(int i=1;i<ans;++i)printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> ac(N), sum(N + 1);
    for (int i = 0; i < N - 1; i++) if (S[i] == 'A' && S[i + 1] == 'C') ac[i] = 1;
    for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + ac[i];

    int l, r;
    int cnt;
    for (int i = 0; i < Q; i++) {
        cin >> l >> r;
        r--; l--;
        cout << sum[r] - sum[l] << '\n';
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}


ll f[5000001];

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}

ll C(ll n, ll r, ll MOD)
{

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}
int main()
{

ll n;
cin>>n;
if(n==1)
    cout<<"Hello World"<<endl;
else
{

    ll a,b;
    cin>>a>>b;
    cout<<a+b<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;

using namespace std;

int n, k, fact[2000001], invfact[2000001], powx[1000001][2], ans;
string s;

int add(int a, int b)
{
    return (a+b)%MOD;
}

int mul(int a, int b)
{
    return (ll(a)*ll(b))%MOD;
}

int inv(int a, int b = MOD-2)
{
    if(b==0)
        return 1;
    int k = inv(a,b/2);
    if(b%2==1)
        return mul(mul(k,k),a);
    return mul(k,k);
}

int ncr(int a, int b)
{
    return mul(mul(fact[a],invfact[b]),invfact[a-b]);
}

int main()
{
    cin >> k >> s;
    n = s.length();
    powx[0][0] = powx[k][1] = 1;
    for(int i = 1; i<=k; i++)
        powx[i][0] = mul(powx[i-1][0],25);
    for(int i = k-1; i>=0; i--)
        powx[i][1] = mul(powx[i+1][1],26);
    fact[0] = invfact[0] = 1;
    for(int i = 1; i<=n+k; i++)
        fact[i] = mul(fact[i-1],i);
    for(int i = 1; i<=n+k; i++)
        invfact[i] = inv(fact[i]);
    for(int i = 0; i<=k; i++)
        ans = add(ans,mul(mul(ncr(n+i-1,i),powx[i][0]),powx[i][1]));
    cout << ans << endl;
}


Measured memory_bytes: 27656
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>




typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;




int main(){
    int n;
    cin>>n;
    vector<int> v;
    rep(i,n){
        int a;
        cin>>a;
        v.push_back(a);
    }
    ll ans=0;
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            ans+=v[i]*v[j];
        }
    }
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,now=0,x;
    long t=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        if(x>now){
            t+=x-now;
        }
        now=x;
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

memo = [0] * n
memo[0] = 0
memo[1] = abs(h[1] - h[0])

for i in range(n)[2:]:
    memo[i] += min(memo[i-2]+abs(h[i]-h[i-2]), memo[i-1]+abs(h[i]-h[i-1]))

print(memo[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define MAX (ll)(1e3 + 7)
#define INF (ll)(4e18)
#define MOD (ll)(998244353)

using namespace std;
using ll = long long;
using cd = complex<double>;

int main () {
	int n;
	cin >> n;
	int st[n], en[n];
	for (int i = 0; i < n; i++) {
		cin >> st[i] >> en[i];
	}
	sort (st, st + n);
	sort (en, en + n);
	if (n & 1) {
		cout << en [n - n / 2 - 1] - st[n / 2] + 1 << "\n";
	}
	else {
		cout << (en[n - n / 2] + en[n - n / 2 - 1]) - (st[n / 2] + st[n / 2 - 1]) + 1 << "\n";
	}
}


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

int main() {
    int N;
    LL a, result;
    bool exceed, zeroExist;

    cin >> N;

    result = 1;
    exceed = false;
    zeroExist = false;
    for (int i = 1; i <= N; i++) {
        cin >> a;

        if (a == 0) {
            zeroExist = true;
            break;
        }

        if (a > INF/result) {
            exceed = true;
            continue;
        } else
            result *= a;
    }

    if (zeroExist)
        cout << 0 << endl;
    else if (exceed)
        cout << -1 << endl;
    else
        cout << result << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
  int n, c;
  cin >> n >> c;
  vector<vector<int>> timet(n, vector<int>(3));
  for(int i=0; i<n; ++i){
    cin >> timet[i][0] >> timet[i][1] >> timet[i][2];
  }
  sort(timet.begin(),timet.end());
  
  vector<P> rec(c,make_pair(0,0));
  for(int i=0; i<n; ++i){
    for(int j=0; j<c; ++j){
      int st = rec[j].first;
      bool st3 = false;
      if(st == timet[i][0] && rec[j].second == timet[i][2]) st3 = true;
      if(st == 0 || st < timet[i][0] || st3){
        rec[j] = make_pair(timet[i][1],timet[i][2]);
        break;
      }
    }
  }
  int ans = 0;
  for(int i=0; i<c; ++i){
    if(rec[i].first != 0) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
long long dp[100009][400],W,n, w[1000], v[1000];
long long solve(long long V, int i) {
    if(i==n){
        if(V==0) return V;
        return INT_MAX;
    }
   if(dp[V][i]!=-1)
       return dp[V][i];
   long long ans = solve(V,i+1);
   if(v[i]<= V)
       ans = min(ans,w[i] + solve(V-v[i],i+1));
   return dp[V][i] = ans;
}
long long bestValue(long long  max_profit){
    for(long long i=max_profit;i>=0;--i){
        if(solve(i,0)<=W){
            return  i;
        }
    }
    return 0;
}
int main() {
    memset(dp,-1,sizeof dp);
    scanf("%lld%lld",&n,&W);
    long long max_profit = 0;
    for(int i=0;i<n;++i){
        scanf("%lld",w+i);
        scanf("%lld",v+i);
        max_profit+= *(v+i);
    }
    printf("%lld ",bestValue(max_profit));

}

Measured memory_bytes: 316360
#include <stdio.h>
int main(void)
{
	int n, m;
	int i, j;
	int C[100]={0};
	scanf("%d%d", &n, &m);

	int A[n][m], B[m];

	//A
	for (i=0;i<n;i++)
	{
		for (j=0;j<m;j++)
		{
			scanf("%d", &A[i][j]);
		}
	}

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

	//C
	for (i=0;i<n;i++)
	{
		for (j=0;j<m;j++)
		{
			C[i]=C[i]+A[i][j]*B[j];
		}
		printf("%d\n", C[i]);
	}

	return 0;
}

Measured memory_bytes: 640
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}
impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (n, a, b) = input!(r, isize, isize, isize);
    if n * a > b {
        println!("{}", b);
    } else {
        println!("{}", n * a);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            //#define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                ios_base::sync_with_stdio(false);
                cin.tie(NULL);
                lli t,n,i,j,b,q,m;
                string s;
                cin>>s;
                rep(i,s.length())cout<<"x";

                return 0;
            }



Measured memory_bytes: 256
import math
a,b=map(int,input().split())
n=math.ceil((a*100)/8)
m=int((a*100)/10)
result=[]
for i in range(m-100,n+100):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        result.append(i)
if result==[]:
    print(-1)
    exit()
print(min(result))


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

#define endl '\n'

const int N = 3000005;
const int M = 1000000007;

long long power(long long a, long long b) {
  if(b == 0) return 1;
  long long r = power(a, b/2);
  r = (r * r) % M;
  if(b&1) return (r * a) % M;
  return r;
}

long long f[N], inv[N];

int main() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();
  f[0] = 1;
  for(int i=1; i<N; i++) f[i] = (f[i-1] * i) % M;
  inv[N-1] = power(f[N-1], M-2);
  for(int i=N-2; i>=0; i--) inv[i] = (inv[i+1] * (i+1)) % M;
  auto C = [&] (int x, int y) -> int {
    if(x < y || y < 0) return 0;
    if(x == y || y == 0) return 1;
    long long r = f[x];
    r = (r * inv[y]) % M;
    r = (r * inv[x-y]) % M;
    return  r;
  };
  auto get = [&] (int i) -> int {
    long long r = power(26, i);
    r = (r * power(25, k - i)) % M;
    r = (r * C(k-i+n-1, n-1)) % M;
    return r;
  };
  long long sum = 0;
  for(int i=0; i<=k; i++) {
    sum = (sum + get(i)) % M;
  }
  cout << sum << endl;
  return 0;
}


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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF INT_MAX/2
#define int long long

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int n,p;
    cin>>n>>p;
    Vi a(n);
    REP(i,0,n){
        cin>>a[i];
        if(a[i]%2==1){
          	int ans=pow(2,n-1);
            cout<<ans<<ENT;
            return 0;
        }
    }
    if(p==0) {int ans=pow(2,n);cout<<ans<<ENT;}
    else cout<<0<<ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

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

int euclid(int a, int b){
  if(a < b){
    int tmp = a;a = b;b = tmp;
  }
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(C<=A+B+1) printf("%d",C+B);
  else printf("%d",A+2*B+1);
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin python3
# -*- coding: utf-8 -*-

# Binary Indexed Tree
# 1-indexed
# sum(r)        :閉区間 [0,r] の合計を取得する
# [8] a0 ・ a1  ・ a2 ・ a3 ・ a4 ・ a5 ・ a6 ・ a7
# [4] a0 ・ a1  ・ a2 ・ a3
# [2] a0 ・ a1               [6] a4 ・ a5
# [1] a0       [3] a2        [5] a4        [7] a6

#                   [1000]
#           [0100]
#   [0010]                [0110]
# [0001]    [0011]      [0111]      [1111]

class BinaryIndexedTree:
    # 初期化処理
    def __init__(self, size):
        self.size = size
        self.dat = [0]*(size+1)

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.dat[i] += x
            i += i & -i # 更新すべき位置

    def sum(self, r):
        r += 1
        ret = 0
        while r>0:
            ret += self.dat[r]
            r -= r & -r # 加算すべき位置
        return ret

    def init(self, a):
        for i, x in enumerate(a):
            self.add(i, x)

    def initrng(self, a):
        self.add(0, a[0])
        for i in range(1,n):
            self.add(i, a[i]-a[i-1])

n, q = map(int,input().split())
a = list(map(int, input().split()))
bit = BinaryIndexedTree(n)
bit.init(a)
for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        bit.add(u, v)
    else:
        print(bit.sum(v-1)-bit.sum(u-1))


Measured memory_bytes: 65248
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define modn 1000000007
#define hell 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;


int main()
{
    int a, b;
    cin>>a>>b;
    cout<<(a*b) - (1*a) - (1*b) + (1*1)<<endl;
    return 0;
}








Measured memory_bytes: 256
def main():
    N = int(input())
    X = list(map(int, input().split()))
    ans = float('inf')
    for i in range(1,101):
        tmp = 0
        for x in X:
            tmp += (x - i) ** 2
        ans = min(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 38896