akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#include <iomanip>
#define rep(i,x) for(ll i=0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
using graph = vector<vector<ll>>;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
    if (a < b)swap(a, b);
    if (a % b == 0) return b;
    else return gcd(b, a % b);
}/*フィボナッチテンプレ
ll memo[50];
ll fibo(ll n) {
    if (memo[n] != 0)return memo[n];
    if (n <= 1)return memo[n] = n;
    else return memo[n] = fibo(n - 1) + fibo(n - 2);
}
*/
bool isp(ll n) {
    bool res = true;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            res = false;
            break;
        }
    }
    return res;
}

int main() {
  ll L,R;
  cin >> L >> R;
  cout << (L - 1) * (R - 1) << endl;
}

Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc102/tasks/abc102_b
# Python 1st Try
import sys


def solve(N, givenList):
    answer = 0
    sortedList = sorted(givenList, reverse=True)
    answer = sortedList[0]-sortedList[-1]
    return answer


if __name__ == "__main__":
    N = int(sys.stdin.readline())
    Ai = list(map(int, sys.stdin.readline().split(' ')))
    print(solve(N, Ai))


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

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

int main() {
  int n,i;
  cin>>n;
  long long int a[n];
  for(i=0;i<n;i++)
    cin>>a[i];
  int ans;
  ans=a[0];
  for(i=0;i<n;i++)
    ans=gcd(ans,a[i]);

  cout<<ans;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int i = 0;
	int a = 0;
	int b = 0; 
	int sum = 0;
	int keta = 0;
	int count = 0;

	// もし入力の終わりではないならループする
	while(scanf("%d %d", &a, &b) != EOF && count <= 200)
	{
		// もし入力された値が規定外だったらif文以下の処理をスキップする。
		if(a < 0 || b <0 || a > 1000000 || b > 1000000)
		{
			continue;
		}
		
		sum = a + b;

		while(sum >= 1)
		{
			sum /= 10;

			keta++;
		}

		printf("%d\n", keta);

		keta = 0;
		count++;
	}

	return 0;
}

Measured memory_bytes: 600
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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 main()
{
    int n; cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];

    vll bit(64, 0);
    rep(i, n){
        rep(j, 64){
            if(((a[i]>>j)&1)==1) bit[j]++;
        }
    }

    ll ans = 0;
    ll now = 1;
    rep(i, 64){
        ll t = bit[i] * ((ll)n - bit[i]);
        t %= MOD;
        t *= now;
        t %= MOD;
        ans = (ans+t)%MOD;
        now = (now*2)%MOD;
    }

    pr(ans);
    return 0;}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < 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() {
    int n;
    cin >> n;
    map<string, ll> mp;
    rep(i, 0, n) {
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll ans = 0;
    for (auto i : mp) {
        ans += (ll)i.second * (i.second - 1LL) / 2;
    }
    cout << ans << endl;
    return 0;
}


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

int main(void){

	int n=10, h1=0, h2=0, h3=0, h0;
	for (int i=0; i<n; i++){
		cin>>h0;
		if (h0>h1) swap(h0, h1);
		if (h0>h2) swap(h0, h2);
		if (h0>h3) swap(h0, h3);
	}
	cout<<h1<<endl;
	cout<<h2<<endl;
	cout<<h3<<endl;

	return 0;
} 

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

using namespace std;

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

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '?') {
			s[i] = 'D';
		}
	}
	cout << s << endl;
		 
	return 0;
}


Measured memory_bytes: 3752
import sys
input = sys.stdin.readline
def linput():
    return list(map(int, input().split()))

def gcd(n,m):
    while m:
        n,m = m, n%m
    return n

def lcm(n,m):
    return n*m//gcd(n,m)

def main():
    # N = int(input())
    A,B,C,D = linput()
    # vA = linput()
    # S = input()
    # mX = [linput() for _ in [0,]*N]
    U = B-A+1
    E = lcm(C, D)
    tC = (B//C - A//C) + (A%C==0)
    tD = (B//D - A//D) + (A%D==0)
    tE = (B//E - A//E) + (A%E==0)

    # res = 0
    # res = -(-N//M)

    res = U - tC - tD + tE
    print(res)

main()


Measured memory_bytes: 3316
/*
  A - ι⊥l
  <http://abc058.contest.atcoder.jp/tasks/abc058_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {
  int a,b,c;
  scanf("%d %d %d", &a,&b,&c);

  if( (b-a) == (c-b) ){
    printf("YES");
  }else{
    printf("NO");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int x, y, ans = INF + 7;
	cin >> x >> y;
	if (x <= y) {
		ans = min(ans, y - x);
	}
	if (-x <= y) {
		ans = min(ans, x + y + 1);
	}
	if (x <= -y) {
		ans = min(ans, (-y) - x + 1);
	}
	if (-x <= -y) {
		ans = min(ans, (-y) - (-x) + 2);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
int main() {
  int N; cin>>N;
  vector<ll> h(N), dp(N, 0);
  for(int i = 0; i < N; i++) cin>>h[i];
  for(int i = 1; i < N; i++) {
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    if(i > 1) {
      dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var N int
	input := readLineInts()
	N = input[0]
	var a int
	var str string
	for {
		a = (N - 1) % 26
		N = (N - 1) / 26
		str = fmt.Sprintf("%s%s", string(a+'a'), str)
		if N == 0 {
			break
		}
	}
	fmt.Println(str)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func readLineStrs() []string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	str := string(buf)
	return strings.Split(str, " ")
}

func readLineInts() []int {
	list := readLineStrs()
	res := make([]int, len(list))
	for i, v := range list {
		pi, _ := strconv.ParseInt(v, 10, 64)
		res[i] = int(pi)
	}
	return res
}


Measured memory_bytes: 2160
N,M = map(int, input().split())
shop = list()
price = 0
item = 0
for i in range(N):
    shop.append(list(map(int, input().split())))
shop.sort()

for i in range(N):
    for _ in range(shop[i][1]):
        if(item >= M):
            break
        price += shop[i][0]
        item += 1

print(price)


Measured memory_bytes: 27760
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)>c&&(a<c||a==c)){
        cout<<"YES"<<endl;
    }
    else if((a+b)<c||a>c){
         cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<math.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
//小さい順
int compareInt(const void* a, const void* b){int aNum = *(int*)a;int bNum = *(int*)b;return aNum - bNum;}

long long _gcd(long long a,long long b){
    long long c;
    while(b!=0){c=a%b;a=b;b=c;}
    return a;
    
}
long long _lcm(long long a,long long b){long long c=_gcd(a,b);a/=c;return a*b;}

int main(){
    char N[100];
    long long K;
    int cnt=0;
    scanf("%s %lld",N,&K);
    for(int i=0;i<100;i++){
        if(N[i]=='1'){
            cnt++;
        }else{
            break;
        }
    }
    if(K<=cnt){
        printf("1");
        return 0;
    }else{
        printf("%c",N[cnt]);
    }
}




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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}

template<typename T>
T gcd(T x, T y){
    if (x == 0 || y == 0) {
        return 0;
    }

    while (x != y){
        if (x > y) {
            x -= y;
        }else{
            y -= x;
        }
    }
    return x;
}

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

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

// }}}
/* vim:set foldmethod=marker: */

void solve(){
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;

    int v1x = x2 - x1;
    int v1y = y2 - y1;
    int v2x = -v1y;
    int v2y = v1x;
    x3 = x2 + v2x;
    y3 = y2 + v2y;
    x4 = x3 - v1x;
    y4 = y3 - v1y;
    // cout << v1x << " " << v1y << endl;
    // cout << v2x << " " << v2y << endl;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
    
    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


// map の key, value を全て抜き出す。
// for (auto itr = mp.begin(); itr != mp.end(); itr++) {
//     cout << "key" << itr->first << " value" << itr->second << endl;
// }

// 文字列の検索
// string s="abc";
// if (s.find('d') == string::npos){
//     cout << "find" << endl;
// }else{
//     cout << "not find" << endl;
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	int a=n*2,b=n*4;
	if(m%2==0 && m>=a && m<=b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main()
{
    int n, k, h, res = 0;
    cin >> n >> k;

    for(int i = 0; i < n; ++i)
    {
        cin >> h;
        if(h >= k) res++;
    }

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


Measured memory_bytes: 3632
n=gets.to_i
c,s,f=[],[],[]
(n-1).times do |i|
  c[i],s[i],f[i]=gets.split.map(&:to_i)
end
(n-1).times do |i|
  t=s[i]+c[i]
  (i+1).upto(n-2) do |j|
    if t<=s[j]
      t=s[j]+c[j]
    else
      if t%f[j]!=0
        t+=(f[j]-t%f[j])+c[j]
      else
        t+=c[j]
      end
    end
  end
  puts t
end
puts 0

Measured memory_bytes: 1788
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();
        int c = sc.nextInt();
        if(a < b){
            if(b < c){
                System.out.printf("%d %d %d\n",a,b,c);
            }else if(a < c){
                System.out.printf("%d %d %d\n",a,c,b);
            }else{
                System.out.printf("%d %d %d\n",c,a,b);
            }
        }else{
            if(a < c){
                System.out.printf("%d %d %d\n",b,a,c);
            }else if(b < c){
                System.out.printf("%d %d %d\n",b,c,a);
            }else{
                System.out.printf("%d %d %d\n",c,b,a);
            }
        }
    }
}


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

int main()
{
    int h, n, r=0, x;
    cin >> h >> n;
    for(int i=0; i<n; i++){
        cin >> x;
        r += x;
    }
    if(r>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
using namespace std;
using i32 = int; using i64 = long long int; using f64 = double; using str = string;
template <typename T> using vec = vector<T>;
template <typename T> using heap = priority_queue<T, vec<T>, greater<T>>;
#define times(n, i) for (i32 i = 0; i < (n); ++i)
#define range(a, b, i) for (i32 i = (a); i < (b); ++i)
#define upto(a, b, i) for (i32 i = (a); i <= (b); ++i)
#define uptol(a, b, i) for (i64 i = (a); i <= (b); ++i)
#define downto(a, b, i) for (i32 i = (a); i >= (b); --i)
#define all(xs) (xs).begin(), (xs).end()
#define sortall(xs) sort(all(xs))
#define reverseall(xs) reverse(all(xs))
#define uniqueall(xs) (xs).erase(unique(all(xs)), (xs).end())
#define even(x) (((x) & 1) == 0)
#define odd(x) (((x) & 1) == 1)
#define append emplace_back
#define findge lower_bound
#define findgt upper_bound
const i64 MOD = 1000000007;
const f64 EPS = 1e-10;

i64 n;;

i32 main()
{
    cin >> n;
    i64 ans = LLONG_MAX;
    uptol(1LL, i64(sqrtl(n))+1, a) {
        i64 b = n/a;
        if (b*a != n) continue;
        i64 v = max(a, b);
        i64 t = 0;
        while (v > 0) {
            t++;
            v /= 10;
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

vector<int> blue;
vector<int> red;
vector<int> redpair;
vector<int> v;
vector<vector<int> > c;

int m = 0;
int n = 0;

int gcd(int x,int y){
    if(x % y == 0){
        return y;
    }
    return gcd(y,x%y);
}

bool match(int x){
    if(x == -1){
        return 1;
    }
    for(int i = 0;i < n;i++){
        if(c[x][i] == 1 && v[i] == 0){
            v[i] = 1;
            if(match(redpair[i])){
                redpair[i] = x;
                return 1;
            }
        }
    }
    return 0;
}


int main(){
    while(cin >> m >> n){
        if(m == 0 && n == 0){
            break;
        }
        blue.clear();
        red.clear();
        redpair.clear();
        v.clear();
        c.clear();
        for(int i = 0;i < m;i++){
            int tmp = 0;
            cin >> tmp;
            blue.push_back(tmp);
        }
        for(int i = 0;i < n;i++){
            int tmp = 0;
            cin >> tmp;
            red.push_back(tmp);
            redpair.push_back(-1);
            v.push_back(0);
        }
        for(int i = 0;i < m;i++){
            c.push_back(vector<int>());
            for(int j = 0;j < n;j++){
                c[i].push_back(gcd(blue[i],red[j]) != 1);
            }
        }
        int ans = 0;
        for(int i = 0;i < m;i++){
            for(int j = 0;j < n;j++){
                v[j] = 0;
            }
            if(match(i)){ans++;}
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<ll>());
    // a<b>c<d>e<f…と考えると、
    // nが偶数の場合; 1回減算が1種類、1回加算が1種類、2回の減算・加算が(n/2)-1種類
    // nが奇数の場合; 1回減算が2種類、2回の減算が(n/2-1)種類、2回の加算が(n/2)種類
    //       or      1回加算が2種類、2回の減算が(n/2)種類、2回の加算が(n/2)-1種類
    ll ans = 0;
    if(n%2 == 0){
        // 偶数なら
        for(ll i=0; i<(n/2)-1; i++) ans += a[i]*2;
        ans += a[n/2-1];
        ans -= a[n/2];
        for(ll i=n/2+1; i<n; i++) ans -= a[i]*2;
    }
    else{
        // 奇数なら
        ll tmp1 = 0, tmp2 = 0;
        for(ll i=0; i<(n/2)-1; i++) tmp1 += a[i]*2;
        tmp1 += a[n/2-1];
        tmp1 += a[n/2];
        for(ll i=n/2+1; i<n; i++) tmp1 -= a[i]*2;

        for(ll i=0; i<(n/2); i++) tmp2 += a[i]*2;
        tmp2 -= a[n/2];
        tmp2 -= a[n/2+1];
        for(ll i=n/2+2; i<n; i++) tmp2 -= a[i]*2;

        ans = max(tmp1, tmp2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3944
#include<cstdio>
#define maxn 2005
#define maxm 4005
using namespace std;

int n,m,q;
int mp[maxn][maxn],ed[maxm][maxm];
int sum[maxn][maxn],cnt[maxm][maxm];

void add()
{
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			if(mp[i][j]!=1)continue;
			if(mp[i][j+1]==1)ed[2*i-1][2*j]=1;
			if(mp[i+1][j]==1)ed[2*i][2*j-1]=1;
		}
	}
}

int main()
{
	//freopen("duty.in","r",stdin);
	//freopen("duty.out","w",stdout);
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	scanf("%1d",&mp[i][j]);
	add();//建边
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+mp[i][j];//前缀和
	for(int i=1;i<=2*n;++i)
	for(int j=1;j<=2*m;++j)
	cnt[i][j]=cnt[i-1][j]+cnt[i][j-1]-cnt[i-1][j-1]+ed[i][j];//前缀和
	for(int i=1;i<=q;++i)
	{
		int x,y,xx,yy,poi,edge;
		scanf("%d%d%d%d",&x,&y,&xx,&yy);
		poi=sum[xx][yy]-sum[xx][y-1]-sum[x-1][yy]+sum[x-1][y-1];
		edge=cnt[xx*2-1][yy*2-1]-cnt[xx*2-1][y*2-2]-cnt[x*2-2][yy*2-1]+cnt[x*2-2][y*2-2];
		printf("%d\n",poi-edge);
	}
	return 0;
}

Measured memory_bytes: 158208
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int N = n[0];
        int Y = n[1];
        string s = "-1 -1 -1";
        bool ans = false;
        //万札確定
        for (int i = 0; i <= N; i++)
        {
            for (int j = 0; j <= N - i; j++)
            {
                if (Y == 10000 * i + 5000 * j + 1000 * (N - i - j))
                {
                    s = i.ToString() + " " + j.ToString() + " " + (N - i - j).ToString();
                    ans = true;
                    break;
                }
            }
            if (ans) break;
        }
        Console.WriteLine(s);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13396
#include <iostream>

#include <fstream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <stack>

#include <queue>


#include <algorithm>

using namespace std;



int main(){
  int R,G;
  cin >> R >> G;
  int b = 2*G-R;
  cout <<b;

  return 0;

}



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

class Node{
public:
    long key;
    int parent, left, right;
    Node(){
        key = -1;
        parent = left = right = -1;
    }
};

class CompleteBT{
public:
    int size;
    std::vector<long> heap;
    std::vector<Node> nodes;
    CompleteBT(int s, std::vector<long> inHeap){
        heap = inHeap;
        size = s;
        Node n;
        nodes.assign(size, n);
    }
    void makeTree(){
        for (int i = 0; i < size; i++){
            nodes[i].key = heap[i];
            if (i > 0){
                nodes[i].parent = (i - 1) / 2;
            }
            if ((i + 1) * 2 - 1 < size){
                nodes[i].left = (i + 1) * 2 - 1;
            }
            if ((i + 1) * 2 < size){
                nodes[i].right = (i + 1) * 2;
            }
        }
    }
};

int main(){
    int size;
    std::cin >> size;
    std::vector<long> heap(size);
    for (int i = 0; i < size; i++){
        std::cin >> heap[i];
    }
    
    CompleteBT tree(size, heap);
    tree.makeTree();
    
    for (int i = 0; i < size; i++){
        std::cout << "node " << i+1 << ": key = " << tree.nodes[i].key << ", ";
        if (tree.nodes[i].parent >= 0){
            std::cout << "parent key = " << tree.nodes[tree.nodes[i].parent].key << ", ";
        }
        if (tree.nodes[i].left >= 0){
            std::cout << "left key = " << tree.nodes[tree.nodes[i].left].key << ", ";
        }
        if (tree.nodes[i].right >= 0){
            std::cout << "right key = " << tree.nodes[tree.nodes[i].right].key << ", ";
        }
        std::cout << std::endl;
    }
    
}


Measured memory_bytes: 3144
#include<stdio.h>

int main()
{
    int x1, x2, x3, x4, y1, y2, y3, y4;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x3 = x2 + (y1-y2);
    x4 = x1 + (y1-y2);
    y3 = y2 + (x2-x1);
    y4 = y1 + (x2-x1);
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let M = buf_it.next().unwrap().parse::<usize>().unwrap();
    let A = (0..N).map(|_| 
        (0..M).map(|_|
            buf_it.next().unwrap().parse::<usize>().unwrap()-1).collect::<Vec<_>>()
                ).collect::<Vec<_>>();

    let check = |n:usize| {
        let mut popped = HashSet::new();
        let mut idx = (0..N).map(|_| 0).collect::<Vec<_>>();
        loop{
            let mut cnt = (0..M).map(|_| 0).collect::<Vec<_>>();
            for i in 0..N{
                cnt[A[i][idx[i]]] += 1;
            }
            if *(cnt.iter().max().unwrap())<=n{ return true; }
            for j in 0..M{
                if cnt[j] > n{
                    popped.insert(j);
                }
            }
            if popped.len()==M {break;}
            for i in 0..N{
                while popped.contains(&A[i][idx[i]]) {
                    idx[i] += 1;
                }
            }
        }
        false
    };
    let mut l = 0;
    let mut r = N;
    while l+1 < r{
        let i = (l+r)/2;
        if check(i) {r = i;}
        else {l = i;}
    }
    println!("{}",r);
}

Measured memory_bytes: 4476
#include <iostream>
#include <string>
using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
 
bool getJudge(string s) {
    int cnt = 0;
    
    if (s[0] != 'A') {
        return false;
    }
    
    FOR(i, 1, s.length()) {
        if (s[i] == 'C' && (i < 2 || s.length() - 2 < i)) {
            return false;
        }
        if (s[i] == 'C') {
            cnt++;
            continue;
        }
        if ('A' <= s[i] && s[i] <= 'Z') {
            return false;
        }
    }
    if (cnt != 1) {
        return false;
    }
    
    return true;
}
 
int main(void) {
    string s;
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    cout << (getJudge(s)? "AC" : "WA") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> d(n);
    vector<int> cnt(n);
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        d[a].push_back(b);
        d[b].push_back(a);
        cnt[a]++;
        cnt[b]++;
    }
    queue<int> que;
    for(int i = 0; i < n; i++)
    {
        if(d[i].size() == 1) que.push(i);
    }
    bitset<100000> bs;
    bool flag = true;
    while(!que.empty())
    {
        int v = que.front();
        que.pop();
        if(bs[v]) continue;
        bs[v] = 1;
        int nv = -1;
        for(int nx : d[v])
        {
            if(bs[nx]) continue;
            nv = nx;
        }
        if(nv == -1)
        {
            flag = false;
            break;
        }
        bs[nv] = 1;
        for(int nnx : d[nv])
        {
            if(bs[nnx]) continue;
            cnt[nnx]--;
            if(cnt[nnx] == 1) que.push(nnx);
        }
    }
    if(flag) cout << "Second" << endl;
    else cout << "First" << endl;
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
LL c[maxn];
LL pw[maxn];
LL fac[maxn];
LL ifac[maxn];

LL C(int n, int m)
{
    return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;
}

LL dp[maxn];

void work()
{
    cin >>n;
    for(int i = 1; i <= n; i++) cin >>c[i];

    pw[0] = 1;
    for(int i = 1; i <= n; i++) pw[i] = pw[i - 1] * 2 % MOD;
    fac[0] = 1;
    for(int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
    ifac[n] = fp(fac[n], MOD - 2, MOD);
    for(int i = n - 1; i >= 0; i--) ifac[i] = fac[i + 1] * (i + 1) % MOD;

    dp[1] = 2;
    for(int i = 2; i <= n; i++)
    {
        dp[i] = 4 * dp[i - 1] % MOD + pw[i - 1] * pw[i - 1] * 2 % MOD;
        dp[i] %= MOD;
    }

    sort(c + 1, c + 1 + n);

    LL res = 0;
    for(int i = 1; i <= n; i++)
    {
        LL cnt = 0;
        cnt = pw[n - i] * pw[n - i] % MOD;
        cnt = cnt + dp[n - i];
        cnt = (cnt * 2 % MOD + MOD) % MOD;

        LL cnt2 = pw[i - 1] * pw[i - 1] % MOD;

//        cout <<i <<" " <<c[i] <<" " <<cnt <<" " <<cnt2 <<endl;

        res += c[i] * cnt % MOD * cnt2 % MOD;
        res %= MOD;
    }
    cout <<res <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>

int main() {
    std::string str{}; std::cin >> str;
    int q{}; std::cin >> q;
    for(auto i=0; i<q; i++) {
        std::string command{}; std::cin >> command;
        int a{}, b{}; std::cin >> a >> b;
        const int len{b-a+1};
        std::string ns{ str.substr(a, len) };
        if(command=="print") {
            std::cout << ns << std::endl;
            continue;
        }
        if(command=="reverse") {
            std::reverse(ns.begin(), ns.end());
            str = str.replace(a, len, ns);
            continue;
        }
        if(command=="replace") {
            std::cin >> ns;
            str = str.replace(a, len, ns);
        }
    }
}



Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N;
    ll x;
    cin >> N >> x;
    vector<ll> a(N);
    for(int i=0;i<N;i++){cin >> a[i];}
    sort(a.begin(),a.end());
    int out=0;
    for(int i=0;i<N;i++){
        x -= a[i];
        if(x<0) break;
        out++;
    }
    if(out==N){
        if(x!=0) out--;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define max3(a, b, c) max (a, max (b, c));
#define max4(a, b, c, d) max (a, max3 (a, b, c));
#define min3(a, b, c) min (a, min (b, c));
#define min4(a, b, c, d) min (a, min3 (b, c, d));
#define reset (a, val) memset (a, val, sizeof (a));
using namespace std;
typedef long long ll;
const int MAXN = 1 + 1e5;
const ll oo = 1  +1e18;
const ll mod = 7 + 1e9;
typedef pair < int, int > II;
typedef pair < int, II > III;
typedef pair < ll, ll > PLL;
typedef pair < ll, PLL > PLLL;
typedef priority_queue < II, vector < II >, greater < II > > pq;
void file();



int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22){
        cout << "bust";
    }
    else cout << "win";
   
    return 0;
}












void file(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

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

using namespace std;

int main()
{

    int n,x;
    cin >> n >> x;
    vector<int>po(n);
    int soma=0,menor=0;
    for(int i=0;i<n;i++){
        cin >> po[i];
        soma+=po[i];
        if( po[i]<menor || i==0){
            menor = po[i];
        }
    }
    if(x-soma > menor){
        n+=(x-soma)/menor;
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 3564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;


/**
 *　２つの整数 a と b を読み込んで、以下の値を計算するプログラム
 * @author 前島佑介
 * @version 2014/12/1
 */
class Main {

	// プログラムのエントリポイント
	public static void main(String[] args) {

		//入力値1つ目
		int intNum1 = 0;

		//入力値2つ目
		int intNum2 = 0;

		//何回約数が存在したかカウンター
		int intAnswer = 0;

		//割った数
		int intDivision = 0;

		//剰余
		int intSurplus = 0;

		//割った数
		double dbDivision = 0.0;

		try{
			//キーボードからの入力準備
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

			//キーボードからの入力をString型で受け取る
			String strLine = br.readLine();

			//文字列の分割:入力値を" "で分ける
			//分けた文字列はstrLineAry[0]とstrLineAry[1]とstrLineAry[2]に分けられる
			String[] strLineAry = strLine.split(" ");


			//入力値の１つ目の値
			intNum1 = Integer.parseInt(strLineAry[0]);

			//２つ目の値
			intNum2 = Integer.parseInt(strLineAry[1]);

			//割った数
			intDivision = intNum1 / intNum2;

			//剰余
			intSurplus = intNum1 % intNum2;

			//割った数
			dbDivision = (double)intNum1 / (double)intNum2;

			 //小数5桁まで
		    DecimalFormat insdf = new DecimalFormat("0.00000");

			//結果を出力 double型は少数5桁まで表示
			System.out.println(intDivision + " " + intSurplus +  " " + insdf.format(dbDivision));

			//例外処理
			}catch(IOException e) {

				//例外時の出力
				System.out.println(e);

			}catch(NumberFormatException e) {

				//数値以外の入力値で出力
				System.out.println("数値で入力して下さい");
			}
	}
}

Measured memory_bytes: 17264
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		LL N, A, B, C, D; cin >> N >> A >> B >> C >> D;
		N--;
		for (LL i = 0; i <= N; i++) {
			LL l, r;
			l = A + C * i - D * (N - i);
			r = A + D * i - C * (N - i);
			//cout << l << " " << r << endl;
			if (l <= B && B <= r) {
				cout << "YES" << endl;
				return;
			}
		}
		cout << "NO" << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main() {
	int h, w;
	cin >> h >> w;
	
	while (h != 0 || w != 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}

	return 0;
}

Measured memory_bytes: 3076
main = do
  li <- getLine
  let n = read li
  print $ compute n

compute :: Int -> Int
compute n = sum [ div n1 a | a <- [1..n1] ]
  where n1 = n - 1

{-
0<a,b,c
a*b+c==n
1<=c<nについてn-cの因数の数を数えるのは辛い。
1<=a<nについて、a*b<nとなるbの個数は b<n/a 個、それぞれについてcは決まる
-}


Measured memory_bytes: 3876
#include "bits/stdc++.h"
using namespace std;
 
#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v)  v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'

const int mod = 1e9 + 7;
const int N = 5e5 + 5;

char s[N];
set < int > st[30];
 
inline void solve() {
    int n;
    cin >> n;   
   cin >> (s+1);
   rep(i,1,n) {
    st[s[i]-'a'].insert(i);
   }
   int q;
   cin >> q;
   while (q--) {
    int ch, x, y;
    char ok;
    cin >> ch;
    if (ch == 1) {
      cin >> x >> ok;
      char now = s[x];      
      st[now-'a'].erase(x);
      st[ok-'a'].insert(x);
      s[x] = ok;
    }
    else {
      cin >> x >> y;
      int ans = 0;
      rep(i,0,25) {
        auto it = st[i].lower_bound(x);
        if (it != st[i].end() && *it <= y)
          ++ans;
      }
      cout << ans << '\n';
    }
   }
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  //cin >> t; while(t--)
  solve();
  return 0;
}

Measured memory_bytes: 24192
// B.

#include <iostream>
#include <sstream>

using namespace std;

int main(int argc, char *argv[])
{
	int h, w;
	cin >> h >> w;
	string b[52];
	b[0] = b[h + 1] = string(w + 2, '.');
	for (int i = 1; i <= h; ++i) {
		string s;
		cin >> s;
		b[i] = "." + s + ".";
	}
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if (b[i][j] == '.') {
				int d = 0;
				for (int k = -1; k <= 1; ++k) {
					for (int l = -1; l <= 1; ++l) {
						d += b[i + k][j + l] == '#';
					}
				}
				b[i][j] = '0' + d;
			}
		}
		cout << b[i].substr(1, w) << endl;
	}
	return 0;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    set<string> st;
    for(int i = 0; i < N; ++i) {
        string S; cin >> S;
        st.insert(S);
    } 
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 19224
#include <bits/stdc++.h>
#include <atcoder/twosat>

using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using pii = pair<int, int>;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

int N,D;
vector<pii> X;
inline void input(){
    fast_io();
    cin >> N >> D;
    for (int i = 0; i < N; i++)
    {
        int x,y; cin >> x >> y;
        X.emplace_back(x,y);
    }
}

inline int solve(){
    atcoder::two_sat ts(N);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if(i==j) continue;
            if(abs(X[i].first-X[j].first)<D) ts.add_clause(i,true,j,true);
            if(abs(X[i].first-X[j].second)<D) ts.add_clause(i,true,j,false);
            if(abs(X[i].second-X[j].first)<D) ts.add_clause(i,false,j,true);
            if(abs(X[i].second-X[j].second)<D) ts.add_clause(i,false,j,false);
        }
    }
    cout << (ts.satisfiable() ? "Yes" : "No") << endl;
    if(ts.satisfiable()){
        auto ans = ts.answer();
        for (int i = 0; i < N; i++)
        {
            if(!ans[i]) cout << X[i].first << "\n";
            else cout << X[i].second << "\n";
        }
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3760
#include<iostream>

using namespace std;

int main(){
    int n;
    int j = 0;
    cin >> n;

    int array[n];
    int dp[n];

    for(int i = 0; i < n; i++){
        cin >> array[i];
        dp[i] = 0;
    }

    for(int i = 0; i < n - 1; i++){
        if(array[i] >= array[i + 1]){
            dp[j]++;
        }else{
            j++;
        }
    }


    int ans = 0;
    for(int i = 0; i < n; i++){
        if(ans < dp[i]){
            ans = dp[i];
        }
    }

    cout << ans;
}


Measured memory_bytes: 1024
def bubbleSort(A,N):
    flag = True
    count = 0
    while flag:
        flag = False
        for j in reversed(range(1,n)):
            if A[j] < A[j-1]:
                v = A[j]
                A[j] = A[j-1]
                A[j-1] = v
                count += 1 
                flag = True
    print(" ".join(map(str,A)))
    print(count)

n = int(input())
numlist = [int(x) for x in input().split()]

bubbleSort(numlist,n)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mk make_pair
    #define ft first
    #define sc second
    #define ppb pop_back
    #define sz size
    #define forn(i,a,n) for(i=a;i<n;i++)
    #define M 1000000007
    #define inf 2e18
    
    int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n;
    cin>>n;
    cout<<n+n*n+n*n*n;

    return 0;
    } 

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
  double x,h;
  while(1){
  cin >> x >> h;
  if(x == 0 && h == 0)break;
  double s = x*x+x*sqrt(pow(h,2)+pow((x/2),2))*2;
  printf("%.5f\n",s);
  }
}

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

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> t(N);
    for (int i = 0; i < N; i++) cin >> t[i];

    long long ans = 0;
    for (int i = 1; i < N; i++) ans += min(T, t[i] - t[i - 1]);
    ans += T;

    cout << ans << endl;
}

Measured memory_bytes: 1024
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int a[n], b[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
    for(int i=0;i<n-2;i++)
    {
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2])
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

int main() {
  ll N = 0,A = 0,B = 0,countA = 0,countB = 0;
  string s;
  cin >> N >> A >> B >> s;
  rep(i,N){
    if(countA + countB >= A + B){
      cout << "No" << endl;
      continue;
    }
    if(s.at(i) == 'c'){
      cout << "No" << endl;
    }
    if(s.at(i) == 'a'){
      if(countA + countB <= A + B){
        cout << "Yes" << endl;
        countA++;
      }
      else{
        cout << "No" << endl;
      }
    }
    if(s.at(i) == 'b'){
      if(countA + countB <= A + B && countB < B){
      cout << "Yes" << endl;
      countB++;
      }
      else{
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 896
i,k,m,t,a[124];main(n){while(scanf("%d%d",&n,&m),n){while(i<n*m)scanf("%d",&k),a[i++%m]+=k;n=m;while(n--){for(t=i=0;i<m;++i)t=t<a[i]?a[k=i]:t;printf("%d%c",k+1,n?32:10),i=a[k]=0;}}}

Measured memory_bytes: 0