akhauriyash/Code-Regression huggingface dataset:
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces1214D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	ll n; cin >> n;
	ll a[n]; parseArray(a, n);
	ll idx[n + 1];
	for ( int k = 0; k < n; k++ )
		idx[a[k]] = k;

	set<ll> st;
	ll ans = 0;
	for ( int k = n; k > 0; k-- ){
		st.insert(idx[k]);
		set<ll>::iterator pre = st.find(idx[k]);
		set<ll>::iterator nxt = next(st.find(idx[k]));
		ll p = -1, nx = n, p1 = -1, nx1 = n;
		if (pre != st.begin()){
			pre = prev(pre);
			p = *pre;
			if (pre != st.begin())
				p1 = *prev(pre);
		}
		if (nxt != st.end()){
			nx = *nxt;
			nxt = next(nxt);
			if (nxt != st.end())
				nx1 = *nxt;
		}
		ans += ((p - p1) * (nx - idx[k])) * k;
		ans += ((nx1 - nx) * (idx[k] - p)) * k;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
int main(){
	int n; cin >> n;
	int a[n];
	for(int i = 0; i < n; ++i) cin >> a[i];
	int pref[n+1]; pref[0] = 0;
	for(int i = 1; i <= n; ++i){
		pref[i] = (pref[i-1] + a[i-1])%mod;
	}
	ll ans = 0;
	for(int i = 0; i < n; ++i){
		ans += (1LL*a[i]*((pref[n] - pref[i+1] + mod)%mod))%mod;
	}
	ans %= mod;
	cout << ans;
}

Measured memory_bytes: 5176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int S,L,R;
  cin>>S;
  L=S/100;
  R=S%100;
  if(L>=1&&L<=12){
    if(R>=1&&R<=12)cout<<"AMBIGUOUS"<<endl;
    else cout<<"MMYY"<<endl;
  }else{
    if(R>=1&&R<=12)cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,t,d,ans;
    cin>>n>>x>>t;
    if(n%x==0)
    {
        cout<<(n/x)*t;
    }
    else
    {
        cout<<(n/x)*t+t;
    }


}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly DateTime inT = DateTime.Parse("17:30");
        static readonly DateTime outT = DateTime.Parse("19:30");

        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int[][] table = new int[8][];
            table[1] = new int[] { 0, 0, 300, 500, 600, 700, 1350, 1650 };
            table[2] = new int[] { 0, 6, 0, 350, 450, 600, 1150, 1500 };
            table[3] = new int[] { 0, 13, 7, 0, 250, 400, 1000, 1350 };
            table[4] = new int[] { 0, 18, 12, 5, 0, 250, 850, 1300 };
            table[5] = new int[] { 0, 23, 17, 10, 5, 0, 600, 1150 };
            table[6] = new int[] { 0, 43, 37, 30, 25, 20, 0, 500 };
            table[7] = new int[] { 0, 58, 52, 45, 40, 35, 15, 0 };

            while (true)
            {
                int s = int.Parse(Console.ReadLine());

                if (s == 0) break;

                bool flg = false;

                string temp = Console.ReadLine().Replace(" ", ":");
                DateTime time = DateTime.Parse(temp);
                flg = CheckTime(time);

                int t = int.Parse(Console.ReadLine());

                if (!flg)
                {
                    temp = Console.ReadLine().Replace(" ", ":");
                    time = DateTime.Parse(temp);
                    flg = CheckTime(time);
                }
                else Console.ReadLine();

                int min = Math.Min(s, t);
                int max = Math.Max(s, t);

                int p = table[min][max];

                if (flg && table[max][min] <= 40)
                {
                    p /= 2;

                    int q = p % 50;
                    if (q > 0) p = p - q + 50;
                }
                sb.AppendLine(p.ToString());
            }
            Console.Write(sb);
        }

        static bool CheckTime(DateTime dt)
        {
            if (dt < inT) return false;
            if (dt > outT) return false;
            return true;
        }
    }
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 1e5 + 7;

vector<int> from[MAXN];
int dp[MAXN];
int ans;

void dfs(int u)
{
    if (dp[u])
        return;
    for (int v : from[u]) {
        dfs(v);
        dp[u] = max(dp[u], 1 + dp[v]);
    }
    if (dp[u] > ans)
        ans = dp[u];
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i != m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        from[u].push_back(v);
    }
    for (int i = 1; i <= n; ++i)
        if (!dp[i])
            dfs(i);
    printf("%d\n", ans);
}

Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();
        int q = sc.NextInt();
        for (int k = 0; k < q; k++)
        {
            long a = sc.NextLong();
            long b = sc.NextLong();
            long c = sc.NextLong();
            long d = sc.NextLong();

            if (a < b || b > d)
            {
                Console.WriteLine("No");
                continue;
            }
            if (c >= b)
            {
                Console.WriteLine("Yes");
                continue;
            }
            long g = Gcd(b, d);
            Console.WriteLine(b - g + a % g > c ? "No" : "Yes");
        }
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }


int main() {
    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3612
n = int(input())
A = [int(a) for a in input().split()]

x = 0
rains = [x]
for a in A:
    x = a - x
    rains.append(x)

diff = (rains[-1] - rains[0]) // 2
result = []
for i, x in enumerate(rains[:-1]):
    if i % 2 == 0:
        result.append(str((x + diff) * 2))
    else:
        result.append(str((x - diff) * 2))

print(' '.join(result))


Measured memory_bytes: 21820
#include<iostream>
#include <vector>
#include <string>
#include<algorithm>
using namespace std;
int T,P,R;
class team{
public:
  int probnum,prob[11],pn,num;
  team(int a){
    num=a;probnum=0;pn=0;
    for(int i=0;i<11;i++){
      prob[i]=0;
    }
  }
  void calc(int pid,int time,string M){
    if(M[0]=='C'){
      probnum++;
      pn+=prob[pid]*1200+time;
    }else{
      prob[pid]++;
    }
  }
};
vector<team> vec;
bool inc(const team& a,const team& b){
  if(a.probnum!=b.probnum)return a.probnum>b.probnum;
  if(a.pn!=b.pn)return a.pn<b.pn;
  else return a.num<b.num;
}
int main(){
  while(1){
    vec.clear();
    cin>>T>>P>>R;
    if(T+R+P==0)break;
    for(int i=0;i<T;i++)vec.push_back(team(i));
    for(int i=0;i<R;i++){
      int tid,pid,time0;
      string mess;
      cin>>tid>>pid>>time0>>mess;
      vec[tid-1].calc(pid-1,time0,mess);
    }
    sort(vec.begin(),vec.end(),inc);
    for(int i=0;i<T;i++){
      cout<<vec[i].num+1<<" "<<vec[i].probnum<<" "<<vec[i].pn<<endl;
    }
  }
}

Measured memory_bytes: 1224
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException, NumberFormatException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		double r = Double.parseDouble(br.readLine());
		//計算
		double x = Math.PI * r * r;//面積
		double y = 2 * Math.PI * r;//円周
		String men = String.format("%.6f", x);
		String en = String.format("%.6f", y);
		System.out.println(men + " " + en);
		br.close();
	}
}

Measured memory_bytes: 17092
// luogu-judger-enable-o2
#include<cstdio>
using namespace std;
const int maxn=100+2;
const int ABC=26;
int n,m;
int num[ABC];
char str[maxn];
int change(char ch){return ch-'a';}
int main(){
	scanf("%d%d",&n,&m);
	int one=(n>>1)*(m>>1),two=(n&1)*(m>>1)+(m&1)*(n>>1),three=m&n&1;
	for (int i=1;i<=n;i++){
		scanf("%s",str+1);
		for (int j=1;j<=m;j++) num[change(str[j])]++;
	}
	bool flag=true;
	for (int i=0;i<ABC;i++){
		while (num[i]>=4&&one){
			num[i]-=4;
			one--;
		}
		while (num[i]>=2&&two){
			num[i]-=2;
			two--;
		}
		while (num[i]&&three){
			num[i]--;
			three--;
		}
		if (num[i]){
			flag=false;
			break;
		}
	}
	if (flag) printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
using namespace std;

int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }
  bool flag = true;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if (s[i][j] == '#'){
        flag = false;
        if (i+1<h&&s[i+1][j] == '#') flag = true;
        if (j+1<w&&s[i][j+1] == '#') flag = true;
        if (0<i&&s[i-1][j] == '#') flag = true;
        if (0<j&&s[i][j-1] == '#') flag = true;
      }
      if (!flag) break;
    }
    if (!flag) break;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
    int n,c,d;
    cin>>n;
      d=n%1000;
    if(d!=0)
       {
            c = (1000-d);
       cout<<c<<"\n";
       }
    else
     cout<<d<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"
//#define M 1000000007

vector <vector <int>> adj;
vector <int> vis;
stack <int> s;
void dfs(int n)
{
	vis[n]=1;
	for (int i=0; i<adj[n].size();++i)
	{
		if (!vis[adj[n][i]])
		{
		dfs(adj[n][i]);
		}
		
	}
	s.push(n);
}


signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	vis.resize(n+1);
	adj.resize(n+1);
	rep(i,vis.size())
	{
		vis[i]=0;
	}
	rep(i,m)
	{
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
	}
	REP(i,1,n)
	{
		if(vis[i]==0)
			dfs(i);
	}
	int ans=-1;
	rep(i,vis.size())
	{
		vis[i]=0;
	}
	while(!s.empty())
	{
		int a=s.top();
		//debug2(a,a);
		s.pop();
		for(auto j:adj[a])
			vis[j]=max(vis[j], vis[a]+1);
	}
	rep(i,n+1)
	{
		//debug1(vis[i]);
		ans=max(ans,vis[i]);
	}
	cout<<ans;
}

Measured memory_bytes: 9344
n = int(input())
a = [int(i) for i in input().split()]


if 0 in a:
    print(0)
else:
    is_true = True
    ans = a[0]
    key = 10 ** 18
    for i in range(n-1):
        ans *= int(a[i+1])
        if ans > key:
            is_true = False
            break
    if is_true:
        print(ans)
    else:
        print('-1')


Measured memory_bytes: 21752
#include<iostream>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main()
{
    ll A[100000],b[100000],sum=0;
    int N,count=0,i;
    cin>>N;
    for(i=0;i<N;i++)
    {
        cin>>A[i];
    }
    for(i=0;i<N;i++)
    {
        if(A[i]<0)
            count++;
    }
    if(count%2==0)
        for(i=0;i<N;i++)
    {
        sum+=abs(A[i]);

    }
       else if(count%2==1)
       {
           for(i=0;i<N;i++)
       {
            b[i]=abs(A[i]);
       }
    sort(b,b+N);
    for(i=1;i<N;i++)
    {
        sum+=b[i];
    }
    sum=sum-b[0];
}
        cout<<sum<<endl;
}


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

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	if(a + b >= c){
		ll d = b + c;
		cout << d << endl;
	}
	else{
		ll d = a + 2 * b + 1;
		cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int D;
	cin >> D;

	cout << "Christmas";
	for (int i = 0; i < 25 - D; i++) {
		cout << " Eve";
	}
}

Measured memory_bytes: 3604
def solve(n, a_list):
    res_list = [0] * n
    for a in a_list:
        res_list[a - 1] += 1
    return res_list


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    for r in res:
        print(r)


def test():
    assert solve(5, [1, 1, 2, 2]) == [2, 2, 0, 0, 0]
    assert solve(10, [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    assert solve(7, [1, 2, 3, 4, 5, 6]) == [1, 1, 1, 1, 1, 1, 0]


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 32408
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;

int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    if(n%(2*d+1)){
        printf("%d\n",n/(2*d+1)+1);
    }
    else{
        printf("%d\n",n/(2*d+1));
    }
    
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> G(N+1, 0);
    for (int i = 0; i < M; ++i) {
        int l, r; cin >> l >> r; --l;
        G[l]++;
        G[r]--;
    }
    for (int i = 0; i < N; ++i) G[i+1] += G[i];
    int res = 0;
    for (int i = 0; i < N; ++i) if (G[i] == M) ++res;
    cout << res << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    //fast;
    long long n;
    cin>>n;
    long long a[n],b[n]={0},i,ans=0,p;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n,greater<long long>());
    b[0]=1;
    p=n-2;
    for(i=1;i<n;i++)
    {
        b[i]=min(2LL,p);
        p-=b[i];
    }
    for(i=0;i<n;i++)
    {
        ans+=(a[i]*b[i]);
    }
    cout<<ans;
}


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

int main()
{
    int N, K, i;
    cin >> N >> K;
    int sum = 0;
    rep(j, N)
    {
        cin >> i;
        if (i < (K - i))
            sum += 2 * i;
        else
            sum += 2 * (K - i);
    }
    cout << sum << endl;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  int z = x*y;
  if (z%2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b;
	cin >> a >> b;
	if (a*b % 2 == 0){
		cout << "Even" << endl;
	}
	else{
		cout << "Odd" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int sum = 0;

  vector<int>V(N);
  for (int i = 0; i < N; i++)
  {
    cin >> V[i];
  }

  vector<int>C(N);
  for (int i = 0; i < N; i++)
  {
    cin >> C[i];
  }

  for (int i = 0; i < N; i++)
  {
    if (V[i]-C[i]>0)
    {
      sum += V[i] - C[i];
    }
  }
  cout << sum << endl;
}


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

const int N = 200 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int inf = 2 * mod;

int c[N];
int w[N];
int a[N];
bool mark1[N];
bool mark2[N];
int cnt[N];
long long fac[N];
int po(int x, int y) {
	if (y == 0)
		return 1;
	long long ans = po(x, y / 2);
	ans *= ans;
	ans %= mod;
	if (y % 2 == 1) {
		ans *= x;
		ans %= mod;
	}
	return ans;
}
int main() {
	int n, x, y;
	cin >> n >> x >> y;
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}
	for (int i = 1; i <= n; i++) {
		cin >> c[i] >> w[i];
	}
	w[0] = inf;
	int min1 = 0, min2 = 0;
	for (int i = 0; i <= n; i++) {
		a[i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		if (w[i] < w[min1]) {
			if (c[i] != c[min1]) {
				min2 = min1;
			}
			min1 = i;
		}
		else if (w[i] < w[min2]) {
			min2 = i;
		}
		if (w[i] < w[a[c[i]]]) {
			a[c[i]] = i;
		}
	}
	for (int i = 1; i <= n; i++) {
		mark1[i] = true;
	}
	for (int i = 1; i <= n; i++) {
		if (c[i] == c[min1]) {
			if (w[i] + w[min2] <= y) {
				mark2[i] = true;
				mark1[i] = true;
			}
		}
		else {
			if (w[i] + w[min1] <= y) {
				mark2[i] = true;
				mark1[i] = true;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (w[i] + w[a[c[i]]] <= x) {
			mark1[i] = true;
			mark2[i] |= mark2[a[c[i]]];
		}
	}
//	cout << min1 << " " << min2 << endl;
//	for (int i = 1; i <= n; i++) {
//		cout << "73 " << i << " " << mark1[i] << " " << mark2[i] << endl;
//	}
	if (w[min1] + w[min2] <= y) {
		int s = 0;
		for (int i = 1; i <= n; i++) {
		/*	if (mark1[i] && !mark2[i]) {
				cnt[c[i]]++;
			}*/
			if (mark2[i]) {
				s++;
				cnt[c[i]]++;
			}
		}
		long long ans = fac[s];
		for (int i = 1; i <= n; i++) {
			ans *= po(fac[cnt[i]], mod - 2);
			ans %= mod;
		}
		cout << ans << endl;
	}
	else {
	/*	for (int i = 1; i <= n; i++) {
			if (mark1[i])
				cnt[c[i]]++;
		}
		long long ans = 1;
		for (int i = 1; i <= n; i++) {
			ans *= fac[cnt[i]];
			ans %= mod;
		}
		cout << ans << endl;*/
		cout << 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5376
from sys import stdin

def main():
    from collections import deque
    import copy
    input = stdin.readline

    h, w = map(int, input().split())
    cm = [[0] * (w + 2) for _ in range(h + 2)]
    que = deque([])
    b = 0
    for i in range(1, h + 1):
        s = input()
        for j in range(1, w + 2):
            if s[j - 1] == ".":
                cm[i][j] = -1
            elif s[j - 1] == "#":
                b += 1
    que.append([1, 1, 0])
    while len(que) > 0:
        y, x, r = que.popleft()
        c = r + 1
        if cm[y + 1][x] == -1:
            cm[y + 1][x] = c
            que.append([y + 1, x, c])
        if cm[y - 1][x] == -1:
            cm[y - 1][x] = c
            que.append([y - 1, x, c])
        if cm[y][x + 1] == -1:
            cm[y][x + 1] = c
            que.append([y, x + 1, c])
        if cm[y][x - 1] == -1:
            cm[y][x - 1] = c
            que.append([y, x - 1, c])
    if cm[h][w] == -1:
        print(-1)
    else:
        print(h * w - b - cm[h][w] - 1)
main()

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

#define MAX 8

int main() {
  int n, buf;
  int sum;
  int i;
  cin >> n;
  
  buf = n;
  sum = 0;
  for (i=0; i < MAX ; i++) {
    if (buf > 10) {
      sum += buf % 10;
      buf /= 10;
    } else {
      sum += buf;
      break;
    }
  }
  
  if ((n % sum) == 0)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s, t; cin >> s >> t;

    vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));
    for (int i = 0; i < s.length(); i++) {
        for (int j = 0; j < t.length(); j++) {
            if (s[i] == t[j]) chmax(dp[i + 1][j + 1], dp[i][j] + 1);
            chmax(dp[i + 1][j + 1], dp[i + 1][j]);
            chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }
    string res = "";
    int i = s.length(), j = t.length();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i - 1][j]) {
            --i;
        } else if (dp[i][j] == dp[i][j - 1]) {
            --j;
        } else {
            res = s[i - 1] + res;
            --i, --j;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 35584
# -*- coding: utf-8 -*-
from sys import stdin
import math

fmt = "%.8f %.8f"
cos60 = math.cos(math.radians(60))
sin60 = math.sin(math.radians(60))

def koch(d,p1,p2):
    #線分(p1,p2)のp1,p2をセット→引数で（nだけでは座標を特定できない）
    #線分を三等分する２点s,tを頂点とした正三角形(s,u,t)を作成
    #線分p1,s s,u u,t t,p2に対して再帰的に繰り返す

    if d == 0:
        return
    sx = (2 * p1[0] + 1 * p2[0]) / 3
    sy = (2 * p1[1] + 1 * p2[1]) / 3
    tx = (1 * p1[0] + 2 * p2[0]) / 3
    ty = (1 * p1[1] + 2 * p2[1]) / 3

    dx = tx - sx
    dy = ty - sy

    ux = dx * cos60 - dy * sin60 + sx
    uy = dx * sin60 + dy * cos60 + sy

    koch(d - 1, p1, (sx, sy))
    print(fmt % (sx, sy))
    koch(d - 1, (sx, sy), (ux, uy))
    print(fmt % (ux, uy))
    koch(d - 1, (ux, uy), (tx, ty))
    print(fmt % (tx, ty))
    koch(d - 1, (tx, ty), p2)


n = int(stdin.readline().rstrip())

a_p1_x = a_p1_y = 0
a_p2_x = 100
a_p2_y = 0

print(fmt % (a_p1_x, a_p1_y))
koch(n, (a_p1_x, a_p1_y), (a_p2_x, a_p2_y))
print(fmt % (a_p2_x, a_p2_y))


Measured memory_bytes: 5768
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
int main(void) {
	int x, y, z,i,ans = 0;
	double r,a,b;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	scanf("%lf", &r);
	printf("%f %f\n",r*r*M_PI,2*r*M_PI);

	
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 2052
def mincost(n, k, A):
    dp = [0] * n
    for i in range(1, n):
        dp[i] = float('inf')
        for j in range(i - 1, i - k - 1, -1):
            if j >= 0:
                dp[i] = min(dp[i], dp[j] + abs(A[j] - A[i]))
    return dp[n - 1]
 
 
if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    A = list(map(int, input().split()))
    res = mincost(n, k, A)
    print(res)

Measured memory_bytes: 55136
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << v[k-1] << endl; 
  return 0;
}

Measured memory_bytes: 256
N = int(input())
sl = []
for n in range(N):
    sl.append(int(input()))

sum = sum(sl)
sorted_sl = sorted(filter(lambda s: s % 10 != 0,sl))
if len(sorted_sl) == 0:
    print(0)
    exit()
count = 0
while sum % 10 == 0 and count < len(sorted_sl):
    sum -= sorted_sl[count]
    count += 1

print(sum)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll N;
	cin >> N;
	ll f = N;
	ll sum = 0;
	while (f != 0){
		sum += (f - (f / 10) * 10);
		f /= 10;
	}
	if (0 == N % sum){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
 	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20200719AtCorder
{
    class Class1
    {
        static void Main(string[] args)
        {
            string[] inputs = Console.ReadLine().Trim().Split(" ");
            var a = int.Parse(inputs[0]);
            var b = int.Parse(inputs[1]);
            int ans = a * b;

            if (ans % 2 == 0)
	        {
                Console.WriteLine("Even");
            }
            else
            {
                Console.WriteLine("Odd");
            }
        }
    }
}


Measured memory_bytes: 26896
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

ll getVert(int bit, int k, vector<string> &arr)
{
	int r = __builtin_popcount(bit);
	int m = sz(arr[0]);
	vector<v32> help(r + 1, v32(m, 0));
	int prev = 0, curr_r = 0;
	for (int b = 0; b < 10; b++)
	{
		if ((bit & (1 << b)))
		{
			for (int c = 0; c < m; c++)
			{
				int sum = 0;
				for (int r = prev; r <= b; r++)
					sum += (arr[r][c] - '0');
				help[curr_r][c] = sum;
			}
			prev = (b + 1);
			curr_r++;
		}
	}
	for (int c = 0; c < m; c++)
	{
		int sum = 0;
		for (int r = prev; r < sz(arr); r++)
			sum += (arr[r][c] - '0');
		help[curr_r][c] = sum;
	}
	ll ans = 0;
	vector<int> cnt(r + 1, 0);
	for (int j = 0; j < m; j++)
	{
		for (int i = 0; i < r + 1; i++)
			if (cnt[i] > k)
				return 1e18;
		for (int i = 0; i < r + 1; i++)
			cnt[i] += help[i][j];
		//print_container(cnt);
		bool flag = true;
		for (int i = 0; i < r + 1; i++)
			if (cnt[i] > k)
			{
				flag = false;
				break;
			}
		if (!flag)
		{
			ans++;
			for (int i = 0; i < r + 1; i++)
			{
				cnt[i] -= help[i][j];
				if (cnt[i] > k)
					return 1e18;
				cnt[i] = help[i][j];
			}
		}
	}
	for (int i = 0; i < r + 1; i++)
		if (cnt[i] > k)
			return 1e18;
	return ans;
}

void solve()
{
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> arr(h);
	for (int i = 0; i < h; i++)
		cin >> arr[i];
	ll ans = 1e18;
	for (int i = 0; i < (1 << (h - 1)); i++)
	{
		ll temp = __builtin_popcount(i) + getVert(i, k, arr);
		if (temp < ans)
			ans = temp;
	}
	cout << ans << ln;
	return;
}

int main()
{
	//FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 256
#include <bitset>
#include <cstdio>
int n, a, s; std::bitset<4000001> b = 1;
int main() {
	scanf("%d", &n); 
	for (int i = 0; i < n; i++) scanf("%d", &a), s += a, b |= b << a;
	for (int i = s; i >= (s + 1) / 2; i--) if (b[i]) a = i;
	printf("%d\n", a);
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int N,M;
auto g = make_vec<int>(105,105);
vector<int> g2[105];

int main() {
    cin >> N >> M;

    fill_v(g,inf);

    vector<int> a(M);
    vector<int> b(M);
    vector<int> c(M);
    REP(i,M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        g[a[i]][b[i]]=g[b[i]][a[i]]=c[i];
    }
    REP(i,N) g[i][i]=0;

    REP(k,N) REP(i,N) REP(j,N) chmin(g[i][j],g[i][k]+g[k][j]);

    int ans=M;
    for(int i = 0; i < M; ++i){
        bool shortest=false;
        for(int j = 0; j < N; ++j) if(g[j][a[i]]+c[i]==g[j][b[i]]) shortest=true;
        if(shortest==true){
            ans -= 1;
        }
    }

    pl(ans)

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e5 + 5;
 
int32_t main()
{
	IOS;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	std::map<ll,ll> map1;
	ll n,b,c,q,sum=0;cin>>n;
	ll arr[n];
	f(i,0,n){
		cin>>arr[i];
		map1[arr[i]]++;
		sum+=arr[i];
	}
	cin>>q;
	while(q--){
		cin>>b>>c;
		ll z=map1[b];
		sum-=z*b;
		sum+=c*z;
		cout<<sum<<endl;
		map1[c]+=z;
		map1[b]=0;
	}

	return 0;
}

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

using namespace std;

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

const ll mod=1e9+7;

int main(){
    vector<ll> a(26);
    string s;
    cin >> s;
    ll n=s.length();
    rep(i,n){
        ll v=s[i]-'a';
        a[v]++;
    }
    rep(i,26){
        if(a[i]==0){
            char c='a'+i;
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
} 


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

#define rep(i, k, n) for(int i = (k); i < (n); i++)
#define irep(i, k, n) for(int i = (k); i > (n); i--)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  int odd = (n+1)/2;
  cout << fixed << setprecision(10) << (double)odd/n << endl;
  return 0;
}

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

int main()
{
	int h, w;
	int i, j;
	
	while(1){
		cin >> h >> w;
		if(h==0&&w==0)
			break;
		
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	
	return 0;
}

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<float> v(n);
  rep(i,n) cin >> v[i];

  sort(v.begin(), v.end());

  float ans = v[0];
  rep(i, n) {
    ans = (v[i] + ans) / 2;
  }
  cout << ans << endl;
}


/*





















*/


Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, m := scanInt(), scanInt()
	ans := make([]int, n+1)
	for i := 0; i < m; i++ {
		a, b := scanInt(), scanInt()
		ans[a]++
		ans[b]++
	}

	var wr = bufio.NewWriter(os.Stdout)
	for _, v := range ans[1:] {
		wr.WriteString(strconv.Itoa(v) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
 
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
int num[3][3];
int main(){
  double t,x;
  cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;long long x[50],y[50];
  cin >>n>>k;
  for (int i=0;i<n;i++){
    cin >>x[i]>>y[i];
  }
  long long ans = 9223372036854775807;
  for (int i1=0;i1<n;i1++){
    for (int i2=0;i2<n;i2++){
      for (int i3=0;i3<n;i3++){
        for (int i4=0;i4<n;i4++){
          int l = 0;
          for (int j=0;j<n;j++){
            if (x[i1]<=x[j] && x[j]<=x[i2] && y[i3]<=y[j] && y[j]<=y[i4]){
              l++;
            }
          if (l==k){
            ans = min (ans, abs((x[i1] - x[i2]) * (y[i3] -y[i4])));
  }
  }
  }
  }
  }}
  cout <<ans<<endl;}


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

int is_even(int x,int k)
{
	int cnt=0,digit;
	while(x!=0)
	{
		digit=x/k;
		cnt++;
		x=x/k;
	}
	
	return cnt;
}

int main()
{
	int n,k;
	cin>>n>>k;
	
	cout<<is_even(n,k)<< endl;
	return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self,size):
        self.parent=range(size)
        self.tree_num=size
        self.tree_w=[1]*size
        self.rank=[0]*size

    def findset(self,x):
        if self.parent[x]==x:
            return x
        else:
            self.parent[x]=self.findset(self.parent[x])
            return self.parent[x]

    def unite(self,x,y):
        x=self.findset(x)
        y=self.findset(y)
        if x==y:
            return
        if self.rank[x]<self.rank[y]:
            self.parent[x]=y
            self.tree_num-=1
            self.tree_w[y]+=self.tree_w[x]
        else:
            self.parent[y]=x
            self.tree_num-=1
            self.tree_w[x]+=self.tree_w[y]
            if self.rank[x]==self.rank[y]:
                self.rank[x]+=1

    def tree_weight(self,x):
        return self.tree_w[self.findset(x)]

n=int(raw_input())
a=map(int,raw_input().split())
p=[0]*(n+1)
for i in xrange(n):
    p[a[i]]=i

uf=UnionFind(n+1)
ans=0
for j in xrange(n,0,-1):
    i=p[j]
    tmp=1
    if i>=1 and a[i]<a[i-1]:
        tmp*=uf.tree_weight(a[i-1])+1
        uf.unite(a[i],a[i-1])
    if i<n-1 and a[i]<a[i+1]:
        tmp*=uf.tree_weight(a[i+1])+1
        uf.unite(a[i],a[i+1])
    ans+=j*tmp
print(ans)

Measured memory_bytes: 25116
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
  cur = bin(i)[2:]
  cur = '0' * (l-1-len(cur)) + cur
  d = s[0]
  for j in range(l-1):
    if cur[j] == '1':
      ans += int(d)
      d = s[j+1]
    else:
      d += s[j+1]
  ans += int(d)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> ans(n, 0);

	bool elf = true;
	for (int i = n - 1; i >= 0; --i) {
		int res = 0;
		for (int j = i + (i + 1); j < n; j += (i + 1)) {
			res ^= ans[j];
		}
		ans[i] = res ^ a[i];
	}
	int ans1 = 0;
	rep(i, n) ans1 += ans[i];
	dunk(ans1);

	rep(i, n) {
		if (ans[i]) dunk(i + 1);
	}

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  string s, t;
  cin >> s >> t;

  for (char c = 'a'; c <= 'z'; c++) {
    if (t == s + c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

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

const int64_t MOD = 998244353;

int main() {
    int64_t N,S;
    cin >> N >> S;
    vector<int64_t> A(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> A[i];
    }
    
    vector<vector<int64_t>> dp(N+1,vector<int64_t>(S+1,0));
    dp[0][0] = 1;
    for ( int64_t i = 1; i <= N; ++i){
        for ( int64_t j = 0; j <= S; ++j){
            if ( j - A[i-1] >= 0 ) {
                dp[i][j] = ( dp[i-1][j] * 2 + dp[i-1][j-A[i-1]] ) % MOD;
            } else {
                dp[i][j] = dp[i-1][j] * 2 % MOD;
            }
        }
    }
    
    if ( dp[N][S] < 0 ) dp[N][S] += MOD;
    cout << dp[N][S] << endl;
    
    
    return 0;
}


Measured memory_bytes: 73640
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  string result = "No";
  if (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ) result = "Yes";
  cout << result << endl;
  return 0;
}

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

int main()
{
  char s[11],t[11],u[11];
  int a,b;
  scanf("%s%s",&s,&t);
  scanf("%d%d",&a,&b);
  scanf("%s",&u);
  if(strcmp(s,u)==0)
      printf("%d %d",a-1,b);
  
  else
     printf("%d %d",a,b-1);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);   //System.in: キーボード入力を受け付けるための引数
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        if (a*b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


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

int main(){
  unsigned int s;
  int q;
  cin >> q;
  for(int i = 0;i < q;++i){
    scanf("%x",&s);
    double temp = 0;
    double t = pow(0.5, 7);

    for(int i = 0;i < 31;++i){
      int b = s % 2;
      temp += (double)b * t;
      
      t *= 2;
      s /= 2;
    }

    if(s % 2){
      cout << "-";
    }

    int n = (int)temp;
    long long m = (long long)(n * pow(10.0 ,7.0));
    long long l = (long long)(temp * pow(10.0 ,7.0));
    if((double)n == temp){
      cout << n << ".0" << endl;
    }else{
      long long x = l - m;
      int tmp = x;
      string st = "";
      for(int j = 0;j < 7;j++){
	if(tmp == 0){
	  st += "0";
	}
	tmp /= 10;
      }
      while(x % 10 == 0){
	x /= 10;
      }
      cout << n << "." << st << x << endl;
    }

  }

  return 0;
}



Measured memory_bytes: 3240
import sys
import math

input = sys.stdin.readline

def check(x):
    for n in range(2, int(math.sqrt(x)) + 1):
            if x % n == 0:
                return False
    return True

def main():
    ans = 0
    x = int(input())
    while check(x) == False:
        x += 1
    print(x)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <cstdio>
int n, s, a;
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; i++) {
		scanf("%d", &a);
		if(a==i) {
			s++;
			scanf("%*d"), i++;
		}
	}
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 128
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 K = sc.nextInt();
        long[] arr = new long[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        long min = Integer.MAX_VALUE;
        for(int i = 0; i < N - K + 1; i++) {
            long tmp = arr[i+K-1] - arr[i];
            min = Math.min(min, tmp);
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 59856
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  ll N;
  cin >> N;
  long double A = N;
  long double x = sqrtl(A);
  int b = 1;
  for(int i = 1;i<=x;i++){
    if(N%i == 0){
      b = max(i,b);
    }
  }

  cout << b + N/b -2 << endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  ll n,k;
  cin >> n >> k;

  vector<mint> cnt(k+1);
  rep(i,k){
    int ki = k-i;
    cnt[ki] = mint(k/ki).pow(n);
    for(int ni = 2*ki; ni<=k; ni+=ki){
      cnt[ki] -= cnt[ni];
    }
  }

  mint ans = 0;
  rep(i,k){
    ll gcd = i + 1;
    ans += mint(gcd)*cnt[gcd];
  }
  cout << ans << endl;
}


Measured memory_bytes: 3560
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,n,cube[50],stk[50],red,front;
char col[10];

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

void roll(int dir){
	if(dir==0){swap(&stk[0],&stk[2]);swap(&stk[2],&stk[5]);swap(&stk[5],&stk[3]);}
	if(dir==1){swap(&stk[0],&stk[3]);swap(&stk[3],&stk[5]);swap(&stk[5],&stk[2]);}
	if(dir==2){swap(&stk[0],&stk[1]);swap(&stk[1],&stk[5]);swap(&stk[5],&stk[4]);}
	if(dir==3){swap(&stk[0],&stk[4]);swap(&stk[4],&stk[5]);swap(&stk[5],&stk[1]);}
	if(dir==4){swap(&stk[1],&stk[2]);swap(&stk[2],&stk[4]);swap(&stk[4],&stk[3]);}
	if(dir==5){swap(&stk[1],&stk[3]);swap(&stk[3],&stk[4]);swap(&stk[4],&stk[2]);}
}

int main(){
	while(scanf("%d",&n)*n){
		k=0;
		for(i=0;i<n;i++){
			for(j=0;j<6;j++){
				scanf("%s",col);
				if(col[0]=='R'){stk[j]=0;red=j;}
				else if(col[0]=='Y')stk[j]=1;
				else if(col[0]=='B')stk[j]=2;
				else if(col[0]=='M')stk[j]=3;
				else if(col[0]=='G')stk[j]=4;
				else if(col[0]=='C')stk[j]=5;
			}
			
			if(red==1)roll(2);
			else if(red==2)roll(0);
			else if(red==3)roll(1);
			else if(red==4)roll(3);
			else if(red==5){roll(0);roll(0);}

			if(stk[5]==1)front=2; else front=1;
			while(stk[1]!=front)roll(4);

			cube[k]=0;
			for(j=0;j<6;j++)cube[k]=cube[k]*10+stk[j];
			
			for(j=0;j<k;j++){if(cube[j]==cube[k])break;}
			if(j==k)k++;
			continue;
		}
		printf("%d\n",n-k);
	}
	return 0;
}

Measured memory_bytes: 600