akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
    return (a.second < b.second);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
ll sumofdigit(ll n)
{
    ll c=0,d=0,sum=0,i;
    while(n>0)
    {
        c=n%10;
        sum+=c;
        n/=10;
    }
    return sum;
}

int main()
{
     fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
       ll  m,k,i,j,c=0,d=0,e=0,f=0,sum=0,g=0,h=0,n,maxi=0;
      cin>>n;
      k=100;
      while(true)
      {
          c=k;
          e=c/100;
          k+=e;
          sum++;
          if(k>=n)
          {
              break;
          }
      }
      cout<<sum<<endl;
     }


}


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

int main() {
    int n, m;
    cin >> n;
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    rep(i,m) {
        string t;
        cin >> t;
        mp[t]--;
    }
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans = max(itr->second, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())

p=list(map(int,input().split()))
count=0
jugh=0
for i in range(n):
    if p[i]==i+1:
        if jugh!=1:
            jugh=1
            count+=1
        else:
            jugh=0
    else:
        jugh=0

print(count)

Measured memory_bytes: 14008
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

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

    cout << (a + b < c ? "No" : "Yes") << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

const long long mod=1000000007;

int n,x,dep,d[200001],hd[200001],cnt,ma,num,ou[200001];
long long er[200001],f[200001][3],ans,f0,f1,f2;

struct node
{
	int to,next,la;
}e[400001];

void addedge(int x,int y)
{
	e[++cnt].next=hd[x];
	e[cnt].la=0;
	e[hd[x]].la=cnt;
	hd[x]=cnt;
	e[cnt].to=y;
}

void del(int x,int i)
{
	if (hd[x]==i) hd[x]=e[i].next,e[hd[x]].la=0;
	else e[e[i].next].la=e[i].la,e[e[i].la].next=e[i].next;
}

void dfs(int x)
{
	if (d[x]==dep)
	{
		f[x][0]=f[x][1]=1; f[x][2]=0;
		num++; return;
	}
	f[x][0]=1; f[x][1]=f[x][2]=0;
	for (int i=hd[x]; i; i=e[i].next)
	{
		dfs(e[i].to);
		f0=f[x][0]; f1=f[x][1]; f2=f[x][2];
		f[x][0]=f0*(f[e[i].to][0]+f[e[i].to][2])%mod;
		f[x][1]=(f0*f[e[i].to][1]+f1*(f[e[i].to][0]+f[e[i].to][2]))%mod;
		f[x][2]=(f1*f[e[i].to][1]+f2*(f[e[i].to][0]+f[e[i].to][1]+f[e[i].to][2]))%mod;
		if (ou[e[i].to]==1) addedge(x,e[hd[e[i].to]].to),del(x,i); else
		if (ou[e[i].to]==0) del(x,i);
	}
}

int main()
{
	scanf("%d",&n); cnt=0;
	memset(hd,0,sizeof(hd)); d[0]=1;
	memset(ou,0,sizeof(ou));
	for (int i=1; i<=n; i++) scanf("%d",&x),addedge(x,i),d[i]=d[x]+1,ou[x]++;
	ma=1;
	for (int i=1; i<=n; i++)
		if (d[i]>ma) ma=d[i];
	er[0]=1;
	for (int i=1; i<=n; i++) er[i]=er[i-1]*2ll%mod;
	ans=er[n];
	for (dep=2; dep<=ma; dep++) 
	{
		num=0; dfs(0);
		ans=(ans+er[n+1-num]*f[0][1])%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13440
# -*- coding:utf-8 -*-

def solve():
    O = input()
    E = input()

    ans = ""
    for i in range(len(O)):
        ans += O[i]
        if i >= len(E):
            continue
        ans += E[i]
    
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
//N = number of atoms

int main()
{
  //int i,j,k,l;
  double L;
  double i;
  double ans;
  
  scanf("%lf",&L);
  i = (L/3.0);
  ans = (i*i*i);
  
  printf("%f\n",ans);


  
  return 0; 
  
}

Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	e = [Int[] for i in 1:n]
	x = Tuple{Int,Int}[(0,0) for i in 1:n-1]
	for i in 1:n-1
		a,b = readline() |> split |> parseMap
		push!(e[a],b)
		push!(e[b],a)
		x[i] = (a,b)
	end
	vst = -ones(Int,n)
	stack = Int[]
	vst[1] = 0
	d = Dict{Tuple{Int,Int},Int}()
	m = length(e[1])
	for i in 1:length(e[1])
		vst[e[1][i]] = i
		push!(stack,e[1][i])
		d[(1,e[1][i])] = i
	end
	while !isempty(stack)
		now = shift!(stack)
		o = 1
		for i in 1:length(e[now])
			if vst[e[now][i]] < 0
				if o==vst[now]
					o += 1
				end
				vst[e[now][i]] = o
				push!(stack, e[now][i])
				d[(now,e[now][i])] = o
				o += 1
			end
		end
		m = max(m,length(e[now]))
	end
	println(m)
	for i in 1:n-1
		if haskey(d,x[i])
			println(d[x[i]])
		else
			println(d[(x[i][2],x[i][1])])
		end
	end
end
main()

Measured memory_bytes: 173464
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
long long sum(long long n) {
    return (n*(n+1))/2;
}
int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long n;
    cin>>n;
    long long total=sum(n);
    long long a=3*sum(n/3);
    long long b=5*sum(n/5);
    long long c=15*sum(n/15);
    long long ans=total-a-b+c;
    cout<<ans<<endl;   

}


Measured memory_bytes: 3652
/*
   Username : moondancer
   Name : Moon Dancer
*/


#include <bits/stdc++.h>
using namespace std;

#define int long long

vector<int> v[200005];
bool v2[200005];
int s;

void dfs(int x){
    s++;
    v2[x]=1;
    for(int i:v[x]){
        if(!v2[i]){
            dfs(i);
        }
    }
}

signed main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    for (int i = 0; i < m; ++i){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int ans=0;
    for(int i=1; i<=n; ++i){
        if(!v2[i]){
            s=0;
            dfs(i);
            ans=max(ans,s);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 20992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(c, i, n) for (int i = c; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans;
    if (A == 0)
    {
        ans = 0;
    }
    else if (N % (A + B) < A)
    {
        ans = (N / (A + B)) * A + N % (A + B);
    }
    else if (N % (A + B) >= A)
    {
        ans = (N / (A + B)) * A + A;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

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

  int o = 0;
  int e = 0;
  repp(i, 1, N) {
    if (i % 2 == 0)
      e++;
    else
      o++;
  }

  cout << (double)o / (double)(o + e) << endl;
}

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

int main()
{
    int n;
    int k;
    int x;
    int y;
    int m;

cin>>n>>k>>x>>y;

    if ((n - k) > 0)
    {
        m = k*x+(n-k)*y;
        cout<<m<<endl;
    }
    else
    {
        m =n*x;
        cout<<m<<endl;
    }



    return 0;
}


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

namespace AtCoder {

    class Program {


        static void Main(string[] args) {

            var temp = Console.ReadLine();

            var map = new Dictionary<string, string>() {
                { "A", "T" },
                { "C", "G" },
                { "T", "A" },
                { "G", "C" }
            };

            Console.WriteLine(map[temp]);
        }
    }
}


Measured memory_bytes: 11104
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int n, k, t = 1, cnt = 0;
    scanf("%d%d\n", &n, &k);
    vector<char> c(n);
    vector<int> d;
    scanf("%s", c.begin());
    for (int i = 0; i < n; ++i) {
        if (c.at(i) - '0' == t) ++cnt;
        else t = !t, d.push_back(cnt), cnt = 1;
    }
    d.push_back(cnt);
    if (!t) d.push_back(0);
    int sum = accumulate(d.begin(), d.begin() + min(2 * k + 1, int(d.size())), 0), ans = sum;
    for (int i = 2 * k + 1; i < int(d.size()); i += 2) {
        sum += d.at(i) + d.at(i + 1) - d.at(i - 2 * k) - d.at(i - 2 * k - 1);
        ans = max(ans, sum);
    }
    printf("%d\n", ans);
    return 0;
}


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

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

    int l = 0;
    for (int i = 0; i < n; i++)
    {
        bool f = true;
        for (int j = i; j < n; j++)
        {
            if (s[j] != t[j - i])
                f = false;
        }
        if (f)
        {
            // cout << n - i << endl;
            l = n - i;
            break;
        }
        // if (i == n-1 && l ==)
        // {
        // l = 0;
        // }
    }
    cout << 2 * n - l << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n ,m;
  int k[30];
  int a[30][30];
  int count = 0;

  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &k[i]);
    for (int j = 0; j < k[i]; j++) {
      scanf("%d", &a[i][j]);
    }
  }

  for (int i = 0; i < k[0]; i++) {
    int temp = 0;
    for (int j = 1; j < n; j++) {
      for (int l = 0; l < k[j]; l++) {
	if (a[j][l] == a[0][i]) {
	  temp++;
	  break;
	}
      }
    }
    if (temp == n - 1)
      count++;
  }  
	
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of jonathanirvings' template v3.0.3 (BETA)

int r,c;
string data[505];
string A[505],B[505];

int main()
{
  scanf("%d %d",&r,&c);
  REP(i,r)
  {
    REP(j,c)
    {
      A[i] += '.';
      B[i] += '.';
    }
  }
  REP(i,r)
  {
    data[i] = GetString();
    REP(j,c)
    {
      if (j == 0) A[i][j] = '#';
      if (j == c - 1) B[i][j] = '#';
      if (i % 2 == 0 && j < c - 1) A[i][j] = '#';
      else if (i % 2 == 1 && j > 0) B[i][j] = '#';
      if (data[i][j] == '#')
      {
        A[i][j] = B[i][j] = '#';
      }
    }
  }
  REP(i,r)
  {
    REP(j,c) printf("%c",A[i][j]);
    puts("");
  }
  puts("");
  REP(i,r)
  {
    REP(j,c) printf("%c",B[i][j]);
    puts("");
  }
  return 0;
}










Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int>g[N];
int freq[N],bad,dp[N],ans = 1e9,n,sz[N];
bool col[N],vis[N];
queue<int>q;
string s;
void calc(int u,int p){
	vis[u] = 1;
	int at = (sz[u] + col[u])&1 ? 0 : -2,mn = 1e9,mn2 = 1e9;
	for(auto i : g[u])
		if(i != p && !vis[i]){
			calc(i,u);
			mn2 = min(mn2,dp[i]);
			if(mn2 < mn)swap(mn,mn2);
		}
	dp[u] = min(0,mn) + at;
	ans = min(ans,min(dp[u],mn + mn2 + at));
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 1,a,b;i < n;i++)
		scanf("%d%d",&a,&b),
		g[--a].push_back(--b),
		g[b].push_back(a);
	cin >> s;
	int temp = 0;
	for(int i = 0;i < n;i++)col[i] = s[i] == 'B';
	for(int i = 0;i < n;i++)temp+=!col[i];
	if(!temp)return printf("%d\n",temp),0;
	for(int i = 0;i < n;i++)
		if(g[i].size() == 1 && col[i])q.push(i),vis[i] = 1;
	temp = 0;
	while(!q.empty()){
		int x = q.front();
		temp++;
		q.pop();
		for(auto i : g[x])
			if((++freq[i]) + 1 == g[i].size() && col[i])
				vis[i] = 1,
				q.push(i);
	}
	for(int i = 0;i < n;i++)
		for(auto j : g[i])sz[i]+=!vis[j];
	for(int i = 0;i < n;i++)
		if(!vis[i] && !((sz[i] + col[i])&1))bad++;
	for(int i = 0;i < n;i++)if(!vis[i])calc(i,-1);
	if (temp + 1 == n)printf("1\n");
	else printf("%d\n",2*(n - 1 - temp) + ans + bad);
}

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

class Program
{
    //static int[] dp;
    //static decimal[,,] dp;
    //static decimal N;
    static void Main(string[] args)
    {
        // 入力
        int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        int N = input[0];
        int M = input[1];
        input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        List<int> cost = new List<int>(input);
        cost.Sort((a, b) => (b - a));

        // 一番値段の高いものに割引券を使う
        for (int i = 0; i < M; i++)
        {
            PK(ref cost); // 要素0番目を適切な位置にする

            //// リストの中身を表示する
            //for(int j=0; j<N; j++)
            //{
            //    Console.Write(cost[j] + " ");
            //}
            //Console.WriteLine();
        }

        // 割引券を全部使った
        long check = 0;
        for (int i = 0; i < N; i++)
        {
            check += cost[i];
        }

        Console.WriteLine(check + "");
    }

    private static void PK(ref List<int> cost)
    {
        cost[0] = cost[0] / 2;
        // 要素0をいい感じにする
        // 末端に行くまでしたと入れ替えていく
        // i*2 + 1番目と i*2+2番目とくらべる
        int len = cost.Count;
        int i = 0;
        while (true)
        {
            // 二つの子の大きいほうとスワップする
            bool left = true;
            if(i*2+2 < len)
               left = (cost[i * 2 + 1] > cost[i * 2 + 2]);

            if (left && (i * 2 + 1) < len && cost[i] < cost[i * 2 + 1])
            {
                int tmp = cost[i];
                cost[i] = cost[i * 2 + 1];
                cost[i * 2 + 1] = tmp;
                i = i * 2 + 1;
            }
            else if (!left && (i * 2 + 2) < len && cost[i] < cost[i * 2 + 2])
            {
                int tmp = cost[i];
                cost[i] = cost[i * 2 + 2];
                cost[i * 2 + 2] = tmp;
                i = i * 2 + 2;
            }
            else
            {
                break;
            }
        }
    }


}


Measured memory_bytes: 30812
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
map< string , int > mp;
int main()
{
	dhoom;
	int a , b , c , d;
	cin >> a >> b >> c >> d;
	int dx = c - a;
	int dy = d - b;
	cout <<  c - dy << " " << d + dx << " " << a - dy << " " << b + dx << endl;
	return 0;
} 



Measured memory_bytes: 256
/*input
106
0
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.trim().to_string()
}

fn main() {
    let mut s;
    let mut total: u32;
    loop {
        s = read_line();
        if s == format!("0") {
            break;
        }
        total = 0;
        for i in s.chars() {
            total = total + i.to_digit(10).unwrap();
        }
        println!("{}", total);
    }
}



Measured memory_bytes: 5036
using System;
using System.Linq;

class Program
{
  public static void Main(string[] args)
  {
    int n = int.Parse(Console.ReadLine());
    int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int count = 0;
    while(true) {
      for (int i = 0; i < n; i ++) {
        if (s[i] % 2 == 1) goto end;
        s[i] /= 2;
      }
      count ++;
    }
    end :;
    Console.WriteLine(count);
  }
}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 1005
#define maxv 10005
int n,a[maxn],s;
int b[maxn],t[maxv];
int solve()
{
    int ans=0;
    bool v[maxn];
    for(int i=0;i<n;++i)
    {
        b[i]=a[i];
        v[i]=false;
    }
    sort(b,b+n);
    for(int i=0;i<n;++i) t[b[i]]=i;
    for(int i=0;i<n;++i)
    {
        if(v[i]) continue;
        int cur=i;
        int S=0;
        int m=maxv;
        int an=0;
        while(true)
        {
            v[cur]=true;
            an++;
            int V=a[cur];
            m=min(m,V);
            S+=V;
            cur=t[V];
            if(v[cur]) break;
        }
        ans+=min(S+(an-2)*m,m+S+(an+1)*s);
    }
    return ans;
}
int main()
{
    cin>>n;
    s=maxv;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        s=min(a[i],s);
    }
    int ans=solve();
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3164
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
 
int main(){
    int N;
    cin >> N;
    vector<ll> ans;
    while (N!=0)
    {
        vector<ll> a;
        a.resize(N);
        Rep(i, N) cin >> a[i];
        ll thismin = 1e10;
        Rep(i, N) {
            Rep(n, N) {
                if (n == i) continue;
                thismin = min(thismin, abs(a[i] - a[n]));
            }
        }
        ans.push_back(thismin);
        cin >> N;
    }
    Foreach(i, ans) out(i);
    return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>

int main(void){

  int a,b;
  int d,r;
  double f;

  scanf("%d%d",&a,&b);

  d=a/b;
  r=a%b;
  f=(double)a/b;

  printf("%d %d %.5lf\n",d,r,f);

  return 0;
}

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

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

  // 素因数分解する
  vector<pair<ll, int>> f;
  ll m = (ll)sqrt(n);
  for (ll i = 2; i <= m; i++) {
    if (i > n) break;
    int cnt = 0;
    while (n % i == 0 && n >= 1) {
      cnt++;
      n /= i;
    }
    if (cnt != 0) f.emplace_back(i, cnt);
  }
  if (n != 1) f.emplace_back(n, 1); // √nより大きい最後の約数を入れる

  int ans = 0;
  for (auto p : f) {
    int x = p.second;
    int b = 1;
    while (x >= b) {
      x -= b;
      b++;
      ans++;
    }
  }

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

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define cY cout << "Yes" << endl;
#define cN cout << "No" << endl;

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll>h(n);
  rep(i,n) cin >> h.at(i);
  sort(h.begin(),h.end());
  ll sum = 0;
  rep(i,n-k) sum += h.at(i);
  cout << sum << endl;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	if(A+B>C*2){
		if(X <= Y){
			if(B>C*2){
			  cout << max(X,Y)*C*2 << endl;	
			}else{
				cout << C * X * 2 + B * (Y - X) << endl;			
			}
		}else{
			if(A>C*2){
			  cout << max(X,Y)*C*2 << endl;
			}else{
				cout << C * Y * 2 + A * (X - Y) << endl;
			}
		}
		/*
		if(min(A,B)<C*2){
			if(X >= Y){
				cout << C * Y * 2 + A * (X - Y) << endl;
			}else{
				cout << C * X * 2 + B * (Y - X) << endl;
			}
		}else{
			cout << max(X,Y)*C*2 << endl;
		}*/
	}else{
		cout << A*X+B*Y << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#import numpy as np
import math
#T= str(input())
#K = int(input())
x1,y1,x2,y2= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())

a=x2-x1
b=y2-y1

print(x2-b,y2+a,x1-b,y1+a)
exit()


Measured memory_bytes: 2940
N = int(input())
l = [1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
dp = [float('inf')] * (N + 1)
dp[0] = 0

for i in range(12):
    for j in range(l[i], N + 1):
        dp[j] = min(dp[j], dp[j - l[i]] + 1)
print(dp[N])


Measured memory_bytes: 6900
// tenka12019_a

#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  if((a < c && c < b) || (b < c && c < a)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


int main()
{
  unsigned long long H;
  cin >> H;

  unsigned long long S = 1;

  while(1){
    if(S > H){
      S /= 2;
      break;
    }
    S *= 2;
  }

  unsigned long long sum = 0;

  while(S>1){
    sum += S;
    S /= 2;
  }

  cout << sum+1 << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
job = []
for _ in range(N):
    a,b = map(int,input().split())
    job.append((a,b))
from operator import itemgetter
job_sort = sorted(job, key = itemgetter(1))
import sys
time = 0
for i in range(N):
    time += job_sort[i][0]
    if time>job_sort[i][1]:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 103944
<?php
  list($n, $m, $l) = explode(" ", trim(fgets(STDIN)));
  $ary_a = array();
  for($i=0; $i < $n; $i++) {
    $line_a = explode(" ", trim(fgets(STDIN)));
    array_push($ary_a, $line_a);
  }
  $ary_b = array();
  for($i=0; $i < $m; $i++) {
    $line_b = explode(" ", trim(fgets(STDIN)));
    array_push($ary_b, $line_b);
  }
  for($i=0; $i < $n; $i++) {
    $eee = array();
    for($f=0; $f < $l; $f++) {
      $sum = 0;
      for($r=0; $r < $m; $r++) {
        $sum += ($ary_a[$i][$r] * $ary_b[$r][$f]);
      }
      // print($sum . " ");
      array_push($eee, $sum);
    }
    if ($i == $n-1) {
      print(join(" ", $eee));
    } else {
      print(join(" ", $eee) . "\n");
    }
  }
?>

Measured memory_bytes: 10164
N=int(input())
H=list(map(int, input().split()))

lengthList=[]
length=0
topHeight=H[0]
length=0
update=False
for i in range(len(H)-1):

    if H[i] < H[i+1] :
        topHeight=H[i+1]
        #print(i)
        #print(length)
        lengthList.append(length)
        length=0
        update=True

    else:
        length=length+1
        update=False

if(update==False):
    lengthList.append(length)
#print(lengthList)
print(max(lengthList))

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#define rep(i, n)   for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

bool primejudge(int n){
    //素数:true
    bool flag = true;
    for(int i = 2; i < n; i++){
	if(n%i == 0)	flag = false;
    }
    if(n == 1)	flag = false;
    return flag;
}

int main(){
    int n;  cin >> n;
    const int mod = 1000000000+7;
    vector<pair<int, int> >prime;
    for(int i = 1; i <= n; i++){
	if(primejudge(i)){
	    prime.emplace_back(i, 1);
	}else{
	    int tmp = i;
	    rep(j, prime.size()){
		while(tmp%prime[j].first == 0){
		    tmp /= prime[j].first;
		    prime[j].second++;
		}
	    }
	}
    }
    ll ans = 1;
    rep(i, prime.size()){
	ans *= (1+prime[i].second);
	ans %= mod;
    }
    cout << ans << endl;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	string s; cin >> s;
	if(s[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}

	bool isC = false;
	int ic = -1;
	FOR(i, 2, s.size()-1){
		if(s[i] == 'C'){
			if(isC){
				cout << "WA" << endl;
				return 0;
			}
			isC=true;
			ic = i;
		}
	}
	if(!isC){
		cout << "WA" << endl;
		return 0;
	}

	REP(i, s.size()){
		if(i==0||i==ic) continue;
		if( ! ('a' <= s[i] && s[i] <= 'z') ){
			cout << "WA" << endl;
			return 0;
		}
	}
	cout << "AC";
	return 0;
}


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

int main(void) {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];
  vector<int> ans(n, 0);
  
  for (int i=0; i<k; i++) {
    vector<long long> ls(n, 0);
    vector<long long> rs(n, 0);
    
    for (int j=0; j<n; j++) {
      int l = max(j - a[j], 0);
      int r = min(j + a[j], n-1) + 1;
      ls[l]++;
      if (r < n) rs[r]++;
    }
    
    ans[0] = ls[0] - rs[0];
    
    for (int j=1; j<n; j++) {
      ls[j] += ls[j-1];
      rs[j] += rs[j-1];
      ans[j] = ls[j] - rs[j];
    }
    
    for (int j=0; j<n; j++) a[j] = ans[j];
    
    bool breakflag = true;
    for (int j=1; j<n; j++) {
      if (ans[j] != ans[j-1] || ans[j] != n) {
        breakflag = false;
        break;
      }
    }
    if (breakflag) break;
    
  }
  
  for (int i=0; i<n; i++) cout << ans[i] << " ";

}


Measured memory_bytes: 7992
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    S = [""] * N
    for i in range(N):
        S[i] = input().rstrip()

    c = Counter(S)
    ans = []
    prev_v = 0
    for k, v in c.most_common():
        if prev_v == 0:
            prev_v = v
        else:
            if prev_v != v:
                break
        ans.append(k)

    ans.sort()
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 45140
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 100010
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int h[N],mx[N],ans,n;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		h[i]=read();
	}
	for(int i=2;i<=n;i++){
		if(h[i]<=h[i-1]){
			mx[i]=mx[i-1]+1;
		}
		ans=max(mx[i],ans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
#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, D, X;
  cin >> N >> D >> X;
  int co = 0;
  int A;
  int AA;
  int sum = 0;
  rep(i, N) {
    cin >> A; 
    AA = A;
    while(true) {
      co++;
      if(co == 1) {
        AA = A + 1;
      }
      else {
        AA = AA + A;
      }
      if(AA > D) {
        break;
      }
    }
    sum += co;
    co = 0;
  }
  cout << sum + X << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int firstIndex = S.length();
		int lastIndex = S.length();
		char[] sArray = S.toCharArray();
		for (int i = 0; i < sArray.length; i++) {
			if (sArray[i] == 'A') {
				firstIndex = i;
				break;
			}
		}
		for (int i = 0; i < sArray.length; i++) {
			if (sArray[i] == 'Z')
				lastIndex = i;
		}
		System.out.println(S.substring(firstIndex, lastIndex + 1).length());
		sc.close();
	}
}

Measured memory_bytes: 26440
n, m = map(int, input().split(' '))
k = []
s = []
for i in range(m):
    a = list(map(int, input().split(' ')))
    k.append(a[0])
    s.append(a[1:])
p = list(map(int, input().split(' ')))
ans = 0
for i in range(2**n):
    ri_cnt = 0
    for j in range(m):
        sw_cnt = 0
        for l in range(k[j]):
            if (i >> (s[j][l]-1)) & 1:
                sw_cnt += 1
        if sw_cnt % 2 == p[j]:
            ri_cnt += 1
    if ri_cnt == m:
        ans += 1
print(ans)


Measured memory_bytes: 9176
from math import *

n = int(input())
a = list(map(int,input().split()))

b = list()

for i in range(n):
    if(i==0):
        b.append(0)
    elif(i==1):
        b.append(abs(a[i]-a[i-1]))
    else:
        b.append(min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2])))
    
print(b[n-1])

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N, M;
    ll count = 0;
    map<ll, ll> m;
    cin >> N >> M;
    for(ll i = 0;i < N;i++) {
        ll K;
        cin >> K;
        for(ll j = 0;j < K;j++) {
            ll temp;
            cin >> temp;
            m[temp]++;
        }
    }
    for(auto &i: m) {
        if(i.second == N) count++;
    }
    cout << count << endl;
    return 0;
}


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

Measured memory_bytes: 72692
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////
matrix ygra(100030);
Vi yexist(100030);
Vi xgroup(100030);
Vi ygroup(100030);

void dfs(ll y,ll id){
    ygroup[y]=id;
    for(auto nxt: ygra[y]){
        if(ygroup[nxt]==0) dfs(nxt,id);
    }
    return;
}
void solve(){
    ll n;
    cin >> n;
    vector<PLL> vp(n);
    rp(i,n){
        ll x,y;
        cin >> x >> y;
        vp[i]=mp(x,y);
        yexist[y]=1;
    }
    sort(all(vp));
    rp(i,n-1){
        if(vp[i].fi==vp[i+1].fi){
            ygra[vp[i].se].pb(vp[i+1].se);
            ygra[vp[i+1].se].pb(vp[i].se);
        }
    }
    ll idx=1;
    repi(i,1,100020){
        if(yexist[i]==0) continue;
        if(ygroup[i]==0) {
            dfs(i,idx);
            idx++;
        }
    }
    rp(i,n){
        xgroup[vp[i].fi]=ygroup[vp[i].se];
    }
    Vi xgroup_ctr(idx,0);
    Vi ygroup_ctr(idx,0);
    rp(i,100020){
        xgroup_ctr[xgroup[i]]++;
        ygroup_ctr[ygroup[i]]++;
    }
    // for(auto x:xgroup_ctr){
    //     princ(x);
    // }
    // cout << endl;
    // for(auto y:ygroup_ctr){
    //     princ(y);
    // }
    ll sum=0;
    repi(i,1,idx){
        sum += xgroup_ctr[i]*ygroup_ctr[i];
    }
    print(sum-n);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 12608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  for (int i=0; i<N; i++){
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for (int i=0; i<M; i++){
    cin >> t.at(i);
  }
  
  vector<int> count(N);
  for (int i=0; i<N; i++){
    for (int j=i; j<N; j++){
      if(s.at(i)==s.at(j)) count.at(i)++;
    }
    for (int j=0; j<M; j++){
      if(s.at(i)==t.at(j)) count.at(i)--;
    }
  }
  int ans=0;
  for (int i=0; i<N; i++){
    ans = count.at(i) > ans ? count.at(i) : ans;
  }
   cout << ans << endl;     
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll  long long int
#define  inf INT_MAX
#define  minf INT_MIN
#define setbits(x) __builtin_popcountll(x)
#define pres(x,y) fixed<<setprecision(y)<<x
#define pair1 pair<long long int,long long int>
#define mp make_pair
#define mk(arr,n,type) type *arr=new type[n];
#define mod  1000000009
#define ins insert
#define w(t) long long int t;t=1; while(t--)

struct s {
  ll a, b, c;
};

void solve() {

  ll n;
  cin >> n;
  vector
 v(n + 1);
  for (ll i = 1; i <= n; i++) {
    cin >> v[i].a >> v[i].b >> v[i].c;
  }
  ll dp[n + 1][3];
  dp[1][0] = v[1].a;
  dp[1][1] = v[1].b;
  dp[1][2] = v[1].c;

  for (ll i = 2; i <= n; i++) {

    dp[i][0] = v[i].a + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = v[i].b + max(dp[i - 1][0], dp[i - 1][2]);
    dp[i][2] = v[i].c + max(dp[i - 1][1], dp[i - 1][0]);

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

}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  w(t) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 7952
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 10005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
char ar[N]; ll d,n; ll dp[10001][2][101];
ll maxval(ll i,ll flg,ll rem){
	if(i==n){
		if(rem==0) return 1;
		else return 0;
	}
	if(dp[i][flg][rem]!=-1){
		return dp[i][flg][rem];
	}
	if(flg){
		ll c=0;
		for(ll j=0;j<=9;j++){
			c=(c%mod+maxval(i+1,1,(rem+j)%d)%mod)%mod;
		}
		return dp[i][flg][rem]=c%mod;
	}
	else{
		ll c=0,j;
		for(j=0;j<(ar[i]-'0');j++){
			c=(c%mod+maxval(i+1,1,(rem+j)%d)%mod)%mod;
		}
		c=(c%mod+maxval(i+1,0,(rem+j)%d)%mod)%mod;
		return dp[i][flg][rem]=c%mod;
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>ar;
	ll i,j,l,k; n=strlen(ar);
	cin>>d;
	
	ll an=maxval(0,0,0)%mod;
	an=(an-1+mod)%mod;
	cout<<an;
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = n - 1; i < (int)n; --i)
#define FOR(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define RFOR(i, l, r) for (int i = (int)(r); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vi a(n);
    ll l = 0;
    ll sum = 0, xorsum = 0, ans = 0;
    REP(i, n) {
        cin >> a[i];
        sum += a[i];
        xorsum ^= a[i];
        if (i == 0) continue;
        while (sum != xorsum) {
            ans += i - l;
            sum -= a[l];
            xorsum ^= a[l];
            l++;
        }
    }
    ans += (n - l) * (n - l + 1) / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
typedef unsigned int UINT;
using namespace std;


int main(void) {
    const long long MAX = 1000000000000000000;
    long long X, Y;
    long long ans;
    cin >> X >> Y;
    if (X == Y)    {
        cout << -1 << endl;
        return 0;
    }
    if (X % Y == 0) {
        cout << -1 << endl;
        return 0;
    }
        
    while (ans < MAX) {
        ans += X;
        if (ans % Y != 0) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}
int n,m;
vector< vector<int> >adj(1e5+10);
vector<bool>b(1e5+10,0);
map< pair<int,int>,int>mp;
void dfs(int v){
   b[v] = 1;
   for(int i = 0;i<adj[v].size();i++){
    int vi = adj[v][i];
    if(b[vi]==1) continue;
    dfs(vi);
   }
}
void solve(){
   cin >> n >> m;
   for(int i = 0;i<m;i++){
    int v,u,z;cin >> v >> u >> z;
    adj[v].push_back(u);
    adj[u].push_back(v);
    mp[{v,u}] = z;
    mp[{u,v}] = z;
}
    int ans = 0;
    for(int i = 1;i<=n;i++){
        if(!b[i]){
            dfs(i);
            ans ++;
        }
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 25872
#include<stdio.h>
int main(){
  char s[110];
  int i,d,m[7][2]={{1,2},{6,3},{1,6},{4,5},{5,2},{2,1},{6,6}};
  while(scanf("%s",s),s[0]-'#'){
    for(i=d=0;s[i];i++)d=m[d][s[i]-'0'];
    if(d-5)printf("No\n");
    else   printf("Yes\n");
  }
  return 0;
}

Measured memory_bytes: 524
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n = s.nextInt
    val w = List.fill(n)(s.nextInt)
    var dif = Int.MaxValue
    for (i <- 1 until n) {
      val (w1, w2) = w.splitAt(i)
      dif = Math.min(dif, Math.abs(w1.sum - w2.sum))
    }
    dif.toString
  }

  val tests = List(
    """3
      |1 2 3""".stripMargin -> """0""",
    """4
      |1 3 1 1""".stripMargin -> """2""",
    """8
      |27 23 76 2 3 5 62 52""".stripMargin -> """2"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 27348
#include <stdio.h>

int main(){
  int r,d,x_2000;
  scanf("%d %d %d",&r,&d,&x_2000);
  int a=x_2000;
  for(int i=1;i<=10;i++){
    a=r*a-d;
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5600000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
long x,y;
cin >> x >> y;
if((x+y)%3==0){
long long aa,bb;
aa=(2*y-x)/3;
bb=(2*x-y)/3;
COMinit();

if(aa>=0 && bb>=0){

 cout << COM(aa+bb,aa) << endl;
 return 0;
}
  else cout << "0";
  return 0;
}
else cout << "0" <<endl;

}


Measured memory_bytes: 131456
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var c = new long[3][];
            for (int i = 0; i < 3; i++)
            {
                c[i]= Reads();
            }
            bool ans = true;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    if (!(c[i + 1][j + 1] - c[i + 1][j] == c[i][j + 1] - c[i][j]))
                        ans = false;
                }
            }

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    if (!(c[i + 1][j + 1] - c[i][j+1] == c[i+1][j] - c[i][j]))
                        ans = false;
                }
            }


            WriteLine(ans ? "Yes" : "No");

            

            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 18960
n = int(input())
s = input()

max_chars = 0
for i in range(1, len(s)):
    s1, s2 = s[:i], s[i:]
    s1_chars = set(s1)
    s2_chars = set(s2)

    same_chars = s1_chars & s2_chars
    max_chars = max(max_chars, len(same_chars))

print(max_chars)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    sc.close();
    Arrays.sort(a);
    int cost[]=new int[a[n-1]-a[0]+1];
    for(int i=0;i<cost.length;i++){
      for(int j=0;j<n;j++){
        cost[i]+=Math.pow((a[0]+i-a[j]),2);
      }
    }
    Arrays.sort(cost);
    System.out.println(cost[0]);
  }
}

Measured memory_bytes: 23764
#include<stdio.h>
#define N (100010)
#define MD (1000000007)
int n,ans,a[N],f[N];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",a+i),f[a[i]]++;
	if (n&1){
		if (f[0]!=1) ans=0; else ans=1;
		for (int i=2;i<n;i+=2){
			if (f[i]!=2){
				ans=0;
				break;
			}
			else {
				ans=ans*2%MD;
			}
		}
	}
	else {
		ans=1;
		for (int i=1;i<n;i+=2){
			if (f[i]!=2){
				ans=0;
				break;
			}
			else {
				ans=ans*2%MD;
			}
		}
	}
	printf("%d\n",ans);
}

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

int main() {
	int n,x,co;
	for(;co=0,cin>>n>>x;)
	{
		if(!n&&!x)break;
		for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)for(int k=j+1;k<=n;k++)if(i+j+k==x)co++;
		cout<<co<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076