akhauriyash/Code-Regression huggingface dataset:
n = int(input())
ans = 0
cmb = [[0 for _ in range(9)] for _ in range(9)]
if n <= 10:
    print(min(n,9))
    exit(0)
for i in range(1,n+1):
    if str(i)[0] != '0' and str(i)[-1] != '0':
        cmb[int(str(i)[0])-1][int(str(i)[-1])-1] += 1
for i in range(9):
    for j in range(9):
        if cmb[i][j] != 0 and cmb[j][i] != 0:
            ans += (cmb[i][j] * cmb[j][i]) 
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main(void){
    long long N,a,x,m=1000000000000000;
    scanf("%lld",&N);
    for (int i=0;i<5;i++){
        scanf("%lld",&x);
        if(x<m)m=x;
    }
    a=N/m;
    if(N%m!=0)a++;
    printf("%lld",a+4);
}

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

class Program
{
    static int[] color;

    static void IsFriend(List<int>[] friend, int u, int id)
    {
        Stack<int> s = new Stack<int>();
        s.Push(u);
        color[u] = id;
        while(s.Count != 0)
        {
            int uu = s.Pop();
            for(int i = 0; i < friend[uu].Count; i++)
            {              
                int v = friend[uu][i];               
                if(color[v] == -1)
                {
                    color[v] = id;
                    s.Push(v);
                }
            }
        }   
    }

    static void AssingColor(List<int>[] friend, int n)
    {
        int id = 1;
     
        for(int i = 0; i < n; i++)
        {
            color[i] = -1;
        }
        for(int u = 0; u < n; u++)
        {
            if(color[u] == -1)
            {
                IsFriend(friend, u, id++);
            }
        }
    }

    static void Main(string[] args)
    {
        string[] input1;        
        var resultlist = new List<string>();
                
        input1 = Console.ReadLine().Split(' ');
        int n = int.Parse(input1[0]);
        int m = int.Parse(input1[1]);

        color = new int[n];
      
        List<int>[] friend = new List<int>[n];
        
        for(int i = 0; i < n; i++)
        {
            friend[i] = new List<int>();
        }

        int a = 0;
        int b = 0;

        for(int i = 0; i < m; i++)
        {
            input1 = Console.ReadLine().Split(' ');
            a = int.Parse(input1[0]);
            b = int.Parse(input1[1]);
            friend[a].Add(b);      
            friend[b].Add(a);      
        }

        AssingColor(friend, n);

        int q = int.Parse(Console.ReadLine());
       
        for(int i = 0; i < q; i++)
        {
            input1 = Console.ReadLine().Split(' ');
            a = int.Parse(input1[0]);
            b = int.Parse(input1[1]);
            
            if(color[a] == color[b])
            {
                resultlist.Add("yes");
            }
            else
            {
                resultlist.Add("no");
            }
        }
                  
        foreach (var s in resultlist)
        {
            Console.WriteLine(s);
        }       
    }
}



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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());

        // dp
        // 動的計画法
        // i円が作れるとき、i+100円が作成できる
        int[] dp = new int[n + 106];
        dp[100] = 1;
        dp[101] = 1;
        dp[102] = 1;
        dp[103] = 1;
        dp[104] = 1;
        dp[105] = 1;

        for (int j = 100; j < n; j++)
        {
            if (dp[j] == 1)
            {
                dp[j + 100] = 1;
                dp[j + 101] = 1;
                dp[j + 102] = 1;
                dp[j + 103] = 1;
                dp[j + 104] = 1;
                dp[j + 105] = 1;
            }
        }

        // 出力
        Console.WriteLine(dp[n]);
    }
}

Measured memory_bytes: 11232
#define lli long long int
#define TC long long int T;cin>>T;while(T--)
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
lli n;
lli ar[100000][3];
lli mat[100000][4]={0};
lli rec(lli a,lli x)
{
	if(a==-1)
	return 0;
	
	if(mat[a][x])
	return mat[a][x];

	vector<lli> dp;
	for(lli i=0;i<3;i++)
	{ 
	  if(i!=x)
	   dp.push_back(ar[a][i]+rec(a-1,i));  	
	 }
	 
	return mat[a][x]=max({dp[0],dp[1],dp[2]});
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    
    for(lli i=0;i<n;i++)
      for(lli j=0;j<3;j++)
        cin>>ar[i][j];
   
   
    cout<<rec(n-1,3);
    
	return 0;
}
    
    

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

int main() {

    int X;
    cin >> X;
    
    if (400 <= X && X <= 599) {
        cout << 8 << endl;
    }
    
    if (600 <= X && X <= 799) {
        cout << 7 << endl;
    }
    
    if (800 <= X && X <= 999) {
        cout << 6 << endl;
    }
    
    if (1000 <= X && X <= 1199) {
        cout << 5 << endl;
    }
    
    if (1200 <= X && X <= 1399) {
        cout << 4 << endl;
    }
    
    if (1400 <= X && X <= 1599) {
        cout << 3 << endl;
    }
    
    if (1600 <= X && X <= 1799) {
        cout << 2 << endl;
    }
    
    if (1800 <= X && X <= 1999) {
        cout << 1 << endl;
    }
    
}

Measured memory_bytes: 3608
s = input()
count = 0
count2 = 0

if s[0] != 'A':
    print('WA')
    exit()

for i in range(2, len(s)-1):
    if s[i] == 'C':
        count += 1

if count != 1:
    print('WA')
    exit()

s2 = s.upper()

for i in range(len(s)):
    if s[i] != s2[i]:
        count2 += 1

if count2 != len(s) - 2:
    print('WA')
    exit()

print('AC')

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007;

int n,m,per,tar,val[_];
int stk[_],top;

inline int able(int who)
{
	top=0;
	for(int i=tar;i<=n;i++)if(i!=who)stk[++top]=val[i];
	lint bas=val[who]+m,res=1ll*(per-tar)*m;
	for(int i=top;i>=1 && res>0;i--)
	{
		lint los=min(m,min(res,bas-stk[i]));
		if(los>0)res-=los,stk[i]+=los;
		if(stk[i]>bas)return 0;
	}
	return res<=0 && stk[1]<=bas;
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty(),m=ty(),per=ty(),tar=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	sort(val+1,val+n+1,greater<int>());
	
	int l=tar,r=n,ans=l;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(able(mid))ans=mid,l=mid+1;
		else r=mid-1;
	}
	cout<<ans<<lf;
	
	return 0;
}


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

vector<int>P,Q,S;
int N;
bool eql(vector<int> a,vector<int> b){
    for(int i=0;i<N;++i)
        if(a[i]!=b[i])return 0;
    return 1;
}
int main(){
    int x,a=0,b=0,c=1;
    cin>>N;
    for(int i=0;i<N;++i){cin>>x;P.push_back(x);}
    for(int i=0;i<N;++i){cin>>x;Q.push_back(x);}
    for(int i=0;i<N;++i)S.push_back(i+1);
    do{
        if(eql(P,S)) a=c;
        if(eql(Q,S)) b=c;
        if(a&&b)break;
        c++;
    }while(next_permutation(S.begin(),S.end()));
    cout<<abs(b-a)<<endl;
    return 0;
}
/*
8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
*/


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

namespace ConsoleApp15
{
    class Class116
    {
        static void Main()
        {
            var NP = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = NP[0], P = NP[1];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int even = A.Count(x => x % 2 == 0);
            int odd = A.Count(x=>x%2==1);
            long ans;
            if (P == 0)
            {
                if (odd == 0) odd = 1;
                ans = (long)Math.Pow(2, odd - 1) * (long)Math.Pow(2, even);
            }
            else
            {
                if (odd == 0) ans = 0;
                else ans = (long)Math.Pow(2, odd - 1) * (long)Math.Pow(2, even);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11348
N = int(input())
U = sorted(map(int, input().split()))


def saiki(n):
    m = ((n[0] + n[1]) / 2)
    n.pop(0)
    n.pop(0)
    n.insert(0, m)
    if (len(n) == 1):
        print(n[0])
        exit()
    saiki(n)


print(saiki(U))


Measured memory_bytes: 3060
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
bool is[404040];
vector<int>p;
int x;
int main()
{
	cin>>x;
	for(int i=2;i<202000;i++)
	{
		if(!is[i])
		{
			p.push_back(i);
			for(int j=i+i;j<202000;j+=i)
			{
				is[j]=true;
			}
		}
	}
	for(int i=0;i<p.size();i++)
	{
		if(p[i]>=x)
		{
			cout<<p[i]<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<map>
using namespace std;
typedef long long ll;
map<ll,int> M;
int main()
{
	int n;ll m,x,s=0,ans=0;
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		s+=x;s%=m;
		ans+=M[s];M[s]++;
	}
	printf("%lld\n",ans+M[0]);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
int main(){
  int n,k,temp=1;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    if(temp*2<temp+k){
      temp*=2;
    }else{
      temp+=k;
    }
  }
  cout<<temp<<endl;
  return 0;
}
    


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map &:to_i
B = gets.split.map &:to_i

diffs = A.zip(B).collect{|a, b| a - b }

ans = -1

minus = diffs.select{|n| n < 0}
S_minus = -minus.inject(0, :+)
#puts "S_minus: #{S_minus}"

plus = diffs.select{|n| n > 0}.sort_by{|n| -n}
#puts "plus: #{plus.to_s}"

if plus.inject(0, :+) - S_minus >= 0 then
	ans = minus.size
	
	plus_sum = 0
	i = 0
	while plus_sum <S_minus do
		#puts "plus_sum: #{plus_sum} < S_minus: #{S_minus}"
		plus_sum += plus[i]
		i += 1
	end

	ans += i
end

puts ans


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

int main()
{
    long h, n, a, tmp;
    std::cin >> h >> n;

    for (int i = 0; i < n; i++)
    {
        std::cin >> tmp;
        h -= tmp;
    }

    std::cout << (h <= 0 ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int num[200000+100];
map<int,int>sz;
set<int>S;
int calcu(int n,int q)
{
    int times=0;
    while(n)
    {
        n/=q;
        times++;
    }
    return times;
}
int my_min(int a,int b)
{
    return a<b?a:b;
}
int main()
{
    int n;
    bool flag=true;
    int min = 1000000007;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        if(i!=0 && num[i] <=num[i-1])
            flag=false;
        min=my_min(min,num[i]);
    }
    if(flag)
        printf("1\n");
    else
    {
        int star=2;
        int end=n;
        while(star<=end)
        {
            int mid=(star+end)/2;
            int limit=calcu(n,mid);
            if(min>=limit)
                end=mid-1;
            else
            {
                bool flagg=true;
                sz.clear();
                S.clear();
                int len=num[0];
                for(int i=1;i<n;i++)
                {
                	len=num[i];
                    if(num[i]>num[i-1])
                    {
                        sz.erase(sz.lower_bound(num[i-1]),sz.end());
					} 
                    else
                    {
                    	set<int> ::iterator it; 
                    	it=S.lower_bound(num[i]);
							{
		                        int k=len-1;
		                        while(k>=0 && sz[k]==mid-1)
		                        {
		                            sz[k]=0;
		                            k--;
		                        }
		                        if(k==-1)
		                        {
		                            flagg=false;
		                            break;
		                        }
		                        sz[k]++;
	                    	}
                    }
          //          for(int k=0;k<len;k++)
            //            printf("%d ",sz[k]);
             //       printf("\n");
                }
                
                if(!flagg)
                    star=mid+1;
                else
                    end=mid-1;
            }
        }
        printf("%d\n",star);
    }
    return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,k;
  cin >> n >> k;
  if(n%k==0)cout << 0 << endl;
  else cout << 1 << endl;

}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem159d(n, a))
}

fun problem159d(n: Int, a: List<Long>): String {
    /**
     * N個の中から2個を選ぶ公式
     */
    fun take2ByN(n: Long): Long {
        return n * (n - 1) / 2
    }
    val countMap = a.groupBy { it }
    val all = countMap.map { take2ByN(it.value.count().toLong()) }.sum()
    val ans = LongArray(n)
    for (i in 0 until n) {
        val num = countMap[a[i]]!!.count().toLong()
        val before = take2ByN(num)
        val after = (num - 1) * (num - 2) / 2
        ans[i] = all - (num - 1)
    }

    return ans.joinToString("\n")
}


Measured memory_bytes: 112076
A, B = map(int, input().split())

#%%
# a finction to find F(0,x)
def XOR_0_to_x(x):

    # for all even integer n, n ^ (n+1) = 1
    xor = ((x+1) // 2) % 2

    if x % 2 == 0:
        return xor ^ x

    else:
        return xor

#%%
# F(A,B) = F(0,A-1) ^ F(0,B)
ans = XOR_0_to_x(A-1) ^ XOR_0_to_x(B)

print(ans)


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c,d; cin >> a >> b >> c >> d;
  bool ok = false;

  if(abs(a-c)<=d) ok = true;
  else if(abs(a-b)<=d && abs(b-c)<=d) ok = true;

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3512
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
answer = (0..10000).map do |i|
    if i % 15 == 0
        'FizzBuzz'
    elsif i % 3 == 0
        'Fizz'
    elsif i % 5 == 0
        'Buzz'
    else
        i.to_s
    end
end

loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0
    players = (1..m).to_a
    (1..n).each do |i|
        call = gets.chomp
        next if players.size == 1
        if call == answer[i]
            players.rotate!(1)
        else
            players.shift
        end
    end
    puts players.sort * ' '
end


Measured memory_bytes: 7024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stack>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int n, a;
    cin >> n >> a;
    cout << pow(n, 2) - a << endl;


    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#define rep(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
 
int get()
{
    char c;
    while (!isdigit(c=getchar()));
    int k=c-'0';
    for (; isdigit(c=getchar()); k=k*10+c-'0');
    return k;
}
 
using namespace std;
typedef long long ll;
const int N=2e5+10;
int n,a[N],b[N],ans,idx;
map<int,int> cnt,id;
struct edge
{
    int v;
    edge *nxt;
} pool[N],*tp=pool,*fst[N];
int dfn[N],low[N],tot,top,stk[N];
bool inst[N];
 
void addedge(int u,int v)
{
//    printf("%d %d\n",u,v);
    *tp=(edge){v,fst[u]},fst[u]=tp++;
}
 
void tarjan(int x)
{
    dfn[x]=low[x]=++idx,stk[++top]=x,inst[x]=1;
    for (edge *i=fst[x]; i; i=i->nxt)
        if (!dfn[i->v])
            tarjan(i->v),low[x]=min(low[x],low[i->v]);
        else if (inst[i->v])
            low[x]=min(low[x],dfn[i->v]);
    if (low[x]==dfn[x])
        for (++tot; inst[stk[top]]=0,stk[top--]!=x; );
}
 
void judge()
{
    bool f=0;
    for (auto i:cnt)
        if (!i.second)
            continue;
        else if (f)
            puts("-1"),exit(0);
        else
            f=1;
}
 
void init()
{
    n=get();
    rep(i,1,n)
        a[i]=get(),++cnt[a[i]];
    rep(i,1,n)
        b[i]=get(),ans+=a[i]!=b[i],--cnt[b[i]];
    int x=0;
    rep(i,1,n)
        x^=a[i];
    ++cnt[x],judge(),--cnt[x];
    bool eq=1;
    for (auto i:cnt)
        if (i.second)
        {
            eq=0;
            break;
        }
    if (eq)
    {
        rep(i,1,n)
            if (a[i]!=b[i] && a[i]==x)
            {
                --ans;
                break;
            }
        return;
    }
    rep(i,1,n)
        if (a[i]!=b[i] && cnt[a[i]]==1 && b[i]!=x)
        {
            a[i]=x,--ans;
            return;
        }
    rep(i,1,n)
        if (a[i]!=b[i] && cnt[a[i]]==1 && b[i]==x)
        {
            a[i]=x;
            return;
        }
    assert(0);
}
 
int main()
{
//    freopen("a.in","r",stdin);
//    freopen("a.out","w",stdout);
    init();
    idx=n+1;
    rep(i,1,n)
        if (!id.count(a[i]))
            id[a[i]]=++idx;
    rep(i,1,n)
    {
        if (a[i]==b[i])
            continue;
        addedge(i,id[b[i]]),addedge(id[a[i]],i);
    }
    idx=0;
    rep(i,1,n)
        if (a[i]!=b[i] && !dfn[i])
            tarjan(i);
    printf("%d",ans+tot);
    return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    int dpl[n + 1], dpr[n + 1];
    dpl[0] = 0;
    dpr[0] = 0;
    int last = -10000000;
    for (int i = 1; i <= n; ++i) {
        if (s[i - 1] == 'x') dpl[i] = dpl[i - 1];
        else if (last + c < i) {
            last = i;
            dpl[i] = dpl[i - 1] + 1;
        }
        else dpl[i] = dpl[i - 1];
    }
    last = -10000000;
    for (int i = 1; i <= n; ++i) {
        if (s[n - i] == 'x') dpr[i] = dpr[i - 1];
        else if (last + c < i) {
            last = i;
            dpr[i] = dpr[i - 1] + 1;
        }
        else dpr[i] = dpr[i - 1];
    }
    //for (int i = 0; i <= n; ++i) cout << dpr[i] << " ";
    for (int i = 0; i < n; ++i) {
        int left = i;
        int right = n - i - 1;
        if (s[i] == 'o' && dpl[left] + dpr[right] < k) cout << i + 1 << endl;
    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    IOS

    for(int i=1;i<=5;i++)
    {
    	int x;
    	cin>>x;
    	if(!x)
    	{
    		cout<<i<<endl;
    		return 0;
    	}
    }

    cout<<-1<<endl;
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <utility> // pairとか
#include <vector>
#include <array>
#include <list>
#include <deque>
#include <map>
#include <algorithm> // sortとか findとか
#include <functional> // algorithmに渡せる関数
#include <cmath>
#include <cstdio>
#include <numeric> // gcd,lcmとか
#define rep(iter, beg, end, step) for (long(iter) = (beg); (iter) < (end); (iter) += (step))
 
using namespace std;
 
int main() {
	int A,N;
	cin >> N;
	cin >> A;
 
	printf("%s\n", ((N % 500) <= A) ? "Yes" : "No");
	return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);

  string s;
  cin >> s;
  unordered_set<char> d;
  for (auto& e : s) {
    d.insert(e);
  }
  if (d.find('S') == d.end() || d.find('N') == d.end()) {
    if (d.find('S') == d.end() && d.find('N') == d.end()) {
    } else {
      cout << "No\n";
      return 0;
    }
  }
  if (d.find('E') == d.end() || d.find('W') == d.end()) {
    if (d.find('E') == d.end() && d.find('W') == d.end()) {
    } else {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}


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

const float RATE = 380000.0f;

int main(int argc, const char * argv[]) {
    int N;
    float totalYen = 0;
    float totalBtc = 0.0f;
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        float x;
        string u;
        cin >> x >> u;
        
        if (u == "JPY") {
            totalYen += x;
        } else if (u == "BTC") {
            totalBtc += (RATE * x);
        }
    }
    
    cout << totalYen + totalBtc << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	ll a;
	cin >> a;

	ll ans = 0, tmp = 1;
	rep(i, 3){
		tmp *= a;
		ans += tmp;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,sum=0;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;i++) {cin>>v[i];
    sum+=v[i];
    }

    ll m=ceil((1.0*sum)/n);
    ll x=floor((1.0*sum)/n);
   // cout<<m<<" ";
    ll ans=0,ans1=0,res=0,res1=0;
    for(int i=0;i<n;i++)
    {
        ans=(v[i]-m)*(v[i]-m);
        ans1=(v[i]-x)*(v[i]-x);
        //cout<<v[i]<<" "<<ans<<" ";
        res+=ans;
        res1+=ans1;
    }
    cout<<min(res,res1);
}


Measured memory_bytes: 256
n,m,k = gets.chomp.split.map(&:to_i)
as = gets.chomp.split.map(&:to_i)
bs = gets.chomp.split.map(&:to_i)

max_cnt = 0
asum = 0
bsum = bs.sum
j = m

for i in 0..n do
    if i == 0
       asum = 0
       a = 0
    else
       asum += as[i-1]
    end
    break if asum > k
    while bsum > k - asum do
        j -= 1
	    bsum -= bs[j]
    end
    cnt = i + j
    if max_cnt < cnt
        max_cnt = cnt
    end
end

puts max_cnt

Measured memory_bytes: 46168
// https://atcoder.jp/contests/abc089/tasks/abc089_d
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, d, t, q;
    cin >> h >> w >> d;
    vector<pii> v(h * w + 1);
    vector<vector<int>> disp(h, vector<int>(w));
    REP(i, h) REP(j, w) {
        cin >> t;
        v[t] = {i, j};
        disp[i][j] = t;
    }
    vector<ll> memo(h * w + 1, 0);
    REP(i, d) {
        int start = i;
        int sum = 0;
        while (start + d <= h * w) {
            pii posNow = v[start];
            pii posNext = v[start + d];
            int diff = abs(posNow.first - posNext.first) +
                       abs(posNow.second - posNext.second);
            sum += diff;
            start += d;
            memo[start] = sum;
        }
    }
    cin >> q;
    vector<pii> s(q);
    REP(i, q) cin >> s[i].first >> s[i].second;
    REP(i, q) cout << memo[s[i].second] - memo[s[i].first] << "\n";

    return 0;
}


Measured memory_bytes: 3712
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from fractions import gcd                    # for Python3.4.3


def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    n = ii()
    v = sorted(lmi())
    ans = (v[0] + v[1]) / 2
    for i in range(2, n):
        ans = (ans + v[i]) / 2
    print(ans)

if __name__ == "__main__":
    main()

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

const int INF = 1e8;
const int MAX = 10000;

void check(int& rx,int& ry,int x,int y,int a,int b){

  if(x + y < rx + ry){
    rx = x;
    ry = y;
  }
  else if(x + y == rx + ry){
    if(x * a + y * b < rx * a + ry * b){
      rx = x;
      ry = y;
    }
  }
}

int main(){
  int a,b,d;
  while(cin >> a >> b >> d,a||b||d){
    int rx,ry;
    rx = ry = INF;

    for(int x = 0 ; x <= MAX ; x++){
      int y;
      y = (a*x - d)/b;
      if(d == a*x - b*y)check(rx,ry,x,abs(y),a,b);
    }
    
    for(int y = 0 ; y <= MAX ; y++){
      int x;
      x = (b*y - d)/a;
      if(d == b*y - a*x)check(rx,ry,abs(x),y,a,b);
    }

    cout << rx << ' ' << ry << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int[] tmp = new int[n];
			int[] map = new int[1000];
			for(int i = 0; i< n; i++) {
				tmp[i] = stdIn.nextInt();
			}
			int counter = 0;
			while(true) {
				map = new int[1000];
				for(int i = 0; i < n; i++) {
					
					map[tmp[i]]++;
					
				}
				boolean change = false;
				for(int i = 0; i < n; i++) {
					if(tmp[i] != map[tmp[i]]) {
						tmp[i] = map[tmp[i]];
						change = true;
					}
				}
				if(!change) {
					break;
				}
				counter++;
			}
			System.out.println(counter);
			System.out.print(tmp[0]);
			for(int i = 1; i < n; i++) {
				System.out.print(" "+tmp[i]);
			}
			System.out.println();
		}
		
	}

}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n, t, a;
  cin >> n >> t >> a;
  double best = 1e10;
  int ret = -1;
  for(int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    double diff = fabs(t - x * 0.006 - a);
    if(diff < best) {
      best = diff;
      ret = i;
    }
  }
  cout << ret << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        _n: usize,
        a: u32,
        b: u32,
        c: u32,
        d: u32,
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut is_fail = true;
    if c > d {
        // A/B がすれ違う場所があるか？
        // a < b より b 基準で前後 1 マス
        for i in b - 1..d {
            if vc[i as usize] == '.' && vc[i as usize - 1] == '.' && vc[i as usize + 1] == '.' {
                is_fail = false;
                break;
            }
        }
        if is_fail {
            println!("No");
            return;
        }
    }

    for i in a..c.max(d) {
        // 移動範囲内に連続して岩があるならば不可
        // a > 0
        if vc[i as usize] == '#' && vc[i as usize - 1] == '#' {
            println!("No");
            return;
        }
    }

    println!("Yes");
}


Measured memory_bytes: 3196
#include<iostream>

using namespace std;

int main(){
  
  int x,y;
  
  int g[13] = {-1,1,3,1,2,1,2,1,1,2,1,2,1};

  cin >> x >> y;

  if(g[x] == g[y]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;    
  }
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;

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

    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    ll pos=-1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0)pos=i;
    }
    ll ans=INF;
    for(int i=0;i<=k;i++){
        if(pos-i+1<0 || pos+k-i<0 || pos+k-i>=n)continue;
        ll tmp1=-a[pos-i+1],tmp2=a[pos+k-i];
        if(i==0)ans=min(ans,tmp2);
        else if(i==k)ans=min(ans,tmp1);
        else ans=min(ans,tmp1+tmp2+min(tmp1,tmp2));
    }
    cout<<ans<<endl;
    
}

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

int main()
{
    int N,l,r,ans=0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
int n;
long long int x=0;
cin>>n;
vector<int>op(n);
for(int i=0;i<n;i++)cin>>op.at(i);
sort(op.begin(),op.end());
cout<<op.at(0)<<" ";
cout<<op.at(n-1)<<" ";
for(int j=0;j<n;j++)x+=op.at(j);
cout<<x<<endl;
}




Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    int64_t K;
    cin >> N >> K;
    vector<int> A(N), F(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    for(int i=0; i<N; i++) {
        cin >> F[i];
    }

    sort(A.rbegin(), A.rend());
    sort(F.begin(), F.end());

    int64_t ok = 1e15, ng = -1;
    while(ng+1 < ok) {
        int64_t mid = (ok+ng) / 2;
        int64_t cnt = 0;
        for(int i=0; i<N; i++) {
            cnt += max(0L, A[i] - mid/F[i]);
        }
        if(cnt <= K) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<map>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=200005;
map<int,int>T;
int n,a[MAXN],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),T[a[i]]++;
	sort(a+1,a+n+1);
	for(int i=1<<30;i>=1;i>>=1)
		for(int j=1;j<=n&&a[j]<i;j++)
			if(T[a[j]]&&T[i-a[j]]){
				if(T[a[j]]==1&&i==a[j]*2)
					continue;
				T[a[j]]--,T[i-a[j]]--,ans++;
			}
	printf("%d\n",ans);
}


Measured memory_bytes: 29824
n = int(input())
num=[int(num) for num in input().split()]
kazu = [[0 for i in range(n+1)] for j in range(21)]
kazu[num[0]][0]=1
for i in range(n-1):
    if i>0:
        for j in range(21):
            if j - num[i] >= 0 and j - num[i] <= 20:
                kazu[j][i] = kazu[j][i] + kazu[j-num[i]][i-1]
            if j + num[i] >= 0 and j + num[i] <= 20:
                kazu[j][i] = kazu[j][i] + kazu[j+num[i]][i-1]
print(kazu[num[n-1]][n-2])


Measured memory_bytes: 5612
#include <stdio.h>
#include <math.h>
#define pi 3.14159265
#define r(arc) ((arc)*pi/180) 
int main(void)
{
	double a,b,c;
	scanf("%lf %lf %lf",&a,&b,&c);
	printf("%lf %lf %lf\n",a*b*sin(r(c))/2,a+b+sqrt(a*a+b*b-2*a*b*cos(r(c))),a*b*sin(r(c))/a);
	return 0;
}

Measured memory_bytes: 672
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	string S=in<string>();
	int state=0;
	int Q=in();
	deque<char> D;
	for(int i=0,ei=S.size();i<ei;i++){
		D.push_back(S[i]);
	}
	LOOP(Q){
		int q=in();
		if(q==1){
			state = (state+1)%2;
		}
		else{
			int f=in();
			char c=in<char>();
			if(f==1){
				if(!state) D.push_front(c);
				else D.push_back(c);
			}
			else{
				if(!state) D.push_back(c);
				else D.push_front(c);
			}
		}
	}
	if(state){
		reverse(ALL(D));
	}
	
	for(auto& x:D){
		cout<<x;
	}
	out();
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  int a = N/1000, d = N%10, b = (N%1000-N%100)/100, c = (N%100-N%10)/10;
  
  if (a == b && a == c && a == d)  {
    cout << "Yes" << endl;  
  }
  
  else {
    if (   a != b && b == c && b == d
        || d != a && a == b && a == c ){
      cout << "Yes" << endl;
    }
    
    else {
      cout << "No" << endl;
    }
  }


}

Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
$a = explode(" ",fgets(STDIN));
$ans=0;
for($i=0;$i<count($a);$i++){
	while($a[$i]%2==0){
		$a[$i]=$a[$i]/2;
		$ans++;
	}
}
echo $ans;

Measured memory_bytes: 5520
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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


int main() {
string s;
cin>>s;
int a=s.length();
cout<<s[0]<<a-2<<s[a-1]<<endl;
}

Measured memory_bytes: 256
#C
N=int(input())
XY=[list(map(int,input().split())) for i in range(N)]
fact=[1 for i in range(N+1)]
for i in range(1,N+1):
  fact[i]=fact[i-1]*i

ans=0
for i in range(N):
  for j in range(i+1,N):
    x0,y0=XY[i]
    x1,y1=XY[j]
    dis=pow((x0-x1)**2+(y0-y1)**2,0.5)
    ans+=dis*fact[N-1]*2

print(ans/fact[N])

Measured memory_bytes: 62588
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


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

	int K, X;
	cin >> K >> X;
	if (500 * K >= X)puts("Yes");
	else puts("No");

	return 0;
}

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

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

n=int(input())
def soinsuu(n):
    #素因数分解リスト生成,collections.Counter(a)で個数取得
    #1に対しては[]をreturn
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
from collections import Counter
a=Counter(soinsuu(n))
if n==1:
    print(0)
    sys.exit()
#print(a)
cnt=0
for i in range(1,1+max(a.values())):
    for item in a.keys():
        #print(i,item)
        if n%(item**i)==0:
            n//=item**i
            #print(n,item)
            cnt+=1
            if n==1:
                break

print(cnt)

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  deque<int> d;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2 == 0) {
      d.push_back(a[i]);
    } else {
      d.push_front(a[i]);
    }
  }

  if (n % 2) {
    reverse(d.begin(), d.end());
  }

  for (auto it = d.begin(); it != d.end(); it++) {
    cout << *it << endl;
  }
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    long long h[100010];
    long long dp[100010];
    for(int i = 0; i < N; i++){
        cin >> h[i];
        dp[i] = INF;
    }
    // for(int i = 0; i < N; i++){
    //     dp[i] = INF;
    // }


    dp[0] = 0;

    for(int i = 1; i < N; i++){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));

        if(i > 1){
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }

    cout << dp[N-1] << endl;


}

Measured memory_bytes: 1792
A, B, C, K = map(int, input().split())

# 1回後 A:B+C B:A+C C:A+B   A-B = B-A
# 2回後 A:2A+B+C B:A+2B+C C:A+B+2C    A-B = A-B

if K % 2 == 0:
    print(A - B)
else:
    print(B - A)

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

template<size_t max_N, size_t prime_size>
struct Prime{
    bool sieve[max_N];
    int_fast64_t prime[prime_size];
    size_t counter = 0;
    constexpr Prime() : sieve(), prime() {
        for(int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for(int_fast64_t i = 2; i < max_N; ++i){
            if(sieve[i]){
                prime[counter] = i;
                ++counter;
                if(counter >= prime_size)break;
            }
            for(int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
    constexpr int_fast64_t operator[](size_t i) const{
        return i < counter ? prime[i] : prime[counter - 1];
    }
};

constexpr Prime<8831, 1000> p = Prime<8831, 1000>();

constexpr int_fast64_t gcd(int_fast64_t a, int_fast64_t b){
    int_fast64_t t(0);
    while(b){
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

constexpr int_fast64_t lcm(int_fast64_t a, int_fast64_t b){
    return a / gcd(a, b) * b;
}

constexpr int_fast64_t lcm(int_fast64_t a, int_fast64_t b, int_fast64_t c, int_fast64_t d){
    return lcm(lcm(a, b), lcm(c, d));
}

struct Ans{
    int_fast64_t ans[502][502];
    constexpr size_t v(size_t i){
        return i & 1 ? i / 2 : 999 - i / 2;
    }
    constexpr Ans() : ans(){
        for(size_t i = 0; i < 501; ++i){
            ans[i][0] = 1;
            ans[501][i] = 1;
            ans[i + 1][501] = 1;
            ans[0][i + 1] = 1;
        }
        for(size_t i = 1; i <= 500; i += 2)
            for(size_t j = 1; j <= 500; j += 2){
                ans[i][j] = p[v((i + j - 2) / 2)] * p[v((1500 + i - j) / 2)];
                if(i < 500 && j < 500)ans[i + 1][j + 1] = p[v((i + j) / 2)] * p[v((1500 + i - j) / 2)];
            }
        for(size_t i = 1; i < 500; i += 2)
            for(size_t j = 1; j < 500; j += 2){
                ans[i + 1][j] = lcm(ans[i][j], ans[i + 2][j], ans[i + 1][j + 1], ans[i + 1][j - 1]) + 1;
                ans[i][j + 1] = lcm(ans[i][j], ans[i][j + 2], ans[i + 1][j + 1], ans[i - 1][j + 1]) + 1;
            }
    }
    constexpr int_fast64_t at(size_t i, size_t j)const{
        return ans[i + 1][j + 1];
    }
};

constexpr Ans a = Ans();
size_t N;

int main(){
    scanf("%lu", &N);
    for(size_t i = 0; i < N; ++i){
        for(size_t j = 0; j < N - 1; ++j)printf("%lld ", a.at(i, j));
        printf("%lld\n", a.at(i, N - 1));
    }
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements <=num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
//#define int long long int
//Binary_Search->dp->greedy
bool is(string s){
	int n=s.length();
	int l=0,r=n-1;
	while(l<=r){
		if(s[l]!=s[r]) return false;
		l++;r--;
	}
	return true;
}
void solve(){
	ll n;
	cin>>n;
	vl vec(n);
	cin>>vec;
	map<ll,ll> mp;
	for(ll i=0;i<n;i++) mp[vec[i]]++;
	ll add=0;
	for(auto it:mp){
		if(it.se!=1) add+=(it.se*(it.se-1)/2);
	}
	for(int i=0;i<n;i++){
		if(mp[vec[i]]==1) cout<<add<<endl;
		else{
			if(mp[vec[i]]==2) cout<<add-1<<endl;
			else{
				ll t=mp[vec[i]];
				cout<<add-(t*(t-1)/2)+((t-1)*(t-2)/2)<<endl;
			}
		}
	}
 
 
 
}
int32_t main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
}   

Measured memory_bytes: 11008
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
void trozen()
{
    for(int i=1;i<=5;i++)
        cin>>arr[i];
    for(int i=1;i<=5;i++)
        if(arr[i]==0)
        {
            cout<<i<<endl;
            return;
        }
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3608
import math

def is_prime(n):
    if n == 1: return False

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

    return True

X = int(input())

if X == 2:
    print(2)
    exit()

if X % 2 == 0:
    X += 1

while True:
    if is_prime(X):
        break
    X += 1

print(X)


Measured memory_bytes: 3060