akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

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

  ll ans = 0;
  if(n == 1 || m == 1){
    if(max(n, m) >= 2){
      ans = max(n, m) - 2;
    }
    else ans = 1;
  }
  else ans = (ll)(n - 2) * (m - 2);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int A,B,K,i;
  cin>>K>>A>>B;

  if(B-A>=K)
    cout << "OK";
  else if(B-A<K){
	for(i=B;i>=A;i--)
	{
		if(i%K==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";

  }
  cout << endl;
}


Measured memory_bytes: 3592
#!/usr/bin/python
#-coding:utf-8-

import sys


data_list = []
for s in sys.stdin:
  data_list.append( map(int,s.split()) )

for e in data_list[1:]:
  e.sort()
  if e[0]*e[0] + e[1]*e[1] == e[2] * e[2]:
    print "YES"
  else:
    print "NO"
  

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

#define pb push_back
#define loop(i,l,r) for(int i = (l); i < (r); i++)
#define rloop(i,r,l) for(int i = (r-1); i >= (l); i--)
#define refloop(x, v) for(auto& x : (v))
#define exists(m,e) if((m).find(e) != (m).end())
#define nexists(m,e) if((m).find(e) == (m).end())
#define sortaka(v) sort((v).begin(), (v).end())
#define rsort(v) sort((v).rbegin(), (v).rend())
#define lower_bound_index(v, x) (lower_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] >= x
#define upper_bound_index(v, x) (upper_bound((v).begin(), (v).end(), x)-(v).begin()) // returns minimum i s.t v[i] > x
#define scanint(x) scanf("%d", &(x))
#define scanfloat(x) scanf("%f", &(x))
#define scanll(x) scanf("%lld", &(x))
#define scanchar(x) scanf("%c", &(x))
#define scanstring(x) scanf("%s", &(x))
#define printint(x) printf("%d", x)
#define printfloat(x) printf("%.9f", x)
#define printll(x) printf("%lld", x)
#define printchar(x) printf("%c", x)
#define printstring(x) printf("%s", x)
#define printintnewline(x) printf("%d\n", x)
#define printfloatnewline(x) printf("%.9f\n", x)
#define printllnewline(x) printf("%lld\n", x)
#define printcharnewline(x) printf("%c\n", x)
#define printstringnewline(x) printf("%s\n", x)
#define square(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))

typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<string> vs;
typedef vector<vector<pair<int, int>>> vvpii;
typedef vector<vector<pair<long long, long long>>> vvpll;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);

    const int MOD = (int)1e9+7;
    int n; cin >> n;

    vl dp(n+1), cum(n+1);

    dp[0] = 1;
    cum[0] = 1;
    dp[1] = dp[2] = 0;
    cum[1] = cum[2] = 1;
    for(int i = 3; i <= n; i++){
        dp[i] = cum[i-3];
        cum[i] = (cum[i-1]+dp[i])%MOD;
    }

    cout<<dp[n]<<endl;
}

Measured memory_bytes: 3620
s = input()
q = int(input())
for _ in range(q):
    line = input().split()
    if line[0] == 'print':
        print(s[int(line[1]):int(line[2]) + 1])
    elif line[0] == 'reverse':
        s1 = s[:int(line[1])]
        s2 = s[int(line[1]):int(line[2]) + 1]
        s2 = s2[::-1]
        s3 = s[int(line[2]) + 1::]
        s = s1 + s2 + s3
    elif line[0] == 'replace':
        s1 = s[:int(line[1])]
        s2 = s[int(line[2]) + 1:]
        s = s1 + line[3] + s2


Measured memory_bytes: 5616
n = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for x in range(j + 1, n):
            if L[i] == L[j] or L[i] == L[x] or L[j] == L[x]:
                continue
            if L[i] + L[j] > L[x]:
                ans += 1
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)					(a).begin(),(a).end()
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(1000 * 1000 * 1000 * 2)
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	ll N, M;
	cin >> N >> M;

	ll ans = min(N, M / 2);
	M -= ans * 2;
	ans += M / 4;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int a, b; cin >> a >> b;
    int tmp = (a >= b ? a - b : b - a);
    int rest = 16 - 2 * (a >= b ? b : a);
    if (tmp * 2 > rest) out(":(");
    else out("Yay!");
}


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

const long long INF = 1e15;
const int MAX_V = 1010;
const int MAX_E = 2010;

struct edge{int from, to;
            long long cost;};

edge es[MAX_E];

long long d[MAX_V];
int N, M;

int main(){
  cin >> N >> M;
  for (int i=0; i<=N; i++){
    d[i] = -INF;
  }
  for (int i=0; i<M; i++){
    cin >> es[i].from >> es[i].to >> es[i].cost;
  }
  d[1] = 0;
  for (int i=0; i<N; i++){
    for (int j=0; j<M; j++){
      edge e = es[j];
      if (d[e.to] < d[e.from]+e.cost){
        d[e.to] = d[e.from]+e.cost;
      }
    }
  }
  long long currentcost = d[N];
  for (int i=0; i<N; i++){
    for (int j=0; j<M; j++){
      edge e = es[j];
      if (d[e.to] < d[e.from]+e.cost){
        d[e.to] = d[e.from]+e.cost;
      }
    }
  }

  if (currentcost!=d[N]){
    cout << "inf" << endl;
    return 0;
  }
  cout << d[N] << endl;
}


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

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

int h, w;

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				char c = 'A' + j;
				cout << c << i + 1 << endl;
			}
		}
	}
//	cin >> w;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int dfn1[N], dfn2[N];
vector<int> G1[N], G2[N];
int cnt = 1;
void dfs(int u, int* dfn, vector<int>* G) {
    if (!dfn[u]) dfn[u] = cnt;
    for (int v : G[u]) if (!dfn[v]) dfs(v, dfn, G);
}
int main() {
    int n, K, L;
    cin >> n >> K >> L;
    for (int i = 0; i < K; ++i) {
        int u, v;
        cin >> u >> v;
        G1[u].push_back(v);
        G1[v].push_back(u);
    }
    for (int i = 0; i < L; ++i) {
        int u, v;
        cin >> u >> v;
        G2[u].push_back(v);
        G2[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) if (!dfn1[i]) {
        ++cnt;
        dfs(i, dfn1, G1);
    }
    for (int i = 1; i <= n; ++i) if (!dfn2[i]) {
        ++cnt;
        dfs(i, dfn2, G2);
    }
    map<pair<int, int>, int> mp;
    for (int i = 1; i <= n; ++i) ++mp[{dfn1[i], dfn2[i]}];
    for (int i = 1; i <= n; ++i) cout << mp[{dfn1[i], dfn2[i]}] << " \n"[i == n];
}

Measured memory_bytes: 30588
x, n = map(int, input().split())
ps = list(map(int, input().split()))

table = [True] * 102
for p in ps:
    table[p] = False
if table[x]:
    print(x)
    exit()

i = 1
while True:
    if table[x - i]:
        print(x - i)
        break
    if table[x + i]:
        print(x + i)
        break
    i += 1


Measured memory_bytes: 9188
x=str(input())

if x[0]==x[1]:
    if x[1]==x[2]:
        print("Yes")
    elif x[1]!=x[2]:
        print("No")
elif x[0]!=x[1]:
    if x[1]==x[2]:
        if x[2]==x[3]:
            print("Yes")
        elif x[2]!=x[3]:
            print("No")
    elif x[1]!=x[2]:
        print("No")
    
    

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

using namespace std;

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

int main() {
  int x;
  scanf("%d", &x);
  int ans = 360 / gcd(x, 360);
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 3788
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var x = int.Parse(_[0]);
            var a = int.Parse(_[1]);
            var b = int.Parse(_[2]);

            if(a - b >= 0){
                Console.WriteLine("delicious");
            }else{
                if(Math.Abs(a - b) <= x){
                    Console.WriteLine("safe");
                }else{
                    Console.WriteLine("dangerous");
                }
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  string s;
  cin >> s;
  int ans=0;
  rep(i,s.size()/2+(s.size()%2)) {
    if(s[i]=='i' && s[s.size()-1-i]!='i') ans++;
    if(s[i]=='w' && s[s.size()-1-i]!='w') ans++;
    if(s[i]=='(' && s[s.size()-1-i]!=')') ans++;
    if(s[i]==')' && s[s.size()-1-i]!='(') ans++;
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 1180
MOD = 10 ** 9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(key=abs, reverse=True)
s = 0
ps = 0
for i in range(k):
    if a[i] < 0:
        s ^= 1
    else:
        ps = 1
b = a[:k]
b.sort(key=abs)
if s:
    p = -MOD
    for i in range(k, n):
        if a[i] >= 0:
            p = a[i]
            break
    q = MOD
    if ps:
        for i in range(k, n):
            if a[i] <= 0:
                q = a[i]
                break
    x = 0
    for j in range(k):
        if b[j] < 0:
            x = b[j]
            xi = j
            break
    y = 0
    for j in range(k):
        if b[j] > 0:
            y = b[j]
            yi = j
            break
    flg = 1
    if y == 0:
        if p >= 0:
            b[xi] = p
            flg = 0
    else:
        if p * y > q * x and p > 0:
            b[xi] = p
        elif q < 0:
            b[yi] = q
        flg = 0
    if flg:
        b = a[-k:]
res = 1
for i in range(k):
    res = res * b[i] % MOD
print(res)


Measured memory_bytes: 111152
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // 参考書数
        int n = sc.nextInt();

        // 習得したいアルゴリズム数
        int m = sc.nextInt();

        // 習得目標理解度
        int x = sc.nextInt();

        // n番目の参考書の値段
        int[] c = new int[n];

        // n番目の参考書のm番目のアルゴリズムの上昇理解度
        int[][] a = new int[n][m];

        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int[] aTmp = new int[m];
        int costTmp = 0;
        List<Integer> costsSave = new ArrayList<>();
        boolean masterd = true;

        // bit全探索
        for (int i = 0; i < 1 << n; i++) {
            // 1loop毎にどの参考書を買うかの判定(j冊目を買うかどうか)
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) {
                    // ここに引っかかった = 買う対象に追加(j冊目購入)
                    for (int h = 0; h < m; h++) {
                        // j冊目の参考書を買った時のm番目のアルゴリズムの理解度上昇
                        aTmp[h] += a[j][h];
                    }

                    // j冊目の値段
                    costTmp += c[j];
                }
            }

            // 参考書を買い終わったので、アルゴリズムを覚えられたかどうかの判定
            for (int h = 0; h < m; h++) {
                if (aTmp[h] < x) {
                    masterd = false;
                    break;
                }
            }

            // 覚えられた場合は値段を保持
            if (masterd) {
                costsSave.add(costTmp);
            }

            // 後始末
            aTmp = new int[m];
            costTmp = 0;
            masterd = true;
        }

        // listのうち最小の値を出力。リストがnullなら"-1"を出力
        int ans = Integer.MAX_VALUE;
        if (costsSave.isEmpty()) {
            ans = -1;
        } else {
            for (int cost : costsSave) {
                if (ans > cost) {
                    ans = cost;
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }

}

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

int dis(int a, int b) {
  if(a-b > 0)  return a-b;
  else         return b-a;
}

int main() {
 
  int n;
  cin >> n;
  vector<int> a(n+2);
  a.at(0) = 0;
  a.at(n+1) = 0;
  vector<int> d(n+1);
  int total = 0;
  for(int i = 1; i < n+1; i++) {
    cin >> a.at(i);
  }
  for(int i = 0; i < n+1; i++) {
    d.at(i) = dis(a.at(i), a.at(i+1));
    total += d.at(i);
  }
  
  for(int i = 0; i < n; i++) {
    int sum = total - d.at(i) - d.at(i+1);
    if((a.at(i+1)-a.at(i)) * (a.at(i+2)-a.at(i+1)) > 0) {
      sum += d.at(i) + d.at(i+1);
    } else {
      sum += dis(d.at(i), d.at(i+1));
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 2048
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


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

    int b;
    vector<int> a;

    for(int i=0;i<n;i++){
        cin >> b;
        a.push_back(b);
        
    }
    sort(a.begin(), a.end());

    vector<int> ans;
    for(int i=0;i<a.size()-1;i++){
        if(a[i] == a[i+1]){
            ans.push_back(a[i]);
            i++;
        }
    }

    if(ans.size()<2){
        cout << 0 << endl;
        return 0;
    }

    cout << 1LL*ans[ans.size()-2] * ans[ans.size() -1] << endl;
    return 0;
}

Measured memory_bytes: 1144
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

ll f(int n) {
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) res+= i;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    cout << f(n) <<endl;
    return 0;
}

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

bool IsPrime(int a) {
    if(a==2) return true;

    if (a<2 || a%2==0) return false;

    int i = 3;
    while(i<=sqrt(a)) {
        if(a%i==0) return false;
        i = i + 2;
    }

    return true;
}

int main() {
    int n;
    cin >> n;
    int a[n], i, j=0;

    for(i=0; i<n; i++) {
        cin >> a[i];
        if(IsPrime(a[i])) j++;
    }
    cout << j << endl;

    return 0;
}

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

long long weights[101];
long long values[101];
const int vMax = 100*1000+1;
long long dp[101][vMax+1];
long long const INF = 1LL << 60;
int main()
{
    int n;
    long long W;
    cin >> n >> W;
    for(int i=0;i<n;i++){
        cin >> weights[i] >> values[i];
    }
    for(int i=0;i<=n;i++){
        for(int v=0;v<=vMax;v++){
            dp[i][v] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int v=0;v<=vMax;v++){
            if(v >= values[i]){
                dp[i+1][v] = min(dp[i][v],dp[i][v - values[i]] + weights[i]);
            }
            else{
                dp[i+1][v] = dp[i][v];
            }
        }
    }
    int ret = 0;
    for(int v=0;v<=vMax;v++){
        if(dp[n][v] <= W){
            ret = v;
        }
    }
    cout << ret;
}

Measured memory_bytes: 79104
import math
def prime(x):
  p = {}
  last = math.floor(x ** 0.5)
  if x % 2 == 0:
    cnt = 1
    x //= 2
    while x & 1 == 0:
      x //= 2
      cnt += 1
    p[2] = cnt
  for i in range(3, last + 1, 2):
    if x % i == 0:
      x //= i
      cnt = 1
      while x % i == 0:
        cnt += 1
        x //= i
      p[i] = cnt
  if x != 1:
    p[x] = 1
  return p


N = int(input())

ans = 0
for i in range(1, N + 1, 2):
  p = prime(i)
  t = 1
  for v in p.values():
    t *= v + 1
  if t == 8:
    ans += 1

print(ans)

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

using std::cout;
using std::cin;
using std::endl;
using std::vector;

void printVector_2(vector<vector<int> > v) {
    // cout << "####  A  ####" << endl;
    for (int i = 0; i < v.size(); i++ ) {
        for (int j = 0; j < v.front().size(); j++) {
            cout << v[i][j] << " "; 
        }
        cout << endl;
    }
}

void printVector_1(vector<int> v) {
    // cout << "####  B  ####" << endl;
    for (int i = 0; i < v.size(); i++ ) {
        cout << v[i] << endl;
    }
}

int main(void) {
    int n; // row 
    int m; // column
    cin >> n >> m;
    // cout << n << m << endl;
    vector<vector<int> > a(n, vector<int>(m, 0));
    vector<int> b(m, 0);
    vector<int> answer(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    // printVector_2(a);
    // printVector_1(b);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            answer[i] += a[i][j] * b[j];
        }
    }

    printVector_1(answer);

    return 0;
}

Measured memory_bytes: 3172
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    
      
    class Program
    {

        static int[] A;
        static int N;
        static long M;
        static long[] B;
        static Dictionary<long, long> dic;

        static void CreateB()
        {
            B = new long[N + 1];
            B[0] = 0;

            for(int i = 1; i <= N; i++)
            {
                B[i] = B[i - 1] + (long)A[i - 1];
            }

        }

        static void Createdic()
        {
            dic = new Dictionary<long, long>();

            for(int i = 0; i <= N; i++)
            {
                long amari = B[i] % M;
                if (!dic.ContainsKey(amari))
                {
                    dic[amari] = 1;
                }
                else
                {
                    dic[amari]++;
                }
            }

        }

        
        static long Solve()
        {
            long cnt = 0;

            foreach(var s in dic)
            {
                cnt += ((long)s.Value * (s.Value - 1)) / 2;
            }

            return cnt;
        }

        static void Main(string[] args)
        {
            //入力1(N, M)
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            N = input[0];
            M = input[1];

            //入力2(A)
            A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            CreateB();
            //Console.WriteLine($"B:{string.Join(" ", B)}");
            Createdic();
            //foreach (var s in dic) Console.WriteLine($"余り:{s.Key} 個数:{s.Value}");

            Console.WriteLine(Solve());

        }
    }

}

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

int main(){
    int h,w,k,b=0;
    cin>>h>>w>>k;
    string grid[h];
    for(int i=0;i<h;i++){
        cin>>grid[i];
    }
    int ans=0;
    for(int maskr=0;maskr<(1<<h);maskr++){
        for(int maskc=0;maskc<(1<<w);maskc++){
            int black=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(((maskr>>i) & 1 !=0) && ((maskc>>j) & 1!=0) && grid[i][j]=='#'){
                        black++;
                    }
                }
            }
           if(black==k){
               ans++;
           }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
const int MAXN = 2005 ;;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e10 ;
int sumofdigit(int N){
    int sum=0;
    while(N>0){
        sum+=N%10 ;
        N/=10;
    }
    return sum ;
}
int main(){
    int N ;
    cin >>N ;
    int mx = MAX ;
    for(int i=1;i<N;i++)
        mx=min(mx,sumofdigit(i)+sumofdigit(N-i));
    cout<<mx<<endl;
    return 0;
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

char s[10];
bool eq(int a,int b,int c,char o){
  return (s[a]==o && s[b]==o && s[c]==o);
}

int mp[12][12];

void dfs(int x,int y,int k){
  if(x<0 || x>=12 || y<0 || y>=12)return;
  if(mp[x][y]!=-1)return;
  mp[x][y] = k;
  int d[5]={0,1,0,-1,0};
  REP(i,4)dfs(x+d[i],y+d[i+1],k);
}

int main(){
  ll n;
  while(~scanf("%lld",&n)){
    REP(i,12){
      mp[0][i]=-(n&1);
      n/=10;
    }
    REPR(i,12){
      scanf("%lld",&n);
      REP(j,12){
        mp[i][j]=-(n&1);
        n/=10;
      }
    }
    int k = 1;
    int cnt = 0;
    REP(i,12)REP(j,12){
      if(mp[i][j]==-1){
        ++cnt;
        dfs(i,j,k++);
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 888
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n){
        cin >> x[i];
    }
    ll ans=0;
    rep(i,n-1){
        ll dx=x[i+1]-x[i];
        ans+=min(dx*a,b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4028
n = gets.to_i
s = gets.chomp!

t = s.clone
i = 0
until i > (t.length-1)
	if t[i] == "(" && t[i+1] == ")"
		t[i,2] = ""
		i -= 1
	else
		i += 1
	end
end
left = t.count(")")
right = t.count("(")
ans = "(" * left + s + ")" * right
puts ans


Measured memory_bytes: 1788
b = gets.split.map(&:to_i)
#p b
if (b[0] - b[2]).abs <= b[3]
 puts "Yes"
elsif (b[0] - b[1]).abs <= b[3] &&  (b[2] - b[1]).abs <= b[3]
 puts "Yes"
else
 puts "No"
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vector<vector<ll>> connection(N);
  for (ll i = 0; i < M; ++i) {
    ll u, v;
    cin >> u >> v;
    u -= 1, v -= 1;
    connection.at(u).push_back(v);
  }
  ll S, T;
  cin >> S >> T;
  S -= 1, T -= 1;
  vector<vector<ll>> point(N, vector<ll>(3, INF));
  queue<vector<ll>> q;//{now, cnt, ken_cnt}
  point.at(S).at(0) = 0;
  q.push({S, 0, 0});
  while (!q.empty()) {
    vector<ll> qf = q.front();q.pop();
    ll now = qf.at(0), cnt = qf.at(1), ken_cnt = qf.at(2);
    for (ll i = 0; i < connection.at(now).size(); ++i) {
      ll next = connection.at(now).at(i);
      if (point.at(next).at((ken_cnt + 1) % 3) > cnt + 1) {
        point.at(next).at((ken_cnt + 1) % 3) = cnt + 1;
        q.push({next, cnt + 1, (ken_cnt + 1) % 3});
      }
    }
  }
  ll ans = point.at(T).at(0);
  // for (ll i = 0; i < N; ++i) {
  //   for (ll j = 0; j < 3; ++j) {
  //     cout << point.at(i).at(j) << ' ';
  //   }
  //   cout << "\n";
  // }
  if (ans != INF) {
    cout << ans / 3 << "\n";
  }
  else {
    cout << -1 << "\n";
  }
}


Measured memory_bytes: 14284
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust, fromMaybe )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.IO as IOA
import qualified Data.Array.MArray as MA
import Control.Monad.ST
import System.IO (stdin)
import Control.Arrow
import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Generic as GV



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- readInts
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- readInts
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> BC.ByteString -> Int
solve n as = minimum eachnum where
    unpacked = BC.unpack as
    scanner (east, west) 'E' =  (east +1, west) 
    scanner (east,west) _ = (east, west+1)
    lrsumacc :: UV.Vector (Int, Int)
    !lrsumacc = GV.fromList $ scanl' scanner (0, 0) unpacked
    rlsumacc :: UV.Vector (Int, Int)
    !rlsumacc = GV.fromList $ scanr (flip scanner) (0, 0) unpacked
    eachnum = (\i -> (snd $ lrsumacc GV.! (i - 1)) + (fst $ rlsumacc GV.! i)) <$> [1..n]

main = do
    n <- readInt
    s <- BC.getLine
    print $ solve n s


Measured memory_bytes: 81276
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

r = [[] for _ in range(n)]
for a, b in ab:
    r[a-1].append(b-1)
    r[b-1].append(a-1)

for i in r[0]:
    if n-1 in r[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 106532
#include<iostream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include <algorithm>
#include <set>
#include<math.h>
#include<cmath>
#include<vector>
#include<map>
#include<random>
#include<sstream>
using namespace std;

int main(){
    int n;cin >> n ;
    int t,h,o;
    t = n/100;
    h = n%100/10;
    o = n%10;
    int m;
    //cout << t << h <<  o << endl;
    if(t == h && t == o){cout << n;}
    else{
        for(int i = 999;i >= n;i-=111){
            m = i;  
        }
        cout << m << endl;
    }
}

Measured memory_bytes: 3644
<?php
    $N = intval(trim(fgets(STDIN)));
    
    $A_array = array_map('intval',explode(" ",trim(fgets(STDIN))));
    
    $ans = array_fill(0,$N,0);
    
    // var_dump($ans);
    
    for($i=0;$i<($N-1);$i++){
        $ans[$A_array[$i]-1]++;
    }
    

    for($i=0;$i<($N);$i++){
        echo $ans[$i]."\n";
    }

?>

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

int main()
{
    int n,d,x;
    cin >> n >> d >> x;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        for(int j = 1; j <= d; j += a){
            ans++;
        }
    }
    cout << ans + x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
int main(){ 
    string s;
    long long int k;
    cin>>s>>k;
    int a=0;
    int b=0;
    REP(i,s.size()){
        if(s[i]=='1'){
            a++;
        }else{
            b=i;
            break;
        }
    }
    if(k<=a){
        cout<<1;
    }else{
        cout<<s[b];
    }
    return 0;
}


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

int main(){
    int64_t a,b;
    cin >> a >> b;

    int64_t ans = 0;
    for ( int i = 1 ; i<= b-a ; i++ ){ans += i;}
    ans -= b;

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

N,M = map(int,input().split())
li = [-1 for i in range(3)]

if M==0 and N==1:
    print(0)
elif M==0 and N==2:
    print(10)
elif M==0 and N==3:
    print(100)
if M==0:
    sys.exit()

for i in range(M):
    s,c = map(int,input().split())


    if li[s-1]==-1 or li[s-1]==c:
        li[s-1] = c
    else:
        print(-1)
        break
else:
    ans = 0
    for i in range(N):
        mm = li[i]
        if li[i]==-1 and i!=0:
            li[i] = 0
        elif li[i]==-1 and i==0:
            li[i] = 1
        ans = ans * 10 + li[i]

    if c == 0 and s==1 and N >= 2:
        print(-1)
    elif c == 0 and s==1 and N==1:
        print(0)
    else:
        print(ans)
    
    



Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		try(Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();// 日にち
			int K = sc.nextInt();// 決められたパスタ
			long[][][] dp = new long[N+1][4][3];
			// 何日までに何のパスタを何日連続して食べている がn通り
			// dp[i][j][2] = dp[i-1][j][1]
			// dp[i][j][1] = dp[i-1][j以外][1]+dp[i-1][j以外][2]
			
			int[] key = new int[N+1];
			for(int i=0; i<N+1; i++) {
				key[i] = 0;
			}
			for(int i=0; i<K; i++) {
				int date = sc.nextInt();
				key[date] = sc.nextInt();
			}
			
			for(int i=1; i<N+1; i++) {
				for(int j=1; j<4; j++){
					for(int l=1; l<3; l++) {
						dp[i][j][l] = 0;
					}
				}
			}
			
			if(key[1] == 1) {
				dp[1][1][1] = 1;
			}
			else if(key[1] == 2) {
				dp[1][2][1] = 1;
			}
			else if(key[1] == 3) {
				dp[1][3][1] = 1;
			}
			else if(key[1] == 0) {
				dp[1][1][1] = 1;
				dp[1][2][1] = 1;
				dp[1][3][1] = 1;
			}
			
			for(int n=2; n<N+1; n++) {
				if(key[n] == 1) {
					dp[n][1][2] = dp[n-1][1][1]%10000;
					dp[n][1][1] = (dp[n-1][2][1]+dp[n-1][2][2]+dp[n-1][3][1]+dp[n-1][3][2])%10000;
				}
				else if(key[n] == 2) {
					dp[n][2][2] = dp[n-1][2][1]%10000;
					dp[n][2][1] = (dp[n-1][1][1]+dp[n-1][1][2]+dp[n-1][3][1]+dp[n-1][3][2])%10000;
				}
				else if(key[n] == 3) {
					dp[n][3][2] = dp[n-1][3][1]%10000;
					dp[n][3][1] = (dp[n-1][2][1]+dp[n-1][2][2]+dp[n-1][1][1]+dp[n-1][1][2])%10000;
				}
				else {
					dp[n][1][2] = dp[n-1][1][1]%10000;
					dp[n][1][1] = (dp[n-1][2][1]+dp[n-1][2][2]+dp[n-1][3][1]+dp[n-1][3][2])%10000;
					dp[n][2][2] = dp[n-1][2][1]%10000;
					dp[n][2][1] = (dp[n-1][1][1]+dp[n-1][1][2]+dp[n-1][3][1]+dp[n-1][3][2])%10000;
					dp[n][3][2] = dp[n-1][3][1]%10000;
					dp[n][3][1] = (dp[n-1][2][1]+dp[n-1][2][2]+dp[n-1][1][1]+dp[n-1][1][2])%10000;
				}
			}
			
			long ans = 0;
			for(int i=1; i<4; i++) {
				for(int j=1; j<3; j++) {
					ans += dp[N][i][j];
				}
			}
			System.out.println(ans%10000);
		}
	}

}




Measured memory_bytes: 26560
def fer(n, r, p):
    # calculate n_C_k mod p
    # a,pが互いに素のとき a ^ (p-2) = a ^ -1 (mod p)
    # これを使って分母のmodを高速に計算できる
    x, y = 1, 1
    for i in range(r):
        x *= (n - i)
        x %= p
        y *= (i + 1)
        y %= p
    # x -> n * (n-1) * ... * (n-r+1)
    # y -> 1 * 2 * ... * r
    return x * pow(y, p-2, p) % p



def main():
    s = int(input())
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(1, s // 3 + 1):
        m = s - 3 * i
        ans += fer(m + i - 1, i - 1, mod)
        ans %= mod

    ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mod_div(ll a,ll b){
  ll tmp=MOD-2,c=b,ret=1;
  while(tmp>0){
    if(tmp&1){
      ret*=c;ret%=MOD;
    }
    c*=c;c%=MOD;tmp>>=1;
  }
  return a*ret%MOD;
}
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b;
  cin>>n>>a>>b;
  vi num(222222);
  ll now = 1;
  vi bin(60);
  bin[0] = 2;
  for(int i=1;i<60;i++)
    bin[i] = (bin[i-1]*bin[i-1])%MOD;
  ll anum = 1;
  for(ll i = 0;i < a;i++){
    anum*=n-i;anum%=MOD;
    anum = mod_div(anum,i+1);
  }
  ll bnum = 1;
  for(ll i = 0;i < b;i++){
    bnum*=n-i;bnum%=MOD;
    bnum = mod_div(bnum,i+1);
  }
  ll hoge = 1;
  for(int i=0;i<60;i++){
    if(BITLE(i)&n){
      hoge *= bin[i];
      hoge %=MOD;
    }
  }
  cout<<(ll)((ll)MOD+MOD+MOD+hoge-anum-bnum-1)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 2048
import * as fs from 'fs'

export function Main(input: string) {
  const lines = input.split("\n");
  const K = parseInt(lines[0]);
  const S = lines[1];
  
  if(S.length <= K) {
    console.log(S);
  }else {
    console.log(S.slice(0, K) + "...") 
  }
}

Main(fs.readFileSync("/dev/stdin", "utf-8"));

Measured memory_bytes: 29552
l, r = map(int,input().split())
min = 2018
if r - l > 673:
    print(0)
else:
    for i in range (l, r):
        for j in range (i + 1, r + 1):
            if min > i * j % 2019:
                min = i * j % 2019
    print(min)
            


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string NO = "IMPOSSIBLE";

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


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int N,M,a[100010],K,b[100010];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;

    int i,odd=0;
    for (i=1; i<=M; i++){
        cin >> a[i];
        if (a[i]%2) odd++;
    }

    if (odd>2){
        cout << "Impossible\n";
        return 0;
    }

    sort(a+1,a+M+1,[](int x, int y){return x%2<y%2; });
    if (a[M-1]%2) swap(a[1],a[M-1]);
    for (i=1; i<=M; i++)
        cout << a[i] << " ";
    cout << "\n";

    if (M==1){
        if (a[1]==1) K=1,b[1]=1;
        else K=2,b[1]=a[1]-1,b[2]=1;
    }
    else {
        b[++K]=a[1]+1;
        for (i=2; i<M; i++)
            b[++K]=a[i];
        if (a[M]!=1) b[++K]=a[M]-1;
    }

    cout << K << "\n";
    for (i=1; i<=K; i++)
        cout << b[i] << " ";
    cout << "\n";
    return 0;
}


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

using namespace std;

int main() {
	// your code goes here
	int n;
	cin >> n;
	vector<vector<double> > dp(n+1, vector<double>(n+1, 0.0));
	dp[0][0]=1.0;
	for(int i=0; i<n; i++){
		double p;
		cin >> p;
		for(int j=0; j<i+1; j++){
			dp[i+1][j+1]=dp[i+1][j+1]+((double)dp[i][j]*p);
			dp[i+1][j]=dp[i+1][j]+((double)dp[i][j]*(1.0-p));
		}
	}
	double ans=0.0;
	for(int j=(n/2)+1; j<=n; j++)
		ans+=(double)dp[n][j];
	cout << fixed;
	cout << setprecision(11) << ans << endl;
	return 0;
}

Measured memory_bytes: 70656
S =raw_input()
L = S.split()

a = L[0]
b = L[1]
c = L[2]

a = int(a)
b = int(b)
c = int(c)
l = [a,b,c]
    
min_1 = min(a,b,c)
# print l.remove(min_1)
l.remove(min_1)

min_2 = min(l)

l.remove(min_2)

min_3 = l[0]

min_1 = str(min_1)
min_2 = str(min_2)
min_3 = str(min_3)

print min_1+' '+min_2+' '+min_3

Measured memory_bytes: 6420
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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

    int N; cin >> N;
    vi A(N+1); FOR(i, 1, N+1) cin >> A[i];

    vi b(N+1, 0);
    int m = 0;
    for (int i = N; i >= 1; i--) {
        int sum = 0;
        for(int j=i; j<=N; j+=i){
            sum += b[j];
        }
        if (sum%2 != A[i]) {
            b[i] = 1;
            m++;
        }
        else b[i] = 0;
    }

    cout << m << endl;
    if (m > 0) {
        bool first = true;
        FOR(i, 1, N+1) {            
            if (b[i]==1) {
                if (first) {
                    cout << i;
                    first = false;
                } else cout << " " << i;
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, i;
    cin >> n;
    vpi a(n);
    for (i=0;i<n;i++){
        int t;
        cin >> t;
        a[i] = make_pair(t, i);
    }
    sort(a.begin(), a.end());
    int max_a=a[n-1].first, sec_a=a[n-2].first;
    
    vi ans(n);
    for (i=0;i<n;i++){
        if (a[i].first == max_a) ans[a[i].second] = sec_a;
        else ans[a[i].second] = max_a;
    }
    for (int i: ans) cout << i << endl;;
 }


Measured memory_bytes: 3968
#include <stdio.h>
#include <math.h>

int main(void)
{
  long a, b;
  scanf("%ld %ld", &a, &b);
  
  long gcd;
  long m = a, d = b;
  while (d > 0){
    long temp = d;
    d = m % d;
    m = temp;
  }
  gcd = m;
  
  if (gcd == 1){
    printf("%d\n", 1);
    return 0;
  }
  
  long count = 0;
  for (long i = 2; i <= sqrt(gcd); i++){
    if (gcd % i == 0){
      count++;
      while (gcd % i == 0){
        gcd /= i;
      }
    }
  }
  
  if (gcd > 1) count++;
  
  printf("%ld\n", count + 1);
  return 0;
}


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

int main() {
	int64_t n;
	cin >> n;
	int64_t ans = 0;
	//nが0,1だと1 ans=0
	if (n <= 1)ans = 0;
	//nが2以上の奇数だと、f(n)=1*3*5*...*n-2*n ans=0
	else if (n % 2 == 1)ans = 0;
	//nが2以上の偶数だと、f(n)=2*4*6*...*n-2*n ans=(n/10)+(n/50)+(n/250)+...
	else {
		int64_t x = 10;
		while (n >= x) {
			ans += n / x;
			x *= 5;
		}
	}
	cout << ans << endl;
}


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

int main(void)
{
	int a=0,b=0,c=0,d=0;
	
	scanf("%d %d",&a,&b);
	c=a*b;
	d=2*(a+b);
	printf("%d %d\n",c,d);
	
	return 0;
}

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

int main() {
	int N;
	int ans = INF;
	
	cin >> N;
	REP(i, N) {
		int a;
		scanf("%d", &a);
		
		int cnt = 0;
		while (a % 2 == 0) a /= 2, cnt++;
		chmin(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

#UnionFind

Group=[i for i in range(N+1)]#グループ分け.Group[i]=jのときiとjは同じグループ

def find(x):#find(a)=find(b)のとき同じグループ
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y,ranksum):  # xとyが同じグループになるよう更新
    if find(x) != find(y):
        ranksum+=(rank[find(x)]+rank[find(y)])**2-(rank[find(x)]**2+rank[find(y)]**2)
        rank[find(x)]=rank[find(y)]=rank[find(x)]+rank[find(y)]
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))

    return ranksum
        

rank=[1]*(N+1)
ranksum=N
MAX=N*(N-1)//2
ANS=[MAX-(ranksum-N)//2]

for x,y in B[::-1]:
    ranksum=Union(x,y,ranksum)
    #print(Group,rank,ranksum)
    ANS.append(MAX-(ranksum-N)//2)

#print(ANS)
ANS.reverse()
for a in ANS[1:]:
    print(a)


Measured memory_bytes: 38116
#include <cmath>
#include <cstdio>
#include <complex>
#include <algorithm>
using namespace std;
const double pi = acos(-1);
int n, val, cnt, sz = 4194304, p[4194333], d[4194333], c[4194333];
complex<double> a[4194333], b[4194333], y[4194333];
void dft(complex<double> *x, bool inv) {
	for (int i = sz >> 1; i >= 1; i >>= 1) {
		complex<double> bs(cos(2.0 * pi * i / sz), (inv ? -1.0 : 1.0) * sin(2.0 * pi * i / sz)), w = 1;
		for (int j = 0; 2 * j < sz; j += i) {
			for (int k = 0; k < i; k++) {
				y[j + k] = x[2 * j + k] + w * x[2 * j + k + i];
				y[j + k + sz / 2] = x[2 * j + k] - w * x[2 * j + k + i];
			}
			w *= bs;
		}
		for (int j = 0; j < sz; j++) x[j] = y[j];
	}
	if (inv) for (int i = 0; i < sz; i++) x[i] /= sz;
}
int main() {
	scanf("%d", &n);
	int s = 2 * n * n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &val);
			a[2 * i * n + j] = val;
			b[s - (2 * i * n + j) - 1] = val;
			cnt += val;
		}
	}
	dft(a, false);
	dft(b, false);
	for (int i = 0; i < sz; i++) a[i] *= b[i];
	dft(a, true);
	for (int i = 0; i < sz; i++) c[i] = a[i].real() + 0.5;
	double sum = 0.0;
	for (int i = 0; i < 2 * s; i++) {
		int ri = i - s + 1;
		int rx = ((ri + s) % (2 * n) < n ? (ri + s) % (2 * n) : 2 * n - (ri + s) % (2 * n));
		int ry = ((ri + s + n) / (2 * n) >= n ? (ri + s + n) / (2 * n) - n : n - (ri + s + n) / (2 * n));
		d[i] = rx * rx + ry * ry;
		sum += sqrt(d[i]) * c[i];
		p[i] = i;
	}
	sort(p, p + 2 * s, [](int i, int j) { return d[i] < d[j]; });
	printf("%.12lf\n", sum / cnt / (cnt - 1));
	long long cur = 0; int counter = 10000;
	for (int i = 1; i <= 2 * s; i++) {
		cur += c[p[i - 1]];
		if (i == 2 * s || d[p[i]] != d[p[i - 1]]) {
			long long realcur = (cur - (d[p[i - 1]] == 0 ? cnt : 0)) / 2;
			if(realcur > 0 && counter-- > 0) printf("%d %lld\n", d[p[i - 1]], realcur);
			cur = 0;
		}
	}
	return 0;
}


Measured memory_bytes: 248932