akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int H, W;
char A[1010][1010];
int m[1010][1010];

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

    queue< pair<int, int> > que;
    cin >> H >> W;
    rep(y, H){
        rep(x, W){
            cin >> A[y][x];
            if(A[y][x] == '#') que.push(make_pair(x, y));
        }
    }

    while(!que.empty()){
        pair<int, int> p = que.front();
        que.pop();

        rep(i, 4){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(0 <= nx && nx < W && 0 <= ny && ny < H && A[ny][nx] == '.' ){
                m[ny][nx] = m[p.second][p.first] + 1;
                A[ny][nx] = '#';
                que.push(make_pair(nx, ny));
            }
        }
    }

    int ans = 0;
    rep(i, H) rep(j, W) ans = max(ans, m[i][j]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11408
import sys
from math import ceil, floor
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def enough(t):
    cnt = 0
    for h in H:
        # 全体攻撃を受けた残りHP
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = floor(sum(H)/(a+(n-1)*b))
if enough(bot):
    print(bot)
    sys.exit(0)
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2
#print(bot,mid,top)
print(top)


Measured memory_bytes: 7088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n,i;
  cin>>n;
  map <string,int> ma;
  for(i=0;i<n;i++)
  {
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    ma[s]++;

  }
  ll ctr=0;
  for(auto it:ma)
  {
    ll k = it.second;
    ctr = ctr+(k*(k-1))/2;
  }
  cout<<ctr<<endl;
  }
  
  




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

#define pii pair <int, int>

#define mp make_pair

#define f first
#define s second

#define pb push_back

using namespace std;

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

const int N = 1e5 + 10;
const int NN = 20;
const int INF = 1e9 + 7;

ll a[10], b[10];

int main() {
    #define fn "balls"
    #ifdef witch
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
//        freopen(fn".in", "r", stdin);
//        freopen(fn".out", "w", stdout);
    #endif
    srand(time(0));
    for (int i = 0; i < 7; i++) {
        cin >> b[i];
    }
    ll mx = min(b[0], min(b[3], b[4])), ans = 0;
    for (int t = 0; t <= min(1ll, mx); t++) {
        for (int i = 0; i < 7; i++) {
            a[i] = b[i];
        }
        a[0] -= t;
        a[3] -= t;
        a[4] -= t;
        ll cnt = 0;
        cnt += t * 6;
        cnt += (a[0] / 2) * 4 + a[1] * 2 + (a[3] / 2) * 4 + (a[4] / 2) * 4;
        ans = max(ans, cnt / 2);
    }
    cout << ans;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int count[100001] = {};
    for(int i=0; i<n; i++){
        int t;
        cin >> t;
        if(t != 0) count[t-1]++;
        count[t]++;
        count[t+1]++;
    }
    cout << *max_element(count, count+100001) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define sz size()
#define pb(x) push_back(x) 
#define a first
#define b second
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,K; cin>>N>>K;
	vector<P> p(N);
	bool zero=false;
	ll ans=10000000000;
	rep(i,N){
		ll t; cin>>t;
		p[i]=mp(abs(t),t>0?1:t==0?0:-1);
	}
	sort(p.bg,p.ed);
	vector<ll> minus;
	vector<ll> plus;
	minus.pb(0);
	plus.pb(0);
	rep(i,N){
		if(p[i].b==1) plus.pb(p[i].a);
		else if(p[i].b==-1) minus.pb(p[i].a);
		else zero=true;
	}
	if(zero){
		if(plus.sz>=K) ans=min(ans,plus[K-1]);
		if(minus.sz>=K) ans=min(ans,minus[K-1]);
          for(int i=minus.sz-1;K-1-i<=plus.sz-1;i--){
			if(i>=1 && K-1-i>=1) ans=min(ans,min(minus[i],plus[K-1-i])+minus[i]+plus[K-1-i]);
		}
        
	}else{
		if(plus.sz-1>=K) ans=min(ans,plus[K]);
		if(minus.sz-1>=K) ans=min(ans,minus[K]);
		for(int i=minus.sz-1;K-i<=plus.sz-1;i--){
			if(i>=1 && K-i>=1) ans=min(ans,min(minus[i],plus[K-i])+minus[i]+plus[K-i]);
		}
      
	}
	cout<<ans;
}

Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll n,T;
    cin>>n>>T;
    ll cheap = 1e9;
    for(ll i = 0; i<n; i++){
        ll c,t;
        cin>>c>>t;
        if(T<t)continue;
        else if(T>=t)cheap = min({cheap,c});
    }
    if(cheap == 1e9)puts("TLE");
    else cout<<cheap<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        long X = scan.nextLong();
        long[] x = new long[N];
        for (int i = 0; i < N; i++) {
            x[i] = Math.abs(scan.nextLong() - X);
        }
        System.out.println(gcd_list(x));
    }
    public long gcd(long x, long y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }
    public long gcd_list(long [] x) {
        long answer = 0;
        for (int i = 0; i < x.length; i++) {
            answer = gcd(x[i], answer);
        }
        return answer;
    }
}


Measured memory_bytes: 48608
a, b = map(int, input().split())
A = list(map(int, input().split()))
d = []
for i in range(len(A)):
  if i == len(A)-1:
    r = a-A[i]+A[0]
    d.append(r)
  else:
    d.append(A[i+1]-A[i])
print(a-max(d))


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

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

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

ll mod_pow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n % 2)ret = ret * x%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}
struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 17);

bool memo1[2001][2001];
ll ret1[2001][2001];

bool memo2[2001][2001];
ll ret2[2001][2001];

ll alsum[2001][2001];

void init() {
	rep(i, 2001) {
		rep(j, 2000) {
			alsum[i][j + 1] = (alsum[i][j] + p.comb(i, j))%mod;
		}
	}
}

ll calc2(int a, int b) {
	if (a == 0 || b == 0)return 1;
	if (a < 0)return 0;
	if (memo2[a][b])return ret2[a][b];
	memo2[a][b] = true;
	ll ret = calc2(a - 1, b);
	int ri = min(a, b - 1);
	ret += alsum[b - 1][ri + 1];
	return ret2[a][b] = ret % mod;
}
ll calc1(int a, int b) {
	if (a == 0 || b == 0)return 1;
	if (a < 0)return 0;
	if (memo1[a][b])return ret1[a][b];
	memo1[a][b] = true;
	ll ret = calc1(a - 1, b);
	for (int j = 0; j <= a; j++) {
		if (b - j <= 0)continue;
		ll pro = p.comb(b-1, j);
		ret += pro*calc2(a - j, j)%mod;
	}
	return ret1[a][b] = ret % mod;
}
void solve() {
	int a, b;
	cin >> a >> b;
	cout << calc1(a,b) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	init();
	solve();

	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 104192
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll n; cin>>n;
    if(n>=1200)cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}



















































Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    while(a<=b){
        if(a%n==0){
            cout << "OK";
            break;
        }
        a++;
    }
    if(a>b){
        cout << "NG";
    }
    return 0;
}


Measured memory_bytes: 3132
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, char *argv[])
{
  int n, i, j, k;
  int *A;
  int cnt, m, G[12], v;
 
  scanf("%d", &n);
 
  A = (int *)malloc(sizeof(int) * n);
 
  for (i = 0; i < n; i++) scanf("%d", &A[i]);
 
  cnt = 0;
  m = 1;
  G[0] = 1;
  while (3 * G[m-1] + 1 < n) {
    G[m] = 3 * G[m-1] + 1;
    m++;
  }
 
  for (i = 0; i < m / 2; i++) {
    v = G[i];
    G[i] = G[m-1-i];
    G[m-1-i] = v;
  }
 
  printf("%d\n", m);
  for (i = 0; i < m; i++) {
    if (i != m - 1) printf("%d ", G[i]);
    else printf("%d\n", G[i]);
  }
 
  for (i = 0; i < m; i++) {
    for (j = G[i]; j < n; j++) {
      v = A[j];
      k = j - G[i];
      
      while (k >= 0 && A[k] > v) {
    A[k+G[i]] = A[k];
    k -= G[i];
    cnt++;
      }
      A[k+G[i]] = v;
    }
  }
 
  printf("%d\n", cnt);
  for (i = 0; i < n; i++) printf("%d\n", A[i]);
 
  return 0;
}

Measured memory_bytes: 4508
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)

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

    if (*min_element(a.begin(), a.end()) == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    rep(i, n) {
        if (a[i] <= 1000000000000000000 / ans) ans *= a[i];
        else {
            cout << -1 << endl;
        return 0;
        }
        
    }
    // cout << pow(10, 18) << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4036
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(n,a,b)=input.split(" ").map(_.toInt)
    Array(n*a,b).min.toString
  }
}


Measured memory_bytes: 25544
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  bool ok = false;
  string s, t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    char c = s[s.size() - 1];s.pop_back();
    s = c + s;
    if(s == t)ok = true;
  }
  cout << (ok?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,d;
  cin>>n>>d;
  int num = d*2+1;
  int sum=0,ans=0;
  while(sum<n)
  {
    	sum+=num;
    ans++;
  }
  cout<<ans;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int main() {
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> as(n),bs(m);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<m;i++) cin>>bs[i];

  sort(as.begin(),as.end());
  vector<Int> ss(n+1,0);
  for(Int i=0;i<n;i++) ss[i+1]=ss[i]+as[i];

  map<Int, Int> cnt;
  for(Int b:bs) cnt[b]++;

  const Int MAX = 3e5;
  Int ans=0;
  for(auto p:cnt){
    Int b=p.first;
    Int res=0;
    for(Int k=0;b*k<=MAX;k++){
      // [lb, ub)
      Int lb=b*k;
      Int ub=b*(k+1);
      auto latte=lower_bound(as.begin(),as.end(),lb)-as.begin();
      auto malta=lower_bound(as.begin(),as.end(),ub)-as.begin();
      res+=ss[malta]-ss[latte];
      res-=lb*(malta-latte);
    }
    ans+=res*p.second;
  }

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



Measured memory_bytes: 19764
s = input()
k = int(input())

len_s = len(s)
substr = set()
for i in range(len_s):
    for j in range(i+1, min(len_s+1, i+k+1)):
        substr.add(s[i:j])

substr = list(substr)
substr.sort()
print(substr[k-1])

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

    REP(i,SZ(s)){
        if(s[i]!=t[i]){
            cout << "No" << "\n";
            return 0;
        }
    }
    cout << "Yes" << "\n";

    return 0;
}

Measured memory_bytes: 3628
import collections as c
n,k = map(int,input().split())
x = list(map(int,input().split()))
y = c.Counter(x)
s = []
for i in y.items():
    s.append([i[1],i[0]])
s.sort()
ans = 0
for i in range(len(s)-k):
    ans += s[i][0]
print(ans)

Measured memory_bytes: 45896
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)

int main(void) {
  lld n, m, c = 0;
  scanf("%lld%lld", &n, &m);
  for (lld i = m; i <= n + 1; i++) {
    c += (n - i + 1) * i + 1;
    c %= 1000000007;
  }
  printf("%lld\n", c);
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    String c = scanner.next();
    
    //　母音か子音かを判別する
    if(c.equals("a") || c.equals("i") || c.equals("u")
       || c.equals("e") ||c.equals("o")) {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }
  }
}

Measured memory_bytes: 35652
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int n , k;

int main(){
	scanf("%d%d" , &n , &k);
	LL ans = (n-2) / 11 * 5;
	int x = (n-2) % 11;
	repm(i,x,0){
		repp(j,1,6){
			if((72 + 9 * (i * 7 + j - 7)) % 11 == k) ++ans;
		}
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <iterator>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int MOD = 998244353;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	if (d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(d.begin(), d.end());
	if (n == 1 && d[0] == 0) {
		cout << 1 << endl;
		return 0;
	}
	else if (n == 1 && d[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	if (d[0] == 0 && d[1] == 0) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, n - 1) {
		if (2 <= d[i + 1] - d[i]) {
			cout << 0 << endl;
			return 0;
		}
	}
	map<int, int> mp;
	rep(i, n) {
		mp[d[i]]++;
	}
	ll ans = 1;
	for (auto itr = mp.rbegin(); itr != prev(mp.rend()); ++itr) {
		rep(i, itr->second) {
			ans *= ll(next(itr)->second);
			ans %= ll(MOD);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8268
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  string s,s1;
  cin>>s>>s1;
  ll ans = 0;
  rep(i,0,s.sz){
    if(s[i]!=s1[i])ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
import math
N,D = list(map(int,input().split()))
A = [[]]*N
for i in range(N):
    A[i] = list(map(int,input().split()))

num = 0
for a in A:
    if (math.sqrt(a[0]**2+a[1]**2)<=D):num+=1
print(num)

Measured memory_bytes: 90724
n,l = map(int,input().split())
all_app = n*l + int((0.5*n*(n + 1)))-n
aji = []
for i in range(n):
    aji.append(all_app - ((i+1)+l-1))

sa = abs(all_app-aji[0])
ans = 0
for i in aji:
    if abs(all_app - i) <= sa: #=も含める事でaji[0]についても考慮する
        sa = abs(all_app - i)
        ans = i

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
//typedef vector<vector<P> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//入力
ll n;
vector<ll>a;

//途中で使う
map<ll,ll>rk;
vector<ll>tmp;

int main(){
    cin >> n;
    a.resize(n);
    tmp.resize(n);
    rep(i,n){
        cin>>a[i];
        tmp[i]=a[i];
    }
    sort(tmp.begin(),tmp.end());
    rep(i,n){
        rk[tmp[i]]=i;
    }
    ll ans = 0;
    rep(i,n){
        if((i%2)!=(rk[a[i]]%2))ans++;
    }
    cout << ans/2 << endl;


    return 0;
}

Measured memory_bytes: 11164
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
bool dp[1000001];
bool a[1000001];
int main() {
	long long n, x;
	fill(a, a + 1000001, true);
	a[0] = false;
	a[1] = false;
	for (int i = 0; i <= 1000000; i++) {
		if (a[i]) {
			int j = 2;
			while (i*j <= 1000000) {
				a[i*j] = false;
				j++;
			}
		}
	}
	while (cin >> n >> x&&n != 0 && x != 0) {
		fill(dp, dp + x + 1, false);
		int y;
		dp[0] = true;
		for (int i = 0; i < n; i++) {
			cin >> y;
			for (int i = y; i <= x; i++) {
				if (dp[i - y]) {
					dp[i] = true;
				}
			}
		}
		for (int i = x; i >= 2; i--) {
			if (a[i]&&dp[i]) {
				cout << i << endl;
				goto stop;
			}
		}
		cout << "NA" << endl;
	stop:;
	}
}

Measured memory_bytes: 5028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n;cin>>n;
    ll sum=0;
    f(i,1,n+1){
        if(i%3==0 || i%5==0)continue;
        else sum+=i;
    }
    cout<<sum;
    return 0;  
} 





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

int just(string x){
    int ret = 0;
    for(int i = 0; i < x.length(); i++){
        ret += x[i] - '0';
    }
    return ret;
}

int main(){
    string s;
    cin >> s;
    cout << max(just(s), (s[0]-'0'-1) + 9*(int)((s.length()-1))) << endl;
    return 0;
}

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

using ll = long long;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut s).unwrap();
    let s = s.split_whitespace().collect::<Vec<_>>();
    println!("{}", if s[3].parse::<i32>().unwrap() == 1 { 1 } else { 0 });
}

Measured memory_bytes: 4352
import java.util.Scanner

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val s = Array<Int?>(n, { null })

    println(0)
    System.out.flush()
    var temp = scanner.next()
    if (temp == "Vacant") {
        return
    } else {
        s[0] = if (temp == "Male") 0 else 1
        var l = 0
        var p = n / 2
        var r = n - 1
        while(true) {
            println(p)
            System.out.flush()
            temp = scanner.next()
            if (temp == "Vacant") {
                return
            } else {
                s[p] = if (temp == "Male") 0 else 1
                if ((s[l] == s[p]) == ((p - l) % 2 == 0)) {
                    l = p
                } else {
                    r = p
                }
                p = (r + l + 1) / 2
            }
        }
    }
}


Measured memory_bytes: 32000
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const int INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
int main()
{
string s;
cin>>s;
int a=s.size();
int q=0;
for(int i=0;i<a-1;i++)
    if(s[i]==s[i+1])
{
    q=1;break;
}
if(q)cout<<"Bad";
else cout<<"Good";

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 0x7fffffff
#define N 300001
typedef long long ll;
typedef long double ld;
 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()

int div(int k)
{
	int ans = 1, temp = 7;
	while(temp % k)
	{
		temp = temp % k * 10 + 7;
		ans++;
	}
	return ans;
}

int main()
{
	fastIO;
	
	int k;
	cin >> k;
	if(k % 2 == 0 || k % 5 == 0) cout << -1 << endl;
	else cout << div(k) << endl;


	return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {

        Int N;
        cin >> N;

        vector<Int> A(N);
        for (int i = 0; i < N; ++i) cin >> A[i];

        Int tapi = INFl;
        Int ans = 0;

        for (int i = 0; i < N; ++i) {
            if (tapi > A[i]) {
                tapi = A[i];
                ans++;
            }
        }

        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

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

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

  long long int total = 0;
  long long int ans = 0;
  int start = 0;

  for(int i=0;i<n;i++) {
    if(start == n) {
      ans += n - i;
      continue;
    }
    for(int j=start;j<n;j++) {
      if(total + A[j] == (total ^ A[j])) {
        total += A[j];
      } else {
        start = j;
        ans += j - i;
        total -= A[i];
        break;
      }

      if(j == n-1) {
        ans += n - i;
        start = n;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
x,n=map(int,input().split())
p=list(map(int,input().split()))
#p.sort(reverse=True)
r=0
while True:
  if not (x-r in p):
    print(x-r)
    exit()
  if not (x+r in p):
    print(x+r)
    exit()
  r+=1
print(1/0) # RE

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cities(n);
  for (int i; i < m; i++) {
    int a, b;
    cin >> a >> b;
    cities.at(a - 1)++;
    cities.at(b - 1)++;
  }
  for (int i; i < n; i++) { cout << cities.at(i) << endl; }
}

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

int main(){
    int a, b, c, i, d;
    d = 0;
    cin >> a >> b >> c;
    for (i = a; i <= b; ++i){
        if (c % i == 0){
            d = d + 1;
        }
    }
    cout << d << endl;
    return 0;
}



Measured memory_bytes: 3116
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author indy256
 */

#include <bits/stdc++.h>

using namespace std;

void solve(istream &in, ostream &out) {
    string s;
    in >> s;

    int res = 0;
    for (int i = 0; i < s.size() / 2; ++i) {
        if (s[i] != s[s.size() - 1 - i])
            ++res;
    }
    out << res << '\n';
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solve(in, out);
}


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

using namespace std;

int main(){
	std::vector<int> N(3);
	for(int i = 0; i < 3; i++)
		cin >> N[i];
	
	int k;
	cin >> k;

	sort(N.begin(), N.end(), greater<int>());
	int ans = N[0];
	for(int i = 0; i < k; i++){
		ans *= 2;
	}

	cout << ans + N[1] + N[2] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod = MOD) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod = MOD) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int main() {
	fact_inv(512345);
	
	int N, K;
	cin >> N >> K;
	vector<int> v(N);
	REP(i, N) scanf("%d", &v[i]);
	sort(ALL(v));
	
	ll ans = 0;
	for (int i = N - 1; i >= K - 1; i--) {
		// K - 1 個 [0, i)
		ans = (ans + (v[i] % MOD + MOD) % MOD * ncr(i, K - 1) % MOD) % MOD;
	}
	REP(i, N - K + 1) {
		// (i, N-1]
		ans = (ans + (-v[i] % MOD + MOD) % MOD * ncr(N - 1 - i, K - 1) % MOD) % MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 8704
// Author: πα

#include <bits/stdc++.h>
using namespace std;

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long int64_t
const int INF = 1000000007;

const int N = 3005;
int dp[N][N];

int main()
{
    FastIO;
    string s, t, ans;
    cin >> s >> t;
    int n = s.size(), m = t.size(), i, j;
    for(i = 0; i < n; ++i)
        for(j = 0; j < m; ++j)
            dp[i+1][j+1] = max({dp[i+1][j], dp[i][j+1], (s[i] == t[j]) + dp[i][j]});
    while(i and j)
    {
        if(s[i-1] == t[j-1])
            ans += s[i-1], i--, j--;
        else if(dp[i][j-1] > dp[i-1][j])
            j--;
        else
            i--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int x;
    cin >> x;

    int a = 0;
    int b = 0;
    for (int i = -150; i <= 150; i++) {
        for (int j = -150; j <= 150; j++) {
            if (pow(i, 5) - pow(j, 5) == x) {
                a = i;
                b = j;
            }
        }
    }

    cout << a << ' ' << b << '\n';
    return 0;
}


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

using ll = long long;

void solve()
{
    using namespace std;
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ab = a + b;
    int cc = c * 2;
    ll price = 0;

    while (x > 0 || y > 0)
    {
        if (cc < a && x > 0)
        {
            --x;
            --y;
            price += cc;
        }
        else if (cc < b && y > 0)
        {
            --x;
            --y;
            price += cc;
        }
        else if (cc < ab && x > 0 && y > 0)
        {
            --x;
            --y;
            price += cc;
        }
        else if (y > 0)
        {
            --y;
            price += b;
        }
        else if (x > 0)
        {
            --x;
            price += a;
        }
    }

    cout << price << endl;

}

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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  rep(i, 0, 3){
    if(s[i] == 'R'){
      cnt++;
    }
  }
  
  if(cnt == 2 && s[1] == 'S'){
    cnt = 1;
  }
  
  cout << cnt << endl;
  
  return 0;
  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 7;

int main(){
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s; cin >> s;
	for(int i = 0; i < s.size(); ++ i) cout << 'x'; cout << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


string s;

int main(){
	cin >> s;
	
	if(s == "SUN"){
		cout << 7 << endl;
	}
	if(s == "MON"){
		cout << 6 << endl;
	}
	if(s == "TUE"){
		cout << 5 << endl;
	}
	if(s == "WED"){
		cout << 4 << endl;
	}
	if(s == "THU"){
		cout << 3 << endl;
	}
	if(s == "FRI"){
		cout << 2 << endl;
	}
	if(s == "SAT"){
		cout << 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
avr = int(sum(X)/N)
avr1 = avr + 1
cnt = 0
cnt1 = 0
for i in range(N):
    cnt += (X[i] - avr)**2 
    cnt1 += (X[i] - avr1)**2 
print(min(cnt,cnt1))

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (n*a>=b){
      System.out.println(b);
    } else {
      System.out.println(n*a);
    }
  }
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
void sort(int *x,int *y,int *z){
	if(*x>*y)
		swap(x,y);
	if(*y>*z)
		swap(y,z);
	if(*x>*y)
		swap(x,y);
	if(*y>*z)
		swap(y,z);
}
int main(){
	int n=1;
	//scanf("%d",&n);
	while(n--){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		int count=0;
		while((x!=y)+(y!=z)){
			sort(&x,&y,&z);
			if(y-x>=2)
				x=x+2;
			else
				x++,y++;
			count++;
		}
		printf("%d",count);
	}
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <queue>
#include <map>
#include <vector>
using namespace std;

const int N = 1e5+5;
int n, a[N], b[N], ans;

int main(){
	scanf("%d", &n);
	for(int i=0;i<n;++i) scanf("%d", a+i);
	for(int i=n-2;~i;--i) if(a[i]>=a[i+1]) ans = max(ans, b[i] = b[i+1]+1);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main()
{
    int n,i,j;
    scanf("%d",&n);
    int r[200000];
    for(i=0;i<n;i++){
		scanf("%d",&r[i]);
	}
int maxv=r[1]-r[0];
int minv=r[0];

for(j=1;j<n;++j){
	if(maxv<(r[j]-minv)){
		maxv=r[j]-minv;
		}
		else{
		maxv=maxv;
		}
    if(minv>r[j]){
		minv=r[j];
		}
		else{
			minv=minv;
			
			
			
			
}
}
		printf("%d\n",maxv);
		return 0;
}

Measured memory_bytes: 2516
/*ex3_4
  moriai ryo 19B30920*/

#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);
  int ture=0;/*真偽値*/
  int div=1;
  while(div<10){
    if(N%div==0 && N/div<10){ /*割り切れて且つ10以下*/
      ture=1;
    }
    div=div+1;
  }
  if(ture==1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(void)
{
  int h,w;
  int a[502][502],b[502][502];
  int i,j;
  long int t=0;

  scanf("%d %d",&h,&w);
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      scanf("%d",&a[i][j]);
      b[i][j] = a[i][j];
    }
  }

  for(i=1;i<h;i++){
    for(j=1;j<w;j++){
      if(a[i][j]%2==1){
        a[i][j]--;
        a[i][j+1]++;
        t++;
      }
    }
    if(a[i][j]%2==1){   //j == w
      a[i][j]--;
      a[i+1][j]++;
      t++;
    }
  }
  for(j=1;j<w;j++){    //i == h
    if(a[i][j]%2==1){
      a[i][j]--;
      a[i][j+1]++;
      t++;
    }
  }
  printf("%d\n",t);
  for(i=1;i<h;i++){
    for(j=1;j<w;j++){
      if(b[i][j]%2==1){
        b[i][j]--;
        b[i][j+1]++;
        printf("%d %d %d %d\n",i,j,i,j+1);
      }
    }
    if(b[i][j]%2==1){   //j == w
      b[i][j]--;
      b[i+1][j]++;
      printf("%d %d %d %d\n",i,j,i+1,j);
    }
  }
  for(j=1;j<w;j++){    //i == h
    if(b[i][j]%2==1){
      b[i][j]--;
      b[i][j+1]++;
      printf("%d %d %d %d\n",i,j,i,j+1);
    }
  }
  return 0;
}


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

using namespace std;

int main(void) {
    long n, m, l;
    cin >> n >> m >> l;

    vector<vector<long>> d(n, vector<long>(n, 1e15));

    for(int i=0; i<m; i++) {
        long a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        if(c > l) continue;
        d[b][a] = d[a][b] = min(d[a][b], c);
    }

    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    vector<vector<long>> s(n, vector<long>(n, 1e15));
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            if(d[i][j] < 1e15 && d[i][j] <= l)
                s[i][j] = 1;

    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                s[i][j] = min(s[i][j], s[i][k] + s[k][j]);

    long q;
    cin >> q;
    for(int i=0; i<q; i++) {
        long u, t;
        cin >> u >> t;
        u--, t--;
        if(s[u][t] == 1e15)
            cout << -1 << endl;
        else
            cout << s[u][t]-1 << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<PII, int> PI3;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int P;
int n;

void gcd(int a,int b,int &x,int &y) {
  if(b==0){x=1,y=0;return;}
  gcd(b,a%b,y,x),y-=a/b*x;
}
int inv(int n) {
  int x,y;gcd(n,P,x,y);
  if(x<0)x+=P;return x;
}

PI3 norm(PI3 x) {
	((x.fi.fi %= P) += P) %= P;
	((x.fi.se %= P) += P) %= P;
	((x.se %= P) += P) %= P;
	int c;
	if (x.se != 0) {
		c = inv(x.se);
	} else
	if (x.fi.se != 0) {
		c = inv(x.fi.se);
	} else c = inv(x.fi.fi);
	return mp(mp(x.fi.fi*c%P, x.fi.se*c%P), x.se*c%P);
}

map<PI3, int> F;
map<pair<PI3, PI3>, vector<PI3> > G;
#define N 2010
vector<int> A[N];

vector<int> c[N];

int main() {
	P = 37;
	n = P*P+P+1;
	int _ = 0;
	F[mp(mp(1, 0), 0)] = _++;
	for (int a = 0; a < P; a++) {
		F[mp(mp(a, 1), 0)] = _++;
		for (int b = 0; b < P; b++)
			F[mp(mp(a, b), 1)] = _++;
	}
	for (map<PI3, int>::iterator ii = F.begin(); ii != F.end(); ii++) {
		vector<PI3> a;
		for (map<PI3, int>::iterator jj = F.begin(); jj != F.end(); jj ++)  {
			PI3 s = ii->fi;
			PI3 t = jj->fi;
			if ((s.fi.fi*t.fi.fi + s.fi.se*t.fi.se + s.se*t.se)%P == 0) a.pb(t);
		}
		assert ((int) a.size() == P+1);
		sort(a.begin(), a.end());
		G[mp(a[0], a[1])] = a;
	}
	int u = 0;
	for (map<pair<PI3, PI3>, vector<PI3> >::iterator ii = G.begin(); ii != G.end(); ii ++) {
		vector<PI3> S = ii->se;
		assert((int) S.size() == P+1);
		for (int i = 0; i < (int) S.size(); i ++)
			A[F[S[i]]].pb(u);
		u++;
	}
	printf ("%d %d\n", n, P+1);
	for (int i = 0; i < n; i ++) {
		assert((int) A[i].size() == P+1);
		for (int j = 0; j < P+1; j++)
			printf ("%d%c", A[i][j]+1, j == P-1?'\n':' ');
	}
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; std::cin >> N;
  int count = 0;
  char pc = '!';
  for (int i = 0; i < N; ++i) {
    char c; std::cin >> c;
    if (pc != c) {
      ++count;
      pc = c;
    }
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 998244353 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3010

ll dp[SIZE];

int main() {
  int N, S;

  scanf("%d%d", &N, &S);

  dp[0] = 1;

  for (int i = 0; i < N; i++) {
    int A;
    scanf("%d", &A);
    for (int j = S; j >= 0; j--) {
      if (j + A <= S)
        dp[j + A] = (dp[j + A] + dp[j]) % mod;
      dp[j] = dp[j] * 2 % mod;
    }
  }

  printf("%lld\n", dp[S]);

  return 0;
}

Measured memory_bytes: 3824
#include<iostream>
using namespace std;
int main(){
  while(1){
    int n,w,h,x,y,mp[101][101]={},an=0;
    cin>>n;
    if(n==0)break;
    cin>>w>>h;
    for(int i=0;i<n;i++)cin>>x>>y,mp[y][x]=1;
    cin>>x>>y;
    for(int i=1;i<=h-y+1;i++)
      for(int j=1;j<=w-x+1;j++){
	n=0;
	for(int k=i;k<i+y;k++)for(int l=j;l<j+x;l++)n+=mp[k][l];
	if(n>an)an=n;
      }
    cout<<an<<endl; 
  }
  return 0;
}

Measured memory_bytes: 1204
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


lim = 2*10**5   #必要そうな階乗の限界を入力

#階乗#
fact = [1] * (lim+1)
for n in range(1, lim+1):
	fact[n] = n * fact[n-1] % mod

#階乗の逆元#
fact_inv = [1]*(lim+1)
fact_inv[lim] = pow(fact[lim], mod-2, mod)
for n in range(lim, 0, -1):
	fact_inv[n-1] = n*fact_inv[n]%mod

def C(n, r):
	return (fact[n]*fact_inv[r]%mod)*fact_inv[n-r]%mod


H, W, A, B = MAP()

ans = 0
for n in range(B, W):
	way = C(H-A-1+n, n)*C(W-n-1+A-1, A-1)%mod
	ans = (ans+way)%mod

print(ans)



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

using namespace std;

using ll = long long;

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

    ll n, a;
    cin >> n;

    bool all_even = true;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 1) all_even = false;
    }

    if (all_even) cout << "second\n";
    else cout << "first\n";

    return 0;
}


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

void Main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        cout << "x";
    }
    
    cout << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3648
/*input
cupofcoffee
cupofhottea
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;





int main() {
	string a;
	string b;
	cin>>a>>b;
	ll count = 0;
	rep(i,a.length()){
		if(a[i]!=b[i]){
			count++;
		}
	}
	cout<<count<<endl;
}



Measured memory_bytes: 3848
#include <stdio.h>
#include <string.h>

int main(void)
{
	char c[200];
	int ans = 0;
	int len;
	while(scanf("%s", c) != EOF){
		len = strlen(c);
		ans++;
		for(int i = 0; i < len / 2; i++){
			if(c[i] != c[len - i - 1]){
				ans--;
				break;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 968