akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 
 
using namespace std;
 
int main(){
 
    int cards[4][13];
 
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 13; j++){
            cards[i][j] = 0;
        }
    }
 
    int n;
    cin >> n;
    char mark;
    int num;
    for (int i = 0; i < n; i++){
        cin >> mark >> num;
        if (mark == 'S'){
            cards[0][num-1] = 1;
        }
        else if (mark == 'H'){
            cards[1][num-1] = 1;
        }
        else if (mark == 'C'){
            cards[2][num-1] = 1;
        }
        else if (mark == 'D'){
            cards[3][num-1] = 1;
        }
    }
 
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 13; j++){
            if (cards[i][j] == 0){
                if (i == 0){
                    cout << 'S' << " ";
                }
                else if (i == 1){
                    cout << 'H' << " ";
                }
                else if (i == 2){
                    cout << 'C' << " ";
                }
                else if (i == 3){
                    cout << 'D' << " ";
                }
                cout << j+1 << endl;
            }
        }
    }
 
}

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


def main():
    n, m = map(int, input().split())
    a = [list(input()) for _ in range(n)]
    b = [list(input()) for _ in range(m)]

    for i in range(n - m + 1):
        for j in range(n - m + 1):
            count = 0

            for k in range(i, i + m):
                for l in range(j, j + m):
                    if a[k][l] == b[k - i][l - j]:
                        count += 1

            if count == m ** 2:
                print('Yes')
                exit()

    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll ans = 0;
    if(b==1){
        cout << ans << endl;
        return 0;
    }
    for(ll x=b-1; x<=n; x+=b){
        ans = max(ans, (a*x)/b - a*(x/b));
    }
    ans = max(ans, (a*n)/b - a*(n/b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3428
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int val;
        cin >> val;
        N -= val;
        if (N < 0) {
            cout << "-1\n";
            return 0;
        }
    }

    cout << N << "\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;

void rec(vector<vector<int> > &Y, int i, int S, vector<int> &path) {
    if (S != 0) rec(Y, Y[i][S], S & ~(1 << i), path);
    path.push_back(i);
}

int TSP(vector<vector<int> > &E, int s, vector<int> &result) {
    const int n = E.size(), N = 1 << n;
    vector<vector<int> > X(n, vector<int>(N, INT_MAX));
    vector<vector<int> > Y(n, vector<int>(N, -1));
    for (int i = 0; i < n; ++i) {
        X[i][1 << i] = E[s][i];
        Y[i][1 << i] = s;
    }
    for (int S = 1; S < N; ++S) {
        for (int i = 0; i < n; ++i) {
            if (!(S & (1 << i))) continue;
            for (int j = 0; j < n; ++j) {
                if (S & (1 << j)) continue;
                if (X[j][S | (1 << j)] > X[i][S] + E[i][j]) {
                    X[j][S | (1 << j)] = X[i][S] + E[i][j];
                    Y[j][S | (1 << j)] = i;
                }
            }
        }
    }
    result.clear();
    rec(Y, s, (1 << n) - 1, result);
    return X[s].back();
}

int main() {
    int v, e;
    cin >> v >> e;
    vector<vector<int>> edges(v, vector<int>(v, INT_MAX / 100));

    rep(i, e) {
        int s, t, d;
        cin >> s >> t >> d;
        edges[s][t] = d;
    }
    vector<int> results;
    int ans = TSP(edges, 0, results);
    if (ans >= INT_MAX / 100) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;

}





Measured memory_bytes: 6840
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    r_count, g_count, b_count = [S.count(x) for x in 'RGB']
    ans = r_count * g_count * b_count
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = j + (j - i)
            if k < N and (S[i] != S[j] and S[j] != S[k] and S[k] != S[i]):
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d);
	printf("%d", max(min(b, d)-max(a, c), 0));
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::cout << "ABC" << std::to_string(N) << std::endl;
  return 0;
}


Measured memory_bytes: 256
// copy from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: usize,
        b: usize,
    }
    println!("{}", solve(a, b));
}

fn solve(a: usize, b: usize) -> usize {
    if a >= 13 {
        b
    } else if a >= 6 {
        b / 2
    } else {
        0
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        let tests: Vec<((usize, usize), usize)> = vec![
            ((30, 100), 100),
            ((12, 100), 50),
            ((0, 100), 0),
        ];
        for t in tests.iter() {
            let ((a, b), expected) = t;
            let actual = solve(*a, *b);
            assert_eq!(actual, *expected);
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<int>> v(26);
    rep(i, 0, n) v[s[i] - 'a'].push_back(i);
    rep(i, 0, n) v[s[i] - 'a'].push_back(i + n);
    ll ans = 0;
    ll p = 0;
    rep(i, 0, m) {
        int c = t[i] - 'a';
        if (v[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto it = lower_bound(all(v[c]), p);
        p = *it + 1;
        if (p >= n) {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1852
#include <iostream>

using namespace std;

int main()
{
    int N, A[101];

    cin >> N;

    int mx = 0;
    int mn = 2000000000;
    
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];

        if (A[i] < mn)
            mn = A[i];
        if (A[i] > mx)
            mx = A[i];
    }

    cout << mx - mn << endl;

    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define LOWBIT(x) ( (x) & -(x) )

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e5 + 10;
const int MAXN = 1e4 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

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

int main()
{
	//freopen("t.txt","r",stdin);
	char a[100],b[100]; cin>>a>>b;
	if (a[0]=='H'&&b[0]=='H')  cout<<'H'<<endl;
        if (a[0]=='H'&&b[0]=='D') cout<<'D'<<endl;
        if (a[0]=='D'&&b[0]=='H') cout<<'D'<<endl;
        if (a[0]=='D'&&b[0]=='D') cout<<'H'<<endl;

}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	string S;
	cin >> S;

	bool flag_AC = false;
	for (int i = 0; i < S.length() - 1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			flag_AC = true;
			break;
		}
	}

	if (flag_AC) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char t[99];
	double s[99],v;
	int p=0,f;
	while(~scanf("%[^ \n]",t)){
		f=0;
		if(t[1]==0) {
			if(t[0]=='+')
				s[p-2]+=s[p-1],p--;
			else if(t[0]=='-')
				s[p-2]-=s[p-1],p--;
			else if(t[0]=='*')
				s[p-2]*=s[p-1],p--;
			else if(t[0]=='/')
				s[p-2]/=s[p-1],p--;
			else
				f=1;
		} else
			f=1;
		if(f) {
			sscanf(t,"%lf",&v);
			s[p++]=v;
		}
		if(getchar()=='\n')
			printf("%f\n",s[--p]);
	}
	return 0;
}

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

using namespace std;

int P[10], Q[10];
int A[10];

int main(){
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", P + i);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", Q + i);
	}
	for (int i = 0; i < N; i++) {
		A[i] = i + 1;
	}
	int p, q;
	int pos = 0;
	while (true) {
		pos++;
		int cp = 0, cq = 0;
		for (int i = 0; i < N; i++) {
			if (A[i] == P[i]) cp++;
			if (A[i] == Q[i]) cq++; 
		}
		if (cp == N) p = pos;
		if (cq == N) q = pos;
		if (!(next_permutation(A, A + N))) break;
	}
	printf("%d\n", abs(p - q));
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(b==1) return a;else if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n,m);
    int x;
    vector<int> dp(n,-1);
    rep(i,m){
        in(x);
        dp[x-1]=0;
    }
    if(dp[0]!=0)dp[0]=1;
    if(dp[1]!=0)dp[1]=1+dp[0];
    for(int i=2;i<n;i++){
        if(dp[i]!=0)dp[i]=(dp[i-1]+dp[i-2])%MOD;
        dp[i]%=MOD;
    }
    out(dp[n-1]);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, m, kk, i, j, k, lastCut, myst, pos, sum, act[12], tab[12][1005], bel[12], must, res, ind;
char t[1005];

int main() {
scanf("%d %d %d", &n, &m, &kk);
for (i=0;i<n;i++) {
	scanf("%s", t);
	for (j=0;j<m;j++) tab[i][j] = (t[j] == '1');
}
res = INF;
for (i=0;i<(1<<(n-1));i++) {
	pos = 1;
	ind = 0;
	bel[0] = 0;
	for (j=0;j<n-1;j++) {
		if ((1<<j) & i) ind++;
		bel[j + 1] = ind;
	}
	for (k=0;k<=ind;k++) act[k] = 0;
	sum = ind;
	for (j=0;j<m;j++) {
		must = 0;
		for (k=0;k<n;k++) if (tab[k][j]) {
			act[bel[k]]++;
			if (act[bel[k]] > kk) must = 1;
		}
		if (must) {
			for (k=0;k<=ind;k++) act[k] = 0;
			for (k=0;k<n;k++) if (tab[k][j]) {
				act[bel[k]]++;
				if (act[bel[k]] > kk) pos = 0;
			}
			sum++;
		}
	}
	if (pos) res = min(res, sum);
}
printf("%d\n", res);
return 0;
}

Measured memory_bytes: 256
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll a,b;
		cin>>a>>b;
		if(a==b)cout<<0;
		else{
			if((a+b)&1)cout<<"IMPOSSIBLE";
			else cout<<(a+b)/2;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
max_L = -1
min_R = 10**6
for i in range(M):
    L, R = map(int, input().split())
    max_L = max(L, max_L)
    min_R = min(R, min_R)

print(max(min_R - max_L + 1, 0))


Measured memory_bytes: 3060
using System;
using System.Linq;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            double x1 = double.Parse(str[0]);
            double y1 = double.Parse(str[1]);
            double x2 = double.Parse(str[2]);
            double y2 = double.Parse(str[3]);
            double res = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;
	int count=0;
	cin >> s;

	for(int i=0;i<s.size();i++){
		if(s.at(i)!=s.at(s.size()-1-i)) count++;
	}
	cout << count/2 << endl;
}

Measured memory_bytes: 256
N = int(input())
A = []

for i in range (0, N):
	X, Y = map(int, input().split())
	A.append([X, Y])

xplusy = []
xminusy = []

for i in range (0, N):
	xplusy.append(A[i][0]+A[i][1])
	xminusy.append(A[i][0]-A[i][1])

print(max((max(xplusy)-min(xplusy)), (max(xminusy) - min(xminusy))))

Measured memory_bytes: 55068
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

ll Gcd(ll a,ll b,ll c){
	return Gcd(Gcd(a,b),c);
}

int main(){
    ll K;
    cin>>K;
    ll sum = 0;
    for(ll i=1;i<=K;i++){
        for(ll j=1;j<=K;j++){
            for(ll k=1;k<=K;k++){
                sum+=Gcd(i,j,k);
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*) array, (T*) (array + N), val);
}
pii Dir[8] = { //?§????
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};
int main() {
	int h, w, n;
	while (scnaf("%d %d %d", &h, &w, &n)) {
		if (!n)
			break;
		vector<vector<int>> m(h, vector<int>(w));
		REP(i, h) {
			REP(j, w) {
				scanf("%d", &m[i][j]);
			}
		}
		n--;
		int dp[1001][1001] = {};
		dp[0][0] = n;
		REP(i, h) {
			REP(j, w) {
				dp[i][j + 1] += (dp[i][j] + m[i][j]) / 2;
				dp[i + 1][j] += (dp[i][j] + 1 - m[i][j]) / 2;
			}
		}
		REP(i, h) {
			REP(j, w) {
				m[i][j] ^= dp[i][j] % 2;
			}
		}
		int x = 0, y = 0;
		for (; h > y; y++) {
			for (; w > x; x++) {
				if (!m[y][x])
					break;
			}
			if (w == x)
				break;
		}
		printf("%d %d\n", y + 1, x + 1);
	}
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;

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

int n, q;

int main(){
    cin >> n;
    string s;
    cin >> s >> q;
    vector<set<int>> str(26);
    REP(i,n)
    {
        str.clear();
    }
    REP(i,n)
    {
        str[s[i]-'a'].insert(i);
    }
    vector<int> ans;
    REP(i,q)
    {
        int t;
        cin >> t;
        if(t==1)
        {
            int j;
            char c;
            cin >> j >> c;
            int cnt = str[s[j-1]-'a'].erase(j-1);
            if(cnt==0)
            {
                while(true)
                {
                }
            }
            s[j-1]=c;
            str[c-'a'].insert(j-1);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            int sum=0;
            REP(d,26)
            {
                if(str[d].empty())continue;
                auto it = str[d].lower_bound(l-1);
                if(it!=str[d].end() && (*it)<=r-1)
                {
                    sum++;
                }
            }
            ans.push_back(sum);
        }
    }
    for(auto it=ans.begin();it!=ans.end();it++)
    {
        cout << (*it) << endl;
    }
    return 0;
}


Measured memory_bytes: 24452
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val N, K = sc.nextInt
    val V = List.fill(N)(sc.nextLong)

    val minTake = if (K % 2 == 0) K / 2 else K / 2 + 1
    var result = 0L
    for (i <- minTake to K) {
      val maxDiscard = K - i
      for (left <- 0 to Math.min(i, N)) {
        val right = Math.min(i, N) - left
        val taken = (V.take(left) ++ V.takeRight(right)).sorted
        val minusCount = taken.count(_.<(0))
        val value = if (minusCount < maxDiscard) {
          taken.filter(_.>(0)).sum
        } else {
          taken.drop(maxDiscard).sum
        }
        if (result < value) {
          result = value
        }
      }
    }
    println(result)
  }
}

Measured memory_bytes: 36408
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long ans = 2e18;
  for (int i = -1; i <= 1; i++) {
    if (!i) continue;
    long long sum = 0, here = 0;
    int lst = i;
    for (int j = 0; j < n; j++) {
      sum += arr[j];
      if (lst == -1) {
        if (sum >= 0) {
          here += abs(sum - (-1));
          sum = -1;
        }
        lst = 1;
      } else {
        if (sum <= 0) {
          here += abs(sum - 1);
          sum = 1;
        }
        lst = -1;
      }
    }
    ans = min(ans, here);
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 640
using System;
namespace kozaiyApp
{
    public class C
    {
        static void Main()
        {
            ulong K = ulong.Parse(Console.ReadLine());
            ulong ans = 0;

            for (ulong a = 1; a <= K; a++)
            {
                for (ulong b = 1; b <= K; b++)
                {
                    for (ulong c = 1; c <= K; c++)
                    {
                        ulong gcdAB = Gcd(a, b);
                        ans += Gcd(gcdAB, c);
                    }
                }
            }

            Console.WriteLine(ans);
        }

        // 最大公約数 m > n ユークリッドの互除法 
        public static ulong Gcd(ulong m, ulong n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }
    }
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> p){
    sort(ALL(p));
    int ans = 0;
    REP(i, N-1) ans += p[i];
    ans += p[N-1] / 2;
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


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

int main(){
  float x1, y1, x2, y2, x3, y3, xp, yp;
  float areasize;
  float areasize_sum, tmp;

  while(cin>>x1){
    cin>>y1;
    cin>>x2; cin>>y2;
    cin>>x3; cin>>y3;
    cin>>xp; cin>>yp;
    areasize=(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);
    if(areasize<0) areasize*=-1.0f;

    tmp=(x1-xp)*(y2-yp)-(y1-yp)*(x2-xp);
    if(tmp<0) tmp*=-1.0f;
    areasize_sum=tmp;
    tmp=(x2-xp)*(y3-yp)-(y2-yp)*(x3-xp);
    if(tmp<0) tmp*=-1.0f;
    areasize_sum+=tmp;
    tmp=(x3-xp)*(y1-yp)-(y3-yp)*(x1-xp);
    if(tmp<0) tmp*=-1.0f;
    areasize_sum+=tmp;

    if(areasize==areasize_sum) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int a,b;
int ans,ans1;

int32_t main(){_
    //freopen("input","r",stdin);
	string s;
	cin >> s;
	int n = sz(s);
	ans = n;
	ans1 = n;
	for(int i = 0;i < sz(s);i++)
	{
		if(s[i] == '0')
		{
			ans = min(ans,max(max(i,1),max(1,n-i-1)));
		}
		if(s[i] == '1')
		{
			ans1 = min(ans1,max(max(i,1),max(1,n-i-1)));
		}
	}
	rc(max(ans,ans1));
}

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


int main()
{
  vector< int > sum(5);

  while(true) {
    for(int i = 0; i < 5; i++) {
      int s1, s2;
      if(cin >> s1 >> s2) {
        sum[i] = s1 + s2;
      } else {
        return(0);
      }
    }
    cout << (char)(max_element(sum.begin(), sum.end()) - sum.begin() + 'A') << " " << *max_element(sum.begin(), sum.end()) << endl;
  }
}

Measured memory_bytes: 1192
#include<stdio.h>
#define MAX 100005
#define NIL -1
#define TRUE 1
#define FALSE 0
 
/*
    p: parent
    l: left-child
    r: right sibling
*/
 
int n;
struct Node {
    int p, l, r;
};
int found;
int root;
 
struct Node T[MAX]; // Tree
 
int dfs (int curr, int depth )
{
    if (found == TRUE ) return depth;
    if (curr == root ){
        found = TRUE;
        return depth;
    } // end if
 
    return dfs (T[curr].p, depth + 1 );
}
 
int calc_depth (int node )
{
    int i;
    found = FALSE;
    if (root == NIL ){
        for (i = 0; i < n; i++ ){
            if (T[i].p == NIL ){
                root = i;
                break;
            } // end if
        } // end for
    } // end if
 
    int res = dfs (node, 0 );
 
    return res; 
}
 
int main()
{
    int i, j, d, v, c, l;
    root = NIL;
    scanf("%d", &n );
 
    for (i = 0; i < n; i++ ){
        T[i].p = T[i].l = T[i].r = NIL;
    } // end for
 
    for (i = 0; i < n; i++ ){
        scanf ("%d %d", &v, &d );   // v: 節点の番号 d: 次数 
        for (j = 0; j < d; j++ ){
            scanf ("%d", &c );  // c: 子の節点番号 
            if (j == 0 ){
                T[v].r = c;
            }else{
                T[l].l = c;
            } // end if
            l = c;
            T[l].p = v;
        } // end for
    } // end for
 
    for (i = 0; i < n; i++ ){
        printf ("node %d: parent = %d, depth = %d, ", i, T[i].p, calc_depth(i ) );
        if (T[i].p == NIL ){        // case root 
            printf ("root, [" );
            int next = T[i].r;
            while (next != NIL ){
                printf ("%d", next );
                next = T[next].l;
                if (next != NIL ) printf (", " );
            } // end while
            printf ("]\n" );
        }else
        if (T[i].r == NIL ){        // case leaf
            printf ("leaf, []\n" );
        }else{              // case internal node
            printf ("internal node, [" );
            int next = T[i].r;
            while (next != NIL ){
                printf ("%d", next );
                next = T[next].l;
                if (next != NIL ) printf (", " );
            } // end while
            printf ("]\n" );
        } // end if
    } // end for        
 
    return 0;
}


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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    int result{0};
    int a[3][3];
    REP(i, 3)
        REP(j, 3)
            cin >> a[i][j];
    lol n; cin >> n;
    vector<int> b(102, 0);
    REP(i, n)
    {
        lol bn; cin >> bn;
        b[bn]++;
    }
    if((b[a[0][0]] && b[a[0][1]] && b[a[0][2]]) || (b[a[1][0]] && b[a[1][1]] && b[a[1][2]]) || (b[a[2][0]] && b[a[2][1]] && b[a[2][2]]))
        result++;
    if((b[a[0][0]] && b[a[1][0]] && b[a[2][0]]) || (b[a[0][1]] && b[a[1][1]] && b[a[2][1]]) || (b[a[0][2]] && b[a[1][2]] && b[a[2][2]]))
        result++;
    if((b[a[0][0]] && b[a[1][1]] && b[a[2][2]]) || (b[a[0][2]] && b[a[1][1]] && b[a[2][0]]))
        result++;
    if(result)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Math;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        string[] s = new string[N];
        int[] t = new int[N];
        for(int i = 0; i < N; i++)
        {
            string[] input = ReadLine().Split(' ');
            s[i] = input[0];
            t[i] = int.Parse(input[1]);
        }
        string X = ReadLine();
        int ans = 0;
        bool f = false;
        for(int i = 0; i < N; i++)
        {
            if (f)
            {
                ans += t[i];
            }
            if(X == s[i])
            {
                f = true;
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 13140
r,c=map(int,input().split())
A=[[0 for i in range(c)] for j in range(r)]
for i in range(r):
    A[i]=list(map(int,input().split()))
tate=[0 for i in range(r)]
yoko=[0 for i in range(c)]
for i in range(r):
    for j in range(c):
        tate[i]+=A[i][j]
for i in range(c):
    for j in range(r):
        yoko[i]+=A[j][i]

for i in range(r):
    for j in range(c):
        print(A[i][j],end=" ")
    print(tate[i])
for i in range(c):
    print(yoko[i],end=" ")
print(sum(tate))


Measured memory_bytes: 6212
n = int(input())
h = list(map(int, input().split()))

s = [0] * n
cnt = 0

while True:
    flag = 0
    for i in range(n):
        if h[i] != s[i]:
            s[i] += 1
            flag = 1
        elif h[i] == s[i] and flag:
            cnt += 1
            flag = 0
    if flag:
        cnt += 1

    if h == s:
        break

print(cnt)

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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  int gp;
  double t=1000;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    if(abs(A-(T-x*0.006))<t){
      t=abs(A-(T-x*0.006));
      gp=i+1;
    }
  }
  cout << gp << endl;
}


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

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

int main()
{
    int n = 0;
    cin >> n;
    string s = "";
    cin >> s;
   set<char> l, r;
    int opt = 0;
    for(int q = 0; q < n; q++){
       set<char>::iterator it;
       set<char>::iterator iter;
        int counter = 0;
        for(int i = q + 1; i <= s.length(); i++){
            l.insert(s[i]);
        }
        for(int z = q; z >= 0; z--){
            r.insert(s[z]);
        }
        if(l.size() < r.size()){
            for(it = l.begin(); it != l.end(); ++it){
                    for(iter = r.begin(); iter != r.end(); ++iter){
                        if(*it == *iter)
                            counter++;
                    }
            }
        }else{
            for(it = r.begin(); it != r.end(); ++it){
                    for(iter = l.begin(); iter != l.end(); ++iter){
                        if(*it == *iter)
                            counter++;
                    }
            }
        }
        if(counter > opt)
            opt = counter;

        l.clear();
        r.clear();
    }

    cout << opt << endl;

    return 0;
}


Measured memory_bytes: 256
ABC = sorted(list(map(int,input().split())))

ans = ABC[2]-ABC[1]

if (ABC[2]-(ABC[0]+ans))%2 == 0:
    ans += (ABC[2]-(ABC[0]+ans))//2
else:
    ans += (ABC[2]-(ABC[0]+ans))//2+2
print(ans)



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

int main() {

	string s;
	cin >> s;
	
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			s[i] = '9';
		}
		else {
			s[i] = '1';
		}
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
import itertools

n, m, x = [int(i) for i in input().split()]
a = []
c = []
for i in range(n):
    temp = [int(j) for j in input().split()]
    c.append(temp[0])
    a.append(temp[1:])

ans = 9999999
for i in range(2**n):
    
    # 参考書パターンの作成
    book_list = []
    amount = 0
    for j in range(n):
        if i >> j & 1:
            book_list.append(a[j])
            amount += c[j]
    
    # 習得するスキルの計算
    skill_list = [0] * m
    for book in book_list:
        for skill_index in range(len(book)):
            skill_list[skill_index] += book[skill_index]
    
    # スキルチェック
    check = True
    for j in skill_list:
        if j < x:
            check = False
            break
        else:
            pass
        
    # 価格の計算
    if check:
        ans = min(ans, amount)

# 答えの表示
if ans == 9999999:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 2019
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int n = s.size();
    vector<int> a(n);
    for(int i=0; i<n; i++){
        a[i] = m(((s[i]-'0')*p(10, i)));
    }
    vector<int> pref(n);
    pref[0] = a[0];
    for(int i=1; i<n; i++){
        pref[i] = m(m(a[i])+m(pref[i-1]));
    }
    map<int, int> ma;
    int ans = 0;
    for(auto i: pref){
        if(i == 0)  ans++;
        ans += ma[i];
        ma[i]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,h,w,a,b;
  char s[LIMIT1];
  
  scanf("%lld %lld %lld %lld",&h,&w,&a,&b);
  rep(i,b){
    rep(j,a) printf("0");
    rep(j,w-a) printf("1");
    printf("\n");
  }
  rep(i,h-b){
    rep(j,a) printf("1");
    rep(j,w-a) printf("0");
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  string S;
  cin >> S;
  
  if(S=="ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define FOR(a, b, c) for (int (a) = (b); (a) < (c); ++(a))
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))

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


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string S;
	cin >> S;
	string ans = "";
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0') {
			ans += "0";
		}
		else if (S[i] == '1') {
			ans += "1";
		}
		else if (ans.size() != 0) {
			ans = ans.substr(0, ans.size() - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())

import math

def primes(x):
    if x < 2: return []
    
    primes = [i for i in range(x)]
    primes[1] = 0
    
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2*prime,x,prime): primes[non_prime] = 0
            
    return [prime for prime in primes if prime!=0 and prime%5 == 2]

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 2 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False
    
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False
        
        prime+=step
        step=6-step
    return True


if __name__ == '__main__':
    for z in range(N):
        print(primes(55555)[z],end=" ")


Measured memory_bytes: 5272
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c= sc.next().toCharArray();
		int res = 700;
		if (c[0] == 'o') res+=100;
		if (c[1] == 'o') res+=100;
		if (c[2] == 'o') res+=100;
		System.out.println(res);
	}
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


ll mypow(ll X, ll n) {  // 繰り返し２乗法　計算量log(n)
    if(n == 0) return 1ll;
    ll Y = mypow(X, n/2);
    if(n % 2 == 1) return X * Y % MOD * Y % MOD;
    else return Y * Y % MOD;
}

// 二項係数ライブラリ---------------------------------------------------------------------------------------//
const ll MAX_COM = 1000007;
ll fac[MAX_COM], finv[MAX_COM], inv[MAX_COM];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1ll;
    finv[0] = finv[1] = 1ll;
    inv[1] = 1ll;
    for (int i = 2; i < MAX_COM; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] % MOD * finv[k] % MOD * finv[n - k] % MOD;
}

// Nが大きいときの二項係数計算
// N = 10^9, k = 2*10^5まで使える
const ll MAX_COM_NB = 200010;
vector<ll> COM_NB(MAX_COM_NB);
void COM_NBinit(int N) {
    // COMinit();
    COM_NB[0] = 1ll;
    rp(i, 1, MAX_COM_NB) {
        COM_NB[i] = COM_NB[i-1] * (N+1-i) % MOD * inv[i] % MOD;
    }
}

// 二項係数ライブラリここまで-----------------------------------------------------------------------------------//




int main() {
    int N, a, b;
    cin >> N >> a >> b;
    ll res = mypow(2, N) + MOD - 1;
    res %= MOD;
    COMinit();
    COM_NBinit(N);
    res = (res + MOD - COM_NB[a]) % MOD;
    res = (res + MOD - COM_NB[b]) % MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 28280
#include <iostream>

using namespace std;

int main(){
    int n;
    long long c;
    cin >> n >> c;
    long long x[100001];
    int v[100001];
    long long cost[100001];//そこに行くのにかかる最小コストをメモする。1から数えてn+1番目は初期いち
    long long costA[100001];//時計そこに行くのにかかる最小コストをメモする。1から数えてn+1番目は初期いち
    long long costB[100001];//反時計そこに行くのにかかる最小コストをメモする。1から数えてn+1番目は初期いち
    for(int i=1;i<=n;i++){
        if(i==0){
            x[i]=0;
            v[i]=0;
            cost[i]=0;
            continue;
        }
        cin >> x[i] >>v[i];
        cost[i]=0;
        costA[i]=0;
        costB[i]=0;
    }
    //とけいまわり
    long long total=0;
    for(int i=1;i<n+1;i++){
        costA[i]=costA[i-1]+v[i]-(x[i]-x[i-1]);
//        costA[i]=max(costA[i-1],costA[i-1]+v[i]-(x[i]-x[i-1]));
    }
    for(int i=1;i<n+1;i++){
//        costA[i]=costA[i-1]+v[i]-(x[i]-x[i-1]);
        costA[i]=max(costA[i-1],costA[i]);
//        cout << costA[i]<<endl;
    }
    x[0]=c;
    for(int i=n;i>0;i--){
//        costB[i]=max(costB[(i+1)%(n+1)],costB[(i+1)%(n+1)]+v[i]-(x[(i+1)%(n+1)]-x[i]));
        costB[i]=costB[(i+1)%(n+1)]+v[i]-(x[(i+1)%(n+1)]-x[i]);
    }
    for(int i=n;i>0;i--){
        costB[i]=max(costB[(i+1)%(n+1)],costB[i]);
//        cout << i <<" "<<costB[i] << " "<< x[(i+1)%(n+1)]<<" "<<x[i] << " " << v[i] <<endl;
    }
    x[0]=0;
    for(int i=0;i<=n;i++){
        cost[i]=max(max(costA[i],costB[i]),max(costA[(i+n)%(n+1)]+costB[i]-min((c-x[i])%c,x[i]),costA[i]+costB[(i+1)%(n+1)]-min((c-x[i])%c,x[i])));
        total=(cost[i]<total)?total:cost[i];
        //問題は、反対側に進んでから食べたほうが安いパターンがあるって事
    }
//    for (int i=0;i<n+1;i++){
//        cout <<i<<" "<<cost[i]<<endl;
//    }
    cout <<total<<endl;

    return 0;
}

Measured memory_bytes: 2944