akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn gcd(a: i32, b: i32) -> i32 {
    if b == 0 { a } else { gcd(b, a % b) }
}

fn main() {
    input! {
        n: i32,
        x: i32,
        cities: [i32; n],
    }
    
    println!(
        "{}",
        cities.iter()
            .map(|p| (p-x).abs())
            .fold(0, |acc, p| gcd(acc, p))
    )
}

Measured memory_bytes: 4352
def cut(w, d, s):
    mod = s % (w + d)
    s = []
    if mod > w:
        tate = mod - w
        yoko = w
        tate_2 = d - (mod - w)
        area = tate * yoko
        area_2 = tate_2 * yoko
        s.append([area, [yoko, tate]])
        s.append([area_2, [yoko, tate_2]])
    else:
        yoko = mod
        tate = d
        yoko_2 = w - mod
        area = tate * yoko
        area_2 = tate * yoko_2
        s.append([area , [yoko, tate]])
        s.append([area_2, [yoko_2, tate]])
    return sorted(s)


while True:
    n, w, d = map(int, input().split())
    if n == 0 and w == 0 and d == 0:
        break
    cuts = [list(map(int, input().split())) for _ in range(n)]
    areas = [(w * d, [w, d])]
    for key, s in cuts:
        area = areas.pop(key - 1)
        areas += cut(*area[1], s)
    ans = []
    for k in areas:
        ans.append(k[0])
    ans.sort()
    print(*ans)



Measured memory_bytes: 5660
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
    long long int i,j,k,d,m,res,rem,sum=0,su=0,r,p;
    char a[10000],b[10000];
    while(gets(a))
    {
        for(i=0; a[i]!=' '; i++)
        {
            if(a[i]<='9' && a[i]>='0')
            {
                b[i] = a[i] - 48;
                d = i;
            }
        }
        for(i=d+4; a[i]!='\0'; i++)
        {
            if(a[i]<='9' && a[i]>='0')
            {
                b[i] = a[i] - 48;
                m = i;
            }
        }
        p = m-(d+4);
        rem = pow(10,d);
//if(d==2 || d==4 || d==7 || d==8 || d==9) {rem = rem+1;}
        res = pow(10,p);
//if(p==2 || p==4 || p==7 || p==8 || p==9) {res = res+1;}
        for(i=0; i<=d; i++)
        {
            sum = sum + (b[i]*rem);
            rem = rem/10;
        }
        for(i=d+4; i<=m; i++)
        {
            su = su + (b[i]*res);
            res = res/10;
        }
        if(a[d+2]=='+') {r=sum+su;}
        else if(a[d+2]=='-') {r=sum-su;}
        printf("%lld\n",r);
        for(i=0;i<10000;i++){
            a[i] = 0;
            b[i] = 0;
        }
        su = 0;
        sum = 0;
        r = 0;
        res = 0;
        rem = 0;
        d = 0;
        m = 0;
        p = 0;
    }
    return 0;
}

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

int main()
{
	int n,i,j,k=-1;
	cin>>n;
	int a[n],b[n],c[n-1];
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) cin>>b[i];
	for(i=0;i<n-1;i++) cin>>c[i];
	
	int ans=0;
	for(i=0;i<n;i++)
	{
		if(a[i]==k+1) ans+=c[k-1];
		ans+=b[a[i]-1];
		k=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    string S;

    cin >> S;

    for(int i=0;i<S.size()-1;i++){
        if(S[i] == 'A' and S[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    string s, t; cin >> s >> t;
    int n = sz(s), m = sz(t);
    int ans = m;
    for (int i = 0; i + m <= n; ++i) {
        int cnt = 0;
        for (int j = 0; j < m; ++j) {
            cnt += (s[i+j] != t[j]);
        }
        ans = min(ans, cnt);
    }

    cout << ans;

    return 0;
}



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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int w,h;
    cin >> h >> w;
    int mat[h][w];
    char c;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin >> c;
            if(c=='.')mat[i][j]=1;
            else
            {
                mat[i][j]=0;
            }
        }
    }
    int row[h][w];
    int col[h][w];
    int maks=0;
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            row[i][j]=mat[i][j];
        }
        for(int j=1;j<w;j++)
        {
            if(mat[i][j])
            {
                row[i][j]+=row[i][j-1];
            }
        }
        for(int j=w-2;j>=0;j--)
        {
            if(mat[i][j])
            {
                row[i][j]=max(row[i][j],row[i][j+1]);
            }
        }
    }
    for(int j=0;j<w;j++)
    {
        for(int i=0;i<h;i++)
        {
            col[i][j]=mat[i][j];
        }
        for(int i=1;i<h;i++)
        {
            if(mat[i][j])
            {
                col[i][j]+=col[i-1][j];
            }
        }
        for(int i=h-2;i>=0;i--)
        {
            if(mat[i][j])
            {
                col[i][j]=max(col[i][j],col[i+1][j]);
            }
        }
    }
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            maks=max(maks,row[i][j]+col[i][j]-1);
        }
    }
    cout << maks;
    return 0;
}


Measured memory_bytes: 47104
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    string s[4] = {"", "KIH", "B", "R"};
    string str;
    cin >> str;
    ll ans = 0;
    for(ll i = 0; i < 16; i++){
        string tmp = "";
        for(ll j = 0; j < 4; j++){
            tmp += s[j];
            if(i & (1 << j))tmp += "A";
        }
        if(tmp == str)ans = 1;
    }
    Say(ans, "YES", "NO");

    return 0;
}

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int ans = 0;
  int res = k;
  
  if(a >= k){
    ans = k;
  }
  else if(a + b >= k){
    ans = a;
  }
  else{
    res = res - a - b;
    ans = a - res;
  }
  
  cout << ans << endl;
}

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

using namespace std;


int main(){
    double N, a;
    double sum = 0.0;
    vector<double> As;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a;
        As.push_back(a);
        sum += a;
    }
    sum /= N;
    double minval = 100000;
    int ans = 0; 
    for(int i = 0; i < N; i++){
        if(minval > abs(As[i] - sum)){
            minval = abs(As[i] - sum);
            ans = i;
        }
    }

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

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

using namespace std;

long long a, b;

inline long long calc(long long x)
{
    ++x;
    long long bit = 2, res = (x%4 < 2 ? 0 : 1);
    while (bit <= x) {
        if (((x/bit)&1) && ((x-x/bit*bit)&1))
            res += bit;
        bit <<= 1;
    }
    return res;
}

#ifdef DEBUG
inline long long brute(long long x)
{
    long long res = 0;
    for (long long i = 1; i <= x; ++i)
        res ^= i;
    return res;
}
#endif

int main()
{
    cin >> a >> b;
#ifdef DEBUG
    cout << calc(b) << " " << brute(b) << endl;
    cout << calc(a-1) << " " << brute(a-1) << endl;
    cout << (a ? brute(b)^brute(a-1) : brute(a)) << endl;
#endif
    cout << (a ? calc(b)^calc(a-1) : calc(b)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  long long  L, R;
  long long  ans = 0;
  long long  a, b;
  long long x,z;
  long long y = 2020;

  cin >> L >> R;

  if(L < 2019 && R < 2019){
    a = L;
    b = a + 1;
  }else if(L < 2019 && R == 2019){
    a = L;
    b = R;
  }else if(L == 2019){
    a = L;
    b = a + 1;
   }else{
    //LR間に2019の倍数が存在するか？
    x = R/2019;
    //    cout << "x = " << x << endl;

    if(L < x*2019){
      //存在する
      a = x*2019;
      b = a+1;
      //cout << "test2 " << endl;
    }else{
      // cout << "test3 " << endl;
      //存在しない
      //積が2019の倍数に近くなるような選び方をする
      for(int i = L; i < R; i++){
        for(int j = i+1; j <= R; j++){
          a = i;
          b = j;
          z = (a*b)%2019;
          y = min(z, y);
        }
      }
    }
    
  }

  if(y == 2020){
    cout << (a*b)%2019 << endl;
  }else{
    //cout << "test3 ans" << endl;
    cout << y << endl;
  }
  
}


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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

int fact(int n){
    int ans = 1;
    for(int i=1; i<=n; i++){
        ans *= i;
    }
    return ans;
}

signed main(){
    cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
    }

    double dis = 0.0;

    vector<int> b(n);
    for(int i=0; i<n; i++){
        b[i] = i;
    }

    do{
        for(int i=0; i<n; i++){
            dis += sqrt((x[i] - x[b[i]]) * (x[i] - x[b[i]]) + (y[i] - y[b[i]]) * (y[i] - y[b[i]]));
        }
    }while(next_permutation(b.begin(), b.end())); 
    
    cout << dis / fact(n) << endl;

    return 0;
}

Measured memory_bytes: 3728
N = int(input())
s = [int(input()) for _ in range(N)]
x = sum(s)
if x % 10 > 0:
  print(x)
else:
  s.sort()
  f = True
  for i in range(N):
    if s[i] % 10 > 0:
      print(x - s[i])
      f = False
      break
  if f:
    print(0)


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, k;
	cin >> n >> k;
	int ans=0;
	for(int i=0; i<n; i++){
		int h;
		cin >> h;
		if(h>=k) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int delta_x = x2 - x1;
  int delta_y = y2 - y1;
  int x3 = x2 - delta_y;
  int y3 = y2 + delta_x;
  delta_x = x3 - x2;
  delta_y = y3 - y2;
  int x4 = x3 - delta_y;
  int y4 = y3 + delta_x;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


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

#define Set(n,pos) (n|(1<<pos))
#define reset(n,pos) (n&~(1<<pos))
#define check(n,pos) (bool)(n&(1<<pos))
int s[16],t[16],n;
bool ok(int p){
	if(p==0)return 1;
	for(int i=0;i<n;i++)
	{
		if(check(p,i))
		{
			for(int j=0;j<n;j++)
			{
				if(check(s[i],j))
				{
					if(check(p,j)!=check(t[i],j))return 0;
				}
			}
		}
	}
	return 1;
}
int solve()
{
	int ma=0;
	for(int p=0;p<(1<<n);p++)
	{
		if(ok(p))ma=max(ma,__builtin_popcount(p));
	}
	return ma;
}
int main(int argc, char const *argv[])
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a,x,y;
		scanf("%d",&a);
		for(int j=0;j<a;j++)
		{
			scanf("%d %d",&x,&y);
			s[i]=Set(s[i],x-1);
			if(y)t[i]=Set(t[i],x-1);
		}
	}
	printf("%d\n",solve());
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
long long mod(long long a)
{
  return((a%M+M)%M);
}
long long add(long long x,long long y)
{
  return mod(mod(x)+mod(y));
}
long long multiply(long long x,long long y)
{
  return mod(mod(x)*mod(y));
}
long long subtract(long long x,long long y)
{
  return mod(mod(x)-mod(y));
}

int main()
{
  long long int N;
  cin>>N;
  long long int A=1,B=1,D=1;
  for(long long int i=0;i<N;i++)
  {
    A=multiply(A,10);
    B=multiply(B,9);
    D=multiply(D,8);
  }
  A=A-B;
  A=A-B;
  A=add(A,D);
  cout<<mod(A);
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> ti;
ll mod=1E9+7;
 
#define REP(a,b,c) for(ll a=b;a<(c);a++)
#define PER(a,b,c) for(ll a=b;a>=(c);a--)

ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
ld id(){ ld x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oe(){ cout << endl; }
void oie(ll x){ oi(x); oe(); }
void ode(ld x){ od(x); oe(); }
void ose(string x){ os(x); oe(); }

ll memo[50][3210];

int main(){
    ll N=ii();
    ll M=ii();
    ll S=ii();

    REP(i,0,50) REP(j,0,3210) memo[i][j]=LLONG_MAX;

    map<pii, vector<ti>> VB;
    REP(i,0,M){
        ll U=ii()-1, V=ii()-1, A=ii(), B=ii();
        REP(i,A,3210){
            VB[make_pair(U,i)].push_back(make_tuple(V,i-A,B));
            VB[make_pair(V,i)].push_back(make_tuple(U,i-A,B));
        }
    }
    REP(i,0,N){
        ll C=ii(), D=ii();
        REP(j,0,3210-C){
            VB[make_pair(i,j)].push_back(make_tuple(i,j+C,D));
        }
    }

    S=min(2500LL,S);
    queue<pii> q;
    q.push(make_pair(0,S));
    memo[0][S]=0;
    while(!q.empty()){
        auto [u,uc] = q.front();
        for(auto vb : VB[q.front()]){
            auto [v,vc,b] = vb;
            if(memo[u][uc]+b < memo[v][vc]){
                memo[v][vc] = memo[u][uc]+b;
                q.push(make_pair(v,vc));
            }
        }
        q.pop();
    }
    
    REP(i,1,N){
        ll ret=LLONG_MAX;
        REP(j,0,3210){
            ret=min(ret,memo[i][j]);
        }
        oie(ret);
    }

    return 0;
}


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


//Compiler version g++ 6.3.0

int main()
{
   int n = 6;
    vector <string> result;
    
    for(int i = n ; i >= 2; i--){
      
      for (int j = 1; j < i; j++){
        
        if(__gcd(i,j) != 1) continue;
        else{
          
          string s = to_string(j);
          s += "/";
          s += to_string(i);
          result.push_back(s);
          
        }
      }
    }
 for(auto i = result.begin();i != result.end();i++)
{
  
  cout<<*i<<" ";
}*/
  
  /*long long A,B,X;
  
  cin >> A >> B >> X;
  
  long long mm = -1;
  long long x,Y;
  
  for (int i = 1; i <= 10; i++){
    
    Y = B * i;
    long long tmp = X - Y;
    long long t = tmp % A;
    long long maxi = X - t;
    long long hh = tmp / A;
    long long sum = 0,rem;
    while(hh != 0){
      rem = hh % 10;
      hh /= 10;
      sum += 1;
    }
    if(sum >= 10){
      x = 1000000000;
      break;
    }
    if(sum != i) continue;
    if(maxi > mm){
      
      mm = maxi;
      x = tmp / A;
    }
    cout << tmp/A << " "<<maxi <<endl;
    
  }
  if(A == B){
    
  cout << 0;}
  else cout << x;
  return 0;*/
    
 /* int n,m;
  int x;
  map <int,int> mp;
  int L,R,cnt = 0;
  cin >> n >> m;
  vector <int> v(2*m);
  for(int i = 0; i < 2*m; i++){
    cin >> x;
    v[i] = x;
  }
  for(int i = 0; i < 2*m; i++){
    
  }
  
  
  
  for(auto i : mp){
    if(i.second == m)cnt++;
  }
  cout << cnt;*/
    #include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  int arr[n];
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  sort(arr,arr+n);
  stack <float> s;
  
  for(int i = n - 1; i >= 0; i--){
    s.push((float)arr[i]);
  }
  for(int i = 0; i < n - 1; i++){
    float a = s.top();
    s.pop();
    float b = s.top();
    s.pop();
    float c = (a+b)/2;
    s.push(c);
  }
  float ans = s.top();
  
  cout << fixed <<setprecision(5) <<ans;
}



  
  
    

Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#define INF 2100000000
#define INVALID -1
using namespace std;
int dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
class Ryouri {
public:
	long long int a, b;
	bool operator<(const Ryouri &another)const
	{
		if (b + a == another.b + another.a)
			return a > another.a;
		else return b + a > another.b + another.a;
	}
	Ryouri(long long int ia, long long int ib)
	{
		a = ia;
		b = ib;
	}
};
vector <Ryouri>ryouri;
int absint(int a)
{
	return max(a , - a);
}
int main()
{
	long long int n,i,ans=0,a,b;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a >> b;
		ryouri.push_back(Ryouri(a, b));
	}
	sort(ryouri.begin(), ryouri.end());
	for (i = 0; i < n; i++)
	{
		//printf("a%db%d\n", ryouri[i].a, ryouri[i].b);
		if (i % 2) ans -= ryouri[i].b;
		else ans += ryouri[i].a;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

class comb {
public:
	comb();
	~comb();
	vector<vector<int>> main_calc(int a);
private:
	void recursive(int k, vector<int> vec, int id);
private:
	vector<vector<int>> ans;
	vector<int> dum;
	int lim;
};

comb::comb() {
}

comb::~comb() {
}

void comb::recursive(int k, vector<int> vec, int id) {
	if (vec.size() == k) {
		ans.push_back(vec);
		return;
	}
	else if (id == lim) {
		return;
	}
	else {
		recursive(k, vec, id + 1);
		vec.push_back(dum[id]);
		recursive(k, vec, id + 1);
	}
}

vector<vector<int>> comb::main_calc(int a) {
	ans.clear();
	dum.clear();
	lim = a;
	vector<int> vec;
	for (int i = 0; i < a; i++) {
		dum.push_back(i);
	}
	for (int i = 0; i < a; i++) {
		vec.clear();
		recursive(i, vec, 0);
	}

	return ans;
}

int main() {

	int H, W;
	int K;
	cin >> H >> W >> K;

	vector<string> c(H, "");
	int sum = 0;
	for (int i = 0; i < H; i++) {
		cin >> c[i];
		for (int j = 0; j < W; j++) {
			if (c[i][j] == '#') {
				sum += 1;
			}
		}
	}



	comb cb;

	vector<vector<int>> vH = cb.main_calc(H);
	vector<vector<int>> vW = cb.main_calc(W);
	vector<string> d = c;
	int ans = sum;
	int val = 0;
	for (int ih = 0; ih < vH.size(); ih++) {
		for (int jw = 0; jw < vW.size(); jw++) {

			d = c;
			ans = sum;

			for (int i = 0; i < vH[ih].size(); i++) {
				for (int l = 0; l < W; l++) {
					if (d[vH[ih][i]][l] == '#') {
						ans -= 1;
						d[vH[ih][i]][l] = '.';
					}
				}
			}

			for (int j = 0; j < vW[jw].size(); j++) {
				for (int l = 0; l < H; l++) {
					if (d[l][vW[jw][j]] == '#') {
						ans -= 1;
					}
				}
			}

			if (ans == K) {
				val += 1;
			}
		}
	}

	cout << val << endl;

	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str,ing;
	cin>>str;
	cin>>ing;
	str+=str;
	int q=(int)str.find(ing);
	if(q==-1)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

using namespace std;
using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 N, A, B;
  cin >> N >> A >> B;

  int64 ret = 0;

  int64 step = A + B;
  ret += N / step * A;
  ret += min(N % step, A);
  cout << ret << endl;
}



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

int main(void)

{
    char s[200000] = {0};
    char t[200000] = {0};
    int a, sum;
    sum = 0;
    cin >> s;
    cin >> t;
    for (a = 0; a < 200000; a++)
    {
        if (s[a] != t[a])
            sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4020
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    ll a, b;
 
    cin >> a >> b;
 
    ll ta = a;
    ll tb = b;
 
    vector<ll> primea;
    primea.push_back(1);
    vector<ll> primeb;
    primeb.push_back(1);
 
    for(ll i = 2; i * i <= a; i++){
        bool in = false;
        while(ta % i == 0){
            in = true;
            ta /= i;
        }
 
        if(in){
            primea.push_back(i);
        }
    }

    if(ta != 1){
        primea.push_back(ta);
    }
 
    for(ll i = 2; i * i <= b; i++){
        bool in = false;
        while(tb % i == 0){
            in = true;
            tb /= i;
        }
 
        if(in){
            primeb.push_back(i);
        }
    }

    if(tb != 1){
        primeb.push_back(tb);
    }
 
    ll ans = 0;
 
    for(ll i = 0; i < primea.size(); i++){
        for(ll j = 0; j < primeb.size(); j++){
            if(primea[i] == primeb[j]){
                ans++;
                break;
            }
        }
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  long A, B, K;
  scanf("%ld %ld %ld", &A, &B, &K);
  
  for(int i=0;i<K;i++){
   A -= 1; 
  }
  
  if(A<0){
    B+=A;
    A=0;
  }
  
  if(B<0){
  	B=0;
  }
  
  printf("%ld %ld", A, B);
  
  return 0;
}

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

s = 26
cnt = 1
while 1:
    if N <= s:
        break
    cnt +=1
    s+=26**cnt


N = N-s+26**cnt-1
r = [0]*cnt
ans = [0]*cnt
for i in range(cnt):
    r[i] = N % 26
    N //= 26
    ans[i] = chr(ord("a")+r[i])
ans.reverse()
print("".join(ans))





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

int main(){
  int a;
  string op;
  int b;
  
  cin>>a>>op>>b;
  
  if(op=="+"){
    cout<<a+b<<endl;
  }
  if(op=="-"){
    cout<<a-b<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,c,x;
  scanf("%d %d %d %d", &a, &b, &c, &x);
  int count = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        if (i*500+j*100+k*50 == x) {
          count++;
        }
      }
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
inline void read(int&ans)
{
	ans=0;
	register char ch=getchar();
	while(ch<'0' or ch>'9')ch=getchar();
	while(ch>='0' and ch<='9')ans=ans*10+(ch^48),ch=getchar();
}
int fa[100010],n,m,dis[100010];
int find(int x)
{
	if(fa[x]!=x){
		int a=fa[x];fa[x]=find(fa[x]),dis[x]+=dis[a];	
	}
	return fa[x];
}
int main()
{
	read(n),read(m);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(register int i=1;i<=m;i++)
	{
		int l,r,d;
		read(l);read(r);read(d);
		int ll=find(l),rr=find(r);
		if(ll==rr and dis[l]-dis[r]!=d)
		{
			cout<<"No";return 0;
		}
		else if(ll!=rr)
		{
			fa[ll]=rr;
			dis[ll]=dis[r]+d-dis[l];
		}
	}
	cout<<"Yes";
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}






void solve() {
    
     ll n;
     cin >> n;
     
     ll A[n + 1];
     
     ll sum = 0 ;
     ll ma = 0;
     
     for(ll i = 1; i <= n; i++) {
            cin >> A[i];
            ma = max(ma, A[i]);
            if(i > 1) {
                    sum += max(0LL, (ma - A[i]));
            }
     }
     
     cout << sum << endl;
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


Measured memory_bytes: 5144
package main

import "fmt"

func main() {
	// Code for A - On the Way
	var A, B, C int
	fmt.Scanf("%d %d %d", &A, &B, &C)

	if (A < C && C < B) || (B < C && C < A) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1836
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int H,N;
string s[11][2];
string t[3][2][2];
bool S[20][2][2];
bool T[3][2][2][2];
int dx[9]={1,1,1,0,0,0,-1,-1,-1},dy[9]={1,0,-1,1,0,-1,1,0,-1};
bool check(int id,int x)
{
	for(int i=0;i<2;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)
	{
		if(T[id][i][j][k]&&S[x+i][j][k])return false;
	}
	return true;
}
int f()
{
	int ret=0;
	for(int i=0;i<N;i++)
	{
		int id=18;
		while(check(i,id))id--;
		id++;
		for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
			S[id+K][I][J]|=T[i][K][I][J];
		for(int K=19;K>0;K--)
		{
			if(S[K][0][0]&&S[K][0][1]&&S[K][1][0]&&S[K][1][1])
			{
				ret++;
				for(int I=K;I<19;I++)
				{
					S[I][0][0]=S[I+1][0][0];
					S[I][0][1]=S[I+1][0][1];
					S[I][1][0]=S[I+1][1][0];
					S[I][1][1]=S[I+1][1][1];
				}
				S[19][0][0]=S[19][0][1]=S[19][1][0]=S[19][1][1]=0;
			}
		}
	}
	return ret;
}
main()
{
	s[0][0]=s[0][1]="##";
	while(cin>>H>>N,N)
	{
		for(int i=0;i++<H;)
		{
			cin>>s[i][0]>>s[i][1];
		}
		vector<int>id;
		for(int i=0;i<N;i++)
		{
			cin>>t[i][0][0]>>t[i][0][1]>>t[i][1][0]>>t[i][1][1];
			id.push_back(i);
		}
		sort(id.begin(),id.end());
		int ans=0;
		do
		{
			for(int i=0;i<(N>=1?9:1);i++)
			{
				bool flag1=true;
				if(N>=1)
				{
					for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
						T[id[0]][K][I][J]=0;
					for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
					{
						int tx=I+dx[i],ty=J+dy[i];
						if(t[0][K][I][J]=='.'||0<=tx&&tx<2&&0<=ty&&ty<2)
						{
							if(t[0][K][I][J]=='#')T[id[0]][K][tx][ty]=true;
						}
						else
						{
							flag1=false;
							break;
						}
					}
				}
				if(!flag1)continue;
				for(int j=0;j<(N>=2?9:1);j++)
				{
					bool flag2=true;
					if(N>=2)
					{
						for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
							T[id[1]][K][I][J]=0;
						for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
						{
							int tx=I+dx[j],ty=J+dy[j];
							if(t[1][K][I][J]=='.'||0<=tx&&tx<2&&0<=ty&&ty<2)
							{
								if(t[1][K][I][J]=='#')T[id[1]][K][tx][ty]=true;
							}
							else
							{
								flag2=false;
								break;
							}
						}
					}
					if(!flag2)continue;
					for(int k=0;k<(N>=3?9:1);k++)
					{
						bool flag3=true;
						if(N>=3)
						{
							for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
								T[id[2]][K][I][J]=0;
							for(int K=0;K<2;K++)for(int I=0;I<2;I++)for(int J=0;J<2;J++)
							{
								int tx=I+dx[k],ty=J+dy[k];
								if(t[2][K][I][J]=='.'||0<=tx&&tx<2&&0<=ty&&ty<2)
								{
									if(t[2][K][I][J]=='#')T[id[2]][K][tx][ty]=true;
								}
								else
								{
									flag3=false;
									break;
								}
							}
						}
						if(!flag3)continue;
						for(int i=0;i<20;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++)
							S[i][j][k]=0;
						for(int i=0;i<=H;i++)
						{
							for(int j=0;j<2;j++)for(int k=0;k<2;k++)
								S[i][j][k]=s[i][j][k]=='#';
						}
						ans=max(ans,f());
					}
				}
			}
		}while(0&&next_permutation(id.begin(),id.end()));
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3232
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
        int H = in.nextInt();
        int W = in.nextInt();
        if(H==0&&W==0){
            break;
        }
        for(int i = 0; i<H ; i++){
            for(int j = 0; j<W ; j++){
                System.out.print("#");
            }
            System.out.println();
        }
        System.out.println();
        }
        in.close();
    }
    }


Measured memory_bytes: 34900
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod   998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define endl "\n"
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow...question galat mat padhna */
{
    fast;   
    ll n,m;
    cin>>n>>m;
    priority_queue<ll>x;
    For(i,n)
    {
        ll a;
        cin>>a;
        x.push(a);
    }
    For(i,m)
    {
        ll a=x.top();
        x.pop();
        a=a/2;
        x.push(a);
    }
    ll ans=0;
    while(!x.empty())
    {
        ans+=x.top();
        x.pop();
    }
    cout<<ans<<endl;
}      

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

int main(){
  int k,s,x,y,z,count;
  cin >> k >> s;
  if(k<2||k>2500||s<0||s>3*k)
  return -1;

  count=0;
  for(x=0;x<=k;x++){
    for(y=x;y<=k;y++){
      for(z=y;z<=k;z++){
        if(x+y+z==s){
          if(x==y && y==z)
            count +=1;
          else if(x==y||y==z||z==x)
            count+=3;
          else
            count+=6;
	}
      }
    }
  }

  cout << count << "\n" ;

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
a, b, c, d = map(int, input().split())
ans = b - a + 1

def lcm(x, y):
  return (x * y) // gcd(x, y)

a -= 1
ans = ans - (b//c) - (b//d) + (b//(lcm(c,d)))
ans = ans + (a//c) + (a//d) - (a//(lcm(c,d)))
print(ans)

Measured memory_bytes: 5048
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

struct ordered_pair {
  int n_, n2_;
  explicit ordered_pair(int n): n_(n), n2_(n*2-3) {}
  int64_t operator()(int x, int y) const {
    int z = std::min(x, y);
    return z*(n2_-z)/2 + std::max(x, y) - 1;
  }
};

uint64_t getZ() {
  uint64_t v = 0; int c;
  while((c = getchar_unlocked()) >= '0') v=v*10+c-'0';
  return v;
}

template<int MAXV>
struct scc {
  std::vector<int> G[MAXV], rG[MAXV], vs;
  bool used[MAXV];
  int cmp[MAXV];
  scc() {}
  void dfs(int v) {
    used[v] = true;
    for(auto c: G[v]) if(!used[c]) dfs(c);
    vs.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for(auto c: rG[v]) if(!used[c]) rdfs(c, k);
  }
  int build(int V) {
    std::fill_n(used, V, false);
    vs.clear();
    for(int v = 0; v < V; ++v) if(!used[v]) dfs(v);
    std::fill_n(used, V, false);
    int k = 0;
    for(int i = vs.size()-1; i >= 0; --i) {
      if(!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
  }
  void add_edge(int fr, int to) {
    G[fr].push_back(to); rG[to].push_back(fr);
  }
};

int const MAXN = 1000;
int const MAXV = MAXN*(MAXN-1)/2;

scc<MAXV> S;
int depth[MAXV];
int calc_depth(int v) {
  if(depth[v] >= 0) return depth[v];
  int res = -1;
  for(auto c: S.G[v]) res = std::max(res, calc_depth(c));
  ++res;
  return depth[v] = res;
}

int main() {
  int N = getZ(), maxv = N*(N-1)/2;
  ordered_pair P(N);
  for(int i = 0; i < N; ++i) {
    int pV = P(i, getZ()-1);
    for(int j = 1; j < N-1; ++j) {
      int cV = P(i, getZ()-1);
      S.add_edge(pV, cV);
      pV = cV;
    }
  }
  if(S.build(maxv) < maxv) fin(-1);
  std::fill_n(depth, maxv, -1);
  int ans = 0;
  for(int i = 0; i < maxv; ++i) {
    ans = std::max(ans, calc_depth(i)+1);
  }
  fin(ans);
  return 0;
}


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

void solve1()
{
	ll n, r = 0, g = 0, b = 0, s;
	string a;
	cin >> n >> a;
	for(int i = 0; i < n; i++)
		if(a[i] == 'R')
			r++;
		else if(a[i] == 'G')
			g++;
		else
			b++;
	s = r * g * b;
	for(int i = 1; i < n; i++){
		for(int j = 0; j < n - i - 1; j++){
			if(a[j] != a[j + i] && a[j] != a[j + i + i] && a[j + i] != a[j + i + i] && j + i + i < n){
				s--;
			}
		}
	}
	cout << s;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

long long N, A, B, C, D;
int main() {
    cin >> N >> A >> B >> C >> D;
    A *= 2, B *= 2, C *= 2, D *= 2;
    --N;
    long long diff = abs(A - B);
    long long gap = (C + D) / 2;
    long long center = 0;
    if (N & 1) center = gap;
    long long radius = (D - C) / 2 * N;

    bool ok = false;
    for (int i = 0; i < N*2; ++i) {
        long long left = center - radius, right = center + radius;
        if (right > D * N) break;
        if (left <= diff && diff <= right) ok = true;
        center += gap * 2;
    }
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

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

int main(){
    int k,x;
    cin >> k >> x ;
    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
A = int(input())    #500円
B = int(input())    #100円
C = int(input())    #50円
X = int(input())

num = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                num += 1

print(num)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x)
{
	x=0;
	int p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
int n;
int a[80];
int tot;
struct node
{
	int x,y;
}e[200];
int maxn=-0x7f7f7f7f;
int pd;
int pos;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++)
	{
		read(a[i]);
		if(maxn<abs(a[i]))
		{
			maxn=abs(a[i]);
			pos=i;
			if(a[i]<0)pd=-1;
			else pd=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		e[++tot].x=pos,e[tot].y=i;
		a[i]=a[i]+pd*maxn;
	}
	if(pd==1)
	{
		for(int i=1;i<n;i++)
		{
			e[++tot].x=i;
			e[tot].y=i+1;
		}
	}
	else
	{
		for(int i=n;i>1;i--)
		{
			e[++tot].x=i;
			e[tot].y=i-1;
		}
	}
	cout<<tot<<endl;
	for(int i=1;i<=tot;i++)
		printf("%d %d\n",e[i].x,e[i].y);
	return 0;
}

Measured memory_bytes: 384
n,m,x,y=list(map(int,input().split(" ")))
X=list(map(int,input().split(" ")))
Y=list(map(int,input().split(" ")))

if x<y and max(X)<min(Y) and max(X)<y and x<min(Y):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
MOD = 10 ** 9 + 7
MAX = 2000

cmb = [[0 for _ in range(MAX + 1)] for _ in range(MAX + 1)]
for i in range(MAX + 1):
    cmb[i][0] = cmb[i][i] = 1
    for j in range(1, i):
        cmb[i][j] = (cmb[i - 1][j - 1] + cmb[i - 1][j]) % MOD

n, k = map(int, input().split())
for i in range(1, k + 1):
    print((cmb[n - k + 1][i] * cmb[k - 1][i - 1]) % MOD)

Measured memory_bytes: 99260
#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,s;
    char x[10],y[10],c,d;
    scanf("%d %d",&a,&b);
    for(i=0;i<b;i++)
    {
        x[i]=a+48;
    }
    x[b]='\0';
    for(i=0;i<a;i++)
    {
        y[i]=b+48;
    }
    y[a]='\0';
    if(a>=b)
    {
        printf("%s",y);
    }
    else if(a<b)
    {
        printf("%s",x);
    }

}



Measured memory_bytes: 1704
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

x = [0] * n
y = [0] * n
for i in range(n):
    x[i] = i + a[i]
    y[i] = i - a[i]

cx = Counter(x)
cy = Counter(y)

ans = 0
for i in cx.keys():
    ans += cx[i] * cy[i]

print(ans)


Measured memory_bytes: 63468
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define pb push_back
#define endl "\n";
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

const int maxn=1e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
int f[maxn];
int an;
int ps;
int mn=inf;
int main(){
	migmig;
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		f[i]=l+i-1;
	}
	for(int i=1;i<=n;i++){
		if(abs(f[i]-0)<mn){
			mn=abs(f[i]-0);
			an=i;
		}
	}
	for(int i=1;i<=n;i++){
		if(i!=an){
			ps+=f[i];
		}
	}
	cout<<ps;
	return 0;
}




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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, k; cin >> n >> k;
  vector<int> l(n); for(int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  int sum = 0;
  for(int i = 0; i < k; i++) {
    sum += l[n-1-i];
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N,K = parseMap(split(readline()))
H = []
for i in 1:N 
    h = parseInt(readline())
    push!(H,h)
end
sort!(H)

min_s = 10^10
for i in 1:N-K+1
    s = H[i+K-1] - H[i]
    if s < min_s
        min_s = s
    end
end        
println(min_s)

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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll n;
  cin >> n;
  ll ret = n - 1;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i) continue;
    ll a = i, b = n / i;
    ret = min(ret, (i - 1) + (b - 1));
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
 
using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
 
using Index = int;
template<typename Data>
struct FenwickTree{
    vector<Data> data;
    FenwickTree(int n){ data.resize(n+1,0); }
    Data sum(Index idx){
        Data s = 0;
        while(idx > 0){
            s += data[idx];
            idx -= idx & (-idx);
        }
        return s;
    }
    Data sum(Index i,Index j){
        return sum(j) - sum(i-1);
    }
    void add(Index i,Data x){
        while(i <= data.size()){
            data[i] += x;
            i += i & (-i);
        }
    }
};
 
class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        vector<vector<pii>> ranges(M + 1);
        rep(i, N) {
            pii r; cin >> r.first >> r.second;
            ranges[r.second - r.first + 1].push_back(r);
        }
        FenwickTree<int> bit(M + 2);
        int more_than_i = N;
        vector<int> ans(M);
        repeat(m, 1, M + 1) {
            more_than_i -= ranges[m - 1].size();
            for(auto r : ranges[m - 1]) {
                bit.add(r.first, 1);
                bit.add(r.second + 1, -1);
            }
            ans[m - 1] = more_than_i;
            for(int i = m; i <= M; i += m) ans[m - 1] += bit.sum(i);            
        }
        rep(i, M) cout << ans[i] << endl;
        return 0;
    }
};
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}

Measured memory_bytes: 8448
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,M;
vector<int> A(SIZE);

void solve(int _t) {
    cin>>N;
    int m = 7%N;
    int ans = 1;
    REP(i,1e7) {
        if (!m) {
            _PN(ans);
            return;
        }
        m = (10*m+7)%N;
        ans++;
    }
    _PN("-1");
}
EXEC(1)



Measured memory_bytes: 4944
from collections import defaultdict

N = int(input())
d1 = defaultdict(int)
d2 = defaultdict(int)
for i in range(N):
    d1[input()] += 1
M = int(input())
for i in range(M):
    d2[input()] += 1
ans = []
for x in d1:
    ans.append(d1[x]-d2[x])
print(max(max(ans), 0))

Measured memory_bytes: 3316