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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int t; cin>> t; for( ; t; --t)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

int32_t main(){
	fastio;
	string s;
	cin >> s;
	bool ok = 1;
	for(int i = 0 ; i<s.size() ; ++i){
		if((i+1) % 2 == 1 && s[i] == 'L'){
			ok = 0;
			break;
		}
		else if((i+1) % 2 == 0 && s[i] == 'R'){
			ok = 0;
			break;
		}
	}
	cout<< (ok? "Yes\n": "No\n");
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.sort(key = lambda x:x[1])
i = 0
ans = 0
while i < m:
    right = ab[i][1] - 1
    ans += 1
    while ab[i][0] <= right < ab[i][1]:
        i += 1
        if i >= m:
            break
print(ans)


Measured memory_bytes: 29084
#include <bits/stdc++.h>
using namespace std;
int main(){
   long long int N,A,B,tot;
   cin>>N>>A>>B;
   long long int sum=A+B;
   long long int Q=A*(N/sum);
   long long int R=N%sum;
   tot=Q+min(R,A);
   long long int power = pow(10,18);
  if(N>=1&&A>=0&&B>=0&&sum>0&&N<=power&&sum<=power){
   cout<<tot;
  }
   return 0;
   
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println(x*x*x);
    }
    
}



Measured memory_bytes: 26200
// AtCoder Begginer Contest 139 A
// https://atcoder.jp/contests/abc136/tasks/abc139_a

#include<iostream>
#include<string>
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	
	int match = 0;
	
	for(int i=0; i<S.length(); i++) {
		if (S[i] == T[i]) {
			match++;
		}
	}
	
	cout << match << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    a = sorted(list(map(int, input().rstrip('\n').split())))
    for i in range(1, n):
        if a[i] == a[i-1]:
            print("NO")
            exit()
    print("YES")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 82804
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};


signed main() {
int n,m,x;
  cin>>n>>m>>x;
  int ans=0,a;
  for(int i=0;i<m;i++){
    cin>>a;
    if(a<x)ans++;
  }
  cout<<min(ans,m-ans);


return 0;
}


Measured memory_bytes: 256
n = int(input())
C = input()
chk = 0
for i in range(n):
    if C[n-1-i] == 'R':
        chk = n-1-i
        break
cnt = 1
for i in range(chk):
    if C[i] == 'R':
        cnt += 1
ans = 0
for i in range(cnt):
    if C[i] == 'W':
        ans += 1
if 'R' not in C:
    print(0)
else:
    print(ans)

Measured memory_bytes: 67396
#include<bits/stdc++.h>
using namespace std;
#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 erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  string s;
  cin >> s;
  if(s == "ARC") cout << "ABC" << endl;
  else cout << "ARC" << endl;
}

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

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

ll N,M;

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

	cin >> N >> M;

	vector<P> G[100005];

	for (int i = 0;i < M;i++){
		ll L, R, D;
		cin >> L >> R >> D;
		G[L].push_back(P(R,D));
		G[R].push_back(P(L,-D));
	}

	bool used[100005]; memset(used, 0, sizeof(used));
	ll dist[100005]; 

	for (int i = 0;i <= N;i++){
		dist[i] = LLONG_MAX;
	}

	for (int s = 1;s <= N;s++){
		if(used[s]) continue;
		queue<P> que; //Node, Dist
		dist[s] = 0;
		que.push(P(s,0LL));
		while(que.size()){
			P p = que.front(); que.pop();
			ll node = p.first, sum = p.second;
			for (int i = 0;i < G[node].size();i++){
				ll to = G[node][i].first;
				ll cost = G[node][i].second;
				if(dist[to] != LLONG_MAX && dist[to] != sum+cost){
					cout << "No" << endl;
					return 0;
				}
				dist[to] = sum+cost;
				if(!used[to]){
					used[to] = true;
					que.push(P(to, sum+cost));
				}
			}
		}
	}

	cout << "Yes" << endl;

	return 0;

}


Measured memory_bytes: 14576
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

const int M = 256;
const double epsilon = 1e-9;

int main() {
  int N;
  while (cin >> N && N) {
    vector<int> L;
    for (auto i=0; i<N; i++) {
      int l;
      cin >> l;
      L.push_back(l);
    }
    double minH = 1e9;
    int minS, minA, minC;
    for (auto S=0; S<16; S++) {
      for (auto A=0; A<16; A++) {
	for (auto C=0; C<16; C++) {
	  int R[300];
	  R[0] = S;
	  for (auto i=1; i<=N; i++) {
	    R[i] = (A*R[i-1]+C)%M;
	    // cerr << R[i] << endl;
	  }
	  int O[300];
	  int App[300];
	  fill(App, App+300, 0);
	  for (auto i=0; i<N; i++) {
	    O[i] = (R[i+1] + L[i])%M;
	    // if (S == 1 && A == 5 && C == 11) cerr << O[i] << endl;
	    App[O[i]]++;
	  }
	  double H = 0;
	  for (auto i=0; i<300; i++) {
	    double temp = (double)App[i]/N;
	    // cerr << "temp = " << temp;
	    if (temp != 0) H -= temp * log(temp);
	  }
	  // cerr << H << endl;
	  if (H + epsilon < minH) { 
	    minH = H;
	    minS = S;
	    minA = A;
	    minC = C;
	    // cerr << "S = " << minS << ", A = " << minA 
	    //  << ", C = " << minC << ", H = " << H << endl;
	  }
	}  
      }
    }
    cout << minS << " " << minA << " " << minC << endl;
  }
}

Measured memory_bytes: 1264
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 1<<30;
typedef pair<int, int> P;

struct Edge{ int to, id; };

int main() {
  int n; cin >> n;
  vector<vector<Edge>> g(n);
  vector<int> ans(n-1);
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    a--, b--;
    g[a].push_back(Edge{b, i});
    g[b].push_back(Edge{a, i});
  }

  queue<int> q;
  vector<int> used(n), pre(n, -1);
  q.push(0);
  used[0] = 1;
  while(!q.empty()) {
    int v = q.front(); q.pop();
    int p = pre[v];
    int c = -1;
    rep(i, g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if(used[u]) c = ans[ei];
    }
    int k = 1;
    rep(i, g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if(used[u]) continue;
      if(k == c) ++k;
      ans[ei]= k; ++k;
      q.push(u);
      used[u] = 1;
    }
  }

  int mx = 0;
  rep(i, n) mx = max(mx, int(g[i].size()));
  cout << mx << endl;
  rep(i, n-1) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 58) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N, M;
  cin >> N >> M;
  vector< int > t(N, -1);
  for(int i = 0; i < M; i++) {
    int k, x;
    cin >> k >> x;
    --k;
    if(t[k] == -1 || t[k] == x) {
      t[k] = x;
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  if(N == 1) {
    for(auto &x : t) cout << max(x, 0);
    cout << endl;
  } else {
    if(t[0] == 0) {
      cout << -1 << endl;
      return 0;
    }
    if(t[0] == -1) t[0] = 1;
    for(auto &x : t) cout << max(x, 0);
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
char a[100010];
int main(){
    scanf("%s" , a + 1);
    int len = strlen(a + 1);
    int ok = 0;
    for(int i = 1 ; i < len ; ++ i){
        if(a[i] == a[i + 1]){
            printf("%d %d\n" , i , i + 1);
            ok = 1;
            break;
        }
        if(i + 2 < len && a[i] == a[i + 2]){
            printf("%d %d\n" , i , i + 2);
            ok = 1;
            break;
        }
    }
    if(!ok){
        printf("-1 -1\n");
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<vector<P>> to(N);
    rep(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        to[u].push_back(P(v, w));
        to[v].push_back(P(u, w));
    }

    vector<int> ans(N, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int nv = q.front();
        q.pop();

        rep(i, to[nv].size()) {
            int u = to[nv][i].first;
            int w = to[nv][i].second;
            if (ans[u] != -1) continue; // 到達済み
            ans[u] = (ans[nv] + w) % 2;
            q.push(u);
        }
    }

    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 6784
#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);

	if(a>b)
		printf("a > b\n");
	else if(a<b)
		printf("a < b\n");	
	else
		printf("a == b\n");		

		}



Measured memory_bytes: 2124
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;

int main(){

	int N ,A ,B;

	cin >> N >> A >> B;

	cout << min(A, B) << " " << max(A+B-N, 0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int rot[24][7] = {
	{ 0,1,2,3,4,5,6 },{ 0,1,3,5,2,4,6 },{ 0,1,4,2,5,3,6 },{ 0,1,5,4,3,2,6 },
	{ 0,2,6,3,4,1,5 },{ 0,2,3,1,6,4,5 },{ 0,2,1,4,3,6,5 },{ 0,2,4,6,1,3,5 },
	{ 0,3,1,2,5,6,4 },{ 0,3,2,6,1,5,4 },{ 0,3,5,1,6,2,4 },{ 0,3,6,5,2,1,4 },
	{ 0,4,1,5,2,6,3 },{ 0,4,2,1,6,5,3 },{ 0,4,5,6,1,2,3 },{ 0,4,6,2,5,1,3 },
	{ 0,5,1,3,4,6,2 },{ 0,5,3,6,1,4,2 },{ 0,5,4,1,6,3,2 },{ 0,5,6,4,3,1,2 },
	{ 0,6,2,4,3,5,1 },{ 0,6,3,2,5,4,1 },{ 0,6,5,3,4,2,1 },{ 0,6,4,5,2,3,1 } };
int assign[7];

int main()
{
	int i, j;
	int a[7], b[7], dice[7];

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	for (i = 1; i <= 6; i++) scanf("%d", a+i);
	for (j = 0; j < 24; j++) {
		for (i = 1; i <= 6; i++) dice[i] = rot[j][i];
		for (i = 1; i <= 6; i++) b[i] = assign[dice[i]];
		for (i = 1; ; i++) {
			if (i > 6) { puts("Yes"); return 0; }
			if (a[i] != b[i]) break;
		}
	}
	puts("No");
	return 0;
}




Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string w,t;
    cin>>w;
    int count=0;
    while(true){
	cin>>t;
	if(t=="END_OF_TEXT"){
	    break;
	}
	transform(all(t),t.begin(),::tolower);

	if(w==t){
	    count++;
	}
    }
    cout<<count<<'\n';
    return(0);
}



Measured memory_bytes: 3220
#include <cstdio>
#include <cstring>
using namespace std;
char s[200005];
int main(void){
	int i,n,ans=1,cnt;
	scanf("%s",s);
	n=strlen(s);
	for(i=1;i<n;){
		if(s[i]==s[i-1]){
			if(i+1<n){
				i++;
				ans++;
				if(i+1<n){
					i+=2;
					ans++;
				}
				else{
					break;
				}
			}
			else{
				break;
			}
		}
		else{
			ans++;
			i++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x)
    {
        data=x;
        left=NULL;
        right=NULL;
    }
};
#define Node struct Node

ll modpow(ll a, ll n)
{
    ll m=1e9+7;
    if(n==0)
        return 1;
    ll y=modpow(a,n/2)%m;
    if(n%2==0)
        return (y*y)%m;
    return (((y*y)%m)*a)%m;
}

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n][2];
        for(int i=0;i<n;i++)
            cin>>a[i][0]>>a[i][1];
        int f=0;
        for(int i=0;i<n-2;i++)
        {
            if( a[i][0]==a[i][1] && a[i+1][0]==a[i+1][1] && a[i+2][0]==a[i+2][1] )
            {
                f=1;
                break;
            }
        }
        if(f==0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}
















Measured memory_bytes: 3640
import java.util.Scanner;
class Main{
    int f,r,m,x,y;
    boolean a;
    String b;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\\s");
        while(a == false){
            m = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
            if(m == -1 && f == -1 && r == -1){
                a = true;
                break;
            }else if(m == -1 || f == -1){
                b = "F";
            }else if(m + f >= 80){
                b = "A";
            }else if(m + f >= 65){
                b = "B";
            }else if(m + f >= 50){
                b = "C";
            }else if(m + f >= 30 && r >= 50){
                b = "C";
            }else if(m + f >= 30){
                b = "D";
            }else{
                b = "F";
            }
            System.out.println(b);
        }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

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

int A[MAX], n;

int partition(int p, int r) {
    int x, i, j, t;
    x = A[r];
    i = p - 1;
    for(j = p; j < r; j++) {
        if (A[j] <= x) {
            i++;
            t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
    t = A[i+1]; A[i+1] = A[r];; A[r] = t;
    return i+1;
}

int main() {
    int i, q;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    q = partition(0, n - 1);

    for (i = 0; i < n; i++) {
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A, B, C;
        cin >> A >> B >> C;

        if (A <= C && C <= B)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;


//-------------------- Modulo --------------------//
#define MOD (1000000007LL)
#define SIZE (500000LL)

long long fac[SIZE + 1];
long long inv[SIZE + 1];
long long finv[SIZE + 1];

void modinit(void) {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i <= SIZE; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i ) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;  
}

long long modcom(long long n, long long k) {
  assert(n >= k);
  assert(n <= SIZE);
  assert(k <= SIZE);
  return fac[n] * finv[n - k] % MOD * finv[k] % MOD;
}
//-------------------- Modulo --------------------//


long long Calc(int A, int B, int N) {
  long long sum = 0;
  
  for (int i = 0; i < N; ++i) {
    long long tmp = (N+i) * modpow(B,i) % MOD * modpow(A+B,N-i) % MOD * modcom(N+i-1,i) % MOD;
    sum = (sum + tmp) % MOD;
  }
  
  sum = sum * modpow(A, N) % MOD;
  for (int i = 0; i < 2 * N; ++i) {
    sum = sum * inv[A + B] % MOD;
  }

  return sum;
}

int main() {
  modinit();
  
  int N, A, B, C;
  cin >> N >> A >> B >> C;

  long long sum1 = Calc(A, B, N);
  long long sum2 = Calc(B, A, N);

  long long ans = (sum1 + sum2) % MOD;
  ans = ans * 100 % MOD;
  ans = ans * inv[100 - C] % MOD;

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    int a,b,c; cin>>a>>b>>c;
    cout<<(b-a==c-b?"YES":"NO")<<endl;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = -1;
  for(int e = 2; e <= s.size(); e += 2){
    bool f = true;
    for(int i = 0;i < (s.size() - e) / 2;i++){
      if(s[i] != s[(s.size() - e) / 2 + i]){
        f = false;
        break;
      }
    }
    if(f){
      ans = s.size() - e;
      break;
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
  
struct UnionFind
{
  vector< int > data;
  
  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }
  
  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
  
  void unite(int a, int b)
  {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(data[a] > data[b]) swap(a, b);
    data[a] += data[b];
    data[b] = a;
  }
  
  bool same(int a, int b)
  {
    return (find(a) == find(b));
  }
};
  
struct Point
{
  int x, y;
  
  Point(int x, int y) : x(x), y(y)
  {
  };
  
  Point()
  {
  };
  
  Point operator+(const Point& a) const
  {
    return (Point(x + a.x, y + a.y));
  }
  
  Point operator-(const Point& a) const
  {
    return (Point(x - a.x, y - a.y));
  }
  
  bool operator<(const Point& b) const
  {
    return x != b.x ? x < b.x : y < b.y;
  }
  
  double abs()
  {
    return (sqrt(x * x + y * y));
  }
};
  
double cross(const Point& a, const Point& b)
{
  return a.x * b.y - a.y * b.x;
}
  
vector< int > Convex_Hull(vector< Point > p)
{
  int n = p.size(), k = 0;
  vector< int > order(p.size());
  for(int i = 0; i < n; i++) order[i] = i;
  sort(begin(order), end(order), [&](int a, int b)
  {
    return (p[a] < p[b]);
  });
  vector< int > ch(2 * n);
  for(int i = 0; i < n; ch[k++] = order[i++]) {
    while(k >= 2 && cross(p[ch[k - 1]] - p[ch[k - 2]], p[order[i]] - p[ch[k - 1]]) < 0) --k;
  }
  for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = order[i--]) {
    while(k >= t && cross(p[ch[k - 1]] - p[ch[k - 2]], p[order[i]] - p[ch[k - 1]]) < 0) --k;
  }
  ch.resize(k - 1);
  return (ch);
}
  
  
int main()
{
  int V, R;
  cin >> V >> R;
  
  vector< Point > point(V);
  for(int i = 0; i < V; ++i) {
    cin >> point[i].x >> point[i].y;
  }
  
  vector< int > polygon = Convex_Hull(point);
  UnionFind tree(V);
  
  double cost = 0;
  for(int i = 1; i <= polygon.size(); ++i) {
    tree.unite(polygon[i - 1], polygon[i]);
    cost += (point[polygon[i - 1]] - point[polygon[i % polygon.size()]]).abs();
  }
  
  vector< pair< double, pair< int, int > > > edges;
  for(int i = 0; i < R; i++) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    if(!tree.same(s, t)) edges.push_back(make_pair((point[s] - point[t]).abs(), make_pair(s, t)));
  }
  sort(begin(edges), end(edges));
  
  for(int i = 0; i < edges.size(); i++) {
    if(!tree.same(edges[i].second.first, edges[i].second.second)) {
      tree.unite(edges[i].second.first, edges[i].second.second);
      cost += (point[edges[i].second.first] - point[edges[i].second.second]).abs();
    }
  }
  
  cout << fixed << setprecision(10) << cost << endl;
}

Measured memory_bytes: 3296
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto b = readln.chomp.to!(char);
    switch (b) {
        case 'A':
            writeln("T");
            return;
        case 'T':
            writeln("A");
            return;
        case 'C':
            writeln("G");
            return;
        case 'G':
            writeln("C");
            return;
        default:
            return;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  map<char, set<int>> m;
  for (int i = 0; i < N; ++i) {
    char c; cin >> c;
    m[c].insert(i);
  }

  LL cnt = (LL)m['R'].size() * (LL)m['G'].size() * (LL)m['B'].size();
  for (int r : m['R']) {
    for (int g : m['G']) {
      int x1 = min(r, g);
      int x2 = max(r, g);
      int d = x2 - x1;
      int b = x2 + d;
      if(m['B'].count(b)) --cnt;

      if (d % 2 == 0) {
        b = x1 + d/2;
        if(m['B'].count(b)) --cnt;
      }

      b = x1 - d;
      if(m['B'].count(b)) --cnt;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  long long int i,num1=0,num2=0;
  for(i=0;i<b;i++)
  {
    num1+=a*pow(10,i);
  }
  for(i=0;i<a;i++)
  {
    num2+=b*pow(10,i);
  }
  if(num1>=num2)
    cout<<num1;
  else cout<<num2;
  return 0;
}
  

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

bool comp(const string& f, const string& s){
    return f.size() < s.size();
}
int main(void){
    char a, b;
    cin >> a >> b;

    if(a == 'H' && b == 'H'){
        cout << 'H' << endl;
    } else if(a == 'D' && b == 'D'){
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
}

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 10000000000000007

#define prime 1000000007

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    ll aux = n;
    for (ll i = 2; i*i <= n; ++i){
        if(n%i == 0) aux = n/i;
    }
    cout << n/aux+aux-2 << endl;

    return 0;
}

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

#define int long long
#define rep(n, i) for (int i = 0; i < n; i++)
#define rep2(m, n, i) for (int i = m; i < n; i++)
#define rep_r(n, i) for (int i = n - 1; i >= 0; i--)

signed main() {
    int a, b;
    cin >> a >> b;
    int cnt = 0;
    rep2(a, b + 1, i) {
        if (i % 10 == i / 10000 && (i % 100) / 10 == (i % 10000) / 1000) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#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 all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 105000000000

const int maxn = 1e5 + 10;

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

	int a;
	cin >> a;
	int min = a;
	int max = a;
	FOR(i,1, n)
	{
		cin >> a;
		if (a > max) max = a;
		else if (a < min) min = a;
	}

	Print(max - min);

	return 0;
	
}

Measured memory_bytes: 256
n = int(input())
XL = []
for _ in range(n):
    x, l = map(int, input().split())
    x_min = x - l
    x_max = x + l
    XL.append((x,l, x_min, x_max))

XL = sorted(XL, key=lambda x: x[3])

now = 0
count = 0
for i in range(1,n):
    if XL[now][3] > XL[i][2]:
        count += 1
    else:
        now = i
ans = n - count

print(int(ans))

Measured memory_bytes: 26976
import heapq

N, M = map(int, input().split())
B = [[] * M for _ in range(M)]
for i in range(N):
    a, b = map(int, input().split())
    if a > M:
        continue
    B[M - a].append(b)
ans = 0
h = []
for i in range(M - 1, -1, -1):
    for b in B[i]:
        heapq.heappush(h, b * -1)
    if len(h) > 0:
        ans += heapq.heappop(h) * -1
print(ans)


Measured memory_bytes: 18328
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class UnionFind{
	vector<ll> rank;
	vector<ll> diff_weight;
	vector<ll> num;
public:
	vector<ll> par;

	UnionFind(ll N):par(N),num(N),rank(N),diff_weight(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
			rank[i]=0;
			diff_weight[i]=0;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		ll r = root(par[x]);
		diff_weight[x]+=diff_weight[par[x]];
		return par[x]=r;
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]) swap(rx,ry);
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		num[rx] += num[ry];
	}

	void relate(ll x,ll y,ll w){
		w+=weight(x),w-=weight(y);
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]){
			swap(rx,ry);
			w = -w;
		}
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		diff_weight[ry] = w;
		num[rx] += num[ry];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}

	ll weight(ll x){
		root(x);
		return diff_weight[x];
	}

	ll diff(ll x,ll y){
		return weight(y)-weight(x);
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in(),M=in(),K=in();
	UnionFind UF(N);
	vector<int> F(N,1),D(N,0);
	REP(i,M){
		int a=in()-1,v=in()-1;
		UF.unite(a,v);
		F[a]++;
		F[v]++;
	}
	REP(i,K){
		int c=in()-1,d=in()-1;
		if(UF.same(c,d)){
			D[c]++;
			D[d]++;
		}
	}
	REP(i,N){
		F[i] = UF.getsize(i)-F[i]-D[i];
	}
	PRINTALL(F);
	return 0;
}


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

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

if (a<b) 
cout << "a < b" << endl;
if (a>b)
cout << "a > b" << endl;
if (a==b)
cout << "a == b" << endl;

return 0;
}


Measured memory_bytes: 3068
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;

    if ( a % 3 == 0 | b % 3 == 0 | (a + b) % 3 == 0 ) {
        std::cout << "Possible" << std::endl;
    }
    else {
        std::cout << "Impossible" << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int n,k;
	cin >> n >> k;
	cout << n-k+1 << endl;
return 0;
}


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

using namespace std;

const int N = 1e5;
vector<vector<int>> in(N+5), out(N+5);
set<int> leaves;
vector<int> dp(N+5);
int solve(int n)
{
    if (dp[n] != -1)
        return dp[n];
    if (in[n].size() == 0)
        return 0;

    int ans = 0;
    for (int i = 0; i < in[n].size(); i++)
    {
        ans = max(ans, 1 + solve(in[n][i]));
    }
    return dp[n] = ans;
}

int main()
{

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        in[b].push_back(a);
        out[a].push_back(b);
    }
    for (int i = 1; i <= n; i++)
    {
        dp[i] = -1;
        if (out[i].size() == 0)
            leaves.insert(i);
    }

    int ans = 0;
    for (auto leaf : leaves)
    {
        
        ans = max(ans, solve(leaf));
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define maxn 102333 
using namespace std;
int a[maxn], b[maxn];
vector< pair<int, int> > V;
int main() {
	int n, H, cur = 0, ans = 0;
	scanf("%d%d", &n, &H);
	for(int i = 1; i <= n; ++i) {
		scanf("%d%d", a + i, b + i);
		V.push_back(make_pair(a[i], 1));
		V.push_back(make_pair(b[i], 0));
	}
	sort(V.begin(), V.end());
	reverse(V.begin(), V.end());
	for(auto it = V.begin(); it != V.end() && cur < H; ++it) {
		if(it->second) {
			ans += (H - cur - 1) / (it->first) + 1;
			break;
		} else {
			cur += it->first;
			++ans;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 5884
#include<bits/stdc++.h>
using namespace std ;
#define ll  long long 
#define dl long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);


int main ()
{
    FAST
    
   dl n,d ;
   cin>>n>>d;
   ll ans = 0 ;

   while(n--)
   {
   	 dl a,b;
   	 cin>>a>>b;
   	 dl p = (a*a)+(b*b);
   	 dl q = sqrt(p);
   	 if (q<=d)
   	 	ans++;
   	

   }
   cout<<ans<<endl;
   

    

    
    return 0;

}

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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#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, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int mee(int i1,int ret, string& s)
{
  if(s[i1] == s[i1+1]) {
    ++ret;
    ret = mee(i1+1,ret,s);
  }
  return ret;
}
int main()
{
  string s1; cin >> s1;
  string s2 = s1+s1;
  string s3 = s2 + s1;
  lint k; cin >> k;
  lint m1 = s1.length()-1;
  lint m2 = s2.length()-1;
  lint m3 = s3.length()-1;
  vector<lint> me1(m1,1);
  vector<lint> me2(m2,1);
  vector<lint> me3(m3,1);
  lint count1 = 0;
  lint count2 = 0;
  lint count3 = 0;
  REP(i,m1){
    if(s1[i] == s1[i+1]) {
      lint ret = 1;
      ret = mee(i+1,ret,s1);
      me1[i] += ret;
      i+=ret;
  	}
  }
  REP(i,m2){
    if(s2[i] == s2[i+1]) {
      lint ret = 1;
      ret = mee(i+1,ret,s2);
      me2[i] += ret;
      i+=ret;
  	}
  }
  REP(i,m3){
    if(s3[i] == s3[i+1]) {
      lint ret = 1;
      ret = mee(i+1,ret,s3);
      me3[i] += ret;
      i+=ret;
  	}
  }
  REP(i,m1){
    if(me1[i] > 1) count1 +=me1[i]/2;
  }
  REP(i,m2){
    if(me2[i] > 1) count2 +=me2[i]/2;
  }
  REP(i,m3){
    if(me3[i] > 1) count3 +=me3[i]/2;
  }
  lint c1 = count3 - count2;
  lint c2 = count2 - count1;
  //cout << c1 << "  " << c2 << "\n";
  if(c1 != c2){
  	FOR(i,1,k){
      if(i%2 == 0){
  		count1 += c1;
      }else{
        count1 += c2;
      }
  	}
  }else{
    count1 += (count2 - count1)*(k-1);
  }
  cout << count1;
}

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

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);

  map<string,int> count;

  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    string temp; cin >> temp;
    count[temp]++;
  }

  int M; cin >> M;
  for (int i = 0; i < M; i++) {
    string temp; cin >> temp;
    count[temp]--;
  }

  int ans = 0;
  for (auto x: count) ans = max(ans, x.second);

  ans = max(ans, 0);
  cout << ans << endl;
  return 0;
  
}
  
  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
using namespace std;
string mp[11];
int w,h;
set <string> cnt;
string ans;
void check(int x,int y){
  string str;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      if(i==0 && j==0) continue;
      str = mp[y][x];
      int nx=(x+j+w)%w,ny=(y+i+h)%h;
      while(ny!=y || nx!=x){
	str+=mp[ny][nx],nx=(nx+j+w)%w,ny=(ny+i+h)%h;
      if(cnt.count(str)){
	if(str.size()>ans.size()) ans = str;
	else if(str.size()==ans.size()) ans = min(str,ans);
      }
      else cnt.insert(str);
      }
    }
}

int main(){
  while(1) {
    cin >> h >> w;
    cnt.clear();
  if(w == 0 && h == 0) break;
  for(int i=0;i<h;i++) cin >> mp[i];

  ans = "";
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)check(j,i);
  if(ans.size()==0) ans = "0";
  cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 33748
#include <algorithm>
#include <iostream>
#include <list>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

int count(const vector<pair<int, int>>& p)
{
    int c = 0;
    for (auto m : p) {
        if (m.second > 0) {
            c += m.second;
        }
    }
    return c;
}

void bomb(int index, int h, int x, int d, vector<pair<int, int>>& p)
{
    for (int i = index; i < p.size(); i++) {
        if (p[i].first > (x + d)) {
            break;
        }
        if (p[i].first >= (x - d)) {
            p[i].second -= h;
        }
    }
}

int main()
{
    int n;
    long long d, a;
    cin >> n >> d >> a;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    d = d*2;
    long long tot = 0;
    queue<pair<long long, long long>> q;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        long long x = p[i].first;
        long long h = p[i].second;
        while (q.size() && q.front().first < x) {
            tot -= q.front().second;
            q.pop();
        }
        h -= tot;
        if (h > 0) {
            long long num = (h + a - 1) / a;
            ans += num;
            long long damage = num * a;
            tot += damage;
            q.emplace(x + d, damage);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3456
import java.util.*;

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

    boolean tmp = true;
    String pat = "#.";

    while(tmp){
      int h = sc.nextInt();
      int w = sc.nextInt();

      if(h == 0 && w == 0){
        tmp = false;
        break;
      }

      for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
          if((i + j) % 2 == 0){
            System.out.print("#");
          } else if((i + j) % 2 == 1){
            System.out.print(".");
          }
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}



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

int main(){
    double xy[100],max=-1,p1=0,p2=0,p3=0;
    int x[100],y[100],i,n;

    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&x[i]);
    for(i=0;i<n;i++) scanf("%d",&y[i]);
    for(i=0;i<n;i++){
        xy[i]=x[i]-y[i];
        if(xy[i]<0) xy[i]*=-1;
        if(max<xy[i]) max=xy[i];
        p1+=xy[i];
        p2+=pow(xy[i],2);
        p3+=pow(xy[i],3);
    }
    printf("%f\n%f\n%f\n%f\n",p1,sqrt(p2),pow(p3,1.0/3.0),max);

    return 0;
}

Measured memory_bytes: 696
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println(n * n - in.nextInt());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

const int MAX_V = 10;
int d[MAX_V][MAX_V]; // 重み付き隣接行列
					 // ワーシャルフロイドではこれを更新していく
					 // 最初、辺がない場合はINFで初期化
					 // d[i][j] : iからjまでの最短距離
const int V = 10;

void warshall_floyd() {
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int H, W;

void input() {
	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i][j];
		}
	}
	warshall_floyd();
}

void solve() {
	ll ans = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int a;
			cin >> a;
			if (a != -1) {
				ans += d[a][1];
			}
		}
	}

	cout << ans << endl;
}

int main() {
	input();
	solve();

	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; ++i)
    {
        int temp;
        cin >> temp;
        if (i % 2 == 1 && temp % 2 == 1)
        {
            ++ans;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
 
int a = 0, b = 0, c = 0,k = 0;
int x = 0;
vector<string> strs;
pair<pair<string, int>, int> p[100];

int main() {

	int n = 0;

	cin >> n;


	for (int i = 0; i < n; i++) {
		string a;
		int b, c;

		cin >> a >> b;

		p[i] = make_pair(make_pair(a, -b), i+1);

	}

	sort(p, p + n);

	for (int i = 0; i < n; i++) {
		if (i < n - 1) {
			cout << p[i].second << endl;
		}
		else {
			cout << p[i].second;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a,b,c,k; 
int main()
{
	 cin>>a>>b>>c>>k;
	 ll ans;
	 if(k<=a)cout<<k;
	 else 
	    if(k<=a+b) cout<<a;
	    else
	      cout<<a-(k-a-b);



return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};

signed main() {
  int n,m;cin>>n>>m;
  int a[31];rep(i,31)a[i] = 0;
  rep(i,n){
    int k;cin>>k;
    rep(j,k){
      int aa;cin>>aa;a[aa]++;
    }
  }
  int ans = 0;
  repd(i,1,m+1)if(a[i] == n)ans++;
  cout << ans << endl;
}


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

int N, K;
ll s, p, r;
string T;

int main() {
    cin >> N >> K;
    cin >> s >> p >> r;
    cin >> T;

    ll ans = 0;
    for (int i = 0; i < K; i++) {
        bool f = false;
        for (int j = i; j < N; j += K) {
            if (!f) {
                if (T[j] == 's') ans += s;
                else if (T[j] == 'p') ans += p;
                else ans += r;
            }

            if (!f && j < N - K) {
                if (T[j] == T[j+K]) f = true;
                else f = false;
            }
            else f = false;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import numpy as np
 
def main(N, H):
    INF = 1000000
    dp = [INF for i in range(N)]
    dp[0] = 0
    dp[1] = abs(H[1]-H[0])
    
    for i in range(2, N):
        dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2]))
    
    print(dp[-1])
    
if(__name__ == "__main__"):
    N = int(input())
    H = [int(h) for h in input().split()]
    
    main(N, H)

Measured memory_bytes: 23120