akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fi first
#define se second
#define PI acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define lowbit(x) x & (-x)
using namespace std;
const int maxx = 1e6 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, m, T, q;
int pre[maxx], a[maxx];

int main(){
	int i, j, k;
	scanf("%d %d %d", &n, &k, &q);
	for(i = 1; i <= n; i++) a[i] = k;
	for(i = 1; i <= q; i++){
		scanf("%d", &m);
		a[m]++;
	}
	for(i = 1; i <= n; i++) a[i] -= q;
	for(i = 1; i <= n; i++){
		if(a[i] <= 0) puts("No");
		else puts("Yes");
	}
	return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B < C + D) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

using edge = struct {ll to, cost;};
const int limit = 100010;
vector<edge> graph[limit];

bool visited[limit];
ll value[limit];

void dfs(ll v, ll c) {
	visited[v] = true;
	value[v] = c;
	for (auto &e : graph[v]) {
		if (visited[e.to]) continue;
		dfs(e.to, c + e.cost);
	}
}

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

	rep(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		graph[a].push_back({b, c});
		graph[b].push_back({a, -c});
	}

	rep(i, n) if (visited[i] == false) dfs(i, 0LL);

	bool ok = true;
	rep(v, n) for (auto &e : graph[v]) if (value[v] + e.cost != value[e.to]) ok = false;
	puts(ok ? "Yes" : "No");

	return 0;
}

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

using namespace std;

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0, K) << "..." << endl;
  }
  return 0;
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var list = Console.ReadLine().Split(' ');
        var ass = new int[n];
        for (int i = 0; i < ass.Length; ++i)
            ass[i] = int.Parse(list[i]);

        var answer = new int[n];

        int count = 0;
        int prev = n - 1, now = 0, next = 1;

        while (true)
        {
            var a = ass[now] - ass[prev];
            if (a > 0)
            {
                ass[now] -= a;
                ass[next] -= a;
                answer[next] += a * 2;
            }

            var b = ass[now] - ass[next];
            if (b > 0)
            {
                ass[now] -= b;
                ass[prev] -= b;
                answer[now] += b * 2;
            }

            if (a == 0 && b == 0)
            {
                if (++count == n)
                    break;
            }
            else
                count = 0;

            prev = now;
            now = next;
            if (++next == n)
                next = 0;
        }

        for (int i = 0; i < answer.Length; ++i)
            answer[i] += ass[i];

        Console.WriteLine(string.Join(" ", answer));
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 30300
N = int(input())
S = [input() for _ in range(N)]
R={}
R["AC"] = 0
R["WA"] = 0
R["TLE"] = 0
R["RE"] = 0

for i in S:
  R[i] += 1

print("AC x", R["AC"])
print("WA x", R["WA"])
print("TLE x", R["TLE"])
print("RE x", R["RE"])

Measured memory_bytes: 79124
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#include <utility>
//#define REP(i,n) for(int i = 0;i < n ;i++)
//#define FOR(i,m,n) for(int i= m ;i<n;i++)
#define PI acos(-1);
#define max_n 100
#define max_w 10000
using namespace std;

long long int N,W;
vector<int>v(max_n),w(max_n);
long long int dp[max_n+1][max_w+1];
int rec(int i,int j){//i=?????° j=??????

  if(dp[i][j]>=0)return dp[i][j];
  int res;
  if(i==N)res=0;
  else if(j<w[i])res=rec(i+1,j);
  else{
    res=max(rec(i+1,j),rec(i+1,j-w[i])+v[i]);
  }
  dp[i][j]=res;
  return res;
}

int main(void){
  cin >> N >> W;
  long long int k;
  memset(dp,-1,sizeof(dp));
  for(k=0;k<N;k++){
    cin >> v[k] >> w[k];
  }
  cout << rec(0,W) << endl;

  return 0;
}

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
int a[N];

int main()

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

    int n, m, ans = 1, tmp = INT_MAX;

    cin >> n >> m;

    pair <int, int> p [m];

    for (int i = 0; i < m; i++) {

        cin >> p[i].first >> p[i].second;

        tmp = min(tmp, p[i].second);
    }

    sort(p, p+m);

    for (int i = 0; i < m; i++) {

        if (p[i].first >= tmp) {

            ans++;

            tmp = INT_MAX;

            for (int j = i; j < m; j++) {

                tmp = min(tmp, p[j].second);
            }
        }
    }

    cout << ans;

    return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n;
ll a[maxn];
ll tot;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
cin>>n;
  for (int i=0; i<n; i++) cin>>a[i];
  for (int i=0; i<n; i++) tot += a[i];
  ll cur=0;
  ll ans = 2e18;
  for (int i=0; i<n-1; i++) {
    cur += a[i];
    ans = min(abs(cur-(tot-cur)),ans);
  }
  out(ans);
  

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<set>
#define ll long long
using namespace std;
int main()
{
    int a[100000];
    int k=0;
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
            a[k++]=i*j;
    sort(a,a+k);
    int n,flag=0;
    scanf("%d",&n);
    for(int i=0;i<k;i++)
    {
        if(n==a[i])
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;

}


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

int main() {

    int K;
    cin >> K;

    rep(i, K){
        cout << "ACL";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>

#define MOD 998244353

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

typedef long long int64;

int main(void){
    int N=0,ans=0,max=0;
    scanf("%d",&N);
    
    int H[N];

    for(int i=0;i<N;i++){
        scanf("%d",&H[i]);
    }

    for(int i=0;i<N;i++){
        if(max<=H[i]) ans++;
        max=MAX(max,H[i]);
    }

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

Measured memory_bytes: 128
import string

n = int(input())
S = [input() for i in range(n)]

D = {}

j = 0
for i in range(ord('a'), ord('z')+1):
    D[chr(i)] = j
    j += 1

LL = [float("inf")] * 26

for i in range(n):
    L = [0] * 26
    for j in range(len(S[i])):
        L[D[S[i][j]]] += 1
    for j in range(26):
        LL[j] = min(LL[j], L[j])
    #print(LL)

ans = ""
j = 0
for i in range(ord('a'), ord('z')+1):
    ans += chr(i) * LL[j]
    j += 1

print(ans)

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

#define ll double 
ll dp[301][301][301];
ll solve(int one,int two,int three,int &n)
{
    if(one<0 or two<0 or three<0)
    {
        return 0;
    }
    if(one==0 and two==0 and three==0)
    {
        return 0;
    }
    if(dp[one][two][three]>0)
    {
        return dp[one][two][three];
    }
    ll remaining=one+two+three;
    ll exp=n+one*solve(one-1,two,three,n)+two*solve(one+1,two-1,three,n)+three*solve(one,two+1,three-1,n);
    dp[one][two][three]=exp/remaining;
    return dp[one][two][three];
}


int main()
{
    int n;
    cin>>n;
    int d=0;
    int one =0,two=0,three=0;
    for(int i=0;i<n;i++)
    {
        cin>>d;
        if(d==1)
        {
            one++;
        }
        else if(d==2)
        {
            two++;
        }
        else
        three++;
    }
    //memset(dp,-1,sizeof dp);
    cout<<fixed<<setprecision(10)<<solve(one,two ,three,n);
    return 0;
}

Measured memory_bytes: 111132
#include <bits/stdc++.h>
using namespace std;
 
long int gcd(long int a,long int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

bool Pri(long int num)
{
    if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (long int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  long int a,b,c,n,i,kotae=1;
  cin>>a>>b;
  c=gcd(a,b);
  n=sqrt(c);
  if(c==1){
    cout<<kotae;
    return 0;
  }
  if(Pri(c)){
    kotae++;
    cout<<kotae;
    return 0;
  }
  for(i=2;i<=n;i++){
    if(c%i==0){
      if(Pri(i)){
        kotae++;
      }
      if(Pri(c/i)){
        kotae++;
      }
    }
  }
  cout<<kotae;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
#define MOD 1000000007
#define MAX 2020
int f[MAX<<1][MAX][2],s[MAX],n,m,K,ans;
void add(int &x,int y){x+=y;if(x>=MOD)x-=MOD;}
int main()
{
	cin>>n>>m>>K;m-=1;K-=1;
	f[0][0][0]=1;
	for(int i=1;i<=max(n,m)<<1;++i)
	{
		for(int j=0;j<=n;++j)s[j+1]=((s[j]+f[i-1][j][0])%MOD+f[i-1][j][1])%MOD;
		for(int j=0;j<=n;++j)
		{
			f[i][j][0]=(s[j+1]-s[j]+MOD)%MOD;
			int k=max(0,j-K);
			f[i][j][1]=(s[j]-s[k]+MOD)%MOD;
		}
		for(int j=0;j<=n;++j)
			if(j%K==n%K&&(i*K-j)%K==m%K&&i*K-j<=m)
				add(ans,f[i][j][1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 63744
/* ex 5_4
  bonbonc */

#include<stdio.h>
#include<string.h>

int main(void){
    int max=0, count=0;//暫定の最長ACGT列の長さと計測途中のACGT列の長さを格納する変数
    char seq[11], *ptr;//入力の最大の長さが10なので長さ10+1のchar配列を用意

    scanf("%s",seq);//入力を受け取る
    ptr = seq;//seqの先頭のアドレスをptrに渡す

    while(*ptr != '\0'){//文字列の最後まで繰り返す
        if (*ptr == 'A' || *ptr =='C' || *ptr == 'G' || *ptr == 'T'){//ptrがACGTのどれかだったら、countをインクリメント
            count++;
        }else{
            count = 0;//*ptrがACGTでなければcountを0にする
        }
        if (max < count) {
            max = count;//countがmaxを最大値を上回っているときmaxをcountにする
        }
        ptr++;//ポインタを進める
    }

    printf("%d\n",max);//最長のACGT列の長さを出力
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
vector<long long> fact_inv, inv;
void init_nCk(ll k){
  fact_inv.resize(k+5);
  inv.resize(k+5);
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(ll i=2;i<k+5;i++){
    inv[i]=MOD-inv[MOD % i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
ll nCk(ll n,ll k){
  assert(!(n<k));
  assert(!(n<0||k<0));
  ll ans=1;
  for(ll i=n;i>=n-k+1;i--){
    ans*=i;
    ans%=MOD;
  }
  return ans*fact_inv[k]%MOD;
}
int main() {
  ll N,a,b,x=1,d,e;
  cin>>N>>a>>b;
  for(ll i=0;i<N/10;i++){
    x*=1024;
    x%=MOD;
  }
  for(ll i=0;i<N%10;i++){
    x*=2;
    x%=MOD;
  }
  if(a<=N){init_nCk(a);d=nCk(N,a);x-=d;}
  if(b<=N){init_nCk(b);e=nCk(N,b);x-=e;}
  cout<<(x+2*MOD)%MOD-1<<endl;
}

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

typedef long long int ll;
const ll N_MAX = 1E+12;
const int E_MAX = 50;
vector<int> num;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    num.resize(E_MAX);
    num[0] = 0;
    for(int i = 1; i < E_MAX; i++){
        num[i] = num[i-1] + i;
    }
    for(ll i = 2; i * i <= n; i++){
        if (i * i > n)break;
        ll e = 0;
        while(n % i == 0){
            n /= i;
            e++;
        }
        vector<int>::iterator it = lower_bound(num.begin(), num.end(), e);
        int pa = it - num.begin();
        if (*it != e)pa--;
        ans += pa;
    }
    if (n > 1)ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 55;
const double EPS = 1e-10;

struct edge{
  ll to;
  ll cap;
  ll rev;
  edge(){};
  edge(ll to, ll cap, ll rev){
    this->to = to;
    this->cap = cap;
    this->rev = rev;
  }
};

vector<edge> G[400];
ll level[400];
ll iter[400];

void add_edge(ll from, ll to, ll cap){
  G[from].push_back(edge(to, cap, G[to].size()));
  G[to].push_back(edge(from, 0,G[from].size() - 1));
}

void bfs(int s){
  memset(level, -1, sizeof(level));
  level[s] = 0;
  queue<int> que;
  que.push(s);
  while(!que.empty()){
    ll v = que.front();que.pop();
    rep(i, (int)G[v].size()){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0) {
	level[e.to] = level[v] + 1;
	que.push(e.to);
      }
    }
  }
}

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

ll max_flow(int s, int t){
  ll flow = 0, f;
  while(true){
    bfs(s);
    if(level[t] < 0) break;
    memset(iter, 0, sizeof(iter));
    while((f = dfs(s, t, INF)) > 0) flow += f;
  }
  return flow;
}

string days[] = {
  "Monday",
  "Tuesday",
  "Wednesday",
  "Thursday",
  "Friday",
  "Saturday",
  "Sunday",
};

int main(){
  ll N, c;
  ll W, need;
  string str;

  while(cin >> N >> W && (N || W)){
    rep(i, 400) G[i].clear();
    ll sum = 0;
    ll s = 7 + N;
    ll t = s + 1;
    rep(i, 7) add_edge(s, i, W);
    rep(i, N){
      cin >> need >> c;
      sum += need;
      add_edge(7 + i, t, need);
      rep(j, c){
	cin >> str;
	rep(k, 7) if(days[k] == str) add_edge(k, 7 + i, INF);
      }
    }
    ll num = max_flow(s, t);
    if(num == sum) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = 0;
    int cnt = 1;
    for(int i = 0; i < n; i++){
        sum += a[i];
        if(sum > x){
            break;
        }else{
            cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 #define ll long long int
 using namespace std;
 int main()
 {
    ll n,w;
    cin>>n>>w;
    ll x,y;
    vector<pair<ll,ll>> v;
    for(ll i=0;i<n;i++)
    {
        cin>>x>>y;
        v.push_back({x,y});
    }
    ll dp[n+1][w+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=w;j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else
                if(v[i-1].first<=j)
                    dp[i][j]=max((v[i-1].second+dp[i-1][j-v[i-1].first]),dp[i-1][j]);
                else
                    dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w]<<endl;
 }

Measured memory_bytes: 82468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, K;
void func()
{
 cin >> N >> K;
 double ans = 0;
 rep(i, 1, N + 1)
 {
  int j = i, count = 0;
  while (j < K)
  {
   ++count;
   j *= 2;
  }
  int tmp = pow(2, count);
  ans += (1.0 / (tmp * N));
 }
 printf("%.10lf\n", ans);
}
int main()
{
 func();
}

Measured memory_bytes: 4228
#include<bits/stdc++.h>
#define int long long int
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define DEBUG false
#define b begin()
#define e end()
#pragma GCC optimize "trapv"

const int mod=998244353; 
const int m=1073741824;
using namespace std;

int32_t main()
{
 nitro;
     long double r;
     cin>>r;
     cout<<2*PI*r;
return 0;
}


Measured memory_bytes: 3820
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        
        int[][] A = new int[n][m];
        int[][] B = new int[m][l];
        
        for (int i = 0; i < n ; i++) {
            for (int j = 0; j < m; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < l; j++) {
                B[i][j] = sc.nextInt();    
            }
        }
        
        long[][] result = new long[n][l];
        
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                for (int k = 0; k < m; k++) {
                    result[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < l; j++) {
                if (j != l - 1) {
                    System.out.printf("%d ", result[i][j]);
                }
                else {
                    System.out.printf("%d\n", result[i][j]);
                }
            }
        }
    }
}


Measured memory_bytes: 65384
// Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！
 
//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
//  "atoi" "atof"などのキャスト、"rand" 疑似乱数を発生させるヘッダーファイルの読み込み
#include <stdlib.h>
//  "strcpy" "strcat"などの文字列操作や"strlen"文字列長さ取得などを行うヘッダーファイルの読み込み
#include <string.h>
//  "sqrtl" "fmax"などの数値操作を行うヘッダーファイルの読み込み
#include <math.h>

 
int main(void){
  //  char text[256];
//    int no[256];
  //  int yuukoudo[500][500];
    char s[256] = {};
    int ok[100001] = {};
    int x,y,z;
    int i,j;
    int pi;
    int n,m;
    int ng[100001] = {};
    int flg = 0;
    int ngcount = 0;
    int count = 0;
    scanf("%d %d",&n,&m);
    for (i = 0; i < m; i++){
       scanf("%d %s",&pi,s);
       if (s[0] == 'A' && s[1] == 'C'){
           ok[pi] = ok[pi] + 1;
           if (ok[pi] == 1){
                ngcount = ngcount + ng[pi]; 
           }
       }else{
           if (ok[pi] == 0){
               ng[pi] = ng[pi] + 1;
           }
       }
    }
    for (i = 0; i <= n; i++){
        if (ok[i] >= 1){
            count++;
        }
    }
    printf("%d %d",count,ngcount);
   
}



 

Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main() {
    int m1,d1,m2,d2;
    cin>>m1>>d2;
    cin>>m2>>d2;
    if(m1!=m2){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> K(N);
  vector<vector<int>> A(N);
  for(int i=0;i<N;i++){
    cin>>K.at(i);
    A.at(i).resize(K.at(i));
    for(int j=0;j<K.at(i);j++){
      cin>>A.at(i).at(j);
    }
  }

  vector<int> count(M);
  for(int i=0;i<N;i++){
    for(int j=0;j<K.at(i);j++){
      count.at(A.at(i).at(j)-1)++;
    }
  }
  int ans=0;
  for(int i=0;i<M;i++){
    if(count.at(i)==N){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
    ll N, K;
    cin >> N >> K;

    ll ans = 0;
    rep(b, 1, N+1){
        ll num = max(0LL, (b-1) - K + 1) * (ll)(N/b);
        //cerr << b << " " << num << " ";
        if(N % b != 0){
            ll rem = N - (ll)(N/b) * b;
            if(K == 0) num += max(0LL, rem - K);
            else num += max(0LL, rem - K + 1);
        }
        //cerr << num << endl;
        ans += num;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

int dist[305][305];
int dist2[305][305];

vector<vector<int>>wayConnect(100000);
vector<vector<int>>subwayConnect(100000);

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	int A, B;
	cin >> A >> B;

	bool isEnable = A <= 9 && B <= 9;
	int ans = isEnable ? A * B : -1;
	cout << ans << endl;
}

Measured memory_bytes: 9600
import Data.List (group)

solve [_] cnt upper = cnt
solve [x0,x1] cnt upper
  | x0 < x1 && upper = cnt
  | x0 > x1 && not upper = cnt
  | otherwise = cnt+1
solve (x0:x1:x2:xs) cnt upper
  | x0 < x1 && upper = solve (x1:x2:xs) cnt upper
  | x0 > x1 && not upper = solve (x1:x2:xs) cnt upper
  | otherwise = solve (x2:xs) (cnt+1) (x1<x2)

main = do
  n <- read <$> getLine :: IO Int
  as <- map head.group.map read.words <$> getLine :: IO [Int]
  print $  solve as 1 (head as<(head.tail) as)


Measured memory_bytes: 38268
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d ",n)
#define lpri(n) printf("%lld\n",n)
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
#define pii pair<int,int> 
#define all(x) (x).begin(),(x).end()
const int N=2e6+5;
const ll M=1e9+7;
const ll inf=1e18+5;

int main()
{
	var(n);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scn(a[i]);
		a[i]-=i+1;
	}
	sort(a,a+n);
	ll ans = 0;
	for(int i=0;i<n;i++)
		ans += abs(a[i]-a[n/2]);
	lpri(ans);
}

Measured memory_bytes: 1024
"use strict";
function Main(input) {
  let args = input.split('\n');
  let n = parseInt(args.shift());
  let a = args.shift().split(' ')
  .map(m => parseInt(m));
  let minusCount= a.reduce((ac, cv) => {
    return (ac * cv) < 0 ? -1 : 1;
  });
  a = a.map(m => m < 0 ? -m : m)
  .sort((a, b) => a - b);
  let max = a.reduce((ac, cv) => ac + cv);
  if (minusCount < 0) {
    max -= a.shift() * 2;
  }
  console.log(max);
}


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

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

int  st[26];
int  ts[26];

int main(){
    string s, t;
    cin >> s >> t;
    bool flag = true;
    for(int i=0; i<s.size(); i++){
        int intS = s[i] - 'a';
        int intT = t[i] - 'a';
        if(st[intS] == 0) st[intS] = intT;
        else if(st[intS] != intT) flag = false;

        if(ts[intT] == 0) ts[intT] = intS;
        else if(ts[intT] != intS) flag = false;
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 776
#define _USE_MATH_DEFINES

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	double H = sin(M_PI*C / 180)*B;
	double S = A*H*0.5;
	double c = sqrt(A*A + B*B - 2*A*B*cos(M_PI*C / 180));

	cout << OF64 << S << endl;
	cout << OF64 << A + B + c << endl;
	cout << OF64 << H << endl;
	return 0;
}


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

long long n, a, b, x[100001], ans = 0;

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

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

		if (i >= 1){
			if ((x[i] - x[i - 1])*a >= b){
				ans += b;
			}
			else{
				ans += (x[i] - x[i - 1])*a;
			}
		}
	}

	cout << ans;
}

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

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

bool judge(int A)
{
  if(1<=A&&A<=12)
  {
	return true;
  }
  else
    return false;
}


int main()
{
  int S;
  cin>>S;
  int A,B;
  B=S%100;
  A=(S-B)/100;
  if(judge(A)&&judge(B)){
    cout<<"AMBIGUOUS";
  }
  else if(judge(A)&&!(judge(B))){
    cout<<"MMYY";
  }
  else if(judge(B)&&!(judge(A))){
    cout<<"YYMM";
  }
  else
    cout<<"NA";

  
}


Measured memory_bytes: 256
#include <stdio.h>
#define D 0

int main(void) {
    int N, X, Y, a, b, c, d, e, x[2005], i, j;
    scanf("%d%d%d", &N, &X, &Y);
    for (i=1; i<=N-1; i++) x[i]=0;
    for (i=1; i<=N-1; i++) {
        for (j=i+1; j<=N; j++) {
            d=0;
            if ((i>=Y || j<=X) && d==0) {
                if (D) printf("(%d, %d): Q", i, j);
                e=j-i;
                d=1;
            }
            if (i<=X && j>=Y && d==0) {
                if (D) printf("(%d, %d): W", i, j);
                e=(X-i)+1+(j-Y);
                d=1;
            }
            if (i<=X && (X<j && j<Y) && d==0) {
                if (D) printf("(%d, %d): E", i, j);
                a=j-i;
                b=(X-i)+1+(Y-j);
                if (a>b) c=b;
                else c=a;
                e=c;
                d=1;
            }
            if ((X<i && i<Y) && d==0) {
                if (X<j && j<Y && d==0) {
                    if (D) printf("(%d, %d): R", i, j);
                    a=j-i;
                    b=(i-X)+1+(Y-j);
                    if (a>b) c=b;
                    else c=a;
                    e=c;
                    d=1;
                }
                if (j==Y && d==0) {
                    if (D) printf("(%d, %d): T", i, j);
                    a=j-i;
                    b=(i-X)+1+(Y-j);
                    if (a>b) c=b;
                    else c=a;
                    e=c;
                    d=1;
                }
                if (j>Y && d==0) {
                    if (D) printf("(%d, %d): Y", i, j);
                    a=j-i;
                    b=(i-X)+1+(j-Y);
                    if (a>b) c=b;
                    else c=a;
                    e=c;
                    d=1;
                }
            }
            if (D) printf(" %d\n", e);
            x[e]++;
        }
    }
    for (i=1; i<=N-1; i++) {
        printf("%d", x[i]);
        if (i!=N-1) printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>

using namespace std;

long long int n,m=0;

int main(){
    scanf("%lld",&n);
    while(m*m<=n){
        m++;
    }
    printf("%lld\n",(m-1)*(m-1));
}


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


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


void solve() {
	string s; cin >> s;
	int a = 0, b = 0;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == '0') a++; else b++;
		}
		else {
			if (s[i] == '1') a++; else b++;
		}
	}
	cout << min(a,b) << endl;
}

int main() {


	solve();


	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
# define ll long long
ll help(ll x,ll y,ll z){
	return (pow(x,2) +pow(y,2) + pow(z,2) + x*y + y*z + x*z);
}

void func(vector<int> &v,ll n,ll x,ll y,ll z,map<pair<ll,pair<ll,ll> >,bool > &m){
	if(m.find({x,{y,z}})!=m.end()) return;
		ll t=help(x,y,z);
		if(t>n) return;
		m[{x,{y,z}}]=true;
		v[t]++;
	//	cout<<x<<" "<<y<<" "<<z<<" "<<t<<"\n";
		  func(v,n,x+1,y,z,m);
		  func(v,n,x,y+1,z,m);
		  func(v,n,x,y,z+1,m);
		 
}
int main() {
	ll n;cin>>n;
	vector<int> v(n+1,0);
	ll x=1,y=1,z=1;
	 map<pair<ll,pair<ll,ll> >,bool > m;
     func(v,n,x,y,z,m);
    
     for(int i=1;i<=n;i++) cout<<v[i]<<"\n";
}

Measured memory_bytes: 23144
package main
import (
	"fmt"
)
func main(){
	var n, i int
	fmt.Scan(&n)
	a:=make([]int, n)
	b:=make([]int, n)
	for i=0;i<n;i++{
		fmt.Scan(&a[i])
	}
	for i=0;i<n;i++{
		b[a[i]-1]=i+1
	}
	for i=0;i<n;i++{
		fmt.Print(b[i])
		fmt.Print(" ")
	}
}


Measured memory_bytes: 6016
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 998244353
#define fi first
#define se second
#define pii pair<int,int>
#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int pre[n+1]={0};
    int a[n];
    map<int,int>m;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[i]=x;
        //a[i]%=k;
        pre[i+1]=(pre[i]+x)%k;
        
    }
    for(int i=0;i<n;i++){
        pre[i+1]-=(i+1)%k;
        //pre[i+1]%=mod;
        pre[i+1]+=k;
        pre[i+1]%=k;
    }
    queue<int>q;
    int ans=0;
    for(int i=0;i<=n;i++){
        //cout<<pre[i]<<" ";
        if(q.size()>=k){
            m[q.front()]--;
            q.pop();
        }
        if(m.find(pre[i])!=m.end())ans+=m[pre[i]];
        //if(pre[i]==1)ans++;
        //if(a[i]==1)ans++;
        m[pre[i]]++;
        q.push(pre[i]);
        //cout<<ans<<" ";
    }
    cout<<ans;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int dp[41][401][401];

struct Y {
  int a, b, c;
};

signed main() {
  int n, m1, m2;
  cin >> n >> m1 >> m2;
  Y y[41];
  rep(i, 0, n) cin >> y[i].a >> y[i].b >> y[i].c;

  rep(i, 0, n) {
    rep(j, 1, 401) {
      rep(k, 1, 401) {
        if(dp[i][j][k]) {
          if(dp[i + 1][j + y[i].a][k + y[i].b]) dp[i + 1][j + y[i].a][k + y[i].b] = min(dp[i + 1][j + y[i].a][k + y[i].b], dp[i][j][k] + y[i].c);
          else dp[i + 1][j + y[i].a][k + y[i].b] = dp[i][j][k] + y[i].c;
          if(dp[i + 1][j][k])dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
          else dp[i + 1][j][k] = dp[i][j][k];
        }
      }
    }
    if(dp[i + 1][y[i].a][y[i].b]) dp[i + 1][y[i].a][y[i].b] = min(dp[i + 1][y[i].a][y[i].b], y[i].c);
    else dp[i + 1][y[i].a][y[i].b] = y[i].c;
  }

  int ans = 1145141919;

  rep(i, 1, 401) {
    rep(j, 1, 401) {
      if(dp[n][i][j] && (i % m1 == 0 && j % m2 == 0) && i / m1 == j / m2) {
        ans = min(ans, dp[n][i][j]);
      }
    }
  }

  if(ans == 1145141919) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 23552
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let buffer = buffer.trim();

    let mut v = Vec::new();
    for word in buffer.split_whitespace() {
        v.push(word);
    }
    v.sort();
    v.reverse();
    print!("{}", v.pop().unwrap());
    v.reverse();
    for c in v {
        print!(" {}", c);
    }
    print!("\n");
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define abs(x) (x < 0 ? -x : x) 
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int MOD = 1000000007;

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

    vector<int> A(N);
    FORO(i, N) {
        cin >> A[i];
    }
    
    int lgcd[N];
    int rgcd[N];
    lgcd[0] = A[0];
    rgcd[N - 1] = A[N - 1];
    for(int i = 1;i < N;i++) {
        lgcd[i] = __gcd(lgcd[i - 1], A[i]);
        rgcd[N - i - 1] = __gcd(rgcd[N - i], A[N - i - 1]);
    }
    int ans = max(rgcd[1], lgcd[N - 2]);
    for(int i = 1;i < N - 1;i++) {
        ans = max(ans, __gcd(lgcd[i - 1], rgcd[i + 1]));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n, b, ans = 0;
	vi a;
	cin >> n;
	rep(i, n) {
		cin >> b;
		a.pb(b);
	}
	sort(a.rbegin(), a.rend());
	rep(i, n) {
		if (i % 2 == 0) ans += a[i];
		else ans -= a[i];
	}
	cout << ans << endl;
	return 0;
}

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

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

    ll n, m;
    cin >> n >> m;

    if (n == 1 && m == 1) {
        cout << 1 << endl;
    } else if (n == 1 || m == 1) {
        cout << max(n, m) - 2 << endl;
    } else {
        cout << (n - 2) * (m - 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int get_top_digit(int x){
    int res;
    while(x > 0){
        res = x % 10;
        x /= 10;
    }
    return res;
}

int get_last_digit(int x){
    return x % 10;
}

int main(void){
    int n;
    cin >> n;
    int cnt[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cnt[i][j] = 0;
        }
    }

    for(int i=1; i<=n; i++){
        int top = get_top_digit(i);
        int last = get_last_digit(i);
        cnt[top][last]++;
    }

    int ans = 0;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            ans += cnt[i][j]*cnt[j][i];
        }
    }

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

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N = ri()
a = ri_()
b = [0] * N
for i in reversed(range(N)):
    if (a[i] + sum(b[i::i+1])) % 2 == 1:
        b[i] = 1
M = sum(b)
print(M)
if M:
    for i in range(N):
        if b[i] == 1:
            print(i + 1, end = ' ')
    print('\n', end = '')

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

int main()
{
 int a,b;cin>>a>>b;
  if((a==1 and b==2) or (a==2 and b==1)) cout<<3;
  else if((a==2 and b==3)or(a==3 and b==2)) cout<<1;
  else cout<<2;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)

if k*d <= x:
    ans = abs(x-k*d)
else:
    ans = d*(x//d)
    if (k-x//d)%2==0:
        ans = x - d*(x//d)
    else:
        ans = abs(x - d*(x//d)-d)
print(ans)


Measured memory_bytes: 9132
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;
using std::bitset;


// ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// ll pow(ll a, ll b) { ll ans = 1; while (b > 0) { if (b % 2 == 1) { ans *= a; ans %= MOD; }b /= 2; a *= a; a %= MOD; }return ans; }
// ll comb(ll a, ll b) { static constexpr ll size = 1e6; static VL fac(size); static VL finv(size); static VL inv(size); static ll n = 0; if (n > a) { return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD; }fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, a + 1) { inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; fac[i] = fac[i - 1] * (ll)i%MOD; finv[i] = finv[i - 1] * inv[i] % MOD; }n = a + 1; return comb(a, b); }
// multiset<ll> prime_decomposition(ll n) { ll i = 2; multiset<ll> table{}; while (i * i <= n) { while (n % i == 0) { n /= i;	table.emplace(i); }++i; }if (n > 1) { table.emplace(n); return table; }return table; }
//-- bit -- REP(i, (1 << n)) {REP(j, n) {cout << (1 & (i >> j));}cout << endl;}

//==============================================================================================

int main() {
	ll n;
	cin >> n;
	string ans;
	cin >> ans;
	list<char> str;
	REPC(c, ans) { str.emplace_back(c); }

	auto itr = str.begin();

	queue<list<char>::iterator> l;
	ll lCount = 0;
	for (auto itr = str.begin(); itr != str.end();) {
		if (*itr == '(') {
			l.emplace(itr);
			++itr;
		} else {
			if (!l.empty()) {
				auto dItr = l.front();
				l.pop();
				str.erase(dItr);
				itr = str.erase(itr);
			} else {
				++lCount;
				++itr;
			}
		}
	}

	ll rCount = l.size();

	REP(i, lCount) { cout << '('; }
	cout << ans;
	REP(i, rCount) { cout << ')'; }

}


Measured memory_bytes: 256
def main():
    x, k, d = map(int, input().split())
    num = abs(x)//d
    if k <= num:
        print(abs(x)-k*d)
    else:
        k -= num
        x = abs(x)-num*d
        if k%2:
            x = abs(x-d)
        print(x)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
string s;
int a,b,c,d;
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				int ans=a;
				if(i==0)ans+=b;
				else ans-=b;
				if(j==0)ans+=c;
				else ans-=c;
				if(k==0)ans+=d;
				else ans-=d;
				if(ans==7){
					cout<<a<<(i==0 ? '+' :'-')<<b<<(j==0 ? '+' :'-')<<c<<(k==0 ? '+' :'-')<<d<<"=7"<<endl;;
					return 0;
				}
			}
		}
	}
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int comp(const void *a,const void *b){
	int* p=(int*)a;
	int* q=(int*)b;
	return *p-*q;
}

int main(){
	while(1){
		int d;
		int n,m;
		int s[200000];
		int k;
		int i,j;
		int ans;
		scanf("%d",&d);
		if(d==0)return 0;
		ans=0;
		scanf("%d",&n);
		scanf("%d",&m);
		for(i=0;i<n-1;i++){
			scanf("%d",&s[i+1]);
			s[i+n+1]=s[i+1]+d;
		}
		s[0]=d;
		s[n]=2*d;
		qsort(s,2*n,sizeof(int),comp);
		int l,r,mid;
		for(i=0;i<m;i++){
			scanf("%d",&k);
			k+=d;
			l=0;
			r=2*n;
			for(j=0;j<100;j++){
				mid=(l+r)/2;
				if(abs(s[mid]-k)>abs(s[mid+1]-k))mid++;
				if(s[mid]<k)l=mid;
				if(s[mid]>k)r=mid;
			}
			ans+=abs(k-s[mid]);
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1696
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n:usize,a:usize,b:usize
   }
   if a + b > n + 1 || a * b < n {
      println!("-1");
      return;
   }
   let mut remove = a * b - n;
   for i in (1..=b).rev() {
      print!("{} ", i);
   }
   let mut start = b;
   let mut prev = b;
   let mut count = b;
   while count < n {
      start = if start + b <= start + remove {
         start + 1
      } else {
         start + b - remove
      };
      remove -= b + prev - start;
      for i in (prev + 1..=start).rev() {
         print!("{} ", i);
         count += 1;
      }
      prev = start;
   }
   println!("");
}


Measured memory_bytes: 2344
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;
 
use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;

    input!{
        s: Chars,
    }
    // let mut s: VecDeque<char> = VecDeque::from(s);
    // let mut leaved = vec![];
    // let all_num = s.len();

    // loop {
    //     // dbg!(&s);
    //     // dbg!(&leaved);
    //     if (s.len() == 0 && (leaved.iter().all_equal() || leaved.len() == 0)) || s.iter().chain(leaved.iter()).all_equal() { break; }

    //     let s1 = s.pop_front().unwrap();

    //     if !leaved.is_empty() {
    //         let l = leaved.pop().unwrap();
    //         if l != s1 { continue; }
    //         leaved.push(l);
    //     }

    //     let s2 = s.pop_front().unwrap();

    //     if s1 != s2 { continue };

    //     leaved.push(s1);
    //     s.push_front(s2);
    // }

    // println!("{}", all_num - s.len() - leaved.len())

    let mut r = 0;
    let mut b = 0;
    
    for &c in s.iter() {
        if c == '0' { r += 1 } else { b += 1 }
    }

    println!("{}", std::cmp::min(r, b) * 2)
}

fn main() {
    solve();
}


Measured memory_bytes: 2508
#include<iostream>
#include<cmath>

using namespace std;

int n;
int a[100005];
int cnt = 0;

int main(){
  cin >> n;
  int tmp = 0;
  a[n + 1] = 0;
  for(int i = 1; i <= n; ++i){
    cin >> a[i];
    cnt += abs(tmp - a[i]);
    tmp = a[i];
  }
  cnt += abs(a[n] - 0);
  //cout << cnt << endl;
  a[0] = 0;
  for(int i = 1; i <= n; ++i){
    if((a[i - 1] <= a[i] && a[i] <= a[i + 1]) || (a[i - 1] >= a[i] && a[i] >= a[i + 1])){
      cout << cnt << endl;
    }else{
      cout << cnt - min(abs(a[i] - a[i - 1]), abs(a[i] - a[i + 1])) * 2 << endl;
    }
  }
  
}

Measured memory_bytes: 1664