akhauriyash/Code-Regression huggingface dataset:
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	string x,l;
	cin >> x>>l;
	 reverse(x.begin(), x.end());
	if (x ==l )
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;




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

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N; cin>>N;
  char t1=' ',t2=' ';
  bool flag=false;//続けばtrue:カウントしない
  int ans = 1;
  cin>>t1;
  for(int i=0;i<N-1;i++){
    cin>>t2;
    if(t1!=t2){
      ans++;
      t1 = t2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<cstring>
#include<algorithm>
#include<cstdio>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
typedef long long LL;
typedef double dob;
using namespace std;
const int P=1000000007;
const int N=100010;
int n,x[N],d[N],di[N],pi[N],f[N],ans;
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",x+i);
	rep(i,1,n-1) d[i]=x[i+1]-x[i];
	pi[0]=1;
	rep(i,1,n) pi[i]=(LL)pi[i-1]*i%P;
	di[n]=1;
	per(i,n-1,1) di[i]=(LL)di[i+1]*i%P;
	rep(i,1,n-1){
		f[i]=((LL)f[i-1]*i%P+pi[i-1])%P;
	}
	rep(i,1,n-1){
		ans=(ans+((LL)d[i]*f[i]%P*di[i+1])%P)%P;
	}
	ans=(ans%P+P)%P;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    int result = 0;
    
    if( c / ( a * 7 ) <= 0 ){
        if( c % a == 0 ){
            result = c / a;
        }else{
            result = c / a + 1;
        }
    }else{
        result += 7;
        c = c - ( a * 7 + b );
        int i = 1;
        while( c > 0 ){
            
            c -= a;
            if( i % 7 == 0 ){
                c -= b;
            }
            
            result++;
            i++;
        }
    }
    
    cout << result << endl;
    
}



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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    LL a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    if(v < w)cout << "NO";
    else if(v == w)
    {
        if(a == b)cout << "YES";
        else cout << "NO";
    }
    else
    {
        w*=t,v*=t;
        if(v >= w+abs(a-b))cout << "YES";
        else cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define endl '\n'

int mod = 998244353;

int pw(int a, int k) {
    if (k == 0) return 1;
    if (k % 2) return ((long long) pw(a, k - 1) * a) % mod;
    int t = pw(a, k / 2);
    return ((long long) t * t) % mod;
}

int rv(int a) {
    return pw(a, mod - 2);
}

int ml(int a, int b) {
    return ((long long)a * b) % mod;
}

int ml(int a, int b, int c) {
    return ml(ml(a, b), c);
}

int dv(int a, int b) {
    return ml(a, rv(b));
}

int sm(int a, int b) {
    return (a + b) % mod;
}

int df(int a, int b) {
    return ((long long)a + mod - b) % mod;
}

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

string yy = "Yes\n";
string nn = "No\n";
string imp = "IMPOSSIBLE\n";



int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1; // cin >> t;
    while (t--) {
        int n; cin >> n;
        int x, m; cin >> x >> m;
        unordered_map<int, int> mp;
        int cnt = 0;
        vector<int> a(m + 1);
        vector<int> b(m + 2);
        a[0] = x;
        b[1] = x;
        mp[x] = 1;
        int cur = 1;
        int st = -1;
        while (true) {
            a[cur] = (a[cur - 1] * a[cur - 1]) % m;
            b[cur + 1] = (a[cur] + b[cur]);
            if (mp[a[cur]]) {
                st = mp[a[cur]];
                break;
            }
            mp[a[cur]] = cur+1;
            cur++;
        }
        int step = cur + 1 - st;
        int val = b[cur + 1] - b[st];
        int beg = b[st];
        if (n <= st) {
            cout << b[n] << endl;
            continue;
        }
        n -= st;
        beg += (n / step) * val;
        n %= step;
        beg += b[st + n] - b[st];
        cout << beg << endl;


    }
    return 0;
}


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

int main() {

  int N;
  cin >> N;

    int64_t sum = 0;
  for(int i = 1; i <= N; i++){
    if(i % 3 != 0 && i % 5 != 0){
        sum += i;
    }
  }
    cout << sum << endl;
}


Measured memory_bytes: 3632
lines = []
colums = []
 
while True:
  H,W = map(int,input().split())
  if H == 0 and W == 0:
    break
  lines.append(H)
  colums.append(W)
 
for H,W in zip(lines,colums):
  for i in range(H):
    if i%2==0:
      for j in range(W):
        if j%2==0:
          print("#",end="")
        else:
          print(".",end="")
    else:
      for j in range(W):
        if j%2!=0:
          print("#",end="")
        else:
          print(".",end="")
       
    print("\n",end="")
  print("\n",end="")


Measured memory_bytes: 7016
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if(A * B % 2 != 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 23252
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	int n;
	string s;
	cin >> n;
	cin >> s;
	
	int counter = 0;
	for (int i = 0; i < (n - 2); i++)
	{
		if ((s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C'))
		{
			counter++;
		}
	}
	
	cout << counter << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 3592
n, k = map(int, input().split())
treat = []
sunuke = list(range(1, n+1)) 
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(len(a)):
        treat.append(a[j])
    
trick = list(set(sunuke) - set(treat))
print(len(trick))

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	string s, t;
	cin >> s >> t;
	int ans = inf;
	zip(i, 0, sz(s))
	{
		int var = 0;
		if (sz(t) + i >= sz(s) + 1)
			break;
		zip(j, i, sz(t) + i)
		{
			if (s[j] != t[j - i])
				var++;
		}
		ans = min(ans, var);
	}
	cout << ans << en;


	return 0;
}




Measured memory_bytes: 3644
uses math;
var
	ans,n,Ma,Mb,i,j,a,b,c,x,mp,mm:Longint;
	p,m:array[0..200]of Longint;
begin
	read(n,Ma,Mb);
	ans:=10000;
	for i:=1 to 200 do begin
		p[i]:=ans;
		m[i]:=ans;
	end;
	for i:=1 to n do begin
		read(a,b,c);
		x:=Ma*b-Mb*a;
		if x>0 then begin
			mp:=min(mp+x,200);
			for j:=mp-x downto 0 do p[j+x]:=min(p[j+x],p[j]+c);
		end else if x<0 then begin
			mm:=min(mm-x,200);
			for j:=mm+x downto 0 do m[j-x]:=min(m[j-x],m[j]+c);
		end else ans:=min(ans,c);
	end;
	for i:=1 to 150 do ans:=min(ans,p[i]+m[i]);
	if ans<10000 then writeln(ans)else writeln(-1);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int mod = 1e9 + 7;
vector<ll> x(100100);

ll PowModRepeatSquaring(int a, int p) {
    if (p == 0) return 1;
    if (p % 2 ==0) {
        ll t = PowModRepeatSquaring(a, p / 2);
        return t * t % mod;
    }
    else {
        return a * PowModRepeatSquaring(a, p - 1) % mod;
    }
}

vector<ll> divisor(ll a) {
    vector<ll> res;
    for (ll i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            res.push_back(i);
            if (i * i != a) res.push_back(a / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;

    ll ans = 0;
    for (int i = k; i > 0; --i) {
        ll cnt = ((PowModRepeatSquaring(k / i, n) - x[i]) % mod + mod) % mod;
        ans = (ans + i * cnt) % mod;

        vector<ll> d = divisor(i);
        for (auto &it : d) {
            x[it] = (x[it] + cnt) % mod;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3852
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	int N = stdIn.nextInt();
	int[] d1 = new int[N];
	for(int i=0;i<N;i++){
	    d1[i]=stdIn.nextInt();
	}
	int[] d2=d1;
	int sum=0;
	int add=0;
	for(int i=0;i<N;i++){
	    for(int j=0;j<N;j++){
		add=d1[i]*d2[j];
		if(i==j){
		    add=0;
		}
		sum+=add;
	    }
	}
	System.out.println(sum/2);
    }
}
		


Measured memory_bytes: 25044
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) {
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, A, B;
  string S;
  cin >> N >> A >> B;
  cin >> S;
  ll bn = 0;
  ll pn = 0;

  REP(i, N) {
    if (S[i] == 'a') {
      if (pn < A + B) {
        cout << "Yes" << endl;
        pn++;
      }
      else {
        cout << "No" << endl;
      }
    } else if (S[i] == 'b') {
      if (pn < A + B && bn < B) {
        cout << "Yes" << endl;
        pn++;
        bn++;
      }
      else {
        cout << "No" << endl;
      }
    } else { // if (S[i] == 'c')
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 848
import java.util.*
import kotlin.collections.HashMap
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val s = readLn()[0]
    println(if (s.isLowerCase()) "a" else "A")
}


Measured memory_bytes: 34464
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(n**3)
    return

#B
def B():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    ans = sum(b)
    for i in range(n-1):
        x = a[i]
        y = a[i+1]
        if y == x+1:
            ans += c[x-1]
    print(ans)
    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

ll F[N], I[N];
ll sum(ll a, ll b) {
	return (a + b + Mod) % Mod;
}
ll sub(ll a, ll b) {
	return (a - b + Mod) % Mod;
}
ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll Pow(ll a, ll b) {
	ll res = 1;
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1) 
			res = mul(res, a);
	return res;
}
ll inv(ll x) {
	return Pow(x, Mod - 2);
}
ll C(ll r, ll n) {
	if (n < 0 || r > n) return 0;
	if (r == n || r == 0) return 1;
	return mul(F[n], mul(I[r], I[n - r]));
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    F[0] = 1;
    for (int i = 1; i < N; i ++) {
    	F[i] = mul(F[i - 1], i);
	}
	I[N - 1] = inv(F[N - 1]);
	for (int i = N - 2; ~i; i --) {
		I[i] = mul(i + 1, I[i + 1]);
	}
	for (int i = 0; i <= min(n, k); i ++) {
		ll cur = C(i, n);
		cur = mul(cur, C(n -i - 1, n - 1));
		ans = sum(ans, cur);
	}
	cout << ans;
    return (0);
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	ll n;
	cin >> n;

	ll ans = n + 1;
	for(ll i = 2; i * i <= n; ++i)
	{
		if (n % i == 0)
		{
			ans = min(ans, i + n / i);
		}
	}
	cout << ans - 2;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n,m,c = MI()
	b = np.array(LI())
	ans = 0
	for _ in range(n):
		a = np.array(LI())
		if np.sum(a*b)+c > 0:
			ans+=1
	print(ans)


if __name__ == '__main__':
	main()

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

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

#define FOR(i,j,k,in) for(int i=(j); i < (k);i+=in)
#define FORD(i,j,k,in) for(int i=(j); i >=(k);i-=in)
#define REP(i,b) FOR(i,0,b,1)
#define REPD(i,b) FORD(i,b,0,1)
#define pb push_back 
#define mp make_pair
#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.1415926535 

int main(){
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL); cout.tie(NULL);
 	double r; cin >> r;
 	cout << fixed; cout << setprecision(5);
 	cout << 2*r*PI << endl;
 	return 0;
}

Measured memory_bytes: 3792
#include <stdio.h>

int map[21][21];

int main(void){
    int N,M;
    int x,y,count;
    int i,j,l;
    char d;
    while(scanf("%d", &N),N){        
        for(i=0;i<=20;i++){
            for(j=0;j<=20;j++){
                map[i][j]=0;
            }
        }
        for(i=0;i<N;i++){
            scanf("%d %d",&x, &y);
            map[x][y]=1;
        }
        
        x=10;
        y=10;
        count=0;
        scanf("%d",&M);
        for(i=0;i<M;i++){
            scanf("%s %d", &d, &l);
            for(j=0;j<l;j++){
                switch(d){
                    case 'N'://+y
                        y++;
                        break;
                    case 'E'://+x
                        x++;
                        break;
                    case 'S'://-y
                        y--;
                        break;
                    case 'W'://-x
                        x--;
                        break;
                }
                if(map[x][y]){
                    map[x][y]=0;
                    count++;
                }
            }
        }
        if(count==N){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

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

  const ll kMod = 1000000007;
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll k = 0;
  ll ans = 1;
  rep(i, 1, 2 * n) {
    if (k == -1) break;

    auto ch = s[i - 1];
    if (ch == 'B' xor k % 2 == 1) {
      ++k;
    } else {
      ans = (ans * k) % kMod;
      --k;
    }
  }

  rep(i, 1, k) {
    ans = (ans * i) % kMod;
  }
  rep(i, 1, n) {
    ans = (ans * i) % kMod;
  }
  if (k != 0) ans = 0;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>

using namespace std;
using pii = pair<int, int>;
static const int INF = 1000000000;
static const int dx[] = { 1, 0, -1, 0 };
static const int dy[] = { 0, -1, 0, 1 };

inline bool between(int a, int b, int c){
	return a <= b && b < c;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >> n >> m >> k;
	vector<string> a(n);
	int sy = 0, sx = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		for(int j = 0; j < m; ++j){
			if(a[i][j] == 'S'){ sy = i; sx = j; }
		}
	}

	vector<vector<int>> init(n, vector<int>(m, INF));
	{
		queue<pii> q;
		q.emplace(sy, sx);
		init[sy][sx] = 0;
		while(!q.empty()){
			const pii p = q.front();
			q.pop();
			if(init[p.first][p.second] >= k){ continue; }
			for(int d = 0; d < 4; ++d){
				const int y = p.first + dy[d];
				const int x = p.second + dx[d];
				if(!between(0, y, n) || !between(0, x, m)){ continue; }
				if(a[y][x] == '#'){ continue; }
				if(init[y][x] < INF){ continue; }
				init[y][x] = init[p.first][p.second] + 1;
				q.emplace(y, x);
			}
		}
	}
	vector<vector<int>> dist(n, vector<int>(m, INF));
	{
		queue<pii> q;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				if(init[i][j] < INF){
					dist[i][j] = k + k - 1;
					q.emplace(i, j);
				}
			}
		}
		while(!q.empty()){
			const pii p = q.front();
			q.pop();
			for(int d = 0; d < 4; ++d){
				const int y = p.first + dy[d];
				const int x = p.second + dx[d];
				if(!between(0, y, n) || !between(0, x, m)){ continue; }
				if(dist[y][x] < INF){ continue; }
				dist[y][x] = dist[p.first][p.second] + 1;
				q.emplace(y, x);
			}
		}
	}
	int answer = INF;
	for(int i = 0; i < n; ++i){
		answer = min(answer, dist[i][0] / k);
		answer = min(answer, dist[i][m - 1] / k);
	}
	for(int j = 0; j < m; ++j){
		answer = min(answer, dist[0][j] / k);
		answer = min(answer, dist[n - 1][j] / k);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <assert.h>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

// フェルマーの小定理を用いたCombination計算(modの構造体と一緒に使う)
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};
int main()
{
	// ABC152-D, 1063, 
	int n; cin >> n;
	map<P, int> mp;
	rep(i, n) {
		int first, last;
		last = (i + 1) % 10;
		if (last == 0) continue;
		first = (i + 1);
		while (10 <= first) first /= 10;
		mp[make_pair(first, last)]++;
	}
	mint ans = 0;
	combination c(200000);
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		mint tmp = 0;
		if ((*itr).first.first < (*itr).first.second) continue;
		tmp = (*itr).second * mp[make_pair((*itr).first.second,(*itr).first.first)];
		if ((*itr).first.first != (*itr).first.second) tmp *= 2;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6432
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                  as A
import qualified Data.Array.Unboxed          as AU
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import           Data.Time
import qualified Data.Vector                 as V
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n =
  replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n =
  replicateM n (map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main :: IO ()
main = do
  [a, b] <- readInts
  print $ solve a b
  return ()

solve a b = maximum [a + a - 1, a + b, b + b - 1]
-- solve n w vw = f 0 w
--   where
--     items = VU.fromList vw
--     f i cap
--       | i == n = 0
--       | snd (items VU.! i) > cap = f (i + 1) cap
--       | otherwise =
--         max
--           (memo A.! (i + 1, cap))
--           (memo A.! (i + 1, cap - snd (items VU.! i)) + fst (items VU.! i))
--     memo =
--       A.array
--         ((0, 0), (n, w))
--         [((n', w'), f n' w') | n' <- [0 .. n], w' <- [0 .. w]]


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

int gcd(int a, int b) { return b != 0 ? 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();
  int r[n] = {}, l[n] = {}, ans[n] = {};
  r[0] = 0;
  l[n - 1] = n - 1;
  FOR(i , 1, n) {
    if (s[i] == 'R') r[i] = i;
    else r[i] = r[i - 1];
  }
  for(int i = n - 2; i > -1; i--) {
    if (s[i] == 'L') l[i] = i;
    else l[i] = l[i + 1];
  }
  REP(i, n) {
    if(s[i] == 'R') {
      int x = l[i];
      if ((l[i] - i) % 2 == 0) {
        ans[l[i]]++;
      } else {
        ans[l[i] - 1]++;
      }
    } else {
      int x = r[i];
      if ((i - r[i]) % 2 == 0) {
        ans[r[i]]++;
      } else {
        ans[r[i] + 1]++;
      }
    }
  }
  REP(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 1792
n,a,b=map(int,input().split())
s=input()
d=0
e=0
for i in range(n):
    if s[i]=="a":
        if a+b>d+e:
            print("Yes")
            d+=1
        else:
            print("No")
        
    elif s[i]=="b":
        if a+b>d+e and b>e:
            print("Yes")
            e+=1
        else:
            print("No")
            
    elif s[i]=="c":
        print("No")

Measured memory_bytes: 4016
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define p 1000000007
#define MAXN 100005
using namespace std;

int n, ans, sum[MAXN], a[MAXN], down[MAXN];

void init()
{
	sum[1]=sum[0]=1; down[0]=down[1]=1;
	for(int i=2; i<=n; i++) sum[i]=1LL*sum[p%i]*(p-p/i)%p;
	for(int i=2; i<=n; i++)
	{
		sum[i]=(sum[i-1]+sum[i])%p;
		down[i]=1LL*down[i-1]*i%p;
	}
}

int main()
{
	scanf("%d", &n);
	for(int i=1; i<=n; i++) scanf("%d", &a[i]);
	init();
	for(int i=1; i<=n; i++) ans=(ans+1LL*(sum[i]+sum[n-i+1]-sum[1])*a[i]%p)%p;
	printf("%d\n", 1LL*ans*down[n]%p);
}

Measured memory_bytes: 1280
n, k = map(int, input().split())
a = [0] * n
for i in range(k):
    d = int(input())
    for l in list(map(int, input().split())):
        a[l-1] = 1

cnt = 0
for i in range(n):
    if a[i] == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 67300
use std::io::*;

const SP: u8 = b' ';
const LF: u8 = b'\n';

struct CharacterInput<'a> {
    locked_stdin: StdinLock<'a>,
    bytes_buffer: Vec<u8>,
}

impl<'a> CharacterInput<'a> {
    fn read(&mut self, delimiter: u8) -> &[u8] {
        self.bytes_buffer.clear();

        let len = self
            .locked_stdin
            .read_until(delimiter, &mut self.bytes_buffer)
            .unwrap();

        if len > 0 {
            let len = len - 1;
            if self.bytes_buffer[len] == delimiter {
                self.bytes_buffer.truncate(len);
            }
        }

        &self.bytes_buffer
    }

    fn scan_u(&mut self, delimiter: u8) -> u32 {
        self.read(delimiter)
            .into_iter()
            .fold(0, |accumulator, byte| {
                (byte - b'0') as u32 + accumulator * 10
            })
    }
}

fn create_cin<'a>(input: StdinLock<'a>, buffer_capacity: usize) -> CharacterInput {
    CharacterInput {
        locked_stdin: input,
        bytes_buffer: Vec::with_capacity(buffer_capacity),
    }
}

struct CharacterOutput {
    string_buffer: String,
}

impl CharacterOutput {
    fn push_s(&mut self, s: &str) {
        self.string_buffer += s;
    }

    fn push<T: ToString>(&mut self, n: T) {
        self.push_s(&n.to_string());
    }

    fn add<T: ToString>(&mut self, n: T, separator: char) {
        self.push(n);
        self.string_buffer.push(separator);
    }

    fn flush(&mut self) {
        let out = stdout();
        let mut out = out.lock();
        out.write_all(self.string_buffer.as_bytes()).unwrap();
        self.string_buffer.clear();
    }
}

fn create_cout(capacity: usize) -> CharacterOutput {
    CharacterOutput {
        string_buffer: String::with_capacity(capacity),
    }
}

// ------------------------------------------------------------------------

fn get_count(n: usize, table: &mut Vec<Option<u64>>, broken: &Vec<bool>) -> u64 {
    match table[n] {
        Some(val) => val,
        None => {
            if broken[n] {
                0
            } else {
                match n {
                    0 => 1,
                    1 => {
                        table[1] = Some(1);
                        1
                    }
                    _ => {
                        let c = (get_count(n - 2, table, broken) + get_count(n - 1, table, broken))
                            % 1000000007;
                        table[n] = Some(c);
                        c
                    }
                }
            }
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = &mut create_cin(cin.lock(), 32);
    let cout = &mut create_cout(32);

    let n = cin.scan_u(SP) as usize;
    let m = cin.scan_u(LF) as usize;

    let mut broken = vec![false; n + 1];
    for _ in 0..m {
        broken[cin.scan_u(LF) as usize] = true;
    }

    let mut table = vec![None as Option<u64>; n + 1];
    table[0] = Some(1);

    cout.add(get_count(n, &mut table, &broken), '\n');

    cout.flush();
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    string S; cin >> S;
    map<ll, char> A; // 前半部分の文字列のカウント
    map<ll, char> B; // 後半部分の文字列のカウント
    // Sを全てBに分割したとして文字列のカウントを行う
    REP(i, N) {
        B[S[i]]++;
    }
    ll ans = 0;
    // 1文字ずつBからAに移動する
    REP(i, N) {
        A[S[i]]++;
        B[S[i]]--;
        ll tmp = 0;
        // Aの文字列がBにあるか確認する
        for(auto x : A) {
            if (B[x.first]) {
                tmp++;
            }
        }
        ans = max(ans, tmp);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

template<typename T = int64_t>
T gcd(T a, T b)
{
        while (b != 0) {
                T t = b;
                b = a % b;
                a = t;
        }
        return a;
}

int main(int argc, char **argv)
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int64_t a, b, c, d;
        cin >> a >> b >> c >> d;
        a--;
        int64_t l = c * d / gcd(c, d);
        int64_t x = a - (a / c + a / d - a / l);
        int64_t y = b - (b / c + b / d - b / l);
        cout << y - x << endl;
        return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
if m == 0:
  print(0,0)
  exit()
A=[[0,0] for _ in range(n)]
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if A[p][0]==1:
    continue
  elif s=='AC':
    A[p][0]=1
  else:
  	A[p][1]+=1
ac=0
wa=0
for a in A:
  ac+=a[0]
  if a[0] == 1:wa+=a[1]
print(ac,wa)

Measured memory_bytes: 13172
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  int p, l, r;
};

struct Node T[MAX];
int D[MAX], H[MAX];
int n;

void strk(int);
int depth(int);
int sibling(int);

int main()
{
  int i, v, l, r;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l, &r);

    T[v].l = l;
    T[v].r = r;

    if ( l != NIL ) T[l].p = v;
    if ( r != NIL ) T[r].p = v;

  }

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

    D[i] = depth(i);
    H[i] = 0;

  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) { // leaf
      H[i] = 0;
      int p = T[i].p;
      int z = 1;
      while(1){
	if ( p == NIL ) break;
	if ( H[p] < z ) H[p] = z;
	z++;
	p = T[p].p;
      }
    }
  }

  for ( i = 0; i < n; i++ ) strk(i);


  return 0;
}


int depth(int u){
  int d = 0;
  while(1){
    u = T[u].p;
    if ( u == NIL ) break;
    d++;
  }
  return d;
}

int sibling(int u){
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  return NIL;
}

void strk(int u){
  int deg = 0;

  printf("node %d: ", u);

  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", sibling(u));

  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;

  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].p == NIL ){
    printf("root\n");
  } else if ( T[u].l == NIL && T[u].r == NIL ){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

Measured memory_bytes: 624
from collections import deque

n, q = map(int, input().split())
ans = [0 for x in range(n)]
g = [list() for x in range(n)]
for i in range (n - 1) :
    v, u = map(int, input().split())
    v -= 1
    u -= 1
    g[v].append(u)
    g[u].append(v)
for i in range (q):
    p, x = map(int, input().split())
    p -= 1;
    ans[p] += x
dq = deque()
dq.append((0, -1))
while (len(dq)) :
    v, p = dq.pop()
    for u in g[v]:
        if (u != p) :
            ans[u] += ans[v]
            dq.append((u, v))
print(*ans)

Measured memory_bytes: 62204
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
    int n,result = 100000;
    cin >> n;
    for(int i=0;i<n;i++){
        result*=1.05;
        if(result%1000>0){
            result+=1000;
            result-=result%1000;
        }
    }
    cout<<result<<endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int i = 0, ans = 0;
    while (i < n) {
        int v = a[i], j = i;
        do { j++; } while (j < n && a[j] == v);
        ans += (j - i) / 2;
        i = j;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    string s, t;
    cin >> s >> t;

    int ans = 1001;
    REP(i, (int) s.length()-t.length()+1) {
        int tmp = 0;
        string sub = s.substr(i, t.length());
        
        // cerr << i << ": " << sub << endl;
        // cerr << i << ": " << t << endl;
        REP(c, (int)t.length()) {
            if (sub[c] != t[c]) tmp++;
        }
        // cerr << i << ": " << tmp << endl;
        ans = min(ans, tmp);
    }

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


Measured memory_bytes: 3660
(function set_utils(undefined){
	this.print_float = function print_float(val, base, pad, prec) {
		var p10=Math.pow(10,prec);
		var ival=""+Math.round(val*p10);
		if ( ival === '0' )
			return '0.'+Array(prec+1).join('0');
		var ilen=ival.length-prec;
		if(ilen===0)
			return "0."+ival.substr(ilen,prec);
		return ival.substr(0,ilen)+"."+ival.substr(ilen,prec);
	};
	this.gcd = function gcd( a, b ) {
		return !b ? a : gcd( b, a % b );
	};
	this.lcm = function lcm( a, b ) {
		return a / gcd( a, b ) * b;
	};
}).call(global);

(function(undefined){
	'use strict';

	(function init() {
		this.output = function() {
			console.log.apply( console, arguments );
		};
		this.stdin = process.openStdin();
		stdin.setEncoding('utf8');
		this.input_list = [];
		stdin.on('data', function(chunk){
			var result = chunk.match(/[-]?\d+/g);
			input_list = input_list.concat(result);
		});
		stdin.on('end', function(){
			fire();
		});
		this.input_number = function() {
			return parseInt( input_list.splice(0,1)[0] );
		};
		this.has_next = function() {
			return ! input_list.length;
		};
	}).call( this );

	(function solver(){
		function sq(x) {
			return x * x;
		}
		function check(v) {
		}
		this.fire = function() {
			setTimeout( solve, 0, this );
		};
		function solve() {
			var args = [input_number(), input_number()];
			output( gcd.apply( this, args ), lcm.apply( this, args ) );
			if ( ! has_next() )
				setTimeout( solve, 0, this );
		}
	}).call(this);

}).call(global);

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

int main(){
    int H,W;
    while(1){
        cin>>H >>W;
        if(H==0 && W==0)break;
            for ( int i = 0; i < H; i++ ){
                for ( int j = 0; j < W; j++ ){
                    cout << "#";
            }cout <<endl;
        }
        cout <<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long>a(n);
  for(int i=0;i<n;i++){
    long long num;
    cin >> a.at(i);
    if(a.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }
  long long x=1;
  long long m=1e18;
  for(int i=0;i<n;i++){
    if(a.at(i)>m/x){
      cout << -1 << endl;
      return 0;
    }
    x*=a.at(i);
  }
  cout << x << endl;
}


Measured memory_bytes: 3940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    vector<int> a =
{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    k--;
    cout<<a[k]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
    const double kPi = 3.14159265359;

    double a, b, c;
    cin >> a >> b >> c;

    c = c * kPi / 180.0;

    double S = a * b * sin(c) / 2;
    double h = b * sin(c);
    double L = a + b + sqrt(pow(h, 2) + pow(a - b * cos(c), 2));
    cout << fixed << setprecision(5);
    cout << S << endl;
    cout << L << endl;
    cout << h << endl;

    return 0;
}

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    
    int cnt=0;
    for(int i=1;i<=N;i++){
        string S=to_string(i);
        int sum=0;
        for(int c=0;c<S.size();c++){
            sum+=S[c]-'0';
        }
        if(A<=sum && sum<=B) cnt+=i;
    }
    cout << cnt << endl;

    return 0;
}

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


void solve()
{
	int N;
	cin>>N;

	if(N >= 1 && N<=1000)
	{
		cout<<1000 - N<<endl;
	}

	else if(N > 1000 && N<=2000)
	{
		cout<<2000 - N<<endl;
	}

	else if(N > 2000 && N<=3000)
	{
		cout<<3000 - N<<endl;
	}

	else if(N > 3000 && N<=4000)
	{
		cout<<4000 - N<<endl;
	}

	else if(N > 4000 && N<=5000)
	{
		cout<<5000 - N<<endl;
	}

	else if(N > 6000 && N<=7000)
	{
		cout<<7000 - N<<endl;
	}

	else if(N > 7000 && N<=8000)
	{
		cout<<8000 - N<<endl;
	}

	else if(N > 8000 && N<=9000)
	{
		cout<<9000 - N<<endl;
	}

	else
		cout<<10000 - N<<endl;
	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	return 0;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
	LL n,k,i,a[100010];
	cin>>n>>k;
	for(i=0;i<n;i++)	cin>>a[i];
	sort(a,a+n);
	if(a[n-1]==k)
	{
		puts("POSSIBLE");
		return 0;
	}
	if(a[n-1]<k)
	{
		puts("IMPOSSIBLE");
		return 0;
	}
	for(i=1;i<n;i++)
	{
		if(__gcd(a[0],a[i])==1)
		{
			puts("POSSIBLE");
			return 0;
		}
		if(__gcd(a[0],k)==__gcd(a[i],a[0])&&__gcd(a[0],k)!=1)
		{
			puts("POSSIBLE");
			return 0;
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m,r = inpl()
rr = inpl()
g = [[INF]*n for _ in range(n)]
for i in range(n):
    g[i][i] = 0
for i in range(m):
    a,b,c = inpl()
    a,b = a-1,b-1
    g[a][b] = c
    g[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            g[i][j] = min(g[i][j], g[i][k]+g[k][j])
res = INF
for root in itertools.permutations(range(r)):
    cnt = 0
    for i in range(r-1):
        a,b = rr[root[i]], rr[root[i+1]]
        a,b = a-1, b-1
        cnt += g[a][b]
    res = min(res, cnt)
print(res)

Measured memory_bytes: 94680
#include<stdio.h>
#include<iostream>
using namespace std;
int n,a[100005],j,k,i;
long long ans,s;
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(i=1;i<=n/2;i++)
    {
        s=0;
        for(j=1,k=n;j<=n;j+=i,k-=i)
        {
            int aa=n-j;
            int b=aa-i;
            if(j==k||j-i==k)
                break;
            s+=a[j]+a[k];
            if(b>0)
                ans=max(ans,s);
        }
    }
    cout<<ans;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, D);
  vector<int> c(26);
  rep(i, 26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D) rep(j, 26) cin >> s[i][j];

  int sat = 0;
  vector<int> last(26);
  rep(i, D) {
    in(int, t);
    --t;
    int d = i + 1;
    last[t] = d;
    sat += s[i][t];
    rep(k, 26) { sat -= c[k] * (d - last[k]); }
    out(sat);
  }
}


Measured memory_bytes: 3632