akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int N;cin>>N;
  vector <int> v(N);
  for(int a;a<N;++a) cin >> v[a];
  sort(v.begin(),v.end(),greater<int>());
  int ans;
  for (int i;i<N;++i){
    if(i&1) ans -= v[i];
    else    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct edge { int to, cap, rev; };
const int MAX_V = 100000;

vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap){
  //printf("add %d -> %d (%d)\n", from, to, cap);
  G[from].push_back((edge){to, cap, G[to].size()});
  G[to].push_back((edge){from, 0, G[from].size()-1});
}
void bfs(int s){
  memset(level, -1, sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v = que.front(); que.pop();
    for(int i = 0; i < G[v].size(); i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

int dfs(int v, int t, int f){
  if(v == t) return f;
  for (int &i = iter[v]; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int Denic(int s, int t){
  int flow = 0;
  while(true){
    bfs(s);
    if(level[t] < 0) break;;
    memset(iter, 0, sizeof(iter));
    int f;
    while((f = dfs(s, t, INF)) > 0){
      flow += f;
    }
  }
  return flow;
}
int main(){
  int N;
  while(cin>>N && N){
    REP(i, MAX_V) G[i].clear();
    int M; cin>>M;
    vector<int> myday;
    REP(i, M){
      int t; cin>>t;
      myday.push_back(t);
    }
    sort(myday.begin(), myday.end());
    REP(i, N){
      int M2;
      cin>>M2;
      while(M2--){
        int t; cin>>t;
        if(binary_search(myday.begin(), myday.end(), t)){
          int idx = lower_bound(myday.begin(), myday.end(), t) - myday.begin();
          add_edge(i, N + idx, 1);
        }
      }
    }
    const int S = N + M;
    const int G = S + 1;
    REP(i, N){
      add_edge(S, i, 1);
    }
    REP(i, M){
      add_edge(N + i, G, 1);
    }
    cout<<Denic(S, G)<<endl;
  }
  return 0;
}

Measured memory_bytes: 4544
X, Y = map(int,input().split())
for crane in range(X + 1):
    for turtle in range(X + 1):
        if (((crane * 2) + (turtle * 4)) == Y) and ((crane + turtle) == X):
            print('Yes')
            flag = 1
            break;
        else:
            flag = 0
    if flag == 1:
        break
if flag == 0:
    print('No')


Measured memory_bytes: 9096
h,w=map(int,input().split())
s=[["#"]*(w+2)]+[["#"]+list(input())+["#"]for i in range(h)]+[["#"]*(w+2)]
p=[[1,1]]
d=0
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==".":
            d+=1
s[1][1]="#"
k=0
while [h,w] not in p:
    k+=1
    g=[]
    for i in range(len(p)):
        x,y=p[i][0],p[i][1]
        if s[x-1][y]==".":
            s[x-1][y]="Q"
            g.append([x-1,y])
        if s[x+1][y]==".":
            s[x+1][y]="Q"
            g.append([x+1,y])
        if s[x][y+1]==".":
            s[x][y+1]="Q"
            g.append([x,y+1])
        if s[x][y-1]==".":
            s[x][y-1]="Q"
            g.append([x,y-1])
    else:
        p=g
        if len(p)==0:
            print(-1)
            break
else:
    print(d-k-1)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
using namespace std;

#define INF 1000000007

int main(){
  long long int N = 0,count = 0;
  cin >> N;
  vector<long long int> box(N);
  for(int i = 0;i < N;i++){
    cin >> box.at(i);
    count += box.at(i);
    count = count % INF;
  }
  //cout << count << endl;
  long long int answer = 0,now = 0;
  for(int i = 0;i < N - 1;i++){
    //cout << box.at(i) << endl;
    count = count - box.at(i);
    if(count < 0){
      count += INF;
    }
    now = box.at(i)*count;
    //cout << a << " " << now << endl;
    answer += now;
    answer = answer % INF;
  }
  cout << answer << endl;
}


Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<int> a(n);
    int k = 0;
    int mi = INF;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        k += a[i];
        k %= 2;
        mi = min(mi, a[i]);
    }
    mi %= 2;
    if(n % 2){
        if(k % 2){
            puts("First");
        }
        else{
            puts("Second");
        }
    }
    else{
        if(mi % 2){
            puts("First");
        }
        else{
            if(k % 2){
                puts("First");
            }
            else{
                puts("Second");
            }
        }
    }
    return 0;
}




Measured memory_bytes: 3632
//https://atcoder.jp/contests/dp/tasks/dp_b
#include<bits/stdc++.h>
using namespace std;
int n,k;
int dp[100001];
int go(int arr[],int x)
{
    if(x==n-1)
        return 0;
    int ans=INT_MAX;
    for(int i=x+1;i<min(n,x+k+1);i++)
    {
        if(dp[i]!=-1)
        {
            ans=min(ans,abs(arr[i]-arr[x])+dp[i]);
        }
        else
        {
            dp[i]= go(arr,i);
            ans=min(ans,abs(arr[i]-arr[x])+dp[i]);
        }
    }
    return ans;
}
int main()
{
    cin>>n>>k;
    int arr[n];
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)cin>>arr[i];
    cout<<go(arr,0)<<'\n';

}


Measured memory_bytes: 8832
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    --n;
    string res;
    while (n >= 0) {
        res.push_back('a' + n % 26);
        n /= 26;
        --n;
    }
    reverse(all(res));
    put(res);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}





Measured memory_bytes: 3128
class WarshallFloyd:
    def __init__(self,V,inf):
        self.V=V
        self.inf=inf
        self.G=[[inf]*V for _ in range(V)]
        for i in range(V):
            self.G[i][i]=0

    def add(self,u,v,cost):
        self.G[u][v]=min(self.G[u][v],cost)

    def shortest_path(self):
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    self.G[i][j]=min(self.G[i][j],self.G[i][k]+self.G[k][j])
        return self.G

    def exist_negative_loop(self):
        for i in range(self.V):
            if self.G[i][i]<0:
                return True
        return False

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    inf=10**9
    n,m=map(int,readline().split())
    wf=WarshallFloyd(n,inf)
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i],c[i]=map(int,readline().split())
        a[i]-=1
        b[i]-=1
        wf.add(a[i],b[i],c[i])
        wf.add(b[i],a[i],c[i])

    li=wf.shortest_path()

    flags=[False]*m
    for i in range(m):
        v=a[i]
        u=b[i]
        w=c[i]
        for j in range(n):
            for k in range(n):
                if li[j][v]+w+li[u][k]==li[j][k]:
                    flags[i]=True

    print(len([i for i in range(m) if flags[i]==False]))

if __name__=="__main__":
    main()

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

int checkPrimeNumber(int n)
{
  bool flag = false;
  for(int i = 2; i <= n/2; ++i)
  {
      if(n%i == 0)
      {
          flag = true;
          break;
      }
  }
  return flag;
}
int fun(int n)
{
  while(checkPrimeNumber(n))
  {
    n++;
  }
  return n;
}
int main()
{
  int n;
  cin>>n;
  cout<<fun(n)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);
//ios::sync_with_stdio(false);
vector<bool> f(100010, false);

vector<ll> dfs(ll s, vector<vector<ll>> &v)
{

    vector<ll> ans(0);
    stack<ll> st;
    st.push(s);

    while (!st.empty())
    {
        ll node = st.top();
        st.pop();

        f.at(node) = true;
        ans.pb(node);

        for (int i = 0; i < siz(v[node]); i++)
        {
            if (!f[v[node].at(i)])
            {
                st.push(v[node].at(i));
                break;
            }
        }
    }

    
    return ans;
}

signed main()
{
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> e(n + 1, vector<ll>(0));
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        e.at(a).pb(b);
        e.at(b).pb(a);
    }

    ll s = 1;
    for (int i = 1; i < n + 1; i++)
    {
        if (siz(e[i]) == 1)
        {
            s = i;
            break;
        }
    }
    vector<ll> x=dfs(s, e),y=dfs(s, e);

    if(siz(y)==1){
        cout<<siz(x)<<endl;
        rep(i,siz(x)){
            cout<<x[i]<<" ";
        }
        cout<<endl;
    }else{
        cout<<siz(x)+siz(y)-1<<endl;
        for(int i=siz(y)-1;0 < i;i--)
        {
            cout<<y[i]<<" ";
        }
        rep(i,siz(x)){
            cout<<x[i]<<" ";
        }
        cout<<endl;
    }
}


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

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int right = c + d;
  int left = a + b;
  if (right == left) {
    cout << "Balanced" << endl;
  } else if (right > left) {
    cout << "Right" << endl;
  } else {
    cout << "Left" << endl;
  }
}


Measured memory_bytes: 3596
def pin(type=int):
  return map(type,input().split())
counter = [0]*4
for i in range(3):
  a,b=pin()
  counter[a-1]+=1
  counter[b-1]+=1
ans=1
for j in counter:
  if j>2 or j<1:
    ans=0
print(["NO","YES"][ans])
    
	

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

int main(){
  int N;
  cin>>N;

  vector<int64_t> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  map<int64_t,int64_t> m;
  for(int i=0;i<N;++i) ++m[A[i]];
  
  int64_t ans=0;
  
  for(auto p:m){
    ans += (p.second*(p.second-1))/2;
  }
  for(int i=0;i<N;++i){
    int64_t sub=ans;
    sub -=  (m[A[i]]*(m[A[i]]-1))/2;
    sub += ((m[A[i]]-1)*(m[A[i]]-2))/2;
    cout<<sub<<endl;
  }

}


Measured memory_bytes: 11008
//
//  main.cpp
//
// g++ -std=c++14 main.cpp
//

//#include "main.hpp"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n, m;
    while (cin >> n >> m) {
        if (n == 0) return 0;
        ll sh[2000] = {}, sw[2000] = {};
        for (int i = 0; i < n; i++) {
            int h;
            cin >> h;
            sh[i + 1] = sh[i] + h;
        }
        for (int i = 0; i < m; i++) {
            int w;
            cin >> w;
            sw[i + 1] = sw[i] + w;
        }
        
        vector<ll> a, b;
        for (int i = 0; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) a.push_back(sh[j] - sh[i]);
        }
        for (int i = 0; i <= m; i++) {
            for (int j = i + 1; j <= m; j++) b.push_back(sw[j] - sw[i]);
        }
        
        sort(a.begin(), a.end());
        sort(b.begin(), b.end());
        
        ll ans = 0;
        ll a_idx = 0, b_idx = 0;
        while (a_idx < a.size() && b_idx < b.size()) {
            if (a[a_idx] < b[b_idx]) a_idx++;
            else if (a[a_idx] > b[b_idx]) b_idx++;
            else {
                ll a_sub = 0, b_sub = 0;
                while (a_idx + a_sub < a.size() && a[a_idx] == a[a_idx + a_sub]) a_sub++;
                while (b_idx + b_sub < b.size() && b[b_idx] == b[b_idx + b_sub]) b_sub++;
                ans += a_sub * b_sub;
                a_idx += a_sub;
                b_idx += b_sub;
            }
        }
        
        cout << ans << endl;
    }
    
}

/*
g++ -std=c++14 main.cpp
*/



Measured memory_bytes: 36924
import java.util.*;

public class Main {

    long INF = Long.MAX_VALUE;
    long[] dp;
    long n;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A= new long[N];
        long f = 0;
        long s = 0;
        int cf = 0;
        int cs = 0;
        for(int i = 0;i< N;i++){
            A[i] = sc.nextLong();
            if(f < A[i]){
                f = A[i];
                cf = i;
            }
        }
        for(int i = 0;i < N;i++){
            if(i == cf){
                continue;
            }
            if(s <= A[i]){
                s = A[i];
            }
        }
        for(int i =0;i < N;i++){
            if(cf == i){
                System.out.println(s);
            }else{
                System.out.println(f);
            }
        }
    }

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


Measured memory_bytes: 108492
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int w,h,m;
int i,j,k;
int x,y,a,b;
int flg=0;
int cnt=0;
void func();
int main(void){
	scanf("%d %d %d",&w,&h,&m);
	scanf("%d %d",&a,&b);
	x=a; 
	y=b;	//ｘが左右　yが上下
	for(k=1;k<=m;k++){
		flg=0;
		//printf("a=%d b=%d\n",a,b);
		scanf("%d %d",&a,&b);
		if(x<a && y<b){	//目標右上の処理
			while(x!=a && y!=b){
				//printf("x=%d y=%d\n",x,y);
				x++; 
				y++;
				cnt++;
				if(x==a || y==b && flg==0){
					func();
				}
			}
		}
		else if(x<a && y>b){ //目標右下
			while(x!=a && y!=b){
				//printf("x=%d y=%d\n",x,y);
				x++;
				cnt++;
				y--;
				cnt++;
				if(x==a || y==b && flg==0){
					func();
				}
			}
		}
		else if(x>a && y<b){	//目標左上
			while(x!=a && y!=b){
				//printf("x=%d y=%d\n",x,y);
				x--;
				cnt++;
				y++;
				cnt++;
				if(x==a || y==b && flg==0){
					func();
				}
			}
		}
		else if(x>a && y>b){	//目標左下
			while(x!=a && y!=b){
				x--;
				y--;
				//printf("x=%d y=%d\n",x,y);
				cnt++;
				if(x==a || y==b && flg==0){
					func();
				}
			}
		}
		else if(x==a || y==b && flg==0){ //同じ行
			func();
		}
		/*printf("x111111=%d y=%d\n",x,y);
		printf("cnt=%d\n",cnt);
		printf("\n");*/
	}
	printf("%d\n",cnt);
	return 0;
}
void func(){
	int temp;
	//printf("x=%d y=%d\n",x,y);
	if(x==a && flg==0){
		temp=y-b;
		//printf("%d\n",temp);
		if(temp<0){
			temp=0-temp;
			y+=temp;
		}
		else {
			y-=temp;
		}
		cnt+=temp;
	}
	else if(y==b && flg==0){
		temp=x-a;
		if(temp<0){
			temp=0-temp;
			x+=temp;
		}
		else {
			x-=temp;
		}
		cnt+=temp;
	}
	flg=1;
}

Measured memory_bytes: 1024
import copy

S = list(input())
K = int(input())

#両端が異なる
def listCount(S,K):
    box = "" #１つ前の文字を格納
    count=0 #f(0):重複ペアをカウント

    for mozi in S:
        if box != mozi:
            box = mozi
        else:
            count += 1
            box=""
            
    return count
  
#両端が同じ全部同じ文字じゃない
def listCount_dash(S,K):
    box =""
    S_origin = copy.deepcopy(S)
    
    #Sの後ろから前まで試行
    for k in range(0,len(S)-1):
        #もし先頭と最後尾が同じならque
        if S[0] == S[len(S)-1]:
            S.append(S[0])
            S.pop(0)
        else:
            break
        
    return listCount(S,K)*(K-1) + listCount(S_origin,K)
  
#両端が全部同じ
def listCount_dou(S,K):
    S_origin = copy.deepcopy(S)
    S.extend(S)
    return listCount(S,K)*int(K/2) + listCount(S_origin,K)*(K%2)
  
flag = 1
box=S[0]
for mozi in S:
    if box != mozi:
        flag = 0
        break
    box = mozi

if flag==0 and S[0] != S[len(S)-1]:
    #両端が異なる場合
    ans = listCount(S, K)*K
elif flag==0:
    #両端が同じ場合
    ans = listCount_dash(S, K)
else:
    #文字が全部同じ
    ans = listCount_dou(S,K)
    
print(ans)

Measured memory_bytes: 38256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        Console.WriteLine(
            Math.Abs(n[0] - n[1]) < Math.Abs(n[0] - n[2]) ?
            "A" : "B");
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,n,x,y;
    scanf("%d", &h);
    scanf("%d", &w);
    scanf("%d", &n);
    if (h<1 || h>100 || w<1 || w>100 || n<1 || n>w*h) {
        printf("Invalid input");
        return 0;
    }
    else {
        priority_queue<int>pq;
        pq.push(h);
        pq.push(w);
        x= pq.top();
        if(n%x==0) {y=n/x;}
        else {y= n/x +1;}
        printf("%d", y);
    }
    return 0;
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::{Bytes, Chars};

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
pub fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        s: Chars,
        t: Chars,
    }
    let mut ans = 0;
    for i in 0..s.len() {
        if s[i] != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3960
n,a,b,k=map(int,input().split())
p=998244353
def getinv(n):
  inv=[0]*(n+1)
  inv[1]=1
  for i in range(2,n+1):
    inv[i]=(-(p//i)*inv[p%i])%p
  return inv
def getnCr(n):
  inv=getinv(n)
  nCr=[0]*(n+1)
  nCr[0]=1
  for i in range(1,n+1):
    nCr[i]=(nCr[i-1]*(n-i+1)*inv[i])%p
  return nCr
def solve(n,a,b,k):
  ans=0
  nCr=getnCr(n)
  for i in range(n+1):
    if (k-a*i)<0 or (k-a*i)%b!=0:
      continue
    j=(k-a*i)//b
    if a*i+b*j==k and 0<=j<=n:
      ans+= nCr[i]*nCr[j]
      ans%=p
  return ans
print(solve(n,a,b,k))

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

const long MAX = 100;
const long INFTY = (1<<21);
const long WHITE = 0;
const long GRAY = 1;
const long BLACK = 2;

long n, M[MAX][MAX];

long prim(){
	long u, minv;
	long d[MAX], p[MAX], color[MAX];

	// d: minimum dist. p: parent

	for (long i = 0; i < n; i++){
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1){
		minv = INFTY;
		// u: node which has minv
		u = -1;
		for (long i = 0; i < n; i++){
			if (minv > d[i] && color[i] != BLACK){
				u = i;
				minv = d[i];
			}
		}
		// cut all nodes
		if (u == -1) break;
		color[u] = BLACK; // already selected
		for (long v = 0; v < n; v++){
			if (color[v] != BLACK && M[u][v] != INFTY){
				if (d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for (long i = 0; i < n; i++){
		if (p[i] != -1) sum += M[i][p[i]];
	}

	return sum;
}

int main(){
	cin >> n;

	for (long i = 0; i < n; i++){
		for (long j = 0; j < n; j++){
			long e;
			cin >> e;
			//M[i][j] = (e == -1) ? INFTY : e;
			if (e == -1) M[i][j] = INFTY;
			else M[i][j] = e;
		}
	}

	cout << prim() << endl;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int fa[N],n,pla[N],m,ans;
int get_fa(int pos) {
  return pos == fa[pos] ? pos : fa[pos] = get_fa(fa[pos]);
}
int main() {
  int x,y;
  scanf("%d%d",&n,&m);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d",&x);
    pla[x] = i;
    fa[i] = i;
  }
  for (int i = 1 ; i <= m ; ++ i) {
    scanf("%d%d",&x,&y);
    x = get_fa(x);
    y = get_fa(y);
    fa[x] = y;
  }
  for (int i = 1 ; i <= n ; ++ i)
    get_fa(i);
  for (int i = 1 ; i <= n ; ++ i)
    if (fa[i] == fa[pla[i]]) ans ++;
  printf("%d\n",ans);
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<long> A(N);
  vector<long> B(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  
  if(N%2==1){
    int x=(N-1)/2;
    cout<<B.at(x)-A.at(x)+1;
  }else{
    int x=N/2-1;
    cout<<B.at(x)+B.at(x+1)-A.at(x)-A.at(x+1)+1;
  }  
}


Measured memory_bytes: 6428
#include<iostream>
using namespace std;
int main() {
    int N,p,a=0;
    cin >> N;
    for(int i=1; i<=N; i++) {
        cin >> p;
        if(p != i) a++;
    }
    cout << (a==0 || a==2 ? "YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let nt = readn::<usize>(" ");
    let n = nt[0];
    let t = nt[1];

    let vt = readn::<usize>(" ");
    let mut ans = 0;

    for i in 1..n {
        if vt[i] - vt[i-1] > t {
            ans += t;
        } else {
            ans += vt[i] - vt[i-1];
        }
    }

    println!("{}", ans + t);
}

Measured memory_bytes: 8444
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N], b[N], c[N], d[N];
    int count = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 0; i < N; i++){
        cin >> c[i] >> d[i];   
    }
    int max_array_size = 2*N;
    int used[max_array_size][max_array_size];
    int init[max_array_size][max_array_size];
    for(int i = 0; i < max_array_size; i++){
        for(int j = 0; j < max_array_size; j++){
            init[i][j] = 0;
            used[i][j] = 0;
        }
    }
    for(int i = 0; i < N; i++){
        init[a[i]][b[i]] = 1; // red
        init[c[i]][d[i]] = 2; // blue
    }


    // look from outside
    bool is_find = false;
    // find blue
    for(int i = 0; i < max_array_size; i++){
        for(int j = 0; j < max_array_size; j++){
            if(init[i][j] == 2){ // found blue
                is_find = false;
                for(int k = j-1; k >= 0; k--){
                    for(int l = i-1; l >= 0; l--){
                        if(init[l][k] == 1 && used[l][k] == 0){
                            count++;
                            used[l][k] = 1;
                            is_find = true;
                            break;
                        }
                    }
                    if(is_find == true){
                        break;
                    }
                }
            } // found blue
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <deque>
#include <queue>
#include <string>
#include <map>
#include <cstring>
#include <stack>
#include <set>
#include <assert.h>
#include <cmath>

using namespace std;
typedef unsigned long long ll;

int main() {
	int n, l;
	cin >> n >> l;

	int sum = 0;

	for(int i = 1; i <= n; i ++){
		sum += l + i - 1;
	}

	int res = sum;

	for(int i = 1; i <= n; i ++){
		if(abs(l+i-1) < abs(res)){
			res = l+i-1;
		}
	}

	cout << sum - res << endl;

    return 0;
}

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

int main() {
	

	string N;
	cin >> N;
	

	int count = 0;

	for (int i = 0; i < N.size(); i++)
	{
		if (atoi(N.substr(i,1).c_str()) ==7)
		{
			count += 1;
		}

	}

	
	if (count == 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}




Measured memory_bytes: 3608
def gcm(a, b)
	if a > b
		a, b = [b, a]
	end
	mod = b % a
	if mod ==0
		return a
	else
		return gcm(mod, a)
	end
end

def lcm(a, b)
	g = gcm(a, b)
	return g * (a / g) * (b / g)
end

N, M = gets.strip.split(/ /).collect{|n| n.to_i}
S = gets.strip.each_char.collect{|c| c.ord}
T = gets.strip.each_char.collect{|c| c.ord}

def check(cm)
	k1 = cm / N
	k2 = cm / M
	
	l = lcm(k1, k2)
	
	d1 = l / k1
	d2 = l / k2

	cm2 = 0
	while cm2 < cm
		if S[cm2 / k1] != T[cm2 / k2]
			return false
		end
		
		cm2 += l
	end
	
	return true
end

nm = N * M
l = lcm(N, M)
if check(l)
	puts l
else
	puts -1
end


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

int main() {
  int n;
  cin >> n;
  int a[22];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 2; i < n; i++) {
    if ((a[i - 2] < a[i - 1]) && (a[i - 1] < a[i])) ans++;
    if ((a[i - 2] > a[i - 1]) && (a[i - 1] > a[i])) ans++;
  }
  cout << ans << endl;
}

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

int main(){
  int n, m, s, g, gg, from, to, cost;
  while(cin >> n >> m >> s >> g >> gg, n){
    s--;g--;gg--;
    vector<vector<int> > graph(n, vector<int>(n, 1e8));
    for(int i = 0; i < m; i++){
      cin >> from >> to >> cost;
      from--;to--;
      graph[from][to] = cost;
    }
    for(int i = 0; i < n; i++) graph[i][i] = 0;
    for(int k = 0; k < n; k++){
      for(int i = 0; i < n; i++){
	for(int j = 0; j < n; j++){
	  graph[i][j] = min(graph[i][k] + graph[k][j], graph[i][j]);
	}
      }
    }
    int ans = 1e9;
    for(int i = 0; i < n; i++){
      ans = min(ans, graph[s][i]+ graph[i][g] + graph[i][gg]);
    }
    cout << ans << endl;
  }
}

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

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    rep(i,h) cin >> c.at(i);

    int ans = 0;
    for (int tmp=0; tmp < (1<<h+w); tmp++) {
      bitset<12> s(tmp);
      int count = 0;
      rep(i,h) {
        if(s.test(i)) {
          rep(j,w) {
            if(s.test(h+j) && c.at(i).at(j) == '#') count++;
          }
        }
      }
      if (count == k) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
from collections import defaultdict

M = 998244353
B = 10**18 % M

def mex(s):
  for i in range(max(s)+2):
    if i not in s:
      return i

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in sorted(e.keys(), reverse=True):
    m = mex({g.get(j,0) for j in e[i]})
    if m:
      g[i] = m
      x = pow(B, i, M)
      sum_g[m] += x
      sum_g[0] -= x
  return sum_g

def get_edge():
  M = int(input())
  e = defaultdict(set)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].add(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, x in sum_g[0].items():
    for gy, y in sum_g[1].items():
      gz = gx^gy
      z = sum_g[2][gz]
      ret = (ret + x*y*z)%M
  return ret

N = int(input())
edge = [get_edge() for i in range(3)]

print(solve(N, edge))

Measured memory_bytes: 72520
while (n=gets.to_i)!=0
  mat=Array.new(n+1){Array.new(n+1,0)}
  n.times.with_index do |id|
    mat[id]=gets.split.map(&:to_i)
    mat[id][n]=mat[id].inject(:+)
    (n+1).times.with_index do |id2|
      mat[n][id2]+=mat[id][id2]
    end
  end
  mat.each do |line|
    line.map!{|ss|ss=format("%5d",ss)}
  end
  mat.each do |line|
    puts line.join
  end
end

Measured memory_bytes: 8836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a,b;
  cin >> a >> b;
  if (a == 'H' && b == 'H') {
    cout << 'H' << endl;
  }
  else if (a == 'D' && b == 'D') {
    cout << 'H' << endl;
  }
  else if (a == 'H' && b == 'D') {
    cout << 'D' << endl;
  }
  else if (a == 'D' && b == 'H') {
    cout << 'D' << endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
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()
{
cin.tie(0);
ios::sync_with_stdio(false);

ll n; cin >> n;
ll now = 10;
ll ans = 0;

if(n % 2 == 0){
    while(now <= n){
        ans += n / now;
        now *= 5;
    }
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	name := ""

	for {
		A := (N - 1) % 26
		N = (N - 1) / 26

		name = fmt.Sprintf("%c%s", 'a'+A, name)

		if N == 0 {
			break
		}

	}

	fmt.Println(name)

}


Measured memory_bytes: 1832
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n[10];
  for(int i = 0; i < 10; i++) cin >> n[i];
  sort( n, n+10, greater<int>());
  cout << n[0] << endl;
  cout << n[1] << endl;
  cout << n[2] << endl;
  return 0;
}

Measured memory_bytes: 1176
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int N, A;
ll dp[51][51][2510];

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

   memset(dp, 0, sizeof(dp));
   dp[0][0][0] = 1;

   for (int i = 0; i < N; i++) {
      for (int k = 0; k <= i; k++) {
         for (int j = 0; j <= A * N; j++) {
            dp[i + 1][k][j] += dp[i][k][j];
            if (j >= x[i]) dp[i + 1][k + 1][j] += dp[i][k][j - x[i]];
         }
      }
   }
   /*
   for (int i = 1; i <= N; i++) {
      for (int j = 0; j <= N * A; j++) {
         cout << i << " " << j << " " << dp[i][i][j] << endl;
      }
   }
   */
   ll ans = 0;
   for (int i = 1; i <= N; i++) ans += dp[N][i][i * A];
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 51200
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int a, b, h, m;
    long double x, c, c_sq;
    const double pi = acos(-1.0);
    
    cin >> a >> b >> h >> m;
    
    x = (2.0 * pi) * (((long double) (h + (m / 60.0)) / 12.0) - (long double) (m / 60.0));
    if (x > pi)
    {
        x = (2 * pi) - x;
    }
    
    c_sq = (long double) ((a * a) + (b * b)) - (long double) ((2.0 * a * b) * cos(x));
    c = sqrt(c_sq);
    
    cout << fixed << setprecision(20) << c;
    
    return 0;
}

Measured memory_bytes: 4140
#include <stdio.h>

int main() {
    
    int i, j;
    
    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++) {
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
    
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  scanf("%d", &n);

  vector<int> v;
  SV(n,v);

  sort(ALL(v), greater<int>());
  int ans = 0, before = INF;
  REP(i,n){
    if(before > v[i]){
      ans++;
      before = v[i];
    }
  }

  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int h[100010];
    int dp[100010];//index番目までの最小コスト
    for(int i = 1; i <= N; i++) cin >> h[i];
    dp[0] = 100000;
    dp[1] = 0;
    
    
    for(int i = 2; i <= N; i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N];
}


Measured memory_bytes: 1024
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd
from itertools import count

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    for i in count(large, large):
        if not i % small:
            lcm = i
            break
    print(gcd(large, small), lcm)

Measured memory_bytes: 5900
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
 
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
 
typedef long long ll;
typedef pair<int, int> PII;
 
const double EPS = 1e-10;
 
int calc(int a, int r) {
  return a*(100 + r)/100;
}
 
int main() {
  int x, y, s;
  int i, j;
  while (1) {
    scanf("%d%d%d ", &x, &y, &s); 
    if (!x && !y && !s) break;
    int res = 0;
    for (i=1; i<s; i++)
      for (j=i; j<s; j++) {
        int z = calc(i,x) + calc(j,x);
        if (z==s) res = max(res, calc(i,y) + calc(j,y));
      }
    printf("%d\n", res);
  }
 
    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;
using P = pair<int, int>;
int main() {
    int n, k;
    cin >> n >> k;
    vector<P> v;
    map<int, int> X, Y, Xi, Yi;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
        X[x]++;
        Y[y]++;
    }
    {
        int p = 0, q = 0;
        for (auto &&t : X) {
            t.second = p++;
            Xi[t.second] = t.first;
        }
        for (auto &&t : Y) {
            t.second = q++;
            Yi[t.second] = t.first;
        }
    }
    vector<vector<int>> v2(n+2, vector<int>(n+2, 0));
    for (auto &&p : v) {
        v2[X[p.first]+1][Y[p.second]+1]++;
    }
    for (int i = 0; i < n+2; ++i) {
        for (int j = 1; j < n+2; ++j) {
            v2[i][j] += v2[i][j-1];
        }
    }
    for (int i = 1; i < n+2; ++i) {
        for (int j = 0; j < n+2; ++j) {
            v2[i][j] += v2[i-1][j];
        }
    }
    ll ans = numeric_limits<ll>::max();
    for (int i = 0; i < n+1; ++i) {
        for (int j = 0; j < n+1; ++j) {
            for (int i2 = i+1; i2 < n+1; ++i2) {
                for (int j2 = j+1; j2 < n+1; ++j2) {
                    if(v2[i2][j2]-v2[i][j2]-v2[i2][j]+v2[i][j] >= k){
                        ans = min(ans, (ll)(Xi[i2-1]-Xi[i])*(Yi[j2-1]-Yi[j]));
                    }
                }
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
main = do
  xs <- getLine
  let x = (words xs) !! 0
  let y = (words xs) !! 1
  let z = (words xs) !! 2
  print $ f (read x) (read y) (read z)

f :: Int -> Int -> Int -> Int
f x y z = (x - z) `div` (y + z)

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define ll long long
#define P pair<ll, ll>
using namespace std;

ll mod = 1e9 + 7;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;

    for(ll i=k;i<=n+1;i++){
        ans += i*(n-i+1) + 1;
        ans %= mod;
    }

    cout << ans << endl;
}

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

int main() {
  int h,w,K;cin>>h>>w>>K;
  vector<string> c(h);
  for(int i=0; i<h; i++) cin>>c[i];
  int ans=0;
  // h,wともに小さい　愚直にやってもよさそう
  // 問題は、行と列を消したときの交点で重ねて数えてしまうことが問題
  // まず行を消すパターンをやった後、列を消すパターンをやる
  // 行消し
  for(int i=0; i<pow(2,h); i++) {
    bitset<6> b(i);
    vector<string> e;
    for(int j=0; j<h; j++) if(b[j]==1) e.push_back(c[j]);
    // 列消し
    for(int k=0; k<pow(2,w); k++) {
      bitset<6> b2(k);
      vector<string> e2=e;
      int count=0;
      for(int l=0; l<w; l++) {
        if(b2[l]==1) {
          for(int m=0; m<(int)e.size(); m++) e2[m][l]='.';
        }
      }
      for(auto v:e2) {
        for(auto elem:v) if(elem=='#') count++;
      }
      if(count == K) ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll t,n,f,i,tog;
    cin>>n;
    string s,a,b;
    cin>>s;
    if(n%2==1)
        cout<<"No";
    else
    {
        a=s.substr(0,n/2);
        b=s.substr(n/2,n/2);
        if(a==b)
            cout<<"Yes";
        else
            cout<<"No";
    }
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int cnt[30];

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

    int N;
    std::cin >> N;

    ++cnt[0];
    for(int i=0;i<N;++i){
        int dt;
        std::cin >> dt;

        ++cnt[dt];
    }

    if(cnt[0] >= 2 || cnt[12] >= 2){
        std::cout << 0 << std::endl;
        return 0;
    }

    int bits = 0;
    vector<int> v;
    
    if(cnt[0] > 0){
        bits |= 1 << 0;
    }
    if(cnt[12] > 0){
        bits |= 1 << 12;
    }
    
    for(int i=1;i<12;++i){
        if(cnt[i] >= 3){
            std::cout << 0 << std::endl;
            return 0;
        }else if(cnt[i] == 2){
            bits |= 1 << i;
            bits |= 1 << (24 - i);
        }else if(cnt[i] == 1){
            v.emplace_back(i);
        }
    }

    int n = v.size(), mx_s = 0;
    
    for(int i=0;i<(1<<n);++i){
        int _bits = bits;
        for(int j=0;j<n;++j){
            if(i >> j & 1){
                _bits |= 1 << v[j];
            }else{
                _bits |= 1 << (24 - v[j]);
            }
        }

        int s = 24;
        for(int j=0;j<24;++j){
            if(!(_bits >> j & 1)){continue;}
            for(int k=j+1;k<24;++k){
                if(!(_bits >> k & 1)){continue;}
                int dt = abs(j - k);
                s = min({s, dt, 24 - dt});
            }
        }

        // for(int j=0;j<24;++j){
        //     std::cout << (_bits >> j & 1);
        // }
        // std::cout << std::endl;

        mx_s = max(mx_s, s);
    }

    std::cout << mx_s << std::endl;
}


Measured memory_bytes: 256
import sys

N, K = map(int, input().split())

H = [int(x) for x in sys.stdin.readlines()]

H.sort()

ans = 10 ** 10
for i in range(K - 1, N):
    left = H[i - (K - 1)]
    right = H[i]
    ans = min(ans, right - left)

print(ans)


Measured memory_bytes: 14228
#include <stdio.h>

int main(void){
	
	int m=1,n=1,dif=0,match=0;
	scanf("%d %d",&n,&m);
	
	dif = n - m;
	char a[n][51], b[m][51];

	for(int i = 0; i < n; i++){
		scanf("%s",a[i]);
	}
	for(int i = 0; i < m; i++){
		scanf("%s",b[i]);
	}
	
	for(int i = 0; i <= dif; i++){
		for(int j = 0; j <= dif; j++){
			for(int k = 0; k < m; k++){
				for(int l = 0; l < m; l++){
					if(a[i+k][j+l] == b[k][l]){ match++;}
					else { match = 0; break;}
					if(match == (m*m)) break;
				}
				if(match == 0 || match == (m*m)) break;
			}
			if(match == (m*m)) break;
		}
		if(match == (m*m)) break;
	}
	
	if(match == (m*m)) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
// https://abc098.contest.atcoder.jp/tasks/abc098_a

function parse(input) {
  return input.trim().split(/\s+/).map((number) => parseInt(number, 10))
}

function f(a, b) {
  const wa = a + b
  const sa = a - b
  const seki = a * b

  var max = wa
  max = sa > max ? sa : max
  max = seki > max ? seki : max

  // return max
  return Math.max(wa, sa, seki)
}

module.exports = {
  parse,
  f,
}

function Main(input) {
  const arr = parse(input)
  const a = arr[0]
  const b = arr[1]

  console.log('%s', f(a, b))
}

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


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

public class Hello
{
    private const long INF = 1000000007;
    public static void Main()
    {
        string s = Console.ReadLine();
        s = s.Substring(0, s.Length - 1);
        int count = 1;
        int ans = 0;
        while (count * 2 < s.Length)
        {
            if (s.Substring(0, count) == s.Substring(count, count)) ans = count * 2;
            //Console.WriteLine(s.Substring(0, count) + " " + s.Substring(count, count));
            count++;
           
        }
        Console.WriteLine(ans);

    }
}

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

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 11092