akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long a,a1,b,b1,c,c1,res=0,flag=0;

    cin>>a>>b>>c;

    while(a%2==0&&b%2==0&&c%2==0)
    {
        a1=(b/2) + (c/2);
        b1=(a/2) + (c/2);
        c1=(a/2) + (b/2);

        a=a1; b=b1; c=c1;
        
        res++;

        if(res>1000000)
        {
            flag=1;
            break;
        }
    }

    if(flag==1)cout<<"-1"<<endl;
    else cout<<res<<endl;
}


Measured memory_bytes: 256
#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() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b*100+0.5;
  a *= ib;
  a /= 100;
  printf("%lld\n", a);
  return 0;
}


Measured memory_bytes: 3780
from collections import deque
H,W=map(int,input().split())
Ch,Cw=map(int,input().split())
Dh,Dw=map(int,input().split())
Ch-=1
Cw-=1
Dh-=1
Dw-=1

S=[]
for i in range(H):
  s=list(input())
  S.append([10**10 if i =="." else -1 for i in s])
visit=[[False for i in range(W)] for j in range(H)]

dq = deque()
dq.append((Ch,Cw,0))
S[Ch][Cw]=0
counter=0

while dq:
  a=dq.popleft()
  if visit[a[0]][a[1]]==True:
    continue
  elif S[a[0]][a[1]]==counter:
    visit[a[0]][a[1]]=True
  elif a[2]==counter+1:
    visit[a[0]][a[1]]=True
    counter+=1
  for i in range(5):
    for j in range(5):
      if a[0]-2+i>=0 and a[0]-2+i<H and a[1]-2+j>=0 and a[1]-2+j<W:
        if abs(i-2)+abs(j-2)==1 and S[a[0]][a[1]]<S[a[0]-2+i][a[1]-2+j] and visit[a[0]-2+i][a[1]-2+j]==False:
          S[a[0]-2+i][a[1]-2+j]=counter
          dq.appendleft((a[0]-2+i,a[1]-2+j,counter))
        elif S[a[0]][a[1]]+1<S[a[0]-2+i][a[1]-2+j] and visit[a[0]-2+i][a[1]-2+j]==False:
          S[a[0]-2+i][a[1]-2+j]=counter+1
          dq.append((a[0]-2+i,a[1]-2+j,counter+1))
  #print(visit,counter,a,dq,"\n")
if S[Dh][Dw]==10**10:
  print(-1)
else:
  print(S[Dh][Dw])

Measured memory_bytes: 109276
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int X = ni();
		int Y = ni();
		int start = Math.min(X, Y);
		int mid = (Y + X)/2;
		int end = Math.max(X, Y);
		int[] ans = new int[N];
//		System.out.println(mid);
		for(int i = 1; i < N; i++) {
			if(i <= start) {
				for(int j = i + 1; j <= mid; j++) {
					ans[j - i]++;
				}
				for(int j = mid + 1; j < end; j++) {
					ans[end - j + 1 + start - i]++;
				}
				for(int j = end; j <= N; j++) {
					ans[j - end + 1 + start - i]++;
				}
			} else if(i > start && i < mid) {

				for(int j = i + 1; j < end; j++) {	
//					System.out.println("i:" +i +  " j:" + j);
//					System.out.println(Math.min(j - i, i - start + 1 + j - end));
					ans[Math.min(j - i, i - start + 1 - j + end)]++;
				}
				for(int j = end; j <= N; j++) {
//					System.out.println("i:" +i +  " j:" + j);
//					System.out.println(j - end + Math.min(i - start + 1, j - i));
					ans[j - end + Math.min(i - start + 1, j - i)]++;
				}
				
			}else {
				for(int j = i + 1; j <= N; j++) {
					ans[j - i]++;
				}
			}
//			System.out.print("i;" + i + "/");
//			Arrays.stream(ans).forEach(v -> System.out.print(v + " "));
//			System.out.println();
		}

		for(int i = 1; i <= N -1; i++) {
			System.out.println(ans[i]);
		}

	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 24848
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")

int main(){

    int n;
    cin >> n;
    vector<int> a(n);

    rep(i, n)cin >> a[i];
    for(int j = 0; j < n-1; j++){
        cout << a[j] << " ";
    }
    cout << a[n-1] << endl;

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

        int v = a[i];

        int j = i-1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }

        a[j+1] = v;

        for(int j = 0; j < n-1; j++){
            cout << a[j] << " ";
        }
        cout << a[n-1] << endl;

    }

}


Measured memory_bytes: 3120
#include <iostream>

using namespace std;

int main (){
  string s;
  cin >> s;
  int answer = 0;

  if(s.at(0) == '1'){
    answer++;
  }
  if(s.at(1) == '1'){
    answer++;
  }
  if(s.at(2) == '1'){
    answer++;
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i;
  	int a,b,c;
  	scanf("%d %d %d",&a,&b,&c);
  	if(a==b)printf("%d",c);
  	if(b==c)printf("%d",a);
  	if(c==a)printf("%d",b);
  	return 0;
  
}

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

int main(){
  int a, b;
  cin >> a >> b;
  rep(i,10100){
    int x=i*8/100, y=i*10/100;
    if(a==x && b==y){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

signed main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> w(n + 1, 0); // wを向いている人
    vector<int> e(n + 1, 0); // eを向いている人
    rep(i, n) {
        if (s[i] == 'W') {
            w[i + 1] = w[i] + 1;
            e[i + 1] = e[i];
        }
        else {
            w[i + 1] = w[i];
            e[i + 1] = e[i] + 1;
        }
    }
    int ans = INF;
    rep(i, n) {
        chmin(ans,w[i] - w[0] + e[n] - e[i + 1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
n, k = map(int, input().split())
a = list(map(int, input().split()))

t = [[] for _ in range(n)]
u = 0
for i in range(k + 1):
    t[u].append(i)
    if len(t[a[u] - 1]) == 2:
        break
    else:
       u = a[u] - 1
ans = 0
for i in range(n):
    if len(t[i]) == 2 and (k - t[i][1]) % (t[i][1] - t[i][0]) == 0:
        ans = i + 1
        break
    elif len(t[i]) == 1 and t[i][0] == k:
        ans = i + 1
        break
print(ans)

Measured memory_bytes: 116068
N,M,X = gets.split.map(&:to_i)
A = N.times.inject([]) {|a,i| a[i] = gets.split.map(&:to_i); a }.transpose

ans = Float::INFINITY

(0..(2**N-1)).each do |i|
  s = ("%0#{N}b" % i).chars
  cost,*a = A.map{|a| s.map.with_index{|x,i| x == "1" ? a[i] : 0}.sum}
  ans = [ans, cost].min if a.all?{|x| x >= X}
end

ans = -1 if ans == Float::INFINITY
puts ans

Measured memory_bytes: 14428
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    if(c <= a - b) {
        out(0);
    }
    else {
        out(c - (a- b));
    }
    
    re0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int n,a[maxn];
ll cnt[maxn];


int main()
{
	fastIO;
	cin >> n;
	rep(i,0,n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	ll ans = 0;
	rep(i,1,n + 1){
		ans += cnt[i] * (cnt[i] - 1) / 2;
	}
	rep(i,0,n){
		ans -= cnt[a[i]] - 1;
		cout << ans << endl;
		ans += cnt[a[i]] - 1;
	}
	return 0;
}

Measured memory_bytes: 3968
s = input()

s1, s2 = int(s[:2]), int(s[2:])

if 1 <= s1 <= 12:
    if 1 <= s2 <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= s2 <= 12:
        print("YYMM")
    else:
        print("NA")



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

int main()
{
	const long long nil = -2000000001;
	int h = 0;

	cin >> h;

	vector<long long> t(h, nil), p(h, nil), l(h, nil), r(h, nil);

	for (int i = 0; i < h; i++)
		cin >> t[i];

	for (int i = 1; i < h; i++)
		p[i] = t[(i + 1) / 2 - 1];
	for (int i = 0; i < h / 2; i++)
		l[i] = t[2 * i + 1];
	for (int i = 0; i < (h - 1) / 2; i++)
		r[i] = t[2 * i + 2];

	for (int i = 0; i < h; i++) {
		cout << "node " << i + 1 << ": key = " << t[i] << ", ";

		if (p[i] != nil)
			cout << "parent key = " << p[i] << ", ";
		if (l[i] != nil)
			cout << "left key = " << l[i] << ", ";
		if (r[i] != nil)
			cout << "right key = " << r[i] << ", ";
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T, typename Can> T bsearch(T L, T R, Can&& can, bool left_feasible = true) {
    static_assert(is_convertible<decltype(can), function<bool(T)>>::value, "can must be bool(T)");
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = L + (R - L) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
const ll LIM = 3e10 + 1;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    cin >> a >> b >> c;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    priority_queue<tuple<ll, int, int, int>> pq({}, {make_tuple(a[x-1] + b[y-1] + c[z-1], x-1, y-1, z-1)});
    set<tuple<int, int, int>> visited({make_tuple(x - 1, y - 1, z - 1)});
    for(int i = 1; i <= k; i++) {
        ll s;
        int ai, bi, ci;
        tie(s, ai, bi, ci) = pq.top();
        pq.pop();
        cout << s << endl;
        if(ai > 0 and not visited.count(make_tuple(ai - 1, bi, ci))) {
            pq.push(make_tuple(a[ai-1] + b[bi] + c[ci], ai-1, bi, ci));
            visited.insert(make_tuple(ai - 1, bi, ci));
        }
        if(bi > 0 and not visited.count(make_tuple(ai, bi - 1, ci))) {
            pq.push(make_tuple(a[ai] + b[bi-1] + c[ci], ai, bi-1, ci));
            visited.insert(make_tuple(ai, bi - 1, ci));
        }
        if(ci > 0 and not visited.count(make_tuple(ai, bi, ci - 1))) {
            pq.push(make_tuple(a[ai] + b[bi] + c[ci-1], ai, bi, ci-1));
            visited.insert(make_tuple(ai, bi, ci - 1));
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
int main(){
	int n,i;
	double m=100.0;
	cin>>n;
	for(i=0;i<n;i++){
		m*=1.05;
		if(m-(int)m>0.0){
			m+=1.0;
			m=(int)m;
		}
	}
	cout<<m<<"000"<<endl;
	return 0;
}

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

int main(){
    std::string str;

    std::cin>>str;
    while(true){
        if(str=="0"){
            break;
        }
        int i,sum=0;
        for(i=0;i<str.size();i++){
            sum+=str[i]-0x30;
        }
    std::cout<<sum<<std::endl;
    std::cin>>str;
    }
    return 0;
}


Measured memory_bytes: 3192
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int 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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll a = 100.0;
	int ans = 0;
	while(a < x){
		a = a + a/100;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3648
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: Usize1,
        mut h: [i64; n],
    };
    h.sort();
    let mut ans = 1_000_000_000_i64;
    for i in k..n {
        let h_max = h[i];
        let h_min = h[i - k];
        ans = std::cmp::min(ans, h_max - h_min);
    }
    println!("{}", ans);
}


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

using namespace std;

#define vi vector<int>
#define pb push_back
#define ll long long
#define qi queue<int>
#define vll vector<long long>
#define si set<int>
#define mi map<int,int>
#define mod %
#define pow ^
#define frt(i,a,b) for(int i=a;i<b;i++)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define pair_int pair<int,int>
#define pair_ll pair<ll,ll>
#define pq priority_queue
#define N 200007


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

   int n, mx;
   cin >> n >> mx;
   int w[n+1];
   ll c[n+1];

   for (int i = 0; i < n; ++i)
   {
   	   cin >> w[i+1];
   	   cin >> c[i+1];
   }

   ll dp[mx+3];

   frt(i,0,mx+1)
   	dp[i] = 0;

   dp[0] = 1;
   for(int i=1;i<=n;i++)
   {
   		for(int j=mx;j>=w[i];j--)
   		{

   			if(dp[j-w[i]]!=0 && dp[j]==0)
   				dp[j] = (j!=w[i])*dp[j-w[i]] + c[i];
   			
   			else if(dp[j]!=0)
   			{
   				dp[j] = max(dp[j], (j!=w[i])*dp[j-w[i]] + c[i]);
   			}
   		}
   		// for(int ii=0;ii<17-1;ii++)
   		// 	cout << dp[ii] << " ";
   		// cout << endl;
   }
   	
   	ll ans = -1; 
   for(int i=1;i<=mx;i++)
   {
   		ans = max(ans,dp[i]);
   }
   cout << ans << endl;	
   return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n,k,t;
char c[100010];
int main(){
	scanf("%d%d%s",&n,&k,c+1);
	for(int i=2;i<=n;++i)t+=c[i]!=c[i-1];
	printf("%d",n-1-max(0,t-(k<<1)));
	return 0;
}

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

int main(){
	string S,ans="yes";
	cin >> S;
	for (int i = 0; i < S.size(); i++){
		for (int j = i + 1; j < S.size(); j++){
			if (S[i] ==S[j]){
				ans = "no";
			}
			
		}
	
	}
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

struct Event
{
    ll time, weight;
    bool operator<(const Event &a) const
    {
        return time < a.time; 
    }

    bool operator>(const Event &a) const
    {
        return time > a.time;
    }

    bool operator==(const Event &a) const
    {
        return time == a.time;
    }    
};



int main()
{
    int n;
    while(cin >> n && n) {
        priority_queue<Event, vector<Event>, greater<Event> > que;
        ll a, b, m;
        for(int i = 0; i < n; i++) {
            cin >> m >> a >> b;
            que.push((Event){a * 2, +m});
            que.push((Event){b * 2 - 1, -m});
        }

        bool flag = true;
        ll sum = 0;
        while(!que.empty()) {
            Event e = que.top(); que.pop();
            sum += e.weight;
            if(sum > 150)
                flag = false;
        }
        if(flag)
            cout << "OK" << endl;
        else 
            cout << "NG" << endl;
    }
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	int n;
	int u, k, v;
	int gra[101][101] = {};

	cin >> n;
	
	FOR(i, 1, n) {
		cin >> u >> k;
		FOR(t, 1, k) {
			cin >> v;
			gra[u][v] = 1;
		}
	}
	FOR(i, 1, n) {
		FOR(t, 1, n) {
			cout << gra[i][t];
			if (t != n) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3124
n = int(input())
h_list = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(n-1):
    if h_list[i] >= h_list[i+1]:
        cnt += 1
    if h_list[i] < h_list[i+1] or i == n-2:
        if cnt > ans:
            ans = cnt
        cnt = 0

print(ans)

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

int n;

int main(){
    cin >> n;
    int div = 0;
    int buf = n;
    while(buf != 0){
        div = div + buf % 10;
        buf = buf / 10;
    }
    if(n % div == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#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)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    ll n;
    cin >> n;
    vector<pll> xy;
    ll pmin = LLONG_MAX, pmax = LLONG_MIN, mmin = LLONG_MAX, mmax = LLONG_MIN;
    REP(i,n) {
        ll x, y;
        cin >> x >> y;
        xy.push_back(make_pair(x,y));
        pmin = min(pmin, x+y);
        pmax = max(pmax, x+y);
        mmin = min(mmin, x-y);
        mmax = max(mmax, x-y);
    }
    ll ans = abs(xy[0].first - xy[1].first) + abs(xy[0].second - xy[1].second);
    int pminidx = -1, pmaxidx= -1, mminidx = -1, mmaxidx = -1;
    REP(i, n) {
        ll x,y;
        x = xy[i].first, y = xy[i].second;
        if (pmin == x + y) {
            pminidx = i;
        }
        if (pmax == x + y) {
            pmaxidx = i;
        }
        if (mmin == x - y) {
            mminidx = i;
        }
        if (mmax == x - y) {
            mmaxidx = i;
        }
    }
    /* cout << pminidx << " " << pmaxidx << " " << mminidx << " " << mmaxidx << endl; */
    int idx = pminidx;
    REP(i,n) {
        if (i == idx) continue;
        ans = max(ans, abs(xy[i].first - xy[idx].first) + abs(xy[i].second - xy[idx].second));
    }
    idx = pmaxidx;
    REP(i,n) {
        if (i == idx) continue;
        ans = max(ans, abs(xy[i].first - xy[idx].first) + abs(xy[i].second - xy[idx].second));
    }
    idx = mminidx;
    REP(i,n) {
        if (i == idx) continue;
        ans = max(ans, abs(xy[i].first - xy[idx].first) + abs(xy[i].second - xy[idx].second));
    }
    idx = mmaxidx;
    REP(i,n) {
        if (i == idx) continue;
        ans = max(ans, abs(xy[i].first - xy[idx].first) + abs(xy[i].second - xy[idx].second));
    }
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 7464
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#define _GLIBCXX_DEBUG//.at(i)を[i]と書いても許される
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
int n;
int main(){
	cin >> n;
	vector<int> A(n);
	vector<int> B;
	rep(i,n){
		cin>>A.at(i);
	}
	for(int i=0;n-2*i-1>=0;i++){
		int a =A.at(n-2*i-1);
		B.push_back(a);
	}
	if(n%2==0){
	for(int i=0;2*i<n;i++){
		int b = A.at(2*i);
		B.push_back(A[2*i]);
	}
	}
	else{
		for (int i = 0; 2*i+1<n; i++){
			int b = A.at(2*i+1);
			B.push_back(b);
		}
	}
	for(int x : B){
		cout<<x<<" ";
	}
}

Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int arr[105];
	int n,count=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}
	for (int i = 0; i < n; i++)
	{
		int minj = i;
		for (int j = i; j < n; j++)
		{
			if (arr[j] < arr[minj])
			{
				minj = j;
			}
		}
		swap(arr[i], arr[minj]);
		if (i != minj)
		{
			count++;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (i > 0)
		{
			cout << " ";
		}
		cout << arr[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 10000000007
#define ff first
#define ss second
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    IOS
    int n;
    cin>>n;
    map<vector<int>,int> hs;
    lli ans = 0;
    for(int i=1;i<=n;i++)
    {
    	string s;
    	cin>>s;
    	vector<int> temp(26,0);
    	for(int i=0;i<s.size();i++) {
    		temp[s[i]-'a']++;
    	}
    	ans = ans + hs[temp];
    	hs[temp]++;
    }
    cout<<ans;
    return 0;
}




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

bool prime(int n)
{
    for(int i=2;i<n;i++)
        if(n%i==0)
            return false;
    return true;
}
int main(void)
{
    int x,i;
    cin >> x;
    for(i=x;prime(i)!=true;i++){
        continue;
    }
    cout << i;
    return 0;
}

Measured memory_bytes: 256
#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<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
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 long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int a, b, c, d; cin >> a >> b >> c >> d; cout << max(a*b, c*d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
using namespace std;

//long long A[100000];
//int stand_bit_num[40];

//int t[1000000];
//long long d[100000];

int x[100];
int y[100];

int main(){
   int K;
   int S;
   cin >> K >> S;

   int ans = 0;
   for(int x = 0; x <= K; x++){
       for(int y = 0; y <= K; y++){
           if(0 <= S - x - y && S - x - y <= K){
               ans += 1;
           }
       }
   }
   cout << ans << endl;
}

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

int main() {
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    int dp[n+1][m+1] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            } else {
                dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
            }
        }
    }
    string ans = "";
    while (n > 0 && m > 0) {
        if (dp[n][m] == dp[n-1][m]) {
            n--;
        }
        else if (dp[n][m] == dp[n][m-1]) {
            m--;
        }
        else {
            ans = s[n-1] + ans;
            n--, m--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 35456
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1e9 + 100;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 1e5 + 100;
int n;
char s[maxn];

bool read() {
  if (scanf("%s", s) < 1) {
    return false;
  }
  return true;
}

void solve() {
  bool c = false;
  bool ok = false;
  for (int i = 0; s[i]; i++) {
    if (s[i] == 'C') {
      c = true;
    }
    if (c && s[i] == 'F') {
      ok = true;
      break;
    }
  }
  printf(ok ? "Yes\n" : "No\n");
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time: %.18f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

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

using namespace std;

long long a[100001];
long long d[100001][5];

int main () {
	int n, p;
	cin >> n >> p;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		a[i] %= 2;
	}
	d[0][0] = 1;
	for (int i = 0;i < n;i ++) {
		for (int j = 0;j <= 1;j ++) {
			d[i + 1][j] += d[i][j];
			d[i + 1][(j + a[i + 1]) % 2] += d[i][j];
		}
	}        
	cout << d[n][p];
	return 0;
}

Measured memory_bytes: 2304
n, k = gets.split.map(&:to_i)
ans = []
part1 = [1]
part2 = [(n - k + 1)]
k.times do |i|
  if i <= (n - k)
    a = part1[i] * part2[i]
    ans << a % 1000000007
    part1 << part1[i]*(k - i - 1)/(i + 1)
    part2 << part2[i]*(n - k - i)/(i + 2)
  else
    ans << 0
  end
end
puts ans

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-b) <= d && abs(b-c) <= d)|| abs(a-c) <= d) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define VMAX 100000


int main(){

  int i,j,n,C[VMAX+1];

  scanf("%d",&n);
  
  short *A,*B;

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);


  for(i=1;i<n+1;i++)scanf("%d",&A[i]);
  
  for(i=0;i<=VMAX;i++)C[i]=0;
  
  for(j=1;j<=n;j++)C[A[j]]++;

  for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  
  for(i=1;i<n;i++)printf("%d ",B[i]);
  printf("%d\n",B[n]);
  return 0;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
int main() {
	std::string s; std::cin >> s; int answ(0);
  for (int i = 0, j = (int)s.size()-1; i <= j; i++,j--)
    answ += s[i] != s[j];
  std::cout << answ << std::endl;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s;
int N = 0;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int x;
  cin >> x >> a;
  ans = x-a;
  if(ans <0)pr(0);
  else pr(ans );
  return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    ll ans = 0;
    rep(i,n){
        ll h; cin>>h;
        if(h>=k)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

class Main
{
    public static void main(String[] args)
    {
	Scanner sc = new Scanner(System.in);
	int timeSec = sc.nextInt();
	
	int timeHour = timeSec / 3600;
	timeSec %= 3600;
	
	int timeMin = timeSec / 60;
	timeSec %= 60;
	
	System.out.println(timeHour + ":" + timeMin + ":" + timeSec);
    }
}

Measured memory_bytes: 26068
# -*- coding: utf-8 -*-
S = input()
list_amari = [0 for i in range(2019)]
amari_prev = 0
X = 1

for i in range(len(S)):
  amari = (int(S[-i-1])*X+amari_prev)%2019
  list_amari[amari] += 1
  amari_prev = amari
  X = (10*X)%2019

count = list_amari[0]
for v in list_amari:
  count += v*(v-1)//2

print(count)

Measured memory_bytes: 9120
use std::io::*;
use std::str::FromStr;
use std::cmp::*;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
fn main() {
    let n: usize = read();
    let mut ans = 1000;
    for _ in 0..n {
        let mut a: i32 = read();
        let mut lans = 0;
        while a % 2 == 0 { a /= 2; lans += 1; }
        ans = min(ans, lans)
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
string s;
int main()
{
    cin>>s;
    for(int i=0;i<=s.size()-1;i++)
    {
    	if(i%2==0) cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
S = input()

L = []
s = 0
u = 0

for i in range(len(S)-1):
  if S[i] != S[i+1]:
    L.append(i+1-u)
    u = i+1
L.append(len(S)-u)

if S[0] == '<':
  if len(L) % 2 == 1:
    L.append(0)
  for j in range(len(L) // 2):
    M = max(L[2*j], L[2*j+1])
    m = min(L[2*j], L[2*j+1])
    s += (M * (M + 1)) // 2 + (m * (m-1)) // 2
elif S[0] == '>':
  s += (L[0] * (L[0] + 1)) // 2
  del L[0]
  if len(L) % 2 == 1:
    L.append(0)
  for j in range(len(L) // 2):
    M = max(L[2*j], L[2*j+1])
    m = min(L[2*j], L[2*j+1])
    s += (M * (M + 1)) // 2 + (m * (m-1)) // 2
    
print(s)

Measured memory_bytes: 6300
#include <stdio.h>
#include <stdlib.h>

#define NUM 3
int main (void){
  int box[NUM]={0};
  int temp=0;
  int sum=0;

  int i,j;
  
  for(i=0; i<NUM; i++){
    scanf("%d",&box[i]);
  }
    
  for(i=0; i<NUM-1; i++){
    for(j=i+1;j<NUM; j++){
      if ( box[i] < box[j]){
  	temp = box[i];
  	box[i] = box[j];
  	box[j] = temp;
      }
    }
  }

  sum += box[0]*10+box[1]+box[2];
  printf("%d\n",sum);
 
  
  return 0;
  
}


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

int main() {
  int n,d,x;
  cin>>n>>d>>x;
  int answer=x,p;
  
  for(int i=0;i<n;i++){
    cin>>p;
    answer+=1+(d-1)/p;
  }
  cout<<answer<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#define MAX 100000
using namespace std;

struct Queue{
    int head;
    int tail;
    int q[MAX];

    void initialize(){
        head = 0;
        tail = 0;
    }
    bool isEmpty(){
        return (head == tail);
    }
    bool isFull(){
        return (head == (tail+1)%MAX);
    }
    void enqueue(int x){
        if(isFull()){
            cout << "queue overflow\n";
            //exit(0);
        }
        q[tail] = x;
        if(tail == MAX-1){
            tail = 0;
        }
        else{
            tail += 1;
        }
    }
    int dequeue(){
        if(isEmpty()){
            cout << "queue underflow\n";
            //exit(0);
        }
        int x = q[head];
        if(head == MAX-1){
            head = 0;
        }
        else{
            head += 1;
        }
        return x;
    }
};

void calc(Queue q_name, string name[], Queue q_time, int quantum){
    int t_sum = 0;
    while(q_name.head != q_name.tail){
        if(q_time.q[q_time.head] <= quantum){
            t_sum += q_time.dequeue();
            cout << name[q_name.dequeue()] << " " << t_sum << '\n';
        }
        else{
            t_sum += quantum;
            q_name.enqueue(q_name.q[q_name.head]);
            q_time.enqueue(q_time.q[q_time.head]-quantum);

            if(q_name.head == MAX-1){
                q_name.head = 0;
                q_time.head = 0;
            }
            else{
                q_name.head += 1;
                q_time.head += 1;
            }
        }
    }
}

int main(){
    Queue q_name, q_time;
    int num, quantum;
    string name[MAX];
    int t;

    q_name.initialize();
    q_time.initialize();

    cin >> num >> quantum;
    for(int i=0; i<num; i++){
        cin >> name[i] >> t;
        q_name.enqueue(i);
        q_time.enqueue(t);
    }

    calc(q_name, name, q_time, quantum);

    return 0;
}


Measured memory_bytes: 7436
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


const int N = 1e4 + 100;

ll A[N];


map<int , int> mx;

const int mod = 1e9 + 7;
ll power(ll a , ll b){
	ll res = 1;
	while(b){
		if(b&1){
			res = res*a%mod;
		}
		a = a*a%mod;
		b >>= 1;
	}
	return res;
}

int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n; cin >> n;
	for(int i = 1;i <= n; ++i){
		cin >> A[i];
	}
	for(int i = 2;i <= n ; ++i){
		int gc = __gcd(A[1] , A[i]);
		int den = A[i]/gc;
		int t = den;

		for(int j = 2;j*j <= t ; ++j){
			int cnt = 0;
			while(t%j == 0){
				t /= j;
				++cnt;
			}
			mx[j] = max(mx[j] , cnt);
		}
		// trace(t);
		if(t > 1){
			mx[t] = max(mx[t] , 1);
		}
	}
	ll b = 1;
	for(auto it : mx){
		b = b*power(it.F , it.S);
		b %= mod;
	}
	ll ans = 0;
	for(int i = 2;i <= n ; ++i){
		ans = ans + power(A[i] , mod-2);
		if(ans >= mod)
			ans -= mod;
	}
	cout << (b + b*A[1]%mod*ans%mod)%mod << endl;











	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>


//return the num of combination of
//four integers, whose sum is just input
int count_comb(int input)
{
    int a,b,c,d;
    int cnt=0;
    for(a=0;a<=9;a++){
        for(b=0;b<=9;b++){
            for(c=0;c<=9;c++){
                for(d=0;d<=9;d++){
                   int sum=a+b+c+d;
                   if(sum==input){
                       cnt++;
                       break;
                   }
                   else if(sum>input){
                       break;
                   }
                }
            }
        }
    }
    return cnt;
}



int main(void)
{
//#define __DEBUG__
#ifdef __DEBUG__
    FILE *fin=fopen("input.txt","r");
    FILE *fout=fopen("output.txt","w");
#else
    FILE *fin=stdin;
    FILE *fout=stdout;
#endif
    while(feof(fin)==0){
        int input;
        fscanf(fin,"%d\n",&input);
        fprintf(fout,"%d\n",count_comb(input));
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
  string line;
  getline(cin, line);

  ll hist[26] = {};
  for (char ch : line)
  {
	hist[ch - 'a']++;
  }

  ll ans = 1;
  for (char ch : line)
  {
	hist[ch - 'a']--;
	for (char c = 'a'; c <= 'z'; c++)
	{
	  if (ch != c)
	  {
		ans += hist[c - 'a'];
	  }
	}
  }
  cout << ans << endl;
}


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

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

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

int main() {
	string S; cin >> S;
	string T="YAKI";
	bool torichan=true;
	if(S.size()<4) torichan=false;
	else{
	    for(int i=0; i<4; ++i){
	        if(S[i]!=T[i]){
	            torichan=false;
	            break;
	        }
	    }
	}
	if(torichan) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

using int64 = long long;

struct Query {
  int i1, i2;
};

constexpr int64 P = 1000000007;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {
    if (x > P || x < 0) { cerr << "Invalied FiniteField!" << endl; exit(1); }
  }
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

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

  int n, num_queries;
  cin >> n >> num_queries;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];

  FiniteField total = 1;
  for (int i = 0; i < num_queries; i++) total *= 2;

  auto dp = Make2DVector<FiniteField>(n, n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (xs[i] > xs[j]) {
        dp[i][j] = total;
      }
    }
  }

  auto half = FiniteField(1) / 2;
  for (int i = 0; i < num_queries; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    for (int k = 0; k < n; k++) {
      if (k == x || k == y) continue;
      dp[x][k] = dp[y][k] = (dp[x][k] + dp[y][k]) * half;
      dp[k][x] = dp[k][y] = (dp[k][x] + dp[k][y]) * half;
    }
    dp[x][y] = dp[y][x] = (dp[x][y] + dp[y][x]) * half;
  }

  FiniteField solution = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      solution += dp[i][j];
    }
  }
  cout << solution.Value() << endl;
}

Measured memory_bytes: 72832
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as BS
import Data.Array.Unboxed
import Data.Array.ST
import Control.Monad.ST
import Control.Monad.State.Strict

asSTUArray :: ST s (STUArray s i a) -> ST s (STUArray s i a)
asSTUArray = id

main = do
  [h,w] <- map (read . BS.unpack) . BS.words <$> BS.getLine
  -- 1 <= h <= 1000, 1 <= w <= 1000
  initialState <- V.replicateM h BS.getLine
  -- for all (i, j), ((a ! i) `BS.index` j) `elem` "#."
  let answer :: Int
      answer = runST $ do
        arr <- asSTUArray $ newArray ((0,0),(h-1,w-1)) False
        let initCells :: [(Int,Int)]
            initCells = [(i,j) | i <- [0..h-1], j <- [0..w-1], (initialState V.! i) `BS.index` j == '#']
        forM_ initCells $ \p ->
          writeArray arr p True
        let -- loop :: Int -> [(Int,Int)] -> m Int
            loop !k xs = do
              ys <- flip execStateT [] $ do
                let doCell p@(!i,!j) | 0 <= i && i < h && 0 <= j && j < w = do
                                         b <- lift $ readArray arr p
                                         when (not b) $ do
                                           lift $ writeArray arr p True
                                           modify' (p :)
                                     | otherwise = return ()
                forM_ xs $ \(i,j) -> do
                  doCell (i-1,j)
                  doCell (i+1,j)
                  doCell (i,j-1)
                  doCell (i,j+1)
              case ys of
                [] -> return k
                _ -> loop (k+1) ys
        loop 0 initCells
  print answer


Measured memory_bytes: 86396
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 1e9 + 7;

const ll INF = 0x7fffffffffffffff;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

// One solution of Ax+By=D
// D=da, x'=xa, y'=ya
// |xb|=A/D, |yb|=B/D
// x=xa+(k*yb), y=ya-(k*xb)

ll da,db,dt,xa,xb,xt,ya,yb,yt;
void egcd() {
    xa=yb=1, xb=ya=0;
    while (db) {
        ll tt = da/db;
        dt = da-tt*db, xt = xa-tt*xb, yt = ya-tt*yb;
        da=db, db=dt, xa=xb, xb=xt, ya=yb, yb=yt;
    }
    xb=abs(xb), yb=abs(yb);
}

int main() {
    ll n;
    scanf("%lld", &n);

    if (n==1) return !printf("1");

    int flag = 0;
    ll t = n;
    for (ll i = 2; i*i <= t; i++) {
        int cnt = 0;
        while (t%i==0) {
            t /= i;
            cnt++;
        }
        if (cnt) flag++;
    }
    if (t>1) flag++;
    if (flag == 1) return !printf("%lld", n-1);

    ll ans = n-1;
    t = n;
    t*=2;

    for (ll i = 2; i*i <= t; i++) {
        if (t%i==0) {
            ll op = t/i;
            if (gcd(i, op) != 1) continue;

            // printf("%lld %lld\n", i, op);
            da = i, db = op;
            egcd();
            // printf("%lld %lld : %lld %lld : %lld %lld %lld\n", i, op, xa, ya, xa*i, ya*op, i*xa+op*ya);

            if (xa > 0) {
                if (xa - 1 <= INF / i) {
                    ans = min(ans, xa * i - 1);
                }
            }
            else {
                if (ya - 1 <= INF / op) {
                    // printf("%lld %lld : %lld %lld : %lld\n", i, op, xa, ya, i*xa+op*ya);
                    ans = min(ans, ya * op - 1);
                }
            }
        }
    }

    printf("%lld", ans);

    // printf("%lld %lld\n", xa, ya);

    /*
    int cnt = 0;
    for (int i = 1; i <= 10000000 && cnt <= 10; i++) {
        ll t = n * i;

        ll le = 1, ri = 1e9, mid;
        while (le <= ri) {
            mid = (le+ri)/2;
            ll tt = mid*(mid+1)/2;
            if (t > tt) le = mid + 1;
            else ri = mid - 1;
        }

        ll kk = le*(le+1)/2;
        if (kk == t) printf("%lld : %lld %lld\n", le, kk, t), cnt++;

        // x*(x+1)=t
        // x^2+x=t
        // x^2=t-x
    }
     */

}


// author: rdd6584


Measured memory_bytes: 3700