akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main() {
  int a;
  int b;
  
  std::cin >> a >> b;
  if (a * b % 2 == 0) {
    std::cout << "Even" << std::endl;
  } else {
    std::cout << "Odd" << std::endl;
  }
  return 0;
}

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

#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define let const auto
#define USE_T template <typename T>
#define USE_Ti template <typename T = int>
#define USE_TU template <typename T, typename U>

USE_Ti using duo = std::pair<T, T>;
USE_Ti using vec = std::vector<T>;
using ll = long long;
// clang-format off
USE_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE_Ti inline T in(){T x;std::cin>>x;return x;}
USE_Ti inline vec<T> in(int n){vec<T> v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE_T inline void in(T*x,int n){rep(i,n)x[i]=in<T>();}
struct IoSetup {
  IoSetup(){
    using namespace std;
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cerr<<setprecision(10);
  }
} iosetup;
// clang-format on
// }}}
using namespace std;
const int inf = 1001001001;
const ll infll = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

ll tri(ll a, ll b) {
  if (a > b) swap(a, b);
  if (b % a == 0) return a * (2 * (b / a - 1) + 1);
  return a * (b / a * 2) + tri(b % a, a);
}

signed main() {
  ll N = in<ll>();
  ll X = in<ll>();
  cout << X + N - X + tri(X, N - X) << endl;
  return 0;
}


Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/abc106/tasks/abc106_c
// ---------------------------------------------
package main

import "fmt"

func main() {
	var (
		s string
		k int
	)
	fmt.Scan(&s, &k)
	k--
	for i := range s {
		if s[i] == '1' {
			continue
		}

		if k >= i {
			fmt.Println(string(s[i]))
			return
		} else {
			fmt.Println("1")
			return
		}
	}
	fmt.Println("1")
}


Measured memory_bytes: 512
#include<iostream>
#include<set>
#include<map>
#include<string>
using namespace std;

set<int> alp[10],U;
map<char,int> m;
set<int>::iterator ite;

set<int> parse(string s){
  int p = 0;
  int l = s.size();
  set<int> a,b,res;

  if(!s.size())return res;
  for(int i=l-1;i>=0;i--){
    if(s[i]==')')p++;
    if(s[i]=='(')p--;
    if(!p){
      if(s[i] == 'u'){
	a = parse(s.substr(0,i));
	b = parse(s.substr(i+1,l-i-1));
	for(ite = a.begin();ite!=a.end();ite++)res.insert(*ite);
	for(ite = b.begin();ite!=b.end();ite++)res.insert(*ite);
	return res;
      }
      if(s[i] == 'i'){
	a = parse(s.substr(0,i));
	b = parse(s.substr(i+1,l-i-1));
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)!=b.end())res.insert(*ite);
	return res;
      }
      if(s[i] == 'd'){
	a = parse(s.substr(0,i));
	b = parse(s.substr(i+1,l-i-1));
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)==b.end())res.insert(*ite);
	return res;
      }
      if(s[i] == 's'){
	a = parse(s.substr(0,i));
	b = parse(s.substr(i+1,l-i-1));
	for(ite = a.begin();ite!=a.end();ite++)
	  if(b.find(*ite)==b.end())res.insert(*ite);
	for(ite = b.begin();ite!=b.end();ite++)
	  if(a.find(*ite)==a.end())res.insert(*ite);
	return res;
      }
    }
  }

  if(s[0] == 'c'){
    a = parse(s.substr(1,l-1));
    for(ite = U.begin();ite!=U.end();ite++)
      if(a.find(*ite)==a.end())res.insert(*ite);
    return res;
  }
  if(s[0] == '(' && s[l-1] == ')')return parse(s.substr(1,l-2));

  return alp[m[s[0]]];
}

int main(){
  char c;
  int n;
  string str;

  while(cin >> c >> n){
    m.clear();
    for(int i=0;i<5;i++)alp[i].clear();
    U.clear();
    while(c != 'R'){
      int tmp;

      m[c] = m.size();
      for(int i=0;i<n;i++){
	cin >> tmp;
	alp[m[c]].insert(tmp);
	U.insert(tmp);
      }
      cin >> c >> n;
    }
    cin >> str;
    
    set<int> ans = parse(str);
    if(ans.empty())cout << "NULL\n";
    else{
      set<int>::iterator ansend = --(ans.end());
      for(ite = ans.begin();ite!=ansend;ite++)cout << *ite << " ";
      cout << *ansend << endl;
    }
  }
}     

Measured memory_bytes: 0
a,b,c=map(int,input().split())
k=int(input())
if a<b and c>b:
    exit(print("Yes"))
while(b<=a and k>0):
    b*=2
    k-=1
while(c<=b and k>0):
    c*=2
    k-=1
if a<b and c>b:
    print("Yes")
else: print("No")

Measured memory_bytes: 61760
/*2019/08/25 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 1000000009
#define MAX -1000000009
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int llasc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
int lldesc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
/*
int asc_t(const void *a,const void *b){return ((struct_t*)a)->member - ((struct_t*)b)->member;}
int desc_t(const void *a,const void *b){return ((struct_t*)b)->member - ((struct_t*)a)->member;}
*/


int main(){
    int N,X,x[200000],d[200000];

    scanf("%d %d",&N,&X);
    for(int i=0;i<N;i++){
        scanf("%d",&x[i]);
    }
    x[N]=X;

    qsort(x,N+1,sizeof(int),asc);
    int tmp=x[1]-x[0];
    for(int i=2;i<=N;i++){
        tmp=gcd(x[i]-x[i-1],tmp);    
    }
    printf("%d\n",tmp);
    return 0;

}


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

using namespace std;

int main() {

    int X;
    cin >> X;

    int ans = 0;
    int a, b;

    a = X / 500;
    X = X % 500;

    b = X / 5;

    ans = a * 1000 + b * 5;

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int n, p, max = 0, ans = 0;
    cin >> n;
    for (int i = 0; i <n; i++) {
        cin >> p;
        ans += p;
        if (max < p) max = p;
    }
    cout << ans - max / 2 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int dp[2005];
vector<int>g[2005];
void dfs(int s){
    for(int x:g[s]){
        if(dp[x] == -1){
            dp[x] = dp[s] + 1;
            dfs(x);
        }
    }
}
void dfs(int s,int p){
    for(int x:g[s]){
        if(x!=p and dp[x] == -1){
            dp[x] = dp[s] + 1;
            dfs(x,s);
        }
    }
}
int main(){
    int n,k;
    cin >> n >> k;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = n;
    if(k%2==0){
        rep(i,n){
            memset(dp,-1,sizeof(dp));
            dp[i] = 0;
            dfs(i);
            int temp = 0;
            rep(j,n){
                if(dp[j] > k/2){
                    temp++;
                }
            }
            ans = min(temp, ans);
        }
    }else{
        rep(a,n){
            for(int b:g[a]){
                memset(dp,-1,sizeof(dp));
                dp[a] = dp[b] = 0;
                dfs(a,b);
                dfs(b,a);
                int temp = 0;
                rep(j,n){
                    if(dp[j] > k/2){
                        temp++;
                    }
                }
                ans = min(temp, ans);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
ll dp[100001][101];
ll n,w;
ll vw[100001][3];

ll solve (ll weight, ll i){
	if(weight > w || i > n)return MINI;
	if(weight <= w && i == n){
		if(vw[i][1]+weight <= w)return vw[i][2];
		else return 0;
	}
	if(dp[weight][i]!=-1)return dp[weight][i];
	dp[weight][i]=MINI;
	dp[weight][i]=max(vw[i][2]+solve(weight+vw[i][1],i+1),solve(weight,i+1));
	return dp[weight][i];
}

int main(){FIN;
	cin >> n >> w;
	fore(i,1,n+1){
		fore(j,1,3){
			cin >> vw[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout << solve(0,1);
}

Measured memory_bytes: 79488
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    int cnt = 0;
    if (S[0] == 'A')
    {
        if (!('a' <= S[1] && S[1] <= 'z'))
        {
            cout << "WA" << endl;
            return 0;
        }

        for (int i = 2; i <= S.length() - 2; i++)
        {
            if (!(('a' <= S[i] && S[i] <= 'z') || S[i] == 'C'))
            {
                cout << "WA" << endl;
                return 0;
            }
            if (S[i] == 'C') cnt++;
            
        }

        if (!('a' <= S.back() && S.back() <= 'z'))
        {
            cout << "WA" << endl;
            return 0;
        }

        if (cnt == 1)
        {
            cout << "AC" << endl;
        }else
        {
            cout << "WA" << endl;
        }
        
    }else
    {
        cout << "WA" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(void){
    string S;
    cin>> S;
    if(S=="ABC") printf("ARC");
    else printf("ABC");
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  long double l, e;
  cin >> l;
  e = l / 3;
  e = e * e * e;
  cout << fixed << setprecision(12) << e << endl;
}

Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <numeric>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define INF 999999999
using namespace std;

int main(){
    int h, w; cin >> h >> w;
    char m[h+2][w+2] = {'.'};

    rep(i, 1, h+1){
        rep(j, 1, w+1) cin >> m[i][j];
    }


    int ans = 0;
    rep(i, 1, h+1){
        rep(j, 1, w+1){
            ans = 0;
            if(m[i][j] == '#') cout << "#";
            else if(m[i][j] == '.'){
                if(m[i-1][j-1] == '#') ans += 1;
                if(m[i-1][j] == '#') ans += 1;
                if(m[i-1][j+1] == '#') ans += 1;
                if(m[i][j-1] == '#') ans += 1;
                if(m[i][j+1] == '#') ans += 1;
                if(m[i+1][j-1] == '#') ans += 1;
                if(m[i+1][j] == '#') ans += 1;
                if(m[i+1][j+1] == '#') ans += 1;
                cout << ans;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll h,w,k,ans;
bool H[10],W[10];
char ch[10][10];

void cal(){
	ll cnt=0;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			if(H[i]==1||W[j]==1){
				continue;
			}
			if(ch[i][j]=='#'){
				cnt++;
			}
		}
	}
	if(cnt==k){
		ans++;
	}
	return;
}
void dep2(ll now){
	if(now==w){
		cal();
		return;
	}
	W[now]=0;dep2(now+1);
	W[now]=1;dep2(now+1);
}
void dep1(ll now){
	if(now==h){
		dep2(0);
		return;
	}
	H[now]=0;dep1(now+1);
	H[now]=1;dep1(now+1);
}
int main() {
	cin>>h>>w>>k;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>ch[i][j];
		}
	}
	dep1(0);
	cout <<ans;
	// your code goes here
	return 0;
}

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

int main() {
    using namespace std;
    int n,x,m;
    vector<int> v;
    cin >> n >> x;
    int sum = 0;
    int minimum = 1000;
    for (int i = 0; i < n; i++) {
        cin >> m;
        v.push_back(m);
        sum += m;
        if (m < minimum) minimum = m;
    }

    x -= sum;
    cout << v.size() + x / minimum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;


class Program
{


    static void Main(string[] args)
    {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

        //int val = int.Parse(Console.ReadLine());
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //string str = Console.ReadLine();
        //string[] strs = Console.ReadLine().Split(cs);

        //string res="";
        //int res = 0; ;
        //int t = int.Parse(Console.ReadLine());
        //string str = Console.ReadLine();
        //int[] vals = parseAry(Console.ReadLine().Split(cs));
        //int n = int.Parse(Console.ReadLine());
		//string res="";
		int res = 0;

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		if ( vals[0] > vals[1] ) { res += vals[0]; vals[0]--; } else { res += vals[1]; vals[1]--; }
		if ( vals[0] > vals[1] ) { res += vals[0]; vals[0]--; } else { res += vals[1]; vals[1]--; }

		Console.WriteLine(res);


        return;
    }

    //　String[]  ----->  int[]
    static int[] parseAry(string[] str)
    {
        int[] nums = new int[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
        return nums;
    }
    //　String[]  ----->  long[]
    static long[] parseAryL(string[] str)
    {
        long[] nums = new long[str.Length];
        for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
        return nums;
    }

    //文字列を1文字ずつString[]に入れる
    static string[] strAry(String str)
    {
        string[] re = new string[str.Length];
        for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
        return re;
    }

}

public class PrimeFactor {

	public IEnumerable<long> Enumerate(long n) {
		while ( n > 1 ) {
			long factor = GetFactor(n);
			yield return factor;
			n = n / factor;
		}
	}

	private long GetFactor(long n, int seed = 1) {
		if ( n % 2 == 0 )
			return 2;
		if ( IsPrime(n) )
			return n;
		long x = 2;
		long y = 2;
		long d = 1;
		long count = 0;
		while ( d == 1 ) {
			count++;
			x = f(x, n, seed);
			y = f(f(y, n, seed), n, seed);
			d = Gcd(Math.Abs(x - y), n);
		}
		if ( d == n )
			// 見つからなかった、乱数発生のシードを変えて再挑戦。
			return GetFactor(n, seed + 1);
		// 素数でない可能性もあるので、再度呼び出す
		return GetFactor(d);
	}

	private int[] seeds = new int[] { 3, 5, 7, 11, 13, 17 };
	private long f(long x, long n, int seed) {
		return ( seeds[seed % 6] * x + seed ) % n;
	}

	private static long Gcd(long a, long b) {
		if ( a < b )
			return Gcd(b, a);  // 引数を入替えて自分を呼び出す
		if ( b == 0 )
			return a;
		long d = 0;
		do {
			d = a % b;
			a = b;
			b = d;
		} while ( d != 0 );
		return a;
	}

	private static bool IsPrime(long number) {
		long boundary = (long)Math.Floor(Math.Sqrt(number));

		if ( number == 1 )
			return false;
		if ( number == 2 )
			return true;

		for ( long i = 2; i <= boundary; ++i ) {
			if ( number % i == 0 )
				return false;
		}

		return true;
	}
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x)
		cout<<"NO";
	if(a==x)
		cout<<"YES";
	int c=x-a;
	if(a<x&&b>=c)
		cout<<"YES";
	if(a<x&&b<c)
		cout<<"NO";
	return 0; 
}

Measured memory_bytes: 256
#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 <bitset>
#include <stack>
#include <cstdlib>
#define REP(i,n) for(int i = 0; n > i; i++)
#define MOD 1000000007
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;
char str[101];
map<char, char> kako = { {'(',')'},{'[',']'} };
int is_balanced(int s) {
	for (int i = s+1; strlen(str) > i; i++) {
		if (str[i] == ')' || str[i] == ']') {
			if(str[i] != kako[str[s]])
				return -1;
			else {
				return i;
			}
		}
		if (str[i] == '(' || str[i] == '[') {
			i = is_balanced(i);
			if (i == -1) return -1;
		}
	}
	return -1;
}

int main() {
	while (1) {
		memset(str, 0, sizeof(str));
		for(int i = 0; ;i++) {
			scanf("%c", &str[i]);
			if (str[i] == '.') break;
		}
		scanf("%*c");
		if (!strcmp(str, "."))
			return 0;
		bool f = true;
		REP(i, strlen(str)) {
			if (str[i] == ')' || str[i] == ']') {
				printf("no\n");
				f = false;
				break;
			}
			if (str[i] == '(' || str[i] == '[') {
				i = is_balanced(i);
				if (i == -1) {
					printf("no\n");
					f = false;
					break;
				}
			}
		}
		if (f) printf("yes\n");
	}

	return 0;
}

Measured memory_bytes: 3096
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    auto H = aryread();
    H.sort();
    H[0 .. max(0, cast(long)$ - K)].sum().writeln();
}


Measured memory_bytes: 12628
N = int(input())
a = input().split()

list_num = [int(i) for i in a]

max_num = 0
count = 0

for i in range(len(list_num)-1):
    if list_num[i] < list_num[i + 1]:
        if count > max_num:
            max_num = count
        count = 0
    else:
        count += 1

if count > max_num:
    max_num = count
print(max_num)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  
  int arr[n];
  for(int i = 0; i < n; i++) {
  	cin >> arr[i];
  }
  
  int ret[n];
  for(int i = 0; i < n; i++) {
    ret[arr[i] - 1] = i + 1;
  }
  for(int i = 0; i < n; i++) {
    cout << ret[i] << ' ';
  }
  
  return 0;
}

Measured memory_bytes: 1536
d = [0 for _ in range(1000 + 1)]
for i in range(1, 1000+1):
    j = i+1
    s = i
    while s <= 1000:
        s += j
        j += 1
        if s <= 1000:
            d[s] += 1

while True:
    N = int(raw_input())
    if N==0:
        break
    print d[N]


Measured memory_bytes: 4232
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 2e5 + 4;
int n,a[MAXN];
map<int,int> mert;
int main(){
    mert.clear();
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans += mert[i - a[i]];
        mert[a[i] + i] ++;
    }
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int A, B, C;

signed main() {
    cin >> A >> B >> C;
    cout << B + min(C, A + B + 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL
#include <pprint.hpp>
#endif
#define endl "\n";
#define pb push_back
#define md 1000000007
#define ll long long int
#define all(v) v.begin(),v.end()
ll power(ll a,ll b){ll z=1;while(b){if(b&1){z*=a;z%=md;}a*=a;a%=md;b/=2;}return z%md;}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n;
double a[3100],ans=0.0,p;
int main(){
	//You need to change array size!
	#ifndef LOCAL
	ios_base::sync_with_stdio(false);	cin.tie(NULL);
	#endif 
	
	a[0]=1.0;
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>p;
		for(int j=i+1;j>=0;--j){
			a[j] = (j==0 ? 0 : a[j-1]*p) + a[j]*(1.0-p);
		}
	}
	for(int i=0;i<=n;++i){
		if(i>(n-i))
			ans+=a[i];
	}
	cout<<fixed<<setprecision(12)<<ans;
	
	return 0;	
}

Measured memory_bytes: 3796
#include<stdio.h>
#include<string.h>
#include<map>
#include<queue>
#include<math.h>
using namespace std;
int a[10005];
float pj[1005];
float m[1005];
float x=1000000;
int main()
{
	int n;
	int t,q;
	scanf("%d",&n);
	scanf("%d %d",&t,&q);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);	
	}
	for(int i=1;i<=n;i++)
	{
		pj[i]=t-(0.006*a[i]);
		m[i]=fabs(pj[i]-q);
		if(x>m[i])
		{
			x=m[i];
		}	
	}
	for(int j=1;j<=n;j++)
	{
		if(m[j]==x)
		{
			printf("%d",j);
	     break;
	   }
	}
	return 0;
}

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


using namespace std;

#define ll long long

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int a=s[0]-'0';
	int b=s[1]-'0';
	int c=s[2]-'0';
	cout << a+b+c;
	return 0;
}




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

int main()
{
    int n,q;
    cin >> n;
    vector<int> S(n);
    for(int i=0;i<n;i++)
        cin >> S[i];
    cin >> q;
    vector<int> T(q);
    for(int i=0;i<q;i++)
        cin >> T[i];
    
    int ret = 0;
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(T[i] == S[j]){
                ret ++;
                break;
            }
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int H,W;
    cin >> H >> W;
    long long int All=H*W;
    if(H==1)cout << 1 << endl;
    else if(W==1)cout << 1 << endl;
    else if(All%2==0)cout << All/2 << endl;
    else cout << All/2+1<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){
	int i;
	int input[2];
	
	while(1){
		scanf("%d %d", &input[0], &input[1]);
		if(input[0]==0 && input[1] == 0){
			return 0;
		}
		if(input[0] > input[1]){
			printf("%d %d\n", input[1], input[0]);
		}
		else{
			printf("%d %d\n", input[0], input[1]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll h,w ;
	cin >> h >> w ;
	map<ll,ll> gs,dis ;
	for(int i=1;i<=w;i++) gs[i] = i ;
	gs[w+10] = -1 ;
	dis[0] = w ;
	for(int i=1;i<=h;i++){
		ll a,b ;
		cin >> a >> b ;
		ll mx = -1 ;
		for(auto it=gs.lower_bound(a);it->first<=b+1;it=gs.erase(it)){
			ll g = it->first ;
			ll s = it->second ;
			chmax(mx,s) ;
			if(dis.count(g-s)){
				dis[g-s]-- ;
				if(dis[g-s]==0) dis.erase(g-s) ;
			}
		}
		if(mx>=0&&b<w){
			gs[b+1] = mx ;
			dis[b+1-mx]++ ;
		}
		ll ans = -1 ;
		if(!dis.empty()){
			ans = i+dis.begin()->first ;
		}
		cout << ans << endl ;
	}
}


Measured memory_bytes: 16108
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n,x,m; cin >> n >> x;
  int minm=INF;
  REP(i,n) {
    cin >> m;
    x-=m;
    minm=min(m,minm);
  }
  COUT(n + x/minm);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  map<int, int> m;
  vector<pair<int, int> > vec;
  REP(i, n) {
    int a, b;
    cin >> a >> b;
    vec.push_back(make_pair(a, b));
  }
  sort(ALL(vec));
  REP(i, n) {
    k -= vec[i].second;
    if (k <= 0) {
      cout << vec[i].first << endl;
      return 0;
    }
  }
}

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

int main(){
	int n,a[10],b[10],k;
	a[0]=1;
	for(int i=1;i<10;i++){
		a[i]=2*a[i-1];
	}
	
	while(cin >> n){
		for(int i=0;i<10;i++){
			b[i]=0;
		}
		for(int i=9;n!=0;i--){
			if(n>=a[i]){
				n-=a[i];
				b[i]=a[i];
			}
		}
		k=0;
		for(int i=0;i<10;i++){
			
			if(b[i]!=0){
				if(k!=0){
					cout <<" ";
				}
				cout << b[i] ;
				k++;
			}
		}
		cout << "\n" ;
	}
		
		
		
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h> 
using namespace std; 
  
long long f[1000055]={0};
int main()
{
    int  n,flag=1;
    cin>>n;
    
    long long a[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
     
    }
    
    sort(a,a+n);
    
    for(int i=0;i<n-1;i++)
    {
        if(a[i]==a[i+1])
        {
            flag=0;
            break;
        }
    }
   
    flag==1? cout<<"YES" : cout<<"NO";
    
    
}   


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 ll n;
 cin>>n;
 ll ans=0,a=0,b=0;
 a=n/500;
 b=(n-n/500*500)/5;
 ans=a*1000+b*5;
 cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int N;
  int  K, point = 1;
  cin >> N >> K;
  while (1)
  {
    N = N / K;
    if (N == 0)
    {
      break;
    }
    point++;
  }
  cout << point << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

ll f(ll A, ll B, ll C) {
  return abs((A+1)/2 - (A/2)) * B * C;
}

int main2() {
  ll A, B, C; cin >> A >> B >> C;
  ll ans = min(f(A,B,C), min(f(B,C,A),f(C,A,B)));
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,w,d = m()

dp = [[0,0] for i in range(h*w+1)]

cost = [0 for i in range(h*w+1)]

for i in range(h):
    a = l()
    for j in range(w):
        dp[a[j]] = [i,j]

for i in range(1,d+1):
    co = i
    while True:
        if co+d > h*w:
            break
        cost[co+d] = cost[co] + abs(dp[co+d][0] - dp[co][0]) + abs(dp[co+d][1] - dp[co][1])
        co += d

n = onem()

for i in range(n):
    L,R = m()
    print(abs(cost[R]-cost[L]))



Measured memory_bytes: 69484
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

ll power(ll a, ll n, ll mod) {
  ll res = 1;
  while (n) {
    if (n&1) (res *= a) %= mod;
    (a *= a) %= mod;
    n >>= 1;
  }
  return res;
}

const int MAX = 210000, MOD = 1e9+7;
ll fac[MAX], finv[MAX];
void init() {
  fac[0] = fac[1] = 1;
  for (int i=2; i<MAX; i++)
    fac[i] = fac[i-1]*i%MOD;
  finv[MAX-1] = power(fac[MAX-1], MOD-2, MOD);
  for (int i=MAX-1; i>1; i--)
    finv[i-1] = finv[i]*i%MOD;
  finv[0] = 1;
}

int comb(int n, int r) {
  return fac[n]*((finv[r]*finv[n-r])%MOD)%MOD;
}

int main() {
  init();
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<ll> mid(H-A);
  rep(i, mid.size())
    mid[i] = comb(B-1+i, i);
  ll ans = 0;
  rep(i, mid.size())
    (ans += mid[i]*comb(W-B-1+H-i-1, H-i-1)%MOD) %= MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
from typing import Optional


class SegmentTree(object):
    def __init__(self, n: int) -> None:
        size = 2 ** (n.bit_length())
        self.size = 2 * size - 1
        self.data = [0] * self.size
        self.lazy = [None] * self.size

    def update(self, lo: int, hi: int, v: int) -> None:
        def _update(r: int, i: int, j: int, lz: Optional[int]) -> int:
            left, right = r * 2 + 1, r * 2 + 2
            if (lz is None):
                lz = lazy[r]
            lazy[r] = None

            if (lo <= i and j <= hi):
                data[r] = v * (j - i + 1)
                if (i < j):
                    lazy[left] = v
                    lazy[right] = v
            else:
                mid = (i + j) // 2
                if (mid >= lo):
                    lv = _update(left, i, mid, lz)
                else:
                    if (lz is not None):
                        lazy[left] = lz
                        lv = lz * (mid - i + 1)
                    elif (lazy[left] is not None):
                        lv = lazy[left] * (mid - i + 1)
                    else:
                        lv = data[left]

                if (mid < hi):
                    rv = _update(right, mid + 1, j, lz)
                else:
                    if (lz is not None):
                        lazy[right] = lz
                        rv = lz * (j - mid)
                    elif (lazy[right] is not None):
                        rv = lazy[right] * (j - mid)
                    else:
                        rv = data[right]

                data[r] = lv + rv

            return data[r]

        data = self.data
        lazy = self.lazy
        _update(0, 0, self.size // 2, None)

    def sum(self, lo: int, hi: int) -> int:
        def _sum(r: int, i: int, j: int, lz: Optional[int]) -> int:
            if (lz is None):
                lz = lazy[r]
            lazy[r] = None
            if (lz is not None):
                data[r] = lz * (j - i + 1)

            left, right = r * 2 + 1, r * 2 + 2
            if (lo <= i and j <= hi):
                if (lz is not None and i < j):
                    lazy[left] = lz
                    lazy[right] = lz
                return data[r]
            else:
                mid = (i + j) // 2
                lv, rv = 0, 0

                if (mid >= lo):
                    lv = _sum(left, i, mid, lz)
                else:
                    if (lz is not None):
                        lazy[left] = lz
                if (mid < hi):
                    rv = _sum(right, mid + 1, j, lz)
                else:
                    if (lz is not None):
                        lazy[right] = lz
                return lv + rv

        data = self.data
        lazy = self.lazy
        return _sum(0, 0, self.size // 2, None)


if __name__ == "__main__":
    n, q = map(lambda x: int(x), input().split())
    segtree = SegmentTree(n)

    for _ in range(q):
        com, *v = map(lambda x: int(x), input().split())
        if (0 == com):
            segtree.update(v[0], v[1], v[2])
        else:
            print(segtree.sum(v[0], v[1]))



Measured memory_bytes: 16812
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))
s=A[0]
k=sum(A)-s
ans=abs(s-k)
for i in range(1,N-1):
    s+=A[i]
    k-=A[i]
    ans=min(ans,abs(s-k))

print(ans)

Measured memory_bytes: 76752
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e4+5;
const int M=105;
const int MOD=1e9+7;

string n;
int d;
int cache[N][M][2];
int sz=0, x[N];

int dp(int idx, int rem, int less)
{
	if(idx==sz+1)
		return (rem==0);
	int &ans=cache[idx][rem][less];
	if(ans!=-1)
		return ans;
	ans=0;
	if(!less)
	{
		for(int i=0;i<=x[idx];i++)
			ans+=dp(idx+1, (rem+i)%d, less|(i<x[idx]));
	}
	else
	{
		for(int i=0;i<=9;i++)
			ans+=dp(idx+1, (rem+i)%d, 1);
	}
	ans%=MOD;
	return ans;
}

int f(string &s)
{
	sz=s.size();
	for(int i=1;i<=sz;i++)
		x[i]=(s[i-1]-'0');
	memset(cache, -1, sizeof(cache));
	return dp(1, 0, 0);
}

int32_t main()
{
	IOS;
	cin>>n>>d;
	int ans=f(n);
	ans-=1;
	ans+=MOD;
	ans%=MOD;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 17536
def takahasi(n , m , a):

    ans = "IMPOSSIBLE"
    list1n = []

    for i in range(m):
        if a[i][0] == 1 or a[i][1] == n:
            list1n.append(a[i][1] if a[i][0] == 1 else a[i][0])

    if len(list1n) != len(set(list1n)):
        ans = "POSSIBLE"

    return ans

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

if __name__ == '__main__':
    main()

Measured memory_bytes: 106456
#include <bits/stdc++.h>
#if ONLINE_JUDGE
    #define DEBUG false
#else
    #define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
using LL = signed long long int;
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcinpb(T &v, U n){rep(i, n){typename T::value_type a;std::cin >> a;v.pb(a);}}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        auto f=[&os](typename T::value_type p){os<<p<<',';};
        std::for_each(all(v),f);
        os<<"}\n";
    }
}
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
// M_PI 3.1415...

void Main(){
    using std::cout;
    using std::cin;
    cill(n);
    V<LL> v(n), ph(201000), mh(201000), idxes;
    LL ans = 0;
    for(auto&& i : v) cin >> i;
    rep(i, n){
        if(i+1 + v[i] < 200900){
            ph[ i+1 + v[i] ]++;
            if (ph[ i+1 + v[i] ] == 1){
                idxes.pb(i+1 + v[i]);
            }
        }
        if(i+1 - v[i] > 0){
            mh[ i+1 - v[i] ]++;
            if (mh[ i+1 - v[i] ] == 1){
                idxes.pb(i+1 - v[i]);
            }
        }

    }
    SORT(idxes);
    UNIQUE(idxes);
    dumpv(idxes);
    for(auto&& i : idxes){
        ans += ph[i] * mh[i];
        dump(ans);
    }
    co(ans);
}

int main() {
    std::cin.tie(nullptr);std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 9932
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
using namespace std;
int main()
{
	int a, b, c, d, e,f,g,h, i, j, k, l, m, n, o, p, q, r,s,t,u;
	while (1){
		cin >> a;
		if (a == 0){ break; }
		cin >> b;
		cin >> c;
		cin >> d;
		cin >> e;
		cin >> f;
		cin >> g;
		cin >> h;
		cin >> i;
		cin >> j;
		a -= b;
		a -= c;
		a -= d;
		a -= e;
		a -= f;
		a -= g;
		a -= h;
		a -= i;
		a -= j;
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
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();
		sc.close();
		String IMPOSSIBLE = "IMPOSSIBLE";
		if(A % 2 != B % 2) System.out.println(IMPOSSIBLE);
		else System.out.println((A + B) / 2);
	}
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cout << n * 800 - n / 15 * 200 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);


char mp[1000][1000];
void solve() {
	int h, w, a, b; cin >> h >> w >> a >> b;
	rep(i, h) {
		if (i < b) {
			rep(j, w) {
				if (j < a) {
					mp[i][j] = '0';
				}
				else {
					mp[i][j] = '1';
				}
			}
		}
		else {
			rep(j, w) {
				if (j < a) {
					mp[i][j] = '1';
				}
				else {
					mp[i][j] = '0';
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			//if (j > 0)cout << " ";
			cout << mp[i][j];
		}
		cout << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


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


int main(){
	
	int N;
	
	
	cin >> N;
	
	int ans = 0 ;
	
	for ( int i = N ; i >=1 ; i--){
		ans+=i;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools
n,m,x = map(int,input().split())
ca = []
for i in range(n):
    ca.append([int(i) for i in input().split()])

comb = []
l = [i for i in range(n)]
for i in range(n+1):
    comb.append(list(itertools.combinations(l, i)))
#print(comb)

rikai = [0 for i in range(m)]
ans = pow(10, 1000)
tmp = 0
for i in range(len(comb)):
    for j in range(len(comb[i])):
        for h in comb[i][j]:
            for k in range(m):
                rikai[k] += ca[h][k+1]
            tmp += ca[h][0]
        #print(rikai)
        flag = True
        for p in rikai:
            if p < x:
                flag = False
        if ans > tmp and flag:
            ans = tmp
            #print(tmp)
            #print(i,j)
        tmp = 0
        rikai = [0 for i in range(m)]
if ans == pow(10, 1000):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9288
import math

def func(a, b):
	if len(str(a)) > len(str(b)): return len(str(a))
	return len(str(b))
N = int(input())
start = int(math.sqrt(N))
for i in range(0, start):
	if N%(start-i) == 0:
		print(func(start-i, N//(start-i)))
		break

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

int main() {
  int r, g;
  cin >> r >> g;
  
  /*
  (r + P) / 2 = g
  r + P = 2g
  P = 2g - r
  */
  
  cout << g * 2 - r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
using namespace boost::range;
using boost::irange;
using boost::math::gcd;
using boost::math::lcm;

using ll = int64_t;
constexpr char LN = '\n';
template<class T> bool chmax(T& a, const T& b) {if(a<b){a=b;return true;}else{return false;}}
template<class T> bool chmin(T& a, const T& b) {if(b<a){a=b;return true;}else{return false;}}

#ifdef LOCAL
template<class H> void dump_(const char* s, H h) {cout<<s<<"="<<h<<LN; }
template<class H, class... T> void dump_(const char* s, H h, T... t) {for(;*s!=',';++s){cout<<*s;}cout<<"="<<h<<",";dump_(++s,t...);}
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__)
#else
#define dump(...)
#endif

struct init_ {init_(){cin.tie(nullptr);ios::sync_with_stdio(false);}} init_;

template<class C> C scan(size_t n) {C c(n);for(auto& v:c){cin>>v;}return c;}
template<class C> C scan(size_t n, size_t m) {C vss(n);for(auto& vs:vss){vs.resize(m);for(auto& v:vs){cin>>v;}}return vss;}

template<class R> struct Joined { const R& r; const char* s; };
template<class R> Joined<R> joined(const R& r, const char* s = " ") {return{r,s};}
template<class R> ostream& operator<<(ostream& out, Joined<R> j) {bool f=true;for(const auto& v:j.r){if(f){f=false;}else{out<<j.s;}out<<v;}return out;}

template<class T> using matrix = vector<vector<T>>;
template<class T> matrix<T> make_matrix(size_t n, size_t m, const T& init = T()) {matrix<T> vss(n);for(auto& vs:vss){vs.resize(m,init);}return vss;}
template<class T> ostream& operator<<(ostream& out, Joined<matrix<T>> j) {bool a=true;for(const auto& vs:j.r){if(a){a=false;}else{out<<LN;}bool f=true;for(const auto& v:vs){if(f){f=false;}else{out<<j.s;}out << v;}}return out;}

template<class T> void show_(const T& t) {cout<<t;}
template<class T> void show_(const vector<T>& v) {cout<<joined(v);}
void show_(bool b) {cout<<(b?"Yes":"No");}
void show_(double d) {cout<<fixed<<setprecision(12)<<d;}
template<class T, class... TS> void show_(const T& t, TS... ts) {show_(t);cout<<' ';show_(ts...);}
template<class T> void show(const T& t) {show_(t);cout<<LN;}
template<class T, class... TS> void show(const T& t, TS... ts) {show_(t, ts...);cout<<LN;}

int main() {
    string s;
    cin >> s;
    int half = s.size() / 2;
    int lhs = 0, rhs = 0;
    for (int i : irange(0ul, s.size())) {
        int r = s.size() - 1 - i;
        if (s[i] != s[r]) {
            if (i < half) {
                lhs++;
            }
            if (r < half) {
                rhs++;
            }
        }
        dump(s[i], s[r], lhs, rhs);
    }
    show(min(lhs, rhs));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-7;
typedef long long ll;
const ll maxx=2e5+10;
const ll mod=1e9+7;
const ll inf=0x3f3f3f3f;
int a[maxx];
int main(){
    for(int i=1;i<=3;i++) cin>>a[i];
    sort(a+1,a+1+3);
    if(a[1]==a[2]&&a[2]!=a[3]) puts("Yes");
    else if(a[2]==a[3]&&a[1]!=a[2]) puts("Yes");
    else puts("No");
}


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

using ll = long long;
using ld = long double;

int main()
{
    int a,b,ans=0;
    cin >> a >> b;
    
    
    for(int i = a; i <= b; i++)
    {
        if(i%10 == i/10000 % 10 && 
            i/10%10 == i/1000%10)
            {
                ans++;
            }
    }
    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int cnt = 0;
	int M = 3001;
	int rest = 0;
	rep(r, M) {
		rep(g, M) {
			rest = N - R * r - G * g;
			if (rest >= 0 && rest % B == 0) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cmath>
#define ll long long
using namespace std;
#define rep2(i,a,n) for(int i=a;i<=n;i++)
int main(void){
    // Your code here!
  int n;
  cin>>n;

 if(n==1)
    {
        cout<<n;
        return 0;
    }
    
string s;
cin>>s;
int count=1;
  for(int i=0;i<s.length()-1;i++){
     if(s[i+1]!=s[i])
        count++;
  }
  cout<<count;
}


Measured memory_bytes: 3316