akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

const int nil = -1;

struct Node
{
  int p;
  int lc;
  int rc;
  int dep;
  int ht;
};

  
class BinaryTrees
{
public:
  int n;
  Node nds[25];
  int solve();
  int sibling( int id );
  int root();
  int setDepth( int id, int d );
  int degree( int id );
  string nodetype( int id );
  int setHeight( int id );
};

int BinaryTrees::setHeight( int id )
{
  if ( degree( id ) == 0 )
    {
      nds[id].ht = 0;
      return 0;
    }

  if ( nds[id].lc != nil )
    setHeight( nds[id].lc );

  if ( nds[id].rc != nil )
    setHeight( nds[id].rc );

  if ( nds[id].lc == nil )
    nds[id].ht = nds[nds[id].rc].ht + 1;
  else if ( nds[id].rc == nil )
    nds[id].ht = nds[nds[id].lc].ht + 1;
  else
    nds[id].ht = max( nds[nds[id].lc].ht, nds[nds[id].rc].ht ) + 1;
  
  return 0;
}

string BinaryTrees::nodetype( int id )
{
  if ( nds[id].p == nil )
    return "root";
  else if ( degree( id ) == 0 )
    return "leaf";
  else
    return "internal node";
}

int BinaryTrees::degree( int id )
{
  int ret = 0;
  if ( nds[id].lc != nil )
    ++ret;
  if ( nds[id].rc != nil )
    ++ret;
  return ret;
}

int BinaryTrees::setDepth( int id, int d )
{
  nds[id].dep = d;

  if ( nds[id].lc != nil )
    setDepth( nds[id].lc, d + 1 );
  if ( nds[id].rc != nil )
    setDepth( nds[id].rc, d + 1 );

  return 0;
}

int BinaryTrees::root()
{
  for ( int i = 0; i < n; ++i )
    if ( nds[i].p == nil )
      return i;

  return nil;
}

int BinaryTrees::sibling( int id )
{
  if ( nds[id].p == nil )
    return nil;
  if ( nds[nds[id].p].lc == id )
    return nds[nds[id].p].rc;
  if ( nds[nds[id].p].rc == id )
    return nds[nds[id].p].lc;
  return nil;
}

int BinaryTrees::solve()
{
  cin >> n;

  int id;
  int l,r;

  for ( int i = 0; i < n; ++i )
    {
      nds[i].p = nil;
      nds[i].lc = nil;
      nds[i].rc = nil;
      nds[i].dep = 0;
      nds[i].ht = 0;
    }

  for ( int i = 0; i < n; ++i )
    {
      cin >> id >> l >> r;
      nds[id].lc = l;
      nds[id].rc = r;
      if ( l != nil )
        nds[l].p = id;
      if ( r != nil )
        nds[r].p = id;
    }

  setDepth( root(), 0);
  setHeight( root() );
  
  for ( int i = 0; i < n; ++i )
    {
      cout << "node " << i << ": parent = " << nds[i].p << ", ";
      cout << "sibling = " << sibling( i ) << ", ";
      cout << "degree = " << degree( i ) << ", ";
      cout << "depth = " << nds[i].dep << ", ";
      cout << "height = " << nds[i].ht << ", ";
      cout << nodetype( i );
      cout << endl;
    }
  
  return 0;
}

int main()
{

  BinaryTrees bt;

  bt.solve();

  return 0;
}

Measured memory_bytes: 1204
import java.io.*;
import java.util.*;
class   Main       {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = in.nextInt();
		int k=in.nextInt();
		int arr[] = new int[100001];
		arr=in.nextIntArray(n);
		int MAX=maximum(arr);
		int gcd=solve(arr);
		if(k%gcd==0&&k<=MAX)
			System.out.println("POSSIBLE");
		else
			System.out.println("IMPOSSIBLE");
		//w.println(n);
		w.close();
		sc.close();
	}
	public static int gcd(int a,int b)
	{
		    if (a == 0)
		        return b;
		    return gcd(b%a, a);
		
	}
	public static int solve(int []arr)
	{
		int result = arr[0];
	    for (int i=1; i<arr.length; i++)
	        result = gcd(arr[i], result);
	 
	    return result;
	}
	public static int maximum(int []arr)
	{
		int ans=0;
		for(int i=0;i<arr.length;i++)
		{
			if(ans<arr[i])
				ans=arr[i];
		}
		return ans;
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

Measured memory_bytes: 22868
S['= r'],m[4]['= r'],W,z,d[4]={1,-1},k,i;f(i){m[k][i]=S[i]+47?0:m[k][i]?:1+f(i+d[k]);}main(t){for(d[2]-=d[3]=scanf("%*d%d ",&W)+W;S[i-~W]=~getchar();++i);for(;i--;z=fmax(z,t))for(t=k=0;k<4;++k)t+=f(i-~W);printf("%d",z-3);}

Measured memory_bytes: 78464
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

N, M, K = map(int, input().split())

p = 998244353


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


def pow_k(x, n, p):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
            K %= p
        x *= x
        x %= p
        n //= 2

    return K * x % p


fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


ans = 0
for i in range(K + 1):
    po = pow_k(M-1, N-i-1, p)
    tmp = po * M % p
    tmp = tmp * cmb(N-1, i, p) % p
    ans = (ans + tmp) % p

print(ans)


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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    bool used1[26] = {}, used2[26] = {};
    for (int j = 0; j <= i; j++) {
      used1[S[j] - 'a'] = 1;
    }
    for (int j = i + 1; j < N; j++) {
      used2[S[j] - 'a'] = 1;
    }

    int tmp = 0;
    for (int j = 0; j < 26; j++) {
      tmp += (used1[j] && used2[j]);
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
# print('N=', N, 'K=', K, 'Q=', Q)

participant_list = [K-Q] * N
# print(participant_list)

for i in range(Q):
    participant_list[int(input())-1] += 1
    
for i in participant_list:
    if i <= 0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 6620
function main()
    D, G = map(x -> parse(Int, x), split(readline()))
    p, c = zeros(Int, (D,)), zeros(Int, (D,))
    for i in 1:D
        p[i], c[i] = map(x -> parse(Int, x), split(readline()))
    end
    ans = 1000
    for i in 0:((1 << D)-1)
        mxid = -1
        res = 0
        cnt = 0
        for j in 0:D-1
            if ((i >> j) & 1) > 0
                res += 100*(j+1)*p[j+1] + c[j+1]
                cnt += p[j+1]
            else
                mxid = j+1
            end
        end
        if res >= G
            ans = min(ans, cnt)
        elseif res + 100*mxid*(p[mxid]-1) >= G
            ans = min(ans, cnt+(G-res-1)÷(100*mxid)+1)
        end
    end
    print("$ans\n")
end

main()


Measured memory_bytes: 114468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    ll t[2];
    rep(i, 2) cin >> t[i];
    ll a[2], b[2];
    rep(i, 2) cin >> a[i];
    rep(i, 2) cin >> b[i];
    
    // youtube解説
    
    rep(i, 2) {
        a[i] *= t[i];
        b[i] *= t[i];
    }
    
    if (a[0] + a[1] == b[0] + b[1]) {
        cout << "infinity" << endl;
        return 0;
    }
    
    if (a[0] + a[1] < b[0] + b[1]) {
        swap(a[0], b[0]);
        swap(a[1], b[1]);
    }
    
    if (a[0] > b[0]) {
        cout << 0 << endl;
        return 0;
    }
    
    ll c = a[0] - b[0];
    ll d = (a[0] + a[1]) - (b[0] + b[1]);
    c = -c;
    
    if (c % d == 0) {
        cout << c / d * 2 << endl;
    } else {
        cout << c / d * 2 + 1 << endl;
    }
}

/*
 1 1
 2 6
 4 2
 
 2
 
 */


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

using namespace std;

int main()
{
	//Ball(xi, i), A(0,i), B(K,i) A = N, B = N;
  int N, K, x[N];
  cin >> N >> K;
  int sum = 0;
  
  for(int i = 0; i < N; i++){
    cin >> x[i];
    if(K < x[i])
      sum += (x[i]-K)*2;
    else if ((x[i] < K) && ((K-x[i]) < x[i]))
      sum += (K-x[i])*2;
    else
      sum += x[i]*2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
# n, k = map(int, input().split())
# from collections import OrderedDict
# d = OrderedDict()
# a = list(input().split())
b = list(map(int, input().split()))
# print(r + max(0, 100*(10-n)))
# print("Yes" if 500*n >= k else "No") 
# s = input()
# a = int(input())
# b = int(input())
# c = int(input())
# s = input()
print(b[-1], *b[:2])

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

const vector<int> coin{10, 50, 100, 500};

void solve(int n) {
    vector<int> cnum(4);
    vector<int> ans(4, 0);
    vector<int> csum(4, 0);

    int coinnum = 0, sum = 0;
    for(int i=0; i<4; ++i) {
        cin >> cnum[i];
        coinnum += cnum[i];
        csum[i] = cnum[i] * coin[i];
        sum += csum[i];
    }

    int ret = sum - n;
    for(int i=3; i>=0; --i) {
        int buf = ret / coin[i];
        ret %= coin[i];
        ans[i] = cnum[i] - buf;
    }
    for(int i=0; i<4; ++i)
        if(ans[i]>0) cout << coin[i] << " " << ans[i] << endl;
}

int main()
{
    int n;
    int f = 0;
    while(cin>>n, n) {
        if(f!=0) cout << endl;
        f++;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 3036
// abc126_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;

    UnionFind(int N) : par(N), rank(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {par[i] = i; rank[i] = 0;}
    }

    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        if(rank[rx] < rank[ry]) { // root が rx の木の方が root が ry の木よりも低い
            par[rx] = ry; // root ry に rx の木をつなぐ
        } else {
            par[ry] = rx; // root rx に ry の木をつなぐ
            if(rank[rx] == rank[ry]) ++rank[rx]; // 同じ高さだったならばまとめたことによって高さ +1
        }
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;
    int x, y, z;
    auto uf = UnionFind(2 * N);
    REP(i, M) {
        cin >> x >> y >> z; x--; y--;
        uf.unite(x, y);
    }

    set<int> st;
    REP(i, N) {
        st.insert(uf.find(i));
    }

    print(st.size());

    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);

    int X; cin >> X;
    int ans = 0;
    while ((ans * (ans + 1)) / 2 < X)
        ans++;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


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

    int res = -1;
    for(int i = 0; i < 10000; i++){
        if((i * 108 - i * 100) / 100 == a && (i * 110 - i * 100) / 100 == b){
            res = i;
            break;
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')

	if text == "ABC\n" {
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}


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

using namespace std;

string reverse(const string &s,int a, int b)
{
  string r = "";
  r = s;
  string rev = "";
  for(int i = b;i >= a ; i--)
  {
    rev+= r[i];
  }
  rev = r.replace(a,b-a+1,rev);
  return rev;
}
int main()
{
  string str;
  int a;
  string order;
  string repl;
  string cpy;
  int onum[2];
  cin >> str;
  cin >> a;
  for(int i = 0 ; i < a ; i ++ )
  {
    cin >> order;
    cin >> onum[0] >> onum[1];
    if(order == "print")cout << str.substr(onum[0],onum[1] - onum[0] + 1)<<endl;
    else if(order == "replace")
    {
      cin >> repl;
      cpy = str.replace(onum[0],onum[1]- onum[0] + 1,repl);
      str = cpy;
    }
    else if(order == "reverse")
    {
      str = reverse(str,onum[0],onum[1]);
    }
  }
  return 0;
}


Measured memory_bytes: 3212
n,k=map(int,input().split())
r,s,p=map(int,input().split())
l=list(input())

m=0
ll=[]
for i in range(len(l)):
    if k<=i:
        if l[i]=="r" and ll[i%k]!=l[i]:
            m+=p
            ll[i%k]="r"
        elif l[i]=="r" and ll[i%k]==l[i]:
            ll[i%k]="."

        elif l[i]=="s" and ll[i%k]!=l[i]:
            m+=r
            ll[i%k]=("s")
        elif l[i]=="s" and ll[i%k]==l[i]:
            ll[i%k]=(".")
            
        elif l[i]=="p" and ll[i%k]!=l[i]:
            m+=s
            ll[i%k]=("p")
        elif l[i]=="p" and ll[i%k]==l[i]:
            ll[i%k]=(".")

    else:
        if l[i]=="r":
            m+=p
            ll.append("r")
        elif l[i]=="s":
            m+=r
            ll.append("s")
        elif l[i]=="p":
            m+=s
            ll.append("p")

print(m)

Measured memory_bytes: 4660
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

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

    auto b = prime_factor(N);

    ll ans = 0;
    for (auto n : b)
    {
        ll m = n.second;
        ll sum = 0;
        ll j = -1;
        for (ll i = 1; i <= 1000000; i++)
        {
            sum += i;
            if (sum > m)
            {
                j = i - 1;
                break;
            }
        }
        ans += j;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if (a%2==1&&b%2==1){
        cout << "Odd" << endl;
    }
    else{
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize ("Ofast")

using namespace std;
#define ms(x,a) memset(x,a,sizeof x)
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7,seed=131,MAXN=0;

int main(){
    cin.tie(0)->sync_with_stdio(0);
    string a, b;
    cin >> a >> b;
    int cnt=0;
    for (int i=0;i<a.size();++i) if (a[i]!=b[i]) cnt++;
    cout << cnt << '\n';
}

Measured memory_bytes: 3732
n = int(input())

ts = 0
hs = 0
for i in range(n):
    c = list(input().split())
    if c[0] > c[1]:
        ts += 3
    elif c[0] < c[1]:
        hs += 3
    else:
        ts += 1
        hs += 1

print(ts, hs)


Measured memory_bytes: 5592
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    
    if op == "?":
        break
    elif op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[1000][5][5][5];
//main
signed main(){
  int N;cin>>N;
  memset(dp,0,sizeof(dp));
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        dp[3][i][j][k]=1;
      }
    }
  }
  for(int i=4;i<=N;i++){
    for(int j=0;j<4;j++){
      for(int k=0;k<4;k++){
        for(int l=0;l<4;l++){
          for(int m=0;m<4;m++){
            dp[i][j][k][l]+=dp[i-1][m][j][k];
          }
          if(j==1&&k==2)dp[i][j][k][l]-=dp[i-1][0][1][2];
          if(j==0&&k==2)dp[i][j][k][l]-=dp[i-1][1][0][2];
          if(j==2&&k==1)dp[i][j][k][l]-=dp[i-1][0][2][1];
          if(l==2){
            if(k==1&&j!=2){
              dp[i][j][k][l]-=dp[i-1][0][j][k];
            }
            if(j==1&&k!=2){
              dp[i][j][k][l]-=dp[i-1][0][j][k];
            }
            if(k==1&&j==1)dp[i][j][k][l]+=dp[i-1][0][j][k];
          }
          dp[i][j][k][l]%=MOD;dp[i][j][k][l]+=MOD;dp[i][j][k][l]%=MOD;
        }
      }
    }
  }
  int ans=0;
  for(int j=0;j<4;j++){
    for(int k=0;k<4;k++){
      for(int l=0;l<4;l++){
        ans+=dp[N][j][k][l];
      }
    }
  }
  ans-=dp[N][0][1][2];
  ans-=dp[N][1][0][2];
  ans-=dp[N][0][2][1];
  ans%=MOD;ans+=MOD;ans%=MOD;
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main(void){
  int n,k;
  cin >> n >> k;
  vector<char> vec(n);
  rep(i,n) {
    cin >> vec.at(i);
  }
  if(vec.at(k-1) == 'A'){
    vec.at(k-1) = 'a';
  } else if(vec.at(k-1) == 'B') {
    vec.at(k-1) = 'b';
  }else if(vec.at(k-1) == 'C') {
    vec.at(k-1) = 'c';
  }
  rep(i,n) {
    cout << vec.at(i);
  }
  return 0;
}

Measured memory_bytes: 256
/*===================*\
|ID : harryPotter_421  |
|      LANG: C++       |
\*====================*/
#include <iostream>
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define f(j,m,n) for(lli j=m;j<n;j++)
#define harry ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
   {harry
    lli n,k;
    cin>>n>>k;
    lli arr[n+1],dp[n+1];
    for(int i=1;i<=n;i++)
         cin>>arr[i];
    dp[1]=0;
    lli mini=INT_MAX;
    for(int i=2;i<=n;i++)
        {dp[i]=INT_MAX;
            for(int j=1;j<=k;j++)
              {if(i-j>=1)
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
               }


        }
        cout<<dp[n];


   }

















Measured memory_bytes: 1792
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  char s[10001];
  scanf("%d", &n);
  scanf("%s", s);
  int l = strlen(s);
  for (int i=0; i<l; i++) {
    if (s[i]-'A'+n < 26) printf("%c", s[i] + n);
    else printf("%c", s[i] + n - 26);
  }
  printf("\n");
  return 0;
}


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

using ll = long long;

static ll const P = 998244353;

template<typename INT, INT P>
class Modulo {
  INT val;

  friend
  std::ostream&
  operator<<(std::ostream& os, Modulo const& m) {
    return os << m.val;
  }

  friend
  Modulo<INT, P>
  operator*(Modulo<INT, P> const& a, Modulo<INT, P> const& b) {
    return a.val * b.val;
  }

  static std::vector<INT> _facts;

public:
  Modulo(INT v) : val(v % P) {};

  Modulo<INT, P>& operator+=(Modulo<INT, P> const& other) {
    val += other.val;
    val %= P;
    return *this;
  }

  static INT facts(size_t n) {
    auto s = _facts.size();
    if (s < n+1) {
      _facts.resize(n+1);
      for (size_t i=s; i<n+1; i++) {
        if (i==0) {
          _facts[0] = 1;
        } else {
          _facts[i] = (_facts[i-1] * i) % P;
        }
      }
    }
    return _facts[n];
  }
};

template<typename INT, INT P>
std::vector<INT> Modulo<INT, P>::_facts;

template <typename INT, INT P>
Modulo<INT, P>
power(INT a, INT b) {
  if (b == 0) {
    return 1;
  }

  if (b % 2 == 0) {
    auto d = power<INT, P>(a, b/2);
    return d*d;
  }

  return a * power<INT, P>(a, b-1);
}

template <typename INT, INT P>
Modulo<INT, P>
comb(INT n, INT k) {
  if (n<0 || k<0 || n<k) return 0;
  if (n==0 || k==0) return 1;

  auto a = Modulo<INT, P>::facts(n);
  auto b = Modulo<INT, P>::facts(k);
  auto c = Modulo<INT, P>::facts(n-k);

  return a * power<INT, P>(b, P-2) * power<INT, P>(c, P-2);;
}

int main() {
  ll N, A, B, K;

  std::cin >> N;
  std::cin >> A;
  std::cin >> B;
  std::cin >> K;

  Modulo<ll, P> ans(0);

  for (ll a=0; a<N+1; a++) {
    if (K >= A * a && (K - A * a) % B == 0) {
      ll b=(K - A * a) / B;
      if (b>N) continue;
      auto c=comb<ll, P>(N, a);
      auto d=comb<ll, P>(N, b);
      // std::cout << N << 'C' << a << '=' << c << std::endl;
      // std::cout << N << 'C' << b << '=' << d << std::endl;
      ans += (c*d);
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

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

    int sum;
    while(1)
    {
        if(c % a == 0) sum++;
        if(a >= b) break;
        a++;
    }

    printf("%d\n", sum);
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

double dp[3030][3030];


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<double> a(N);
    REP(i,N) cin >> a[i];
    dp[0][0] = 1.0;
    REP(i,N){
        REP(j,i+1){
            dp[i+1][j+1] += dp[i][j] * a[i];
            dp[i+1][j] += dp[i][j] * (1 - a[i]);
        }
    }
    double ans = 0.0;
    for(int i = N; i >= N/2+1; --i) ans += dp[N][i];
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 70400
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;

int S[200000];

signed main()
{
    int N; scanf("%d", &N);

    rep(i, N) scanf("%d", &S[i]);

    int ma = 0;

    for (int i = 1; i <= N; ++i) {
        if (N % i == 0) {
            for (int j = i; j < N; j += i) {
                for (int k = 0; k < i; ++k) {
                    if (S[k] != S[j + k]) goto nxt;
                }
            }

            chmax(ma, N / i);
            break;
nxt:;
        }
    }

    printf("%d\n", ma);
}

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

int main() {
  long long k,l;
  cin >> k;
  queue<long long>store;
  for (int i = 1; i < 10; i++) {
    store.push(i);
  }
  
  for (int i=0; i < k; i++) {
    l = store.front();
    store.pop();

    if (l%10 == 0) {
      store.push(l*10);
      store.push(l*10+1);
    }
    else if (l%10 == 9) {
      store.push(l*10+8);
      store.push(l*10+9);
    }
    else {
      store.push(l*10+l%10-1);
      store.push(l*10+l%10);
      store.push(l*10+l%10+1);
    }
  }
  cout << l << endl;
}

Measured memory_bytes: 5068
#include<cstring>
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
ll in[200007];
int main()
{	
 	int n;
 	scanf("%d",&n);
 	for(int i=1;i<=n;i++)
 	{
 		scanf("%lld",&in[i]);
 		in[i]=in[i]-i;
	 }
	 sort(in+1,in+1+n);
	 ll b=in[(n+1)/2];
	 ll ans=0;
	 for(int i=1;i<=n;i++)
	 {
	    ans+=abs(in[i]-b);
	 }
	 printf("%lld\n",ans);
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!
    val Q = readLine()!!.toInt()

    val s = S.toCharArray()

    val t = mutableMapOf<Char, TreeSet<Int>>()
    for(i in 0 until 26){
        t['a' + i] = sortedSetOf()
    }
    for(i in s.indices){
        t[s[i]]!!.add(i)
    }

    repeat(Q){
        val q = readLine()!!.split(" ")
        if(q[0] == "1"){
            val i = q[1].toInt() - 1
            val c = q[2][0]
            t[s[i]]!!.remove(i)
            s[i] = c
            t[c]!!.add(i)
        }else{
            val l = q[1].toInt() - 1
            val r = q[2].toInt() - 1
            (0 until 26)
                .filter { i ->
                    val p = t['a' + i]!!.higher(l - 1) ?: N
                    p <= r
                }
                .count()
                .let { println(it) }
        }
    }
}


Measured memory_bytes: 96504
sa = list(input())
sb = list(input())
sc = list(input())

d = 'a'
cnta = 0
cntb = 0
cntc = 0
A = len(sa)
B = len(sb)
C = len(sc)

while 1:
    if d == 'a':
        cnta += 1
        if cnta == A+1:
            print('A')
            break
        d = sa.pop(0)
    elif d == 'b':
        cntb += 1
        if cntb == B+1:
            print('B')
            break
        d = sb.pop(0)
    else:
        cntc += 1
        if cntc == C+1:
            print('C')
            break
        d = sc.pop(0)

Measured memory_bytes: 3064
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int arr[210000];
int brr[210000][2];
queue<int>qu[210000];
bool crr[210000];
map<pair<int,int>,int>mp;
pair<int,int>pa;
void fff(int a,int c){
	int n=qu[a].size();
	int count=1;
	for(int i=0;i<n;i++){
		int p=qu[a].front();
		qu[a].pop();
		if(!crr[p]){
			crr[p]=1;
			if(c==count){
				count++;
			}
			pa.first=a;
			pa.second=p;
			mp[pa]=count;
			pa.first=p;
			pa.second=a;
			mp[pa]=count;
			fff(p,count);
			count++;
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		sfdd(brr[i][0],brr[i][1])
		arr[brr[i][0]]++;
		arr[brr[i][1]]++;
		qu[brr[i][0]].push(brr[i][1]);
		qu[brr[i][1]].push(brr[i][0]);
	}
	int max=0;
	int maxi;
	for(int i=0;i<n;i++){
		if(arr[i]>max){
			max=arr[i];
			maxi=i+1;
		}
	}
	cout<<max<<endl;
	crr[maxi]=1;
	fff(maxi,0);
	for(int i=1;i<n;i++){
		pa.first=brr[i][0];
		pa.second=brr[i][1];
		pfd(mp[pa])
		pfn
	}
}

Measured memory_bytes: 157952
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

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

    vector<int>v(n);
    vector<int>c(n);

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

    int sum = 0;
    for(int i = 0; i < n; i++){
        if(v[i] > c[i]){
            sum += (v[i] - c[i]);
        }
    }
    printf("%d\n",sum);


    return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <cstdlib>
using namespace std;
using ll = long long int;

int main()
{
    int N;
    cin >> N;
    if (N == 1)
        cout << "Hello World" << endl;
    if (N == 2) {
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    int n,x,y=0,z=0;
    boolean a;
    String b;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\\s");
        while(a == false){
            n = sc.nextInt();
            x = sc.nextInt();
            if(n == 0 && x == 0){
                a = true;
                break;
            }
            for(int s1 = 1;s1 <= n-2; s1++){
                for(int s2 = s1+1;s2 <= n-1; s2++){
                    for(int s3 = s2+1;s3 <= n; s3++){
                        if(s1 + s2 + s3 == x){
                            z++;
                        }
                    }
                }
            }
            System.out.println(z);
            z = 0;
        }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 19800
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();

    if (N % 500 <= A) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

Measured memory_bytes: 23380
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    ll b_cnt = 0, ans = 0;
    //ある白石に対して，その左側にある黒石の数だけ入れ替えが発生する
    for(int i = 0; i < n; i++){
        if(s[i] == 'B') b_cnt++;
        else{
            ans += b_cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
main = do
  li <- getLine
  let c = read $ last $ words li
  li <- getLine
  let bs = map read $ words li
  co <- getContents
  let ass = map (map read . words) $ lines co
  print $ compute c bs ass

compute :: Int -> [Int] -> [[Int]] -> Int
compute c bs ass = length [() | as <- ass, sum (zipWith (*) bs as) > negate c]

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

int main()
{
  unsigned long N;
  unsigned long ans;
  cin >> N;
  
  ans = N - 1;
  for (unsigned long a = 2; a <= long(sqrt(N) + 1e-9); a++) {
    unsigned long b = N / a;
    if ((a * b == N) && (ans > (a - 1) +(b-1))) {
      ans = (a - 1) + (b - 1);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(void)
{
    int a;  // 時針の長さ(cm), 1 <= a <= 1000
    int b;  // 分針の長さ(cm), 1 <= a <= 1000
    int h;  // 0 <= h <= 11
    int m;  // 0 <= m <= 59
    std::cin >> a;
    std::cin >> b;
    std::cin >> h;
    std::cin >> m;

    // (h_x - m_x)^2 + (h_y - m_y)^2 = d^2
    const double theta_m = m / 60.0 * (2 * M_PI);
    const double m_x = b * cos(theta_m);
    const double m_y = b * sin(theta_m);

    const double theta_h = ((h / 12.0) + (m / 60.0) / 12.0) * (2 * M_PI);
    const double h_x = a * cos(theta_h);
    const double h_y = a * sin(theta_h);

    const double d = sqrt((h_x - m_x) * (h_x - m_x) + (h_y - m_y) * (h_y - m_y));
    // std::cout << d << std::endl;
    printf("%.16f", d);

    return 0;
}


Measured memory_bytes: 4092
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        int n = Convert.ToInt32( Console.ReadLine() );
        var a = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt64 );

        //--------------------------------solve--------------------------------//

        int so=0;
        foreach(int i in a)
            if(i<=0) so++;
        var b=a.Select(x=>Math.Abs(x)).ToList();
        if(so%2==0)
            Console.WriteLine(b.Sum());
        else Console.WriteLine(b.Sum()-2*b.Min());
    }




}

Measured memory_bytes: 31452
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	const unsigned int M = 1000000007;
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll sum=0;
	ll ans=0;
	for(ll i=0;i<n-1;i++)
	{
		sum=(sum%M+a[i]%M)%M;
		ans=(ans%M+(sum*(a[i+1])%M)%M)%M;
	}
	cout<<ans%M;

	return 0;
}

Measured memory_bytes: 5148
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
    N,K = map(int,input().split())
    MOD = 10**9+7
    
    a = [list(map(int,input().split())) for _ in range(N)]
    arr = np.array(a,dtype=object)

    use = np.eye(N,dtype=object)
    while K>0:
        if K&1:
            use = np.dot(use,arr)%MOD
        arr = np.dot(arr,arr)%MOD
        K //= 2

    print(np.sum(use)%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 12448
#include<iostream>
#include<algorithm>
#include<string.h>
#include<queue>
#include<cassert>

using namespace std;
typedef long long ll;

static const int MAX_N = 2000;
static const int MAX_C = 1000000000;

int w, H, N;
ll X1[MAX_N], X2[MAX_N], Y1[MAX_N], Y2[MAX_N];

int G[MAX_N*4+1][MAX_N*4+1];


vector<ll> compress(ll *c1, ll *c2){
  vector<ll> xs;

  for ( int i = 0; i < N; i++ ){
    for ( int d = 0; d <= 1; d++ ){
      int tx1 = c1[i] + d;
      int tx2 = c2[i] + d;
      xs.push_back(tx1);
      xs.push_back(tx2);
    }
  }
  xs.push_back(MAX_C+1);

  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());

  for ( int i = 0; i < N; i++ ){
    c1[i] = find(xs.begin(), xs.end(), c1[i]) - xs.begin();
    c2[i] = find(xs.begin(), xs.end(), c2[i]) - xs.begin();
  }

  return xs;
}

int main(){
  cin >> N;
  for ( int i = 0; i < N; i++ ){
    cin >> X1[i] >> Y1[i] >> X2[i]>> Y2[i];
    assert( X1[i] < X2[i]);
    assert( Y1[i] < Y2[i]);
  }

  vector<ll> X = compress(X1, X2);
  vector<ll> Y = compress(Y1, Y2);

  memset(G, 0, sizeof(G));

  for ( int i = 0; i < N; i++ ){
    G[Y1[i]][X1[i]]++;
    G[Y2[i]][X2[i]]++;
    G[Y1[i]][X2[i]]--;
    G[Y2[i]][X1[i]]--;
  }
 for ( int y = 0; y < Y.size()-1; y++ ){
    for ( int x = 1; x < X.size()-1; x++ ){
      G[y][x] += G[y][x-1];
    }
  }
  for ( int x = 0; x < X.size()-1; x++ ){
    for ( int y = 1; y < Y.size()-1; y++ ){
      G[y][x] += G[y-1][x];
    }
  }

  ll area = 0;
  for ( int y = 0; y < Y.size()-1; y++ ){
    for ( int x = 0; x < X.size()-1; x++ ){
      if ( G[y][x] )
        area += (X[x+1]-X[x])*(Y[y+1]-Y[y]);
    }
  }

  cout << area << endl;

  return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS

    int n,k;
    cin>>k>>n;
    if (k>10) cout<<n<<endl;
    else cout<<n+100*(10-k)<<endl;
}



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

#pragma GCC optimize("02")
#pragma GCC target("tune=native")

using namespace std;

#define ll long long int
#define lu unsigned long long int
#define fi first
#define se second
#define edge pair<long long int,long long int>
#define weighted_edge pair<long long int,pair<long long int,long long int>>

bool matrix[101][101];

int main() {

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

	int w,h,n; cin >> w >> h >> n;

	int x,y,a;

	while(n--) {
		
		cin >> x >> y >> a;

		if(a == 1) {
			for(int i = 1; i <= h; i++) {
				for(int j = 1; j <= x; j++) {
					matrix[i][j] = 1;
				}
			}
		}
		else if(a == 2) {
			for(int i = 1; i <= h; i++) {
				for(int j = x+1; j <= w; j++) {
					matrix[i][j] = 1;
				}
			}
		}
		else if(a == 3) {
			for(int i = 1; i <= y; i++) {
				for(int j = 1; j <= w; j++) {
					matrix[i][j] = 1;
				}
			}	
		}
		else {
			for(int i = y+1; i <= h; i++) {
				for(int j = 1; j <= w; j++) {
					matrix[i][j] = 1;
				}
			}
		}
	}

	int ans = 0;

	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			if(!matrix[i][j])ans++;
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
<?php
$str = "#.";
while (true) {
        fscanf(STDIN,"%d %d",$h,$w);
        if ($h === 0 && $w === 0) break;
        for ($i = 0; $i < $h; $i++) {
                for ($j = 0; $j < $w; $j++) {
                        echo $str[($i+$j)%2];
                }
                echo PHP_EOL;
        }
        echo PHP_EOL;
}

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

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

min_, max_ = map(int, input().split())

for _ in range(M-1):
    LL, MM = map(int, input().split())
    min_ = max(min_, LL)
    max_ = min(max_, MM)


if min_ <= max_:
    print(max_ - min_ + 1)
else:
    print(0)

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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pi 3.1415926535
#define mod1 1000000007
#define mod2 1000000009
#define no_of_digits(n) floor(log10(n)) + 1
#define lcm(a, b) (a/__gcd(a,b)*b

using namespace std;





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

	char c;
	cin >> c;
	cout << (char)(c+1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	int a; map<int,int> cnt;
	rep(i,0,N){ cin>>a; cnt[a]++; }
	int ans = 0;
	for(pair<int,int> p:cnt){
		if(p.first > p.second) ans += p.second;
		else ans += p.second - p.first;
	}cout<<ans<<endl;
}

Measured memory_bytes: 4736
import std.stdio : readf, readln, writeln;
import std.string;
import std.array;
import std.conv;

void main() {
  int[] v;
  v = readln.split.to!(int[]);
  int H = v[0];
  int W = v[1];
  string[] s;
  for (int i=0; i<H; i++)
    s ~= readln.chomp;
  int[][] dw;
  int[][] dh;
  for (int i = 0; i < H; i++) {
    int[] cw;
    int count = 0;
    for (int j = 0; j < W; j++) {
      if (s[i][j] == '#') {
          cw ~= 0;
      }
      else if (j == 0 || s[i][j - 1] == '#') {
        count = 0;
        for (int k = j; k < W; k++) {
          if (s[i][k] == '.') {
            count++;
          }
          else {
            break;
          }
        }
        cw ~= count;
      }
      else {
        cw ~= count;
      }
    }
    dw ~= cw;
  }
  for (int j = 0; j < W; j++) {
    int[] ch;
    int count = 0;
    for (int i = 0; i < H; i++) {
      if (s[i][j] == '#') {
        ch ~= 0;
      }
      else if (i == 0 || s[i - 1][j] == '#') {
        count = 0;
        for (int k = i; k < H; k++) {
          if (s[k][j] == '.') {
            count++;
          }
          else {
            break;
          }
        }
        ch ~= count;
      }
      else {
        ch ~= count;
      }
    }
    dh ~= ch;
  }
  int max = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int sum = dw[i][j] + dh[j][i];
      if (max < sum) {
        max = sum;
      }
    }
  }
  writeln(max - 1);
}


Measured memory_bytes: 40700
#include<stdio.h>

int main (void){
        int a,b,n,k = 0;

        scanf("%d",&n);

        b = n;
        do{
        a = b % 10;
        k = k + a;
        b = b / 10;
        }while(b);


        if (n % k == 0){
        puts("Yes");
        }else {
        puts("No");
        }
        return 0;

}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
 		String input = null;
      
        try {
            input = br.readLine();
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
      
		int len = input.length();
        String ret = "";
      
      	for (int i = 0; i < len; i++){
          ret = ret + "x";
        }
      
        System.out.println(ret);
    }
 
}


Measured memory_bytes: 21204
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int a[200005],b[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(i+a[i]<=n)
            b[a[i]+i]++;
        if(i-a[i]>=0)
            ans+=b[i-a[i]];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4636