akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;
const int MOD = 1000000007;
typedef pair<int,int> P;
struct edge{
    int to;
    int yen;
    int snuuk;
};
signed main(void){
    cin.tie(0);
ios::sync_with_stdio(false);
    int n,m,s,t; cin>>n>>m>>s>>t; s--; t--;
    vector <vector<edge>> g(100010,vector <edge>());
    rep(i,m){
        int a,b,c,d; cin>>a>>b>>c>>d; a--; b--; edge e = {b,c,d};
        g[a].push_back(e);
        edge ee = {a,c,d};
        g[b].push_back(ee);
    }
    ////sから円のダイクストラ
    vector <int> dy(100010,INF); 
    dy[s]=0;
    priority_queue <P, vector <P>, greater<P>> q;
    q.push({0, s});
    while(!q.empty()){
        //cout<<"*"<<endl;
        P tmp = q.top(); q.pop();
        int cost = tmp.first, now = tmp.second;
        //cout<<cost<<' '<<now<<endl;
        if(dy[now] < tmp.first) continue;
        else dy[now] = tmp.first;
        
        for(int i = 0;i<g[now].size(); i++){
            //cout<<"*"<<endl;
            if(dy[g[now][i].to] > cost + g[now][i].yen) {dy[g[now][i].to]= cost + g[now][i].yen; 
            q.push({cost + g[now][i].yen, g[now][i].to}); }
        }
    }

    ///tからスヌークの
    vector <int> ts(100010, INF); 
    ts[t] = 0;
    priority_queue <P, vector <P>, greater<P>> q4;
    q4.push({0, t});
    while(!q4.empty()){
        P tmp = q4.top(); q4.pop();
        int cost = tmp.first, now = tmp.second;
        if(ts[now]< tmp.first) continue;
        
        for(int i = 0;i<g[now].size(); i++){
            if(ts[g[now][i].to] > cost + g[now][i].snuuk) {ts[g[now][i].to]= cost + g[now][i].snuuk;
            q4.push({cost + g[now][i].snuuk, g[now][i].to});}
        }
    }
    int ans[n];
    int mi = INF;
    rrep(i,n){
        //cout<<dy[i]<<"円"<<ts[i]<<"スヌーク"<<endl;
        chmin(mi, dy[i] + ts[i]);
        if(t>i) chmin(mi, dy[t]);
        if(s>i) chmin(mi, ts[s]); 
        ans[i] = mi;
    }
    rep(i,n) printf("%lld\n" ,1000000000000000 - ans[i]);
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < K; ++i) {
    ans += p[i];
  }
  cout << ans << endl;
}


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

int n, m, s, t;
int dist[2][100000];
vector<int> e[100000];
long long num[2][100001];

int main(){
	cin >> n >> m >> s >> t;
	rep(u,2) rep(i,100000) dist[u][i] = INF;
	s--; t--;
	rep(i,m){
		int x, y;
		cin >> x >> y;
		x--; y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	queue<P> que;
	dist[0][s] = 0;
	num[0][0]++;
	que.push(P(0,s));
	while(true){
		if(que.size() == 0) break;
		P q = que.front();
		que.pop();
		rep(i,e[q.second].size()){
			if(dist[0][e[q.second][i]] != INF) continue;
			dist[0][e[q.second][i]] = q.first+1;
			num[0][q.first+1]++;
			que.push(P(q.first+1,e[q.second][i]));
		}
	}
	dist[1][t] = 0;
	num[1][0]++;
	que.push(P(0,t));
	while(true){
		if(que.size() == 0) break;
		P q = que.front();
		que.pop();
		rep(i,e[q.second].size()){
			if(dist[1][e[q.second][i]] != INF) continue;
			dist[1][e[q.second][i]] = q.first+1;
			num[1][q.first+1]++;
			que.push(P(q.first+1,e[q.second][i]));
		}
	}
	long long ans = 0;
	int D = dist[0][t];
	for(int i = 0; i <= D-2; i++){
		ans += num[0][i]*num[1][D-2-i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 8624
n = int(input())
ans = ""
alp = "abcdefghijklmnopqrstuvwxyz"
# while n>0:
#     temp = 0
#     for i in range(12):
#         temp += 26**(i+1)
#         print(temp)
#         if n <= temp:
#             print(i,(n//(26**(i)))-1,n,temp,ans)
#             ans += alp[(n//(26**(i)))-1]
#             n-=n//(26**(i+1))*26
#             print(n)
#             break

while n>0:   
    n-=1 
    ans += alp[n%26]
    # print(n,alp[n%26])
    n//=26
print(ans[::-1])



Measured memory_bytes: 9160
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();

		int[] a = new int[h+1];
		
		for(int i = 1; i <= h; i++)
			a[i] = scan.nextInt();

		for(int i = 1; i<= h; i++)
			print(a, i);

		scan.close();
		System.exit(0);
	}

	private static void print(int[] a, int i){
		System.out.print("node " + i + ": ");
		System.out.print("key = " + a[i] + ", ");
		if(i > 1)
			System.out.print("parent key = " + a[i/2] + ", ");
		if(i * 2 < a.length)
			System.out.print("left key = " + a[i*2] + ", ");
		if(i * 2 + 1 < a.length)
			System.out.print("right key = " + a[i*2+1] + ", ");
		System.out.print("\n");
	}
}

Measured memory_bytes: 27308
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
bool kaibun(string s) {
    string a = s;
    reverse(s.begin(), s.end());
    string b = s;
    if(a == b)
        return true;
    else
        return false;
}
signed main() {
    string s;
    cin >> s;
    if(kaibun(s) == true && 
    kaibun(s.substr(0, (s.size() - 1) / 2)) == true && 
    kaibun(s.substr((s.size() + 2) / 2)) == true
    )
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll t[105];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	ll ans = 1LL;
	for (int i = 0; i < n; i++) {
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, z, w;
    cin >> n >> z >> w;
    vi a(n);
    rep(i, n) cin >> a[i];
    if (n == 1) {
        cout << abs(a[n-1] - w) << endl;
        return 0;
    }
    cout << max(abs(a[n-2] - a[n-1]), abs(a[n-1] - w));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int flag = 0;
  string s;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s;
    if (s == "Y")  {
      flag = 1;
      break;
    }
  }
  if (flag == 1) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
double pai = 3.141592653589793;

struct point{
	double x, y; 
};

void slove(int n, point a, point b){
	if(n == 0) return;
	point s, t, u;
	double th = pai * 60.0 / 180.0;//60??????1/3???????????

	//???????????????????????¬?????????
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	//??£????§???¢????????? ????´???°?????¢????????§?????????????????¢??????
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	slove(n - 1, a, s);
	printf("%.9f %.9f\n", s.x, s.y);
	slove(n - 1, s, u);
	printf("%.9f %.9f\n", u.x, u.y);
	slove(n - 1, u, t);
	printf("%.9f %.9f\n", t.x, t.y);
	slove(n - 1, t, b);
}


int main (void){
	point a, b;
	int n;
	cin >> n;

	a.x = 0.0;
	a.y = 0.0;
	b.x = 100.0;
	b.y = 0.0;

	printf("%.9f %.9f\n", a.x, a.y);//?§??????????
	slove(n, a, b);//?????????????????¨?????????????????°??????????£???°???
	printf("%.9f %.9f\n", b.x, b.y);//????????????

	return 0;
}

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

int store[107];

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

    for (int i = 0; i < N; i++) scanf("%d", &store[i]);

    int sum = store[0];
    for (int i = 1; i < N; i++) {
        sum += min(store[i], store[i-1]);
    }
    sum += store[N-1];

    cout << sum << endl;
}


Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
ans=True

if sum(A)*2%(N*(N+1))!=0:
        ans=False
k=sum(A)*2/(N*(N+1))


d=[A[i+1]-A[i]-k for i in range(N-1)]
d.append(A[0]-A[N-1]-k)
for i in range(N):
        if d[i]>0 or d[i]%N!=0:
                ans=False
if ans:
        print("YES")
else:
        print("NO")

Measured memory_bytes: 14476
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 200007
using namespace std;
int main() {
  fastio;
  ll n = 0;
  cin >> n;
  if (n >= 30)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 3644
#include<iostream>
#include<cmath>

using namespace std;

int main(void){
	string tenki[3] = {"Sunny","Cloudy","Rainy"};
  string today;
  cin >>today;
  for (int i = 0; i<3;i++){
    if (today == tenki[i])
      cout<<tenki[(i+1)%3]<<endl;
  }
}


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

#define int long long
#define INF 1e18

signed main() {
    int  n, x; cin >> n >> x;
    int sum = 0;
    int minimum = INF;

    for(int i = 0; i < n; i++) {
        int m; cin >> m;
        sum += m;
        minimum = min(minimum, m);
    }

    int ans = n + (x - sum) / minimum;

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>

using namespace std;

int main(){

    int x[5];
    for(auto& i : x){
        cin >> i;
    }

    int k;
    cin >> k;

    bool flag = true;
    for(int i = 0; i < 5; i++){
        for(int j = 0; j < 5; j++){
            if(abs(x[i] - x[j]) > k ){
                flag = false;
                break;
            }
        }
    }

    if(flag){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    int one = N % 10;
    switch(one){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon" << endl;
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        cout << "pon" << endl;
        break;
        case 3:
        cout << "bon" << endl;
    }

    return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
int main(void){
int k;
scanf("%d",&k);
int a,b;
scanf("%d %d",&a,&b);
int i,min,max;
max = a>b?a:b; min = a>b ? b:a; 
for(i = min; i<= max; i++){
if(i%k == 0){
printf("OK");
return 0;
}
}
printf("NG");
return 0;
}

Measured memory_bytes: 1684
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int N,M;
    cin >> N;
    vector<string> s(N);
    map<string,int> m;
    int ans=0;
    rep(i,N){
        cin >> s[i];
    }
    cin >> M;
    vector<string> t(M);
    rep(i,M){
        cin >> t[i];
    }

    rep(i,N){
        int a=0;
        rep(j,N) {
            if (s[i] == s[j])
                a++;
        }
        rep(j,M){
            if(s[i] == t[j]){
                a--;
            }
        }
        ans = max(ans,a);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
// Author : Rifayat Samee (Sanzee)
// Problem :
// Algorithm:

/*

*/
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int memo[21][1<<21];
int dp(int i,int mask,const int &n,const vector<vector<int>>&A){
    if(i == n){
        return 1;
    }
    if(memo[i][mask]!= -1){
        return memo[i][mask];
    }
    int res = 0;
    for(int j=0;j<n;j++){
        if((mask & (1<<j)) == 0 && A[i][j]){
            res = (res + dp(i+1,mask|(1<<j),n,A))%mod;
        }
    }
    memo[i][mask] = res;
    return res;
}
int main(){

	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
    int n;
    scanf("%d",&n);
    vector<vector<int>>A(n+1,vector<int>(n+1,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf("%d",&A[i][j]);
        }
    }
    memset(memo,-1,sizeof(memo));
    printf("%d\n",dp(0,0,n,A));

	return 0;
}


Measured memory_bytes: 172416
#include<bits/stdc++.h>
#define pb push_back
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<double,double> PAIR;
const int N = 5e5+5;
const int INF = 0x3f3f3f3f;

int main()
{
	std::ios::sync_with_stdio(0);cin.tie(0);
	
	string s;
	cin >> s;
	int len = s.size();
	if(len == 6 && s[2] == s[3] && s[4] == s[5]) printf("Yes\n");
	else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    weathers = [
        'Sunny',
        'Cloudy',
        'Rainy'
    ]

    s = str(input())

    index = 0
    next_index = 0

    for w in weathers:
        if w == s:
            next_index = (index + 1) % 3
            break
        else:
            index += 1

    print(weathers[next_index])


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

int maxfig(ll A,ll B){
    int cntA = 0,cntB = 0;

    while(A > 0){
        A /= 10;
        cntA++;
    }

    while(B > 0){
        B /= 10;
        cntB++;
    }

    if(cntA > cntB)
        return cntA;

    else
        return cntB;
}

int main(void)
{
    ll N;
    int ans = 20;
    cin >> N;

   for(ll i = 1;i*i <= N;i++){
       if(N%i == 0){
           ans = min(ans,maxfig(i,N/i));
       }
   }

   cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
import 'dart:io';

void main(){
	int n, k;
	List<int> arr = stdin.readLineSync().split(" ").map((ele) => int.parse(ele)).toList();
	List<bool> bol = new List(10);
	n = arr[0];
	k = arr[1];
	arr = stdin.readLineSync().split(" ").map((ele) => int.parse(ele)).toList();
	arr.forEach((ele) => bol[ele] = true);
	for(int i = n; true; i++){
		int temp = i;
		bool test = false;
		while(temp > 0){
			test |= bol[temp%10]??false;
			temp = temp ~/ 10;
		}
		if(!test){
			print(i);
			return;
		}
	}
}

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

char s[200001];
int fr[26];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	ll an = ((ll)n * (n - 1) >> 1) + 1;
	f(i, 0, n){
		an -= fr[s[i] - 'a'];
		++fr[s[i] - 'a'];
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

double memo[104][104];
bool viewed[104][104];

int N, T, L, B;
bool is_back[104];
bool is_lose[104];

double dfs(int pos, int t){
    if(pos == N) return 1;
    if(is_back[pos]) return dfs(0, t);
    if(is_lose[pos]) t++;
    if(t >= T) return 0;
    if(viewed[pos][t]) return memo[pos][t];
    double ret = 0;
    for(int d=1;d<=6;d++){
        int ext = max(0, pos + d - N);
        ret += dfs(pos + d - 2 * ext, t + 1);
    }
    ret /= 6;
    memo[pos][t] = ret;
    viewed[pos][t] = true;
    return ret;
}

int main(){
    while(true){
        cin >> N >> T >> L >> B;
        if(N == 0) break;

        memset(viewed, 0, sizeof(viewed));
        memset(is_back, 0, sizeof(is_back));
        memset(is_lose, 0, sizeof(is_lose));
        for(int i=0;i<L;i++){
            int lose;
            cin >> lose;
            is_lose[lose] = true;
        }
        for(int i=0;i<B;i++){
            int back;
            cin >> back;
            is_back[back] = true;
        }

        printf("%.8f\n", dfs(0, 0));        
    }
    return 0;
}


Measured memory_bytes: 3212
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // String S = sc.next();
        // long u = sc.nextLong();

        int N = sc.nextInt();

        int[] V = new int[N];
        int[] C = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
        }

        int benefit = 0;
        for (int i = 0; i < N; i++) {
            if (V[i] > C[i]) {
                benefit += V[i] - C[i];
            }
        }

        System.out.println(benefit);
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define MAX 330
#define MOD 1000000007
inline int read()
{
    int x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int n,m,f[MAX][MAX][MAX],ans;
struct Node{int l,x;};
vector<Node> e[MAX];
bool check(int a,int b,int c)
{
    int r=max(a,max(b,c));
    for(int i=0,t=e[r].size();i<t;++i)
    {
        int l=e[r][i].l,x=e[r][i].x,s=0;
        s=(a>=l)+(b>=l)+(c>=l);
        if(s!=x)return false;
    }
    return true;
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=m;++i)
    {
        int l=read(),r=read(),x=read();
        e[r].push_back((Node){l,x});
    }
    f[0][0][0]=1;
    for(int i=0;i<=n;++i)
        for(int j=0;j<=n;++j)
            for(int k=0;k<=n;++k)
            {
                if(!f[i][j][k])continue;
                if((i&&k&&i==k)||(i&&j&&i==j)||(j&&k&&j==k))continue;
                if(!check(i,j,k)){f[i][j][k]=0;continue;}
                int r=max(i,max(j,k));
                add(f[r+1][j][k],f[i][j][k]);
                add(f[i][r+1][k],f[i][j][k]);
                add(f[i][j][r+1],f[i][j][k]);
                if(r==n)add(ans,f[i][j][k]);
            }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  string S;
  int cost = 700;
  getline(cin,S);
  for(int i = 0; i < 3;i++){
    if (S[i] == 'o'){
      cost += 100;
    }
  }
  cout << cost <<endl;
}


Measured memory_bytes: 256
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}

func DFC(G *[][][]int, V *[][]int, u, d int) bool {
  suc := true
  for _, g := range (*G)[u] {
    v, s := g[0], g[1]
    x := s - (*V)[u][d]
    update := false
    if (*V)[v][1 - d] == p {
      (*V)[v][1 - d] = x
      update = true
    } else if (*V)[v][1 - d] != x {
      return false
    }
    if update {
      suc = suc && DFC(G, V, v, 1 - d)
    }
  }
  return suc
}

func Solve() {
  NM := NextIntVec()
  N, M := NM[0], NM[1]
  G := make([][][]int, N)
  for i := range G {
    G[i] = make([][]int, 0)
  }
  V := make([][]int, N)
  for i := range V {
    V[i] = []int{p, p}
  }
  V[0][0] = 0
  for i := 0; i < M; i++ {
    UVS := NextIntVec()
    u, v, s := UVS[0] - 1, UVS[1] - 1, UVS[2]
    G[u] = append(G[u], []int{v, s})
    G[v] = append(G[v], []int{u, s})
  }
  suc := DFC(&G, &V, 0, 0)
  if suc {
    max, min := p, 1
    uniq := -1
    err := 0
    for _, v := range V {
      if v[0] != p { min = MaxInt(-v[0] + 1, min) }
      if v[1] != p { max = MinInt(v[1] - 1, max) }
      if v[0] != p && v[1] != p {
        if -1 < uniq && uniq != (v[1] - v[0]) / 2 { err = 1 }
        err |= (v[1] - v[0]) % 2
        uniq = (v[1] - v[0]) / 2
      }
    }
    if -1 < uniq {
      if uniq < min || max < uniq { err = 1 }
      Write(1 - err)
    } else {
      Write(MaxInt(max - min + 1, 0))
    }
  } else {
    Write(0)
  }
  return
}

const p = 1000000007

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 86784
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N;cin>>N;
  string s; cin>>s;
  ll x = s.length();

  rep(i,x){
    char c = s[i];
    ll d = c - 'A';
    ll m = d + N;
    m %= 26;
    char nc = 'A' + m;
    s[i] = nc;
  }
  cout<<s<<endl;
}


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

int main() {

	ll n, m; cin >> n >> m;
	vector<bool> isBroken(n + 1, false);
	for (ll i = 0; i < m; i++) {
		ll a; cin >> a;
		isBroken[a] = true;
	}
	const ll mod = 1000000007;
	vector<ll> dp(n + 1, 0);
	dp[0] = 1;
	dp[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (!isBroken[i - 1]) {
			dp[i] += dp[i - 1];
			dp[i] %= mod;
		}
		if (!isBroken[i - 2]) {
			dp[i] += dp[i - 2];
			dp[i] %= mod;
		}	
	}
	cout << dp[n] << endl;
	return 0;
}

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

using namespace std;

#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000000
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
  int n, c;
  cin >> n >> c;
  int d[c][c], b[n][n];
  REP(i, c) REP(j, c) cin >> d[i][j];
  REP(i, n) REP(j, n) cin >> b[i][j];
  int freq[c][3] = { };
  REP(i, n) REP(j, n) freq[b[i][j]-1][(i+j)%3]++;
  int ans = INF;
  REP(i, c){
    REP(j, c){
      if(i == j) continue;
      REP(k, c){
        if(k == i || k == j) continue;
        int cur = 0;
        REP(l, c) cur += freq[l][0]*d[l][i];
        REP(l, c) cur += freq[l][1]*d[l][j];
        REP(l, c) cur += freq[l][2]*d[l][k];
        ans = min(ans, cur);
      }
    }
  }
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
template< class T >
struct BinaryIndexedTree
{
  vector< T > data;

  BinaryIndexedTree(ll sz)
  {
    data.assign(++sz, 0);
  }

  T sum(ll k)//区間 [0,k] の合計を求める(閉区間なので注意)。
  {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(ll k, T x)//要素 k に値 x を加える。
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
int main(){
	int N,M,Q;
	scan(N>>M>>Q);
	vector<pair<pint,int> > kukan;
	BinaryIndexedTree< int > bit(N+1);
	int ans[100001];
	rep(i,M){
		int L,R;
		scan(L>>R);
		kukan.push_back(mp(mp(R,-L),-1));
	}
	rep(i,Q){
		int p,q;
		scan(p>>q);
		kukan.push_back(mp(mp(q,-p),i));
	}
	sort(kukan.begin(),kukan.end());
	rep(i,M+Q){
		int L=-kukan[i].first.second,R=kukan[i].first.first;
		if(kukan[i].second==-1){
			bit.add(L,1);
		}
		else{
			ans[kukan[i].second]=bit.sum(R)-bit.sum(L-1);
		}
	}
	rep(i,Q){
		prin(ans[i]);
	}
	return 0;
}


Measured memory_bytes: 8176
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/




/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int main() {
	
	while (1) {
		int d, w; cin >> d >> w;
		if (d == 0 && w == 0) { return 0; }

		int e[11][11];

		for (int i = 1; i <= d; i++) {
			for (int j = 1; j <= w; j++) {
				cin >> e[i][j];
			}
		}

		int ans = 0;

		for (int i = 1; i <= d; i++) {//高さ始点決め
			for (int j = 1; j <= w; j++) {//横始点決め
				for (int k = i + 2; k <= d; k++) {//高さ終点決め
					for (int l = j + 2; l <= w; l++) {//横終点決め

						int min_out = 9;
						int tmp = 0;
						bool missed = false;

						for (int x = i; x <= k; x++) {
							for (int y = j; y <= l; y++) {//2つのループで中身を見る

								bool in = true;
								if (x == i || x == k || y == j || y == l) { in = false; }

								if(in){}
								else {
									min_out = min(min_out, e[x][y]);//外堀の最小値を確認
								}

							}
						}

						for (int x = i+1; x < k; x++) {
							for (int y = j+1; y < l; y++) {//2つのループで中身を見る
								if (e[x][y] < min_out) { tmp += min_out - e[x][y]; }
								else { missed = true; }
							}
						}

						if(missed){}
						else { ans = max(ans, tmp); }

					}
				}
			}
		}


		cout << ans << endl;

	}
	
	return 0;
}




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

using namespace std;

typedef long long ll;

int main(){
    ll n, k;
    cin>>n>>k;
    vector <ll> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h.begin(), h.end());
    ll ans=0;
    for(int i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    string s; cin >> s;
    int n = s.length();
    rep(i,n-2){
        if(s[i] == s[i+1]){ cout << i+1 << " " << i+2 << endl; return 0; }
        if(s[i] == s[i+2]){ cout << i+1 << " " << i+3 << endl; return 0; }
    }
    if(s[n-2] == s[n-1]){ cout << n-1 << " " << n << endl; return 0; }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
using namespace std;
int N,M;
int A[100];
int B[100];
int sum1,sum2;
int ans1,ans2;
int main()
{
	while(true){
		scanf("%d%d",&N,&M);
		if(N==0&&M==0)break;
		sum1=0;sum2=0;
		ans1=100001;ans2=100001;
		for(int i=0;i<N;i++){
			scanf("%d",&A[i]);
			sum1+=A[i];
		}
		for(int i=0;i<M;i++){
			scanf("%d",&B[i]);
			sum2+=B[i];
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<M;j++){
				int sum3=sum1;
				int sum4=sum2;
				sum3-=A[i];sum3+=B[j];
				sum4+=A[i];sum4-=B[j];
				if(sum3==sum4){
					if(ans1+ans2>A[i]+B[j]){
						ans1=A[i];ans2=B[j];
					}
				}
			}
		}
		if(ans1!=100001)printf("%d %d\n",ans1,ans2);
		else printf("-1\n");
	}
	return 0;
}

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

void solve() {
  long long x, y;
  cin >> x >> y;
  if (x == y) {
    cout << -1 << endl;
    return;
  } else if (x % y == 0) {
    cout << -1 << endl;
    return;
  } else {
    cout << x << endl;
  }
}

int main() {
  solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        int cd=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                cd++;
            }
        }
        if(cd==8){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [N;M] = reads int
    let XYS = List.init M (fun _ -> reads int)

    let b = Array.create (N + 1) 1
    let r = Array.create (N + 1) false
    r.[1] <- true

    for [f;t] in XYS do
        b.[f] <- b.[f] - 1
        b.[t] <- b.[t] + 1
        if r.[f] then r.[t] <- true
        if b.[f] = 0 then r.[f] <- false

    Array.filter ((=) true) r
    |> Array.length
    |> printfn "%i"

    0

Measured memory_bytes: 29676
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n ; 
	cin >> n ; 
	vector<int> v(n) ; 
	for(int i=0;i<n;i++){
		cin >> v[i] ; 
	}
	while(v.size() > 1){
		sort(v.begin(),v.end());
		vector<int> after ; 
		after.push_back(v[0]);
		for(int i=1;i<(int)v.size();i++){
			int t = v[i] - v[i]/v[0] * v[0] ; 
			if ( t > 0 ) after.push_back(t) ; 
		}
		v = after ; 
		debug() << imie(after) ; 
	}
	cout << v[0] << endl;
    return 0 ;
}


Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template


ll f[400000];

void calc() {
    f[0] = 1;
    rep(i, 1, 400001) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }
}

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

ll comb(ll n, ll r) {
    ll ret = f[n];
    ret *= inv_mod(f[r], mod);
    ret %= mod;
    ret *= inv_mod(f[n - r], mod);
    ret %= mod;
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll N;
    ll A, B, K;
    cin >> N >> A >> B >> K;
    calc();
    ll ans = 0;
    for(ll n = 0; n <= N; n++) {
        if ((K - n * A) % B == 0) {
            ll b = (K - n * A) / B;
            if(b <= N && b >= 0) {
                ll tmp = comb(N, n);
                tmp *= comb(N, b);
                tmp %= mod;
                ans += tmp;
                ans %= mod;
            }
            
        }
    }
    output(ans);
    
    return 0;
}


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

int main() {
    int c[3][3];
    rep(i, 3) {
        rep(j, 3) {
            cin >> c[i][j];
        }
    }
    int a[3] = {0, c[1][0]-c[0][0], c[2][0]-c[0][0]};
    int b[3] = {c[0][0], c[0][1], c[0][2]};
    int flag;

    if( (a[1]+b[1] == c[1][1]) && (a[1]+b[2] == c[1][2]) && (a[2]+b[1] == c[2][1]) && (a[2]+b[2] == c[2][2]) ) {
        flag = 0;
    }
    else {
        flag = 1;
    }

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

Measured memory_bytes: 384
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode()

is_YYMM = 1 <= int(S[2:]) <= 12
is_MMYY = 1 <= int(S[:2]) <= 12

if is_YYMM and is_MMYY:
    print('AMBIGUOUS')
elif is_YYMM:
    print('YYMM')
elif is_MMYY:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9176
#include<stdio.h>
int main()
 {
 int a, b, c;
 scanf("%d %d %d", &a,&b,&c);
  if(a+b >=2 && a+b <= 1000 && a+b >=c && c <=1000) {
    printf("Yes\n");
    }else{
     printf("No\n");
   }
 
 return 0;
 }
 

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int n,ans,sum;
int a[1005];
int main()
{
	int i,j;
	cin>>n;
	ans=50000000;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(j=a[1];j<=a[n];j++)
	{
		sum=0;
		for(i=1;i<=n;i++)
			sum+=(j-a[i])*(j-a[i]);
		ans=min(ans,sum); 
	}
	cout<<ans;
	return 0;
}

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

    if temp!=1:
        arr.append(temp)

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

    return arr

#import numpy as np

a, b = map(int, input().split())
if a==1 and b==1:
    print(1)
else:
    #print(factorization(a))
    prime_a = factorization(a)
    prime_b = factorization(b)
    #print(prime_a, prime_b)
    print(1+len(set(prime_a)&set(prime_b)))

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N;
	while(cin>>N&&N){
		map<string,int> anime;
		vector<int> time;
		for(int i=0; i<N; ++i){
			int weekday,start;
			string name;
			cin >> name >> weekday >> start;
			int tmp=60*(start/100)+start%100;
			anime[name]=weekday*60*24+tmp;
			time.push_back(weekday*60*24+tmp);
		}
		int P;
		cin >> P;
		vector<string> fav(P);
		for(int i=0; i<P; ++i){
			cin >> fav[i];
		}
		bool flag=true;
		for(int i=0; i<P; ++i){
			for(int j=0; j<P; ++j){
				if(i!=j&&abs(anime[fav[i]]-anime[fav[j]])<30) flag=false;
			}
		}
		sort(time.begin(),time.end());
		int ans=0,t=0;
		for(int i=0; i<N; ++i){
			bool flag_=true;
			if(t<=time[i]){
				for(int j=0; j<P; ++j){
					if(time[i]!=anime[fav[j]]&&time[i]<anime[fav[j]]&&time[i]+30>anime[fav[j]]){
						flag_=false;
						break;
					}
				}
				if(flag_){
					++ans;
					t=time[i]+30;
				}
			}
		}
		if(!flag) cout << -1 << endl;
		else cout << ans << endl;
	}
	return 0;
}

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

int main()
{
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<int>> v(n + 1, vector<int>(n + 1));

  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    v[l][r]++;
  }

  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      v[i][j] += v[i][j - 1];
    }
  }

  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    int x(0);
    for (int j = l; j <= r; j++) {
      x += v[j][r];
    }
    cout << x << endl;
  }
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
const double PI = acos(-1);
typedef long long ll;

template<class T>
T print(T a){cout<<a<<endl;}

int main(void){
    int X,Y;cin>>X>>Y;int ans=0;
    if(X==1&&Y==1){
        cout<<1000000<<endl;
        return 0;
    }

    if(X==1)ans+=300000;
    else if(X==2)ans+=200000;
    else if(X==3)ans+=100000;

    if(Y==1)ans+=300000;
    else if(Y==2)ans+=200000;
    else if(Y==3)ans+=100000;

    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
a, b, c = [1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]
x, y = map(int, input().split())
flg = 0
for lst in [a, b, c]:
    if x in lst and y in lst:
        flg = 1
if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
fun main(args: Array<String>) {
    val MOD = 1000000007L
    val N = nextLong()
    val A = listOfLong()
    val C = LongArray(61)
    for (a in A) {
        for (b in 0 until 61) {
            C[b] += (a shr b) % 2
        }
    }
    var ans = 0L
    fun shiftLeft(v: Long, shift: Int): Long {
        var ret = v % MOD
        for (s in 0 until shift) {
            ret *= 2
            ret %= MOD
        }
        return ret
    }
    for (b in 0 until 61) {
        ans += shiftLeft(C[b] * (N - C[b]), b)
        ans %= MOD
    }
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 112516
import java.util.*;
// warm-up
// Much cleaner i guess. Not sure why the previous solution (without any extra memory) failed. No way to know the test cases.
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int t=0, i=0, n=sc.nextInt(), k=sc.nextInt(), tot=n, max=Integer.MIN_VALUE;
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		while (tot-->0) a[i++] = sc.nextInt();
		i=0; b[i]=a[i];
		for (i=1; i<n; i++) b[i] = Math.min(b[i-1],a[i]);
		for (i=0; i<n; i++) {
			c[i] = a[i]-b[i];
			if (c[i]>max) max=c[i];
		}
		for (int d : c) if (d==max) t++;
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 60796
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
bool palindrome(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-1-i])
        return 0;
    }
    return 1;
}
void solveforthiscase(const int & test)
{//deb(test);
string s;
cin>>s;
n=s.size();
if(!palindrome(s))
{cout<<"No";return ;}
string s1;
string s2;
for(int i=0;i<(n-1)/2;i++)
s1.pb(s[i]);
for(int i=(n+3)/2-1;i<n;i++)
{
    s2.pb(s[i]);
}
if(palindrome(s1) && palindrome(s2))
{
    cout<<"Yes";
    return ;
}
cout<<"No";
return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
from itertools import product

N = int(input())
P = []

for i in range(len(str(N))):
    P += list(product(["7", "5", "3"], repeat=i + 1))

ans = 0
for p in P:
    if ("7" not in p) or ("5" not in p) or ("3" not in p):
        continue
    else:
        p = int("".join(p))
        ans += (p <= N)

print(ans)


Measured memory_bytes: 7028
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  int sum = 0;
  REP(i,N-1){
    sum+=min(T,A.at(i+1)-A.at(i));
  }

  cout << sum+T << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,x=0,ans=0;
  string s;
  cin >> n >> s;
  for(long i=0;i<n;i++) {
    if(s[i]=='I') x++;
    else x--;
    ans=max(ans,x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  if(m<=n){
    cout<<0;
    return 0;
  }
  vector<int> x(m);
  for(int i=0;i<m;i++){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
  vector<int> diff;
  for(int i=0;i<m-1;i++){
    diff.push_back(x[i+1]-x[i]);
  }
  sort(diff.begin(),diff.end());
  for(int i=0;i<n-1;i++){
    diff.pop_back();
  }
  int sum=0;
  for(auto& e:diff){
    sum+=e;
  }
  cout<<sum;
}

Measured memory_bytes: 1404
#include<stdio.h>
#include<math.h>

int main(){
  int i,j,n,flag,A[10000],num=0;
  scanf("%d",&n);
  for(i = 0; i < n;i++) scanf("%d",&A[i]);

  for(i = 0; i < n;i++){
    flag = 0;
    for(j = 2; j <= sqrt((int)A[i]);j++){
      if(A[i] % j == 0 && A[i] != 2){
	flag = 1;
	break;
      }
    }
    if(flag == 0) num += 1;
  }
  printf("%d\n",num);
  return 0;
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
string s;
ll k;
int main(){
	cin>>s;
	f(i,0,s.size()-1)k=(k+s[i]-'0')%9;
	if(k==0)cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ; 
  cin >> n ; 
  int ac=0, wa=0, tle=0, re = 0 ; 
  
  rep(i,n){
    string s ; 
    cin >> s ;
    if(s == "AC" ) ac  ++ ; 
    if(s == "WA" ) wa  ++ ;
    if(s == "TLE") tle ++ ;
    if(s == "RE" ) re  ++ ;
  }
  
  cout << "AC x " << ac << endl ;
  cout << "WA x " << wa << endl ;
  cout << "TLE x "<<tle << endl ;
  cout << "RE x " << re << endl ;
  
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n*m];
        int[] b = new int[m];
        int[] ret = new int[n];
        for (int i = 0;i < n*m;i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0;i < m;i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0;i < n;i++) {
            for (int j = 0;j < m;j++) {
                ret[i] += a[i * m + j] * b[j];
            }
            System.out.println(ret[i]);
        }
        
    }
}

Measured memory_bytes: 40760
N,M,K = map(int,input().split())

def comb_list(n, r, mod):
    ret = [1]
    for i in range(1, r+1):
        ret.append(ret[-1] * (n+1-i) * pow(i, mod-2, mod) % mod)
    return ret

ans = 0

mod = 998244353

c_list = comb_list(N-1,K,mod)

for i in range(K+1):
    ans = (ans + c_list[i] * M * pow(M-1,N-i-1,mod))%mod
print(ans)

Measured memory_bytes: 88688