akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
bool prime(int n){
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return n!=1;
}
int gcd(int x,int y){
    if(x<y)swap(x,y);
    if(y==0)return x;
    return (y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}
int kai(int n){
    if(n==0)return 1;
    return kai(n-1)*n;
}
int mod_pow(int x,int y,int mod){
    int res=1;
    while(y>0){
        if(y&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        y>>=1;
    }
    return res;
}
int n,h,w,a,b,cnt;
signed main(){
    cin>>n>>h>>w;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        if(a>=h&&b>=w)cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  	int n;	cin >> n;
	vector<int> b(n-1);	rep(i,n-1) cin >>b.at(i);
	vector<int> a(n);
  	a.at(0) = b.at(0);	a.at(n-1) = b.at(n-2);
  	int sm = a.at(0) + a.at(n-1);
	for(int i = 1; i < n-1; i++){
    	a.at(i) = min(b.at(i-1),b.at(i));
      	sm += a.at(i);
    }
  	
  	cout << sm << endl;
  	
}

Measured memory_bytes: 256
package main

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

func main() {
	array := nextInts(5)
	var n []int
	t := 0
	for _, a := range array {
		t += a
		r := a % 10
		if r != 0 {
			r = 10 - r
		}
		n = append(n, r)
	}
	sort.Ints(n)
	for i := 0; i < len(n)-1; i++ {
		t += n[i]
	}
	fmt.Printf("%v", t)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func MaxIn2Values(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func MinIn2Values(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanInt()

	y := (s+1e9-1)/1e9
	x := y*1e9-s
	fmt.Fprintln(wr, 0,0,int(1e9),1,x,y)
	// fmt.Fprintln(wr,y*1e9-x)

}


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

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

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << max( min( B, D ) - max( A, C ), 0 ) << endl;

	return 0;
}


Measured memory_bytes: 256
import math
N, M = map(int, input().split())
tmp = [1]
if N == 1:
    print(M)
else:
    for i in range(2, int(math.ceil(M**0.5))):
        if M % i == 0:
            tmp.append(i)
            tmp.append(int(M/i))
    ans = 1
    for x in tmp:
        if M / x >= N:
            ans = max(ans, x)
    print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int n=0;
        for(int i =0;i<3;i++){
            if((a.substring(i,i+1)).equals(b.substring(i,i+1)))
                n++;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 21716
function main(stdin) {
    const inputs = stdin.split('\n');
    const len = parseInt(inputs.shift(), 10);
    const dict = {};

    for(let i =0;i<len;i++){
        const state = inputs[i].split(' ');
        if(state[0] === 'insert'){
            dict[state[1]] = 1;
        } else {
            console.log(dict[state[1]] ? 'yes' : 'no');
        }
    }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 247708
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	
	int p,q,r;
	cin >> p >> q >> r;
	int ans = min(p+q, q+r);
	ans = min(ans, p+r);
	cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vi vector < ll  int >
#define CLR(a) memset((a),0,sizeof(a))
#define mp make_pair
#define hell 1000000007
using namespace std;

 //int dp[1001][1001];
bool comp(string s1,string s2)
{
    string s12=s1; s12+=s2;
    string s21=s2; s21+=s1;
    return s12>s21;
}

void solve()
{
 ll int i,j=0,r=200,p,q,k=1,tot=0,d,ans=0,y=0,x,n,h,flag=1,m=0,id,c,h1=-1,h2=-1,a1,b1,w,a,b,co=0,ce=0;
 cin>>n;
 vector  <ll int > vf(n),vb(n),v(n);
 rep(i,0,n)
   {
       cin>>v[i];

   }
   vf[0]=v[0];
   rep(i,1,n) vf[i]=__gcd(vf[i-1],v[i]);
   vb[n-1]=v[n-1];
   for(i=n-2;i>=0;i--) vb[i]=__gcd(vb[i+1],v[i]);
   ans=vb[1];
   for(i=1;i<n-1;i++)
   {

       ans=max(ans,__gcd(vf[i-1],vb[i+1]));
   }
 ans=max(ans,vf[n-2]);
 cout<<ans;

}



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


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;

using namespace std;


int main(void){
  ll h;
  cin >> h;

  ll ans = 1;
  for(ll i = 1; h!= 1;){
    h /= 2;
    i*=2;
    ans += i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	set<string> a = {
		"AKIHABARA",
		"AKIHABAR",
		"AKIHABRA",
		"AKIHABR",
		"AKIHBARA",
		"AKIHBAR",
		"AKIHBRA",
		"AKIHBR",
		"KIHABARA",
		"KIHABAR",
		"KIHABRA",
		"KIHABR",
		"KIHBARA",
		"KIHBAR",
		"KIHBRA",
		"KIHBR" };
	if (a.count(s)) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

template <class T>
T gcd(T x, T y) {
  if (!x)
    return y;
  return gcd(y % x, x);
}

constexpr int MAX_N = 1e5+9;

int T1[MAX_N];
int T2[MAX_N];
int A[MAX_N];

int main() {
  int N; cin >> N;
  for (int i{}; i < N; ++i) cin >> A[i];

  T1[0] = A[0];
  for (int i{1}; i < N; ++i)
    T1[i] = gcd(T1[i-1], A[i]);

  T2[N-1] = A[N-1];
  for (int i{N-2}; i >= 0; --i)
    T2[i] = gcd(T2[i+1], A[i]);

  int i{};
  int ans = T2[++i];
  for (; i < N - 1; ++i) {
    ans = max(ans, gcd(T1[i-1], T2[i+1]));
  }
  ans = max(ans, T1[i-1]);

  cout << ans << endl;
}


Measured memory_bytes: 1408
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	vector<vector<LL>> dp(2, vector<LL>(s.size()));

	dp[0][0] = 2;
	dp[1][0] = 1;

	for (int i = 1; i < s.size(); i++) {
		
		if (s[i] == '1') {
			//0,1 1,0の2個を置くとぴったりを維持
			dp[0][i] += dp[0][i - 1] * 2;
			dp[0][i] = (dp[0][i] + MOD) %MOD;

			//0,0を置いて、ぴったりから未満へ
			dp[1][i] += dp[0][i-1];
			dp[1][i] = (dp[1][i] + MOD) % MOD;
			
			//未満から未満は1,1以外の3つをおける
			dp[1][i] += dp[1][i-1]*3;
			dp[1][i] = (dp[1][i] + MOD) % MOD;
		}

		if (s[i] == '0') {

			//0,0をおくしかない
			dp[0][i] += dp[0][i-1];
			dp[0][i] = (dp[0][i] + MOD) % MOD;

			//未満は1,1以外の3つを自由における
			dp[1][i] += dp[1][i-1] * 3;
			dp[1][i] = (dp[1][i] + MOD) % MOD;
		}
		
	}

	//MODを取り忘れるな！！！
	cout << (dp[0][s.size()-1] + dp[1][s.size()-1]+MOD)%MOD<< endl;

	return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <algorithm>
int n, k;
int p[1000];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%d", p + i);
	}
	std::sort(p, p + n);
	n = 0;
	for (int i = 0; i < k; i++)n += p[i];
	printf("%d\n", n);
}

Measured memory_bytes: 1684
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
  
#define N 101
#define WHITE 0
#define BLACK 1
#define GRAY 2
  
int n,head=1,tail=1,adj[N][N],color[N],d[N],Q[N];
  
int Queemp(){
  if(head == tail){
    return 1;
  }
 else{
    return 0;
  }
}
 
 
void Enque(int r){
  int i;
  Q[tail] = r;
  tail++;
}
 
 
int Deque(void){
  int i;
  i = Q[head];
  Q[head] = -1;
  head++;
  return i;
}
 
 
void bfs(int s){
  int u,v;
  color[s] = GRAY;
  d[s] = 0;
  Enque(s);
  while(Queemp() == 0){
    u = Deque();
    for(v=1;v<=n;v++){
      if(color[v] == WHITE && adj[u][v] == 1){
    color[v] = GRAY;
    d[v] = d[u] + 1;
    Enque(v);
      }
    }
    color[u] = BLACK;
  }
}
 
 
int main(void) {
  int i,j,k,u,v;
 
  for(i=1;i<N;i++){
    for(j=1;j<N;j++){
      adj[i][j] = 0;
    }
    Q[i] = -1;
    color[i] = WHITE;
    d[i] = INT_MAX;
  }
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      adj[u][v] = 1;
    }
  }
  bfs(1);
  for(i=1;i<=n;i++){
    if(d[i] == INT_MAX){
      d[i] = -1;
    }
    printf("%d %d\n",i,d[i]);
  }
  return 0;
}

Measured memory_bytes: 640
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
A = III()

#互いに素なa,bについて、a*x+b*y=1の一つの解[x,y]を出力
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]


#aの逆元(mod M)を求める（aとMは互いに素）
def mod_inv(a,M=mod):
    if a==0:
        return 0
    x = extgcd(a,M)[0]
    return (M+x%M)%M

inv_list = [mod_inv(a) for a in range(max(A)+1)]

import fractions
from functools import reduce
def lcm_base(x,y):
    return (x*y) // fractions.gcd(x,y)
def lcm_list(numbers):
    return reduce(lcm_base,numbers,1)

x = lcm_list(A) % mod
y = [x*inv_list[a] for a in A]

ans = 0
for i in range(N):
    ans += y[i]
    ans %= mod

print(ans)

Measured memory_bytes: 135516
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

template<typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];

  vector<int> l(n), r(n);
  l[0] = a[0];
  r[n-1] = a[n-1];
  REP(i, 1, n) l[i] = gcd(l[i-1], a[i]);
  RREP(i, n-1, 0) r[i] = gcd(r[i+1], a[i]);
  int ans = max(l[n-2], r[1]);
  REP(i, 1, n-1) ans = max(ans, gcd(l[i-1], r[i+1]));
  print(ans);
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };

string str;
string R = "yuiophjklnm";

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

int main() {
	sort( R.begin(), R.end() );
	while ( !!(cin >> str) && str != "#" ) {
		int ans = 0;
		for ( int i = 1; i < str.size(); i++ ) {
			ans += binary_search( R.begin(), R.end(), str[ i - 1 ] ) == !binary_search( R.begin(), R.end(), str[ i ] );
		}
		printf( "%d\n", ans );
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll k;
    cin >> k;

    pair<int, int> p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i].first >> p[i].second;
    }

    sort(p, p + n);

    ll cou = 0;
    int now = 0;
    for(int i= 0; i < n; i++){
        cou += p[i].second;
        if(cou >=k){
            now = p[i].first;
            break;
        }
    }

    cout << now << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
    public Main(){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();
	    if(n == 0){
		break;
	    }
	    String[] str = new String[10];
	    for(int i = 0; i < 10; i++){
		str[i] = "";
	    }
	    for(int i = 0; i < n; i++){
		int t = sc.nextInt();
		str[t] += "*";
	    }

	    for(String s: str){
		if(s.length() == 0){
		    System.out.println("-");
		} else {
		    System.out.println(s);
		}
	    }
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

Measured memory_bytes: 13000
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <fstream>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S;

    cin>>S;

    if(S=="ABC"){
        cout<<"ARC"<<endl;
    }
    if(S=="ARC"){
        cout<<"ABC"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3624
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    x = int(readline().rstrip())
    li = [400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]
    for i in range(9):
        if li[i] > x:
            print(9 - i)
            break


if __name__ == '__main__':
    main()


Measured memory_bytes: 9480
/******************************************
* AUTHOR : Lokesh goel*
* NICK : InsaneNerd *
* INSTITUTION : NIT Kurukshetra *
******************************************/
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 1000000000
#define N 100005
#define pii pair<int,int>
#define vp vector<pair<int,int > >
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define gsz(x) ((int)(x).size())
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
#define endl "\n"
#define ms(x,v) memset(x,v,sizeof(x))

int main()
{
	fastio;
	ll n,i,j,k;
	cin>>n;
	ll arr[n+1]={0};
	


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

		for(j=i;j<=n;j+=i){
			//cout<<j<<" "<<arr[j]<<endl;
			arr[j]++;
		}
	}
	unsigned ll res=0;
	for(i=1;i<=n;i++){

		res+=(i*arr[i]);
	}
	cout<<res<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  
  sort(d.begin(), d.end());
  
  int a = d[n/2 - 1];
  int b = d[n/2];
  
  cout << b-a << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int a,b;
	int sum;
	int number;
	while(scanf("%d %d",&a,&b)==2){
		sum=a+b;
		for(number=0;sum!=0;number++)sum/=10;
		printf("%d\n",number);
	}
	return 0;
}

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

int main()
{
    int n , s = 0 ;
    cin>>n;
    
	while( n > 0 )
	{
	    s += n % 10 ;
	    n /= 10;
	}
	
	if ( s==1 )
	{
	    cout<<10<<endl;
	}
	else 
	{
	    cout<<s<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin=new Scanner(System.in);
		double a=stdin.nextInt();
		double b=stdin.nextInt();
		double x=(a+b)/2;
		int y=(int)(a+b)/2;
		
//		System.out.println(x);
//		System.out.println(y);
		if(x==y)
			System.out.println(y);
		else if(x!=y)
			System.out.println(y+1);
	}

}


Measured memory_bytes: 21588
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, c := getInt(), getInt(), getInt()

	ans := b * c * (a % 2)
	ans = min(ans, a*c*(b%2))
	ans = min(ans, a*b*(c%2))
	out(ans)
}


Measured memory_bytes: 1772
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define ll long long
#define INF 100000000000000000
#define MAX 100010
using namespace std;

struct node{
  int to;
  ll cost;
};

typedef pair<ll, int> p;
ll dis[MAX];
vector<node> v[MAX];

void dijkstra(int n, int k){
  priority_queue<p, vector<p>, greater<p> > que;
  bool color[MAX];
  for(int i = 0; i < MAX; i++){
    dis[i] = INF;
    color[i] = false;
  }
  dis[k] = 0;
  que.push(p(0, k));
  while(!que.empty()){
    p f = que.top(); que.pop();
    int u = f.second;
    color[u] = true;
    if(dis[u] < f.first) continue;
    for(int i = 0; i < v[u].size(); i++){
      node g = v[u][i];
      if(color[g.to] == true) continue;
      if(dis[g.to] > dis[u] + g.cost){
        dis[g.to] = dis[u] + g.cost;
        que.push(p(dis[g.to], g.to));
      }
    }
  }
}

int main(){
  int n, q, k, a, b;
  ll c;
  cin >> n;
  for(int i = 0; i < n-1; i++){
    cin >> a >> b >> c;
    a--; b--;
    v[a].push_back((node){b, c});
    v[b].push_back((node){a, c});
  }
  cin >> q >> k;
  k--;
  dijkstra(n, k);
  for(int i = 0; i < q; i++){
    int x, y;
    cin >> x >> y;
    x--; y--;
    cout << dis[x] + dis[y] << endl;
  }
  return 0;
}


Measured memory_bytes: 11248
N = int(input())
S = list(input())
c = [0]
x = 0
for y in range(N):
  if S[y] == 'I':
    x = x + 1
    c.append(x)
  elif S[y] == 'D':
    x = x - 1
    c.append(x)
print(max(c))

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vector<vi> field(n, vi(n, 0));

		int i = n/2, j = n/2+1;
		int cnt = 1;
		while(cnt<=n*n){
			if(i<0)
				i = n-1;
			else if(n<=i)
				i = 0;
			else if(n<=j)
				j = 0;
			else if(field[j][i]){
				i--;
				j++;
			}else{
				field[j][i] = cnt++;
				i++;
				j++;
			}
		}

		rep(k, n){
			rep(l, n)
				printf("%4d", field[k][l]);
			puts("");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll a,b,c,d,p1,p2,p3,p4,largest;
    cin>>a>>b>>c>>d;
    p1=a*c;
    p2=a*d;
    p3=b*c;
    p4=b*d;
    largest= (p1>p2)?(p1>p3)?(p1>p4)?p1:p4:(p3>p4)?p3:p4:(p2>p3)?(p2>p4)?p2:p4:(p3>p4)?p3:p4;
    cout<<largest; 
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    rep(i, N){
        int s;
        cin >> s;
        if(s >= K) ans ++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import math
a,b,c,d=map(int,input().split())
x=b//c-(a-1)//c
y=b//d-(a-1)//d
g=math.gcd(c,d)
l=c*d//g
z=b//l-(a-1)//l
print(b-a+1-x-y+z)

Measured memory_bytes: 9148
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		String S = sc.next();
		
		if(K >= S.length()){
			System.out.println(S);
		} else {
			System.out.println(S.substring(0,K) + "...");
		}
	}
}

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

A = []
for i in range(N):
  A.append(int(input()) - 1)

now = 0
count = 0
visited = set()

while True:
  now = A[now]
  count += 1
  if now == 1:
    print(count)
    exit(0)
    
  if now in visited:
    print(-1)
    exit(0)
  else:
    visited.add(now)
    
  

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll dp[101010][4];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cin>>x;
	memset(dp,0xcf,sizeof(dp));
	dp[0][0]=x;
	FOR(i,N-1) {
		cin>>s>>x;
		
		ll T[3];
		if(s=="+") {
			T[0]=dp[i][0];
			T[1]=dp[i][1];
			T[2]=dp[i][2];
			//T[3]=dp[i][3];
		}
		else {
			T[0]=dp[i][1];
			T[1]=max(dp[i][0],dp[i][2]);
			T[2]=dp[i][1];
			//T[3]=dp[i][2];
		}
		//dp[i+1][3] = T[3]-x;
		dp[i+1][2] = T[2]+x;
		dp[i+1][1] = max(dp[i+1][2], T[1]-x);
		dp[i+1][0] = max(dp[i+1][1], T[0]+x);
	}
	
	cout<<*max_element(dp[N-1],dp[N-1]+4)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,h,w;
	cin>>n>>h>>w;
	int ct=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i+w-1<n && j+h-1<n)
			{
				ct++;
			}
		}
	}
	cout<<ct<<"\n";
}


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

int main(){
	
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		//getchar();
		cin.ignore();
		
		string s;
		vector<int> imo(86401,0);
		for(int i=0;i<n;i++){
			getline(cin,s);
			int st=((s[0]-'0')*10+(s[1]-'0'))*60*60+((s[3]-'0')*10+(s[4]-'0'))*60+((s[6]-'0')*10+(s[7]-'0'));
			int gt=((s[9]-'0')*10+(s[10]-'0'))*60*60+((s[12]-'0')*10+(s[13]-'0'))*60+((s[15]-'0')*10+(s[16]-'0'));
			//cout<<st<<" "<<gt<<endl;
			imo[st]++;
			imo[gt]--;
		}
		
		int tmp=0;
		int ans=0;
		
		for(int i=0;i<86401;i++){
			tmp+=imo[i];
			ans=max(ans,tmp);
		}
		
		cout<<ans<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<(int)(n); i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;

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

  wi a(3, vi(3));
  rep(i, 3)rep(j, 3)cin >> a[i][j];
  int n;
  cin >> n;
  wi cnt(3, vi(3));
  rep(i, n){
    int b;
    cin >> b;
    rep(i, 3)rep(j, 3){
      if(a[i][j]==b){
        cnt[i][j]++;
        i=3;j=3;
      }
    }
  }

  string ans="No";
  rep(i, 3){
    if(cnt[i][0]==1&&cnt[i][1]==1&&cnt[i][2]==1)ans="Yes";
    if(cnt[0][i]==1&&cnt[1][i]==1&&cnt[2][i]==1)ans="Yes";
  }
  if(cnt[0][0]==1&&cnt[1][1]==1&&cnt[2][2]==1)ans="Yes";
  if(cnt[2][0]==1&&cnt[1][1]==1&&cnt[0][2]==1)ans="Yes";

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
  
int main () {
	int N, A, B;
  	cin >> N >> A >> B;
  
  	int C = N * A;
  
  	if (C >= B) {
    	cout << B << endl;
    }
  	else {
    	cout << C << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * A - Can't Wait for Holiday
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力された曜日（英語表記）
        String s = sc.next();

        switch( s ) {
            case "SUN" :
                System.out.println( 7 );
                break;
            case "MON" :
                System.out.println( 6 );
                break;
            case "TUE" :
                System.out.println( 5 );
                break;
            case "WED" :
                System.out.println( 4 );
                break;
            case "THU" :
                System.out.println( 3 );
                break;
            case "FRI" :
                System.out.println( 2 );
                break;
            case "SAT" :
                System.out.println( 1 );
                break;
        }

        sc.close();
    }
}

Measured memory_bytes: 21844
public class Hello{
    public static void Main(){
        string[] str = new string[3];
        //int[,] a = new int[3,3];
        int[] a =new int[9];
        for(int i=0; i<3; i++){
            str[i] = System.Console.ReadLine();
            string[] s = str[i].Split(' ');
            for(int j=0; j<3; j++){
                //a[i,j] = int.Parse(s[j]);
                a[(i*3)+j] = int.Parse(s[j]);
                //System.Console.WriteLine(a[i,j]);
                //System.Console.WriteLine((i*3)+j+":"+a[(i*3)+j]);
            }
        }
        var N = int.Parse(System.Console.ReadLine());
        int[] b = new int[N];
        for(int i=0; i<N; i++){
            b[i] = int.Parse(System.Console.ReadLine());
            for(int j=0; j<9; j++){
                if(b[i] == a[j]){
                    a[j] -= b[i];
                    //System.Console.WriteLine(j+":"+a[j]);
                }
            }
            //System.Console.WriteLine(b[i]);
        }
        if(a[0]==0 && a[1]==0 && a[2]==0){
            System.Console.WriteLine("Yes");
        }else if(a[3]==0 && a[4]==0 && a[5]==0){
            System.Console.WriteLine("Yes");
        }else if(a[6]==0 && a[7]==0 && a[8]==0){
            System.Console.WriteLine("Yes");
        }else if(a[0]==0 && a[3]==0 && a[6]==0){
            System.Console.WriteLine("Yes");
        }else if(a[1]==0 && a[4]==0 && a[7]==0){
            System.Console.WriteLine("Yes");
        }else if(a[2]==0 && a[5]==0 && a[8]==0){
            System.Console.WriteLine("Yes");
        }else if(a[0]==0 && a[4]==0 && a[8]==0){
            System.Console.WriteLine("Yes");
        }else if(a[2]==0 && a[4]==0 && a[6]==0){
            System.Console.WriteLine("Yes");
        }else{
            System.Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 17808
#include <bits/stdc++.h>
#include <string.h>
#include <iomanip>
using namespace std;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll MAX = 500005;
//https://www.youtube.com/watch?v=zlJDTxahav0--ps -Still miss you !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
ll x[10],y[10];
double ans=0;
  ll n;


double dist(int i, int j){

double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
return d;

}
ll fact(ll n){
    ll ans=1;
for(int i=1;i<=n;i++){
    ans*=i;
}
return ans;
}
void permute(string a, int l, int r)
{
    // Base case
    if (l == r)
      {//cout<<a<<endl;
          for(int i=0;i<n-1;i++){
            ans+=dist(a[i]-'0',a[i+1]-'0');
          }
          //cout<<ans<<endl;
      }
    else
    {
        // Permutations made
        for (int i = l; i <= r; i++)
        {

            // Swapping done
            swap(a[l], a[i]);

            // Recursion called
            permute(a, l+1, r);

            //backtrack
            swap(a[l], a[i]);
        }
    }
}
int main()
{

    cin>>n;
    string s;
    for(int i=1;i<=n;i++){
        s+=i+'0';
    }
    for(int i=1;i<=n;i++){
        cin>>x[i]>>y[i];
    }
    //cout<<s;
    permute(s,0,n-1);
    cout<<fixed<<setprecision(10)<<ans/fact(n);

}


Measured memory_bytes: 384
#a_{n} = a_{n-1}*10 + 7
#a_{n}(modK) = a_{n-1}*10(modK) + 7(modK)

K = int(input())
count = 0
a = 0
if K % 2 == 0 or K % 5 == 0:
  print(-1)
  exit()

while True:
  a = (a*10 + 7)%K
  count += 1
  if a == 0:
    break
print(count)

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
ll gcd (ll a,ll b){
	ll r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main(void){
	ll a,b,c,d,e;
	cin >> a >> b >> c >> d;
	a--;
	if(c>d)e=c*d/gcd(c,d);
	else e= c*d/gcd(d,c);
	ll ans = 0;
	ans = b-(b/c+b/d-b/e)-a+(a/c+a/d-a/e);
//	cout << "e = " << e <<endl;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
 
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)
 
using namespace std;
 
typedef long long llint;
 
const int MAXN = 100010;
 
int n, k, a[MAXN], sol, bio[MAXN];
vector<int> e[MAXN];
 
int dfs(int x) {
  int ret = 0;
  for (int y : e[x]) {
    int t = dfs(y);
    if ((t == k - 1 && x != 0) || (t == k && x == 0)) {
      ++sol;
      continue;
    }
    ret = max(ret, t + 1);
  }
  return ret;
}
 
int main(void) {
  scanf("%d %d",&n,&k);
  REP(i, n) {
    scanf("%d",&a[i]);
    --a[i];
  }
 
  if (a[0] != 0) {
    ++sol;
    a[0] = 0;
  }
 
  FOR(x, 1, n) e[a[x]].push_back(x);
 
  dfs(0);
  
  printf("%d\n",sol);
  
  return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
#define N 100
int n;
priority_queue<double> q;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int tmp; scanf("%d", &tmp);
        q.push(-tmp);
    }
    for(int i = 1; i < n; i++) {
        double a, b;
        a = q.top(), q.pop(), b = q.top(), q.pop();
        q.push((a + b) / 2);
    }
    printf("%.5f", -q.top());
}

Measured memory_bytes: 256
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft

def isOk(n):
    a = 0
    for i in range(1, n+1):
        if n % i == 0:
            a += 1
    return a == 8

def main():
    n = int(input())
    ans = 0
    for i in range(1, n+1):
        if i % 2 == 0:
            continue
        if isOk(i):
            ans += 1

    print(ans)



main()


Measured memory_bytes: 3316
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define NMAX 2000000
int H[NMAX+1], N = 0;

void maxHeapify(int ix) {
	int p = ix, l = ix * 2, r = l + 1;
	if ((l <= N) && (H[l] > H[p])) p = l;
	if ((r <= N) && (H[r] > H[p])) p = r;
	if (p != ix) {
		swap(H[ix], H[p]);
		maxHeapify(p);
	}
}

void myInsert(int key) {
	N++;
	H[N] = key;
	int ix = N;
	while ((ix > 1) && (H[ix] > H[ix/2])) {
		swap(H[ix], H[ix/2]);
		ix = ix / 2;
	}
}

int myExtract() {
	int vmax = H[1];
	H[1] = H[N--];
	maxHeapify(1);
	return vmax;
}

int main(void) {
	char command[10];
	int key;
	while (1) {
		scanf("%s", &command); // 'end' or 'insert [key]' or 'extract'
		if (command[2] == 'd') break;
		else if (command[0] == 'i') {
			scanf("%d", &key);
			myInsert(key);
		}
		else printf("%d\n", myExtract());
	}
	return 0;
}


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

int		main() {
	int N;
	int A;
	int r;

	cin >> N >> A;
	r = 0;
	while (A % 2 == 0)
	{
		r++;	
		A /= 2;
	}

	for (int i = 0; i < N - 1; i++)
	{
		int temp;

		temp = 0;
		cin >> A;
		while (A % 2 == 0)
		{
			temp++;	
			A /= 2;
		}
		if (temp < r)
			r = temp;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int l, r; cin >> l >> r;
	int d, cnt = 0; cin >> d;
	for(int i = l; i <= r; ++i) {
		if(i % d == 0) ++cnt;
	}
	cout << cnt << '\n';
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
#define hash hashh
using namespace std;
 
const int mod = 1e9 + 7;
const int inf = 1e9;
const int N = 3e3;

char s[N][N];
int n, m, q, sum[N][N], sum1[N][N], sum2[N][N], a[N][N], b[N][N], ans;

int main() {
	cin >> n >> m >> q;
	for (int i = 1; i <= n; i++) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= m; j++) {
			sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + (s[i][j] == '1');
		//	cout << i << "," << j << "," << sum[i][j] << endl;
			if (j > 1 && s[i][j - 1] == '1' && s[i][j] == '1') a[i][j]++;
			if (i > 1 && s[i - 1][j] == '1' && s[i][j] == '1') b[i][j]++;
			sum1[i][j] = sum1[i - 1][j] + sum1[i][j - 1] - sum1[i - 1][j - 1] + a[i][j];
			sum2[i][j] = sum2[i - 1][j] + sum2[i][j - 1] - sum2[i - 1][j - 1] + b[i][j];
		}
	}
	while (q--) {
		int x, xx, yy, y;
		scanf("%d %d %d %d", &x, &y, &xx, &yy);
		ans = sum[xx][yy] - sum[x - 1][yy] - sum[xx][y - 1] + sum[x - 1][y - 1];
	  y++;
		if (x <= xx && y <= yy)
			ans -= (sum1[xx][yy] - sum1[x - 1][yy] - sum1[xx][y - 1] + sum1[x - 1][y - 1]);
		y--; x++;
		if (x <= xx && y <= yy)
			ans -= (sum2[xx][yy] - sum2[x - 1][yy] - sum2[xx][y - 1] + sum2[x - 1][y - 1]);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 134656
#include<stdio.h>

int main(void){

  double g=9.8;
  double high;
  double time;
  double speed;
  double n;

  while(scanf("%lf",&speed)!=EOF){
    time = speed / g;
    high = time * time * g / 2.0;
    n = (5 + high) / 5;
    if((int)n != n)n++;
    printf("%d\n",(int)n);
  }

  return 0;
}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const ll MOD = 1e9 + 7;
int n;
string s[2];

int main() {
	cin >> n;
	cin >> s[0] >> s[1];
	ll cur = 1;
	int us = 0;
	for (int i = 0; i < n; ++i) {
		if (s[0][i] == s[1][i]) {
			cur = (cur * (3 - us)) % MOD;
			us = 1;
		}
		else {
			if (us == 0) {
				cur = (cur * 6) % MOD;
			}
			else if (us == 1) {
				cur = (cur * 2) % MOD;
			}
			else {
				cur = (cur * 3) % MOD;
			}
			us = 2;
			++i;
		}
	}
	cout << cur << "\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(container,it) for(auto it=container.begin();it!=container.end();it++)
#define present(container, element) (container.find(element) != container.end())
#define vpresent(container, element) (find(all(container),element) != container.end()) //for vectors

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
     int k,x;cin>>k>>x;
     int l=x-k+1;int u=x+k-1;
     if(l<-1000000)
     {
       for(int i=-1000000;i<=(-1000000+k-1);i++)
         cout<<i<<" ";
     }
  else if(u>1000000)
  {
    for(int i=(1000000-k+1);i<=1000000;i++)
      cout<<i<<" ";
  }
  else
  {for(int i=l;i<=u;i++)
     cout<<i<<" ";  
  }
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b = map(int, input().split())
    r = 0
    for i1 in range(a, b + 1):
        c1 = i1 // 10000 == i1 % 10
        c2 = ((i1 // 1000) % 10) == ((i1//10)%10)
        r += c1 and c2
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

int main(){
  int n,r;
  cin >> n >> r;
  if(n>=10)cout << r << endl;
  else {
    cout << r+100*(10-n) << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<stack>
#include<vector>
using namespace std;
int a[100000];
int s(int n,int k)
{
	a[n]=k;
	int i=0;
	while(a[i]!=k)i++;
	return i!=n;
}
int main()
{
    int n;int sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}	
	int m;int l;
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&l);
		if(s(n,l)) sum++;
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 3216
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long c = in.nextLong();

        long ans = Math.min(a, c);
        a -= ans;
        c -= ans;

        long tmp = Math.min(b, c);
        ans += tmp;
        b -= tmp;
        System.out.println(a + " " + b);
        
    }
}

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

int main() {
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;

    vector<char> t(Q), d(Q);
    for (int i = 0; i < Q; i++) {
        cin >> t[i] >> d[i];
    }
    int left = -1, right = N;
    for (int i = Q - 1; i >= 0; i--) {
        if (d[i] == 'L' && t[i] == s[left + 1]) left++;
        if (d[i] == 'R' && t[i] == s[right - 1]) right--;
        if (d[i] == 'L' && t[i] == s[right]) right++;
        if (d[i] == 'R' && t[i] == s[left]) left--;
    }
    cout << max(0, right - left - 1) << endl;
}

Measured memory_bytes: 900
#define $ for(i=j=0;j<n?:(j=0,++i<n);j++)
#define _(a,b)$ for(b=l=0;l<n;)b+=a[i][l]*p[l++][j]%m;$ a[i][j]=b%m;
long m=1e9+7,p[50][50],a[50][50],b[50][50],k,s;i,j,l;main(n){scanf("%d%ld",&n,&k);$ a[i][i]=scanf("%d",p[i]+j);for(;k;k/=2){if(k&1){_(a,b[i][j])}_(p,b[i][j])}$ s+=a[i][j];printf("%d",s%m);}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    private static void nCombination3(int c) {
        int count = c;
        int num = 0;
        for (int i = 0; i < count - 2; i++) {
            for (int j = i + 1; j < count - 1; j++) {
                for (int k = j + 1; k < count; k++) {
                    num++;
                }
            }
        }
    }

    public static void main(String[] args) {
        // write your code here
        Scanner sc=new Scanner(System.in);
        char[] S=sc.next().toCharArray();
        int currentlength = 0;
        int length = 0;
        for(int i=0;i<S.length;i++){
            if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T'){
               currentlength++;

            }else{
                if(currentlength>length){
                    length = currentlength;
                }
                currentlength = 0;
            }
        }
        System.out.println(Math.max(length,currentlength));

    }
}


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

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

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

int main(){
	int N;
	cin >> N;	
	ll ans = 1;
	rep(i,N) {
		ll T;
		cin >> T;
		ans = lcm(ans, T);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int MAX = 123321;
char S[MAX];
int nextL[MAX], nextR[MAX], goal[MAX], ans[MAX];

int main(){

    // 1. 入力情報取得.
    scanf("%s", S);
    int l = strlen(S);
    
    // 2. 各初期位置について, 以下の情報を保存(0-index).
    // 2-1. 初期位置に, 'L' が記載されていたとして, 次に, 'R' が 始めて出現するケース.
    int posL = -1;
    for(int i = l - 1; i >= 0; i--){
        if(S[i] == 'L') posL = i;
        nextL[i] = posL;
    }
    
    // 2-2. 初期位置に, 'R' が記載されていたとして, 次に, 'L' が 始めて出現するケース.
    int posR = -1;
    for(int i = 0; i < l; i++){
        if(S[i] == 'R') posR = i;
        nextR[i] = posR;
    }
    
    // 3. 各マスについて, 1グーゴル回後の位置を計算.
    // 初期位置が, 'R' or 'L' で 分岐.
    for(int i = 0; i < l; i++){
        if(S[i] == 'R'){
            int dist = nextL[i] - i;
            if(dist % 2 == 0) goal[i] = nextL[i];
            else              goal[i] = nextL[i] - 1;
        }
        if(S[i] == 'L'){
            int dist = i - nextR[i];
            if(dist % 2 == 0) goal[i] = nextR[i];
            else              goal[i] = nextR[i] + 1;
        }
    }
    
    // 4. 移動後の位置情報が, goalに保存されているので集計.
    for(int i = 0; i < l; i++) ans[goal[i]]++;
    
    // 5. 出力 ～ 後処理.
    for(int i = 0; i < l; i++) printf("%d ", ans[i]);
    return 0;

}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
  	cin >> s;
  	for (char c = 'a'; c <= 'z'; c++){
    	if (s.find(c) == string::npos){
        	cout << c;
          	return 0;
        }
    }
  	cout << "None";
}

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

int main()
{
    long N, M, a,b,t1=0, t2=100010;
    cin >> N >> M;
    for (int i = 0; i < M;i++){
        cin >> a >> b;
        t1 = max(a, t1);
        t2 = min(b, t2);
        //cout << t1 << " " << t2 << endl;
    }
    if((t2-t1)<0){
        cout << "0" << endl;
    }
    else{
        cout << t2 - t1 + 1 << endl;
    }

}

Measured memory_bytes: 256