akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
    string str;
    cin >> str;
    
    int out = 0;
    int range = str.length()/2;
    for( int ii = 0; ii < range; ++ii ){
        if( str[ii] != str[str.length()-ii-1] ){
            ++out;
        }
    }
    
    cout << out << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
#define FOR(i , num) for(i = 0; i < num; i++)

using namespace std;

int main()
{
    double pi = 3.1415926535897932384626433832795028841971;
    double A, B, H ,M;
    cin >> A >> B >> H >> M;


    double m_vec_x, m_vec_y;
    double h_vec_x, h_vec_y;
    double m_ang, h_ang;

    m_ang = 2 * pi * M / 60.0;
    h_ang = 2 * pi * (60 * H + M) / 720.0;

    m_vec_x = -cos(m_ang) * B;
    m_vec_y = sin(m_ang) * B;
    
    h_vec_x = -cos(h_ang) * A;
    h_vec_y = sin(h_ang) * A;

    double res = sqrt(pow(m_vec_x - h_vec_x, 2) + pow(m_vec_y - h_vec_y, 2));
    cout << std::setprecision(15) <<  res << endl;

    return 0;   
}

Measured memory_bytes: 4128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int g = 0;

		for(int i = a; i <= b; i++) {
			if(i % k == 0) {
				g = 1;
				break;
			}
		}
		if(g == 1) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
	}
}


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

int main() {
    std::string sss; std::cin >> sss;  // 文字列はcin, 数値はscanfでやったほうがいいかも
    int num_of_one; num_of_one = std::count(sss.cbegin(), sss.cend(), '1');
    
    printf("%d", num_of_one);

    return 0;
}

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

int main() {
  char a;
  cin >> a;
  if(a == 'A')
    cout << 'T' << endl;
  else if(a == 'T')
    cout << 'A' << endl;
  else if(a == 'C')
    cout << 'G' << endl;
  else
    cout << 'C' << endl; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#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 all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}
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);
}



ll  d, n, r, l, k, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s, t;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> s >> k;
	k--;
	rep(i, n) {
		if (s[i] == s[k]) t += s[k];
		else t += '*';
	}
	cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep1(i, n){
        cin >> a[i];
        a[i]--;
        if (a[i]==i) b[i] = 1;
    }
    rep1(i, n-1) if (b[i]==b[i+1]) b[i+1] = 0;
    ll ans = 0; 
    rep1(i, n) ans += b[i];
    cout << ans << endl;
    //printf("%.12f", ans);
}

Measured memory_bytes: 4840
//AT2688
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define fst first
#define scd second
using namespace std;
inline ll read() {
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
const int MAXN=2e5+5;
const int INF=1e9;
int n,a[MAXN],st1[MAXN][30],st2[MAXN][30],lg[MAXN];
inline int query1(int l,int r) {
	int k=lg[r-l+1];
	return (a[st1[l][k]]<a[st1[r-(1<<k)+1][k]]?st1[l][k]:st1[r-(1<<k)+1][k]);
}
inline int query2(int l,int r) {
	int k=lg[r-l+1];
	return (a[st2[l][k]]<a[st2[r-(1<<k)+1][k]]?st2[l][k]:st2[r-(1<<k)+1][k]);
}
inline int ask(int t,int l,int r) {
	if(t) return query1(l,r);
	else return query2(l,r);
}
struct node {
	int l,r,p1,p2;
	friend bool operator < (node x,node y) {
		return a[x.p1]>a[y.p1];
	}
	node (int l_,int r_,int p1_,int p2_) {
		l=l_; r=r_; p1=p1_; p2=p2_;
	}
};
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);/*syn加速*/
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	lg[0]=-1;
	for(int i=1;i<=n;++i) lg[i]=lg[i>>1]+1;
	a[0]=INF;
	for(int i=1;i<=n;++i) {
		if(i&1) st1[i][0]=i;
		else st2[i][0]=i;
	}
	for(int j=1;(1<<j)<=n;++j) {
		for(int i=1;i+(1<<j)-1<=n;++i) {
			st1[i][j]=a[st1[i][j-1]]<a[st1[i+(1<<(j-1))][j-1]]?st1[i][j-1]:st1[i+(1<<(j-1))][j-1];
			st2[i][j]=a[st2[i][j-1]]<a[st2[i+(1<<(j-1))][j-1]]?st2[i][j-1]:st2[i+(1<<(j-1))][j-1];
		}
	}
	priority_queue<node> q;
	int p1=query1(1,n);
	int p2=query2(p1+1,n);
	q.push(node(1,n,p1,p2));
	while(!q.empty()) {
		node t=q.top();q.pop();
		cout<<a[t.p1]<<" "<<a[t.p2]<<" ";
		if(t.l<=t.p1-1) {
			int pp1=0,pp2=0,z=t.l%2;
			pp1=ask(z,t.l,t.p1-1);
			if(pp1) pp2=ask(1-z,pp1+1,t.p1-1);
			if(pp1&&pp2) q.push(node(t.l,t.p1-1,pp1,pp2));
		}
		if(t.p1+1<=t.p2-1) {
			int pp1=0,pp2=0,z=(t.p1+1)%2;
			pp1=ask(z,t.p1+1,t.p2-1);
			if(pp1) pp2=ask(1-z,pp1+1,t.p2-1);
			if(pp1&&pp2) q.push(node(t.p1+1,t.p2-1,pp1,pp2));
		}
		if(t.p2+1<=t.r) {
			int pp1=0,pp2=0,z=(t.p2+1)%2;
			pp1=ask(z,t.p2+1,t.r);
			if(pp1) pp2=ask(1-z,pp1+1,t.r);
			if(pp1&&pp2) q.push(node(t.p2+1,t.r,pp1,pp2)); 
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 50676
#include <cstdio>
#include <functional>
#include <vector>
#include <tuple>

using namespace std;

int main()
{
  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);
  printf("%d %d", min(a, b), max(0, a+b-n));
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main ( void )
{
    int N;
    double a[100];
    int i;
    double sum = 0;
    double ans;

    scanf( "%d", &N );
    
    if( N <= 100 )
    {
        for( i=0; i<N; i++ )
        {
            scanf( "%lf", &a[i] );
        }
    }
    
    for( i=0; i<N; i++ )
    {
        a[i] = 1 / a[i];
        sum = sum + a[i];
    }
    
    ans = 1 / sum;
    printf( "%lf", ans );
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007

typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[200200];
li b[200200];
li n;

int main() {
    cin >> n;
    li res = 0;
    bool all_same = true;
    li sum = 0;
    li mi = INF;
    rin{
        cin >> a[i] >> b[i];
        if (a[i] != b[i]) {
            all_same = false;
        }
        if (a[i] > b[i]) {
            mi = min(mi, b[i]);
        }
        sum += a[i];
    }
    if (all_same) {
        cout << 0 << endl;
    } else {
        cout << sum - mi << endl;
    }

    return 0;
}


Measured memory_bytes: 512
N = int(input())

V = list(map(int, input().split()))
C = list(map(int, input().split()))

v_c = []

for i in range(N):
	v_c.append(V[i]-C[i])

ans = 0
for i in range(N):
	if v_c[i] > 0:
		ans += v_c[i]

print(ans)

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

struct union_find {
  vector<long long> parent, sizes;
  void init(long long n) {
    for (long long i = 0; i < n; i++) {
      parent.push_back(i);
      sizes.push_back(1);
    }
  }
  long long root(long long n) {
    if (parent[n] == n) return n;
    return parent[n] = root(parent[n]);
  }
  bool is_united(long long a, long long b) {return (root(a) == root(b));}
  void unite(long long a, long long b) {
    if (is_united(a, b)) return;
    parent[root(b)] = a;
    sizes[root(a)] += sizes[root(b)];
  }
};

int main() {
  long long n, m;
  cin >> n >> m;
  
  union_find uf;
  uf.init(n);
  
  vector<vector<long long>> v(m, vector<long long>(0));
  for (long long i = 0; i < n; i++) {
    long long k;
    cin >> k;
    for (long long j = 0; j < k; j++) {
      long long l;
      cin >> l;
      v[l - 1].push_back(i);
    }
  }
  for (long long i = 0; i < m; i++) {
    for (long long j = 1; j < v[i].size(); j++) {
      uf.unite(v[i][0], v[i][j]);
    }
  }
  
  for (long long i = 1; i < n; i++) {
    if (!uf.is_united(0, i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m, d, M, D;
    cin >> m >> d >> M >> D;
    if(m != M) cout << 1 << endl;
    else cout << 0 << endl;
}

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

int main ()
{

  string s; cin>> s;
  
  for (char ch ='a'; ch <= 'z'; ch++) {
    bool ok=true;
    for (int i=0; i<s.size(); i++) {
      if (s[i] == ch) 
      {
        ok = false;
        break;
      }
    }
      if (ok)	{
        cout << ch << endl;
        return 0;
    }
  }
    cout << "None" << endl;
    return 0;
}

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

using namespace std;
int main(){
	int n,l;
	cin>>n>>l;
	for(int i=0;i<=n;i++){
		if(2*i +(n-i)*4==l){
			cout<<"Yes"<<endl;
			break;
		}
		else if(i==n)
			cout<<"No"<<endl;
	}

    return 0;
}

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


using namespace std;

int main(){


    string a, b;
    cin >> a >> b;
    a = a+b;
    int sum = atoi(a.c_str());


    bool is = false;

    for(int i = 0; i <= sqrt(sum); i++)
        if(sum == i*i) is = true;

    if(is) cout << "Yes" << endl;
    else cout <<"No" << endl;
}


Measured memory_bytes: 256
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    x = int(input())
    while True:
        if is_prime(x):
            print(x)
            break
        x += 1


Measured memory_bytes: 2940
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
ans = sum(s)

if ans%10!=0:
    print(ans)
else:
    i =0
    while i<n:
        if s[i]%10!=0:
            print(ans-s[i])
            exit()
        else:
            i +=1
    print(0)

Measured memory_bytes: 38256
#include <cstdio>

const int N = 1000000 + 10, MOD = 1000000007;

int n, f[N], g[N];

int main() {
  scanf("%d", &n);
  f[0] = g[0] = 1;
  f[1] = n, g[1] = n + 1;
  for (int i = 2; i <= n; ++i) {
    f[i] = (g[i - 1] - f[i - 2]) % MOD;
    f[i] = (f[i] + (n - 1LL) * (n - 1LL)) % MOD;
    f[i] = (f[i] + n - i + 1LL) % MOD;
    g[i] = (g[i - 1] + f[i]) % MOD;
  }
  printf("%d\n", (f[n] + MOD) % MOD);
  return 0;
}


Measured memory_bytes: 7936
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    public class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine().Trim());
            LinkedList<int> ls = new LinkedList<int>();
            while (n != 0)
            {
                string[] temp = Console.ReadLine().Trim().Split(' ');
                switch (temp[0])
                {
                    case "insert":
                        ls.AddFirst(int.Parse(temp[1]));
                        break;
                    case "delete":
                        ls.Remove(int.Parse(temp[1]));
                        break;
                    case "deleteFirst":
                        ls.RemoveFirst();
                        break;
                    case "deleteLast":
                        ls.RemoveLast();
                        break;
                    default:
                        break;
                }
                n--;
            }
            Console.WriteLine(string.Join(" ", ls));
        }
    }
}




Measured memory_bytes: 75384
import itertools

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

a=list(itertools.permutations(range(1,N+1)))
ans2=-1

for n in range(len(a)):
  if a[n]==P:
    ans1=n
  elif a[n]==Q:
    ans2=n
if ans2 != -1:
  print(abs(ans1-ans2))
else:
  print(0)

Measured memory_bytes: 8052
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {

	int n, a, b, min;

	cin >> n >> a >> b;

	min = n * a;

	if (min > b) {
		min = b;
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> left(N, 0), right(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    left[0] = A[0];
    right[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++) {
        left[i] = __gcd(left[i - 1], A[i]);
    }
    for (int i = N - 2; i >= 0; i--) {
        right[i] = __gcd(right[i + 1], A[i]);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == 0) ans = max(ans, right[i + 1]);
        else if (i == N - 1) ans = max(ans, left[i - 1]);
        else ans = max(ans, __gcd(left[i - 1], right[i + 1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#define pii pair<long long, long long>
using namespace std;
const int maxn = 3e5+5;
vector<pii> a[maxn];
int main()
{
  long long n,x,d,ans=0;
  cin >> n >> x >> d;
  if(d == 0)
  {
    if(x == 0) ans = 1;
    else ans = n+1;
    cout << ans << endl;
    exit(0);
  }
  a[0].push_back({0,0});
  long long cycle = n+1, amount = 0;
  for(int i = 1; i <= n; i++)
  {
    long long y = i * x;
    if(y%d == 0)
    {
      cycle = i;
      amount = y / d;
      break;
    }
  }
  for(long long i = 1; i <= n; i++)
  {
    long long to_add = i/cycle*amount;
    long long l = i * (i-1) / 2, r = i * (n+n-i-1) / 2;
    a[i%cycle].push_back({l+to_add, r+to_add});
  }
  for(int i = 0; i < cycle; i++)
  {
    if(a[i].empty())continue;
    sort(a[i].begin(),a[i].end());
    long long base = a[i][0].first, bound = a[i][0].second;
    for(int j = 1; j < a[i].size(); j++)
    {
      if(a[i][j].first > bound)
      {
        ans += bound - base + 1;
        base = a[i][j].first;
      }
      bound = max(bound, a[i][j].second);
    }
    ans += bound - base + 1;
  }
  cout << ans << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 200003;

using Complex = complex<double>;

// Reference: http://www.prefield.com/algorithm/math/fft.html
vector<Complex> DFT(const vector<Complex>& p, int n, int sign = 1) {
  const double theta = 2.0 * M_PI / n * sign;
  int unit = 1;
  vector<Complex> q = p;
  for (int m = n; m >= 2; m >>= 1) {
    int mh = m >> 1;
    for (int i = 0; i < mh; i++) {
      Complex w = Complex(cos(theta * unit * i), sin(theta * unit * i));
      for (int j = i; j < n; j += m) {
        int k = j + mh;
        Complex x = q[j] - q[k];
        q[j] += q[k];
        q[k] = w * x;
      }
    }
    unit *= 2;
  }
  int i = 0;
  for (int j = 1; j < n - 1; j++) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1);
    if (j < i) swap(q[i], q[j]);
  }
  return q;
}
 
vector<Complex> InvDFT(const vector<Complex>& p, int n) {
  auto q = DFT(p, n, -1);
  for(int i = 0; i < n; i++) {
    q[i] /= n;
  }
  return q;
}
 
vector<Complex> MultiplyFFT(
    const vector<Complex>& p1, const vector<Complex>& p2) {
  int d = p1.size() + p2.size() - 1;
  int n = 1;
  while(n < d + 1) n *= 2;
 
  auto q1 = p1;
  q1.resize(n);
  auto q2 = p2;
  q2.resize(n);
  auto r1 = DFT(q1, n);
  auto r2 = DFT(q2, n);
 
  vector<Complex> s(n);
  for(int i = 0; i < n; i++) {
    s[i] = r1[i] * r2[i];
  }
  return InvDFT(s, n);
}

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

  // i = 2^p
  vector<int64> i_to_p(P, -1);
  vector<int64> p_to_i(P - 1, -1);
  {
    int64 x = 1;
    for (int i = 0; i < P - 1; i++) {
      i_to_p[x] = i;
      p_to_i[i] = x;
      x *= 2;
      x %= P;
    }
  }

  int n;
  cin >> n;

  int64 delta = 0;
  vector<Complex> xs(P - 1);
  for (int i = 0; i < n; i++) {
    int64 a;
    cin >> a;
    if (a == 0) continue;
    xs[i_to_p[a]] += 1;
    // cout << a * a % P << endl;
    delta += a * a % P;
  }
  // cout << "Before FFT" << endl;
  vector<Complex> ys = MultiplyFFT(xs, xs);
  // cout << "After FFT" << endl;
  int64 ans = 0;
  for (int i = 0; i < ys.size(); i++) {
    int k = i % (P - 1);
    // int64 c = roundf64(ys[i].real());
    // int64 v = p_to_i[k];
    // if (c > 0) {
    //   cout << c << " " << v << endl;
    // }
    ans += p_to_i[k] * roundf64(ys[i].real());
  }
  // cout << ans << endl;
  ans -= delta;
  ans /= 2;
  cout << ans << endl;
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

bool isPrime(ll x){
	forni(i,sqrt(x)){
		if(x%(i+1)==0)return false;
	}
	return true;
}

int main(){
	IO;
	ll x;
	cin>>x;
	while(!isPrime(x)){
		x++;
	}
	cout<<x<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


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

using namespace std;

int gcd(int a, int b){
  //ユークリッドの互除法を使う
  //aとbの大小関係をみて、デカい方をl小さい方をmに代入
  int l, m, r = 1;

  if (a >= b){
    l = a;
    m = b;
  }
  else{
    l = b;
    m = a;
  }

  //**ループ**
  while(r != 0){
  //lをmで割ったあまりr（剰余）を求める
    r = l % m;
  //0以外なら、lにmを、mに剰余を代入する。
    l = m;
    m = r;
  //**ループ**
  }

  //0ならlを返す
  return l;
}

int main(){
  int a, b;//数字

  cin >> a >> b;

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



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

using namespace std;

typedef long long LL;
#define N (1<<19)

const LL mod=998244353;
LL n,sum,isum,a[N],ans;

void upd(LL &x,LL y){x=(x+y)%mod;}

LL inv(LL x){
	return x==1?1:(mod-mod/x)*inv(mod%x)%mod;
}

void fwt(LL f[],LL n){
	for (LL i=0;i<n;++i){
		LL t=1<<i;
		for (LL j=0;j<1<<n;j+=t<<1){
			LL *f1=f+j,*f2=f+j+t;
			for (LL k=0;k<t;++k){
				LL x=(f1[k]+f2[k])%mod,y=(f1[k]-f2[k]+mod)%mod;
				f1[k]=x; f2[k]=y;
			}
		}
	}
}

int main(){
	scanf("%lld",&n);
	for (LL i=0;i<1<<n;++i){
		scanf("%lld",a+i);
		upd(sum,a[i]);
	}
	isum=inv(sum);
	for (LL i=0;i<1<<n;++i) a[i]=a[i]*isum%mod;
	fwt(a,n);
	a[0]=0; for (LL i=1;i<1<<n;++i) a[i]=inv((1-a[i]+mod)%mod);
	fwt(a,n);
	for (LL i=0;i<1<<n;++i){
		ans=(a[0]-a[i]+mod)%mod;
		printf("%lld\n",ans);
	}
	
	return 0;
}
			

Measured memory_bytes: 6912
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector as V
import Debug.Trace as De

func :: Int -> Int -> Int
func a b
  | a < b = b
  | otherwise = a

main = do
  n <- readLn :: IO Int
  a1 <- getLine
  let a = map (read :: String -> Int) (words a1)
  let b = scanl func 0 a
  let ans = (sum b) - (sum a)
  putStrLn $ show ans

Measured memory_bytes: 89872
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	char a, b, c, d, e, f;
	scanf("%c%c%c", &a, &b, &c);
	scanf(" %c%c%c", &d, &e, &f);
	if(((a==f)&&(b==e)&&(d==c)))
		printf("YES");
		else
			printf("NO");
	return 0;
	}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream> 
using namespace std;

const int mod = 1000000007;
char map[2][52];
int main()
{
	int n;
	long long ans;
	while(~scanf("%d",&n))
	{
		for(int i = 0;i <= 1; i++)
		{
			cin>>map[i];
		}
		if(map[0][0]==map[0][1])	ans=6;
		if(map[0][0]!=map[0][1])	ans=3;
		for(int i = ans/3;i < n; i++)
		{
			if(map[0][i-1]==map[1][i-1])//x
			{	
				if(map[0][i]!=map[0][i+1])//x
				{
					ans=ans*2%mod;
				}
				if(map[0][i]==map[0][i+1])//y
				{
					ans=ans*2%mod;
					i++;
				}
			
			}
			if(map[0][i-1]!=map[1][i-1])//y
			{
				if(map[0][i]==map[0][i+1])//y
				{
					ans=ans*3%mod;
					i++;
				}
			}
		}
		printf("%lld\n",ans);
	}
	
} 


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;

int main() {

	ll N;
	string str;
	cin >> N;
	cin >> str;

	string str2;
	str2.push_back(str.at(0));
	bool same = false;
	rep(i, N-1) {
		if (str.at(i) == str.at(i + 1)) {
			same = true;
		}
		else {
			str2.push_back(str.at(i+1));
			same = false;
		}
	}
	cout << str2.size() << endl;
	return 0;
}

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

void primeFactors(int n)
{
    while (n%2 == 0){
        cout << " " << 2;
        n = n/2;
    }
    
    for (int i = 3; i <= sqrt(n); i = i+2){
        while (n%i == 0){
            cout << " " << i;
            n = n/i;
        }
    }
    if (n > 2) cout << " " << n;
}

int main()
{
    int n;
    cin >> n;
    cout << n << ":";
    primeFactors(n);
    cout << endl;
    return 0;
}



Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        int N = parseInt(read.readLine());
        int rem = N % 1000;
        if (rem > 0) {
            System.out.println(1000 - rem);
        } else {
            System.out.println(0);
        }

    }
}


Measured memory_bytes: 32488
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,q,a,t,x;
    cin >> n;
    vector<vector<int>> vec(n,vector<int>());
    cin >> q;
    for (int i=0;i<q;i++) {
        cin >> a >> t;
        if ( a==0 ) {
            cin >> x;
            vec[t].emplace_back(x);
//            cout << vec[t].size() << endl;
        } else if ( a==1 ) {
            if ( vec[t].empty()!=true ) {
                cout << vec[t][vec[t].size()-1] << endl;
            }
        } else if ( a==2 ) {
            if ( vec[t].empty()!=true ) {
                vec[t].pop_back();
                vec.shrink_to_fit();
            }
        }
    }
}



Measured memory_bytes: 3908
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int N, ans = 1;
	
	cin>>N;
	
	for(int i = 1; i <= N; i++){
		ans *= i;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

bool hashs[200] = {};

int main(){
    int a, b, c, cnt= 0;
    scanf("%d %d %d",&a,&b,&c);
    hashs[a] = hashs[b] = hashs[c] = true;
    for(int i=0;i<=100;i++)
        if(hashs[i])
            cnt++;
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();
		int g = x - t;
		if (g < 0) {
			g = 0;
		}
		System.out.println(g);
	}
}


Measured memory_bytes: 22612
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        // n*nマス
        int n = Integer.parseInt(sc.next());
        // 白色のマス数
        int white = Integer.parseInt(sc.next());
        // 黒色のマス
        int black = n * n - white;
        System.out.println(black);
    }
}


Measured memory_bytes: 35608
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let s: String = read();


    if &s[..n / 2] == &s[n / 2..] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	string s,t;
	cin >> s >> t;
	int n = s.size(),ans = 0;
	for(int i = 0;i < n;i++){
		if(s[i] != t[i]){
			ans++;
		}
	}
	cout << ans << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3792
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		List<Long> list = new ArrayList();
		for(int i=0; i<N ; i++) {
			list.add(Long.parseLong(sc.next()));
		}
		Collections.sort(list);
		long b = Long.MAX_VALUE;
		for(Long a : list) {
			if(a == b) {
				System.out.println("NO");
				return;
			}
			b = a;
		}
		System.out.println("YES");
	}
}


Measured memory_bytes: 64896
import java.util.Arrays

const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var mint = 0L
    var mina = 0L
    for (i in 0..n-1) {
        val (t, a) = readLine()!!.split(" ").map{it.toInt()}
        val m = arrayOf((mint + t - 1) / t, (mina + a - 1) / a, 1L).max()!!
        mint = t * m
        mina = a * m
    }

    println(mina + mint)
}


Measured memory_bytes: 36012
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 1000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const LL MAXVAL = 1LL * INF * INF + INF;

int n; LL t, a;

int main() {
    GI(n); LL rest, resa;

    GLL(rest); GLL(resa);

    FORN(i, n-1) {
        GLL(t); GLL(a);
        
        LL lo = 1; LL hi = MAXVAL / max(a, t); LL res = -1;

        while (lo <= hi) {
            LL mid = (lo + hi) / 2;

            if (mid * t >= rest && mid * a >= resa) {
                res = mid;
                hi = mid - 1;
            }
            else {
                lo = mid + 1;
            }
        }

        rest = res * t;
        resa = res * a;
    }

    cout << rest + resa << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int dp[100001];
int  main()
{
	ll n,k;
	cin>>n>>k;
	memset(dp,0,sizeof(int));
	ll a[n];
	for(int i=0;i<n;i++) {
		cin>>a[i];
		dp[a[i]] = 1;
	}

	for(ll i=0;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[j] <=i)
			{
				if(dp[i-a[j]] == 0) dp[i] = 1;
			}
		}
	}
	if(dp[k]) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#define N 100


int main(){
  int S[N][N];
  int n,i,j,x,y,count;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      S[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&y,&count);
    y--;
    for(j=0;j<count;j++){
      scanf("%d",&x);
      x--;
      S[y][x]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",S[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 636
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    ll X;
    cin >> N >> X;
    vi C{ 5 };
    if (N >= 2) {
        C.push_back(5);
    }
    for (int i = 3; i <= N; ++i) {
        C.push_back(C.back()+2);
    }

    vi xx(N);
    rep(i, N) {
        cin >> xx[i];
    }
    reverse(all(xx));
    vll sm(N + 1);
    rep(i, N) {
        sm[i + 1] = sm[i] + xx[i];
    }

    ll ans = LLONG_MAX / 3;
    for (int i = 1; i <= N; ++i) {
        ll x = N * X + X * i;
        for (int j = 0, k = 0; k < N; ++j) {
            int nk = min(N, k + i);
            x += (sm[nk] - sm[k])*C[j];
            if (x >= ans) {
                break;
            }
            k = nk;
        }
        smin(ans, x);
    }
    cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m, l;
    cin >> n >> m >> l;
    vector<vector<PII>> g(n);
    REP(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        if(c > l) continue;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
    }

    vector<vector<PII>> dist(n, vector<PII>(n, PII(INF, -INF)));
    REP(s, n) {
        using P = pair<PII, ll>;
        priority_queue<P, vector<P>, greater<P>> que;
        dist[s][s] = PII(0, -l);
        que.push({dist[s][s], s});
        while(que.size()) {
            ll mi, rest, v;
            auto temp = que.top(); que.pop();
            tie(mi, rest) = temp.first;
            rest *= -1;
            v = temp.second;
            if(dist[s][v] < PII(mi, -rest)) continue;
            for(auto to: g[v]) {
                PII np(mi, rest);
                if(-dist[s][v].second < to.second) {
                    np.first++;
                    np.second = l - to.second;
                } else {
                    np.second -= to.second;
                }
                np.second *= -1;
                if(dist[s][to.first] > np) {
                    dist[s][to.first] = np;
                    que.push({np, to.first});
                }
            }
        }
    }

    dump(dist);

    ll q;
    cin >> q;
    while(q--) {
        ll s, t;
        cin >> s >> t;
        s--, t--;

        if(dist[s][t].first == INF) cout << -1 << "\n";
        else cout << dist[s][t].first << "\n";
    }
    cout << flush;

    return 0;
}

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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

bool IsPrime(int);

int getReward(int a) {
  switch (a)
  {
  case 1:
    return 300000;
  case 2:
    return 200000;
  case 3:
    return 100000;
  default:
    return 0;
  }
}

/***** MAIN *****/
signed main() {
  int a, b;
  int ans = 0;
  cin >> a >> b;
  ans = getReward(a) + getReward(b);
  if(ans == 600000) ans += 400000;
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}


Measured memory_bytes: 256
/*
                                                  
  _|_|                              _|  _|    _|  
_|    _|  _|  _|_|  _|_|_|_|        _|  _|  _|    
_|    _|  _|_|          _|          _|  _|_|      
_|    _|  _|          _|      _|    _|  _|  _|    
  _|_|    _|        _|_|_|_|    _|_|    _|    _|  
                                                                                                    
*/ 
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int maxn=186;
int sum[maxn][maxn],n,m,dp[2][maxn][maxn][maxn];
char s[maxn];
int que(int xl,int xr,int yl,int yr){
	int siz=(xr-xl+1)*(yr-yl+1),tot=sum[xr][yr]-sum[xl-1][yr]-sum[xr][yl-1]+sum[xl-1][yl-1];
	if(!tot||tot==siz)return 1;
	return 0;
}
void init(){
/*	rep(i,1,n)rep(j,i,n)for(int r=1,l=1;l<=m;l=r+1){
		r=l;bool flag=0;
		while(r<m&&que(i,j,l,r+1))flag=1,
		r++;
		//if(!flag)r=l-1;
		rep(k,l,r)dp[0][i][j][k]=(flag)?r:(r-1);
	}*/
	 for(int i=1;i<=n;++i)
        for(int j=i;j<=n;++j)
            for(int l=1,r;l<=m;l=r)
            {
                r=l;
                while(que(i,j,l,r)&&r<=m)r++;
                for(int p=l;p<r;++p)dp[0][i][j][p]=r-1;
                if(l==r)dp[0][i][j][l]=l-1,r++;
            }
}
/*int find(int c,int i,int j,int st){
	int l=i,r=j;
	int ans=0;
	while(l<r){
		int mid=(l+r)>>1;
	//	cout<<mid<<endl;
		ans=max(ans,min(dp[c][i][mid][st],dp[c][mid+1][r][st]));
		if(dp[c][i][mid][st]<dp[c][mid+1][r][st])r=mid;
		else l=mid+1;
	}
	return ans;
}*/
int find(int c,int u,int d,int L){
    int l=u,r=d-1,mid;
    int res=0;
    int v1,v2;
    while(l<=r)
    {
        mid=(l+r)/2;
        v1=dp[c][u][mid][L];
        v2=dp[c][mid+1][d][L];
        res=max(res,min(v1,v2));
        if(v1<v2)r=mid-1;
        else l=mid+1;
    }
    return res;
}
void go(int c){
	rep(i,1,n)rep(j,i,n)rep(l,1,m){
		//cout<<c<<' '<<i<<' '<<j<<' '<<l<<endl;
		int r=dp[c^1][i][j][l],tar;
		if(r!=m){
			tar=dp[c^1][i][j][r+1];tar=max(tar,find(c^1,i,j,l));
		}
		else tar=m;
		dp[c][i][j][l]=tar;
	}
}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n){
		scanf("%s",s+1);
		rep(j,1,m){
			sum[i][j]=(s[j]=='#');
		}
	}
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i][j-1];
	rep(i,1,n)rep(j,1,m)sum[i][j]+=sum[i-1][j];
	init();
	int ans=0;
	for(int i=1;dp[(i&1)^1][1][n][1]<m;i++)go(i&1),ans=i;
	printf("%d",ans);
	return 0; 
}

Measured memory_bytes: 30384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  int a,b;
  cin>>a>>b;
  if(a==1&&b==1)
  cout<<1<<endl;
  else if(a==1||b==1)
    cout<<max(a,b)-2<<endl;
  else
    cout<<(a-2)*(b-2)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<utility>
#include<vector>
#include<functional>
#include<stack>
#include<queue>
#include<math.h>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

int main() {
	int a = 0, b = 0, n = 0;
	int x = 0, y = 0, z = 0;
	cin >> n >> a >> b;
	int p[100] = {};
	rep(i, n) {
		cin >> p[i];
	}
	sort(p, p + n);

	rep(i, n) {
		if (p[i] <= a) {
			x++;
		}
		else if (p[i] <= b) {
			y++;
		}
		else {
			z++;
		}
	}
	cout << min({ x,y,z }) << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	
	string s, t; int q, i, k, f; char c;
	cin >> s >> q;
	zip(i, 0, q)
	{
		cin >> k;
		if (k == 1)
		{
			swap(s, t);
		}
		else
		{
			cin >> f >> c;
			if (f == 1)
				t = t + c;
			else
				s = s + c;
		}
	}
	reverse(all(t));
	t = t + s;
	cout << t;
	return 0;
}



Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <cmath>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;
using ll = long long;
using ull = unsigned long long;


#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

auto sumdig(ll num) {
	ll dig, sum;
	sum = 0;
	while (num) {
		dig = num % 10;
		sum = sum + dig;
		num = num / 10;
	}
	return sum;
}

auto mdist(pair<int, int> a, pair<int, int> b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {

	int k, a, b;
	cin >> k >> a >> b;
	int i = 1;
	int kt;
	while (true) {
		kt = i * k;
		if (kt <= b && kt >= a) {
			cout << "OK" << endl;
			return 0;
		}
		if (kt >= b) {
			cout << "NG" << endl;
			return 0;
		}
		i++;
	}

	return 0;
}


Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []d = new int[n];
		
		for(int i = 0; i < n ; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
				
		System.out.println(d[(n/2)] - d[(n/2)-1]);
		}

	}




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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n; cin >> n;
    bool poss = 0;
    vector<int> a(n + 1, -1);
    a[0] = 0;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (x == 1)
            poss = 1;
        if (a[x - 1] >= 0)
            a[x] = a[x - 1] + 1;
        mx = max(mx, a[x]);
    }
    cout << (poss ? n - mx : -1);
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
using namespace std;
long double e[301][301][301];

int main()
{
	int n, a = 0, b = 0, c = 0, temp;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> temp;
		if (temp == 1) a++;
		else if (temp == 2) b++;
		else c++;
	}
	
	e[0][0][0] = 0;
	
	for (int k = 0; k <= n; k++)
		for (int j = 0; j <= n - k; j++)
			for (int i = 0; i <= n - j - k; i++)
			{
				if (!i && !j && !k) continue;
				e[i][j][k] = n;
				if (i) e[i][j][k] += i * e[i - 1][j][k];
				if (j) e[i][j][k] += j * e[i + 1][j - 1][k];
				if (k) e[i][j][k] += k * e[i][j + 1][k - 1];
				e[i][j][k] /= (i + j + k);
			}
			
	cout << fixed << setprecision(10) << e[a][b][c];
}

Measured memory_bytes: 426240
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <fstream>

#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
#include <functional>
#include <stack>
#include <numeric>
#include <cassert>

using namespace std;

class TaskC {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> S(N);
        int sum = 0;
        for (int i = 0; i < N; ++i) {
            in >> S[i];
            sum += S[i];
        }
        
        if (sum % 10 == 0) {
            int mn = 100;
            for (int i = 0; i < N; ++i) {
                if (S[i] % 10) {
                    mn = min(mn, S[i]);
                }
            }
            
            if (mn == 100) {
                sum = 0;
            } else {
                sum -= mn;
            }
        }
        out << sum << "\n";
    }
};


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

	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256