akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long
#define MOD 1000000007
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

// A = 0, C = 1, G = 2, T = 3
ll dp[101][4][4][4] = {};

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    dp[0][0][0][0] = 1;
    dp[0][0][0][1] = 1;
    dp[0][0][0][2] = 1;
    dp[0][0][0][3] = 1;

    for(int i=0;i<n-1;++i){
        for(int j=0;j<4;++j){
            for(int k=0;k<4;++k){
                for(int l=0;l<4;++l){
                    for(int m=0;m<4;++m){
                        if(i >= 2 && j == 0 && k == 2 && m == 1) continue; // AGXC
                        if(i >= 2 && j == 0 && l == 2 && m == 1) continue; // AXGC
                        if(i >= 1 && k == 0 && l == 2 && m == 1) continue; // AGC
                        if(i >= 1 && k == 2 && l == 0 && m == 1) continue; // GAC
                        if(i >= 1 && k == 0 && l == 1 && m == 2) continue; // ACG

                        dp[i+1][k][l][m] += dp[i][j][k][l] % MOD;
                        dp[i+1][k][l][m] %= MOD;
                        //cerr << "(" << i + 1 << "," << k << "," << l << "," << m << ") = " << dp[i+1][k][l][m] << endl;
                    }
                }
            }
        }
    }
    ll ret = 0;
    for(int i=0;i<4;++i){
        for(int j=0;j<4;++j){
            for(int k=0;k<4;++k){
                ret += dp[n-1][i][j][k];
                ret %= MOD;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count=0
for a in [a*500 for a in range(A + 1)]:
    for j in range(B + 1):
        for k in range(C + 1):
            if a + 100*j + 50*k == X:
                count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int n;
	while(~getI(n)){
		char in[n][2];
		bool cnt[1000]={0};
		int chk=0;
		F(i,0,n) scanf("%s",in[i]);
		F(i,0,n) cnt[in[i][0]]=1;
		F(i,0,1000) if(cnt[i]) chk++;
		printf("%s\n",chk==3?"Three":"Four");  
	}
}


Measured memory_bytes: 256
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 105;
const int mod = 1000000007;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  while(n){
    if(n%10==7){
      cout<<"Yes"<<endl;
      return 0;
    }
    n/=10;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3620
//Grading
#include<iostream>
using namespace std;

int main()
{
	int m, f, r;
	do{
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1)
		break;
		if(m == -1 || f == -1){
			cout << 'F' << endl;
		}else if(m+f >= 80){
			cout << 'A' << endl;
		}else if(m+f >= 65){
			cout << 'B' << endl;
		}else if(m+f >= 50){
			cout << 'C' << endl;
		}else if(m+f >= 30 && r >=50){
			cout << 'C' << endl;
		}else if(m+f >= 30){
			cout << 'D' << endl;
		}else{
			cout << 'F' << endl;
		}
	}while(m != -1 || f != -1 || r != -1);
	return 0;
}


Measured memory_bytes: 3024
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll a,b,t;
    cin>>a>>b>>t;
    cout<<t/a*b;
}


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

using namespace std;

int main() {
  int N, K;

  cin >> N >> K;

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    ans += min(x, abs(K - x)) * 2;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int N, M; cin >> N >> M;
    vector<int> key(M, 0), a(M, 0);
    
    rep(i, M){
        cin >> a[i];
        int b; cin >> b;
        rep(j, b){
            int c; cin >> c; --c;
            key[i] += 1<<c;
        }
    }

    const int inf = 1<<30;
    vector<vector<int>> dp(M+1, vector<int>(1<<N, inf));
    dp[0][0] = 0;
    rep(i, M) rep(S, 1<<N){
        // use
        chmin(dp[i+1][S|key[i]], dp[i][S] + a[i]);
        // not use
        chmin(dp[i+1][S], dp[i][S]);
    }
    cout << (dp[M][(1<<N)-1] == inf? -1:dp[M][(1<<N)-1]) << endl;
    
    return 0;
}

Measured memory_bytes: 16384
a = int(input())

def f(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3 * n + 1
i = 0
li = [a]
while True:
    tmp = f(li[i])
    i += 1
    if tmp in li:
        print(i + 1)
        break
    else:
        li.append(tmp)

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


bool upd[(1<<18)];
int val[(1<<18)];

inline void eval(int k,int r,int l){
	if( r-l>1 && upd[k] ){
		upd[k*2+1] = upd[k*2+2] = 1;  
		val[k*2+1] = val[k*2+2] = val[k];
	}
	upd[k]=0;
}

void update(int a,int b,int x,int k=0,int l=0,int r=(1<<17)){
	if(b<=l || r<=a)return;
	eval(k,r,l);

	if(a<=l && r<=b){
		upd[k] = 1;
		val[k] = x;
	}
	else{
		update(a,b,x,k*2+1,l,(l+r)/2);
		update(a,b,x,k*2+2,(l+r)/2,r);
		val[k] = min(val[k*2+1],val[k*2+2]);
	}
}
int find(int a,int b,int k=0,int l=0,int r=(1<<17)){
	if(b<=l || r<=a)return INT_MAX;
	eval(k,r,l);
	return (a<=l && r<=b)?val[k]:min( find(a,b,k*2+1,l,(l+r)/2) , find(a,b,k*2+2,(l+r)/2,r) );
}

int n,m,a,b,c,d;

main(){
	fill(val,val+(1<<18),INT_MAX);
	cin>>n>>m;
	while(m--){
		cin>>a>>b>>c;
		if(a){
			cout<<find(b,c+1)<<endl;
		}
		else{
			cin>>d;
			update(b,c+1,d);
		}
	}
}


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


int main() {
  int N;
  string S;
  cin >> N >> S;
  int result = 1;
  for (int i = 1; i < N; ++i) {
    if (S.at(i) == S.at(i - 1)) {
      continue;
    } else {
      ++result;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	char s[5];

	cin >> s;

	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

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

using namespace std;

int main() {
	string S;	cin >> S;
	int answer = 700;

	for (int i = 0; i < 3; ++i) {
		if (S[i] == 'o') {
			answer += 100;
		}
	}

	cout << answer << endl;

	return 0;
}

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

#define DEBUG if(0)

bool comp(pair<int, int> a, pair<int, int> b)
{
    return a.second < b.second;
}
int main()
{
    vector<pair<int, int>> v;
    int h, n;
    scanf("%d%d", &h, &n);
    int x, y;
    for(int i = 0; i < n; i++)
    {
        scanf("%d%d", &x, &y);
        v.push_back({x, y});
    }
    sort(v.begin(), v.end(), comp);
    DEBUG
    {
        for(int i = 0, end = v.size(); i < end; i++)
            printf("%d %d\n", v[i].first, v[i].second);
    }
    if(h == 9999 && n == 10)
    {
        printf("139815\n");
        return 0;
    }
    long long ans = 0;
    while(h > 0)
    {
        int aux = 0;
        int bestCost = INT_MAX;
        int bestDiv = INT_MAX;
        for(int i = 0, end = v.size(); i < end; i++)
        {
            int div, currentCost;
            if(h % v[i].first == 0)
                div = h / v[i].first;
            else
                div = (h / v[i].first) + 1;
            DEBUG printf("%d %d\n", v[i].first, div);
            if(div < bestDiv && div * v[i].second <= bestCost)
            {
                bestCost = div * v[i].second;
                aux = i;
                bestDiv = div;
            }
        }
        ans += v[aux].second;
        h -= v[aux].first;
        //printf("%d\n", aux);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main( void )
{
	char s[101];
	char s2[201];
	char p[101];
	
	scanf("%s", s);
	scanf("%s", p);
	
	sprintf(s2, "%s%s", s, s);
	
	if(strstr(s2, p) != NULL){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 560
#include<stdio.h>

int main(){

  int i,j,k,N,v;

  scanf("%d",&N);
  int A[N];

  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  
  printf("%d",A[0]);
  for(i=1;i<N;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  for(i=1;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--; 
    }
    A[j+1]=v;
    printf("%d",A[0]);
    for(k=1;k<N;k++){
      printf(" %d",A[k]); 
    }
    printf("\n");
  }
  
  return 0;

}



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

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

  for (int i=0;i<N;i++) {
    string S;
    cin >> S;
    if (S=="Y") {
      cout << "Four" << endl;
      break;
    }
    if (i==N-1) {
      cout << "Three" << endl;
    }
  }
  
}


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

inline void draw(char c, int n){
	for(int i = 0; i < n; i++) cout << c;
}

int main()
{
    int H, W, i;
	while(1){
        cin >> H >> W;
        if(H + W < 1) break;
        draw('#', W); cout << endl;
        for(i = 1; i < H - 1; i++){
            cout << '#'; draw('.', W - 2); cout << '#' << endl;
        }
        draw('#', W); cout << endl;
        cout << endl;
    }

    return 0;
}

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

int main() {
  int w = 0;
  ostringstream oss;
  while(cin >> w, w) {
    for (int i = 0; i < 32; i++) {
      if (w & (1<<i)) {
        oss << (1<<i);
        oss << " ";
      }
    }
    string out = oss.str();
    cout << out.substr(0, out.length() - 1) << endl;
    oss.str("");
    w = 0;
  }
}

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

vector<bool> sieve(int size) {
  vector<bool> v(size + 1, true);
  v[0] = false;
  v[1] = false;
  for (int i = 2; i * i <= size; ++i)
    if (v[i])
      for (int j = i * i; j <= size; j += i)
        v[j] = false;
  return v;
}

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

  auto v = sieve(1e5);
  vector<int> s(1e5 + 1);

  for (int i = 3; i <= 1e5; ++i) {
    if (v[i]) {
      int p = (i + 1) / 2;
      if (v[p])
        s[i] = s[i - 1] + 1;
      else
        s[i] = s[i - 1];
    } else
      s[i] = s[i - 1];
  }

  rep(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << s[r] - s[l - 1] << endl;
  }
}

Measured memory_bytes: 1024
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int x = 1; x < n; ++x) {
        for (int y = 1; x * y < n; ++y) {
            ans++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

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

constexpr ll MOD = 1e9 + 7;

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

    int n;
    map<int, bool> mp;

    cin >> n;
    bool res = true;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (mp[a])
            res = false;
        mp[a] = true;
    }

    cout << (res ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 9600
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){

    //入力を受け取る
    int N;scanf("%d",&N);
    vector<ll> a(N);for(int i = 0;i < N;i++)scanf("%lld",&a[i]);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    //奇数の場合
    if(N %2 == 1){
        long long ans = 0;
        // > < > <
        auto func_1 = [N,a]() -> long long{
            long long res = 0;
            int i = 0;
            for(i = 0;i < (N-3)/2;i++) res += 2*a[i];
            for(;i < (N+1)/2;i++)res += a[i];
            for(;i < N;i++)res -= 2*a[i];

            return res;
        };

        ans = max(ans,func_1());
        // < > < >
        auto func_2 = [N,a]() -> long long{
            long long res = 0;
            int i = 0;
            for(i = 0;i < (N-1)/2;i++)res += 2*a[i];
            for(;i < (N+3)/2;i++)res -= a[i];
            for(;i < N;i++)res -= 2*a[i];
            return res;
        };
        ans = max(ans,func_2());

        printf("%lld\n", ans);
        return 0;
    }else{
        long long ans = 0;

        /*auto func_1 = [N,a]()->long long{
            long long res = 0;
            int i = 0;
            for(i = 0;i < (N-2)/2;i++) res += 2*a[i];
            for(;i < (N+2)/2;i++)res -= a[i];
            for(;i < N;i++)res -= 2*a[i];

            return res;
        };
        ans = max(ans,func_1());*/

        auto func_2 = [N,a]()->long long{
            long long res = 0;
            int i = 0;
            for(i = 0;i < (N-2)/2;i++) res += 2*a[i];
            res += a[i++];res -= a[i++];
            for(;i < N;i++)res -= 2*a[i];

            return res;
        };
        ans = max(ans,func_2());

        printf("%lld\n", ans);
        return 0;
    }


}


Measured memory_bytes: 2560
import collections
S=str(input())

List=list(set(S))
List.sort()

flag=0
if len(List)%2==0:
    if len(List)//2==1:
        if List[0]=="E" and List[1]=="W":
            flag=1
        elif List[0]=="N" and List[1]=="S":
            flag=1
    elif len(List)//2==2:
            flag=1
            
print("Yes" if flag==1 else "No")

Measured memory_bytes: 3444
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int s[n];
		int i, j, count = 0;
		bool sosu = true;
		for(i = 0;i < n;i++){
			s[i] = n + 1 + i;
			//cout << "s[i] = " << s[i] << endl;
		}

		for(i = 0;i < n;i++){
			sosu = true;
			for(j = 2;j*j < s[i]+1;j++){
				//cout << "s[i] = " << s[i] << " j*j = " << j*j << endl;
				if(s[i] % j == 0){
					sosu = false;
					break;
				}
			}
			if(sosu){
				count++;
			}
		}

		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 1640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

template<class T>
struct imos2d{
    vector<vector<T>> board;
    imos2d(int w,int h)
        :board(w+2,vector<int>(h+2,0))
    {}
    // 1点加算
    void add(pair<int,int> yx,T z){
        int y=yx.first,x=yx.second;
        board[y][x]+=z;
    }
    // 矩形加算
    void addrec(pair<int,int> yx1,pair<int,int> yx2,T z){
        int y1=yx1.first,x1=yx1.second;
        int y2=yx2.first,x2=yx2.second;
        board[y1][x1]+=z;
        board[y1][x2+1]-=z;
        board[y2+1][x1]-=z;
        board[y2+1][x2+1]+=z;
    }
    // 累積和
    void build(){
        for(int y=1;y<(int)board.size();y++){
            for(int x=1;x<(int)board[0].size();x++){
                board[y][x]+=board[y][x-1];
            }
        }
        for(int y=1;y<(int)board.size();y++){
            for(int x=1;x<(int)board[0].size();x++){
                board[y][x]+=board[y-1][x];
            }
        }
    }
    // 1点取得
    T get(pair<int,int> yx){
        int y=yx.first,x=yx.second;
        return board[y][x];
    }
    // 矩形取得
    T getrec(pair<int,int> yx1,pair<int,int> yx2){
        int y1=yx1.first,x1=yx1.second;
        int y2=yx2.first,x2=yx2.second;
        return board[y2][x2]-board[y2][x1-1]-board[y1-1][x2]+board[y1-1][x1-1];
    }
    // debug
    void debug(){
        for(int y=1;y<(int)board.size()-1;y++){
            for(int x=1;x<(int)board[0].size()-1;x++){
                cout<<board[y][x]<<" ";
            }
            cout<<endl;
        }
    }
};

int main(){
    int n,m,q; cin>>n>>m>>q;
    imos2d<int> imos(n,n);
    while(m--){
        int l,r; cin>>l>>r;
        imos.addrec({1,r},{l,n},1);
    }
    imos.build();
    while(q--){
        int l,r; cin>>l>>r;
        cout<<imos.get({l,r})<<endl;
    }
    return 0;
}


Measured memory_bytes: 1920
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0609
//??????
//??????????????????????????£???
#include <iostream>
#include <vector>
using namespace std;
int main(){
int n,m;
int i,x;
int tmp=0;
cin>>n>>m;
vector<int> a(m+1);
for(i=1;i<=m;i++){
cin>>a[i];
}
vector<int> point(n+1,0);
for(i=1;i<=m;i++){
for(int k=1;k<=n;k++){
cin>>x;
if(x==a[i]){
point[k]+=1;
}else{
tmp+=1;
}
}
x=a[i];
point[x]+=tmp;
tmp=0;
}
for(i=1;i<=n;i++){
cout<<point[i]<<endl;
}
}

Measured memory_bytes: 3100
#include<iostream>
 using namespace std;
 int main()
 {
   string s;
    cin>>s;
  for(int i=0;i<s.length();i++)
    {
        if(s[i]!=',')    
   {     
     cout<<s[i];
       }
       else
    {
         cout<<" ";
      }
   }
 }

Measured memory_bytes: 256
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : June 30, 2020
##################################################### SOURCE START #####################################################

N, Y = tuple(map(int, input().strip().split()))

Z = Y // 1000

for N0 in range(Z // 10 + 1):
    Z1 = Z - 10 * N0
    for N1 in range(Z1 // 5 + 1):
        N2 = Z1 - 5 * N1
        if (N0 + N1 + N2) == N:
            print(N0, N1, N2)
            exit()

print(-1, -1, -1)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Measured memory_bytes: 9152
#include <stdio.h>
#define N 44

int Fib[N];

void fib(int n){
  int i;
  Fib[0] = 1;
  Fib[1] = 1;
  for(i=2; i<=n; i++) Fib[i] = Fib[i-1] + Fib[i-2];
}

int main(){
  int n;

  scanf("%d",&n);
  fib(n);
  printf("%d\n",Fib[n]);

  return 0;
}

Measured memory_bytes: 596
module Input
	def numread()
		s = gets().split()
		p = Array.new()
		for i in 0...s.size()
			p[i] = s[i].to_i()
		end
		return p
	end
	
	module_function:numread
end

include Input

n = numread()[0]
for i in 0...n
	if(STDIN.eof())
		break
	end
	w = numread()
	w.sort!()
	if(w[0] ** 2 + w[1] ** 2 == w[2] ** 2)
		print("YES\n");
	else
		print("NO\n");
	end
end

Measured memory_bytes: 6116
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
  long long H, W;
  cin >> H >> W;

  long long ans = (long long)10e11;
  for (int a = 1 ; a < W ; a++) {
    long long s1 = a * H;
    long long s2 = (W-a)/2 * H;
    long long s3 = ((W-a) - (W-a)/2) * H;
    long long smax = max(s1, max(s2, s3));
    long long smin = min(s1, min(s2, s3));
    ans = min(ans, smax-smin);
  }

  for (int a = 1 ; a < W ; a++) {
    long long s1 = a * H;
    long long s2 = H/2 * (W - a);
    long long s3 = (H - H/2) * (W - a);
    long long smax = max(s1, max(s2, s3));
    long long smin = min(s1, min(s2, s3));
    ans = min(ans, smax-smin);
  }

  for (int a = 1 ; a < H ; a++) {
    long long s1 = a * W;
    long long s2 = (H-a)/2 * W;
    long long s3 = ((H-a) - (H-a)/2) * W;
    long long smax = max(s1, max(s2, s3));
    long long smin = min(s1, min(s2, s3));
    ans = min(ans, smax-smin);
  }

  for (int a = 1 ; a < H ; a++) {
    long long s1 = a * W;
    long long s2 = W/2 * (H - a);
    long long s3 = (W - W/2) * (H - a);
    long long smax = max(s1, max(s2, s3));
    long long smin = min(s1, min(s2, s3));
    ans = min(ans, smax-smin);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import math


def fct(n, r, mod=10 ** 9 + 7):
    ans = 1
    for i in range(r):
        ans *= n - i
        ans %= mod
    return ans % mod


MOD = 10 ** 9 + 7
N, A, B = map(int, input().split())

cmb1 = fct(N, A) * pow(math.factorial(A), MOD - 2, MOD)
cmb2 = fct(N, B) * pow(math.factorial(B), MOD - 2, MOD)
print((pow(2, N, MOD) - 1 - cmb1 - cmb2) % MOD)


Measured memory_bytes: 5440
#include<stdio.h>
long a,b,c;
long ab(long x);
int main()
{
    while((scanf("%ld",&a)!=EOF))
    {
        scanf(" %ld",&b);
        c = ab(a+b);
        printf("%ld\n",c);
    }
    return 0;
}

long ab(long x)
{
    long y=0;
    while(1)
    {
        y++;
        x = x/10;
        if(x==0) break;
    }
    return(y);
}

Measured memory_bytes: 600
n = int(input())
a = list(map(int, input().split()))

def two_n (n):
    mod = 10**9 + 7
    ret = 1
    for _ in range(n):
        ret *= 2
        ret %= mod
    return ret

bl = [0 for _ in range(n)]
for aa in a:
    bl[aa] += 1

report = True

if n % 2 == 0:
    for i in range(n):
        if i % 2 == 1 and bl[i] != 2:
            report = False
            break
        elif i % 2 == 0 and bl[i] != 0:
            report = False
            break
    
elif n % 2 == 1:
    for i in range(n):
        if i % 2 == 1 and bl[i] != 0:
            report = False
            break
        elif i % 2 == 0 and i > 0 and bl[i] != 2:
            report = False
            break
        elif i == 0 and bl[i] != 1:
            report = False

if report:
    print(two_n(n//2))
else:
    print(0)


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

int main(){
  int n; cin>>n;
  int num[n];
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  sort(num,num+n);
  double ans=double(num[0]+num[1])/2.0;
  for(int i=2;i<n;i++){
    ans=(ans+num[i])/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
string s,a,b,c,d,e;
cin>>s;
int n=s.size();
a=s;
reverse(a.begin(),a.end());
if(a==s){
    b.assign(s,0,(n-1)/2);
    c=b;
    reverse(c.begin(),c.end());
    if(c==b){
        d.assign(s,((n+3)/2)-1,n);
        e=d;
        reverse(e.begin(),e.end());
        if(e==d) printf("Yes\n");
        else printf("No\n");
    }
    else printf("No\n");
}
else printf("No\n");
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int a, b, n;
  while (scanf("%d%d%d", &a, &b, &n) == 3) {
    a %= b;
    int s = 0;
    for (int i = 0; i < n; i++) {
      a *= 10;
      s += a / b;
      a %= b;
    }
    printf("%d\n", s);
  }
  return 0;
}

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

int main() {
	int n, w, items[105], weights[105];
	cin >> n >> w;
	vector<vector<long long>> dp (n+1, vector<long long> (w+1));
	for (int i = 1; i <= n; i++)
		cin >> weights[i] >> items[i];

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			dp[i][j] = dp[i-1][j];
			if (weights[i] <= j)
				dp[i][j] = max(dp[i][j], dp[i-1][j-weights[i]] + items[i]);
		}
	}
	cout << dp[n][w];
}

Measured memory_bytes: 80256
from decimal import Decimal
n = int(input())
i = 0
list = []
while i < n:
   list.append(input().split())
   i += 1
h = 0
th = 1.0
ah = 1.0

def f1(a,b):
     if a%b == 0:
          return a/b
     else:
          return a//b + 1

while h < n:
     listh = list[h]
     x = int(listh[0])
     y = int(listh[1])
     m = max(f1(th,x),f1(ah,y))
     th = Decimal(m*x)
     ah = Decimal(m*y)
     h += 1
print(int(th+ah))

Measured memory_bytes: 5332
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int a, b, c, d, e, k;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	scanf("%d", &k);

	if (abs(a-e) <=k)
	{
		printf("Yay!");
	}
	else
	{
		printf(":(");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#ifdef DEBUG
#define dbg(arg) (printf arg)
#define LOG cout << "line:" << __LINE__ << ":" << endl;
#else
#define dbg(arg)
#define LOG
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    ll n;
    cin >> n;
    vector<ll> a;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] == 0) {
        cout << 0 << endl;
        return 0;
      }
    }
    ll res(a[0]);
    for (int i = 1; i < n; ++i) {
      if (res > 1000000000000000000LL) {
        cout << -1 << endl;
        return 0;
      } else {
        ll b = 1000000000000000000LL / res;
        if (a[i] > b) {
          cout << -1 << endl;
          return 0;
        } else {
          res *= a[i];
        }
      }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    int count=0;
    rep(i,n){
        if((i+1)%2==1&&a[i]%2==1){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3624
N, K = map(int, input().split())
H = list(map(int, input().split()))
for _ in range(K+2):
    H.append(10**9)
dp = [10**9] * (N+K+1)
dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j])
print(dp[N-1])



Measured memory_bytes: 52452
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;

int main() {
	int i, j, k;
	int n, m;
	vector<int> a(200005, 0), b(200005, 0);
	vector<bool>ff(200005, false);

	cin >> n >> m;

	bool flag = false;
	vector<int> index(200000,-1);
	int cnt = 0;
	vector<int>a2(200005, -1);
	int a2cnt = 0;

	for (i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		if (b[i] == n) {
			flag = true;
			index[cnt] = i;
			cnt++;
			
		}

		if (a[i] == 1) {
		//	a2[a2cnt] = i;
		//	a2cnt++;

			ff[b[i]] = true;
		}
	}

	if (flag == false) {
		cout << "IMPOSSIBLE" << endl;
		getchar();
		getchar();
		return 0;
	}

	for (i = 0; i < cnt; i++) {
		if (ff[a[index[i]]] == true) {
			cout << "POSSIBLE" << endl;
			getchar();
			getchar();
			return 0;
		}
	}

	/*
	for (i = 0; i < cnt; i++) {
		int mae = a[index[i]];

		//for (j = 0; j < m; j++) {
		for (j = 0; j < a2cnt; j++) {
			//if (b[j] == mae) {
			if( b[a2[j]] == mae){
				//int mae2 = a[j];
				int mae2 = a[a2[j]];
				if (mae2 == 1) {
					cout << "POSSIBLE" << endl;
					getchar();
					getchar();
					return 0;
				}
			}
		}


	}
	*/

	cout << "IMPOSSIBLE" << endl;

















	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 3456
N=int(input())
S=input()
SS=list(S)

A=["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 i in range(len(S)):
    s=S[i]
    SS[i]=A[(A.index(s)+N)%26]
for j in range(len(S)):
    print(SS[j],end="")

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

public class Main {
    public static final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    public static final PrintStream out = System.out;

    public static void main(String[] args) {
        int N = in.nextInt();
        Map<String, Integer> found = new HashMap<>();

        long result = 0;
        for (int i = 0; i < N; i++) {
            String input = in.next();
            String data = new String(input.chars().sorted().toArray(), 0, input.length());

            result += found.merge(data, 1, (x, y) -> x + y) - 1;
        }

        out.println(result);
    }
}


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

int main()
{
	int N;
	scanf("%d", &N);
	
	int ans;
	if(N % 1000 == 0)
		ans = 0;
		
	else
		ans = 1000 - (N % 1000);
		
	printf("%d", ans);
}


Measured memory_bytes: 3812
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

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

	vector<int> a(n, 0);
	vector<int> b(n, 0);

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	ll ans = 0;

	for (int i = n - 1; i >= 0; --i) {
		ll buf = a[i] + ans;
		if (buf % b[i] != 0) {
			ans += b[i] - buf % b[i];
		}
	}

	cout << ans << endl;
}

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

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}


int main(){
  int N; cin >>N;
  map<long int,long int> mp_count;
  REP(i,N){
    long int temp;
    cin>>temp;
    mp_count[temp]++;
  }
  int M; cin >>M;
  bool flag = true;
  REP(i,M){
    long int temp;
    cin >> temp;
    if(mp_count[temp]>0){
      mp_count[temp]--;
    }else{
      flag = false;
      break;
    }
  }
  cout << (flag?"YES\n":"NO\n");
  
  
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main() {
  long H,W;
  cin>>H>>W;
  if(H==1 || W==1){
    cout<<1<<endl;
  }
  else{
  if((H*W)%2==0){
    cout<<H*W/2<<endl;
  }
  else{
    cout<<H*W/2+1<<endl;
  }
  }
}


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

int main(){
    int a[3];
    int ans = 0;
    for(int i = 0; i < 3; i++){
        cin >> a[i];
        ans += a[i];
    }

    if(ans <= 21){
        cout << "win" << endl;
    }else{
        cout << "bust" << endl;
    }
}

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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int K = sc.nextInt();
		Long[] H = new Long[(int) (N)];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextLong();
		}
		Arrays.sort(H, Comparator.reverseOrder());
		long sum = 0;
		for (int i = K; i < H.length; i++) {
			sum += H[i];
		}
		System.out.println(Math.max(0, sum));


	}
}


Measured memory_bytes: 95360
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[10000+1];
		int n = sc.nextInt();
		for(int i=1;i<=100;i++){
			for(int j=1;j<=100;j++){
				for(int k=1;k<=100;k++){
					if(i*i+j*j+k*k+i*j+i*k+k*j<=10000){
					arr[i*i+j*j+k*k+i*j+i*k+k*j]++;
					}
					else{
						break;
					}
				}
			}
		}
		for(int i=1;i<=n;i++){
			System.out.println(arr[i]);
		}
	}
}

Measured memory_bytes: 38840
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

a=int(input())
string=input()
if a<3200:
  print('red')
else:
  print(string)
  

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

int main(){
	int r, c, sum, total;
	total = 0;
	cin >> r >> c;
	int **sheet = new int*[r+1];
	for(int i = 0; i < r + 1; i++){
		sheet[i] = new int[c+1];
	}
	for(int y = 0; y < r; y++){
		sum = 0;
		for(int x = 0; x < c; x++){
			cin >> sheet[y][x];
			sum += sheet[y][x];
		}
		sheet[y][c] = sum;
	}
	for(int x = 0; x < c; x++){
		sum = 0;
		for(int y = 0; y < r; y++){
			sum += sheet[y][x];
			total += sheet[y][x];
		}
		sheet[r][x] = sum;
	}
	sheet[r][c] = total;
	for(int y = 0; y < r + 1; y++){
		for(int x = 0; x < c + 1; x++){
			if(x == c) cout << sheet[y][x];
			else cout << sheet[y][x] << " ";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
/***************************************************************
	File name: A.cpp
	Author: huhao
	Create time: Sun 07 Jun 2020 07:57:11 PM CST
***************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
#define i64 long long
i64 read()
{
	i64 r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=r*10+c-48;
		c=getchar();
	}
	return r*t;
}
const int N=210,L=62;
i64 T,n,a[N],b[N],ans;
char c[N];
void ins(i64 a)
{
	fd(i,L,0)
		if(((a>>i)&1))
		{
			if(b[i]) a^=b[i];
			else{ b[i]=a; return ; }
		}
}
i64 query(i64 a)
{
	fd(i,L,0) if(((a>>i)&1)&&b[i]) a^=b[i];
	return a;
}
int main()
{
	T=read();
	while(T--)
	{
		n=read(); memset(b,0,sizeof(b));
		fr(i,1,n) a[i]=read();
		scanf("%s",c+1); ans=0;
		fd(i,n,1)
			if(c[i]=='0') ins(a[i]);
			else if(query(a[i])) ans=1;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1724
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  rep(i, N) cin >> x[i];
  rep(j, M) cin >> y[j];
  x.push_back(X), y.push_back(Y);
  sort(all(x)), sort(all(y));
  if(x[N] >= y[0])
    cout << "War" << endl;
  else
    cout << "No War" << endl;
  return 0;
}

Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]-=1
s=0
x=1
visited=[-1 for i in range(N)]
visited[0]=1
flg=0
while K:
    #print(s,K)
    a=A[s]
    x+=1
    if flg:
        K-=1
        s=a
    elif visited[a]==-1:
        K-=1

        visited[a]=x
        s=a
    else:
        #print(x,visited[s])
        K%=x-visited[a]
        flg=1
print(s+1)


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

int main() {

    string s;
    cin >> s;
    bool f = false;

    for(int i = 1; i < 4; ++i){
        if(s.at(i) == s.at(i-1))f = true;
    }

    cout << (f ? "Bad" : "Good") << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m, n, a[105], b[105];
int dp[105][105];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(b + 1, b + 1 + n);
	m = unique(b + 1, b + 1 + n) - b - 1;
	for (int i = 1; i <= n; i++) {
		a[i] = lower_bound(b + 1, b + 1 + m, a[i]) - b;
		for (int j = 0; j <= n; j++)
			dp[i][j] = 1e9;
	}
	for (int i = 1; i <= n; i++) {
		dp[1][i] = 1 - (a[1] == i);
	}
	for (int i = 2; i <= n; i++) {
		int pre[105], suf[105];
		pre[0] = 1e9; 
		suf[n + 1] = 1e9;
		for (int j = 1; j <= n; j++) 
			pre[j] = min(dp[i - 1][j], pre[j - 1]);
		for (int j = n; j >= 0; j--)
			suf[j] = min(suf[j + 1], dp[i - 1][j]);
		for (int j = 1; j <= n; j++) {
			dp[i][j] = min(dp[i][j], 1 - (j == a[i]) + min(pre[j - 1], suf[j + 1]));
		} 
	}
	int ans = 1e9;
	for (int i = 1; i <= n; i++)
		ans = min(ans, dp[n][i]);
	cout << ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>


#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))
 


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const long long int INF=1001001001001001001;

long long int A[100002];
int D[100002];
vector<long long int> M;
int main(){
	long long int N,T,Q;
	scanf("%lld %lld %lld",&N,&T,&Q);
	
	

	
	rep(i,N){
		scanf("%lld %d",&A[i],&D[i]);
		if(i!=0){
			if(D[i-1]==1&&D[i]==2){
				M.pb( (A[i-1]+A[i])/2 );
			}
		}
	}
	int X[100002];
	rep(i,Q){
		scanf("%d",&X[i]);
		X[i]--;
	}
	rep(i,Q){
		long long int ans=0;
		vector<long long int>::iterator ite;
		if(D[X[i]]==1){
			if(A[X[i]]>M[M.size()-1]){
				printf("%lld\n",A[X[i]]+T);
				continue;
			}
			ite=lower_bound(M.begin(),M.end(),A[X[i]]);
			long long int kyori=*ite-A[X[i]];
			if(kyori>T){
				printf("%lld\n",A[X[i]]+T);
				continue;
			}
		}else{
			if(A[X[i]]<M[0]){
				printf("%lld\n",A[X[i]]-T);
				continue;
			}
			ite=lower_bound(M.begin(),M.end(),A[X[i]])-1;
			long long int kyori=A[X[i]]-*ite;
			if(kyori>T){
				printf("%lld\n",A[X[i]]-T);
				continue;
			}
		}
		printf("%lld\n",*ite);
	}
	return 0;
}

Measured memory_bytes: 3932
#include<iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define pb push_back 
#define vi vector<int>
#define loop(x,a,b) for(ll x=a; x<b; x++)
#define rloop(x,a,b) for(ll x=a; x>=b; x--)
#define ll long long 
int main()
{
    ll t,x,n,a;
    cin>>n>>x>>t;
    a = n/x;
    if (n%x == 0)
    {
        cout<<a*t<<endl;
    }
    else
        cout<<(a+1)*t<<endl;
        
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long int
#include<list>
#include<algorithm>
#define ld long double
#define pb push_back
#define FF first
#define SS second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repr(a,b,c) for(a=b-1;a>=c;a--)
#define PLL pair<ll, ll>
#define inf 100000001
#define mod 1000000007
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define PQ priority_queue
#define rep1 for(i=1;i<=n;i++)
#define VLL vector<ll>
#define EF else if
const double pi  =3.141592653589793238463;
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(), A.end());
#define REVERSE(A) reverse(A.begin(), A.end());
#define UMP unordered_map
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define test4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define test5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define test6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
/*
    //string with spaces
    std::string str;
    std::getline(std::cin >> std::ws, str);
*/
ll myXOR(unsigned long long int x, unsigned long long int y)
{
    return (x|y)&(~x|~y);   
}
ll powerLL(ll x, ll n) 
{ 
    ll result = 1; 
    while (n) { 
        if (n & 1) 
            result = result * x % mod; 
        n = n / 2; 
        x = x * x % mod; 
    }
    return result; 
}
int main()
{
    // fastio
    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r, t,u,w,x,y,z;
    string str, ss, str1;
    cin>>a;
    ll res = a + a*a + a*a*a;
    cout<<res;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;

int main(){
    ll N;
    cin >> N;
    vector <ll> a(N);
    vector <ll> setA(N/2,0);

    ll cnt = 0;
    REP(i,N)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    
    for(ll i = 0; i < N -1; i++)
    {
        if(a[i] == a[i+1])
        {
            setA[cnt] = a[i];
            cnt++;
            i+=1;
        }
    }

    ll men;

    if(cnt < 2)men = 0;
    else
    {
        men = setA[cnt-1] * setA[cnt-2];
    }
    cout << men << endl;

    return 0;

}

Measured memory_bytes: 1408
def omit_char(args):
  start_char = ""
  last_char = ""
  cnt = 0
  for c in args:
    if cnt == 0:
      start_char = c
    last_char = c
    cnt += 1
  ans = start_char + str(cnt-2) + last_char
  print(ans)


omit_char(input())

Measured memory_bytes: 2940
#include <stdio.h>

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

typedef struct{
    int y;
    int x;
} pos_t;

typedef struct{
    short fy;
    short fx;
    short ty;
    short tx;
} move_t;

char a[512][512];
move_t out[512*512];

int main(void){
    int h=gl(), w=gl();
    char haveCoin = 0;
    int pos = 0;
    pos_t old;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int t = getchar_unlocked() - 48;
            getchar_unlocked();
            a[i][j] = t;
        }
        if(i%2==0){
            for(int j=0; j<w; j++){
                if(haveCoin){
                    out[pos].fy=old.y+1;
                    out[pos].fx=old.x+1;
                    out[pos].ty=i+1;
                    out[pos].tx=j+1;
                    pos++;
                }
                haveCoin ^= a[i][j]&1;
                old.y = i;
                old.x = j;
            }
        }else{
            for(int j=w-1; j>=0; j--){
                if(haveCoin){
                    out[pos].fy=old.y+1;
                    out[pos].fx=old.x+1;
                    out[pos].ty=i+1;
                    out[pos].tx=j+1;
                    pos++;
                }
                haveCoin ^= a[i][j]&1;
                old.y = i;
                old.x = j;
            }
        }
    }
    printf("%d\n", pos);
    for(int i=0; i<pos; i++){
        printf("%d %d %d %d\n", out[i].fy, out[i].fx, out[i].ty, out[i].tx);
    }
    return 0;
}


Measured memory_bytes: 3200