akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public  class Main  {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int V_i[] = new int[N];
		int C_i[] = new int[N];
		int sum = 0;
		for(int i = 0; i<N ;i++) {
			V_i[i] = sc.nextInt();
		}
		for(int i = 0; i<N; i++) {
			C_i[i] = sc.nextInt();
		}
		for(int i = 0; i<N; i++) {
			int p = V_i[i]-C_i[i];
			if(p >0)sum+=p;
		}
		
		System.out.println(sum);
	}
	

}


Measured memory_bytes: 23380
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL dp[3][66];

int main() {
	LL n;
	cin >> n;
	int k = 0;
	LL mask = 1;
	while (n >= mask) {
		mask <<= 1;
		k++;
	}
	dp[0][0] = 1;
	REP(i, k) {
		mask >>= 1;
		if (n & mask) {
			//both 0
			dp[1][i + 1] = (dp[1][i + 1] + dp[0][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[1][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[2][i]) % MOD;
			// 0 + 1
			dp[0][i + 1] = (dp[0][i + 1] + dp[0][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[1][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[2][i]) % MOD;
			// 1 + 1
			//dp[0][i + 1] = (dp[1][i + 1] + dp[0][i]) % MOD;
			dp[1][i + 1] = (dp[1][i + 1] + dp[1][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[2][i]) % MOD;
		}
		else {
			//both 0
			dp[0][i + 1] = (dp[0][i + 1] + dp[0][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[1][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[2][i]) % MOD;
			// 0 + 1
			//dp[0][i + 1] = (dp[1][i + 1] + dp[0][i]) % MOD;
			dp[1][i + 1] = (dp[1][i + 1] + dp[1][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[2][i]) % MOD;
			// 1 + 1
			//dp[0][i + 1] = (dp[1][i + 1] + dp[0][i]) % MOD;
			dp[0][i + 1] = (dp[0][i + 1] + dp[1][i]) % MOD;
			dp[2][i + 1] = (dp[2][i + 1] + dp[2][i]) % MOD;
		}
	}
	cout << (dp[0][k] + dp[1][k] + dp[2][k]) % MOD << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int X, A;
	cin >> X >> A;
	if(X < A){
		cout << 0 << endl;
	}
	else{
		cout << 10 << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int N;
map<string, int> S;
vector<string> candidates;


int main(void) {

    cin >> N;

    int highest = 0;

    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        auto key = S.find(s);
        if (key != S.end()) {
            S[s]++;
        }
        else {
            S[s] = 1;
        }

        if (S[s] > highest) {
            candidates.clear();
            candidates.push_back(s);
            highest = S[s];
        }
        else if (S[s] == highest) {
            candidates.push_back(s);
        }

    }

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

    for (auto str : candidates) {
        cout << str << endl;
    }


    return 0;
}

Measured memory_bytes: 28528
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    int n;
    cin>>n;
    if(n/100==n%10)cout<<"Yes";
    else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=1e5+10;
int n,lst[N],fa[N],m,k,cnt;
inline int read(){
	char ch=getchar(); int x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	return x*f;}
inline int f(int son){return fa[son]==son ? son : f(fa[son]);}
int main()
{
	//freopen("Interpretation.in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(); m=read();
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++)
	{
		k=read();
		for(int j=1,a;j<=k;j++)
		{
			a=read();
			if(!lst[a]) 
			{
				lst[a]=i;
				continue;
			}
			int fx=f(lst[a]), fy=f(i);
			if(fx!=fy) fa[fx]=fy;
			lst[a]=i;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(fa[i]==i) cnt++;
		if(cnt>=2) return printf("NO\n"), 0;
	}
	return printf("YES\n"), 0;
	//fclose(stdin); fclose(stdout);
	return 0;
}


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

using namespace std;

int a[200010];

int main(){
	// freopen("test.txt","r",stdin);
	cin.sync_with_stdio(0); cin.tie(0);
	int n;
	cin >> n;
	for (int i=0; i<n; ++i){
		cin >> a[i];
	}
	int minline = 1;
	long long ans = 0;
	for (int i=n-1; i>=0; --i){
		int maxline = i;
		--minline;
		if (a[i] > maxline || a[i] < minline){
			cout << -1;
			return 0;
		}
		if (a[i] == a[i+1] - 1){
			//okay
		}
		else{
			ans += a[i];
			minline = a[i];
		}
	}
	cout << ans;

	return 0;	
}

Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x = 500*a + 100*b + 50*c
            if X == x:
                ans += 1
            else:
                pass

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
   int Q,N;
   cin>>N>>Q;
   dsu ds(N);
   for(int i=0;i<Q;i++){
       int t,u,v;
       cin>>t>>u>>v;
       if(t==0){
           ds.merge(u,v);
       }
       else{
           cout<<ds.same(u,v)<<endl;
       }
   }
}

Measured memory_bytes: 4076
#include <iostream>
using namespace std;
long long f[100]={2,1}; //a6666666666666666666666666
int main()
{
	int n;
	cin>>n;
	for(int i=2;i<=n;i++) f[i]=f[i-1]+f[i-2];
	cout<<f[n]<<endl;
	return 0;
}

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

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

	int ans = 1e9;
	for (int i = 0;i < 26;i++) {
		char c = 'a' + i;
		string tmp = s;
		int count = 0;
		while (string(tmp.size(), c) != tmp) {
			for (int j = 0;j < tmp.size() - 1;j++) {
				if (tmp[j + 1] == c) {
					tmp[j] = c;
				}
			}
			tmp.pop_back();
			count++;
		}
		ans = min(ans, count);
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  while(1){
    int n,p;
    cin>>n>>p;
    if(n==0&&p==0)return 0;
    vector<int> a(n,0);
    int pool=p;
    int i=0;
    while(1){
      if(pool==0){
        pool+=a[i];
        a[i]=0;
      }else{
        pool--;
        a[i]++;
      }
      if(a[i]==p)break;
      i = (i+1)%n;
    }
/*
    while(1){
      for(i = 0;i<n;i++){
        if(pool==0){
          pool+=a[i];
          a[i]=0;
        }else{
          pool--;
          a[i]++;
        }
        if(a[i]==p)break;
      }
      if(a[i]==p)break;
    }
    */
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n;
    cin >> n;
    vector<ll> A(n);
    for (ll i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        A[i] = a - (i+1);
    }
    sort(A.begin(), A.end());

    ll b = 0;
    if (n % 2 == 0) {
        b = A[n/2 - 1];
    } else {
        b = A[n / 2];
    }

    ll res = 0;
    for (auto a : A) {
        res += abs(a-b);
    }
    cout << res << endl;
}


Measured memory_bytes: 4736
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

const int N=61,P=1000000007;

int n;

char s1[N],s2[N];

long long f[N];

int main()
{
	cin>>n;
	scanf("%s",s1);
	scanf("%s",s2);
	if(s1[0]==s2[0])
		f[0]=3;
	else
		f[0]=6;
	for(int i=1;i<n;i++)
	{
		if(s1[i]==s2[i])
		{
			if(s1[i-1]==s2[i-1])
				f[i]=f[i-1]*2ll%P;
			else
				f[i]=f[i-2];
		}
		else
		if(s1[i]==s1[i+1]&&s2[i]==s2[i+1])
		{
			if(s1[i-1]==s2[i-1])
				f[i]=f[i-1]*2ll%P;
			else
				f[i]=f[i-2]*3ll%P;
		}
	}
	if(f[n-1]==0)
		cout<<f[n-2];
	else
		cout<<f[n-1];
}

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

int main() {
#ifdef HOME
	freopen("arc95d.in", "r", stdin);
	freopen("arc95d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	vector<int> v;
	int n, best;

	cin >> n;
	v.resize(n);
	for (auto &i: v)
		cin >> i;

	sort(begin(v), end(v));
	best = v[0];
	for (int i = 1; i < n; ++i)
		if (min(best, v[n - 1] - best) < min(v[i], v[n - 1] - v[i]))
			best = v[i];

	cout << v[n - 1] << ' ' << best << '\n';

	return 0; }



Measured memory_bytes: 640
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    use = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    U = dict()
    for a in A:
        if use[a] in U: U[use[a]] = max(a, U[use[a]])
        else: U[use[a]] = a

    DP = [-1] * (N + 1)
    DP[0] = 0
    for i in range(N):
        if DP[i] > -1:
            for key in U:
                if i + key <= N:
                    DP[i + key] = max(DP[i + key], DP[i] * 10 + U[key])
    print(DP[N])

    return 0

if __name__ =="__main__":
    solve()

Measured memory_bytes: 14708
n = int(input())
A = list(map(int,input().split()))

A.sort(reverse=True)

from collections import defaultdict
d = defaultdict(int)
ans = 0
t = 0
for i in A:
    d[i] +=1
    if d[i] == 4:
        print(i**2)
        exit()
    elif d[i]==2 and ans ==0:
        ans +=2
        t = i  
    elif d[i] == 2:
        ans +=2 
    if ans ==4:
        print(t*i)
        exit()

print(0)

Measured memory_bytes: 14252
s=input()
n=len(s)
dp=[[0]*2 for _ in range(n)]
dp[0]=[1,0]
# dp[1]=
for i in range(n):
    if i+1<n:
        dp[i+1][0]=max(dp[i+1][1],dp[i][1]+1)
        if s[i]!=s[i+1]:
            dp[i+1][0]=max(dp[i+1][0],dp[i][0]+1)
    if i+2<n:    
        dp[i+2][1]=max(dp[i+2][0],dp[i][0]+1)
        if s[i-1:i+1]!=s[i+1:i+3]:
            dp[i+2][1]=max(dp[i+2][1],dp[i][1]+1)
print(max(dp[-1]))

Measured memory_bytes: 38604
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

p = 10**9 + 7

N, A, B, C = map(int, input().split())
inv100 = pow(100,p-2,p)
A = A * pow(100-C,p-2,p) % p
B = B * pow(100-C,p-2,p) % p
C = C * inv100 % p
# print(A,B,(1-C)%p)

a = [None] * (2*N+1)
inva = [None] * (2*N+1)
a[0] = 1

for i in range(1, 2*N+1):
    a[i] = i * a[i-1] % p

inva[2*N] = pow(a[2*N],p-2,p)
for i in range(2*N):
    inva[2*N-i-1] = inva[2*N-i] * (2*N-i) % p

ans = 0
prevN = pow(A,N,p) * pow(pow(B,N,p),p-2,p) % p# (A/B)^N

for m in range(N,2*N):
    tmp = (a[m-1] * inva[N-1] % p) * inva[m-N] % p
    # tmp = tmp * ((pow(B,m,p)*prevN % p + pow(A,m,p)*pow(prevN,p-2,p) % p) % p) % p
    tmp *= m
    tmp %= p
    tmp *= ((pow(A,m-N,p) * pow(B,N,p) % p) + (pow(B,m-N,p) * pow(A,N,p) % p)) % p
    tmp %= p
    ans += tmp
    ans %= p
print(ans * pow(1-C,p-2,p)%p)

Measured memory_bytes: 24980
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextInt();
    long B = sc.nextInt();
    long C = sc.nextInt();
    long X = sc.nextInt();
    long Y = sc.nextInt();

    long ans;
    if (C*2 < A+B) {
      if (X > Y) {
        ans = (X-Y)*Math.min(A,C*2) + 2*Y*C;
      } else {
        ans = (Y-X)*Math.min(B,C*2) + 2*X*C;
      }
    } else {
      ans = A*X + B*Y;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int ans = 0;
	int A, B; cin >> A >> B;
	int D; cin >> D;

	eFOR(i, A, B)if (i%D == 0)ans++;
	cout << ans << endl;


	return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll M = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    map<int, int> cnt;
    for(int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int m;
    cin >> m;
    bool ok = true;
    for(int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        ok&= --cnt[x] >= 0;
    }
    if(ok) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<string> a;
    vector<string> b;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        a.pb(s);
    }
    for(int i=0;i<m;i++){
        string s;
        cin>>s;
        b.pb(s);
    }
    int count=0;
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            int ans=1;
            for(int p=0;p<m;p++){
                for(int q=0;q<m;q++){
                    if(a[i+p][j+q]!=b[p][q]){
                        ans=0;
                    }
                }
            }
            if(ans==1){
                count=1;
            }
        }
    }
    if(count==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

namespace GrandGarden
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] strList = Console.ReadLine().Split(' ');

            List<int> flower = new List<int>();

            foreach (var str in strList)
            {
                flower.Add(int.Parse(str));
            }

            int roundCount = 0;
            int dividedCount = 0;
            bool wateringFlg = false;

            int flowerMaxValue = flower.Max();

            while (flowerMaxValue > 0)
            {

                wateringFlg = false;

                for (int i = 0; i < flower.Count; i++)
                {

                    if (flower[i] - roundCount > 0)
                    {
                        
                        if (i > 0 && flower[i - 1] - roundCount <= 0 && wateringFlg)
                        {
                            dividedCount++;
                        }
                        else
                        {
                            wateringFlg = true;
                        }
                        
                    }
                }
                roundCount++;
                flowerMaxValue--;
            }

            Console.Write(roundCount + dividedCount);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define keta setprecision(10) //10桁表示


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<double> x(n), y(n);
	rep(i, n)
	{
		cin >> x[i] >> y[i];
	}

	double ans = 0;

	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ans += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
		}
	}

	cout << setprecision(15) << ans * 2 / (double)n << endl;

	return 0;
}

Measured memory_bytes: 256
void main() {
    long s = readln.chomp.to!long;

    long x1 = 1L;
    long x2 = 10L ^^ 9;
    long y1 = (s + x2 - 1) / x2;
    long y2 = x2 * y1 - s;

    writeln(0, " ", 0, " ", x1, " ", y1, " ", x2, " ", y2);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        String s = "";
        int[] set = new int[scanner.nextInt()];
        for (int i = 0; i < set.length; i++) {
            int a = scanner.nextInt();
            if (a == scanner.nextInt())
                if (i != 0)
                    set[i] = set[i - 1] + 1;
                else
                    set[0] = 1;
            if (set[i] == 3) {
                s = "Yes";
                break;
            }
        }
        if (!s.equals("Yes"))
            s = "No";
        System.out.println(s);
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(nextToken());
    }

    long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 32872
#include<stdio.h>
#include<math.h>

int main(){

  int i, j, n;
  double q;

  scanf("%d", &n);

  int a[n], cnt=n;

  for(i=0;i<n;i++) scanf("%d", &a[i]);

  for(i=0;i<n;i++){

    if(a[i]==2) continue;
    else if(a[i]%2==0){
      cnt--;
      continue;
    }

    q = sqrt(a[i]);
    
    for(j=3;j<=q;j+=2){

      if(a[i]%j==0){

	cnt--;

	break;
      }
    }
  }

  printf("%d\n", cnt);

  return 0;
}



Measured memory_bytes: 2072
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 103
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG

//
//  ライブラリ
//

// よく使う型のエイリアス
typedef pair<int, int> p;
typedef long long ll;

// よく使う定数[配列]
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// Union-Find Tree
class UnionFindTree{
    struct node{
        int par;
    };
    std::vector<node> T;

    public:
    void init(int num){
        T.resize(num+1);    // ignore T[0]
        for (int i = 1; i <= num; ++i)
        {
            T[i].par = i;
        }
    }
    void unite(int x, int y){
        T[find(y)].par = find(x);
    }
    int find(int x){
        if (T[x].par == x) return x;
        else return T[x].par = find(T[x].par);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

//
// ライブラリ終了
//


ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX][MMAX] = {};

ll ans = INFLL;

void solve(){
    // 解答アルゴリズム
    for (int t = -100; t <= 100; ++t)
    {
        ll cand = 0;
        for (int i = 0; i < N; ++i)
        {
            cand += (A[i] - t) * (A[i] - t);
        }
        ans = min(ans, cand);
    }
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法

    // Fill(dp, -1);
    scanf("%lld", &N);
    for (int i = 0; i < N; ++i)
    {
        scanf("%lld", &A[i]);
    }
    solve();
    #ifdef DEBUG
    debug();
    #endif
    answer();

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


class Combination:
    def __init__(self, n: int, mod: int):
        self.mod = mod
        self.fact = [0] * (n + 1)
        self.factinv = [0] * (n + 1)
        self.inv = [0] * (n + 1)
        
        self.fact[0] = self.fact[1] = 1
        self.factinv[0] = self.factinv[1] = 1
        self.inv[1] = 1
        for i in range(2, n + 1):
            self.fact[i] = (self.fact[i - 1] * i) % mod
            self.inv[i] = (-self.inv[mod % i] * (mod // i)) % mod
            self.factinv[i] = (self.factinv[i - 1] * self.inv[i]) % mod
    
    def ncr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        r = min(r, n - r)
        return self.fact[n] * self.factinv[r] % self.mod * self.factinv[n - r] % self.mod
    
    def nhr(self, n: int, r: int):
        return self.ncr(n + r - 1, r)
    
    def npr(self, n: int, r: int):
        if r < 0 or n < r:
            return 0
        return self.fact[n] * self.factinv[n - r] % self.mod


def solve():
    N, M, K = map(int, rl().split())
    MOD = 998244353
    
    com = Combination(N + 10, MOD)
    
    ans = 0
    for x in range(K + 1):
        ans = (ans + com.ncr(N - 1, x) * M * pow(M - 1, N - 1 - x, MOD)) % MOD
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 78416
#include<stdio.h>

char s[8]="AGCT";

int main(){
    int i;
    char t[8];
    scanf("%s",t);
    for(i=0;i<4;i++){
        if(t[0]==s[i]){
            printf("%c\n",s[3-i]);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = (x / 500) * 1000 + (x % 500) / 5 * 5;
		
		System.out.println(ans);
		
		sc.close();
		
	}
	
}

Measured memory_bytes: 21716
import std.stdio, std.array, std.conv, std.typecons, std.algorithm, std.numeric, std.bigint;

T diff(T)(const T a, const T b) { return a > b ? a - b : b - a; }
T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void main() {
    const ip = readToArray!(ulong);
    const auto a = ip[0], b = ip[1], c = ip[2], d = ip[3];
    const auto all_cnt = b - a + 1;

    if (c == 1 || d == 1) {
        writeln(0);
    } else { // c != 1 && d != 1
        ulong lcm = c*d/gcd(c, d);
        //writefln("!!%d %d %d\n", c, d, lcm);
        ulong c_div = b/c - (a-1)/c;
        ulong d_div = b/d - (a-1)/d;
        ulong lcm_div = b/lcm - (a-1)/lcm;
        //writefln("!!%d %d %d\n", c_div, d_div, lcm_div);
        writeln(all_cnt-(c_div+d_div-lcm_div));
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

string S;

int main() {
    cin >> S;

    int l = S.length();
    bool ans = true;
    for (int i = 0; i < l; i++) {
        if (i % 2 == 1 && S[i] == 'R') ans = false;
        if (i % 2 == 0 && S[i] == 'L') ans = false;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif
 
int32_t main() 
{
	IAMSPEED
	int a,b,c,d; cin >> a >> b >> c >> d;
	while(1){
		c-=b;
		if(c<=0)return cout << "Yes",0;
		a-=d;
		if(a<=0)return cout << "No",0;
	}
}


Measured memory_bytes: 3656
s = gets.chomp
gets.to_i.times do
  c, a, b, p = gets.split
  a = a.to_i
  b = b.to_i
  case c
  when 'print'
    puts s[a..b]
  when 'reverse'
    s[a..b] = s[a..b].reverse
  when 'replace'
    s[a..b] = p
  end
end

Measured memory_bytes: 8688
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0,A=0,B=0;
  cin >> N >> A >> B;
  cout << (N*A<B?N*A:B) << endl;

  return 0;
}

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

using namespace std;

int main() {
	string s;
	int len, Len;
	int a = -1, z = -1;

	cin >> s;
	len = s.size();
	Len = len - 1;

	for (int i = 0; i < len; i++) {
		if (a < 0 && s[i] == 'A')		a = i;
		if (z < 0 && s[Len - i] == 'Z')	z = i;
		if (a >= 0 && z >= 0)	break;
	}

	cout << (len - a - z) << endl;

	return 0;
}

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

#define LIMIT 200

int main(void){
  while(true){
    int n, q;
    cin >> n >> q;
    if(n == 0 && q == 0){ break; }

    int m, input;
    int convenience[LIMIT] = {};
    for(int i = 0; i < n; i++){
      cin >> m;
      for(int j = 0; j < m; j++){
        cin >> input;
        ++convenience[input];
      }
    }

    vector<pair<int, int> > conv;
    for(int i = 0; i < LIMIT; i++){ conv.push_back(make_pair(-convenience[i], i)); }
    sort(conv.begin(), conv.end());

    if((-conv[0].first) < q){ cout << 0 << endl; }
    else{ cout << conv[0].second << endl; }
  }
  return 0;
}

Measured memory_bytes: 3020
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

point = 0
for i in range(N):
    point = point + b[i]

for i in range(1, N):
    if a[i] == a[i-1] + 1:
        point = point + c[ a[i-1]-1 ]

print(point)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    string s, t, res; cin >> s >> t;
    vector<char> sv, tv;
    res = "No";
    int ssize, tsize;
    ssize = s.size(); tsize = t.size();
    for (int i = 0; i < ssize; i++)
    {
        sv.push_back(s[i]);
    }
    sort(sv.begin(), sv.end());
    for (int i = 0; i < tsize; i++)
    {
        tv.push_back(t[i]);
    }
    sort(tv.begin(), tv.end(), greater<int>());

    int j = 0;
    for (; j < min(ssize, tsize); j++)
    {
        if (sv[j] < tv[j])
        { 
            res = "Yes";
            break;
        }
        else if ( sv[j] > tv[j] )
        {
            break;
        }
    }
    if (j == min(ssize, tsize) && ssize < tsize)
    {
        res = "Yes";
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Objects;

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

    Scanner sc = new Scanner(System.in);

    int P = sc.nextInt();
    int Q = sc.nextInt();
    int R = sc.nextInt();

    // a <-> b = P
    // b <-> c = Q
    // c <-> a = R

    int minTime = 1001;

    minTime = Math.min(minTime, Q + R);
    minTime = Math.min(minTime, P + R);
    minTime = Math.min(minTime, P + Q);
    System.out.println(minTime);
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  rep(i,n) cin >> s[i];
  rep(i,m) cin >> t[i];
  vector<vector<mint>> dp(n+1, vector<mint>(m+1,0));
  vector<vector<mint>> sum(n+1, vector<mint>(m+1,0));

  dp[0][0] = 1;
  rep(i,n+1)rep(j,m+1){
    if(j>0) dp[i][j] += dp[i][j-1];
    if(i>0) dp[i][j] += dp[i-1][j];
    if(i>0 && j>0 && s[i-1]!=t[j-1]) dp[i][j] -= dp[i-1][j-1];
  }
  ll ans = dp[n][m].x;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 62976
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  combination c(n);
  mint ans(0);
  rep(i,n){
    ans += c(i,k-1)*a[i];
  }
  rep(i,n){
    ans -= c(n-i-1,k-1)*a[i];
  }
  cout << ans.x << endl;
}


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

int n, A[50];

int solve(int i, int m){
	if(m == 0) return 1;
	if(i >= n) return 0;
	int res = solve(i+1, m) || solve(i+1, m - A[i]);
	return res;
}

int main(){
	int q, M;
	
	cin >> n;
	for(int i =0; i<n; i++){
		cin >> A[i];
	}
	
	cin >> q;
	for(int i=0; i<q; i++){
		cin >> M;
		if(solve(0,M)) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
void yesOrNo(bool flg) {
  if (flg)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

void solve(std::string N) {
  int sum = 0;

  rep(i, sz(N)) {
    int v = N.at(i) - '0';
    sum += v;
    sum %= 9;
  }

  yesOrNo(sum % 9 == 0);
}

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


Measured memory_bytes: 3712
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A = [min(x & -x, 4) for x in A]

CA = Counter(A)
num0 = CA[1]
num1 = CA[2]
num2 = CA[4]
if num1:
    num1 = 1
if num2 - (num1 + num0) >= -1:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 20404
#include <climits>
#include <iostream>

int main() {
  long a, b, x;
  std::cin >> a >> b >> x;
  if (a == 0)
    std::cout << b / x + 1 << std::endl;
  else
    std::cout << b / x - (a - 1) / x << std::endl;
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(t,a,b) for(int t=(a);t<(b);t++)
#define rrep(t,a,b) for(int t=(b)-1;t>=(a);t--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//KMP??? O(S.size()+W.size())
//https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
int knuth_morris_pratt_search(string S, string W) {
	vector<int> T(W.size());
	T[0] = -1, T[1] = 0;
	for (int w = 2, j = 0; w < W.size();) {
		if (W[w - 1] == W[j]) {
			T[w] = j + 1;
			w++, j++;
		}
		else if (j > 0)
			j = T[j];
		else
			T[w] = 0, w++;
	}

	for (int i = 0, w = 0; i + w < S.size();) {
		if (W[w] == S[i + w]) {
			w++;
			if (w == W.size())return i;
		}
		else {
			i = i + w - T[w];
			if (w > 0)w = T[w];
		}
	}
	return -1;
}
vector<int> knuth_morris_pratt_search_all(string S, string W) {
	vector<int> T(W.size() + 1);
	T[0] = -1;
	if (T.size() >= 2)T[1] = 0;
	for (int t = 2, w = 0; t < T.size();) {
		if (W[t - 1] == W[w]) {
			T[t] = w + 1;
			t++, w++;
		}
		else if (w > 0)
			w = T[w];
		else
			T[t] = 0, t++;
	}
	vector<int> ret;
	for (int i = 0, w = 0; i + w < S.size();) {
		if (W[w] == S[i + w]) {
			w++;
			if (w == W.size()) {
				ret.emplace_back(i);
				i = i + w - 1 - T[w - 1];
				if (w - 1 > 0)w = T[w - 1];
			}
		}
		else {
			i = i + w - T[w];
			if (w > 0)w = T[w];
		}
	}
	return ret;
}

signed main() {
	string S, W; cin >> S >> W;
	vector<int> ans = knuth_morris_pratt_search_all(S, W);
	rep(i, 0, ans.size())cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 9436
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int out=0;
  rep(i,10){
    int a;cin>>a;out+=a;
  }
  cout<<out<<endl;

}

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

int main(){
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  map<ll,int> mp;
  rep(i,n)mp[a[i]]++;

  ll ans=0;
  for(auto c : mp){
    ll x=c.first;
    int y=c.second;

    if(y<x){
      ans+=y;
    }
    else{
      ans+=y-x;
    }
  }
  cout << ans <<endl;

}

Measured memory_bytes: 7040
#include <stdio.h>


struct dice{
	int top;
	int bottom;
	int up;
	int down;
	int left;
	int right;
};


int north( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->down;
	n->down = n->bottom;
	n->bottom = n->up;
	n->up = temp;

	return 0;
};


int south( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->up;
	n->up = n->bottom;
	n->bottom = n->down;
	n->down = temp;

	return 0;
}







int west( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->right;
	n->right = n->bottom;
	n->bottom = n->left;
	n->left = temp;

	return 0;
}

int east( struct dice *n ){

	int temp;

	temp = n->top;
	n->top = n->left;
	n->left = n->bottom;
	n->bottom = n->right;
	n->right = temp;

	return 0;
}


int main(){

	char move;
	struct dice n;


	scanf( "%d %d %d %d %d %d\n", &n.top, &n.down,
			&n.right, &n.left, &n.up, &n.bottom );

	while(1){

		scanf( "%c", &move );
		if( move == '\n' ) break;


		switch(move){
		case 'N': north( &n ); break;
		case 'S': south( &n ); break;
		case 'E': east( &n ); break;
		case 'W': west( &n ); break;
		} 
	}	

	printf( "%d\n", n.top );	


	return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return ((fac[n]*power(fac[r],MOD-2))%MOD*power(fac[n-r],MOD-2))%MOD;}

void ram5564()
{
     int n;
     cin>>n;
     if(n%2==0)
     {
        cout<<-1;return;
     }
     int cnt=0;
     set<int>s;
     int rem,num=7;
     while(1)
     { 
        rem=num%n;
        ++cnt;

        if(rem==0)
        {
            cout<<cnt;return;
        }
        if(s.count(rem))
        {
            cout<<-1;return;
        }
        s.in(rem);
        num=rem*10+7;


     }

}

signed main()
{
        FIO
        // #ifndef ONLINE_JUDGE
        //   freopen("input.txt","r",stdin);
        //   freopen("output.txt","w",stdout);
        // #endif   
        
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

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

town = list(map(int, input().split()))
diff = [0]*(N+1)
for i in range(1, N):
    diff[i] = town[i] - town[i-1]

sumz = 0
for i in range(1, N+1):
    if diff[i]*A > B:
        sumz += B
    else:
        sumz += diff[i]*A

print(sumz)


Measured memory_bytes: 85040
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int N=1e5+5;
int n,m,p[N],tot[N];
vector < int > v[N];
vector < pair < int , int > > s;
int P(int x){
	if (p[x]==x) return x;
	return p[x]=P(p[x]);
}

void Uni(int a,int b) {
	a=P(a);
	b=P(b);
	p[b]=a;
}

void Dfs(int x,int p) {
	for (int i=0; i<v[x].size(); i++) {
		if (v[x][i]==p) continue;
		Dfs(v[x][i],x);
	}
	
	if (x!=p) {
		if (tot[x]%2==1) cout<<x<<" "<<p<<endl,tot[x]=0;
					else cout<<p<<" "<<x<<endl,tot[p]++;
	}
}
main () {
	cin>>n>>m;
	for (int i=1; i<=n; i++)
		p[i]=i;
		
	for (int i=1; i<=m; i++) {
		int x,y;
		cin>>x>>y;
		s.push_back({x,y});
	}	
	
	if (m%2==1) {
		cout<<-1<<endl;
		return 0;
	}
	
	for (int i=0; i<s.size(); i++) {
		int a=s[i].F,b=s[i].S;
		
		if (P(a)!=P(b)) {
			Uni(a,b);
			v[a].push_back(b);
			v[b].push_back(a);
		}
			else {
			tot[a]++;	
			cout<<a<<" "<<b<<endl;	
		}
	}
	
	Dfs(1,1);
}

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

typedef long long int lli;
typedef pair<int,int> pii;

lli binSearch(vector<lli> arr,lli s,lli e,lli t){
    lli low = s;
    lli high = e;
    while(low<=high){
        lli mid = low + (high - low)/2;
        if(arr[mid] == t){
            return mid;
        } else if(arr[mid]>t){
            high = mid-1;
        } else {
            low = mid+1;
        }
    }
    return -1;
}

lli greatSearch(vector<lli> arr, int vis[], lli t){
    lli l = 0;
    lli h = arr.size()-1;
    while(l<h){
        lli mid = l + (h-l)/2;
        if(vis[mid] == 0 ){
            
            if(arr[mid] == t || ((mid+1)<arr.size() && arr[mid]<t && arr[mid+1]>=t)){
                return mid;
            } else if( arr[mid]>t ){
                h = mid - 1; 
            } else {
                l = mid + 1;
            }
        }
    }
    return -1;
}

int main(){

    lli a;//b,count=0;
    cin>>a;//>>b;
    // string s;
    // cin>>s;
    // vector<lli> arr;
    
    // vector<lli> arr1;
    //unordered_map<lli,lli> ans;
    //vector<int> vis;
    
    lli arr[4] = {0};


    while(a--){
        string temp;
        cin>>temp;
        if(temp=="AC"){
            arr[0]++;
        } else if( temp == "WA") {
            arr[1]++;
        } else if( temp == "TLE") {
            arr[2]++;
        } else if (temp == "RE") {
            arr[3]++;
        }
    }   

    cout<<"AC x "<<arr[0]<<endl;
    cout<<"WA x "<<arr[1]<<endl;
    cout<<"TLE x "<<arr[2]<<endl;
    cout<<"RE x "<<arr[3]<<endl;

    // while(n--){
        
        // lli x,y,ans;
        // cin>>y>>x;
        // cout<<ans<<endl;

    //}
    return 0;
}   

Measured memory_bytes: 3628