akhauriyash/Code-Regression huggingface dataset:
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static private int sample = 0;
	static private InputStream in;
	static private PrintStream out;
	static private Scanner sc;
	static {
		if(sample == 0) {
			in = System.in;
			out = System.out;
		}else {
			try {
				in = new FileInputStream(new File("sample"+sample));
				out = new PrintStream("result"+sample);
			} catch (Exception e) {
				e.printStackTrace();
				System.exit(1);
			}
		}
		sc = new Scanner(in);
	}
	static public boolean fileCompare2(String fileA, String fileB) {
	    boolean bRet = false;
	    try {
	        bRet = Arrays.equals(Files.readAllBytes(Paths.get(fileA)), Files.readAllBytes(Paths.get(fileB)));
	    } catch (IOException e) {
	    }
	    return bRet;
	}
	static public void exit() {
		if(sample!=0) {
			out.close();
			if(fileCompare2("answer"+sample, "result"+sample)) {
				System.out.println("AC");
			}else {
				System.out.println("WA");
			}
		}
		sc.close();
	}
	static public void main(String ...strings ) {
		final int N = sc.nextInt();
		final int D = sc.nextInt();
		final int p[][] = new int[N][D];
		Set<Integer> set = new HashSet<>();
		for(int i=1;i<127;i++) {
			set.add(i*i);
		}
		for(int i=0;i<N;i++) {
			for(int d=0;d<D;d++) {
				p[i][d] = sc.nextInt();
			}
		}
		int count = 0;
		for(int i=0;i<N-1;i++) {
			for(int j=i+1;j<N;j++) {
				int diff = 0;
				for(int d=0;d<D;d++) {
					diff += (p[i][d]-p[j][d])*(p[i][d]-p[j][d]);
				}
				if(set.contains(diff)) {
					count++;
				}
			}
		}
		out.println(count);
		exit();
	}
}


Measured memory_bytes: 22996
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int main(){
    int n;
    scanf("%d", &n);
    int cnt = 0;
    for(int i = 1 ; i <= n ; ++i){
        int x;
        scanf("%d", &x);
        if(x != i)++cnt;
    }
    if(cnt == 0 || cnt == 2)
        puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int w,n,a,b,z;
    char q;
    cin>>w>>n;
    vector<int> ans(n);
    for(int i=0;i<w;i++){
        ans[i]=i+1;
    }
    for(int i=0;i<n;i++){
        cin>>a>>q>>b;
        z=ans[a-1];
        ans[a-1]=ans[b-1];
        ans[b-1]=z;
    }
    for(int i=0;i<w;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll solve(string s) {
	ll n = sz(s);
	if (n == 1) return 1;
	
	vvl dp(n+1,vl(3,-oo));
	dp[1][1] = dp[2][1] = 1;
	
	FOR(i,0,n+1) FOR(ilen,1,3) {
		ll j = i-ilen;
		FOR(jlen,1,3) {
			ll k = j-jlen;
			if (k < 0) continue;
			if (s.substr(k,jlen) == s.substr(j,ilen)) continue;
			dp[i][ilen] = max(dp[i][ilen], 1 + dp[j][jlen]);
		}
	}
	return *max_element(all(dp[n]));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	cout << solve(s) << endl;
}



Measured memory_bytes: 11412
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int e,y;
    cin>>e>>y;
    if(1868<=y&&y<=1911){cout<<"M"<<y-1868+1<<endl;}
    else if(1912<=y&&y<=1925){cout<<"T"<<y-1912+1<<endl;}
    else if(1926<=y&&y<=1988){cout<<"S"<<y-1926+1<<endl;}
    else if(1989<=y&&y<=2016){cout<<"H"<<y-1989+1<<endl;}
    if(e==1){cout<<1868+y-1<<endl;}
    else if(e==2){cout<<1912+y-1<<endl;}
    else if(e==3){cout<<1926+y-1<<endl;}
    else if(e==4){cout<<1989+y-1<<endl;}
}



Measured memory_bytes: 3120
lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(lst[K-1])

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

int main() {
  int N, t=0, cnt = 0;
  
  cin >> N;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  for (int i = 0; i < N; i++) {
    if (vec.at(i) > t) {
      cnt++;
      t = vec.at(i);
    }
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n)
	fmt.Scan(&x)

	a := make([]int, n, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	answer := 0
	for i := 1; i < n; i++ {
		if a[i-1]+a[i] > x {
			answer += a[i-1] + a[i] - x
			if a[i-1] > x {
				a[i-1] = x
				a[i] = 0
			} else {
				a[i] = x - a[i-1]
			}
		}
	}

	fmt.Println(answer)
}


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


int main() {
  int a,b;
  cin >> a >> b;
  if((a+b)%2==1){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << (a+b)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
main() {
    int a[110] = {};
    int n, k, d, i, j, A, ans = 0;
    scanf("%d%d", &n, &k);
    for(i = 1; i <= k; ++i) {
        scanf("%d", &d);
        for(j = 1; j <= d; ++j) {
            scanf("%d", &A);
            a[A] = 1;
        }
    }
    for(i = 1; i <= n; ++i) if(!a[i]) ++ans;
    printf("%d\n", ans);
}

Measured memory_bytes: 1696
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

const long long MOD = 1000000007;

struct Sieve {
  long long n;
  vector<long long> f, primes;
  Sieve(long long n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(long long x) { return f[x] == x;}
  vector<long long> factorList(long long x) {
    vector<long long> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<P> factor(long long x) {
    vector<long long> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, make_pair(fl[0], 0));
    for (long long p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

long long pow(long long a, long long key) {
  long long x = key;
  long long temp = 1;
  while(x > 0) {
    if(x & 1) {
      temp *= a;
      temp %= MOD;
    }
    a *= a;
    a %= MOD;
    x >>= 1;
  }
  return temp;
}


int main() {
  long long N;
  vector<long long> a;
  cin >> N;
  rep(i, N) {
    long long temp;
    cin >> temp;
    a.push_back(temp);
  }

  Sieve si(1000000);

  // long long b[1000001] = {0};
  // rep(i, N) {
  //   vector<pair<long long, long long>> factor = si.factor(a[i]);
  //   rep(j, factor.size()) {
  //     b[factor[j].first] = max(b[factor[j].first], factor[j].second);
  //   }
  // }

  vector<long long> factors(1000001, 0);
  vector<long long> b(a);
  b.erase(unique(ALL(b)), b.end());
  for(const auto& bv : b)
  {
    for(const auto& v : si.factor(bv))
    {
      factors[v.first] = max(factors[v.first], v.second);
    }
  }
  long long lcm = 1;
  rep(i, 1000001) {
    lcm *= pow(i, factors[i]);
    lcm %= MOD;
  }
  long long ans = 0;
  rep(i, N) {
    long long temp = 1;
    temp = lcm * pow(a[i], MOD-2);
    temp %= MOD;
    ans += temp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  map<ll,ll>mp;
  rep(i,0,n){
    rep(j,0,30){
      if(a[i]&1<<j){
        mp[j]++;
        break;
      }
    }
    res^=a[i];
  }
  ll pre=res&1;
  rep(i,0,30){
    ll t=!!(res&1<<i+1);
    if(t!=pre){
      buf++;
      if(!mp.count(i))judge=false;
    }
    pre=t;
  }
  if((buf&1)!=(res&1))judge=false;
  ans(judge,buf,-1);
  return 0;
}

Measured memory_bytes: 1024
//ABC105A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	if(n%k == 0){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
	return 0;
}

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

int main () {
  int a, b;
  cin  >> a >> b;
  cout << ((a*b) % 2 ? "Odd" : "Even") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

ans = False
for ha in range(N):
    for wa in range(N):
        flag = True
        for hb in range(M):
            for wb in range(M):
                if ha + hb >= N or wa + wb >= N:
                    flag = False
                    continue
                if A[ha + hb][wa + wb] != B[hb][wb]:
                    flag = False

        ans |= flag

print("Yes" if ans else "No")

Measured memory_bytes: 3572
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s_x, s_y, t_x, t_y = map(int, readline().split())
if s_x < 0 and t_x < 0:
    x = abs(s_x) - abs(t_x)
else:
    x = t_x - s_x
if s_y < 0 and t_y < 0:
    y = abs(s_y) - abs(t_y)
else:
    y = t_y - s_y
print('U' * y + 'R' * x + 'D' * y + 'L' * (x + 1) + 'U' * (y + 1) + 'R' * (x + 1) + 'D' + 'R' + 'D' * (y + 1) + 'L' * (x + 1) + 'U')


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

typedef long long ll;

// from franz' library
struct union_find {
	vector<int> p; union_find(int n) : p(n, -1) {}
	int find(int x) { 
		return p[x] < 0 ? x : p[x] = find(p[x]); 
	}
	bool unite(int x, int y) {
		int xp = find(x), yp = find(y);
		if (xp == yp)
			return false;
		if (p[xp] > p[yp])  
			swap(xp,yp);
		p[xp] += p[yp], p[yp] = xp;
		return true;
	}
	int size(int x) { 
		return -p[find(x)]; 
	}
};


int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, m; cin >> n >> m;
	stack<pair<int,int>> edges;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		edges.push({u,v});
	}

	union_find uf(n+1);
	stack<ll> ans; ans.push((n*(n-1))/2);
	while (not edges.empty()) {
		// add the edge
		pair<int,int> e = edges.top(); edges.pop();
		int f = uf.find(e.first), s = uf.find(e.second);
		ll fs = uf.size(e.first), ss = uf.size(e.second);
		uf.unite(e.first, e.second);
		if (f == s) {
			ans.push(ans.top());
		} else {
			ll ns = uf.size(e.first);
			ans.push(ans.top() - ((ns*(ns-1))/2 - (fs*(fs-1))/2 - (ss*(ss-1))/2));
		}
	}

	ans.pop();
	while (not ans.empty()) {
		cout << ans.top() << endl;
		ans.pop();
	}

	return 0;
}


Measured memory_bytes: 2560
from collections import defaultdict

N,P=map(int,input().split())
S=input()

def solMin():
  dp=[[0]*P for i in range(N+1)]
  
  for i,s in enumerate(map(int,S), start=1):
    dp[i][s%P]+=1
    for p in range(P):
      dp[i][(p*10+s)%P]+=dp[i-1][p]
  
  return sum(dp[i][0] for i in range(N+1))

def solLarge():
  cnt=defaultdict(int)
  ret=0
  now=0
  
  for d,s in enumerate(map(int, S[::-1])):
    now+=pow(10,d,P)*s
    now%=P
    ret+=cnt[(now-P)%P]
    if now==0:
      ret +=1
    cnt[now]+=1
  
  return ret

print(solMin() if P*N<=10**6 else solLarge())  

Measured memory_bytes: 42928
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 1000000007
#define int long long
#define inf (1LL << 30)
const int maxnodes=1005;
#define LL long long
#define N 1001
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main()
{
    IOS;
    
    int k,a,b;
    cin >> k >> a >> b;
    if(a > b or (b-a) <= 2)
    {
        cout <<  1 + k;
    }
    else
    {

        if(a >= k)
            cout << k + 1;
        else
        {
            int start = a;
            k -= (a-1);
            int gain = b - a;
            int z = k / 2;
            int y = k % 2;
            start += gain * z;
            start += y;
            cout << start;
        }

    }
    return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))

cnt=0
sum=0
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(m):
        sum+=a[j]*b[j]
    if sum + c > 0:
        cnt += 1
        sum=0
    else:
        sum=0
print(cnt)

Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[210][100010];
signed main() {
    int N, X; cin >> N >> X;
    vector<int> S(N);
    for(int i=0; i<N; i++) {
        cin >> S[i];
    }
    sort(S.rbegin(), S.rend());

    dp[0][X] = 1;
    for(int i=0; i<N; i++) {
        for(int j=0; j<=X; j++) {
            if(dp[i][j] == 0) continue;
            (dp[i+1][j] += dp[i][j] * (N - i - 1)) %= MOD;
            (dp[i+1][j%S[i]] += dp[i][j]) %= MOD;
        }
    }
    int ans = 0;
    for(int i=0; i<=X; i++) (ans += dp[N][i] * i) %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 155904
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		ContestScanner scan = new ContestScanner();
		int n = scan.nextInt();
		int[] A = new int[n];

		for(int i=0; i < n; i++) A[i] = scan.nextInt();

		(new Solve(n, A)).solve();
	}
}
class Solve {
	public final int n;
	public final int[] A;

	public Solve(final int n, final int[] A)
	{
		this.n = n;
		this.A = A;
	}

	public void solve()
	{
		int count = 0;

		int[] G = { 1, 4, 13, 40, 121, 364, 1093, 3280, 9841, 29524, 88573, 265720, 797161 };

		int[] sorted = new int[n];

		for(int i=0; i < n; i++) sorted[i] = A[i];

		for(int i=G.length-1; i >= 0; i--)
		{
			count = insertionSort(sorted, n, G[i], count);
		}

		int start = G.length-1;
		for(; start >= 0 && n < G[start]; start--);

		System.out.println(start + 1);

		for(int i=start; i >= 0; i--)
		{
			if(i < start) System.out.print(" ");
			System.out.print(G[i]);
		}

		System.out.println("");
		System.out.println(count);

		for(int i=0; i < n; i++) System.out.println(sorted[i]);
	}

	private int insertionSort(int[] A, final int n, final int g, int count)
	{
		for(int i=g; i < n; i++)
		{
			int v = A[i];
			int j = i - g;

			while(j >= 0 && A[j] > v)
			{
				A[j + g] = A[j];
				j = j - g;
				count++;
			}

			A[j + g] = v;
		}

		return count;
	}
}
class ContestScanner {
	BufferedReader reader;
	String[] line;
	int index;
	public ContestScanner() {
		reader = new BufferedReader(new InputStreamReader(System.in));
	}

	public ContestScanner(String filename) throws FileNotFoundException {
		reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
	}

	public String nextToken() throws IOException {
		if(line == null || index >= line.length)
		{
			line = reader.readLine().trim().split(" ");
			index = 0;
		}

		return line[index++];
	}

	public String next() throws IOException {
		return nextToken();
	}

	public String readLine() throws IOException {
		line = null;
		index = 0;

		return reader.readLine();
	}

	public int nextInt() throws IOException, NumberFormatException {
		return Integer.parseInt(nextToken());
	}

	public long nextLong() throws IOException, NumberFormatException {
		return Long.parseLong(nextToken());
	}

	public double nextDouble() throws IOException, NumberFormatException {
		return Double.parseDouble(nextToken());
	}

	public int[] nextIntArray(int N) throws IOException, NumberFormatException {
		int[] result = new int[N];

		for(int i=0; i < N; i++) result[i] = nextInt();

		return result;
	}

	public long[] nextLongArray(int N) throws IOException, NumberFormatException {
		long[] result = new long[N];

		for(int i=0; i < N; i++) result[i] = nextLong();

		return result;
	}

	public double[] nexDoubleArray(int N) throws IOException, NumberFormatException {
		double[] result = new double[N];

		for(int i=0; i < N; i++) result[i] = nextDouble();

		return result;
	}
}

Measured memory_bytes: 115092
#include <iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n,R[200001],maxv,minv;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>R[i];
	}
	maxv=-100000000000;
	minv=R[0];
	for(int j=1;j<n;j++){
		maxv=max(maxv,R[j]-minv);
		minv=min(minv,R[j]);
	}
	cout<<maxv<<endl;
	int a;cin>>a;

	return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  using Mint = ModInt<int(1e9 + 7)>;
  int N;
  cin >> N;
  Mint A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  Mint sum = 0, sum2 = 0;
  for (int i = 0; i < N; i++) sum += A[i], sum2 += A[i] * A[i];
  Mint ans = (sum * sum - sum2) / Mint(2);
  cout << ans << '\n';
  return 0;
}


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

int main(){
    long long int n;
    cin >> n;

    for(long long int i=1; i<=3500; i++){
        for(long long int j=1; j<=3500; j++){
            if(4*i*j-n*i-n*j > 0 && n*i*j % (4*i*j-n*i-n*j) == 0){
                cout << i << " " << j << " " << (n*i*j / (4*i*j-n*i-n*j)) << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,cnt;
long long d,x,y;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>d;
	while(n--){
		cin>>x>>y;
		if((x*x)+(y*y)<=(d*d)) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 3648
use std::io::*;
use std::str::FromStr;

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 min<T: std::cmp::PartialOrd>(a: T, b: T) -> T {
    if a < b {
        return a;
    } else {
        return b;
    }
}

fn main() {
    let n: usize = read();
    let x: i32 = read();
    let y: i32 = read();

    let mut ans_vec = vec![0; n-1];
    for i in 1..n+1 {
        for j in i+1..n+1 {
            let i = i as i32;
            let j = j as i32;
            let mut hop = n as i32 + 1;
            hop = min(hop, j - i);
            hop = min(hop, (x - i).abs() + (y - j).abs() + 1);
            hop = min(hop, (y - i).abs() + (x - j).abs() + 1);
            // println!("{} {} {}", i, j, hop);
            ans_vec[(hop - 1) as usize] += 1;
        }
    }

    for ans in ans_vec {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long agcd(T1 a, T2 b){return a % b ? agcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll X; cin >> X;
    pt((360 * X / agcd(X, (ll)360)) / X);

    return 0;
}

Measured memory_bytes: 3624
/*
　　　　　　 ＿＿
　　　　　／＞　　 フ
　　　　　|   _　 _l
　 　　　／` ミ＿x ノ   Zzz..
　　 　 /　 　 　 |   コード見ちゃだめ！！
　　　 /　 ヽ　　  ﾉ
　 　 │　　|　|  |
　／￣|　　 |　|  |
　| (￣ヽ＿_ヽ_)_ _)
　＼二つ
*/

#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define REP(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 0) {
    cout << min(min(min(min((b - a) / 2, n - a), b - 1),(a-1+b-1)/2),(n-b+n-a)/2) << endl;
  } else {
    cout << min(min(min(n - a, b - 1),(a-1+b-1+1)/2),(n-b+n-a+1)/2)<< endl;
  }
}

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

int main() {
    while(1) {
        int n;
        cin >> n;

        if(n == 0) break;

        vector<int> s(n);

        int sum = 0;

        for(int i = 0; i < n; i++) {
            cin >> s.at(i);
            sum += s.at(i);
        }

        double wa = 0;
      	double m = (double)sum/(double)n;
        for(int i = 0; i < n; i++) {
            wa += (s.at(i) - m)*(s.at(i) - m);
        }

        printf("%.8f\n", sqrt(wa/(double)n));
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k; cin >> n >> k;
	vi h(n); rep(i, n) cin >> h[i];
	vi dp(n, INT_MAX); dp[0] = 0;
	function<int()> solve = [&]() {
		repF(i, 1, n - 1) {
			repF(j, 1, k) {
				if (i - j < 0) break;
				dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
		return dp[n - 1];
	};
	cout << solve() << endl;
	return 0;
}

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

int main() {
  int A, B;
  string a, b;
  cin >> A >> B;

  for (int i = 0; i < B; i++) {
    a += to_string(A);
  }
  for (int i = 0; i < A; i++) {
    b += to_string(B);
  }

  cout << min(a, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long ll;
 
int main(){
    
    int N, K;
    cin >> N >> K;
    
    ll x[N], y[N];
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
    }
    
    int xM, xm, yM, ym;
    int cnt;
    ll S, ans = 4e18;
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            for(int k=0; k<N; k++){
                for(int l=0; l<N; l++){
                    xM = max(x[i],x[j]);
                    xm = min(x[i],x[j]);
                    yM = max(y[k],y[l]);
                    ym = min(y[k],y[l]);
                    cnt = 0;
                    for(int m=0; m<N; m++){
                        if(xm<=x[m] && x[m]<=xM && ym<=y[m] & y[m]<=yM) cnt++;
                    }
                    S = 1LL * (xM-xm) * (yM-ym);
                    if(cnt>=K && S>0){
                        ans = min(ans, S);
                    }
                }
            }
        }
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
def isbipart(n,graph):  
  colors = [0 for i in range(n)]
  stack = deque([(0,1)])
  while stack:
    v,color = stack.pop()
    colors[v] = color
    for to in graph[v]:
      if colors[to] == color:
        return False
      if colors[to] == 0:
        stack.append((to,-color))
  return colors

def solve():
  n,m  =(int(i) for i in input().split())
  graph = [[] for _ in range(n)]
  for i in range(m):
    a,b = (int(i) for i in input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
  colors = isbipart(n,graph)
  if colors:
    b = colors.count(1)
    w = n-b
    print(b*w-m)
  else:
    print(n*(n-1)//2-m)
solve()

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

int main() {
	int N, X, ANS = 1, COUNT = 0;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		int L;
		cin >> L;
		COUNT += L;
		if (COUNT <= X) ANS++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;




int main(){
	int n;
	cin >> n;
	vector<int> col(9);

	rep(i, 0, n) {
		int x;
		cin >> x;
		if (x < 3200) {
			col[x / 400]++;
		}
		else {
			col[8]++;
		}
	}

	int kind=0;
	rep(i, 0, 8) {
		if (col[i] > 0)kind++;
	}


	if (col[8] == 0) {
		cout << kind << " " << kind << endl;
	}
	else if(kind != 0){
		cout << kind << " " << kind + col[8] << endl;
	}
	else {
		cout << 1 << " " << col[8] << endl;
	}



	return 0;
}


Measured memory_bytes: 256
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))
	/*
	val line = f.readLine().split(" ")
	println(line)
	val a = line[0].toLong()
	println(a)
	System.out.flush()
	val b = (line[1].toDouble()*100.0).toLong()
	println(a*b/100)
*/
/*
	val st = StringTokenizer(f.readLine())
	val a = st.nextToken().toLong()
	val b = (st.nextToken().toDouble()*100).toLong()
	println(a*b/100)*/

	val (a,b) = f.readLine().split(" ").map{it.toBigDecimal()}
	val prod = a.times(b)
	val string = prod.toPlainString()
	//println(string)
	//System.out.flush()
	if(string.indexOf('.') != -1){
		println(string.substring(0,string.indexOf('.')))
	} else {
		println(string)
	}
}


Measured memory_bytes: 36704
#include <stdio.h>

int main(){
  int i,n,a[100005];
  long m=0,b=1,c[100005];
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    scanf("%d",&a[i]);
  }
  c[n]=0;
  for(i=n;i>0;i--){
    c[i-1]=c[i]+a[i];
  }
  for(i=0;i<=n;i++){
    m+=b;
    b-=a[i];
    if(b<0) break;
    b<<=1;
    if(b>c[i]){
      b=c[i];
    }
  }
  if(i<=n){
    printf("-1");
  }else{
    printf("%ld",m);
  }
  return(0);
}


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

long long Ceil(long long a, long long b)
{
    return (a + b - 1) / b;
}

int main()
{
    long long k, a, b;
    cin >> k >> a >> b;

    if (a > b)
    {
        cout << 2 * Ceil(k - b, a - b) - 1 << endl;
    }
    else
    {
        if (a >= k)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
i64 A[202020];

int main(){
  cin >> N;
  rep(i,0,N - 1){
    cin >> A[i];
  }
  int r = 0;
  i64 ans = 0;
  i64 now = 0;
  rep(l,0,N - 1){
    while(r < N && (now & A[r]) == 0){
      now |= A[r];
      r++;
    }
    ans += r - l;
    if(l == r){
      r++;
    }
    else{
      now &= ~(A[l]);
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <set>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    vector <ll> a(N);
    REP(i,N)
    {
        cin >> a[i];
    }

    int now = a[0];
    int res = 1;
    for(int i = 1; i < N; ++i)
    {
        if(now >= a[i])++res;

        now = a[i];
    }
    cout << res << endl;
    cout << N << endl;


    return 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define N 3010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forv(i, n)	for(int i = n - 1; i >= 0; --i)
#define r0 return 0
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lld long double
 
const int inf = 1e9 + 1;
const ll modw = 1e9 + 7;
 
using namespace std;

lld dp[N][N];
lld a[N];

int main() {
	barnarnar
	int n;
	cin >> n;
	forn1(i, n)	cin >> a[i];
	dp[1][1] = a[1];
	dp[1][0] = 1 - a[1];
	//cout << a[1] << '\n';
	for(int i = 2; i <= n; i++)
	{
		dp[i][0] = dp[i - 1][0] * (1 - a[i]);
		for(int j = 1; j <= i; j++)
		{
			dp[i][j] = dp[i - 1][j] * (1 - a[i]) + dp[i - 1][j - 1] * a[i];
			//cout << dp[i][j] << ' ';
		}
		//cout << endl;
	}
	lld ans = 0;
	for(int i = n / 2 + 1; i <= n; i++)
	{
		ans += dp[n][i];
	}
	cout << setprecision(9) << fixed;
	cout << ans;
	return 0;
}

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

int main(){
    // input
    int N, K, tmp, count;
    cin >> N >> K;
    priority_queue<int> h;
    for( int i=0; i<N; i++ ){
        cin >> tmp;
        h.push(tmp);
    }

    // count
    count = 0;
    for( int i=0; i<N; i++ ){
        tmp = h.top();
        h.pop();
        if( tmp >= K){
            count++;
        }
    }

    // output
    cout << count << endl;
} 

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int n, a, b, c;
vector<int> abc;
vector<int> vec;
ll ans = INF;

int check(ll st) {
  vector<int> r(3, 0);
  vector<int> cost(3, 0);
  int cnt = 0;
  while(st) {
    if(st % 10 != 4) {
      int idx = st % 10 - 1;
      if (r[idx] != 0) {
        cost[idx] += 10;
      }
      r[idx] += vec[n-1-cnt];
    };
    st /= 10;
    cnt++;
  }
  int tmp = 0;
  rep(i, 3) {
    if (r[i] == 0) {
      return -1;
    }
    tmp += cost[i] + abs(r[i] - abc[i]);
  }
  return tmp;
}

void dfs(ll st, int cnt) {
  if (cnt == n) {
    int tmp = check(st);
    if (tmp != -1) {
      ans = min(ans, (ll)tmp);
    }
    return;
  }
  reps(i,1,5) {
    ll nxt = st * 10 + i;
    dfs(nxt, cnt+1);
  }
  return;
} 

int main()
{
  cin >> n >> a >> b >> c;
  abc.push_back(a);
  abc.push_back(b);
  abc.push_back(c);
  vec.resize(n, 0);
  rep(i,n) cin >> vec[i];
  dfs(0, 0);
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  queue<int> Q;
  set<int> S;
  Q.push(3);
  Q.push(5);
  Q.push(7);
  while (true) {
    int X = Q.front();
    Q.push(10 * X + 3);
    Q.push(10 * X + 5);
    Q.push(10 * X + 7);
    Q.pop();
    if (X > N) break;
    else {
      set<int> T;
      int Y = X;
      while (Y > 0) {
        T.insert(Y % 10);
        Y /= 10;
      }
      if (T.size() == 3) S.insert(X);
    }
  }
  cout << S.size() << endl;
}

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

#define ll long long
using namespace std;
const int kmod = 1e9 + 7;
double ans = 0;


double solve(int idx ,int h ,vector<double>& coins , vector<vector<double>>&dp ,int n )
{
    if(idx == n)
    {
        int t = n - h;
        if( h > t)
         return 1.0;
        return 0.0;
    }
    
    if(dp[idx][h] != -1)
     return dp[idx][h];
    
    double my = 0;
     
     my = solve(idx + 1 , h + 1 , coins , dp , n  )*coins[idx] ;

    my = my + solve(idx + 1 , h , coins , dp , n )*(1 - coins[idx]);
   
    
    return dp[idx][h] = my;

}
int main()
{
    
   
   int n;
   cin>>n;
   
   vector<double>coin(n);

   vector<vector<double>>dp(n+1 , vector<double>(n+1 ,-1));

   for(int i = 0; i<n ;i++)
   cin>>coin[i];

    double ans = solve(0 , 0 , coin , dp , n);
   
   
   printf("%.9lf\n" ,ans);
   
}

Measured memory_bytes: 74076
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  long long x,y;
  cin >> x >> y;
  long long ans;
  
  if(x == 1 || y == 1){
    ans = 1;
  } else if(x%2==0 || y%2 == 0){
    ans = x*y/2;
  } else { 
    ans = (x*y +1)/2 ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, nextint;
	scanf("%d", &N);
	int ans[N];
	for (int i = 1; i <= N; ++i) {
		scanf("%d", &nextint);
		ans[nextint - 1] = i;
	}
	for (int i = 0; i < N; ++i) printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=(l); i<(r); ++i)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    string s; cin >> s;
    int n=s.length();

    vector<vector<int>> dp(20, vector<int>(2, 0));

    rep(i, 0, n) rep(j, 0, 2){
        if(i==0 && j==1) continue;
        int lim = j? 9:s[i]-'0';
        rep(d, 0, lim+1) chmax(dp[i+1][j || d<lim], dp[i][j]+d);
    }

    cout << max(dp[n][0], dp[n][1]) << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] H) {
    int move;
    int ans;
    foreach (i; 0 .. cast(int) N) {
        if (i == N - 1) {
            ans = max(ans, move);
            break;
        }
        
        if (H[i] >= H[i + 1]) {
            move++;
        } else {
            ans = max(ans, move);
            move = 0;
        }
    }
    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] H = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        H[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, H);
    else
        solve(N, H).writeln;
}


Measured memory_bytes: 9396
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = list(map(int, input().split()))
for i in range(x): r.append(p[a-i-1])
for i in range(y): r.append(q[b-i-1])
r.sort()
print(sum(r[len(r)-x-y:]))

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

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

    ll ans=1,f=0,s=0;
    rep(i,n-1){
        if(a[i] < a[i+1]) f=1;
        if(a[i] > a[i+1]) f=-1;

        if(f==-1 && s==1 || f==1 && s==-1){
            ++ans;
            f=s=0;
            continue;
        }
        s = f;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define int long long
#define MOD 1000000007

int bexp (int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1)
			res = a * res % MOD;

		a =  a * a % MOD;
		b >>= 1; 
	}
	return res;
}	

int ncr(int n, int r)
{
	int k = max(r, n - r);
	int res = 1;
	for (int i = k + 1; i <= n; ++i)
	{
		res = res * i % MOD;
	}

	for (int i = 1; i <= min(r, n - r); ++i)
	{
		res = res * bexp(i, MOD - 2) % MOD;	
	}
	return res;
}

int32_t main()
{
	int n, a, b;
	cin >> n >> a >> b;

	int ans = bexp(2, n) - 1;

	ans = (2 * MOD + ans - ncr(n , a) - ncr(n, b)) % MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;
typedef long long ll;

ll n, m;
vector<vector<ll>> net;
vector<bool> visited;
vector<ll> cur_nxt;

bool check(ll start){
    unordered_set<ll> v;

    ll cur = start;
    do{
        if(cur == -1){ return false; }
        v.insert(cur);
        cur = cur_nxt.at(cur);
    }while(cur != start);

    for(ll x : v){
        for(ll to : net.at(x)){
            if(cur_nxt.at(x) != to && v.count(to)){
                return false;
            }
        }
    }

    cout << v.size() << endl;
    for(ll x : v){
        cout << x + 1 << endl;
    }
    return true;
}

bool dfs(ll cur){
    visited.at(cur) = true;
    for(ll nxt : net.at(cur)){
        cur_nxt.at(cur) = nxt;
        if(visited.at(nxt)){
            if(check(nxt)){
                return true;
            }
        }else if(dfs(nxt)){
            return true;
        }
    }
    return false;
}

int main(){
    cin >> n >> m;
    net.resize(n);
    for(int i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        net.at(a).push_back(b);
    }

    visited.resize(n, false);
    cur_nxt.resize(n, -1);
    for(int i = 0; i < n; ++i){
        if(visited.at(i)){
            continue;
        }
        if(dfs(i)){
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

const int MAX_N = 100;

int main() {
  int n;
  int w[MAX_N + 1];
  int sum[MAX_N + 1];
  int x = 0;
  int ans = 1000000;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    x += w[i];
    sum[i] = x;
  }
  for (int i = 0; i < n; i++) {
    ans = min(ans, abs(sum[n - 1] - 2 * sum[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

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

    if(S.length() <= K){
        cout<<S <<endl;

    }
    else{
     string tempS;
     tempS = S.substr(0,K);
     cout<< tempS +"..."<<endl;
    }
}



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

int main(){
    long N;
    cin >> N;
    cout << (N * (N - 2) + 1) / 2 << endl;
    for(long i = 1; i <= N; ++i)
        for(long j = 1; j < i; ++j)
            if(j + i != N + !(N & 1))cout << j << " " << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n;
  cin>>n;
  vector<int> d(n,0),h(n);
  for(auto& i:h)cin>>i;
  for(int i=1;i<n;++i)d[i]=min(d[i-1]+abs(h[i]-h[i-1]),i>1?d[i-2]+abs(h[i]-h[i-2]):INT_MAX);
  cout<<d[n-1];
}

Measured memory_bytes: 1024