akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;

static const double EPS = 1e-8;

int main(){
	
	int arvH,arvM,arvS,dptH,dptM,dptS;
	while(~scanf("%d %d %d %d %d %d",&arvH,&arvM,&arvS,&dptH,&dptM,&dptS)){
		int diff = ((dptH*60*60+dptM*60+dptS)-(arvH*60*60+arvM*60+arvS));
		int H = diff/60/60;
		diff %= 3600;
		int M = diff/60;
		diff %= 60;
		int S = diff;
		printf("%d %d %d\n",H,M,S);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5],B[MAXN+5],C[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	f1(i,n)sc(A[i]);
	f1(i,n)sc(B[i]);
	f1(i,n-1)sc(C[i]);
	v=-oo;
	f1(i,n){
		ans+=B[A[i]];
		if(A[i]==v+1)ans+=C[v];
		v=A[i];
	}
	pr(ans);
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

Measured memory_bytes: 4352
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def root(x):
        if par[x] == x:
            return par[x]
        par[x] = root(par[x])
        return par[x]

    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
            s[y] += s[x]
            s[x] = 0
        else:
            par[y] = x
            s[x] += s[y]
            s[y] = 0
            if rank[x] == rank[y]:
                rank[x] += 1

    n,m = LI()
    v = []
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v.append((a,b))
    par = [i for i in range(n)]
    rank = [0]*n
    s = [1]*n
    su = n*(n-1) >> 1
    ans = [su]
    for i,j in v[1:][::-1]:
        ri = root(i)
        rj = root(j)
        if ri != rj:
            su -= s[ri]*s[rj]
            unite(i,j)
        ans.append(su)
    for i in ans[::-1]:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 97116
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
  	char x;
	cin >> x;
  	cout << (char)(x+1) << endl;
	return;
}

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

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

typedef struct {
	int x,y;
} point;


int main(){
	int n,i,x,y,k,f,j,l;
	long area,max;
	static char exist[5001][5001];
	point p[3000],hold;
	scanf("%d",&n);
	while(n!=0){
		memset(exist,0,sizeof(exist));
		for(i=0;i<n;i++){
			scanf("%d %d",&p[i].x,&p[i].y);
			exist[p[i].x][p[i].y]=1;
		}
		area=0;
		max=0;
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				x=p[j].x-p[i].x;
				y=p[j].y-p[i].y;
				area=(long)x*(long)x+(long)y*(long)y;
				if(max>=area) continue;
				if(0<=p[i].x-y && p[i].x-y<=5000 && 0<=p[i].y+x && p[i].y+x<=5000 && 0<=p[i].x-y+x && p[i].x-y+x<=5000 && 0<=p[i].y+x+y && p[i].y+x+y<=5000){
					if(exist[p[i].x-y][p[i].y+x] && exist[p[i].x-y+x][p[i].y+x+y]){
						max=area;
					}
				}
			}
		}
		printf("%ld\n",max);
		scanf("%d",&n);
	}
	return 0;
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define LL              long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    char c;
    cin >> c;
    cout << (char)(c+1);
}



Measured memory_bytes: 256
A,B,C,D=map(int,input().split())
if C<=A and B<=D:
  print(B-A)
elif C<D<=A<B:
  print(0)
elif C<=A and D<=B:
  print(D-A)
elif B-C>=0 and B<=D:
  print(B-C)
elif B-C>=0 and B>=D:
  print(D-C)
else:
  print(0)

Measured memory_bytes: 9120
#include <stdio.h>
#include <stdlib.h>
int main(void){
  int a;
  int b;

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

  
 if(a>0 ||b>0 || a<23 || b <23){
  int i = a + b;
  if(i>23){
  i = i-24;
  printf("%d",i);
  }else{
  printf("%d",i);
  }
 }else{
 printf("A and B should be no more than 24");
 exit(0);
 }
}

Measured memory_bytes: 128
S = list(input())
ans = 0
for i in range(len(S)):
  for j in range(i+1,len(S)+1):
    if len(S[i:j]) == S[i:j].count("A") + S[i:j].count("C") + S[i:j].count("G") + S[i:j].count("T"):
      if ans < len(S[i:j]):
        ans = len(S[i:j])
print(ans)

Measured memory_bytes: 3064
import collections
n=int(input())
s=list(map(int, input().split()))
L=[i+a for i,a in enumerate(s)]
R=[i-a for i,a in enumerate(s)] 
t=collections.Counter(L)
u=collections.Counter(R)
ans = 0
for i in t.keys():
  ans+=t[i]*u[i]
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 105;
const int M = 305;
int w[N], v[N], dp[N][N][M];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, W;
	cin>>n>>W;
	for(int i = 1; i <= n; i++){
		cin>>w[i]>>v[i];
	}
	int base_w = w[1];
	for(int i = 1; i <= n; i++){
		w[i] -= base_w;
	}
	int ans = 0;
	memset(dp, 0, sizeof(dp));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= i; j++){
			if(j*base_w > W)break;
			for(int sum = 0; sum < M; sum++){
				if(j*base_w + sum > W)continue;
				dp[i][j][sum] = dp[i - 1][j][sum];
				if(sum >= w[i])dp[i][j][sum] = max(dp[i][j][sum], dp[i - 1][j - 1][sum - w[i]] + v[i]);
				ans = max(ans, dp[i][j][sum]);
				// cout<<i<<" "<<j<<" "<<sum + j*base_w<<" "<<dp[i][j][sum]<<'\n';
			}
		}
	}
	cout<<ans<<'\n';


	return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,W;
    cin>>n>>W;
    ll w[n], v[n];
    ll maxi = 0;
    for(ll i=0; i<n; i++)
    {
        cin>>w[i]>>v[i];
        maxi += v[i];
    }
    vector< vector<ll> >  dp(n, vector<ll>(maxi + 1, 1e10));
    for(ll i=0; i<n; i++)
    {
        dp[i][0] = 0;
    }
    dp[0][v[0]] = w[0];
    ll ans = 0;
    if(w[0]<=W)
        ans = v[0];
    for(ll i=1; i < n; i++)
    {   
        for(ll j=0; j<=maxi; j++)
        {
            if(j>=v[i])
            {
                dp[i][j] = min(dp[i-1][j - v[i]] + w[i], dp[i-1][j]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
            if(i==(n-1))
            {
                if( dp[i][j] <= W)
                {
                    // cout<<dp[i][j]<<'\n';
                    ans = max(ans, j);
                }
            }
            // cout<<dp[i][j]<<'\n';
        }
    }
    // cout<<dp[0][5]<<'\n';
    cout<<ans<<'\n';
}

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

using namespace std;

int n;
int a[2*100000] = {0};
int main(){
  long long tmp;
  cin >> n;
  cin.ignore();

  for (int i = 0; i < n - 1; i++){
    cin >> tmp;
    ++(a[tmp - 1]);
  }

  for (int i = 0; i < n; i++){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4368
#include <vector>
#include <queue>
#include <stdio.h>

using namespace std;
const int MAXN = 1005;
const int INF = (int)1e9;
vector<int> G[MAXN];

vector<int> bfs(int start, int &n) {
  int dist[n];
  int pre[n];
  fill(dist, dist + n, INF);
  fill(pre, pre + n, INF);
  queue<int> q;
  q.push(start);
  dist[start] = 0;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (size_t i = 0; i < G[v].size(); ++i) {
      int u = G[v][i];
      if (dist[u] != INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }

  pair<int, int> shortest(INF, -1);
  for (int v = 0; v < n; ++v) {
    if (v == start) continue;
    for (int u: G[v]) {
      if (u == start) {
	shortest = min(shortest, make_pair(dist[v], v));
      }
    }
  }

  if (shortest.first == INF) return vector<int>(n + 1);
  int v = shortest.second;
  vector<int> res;
  res.push_back(v);
  while (v != start) {
    v = pre[v];
    res.push_back(v);
  }
  return res;
}
  

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--; b--;
    G[a].push_back(b);
  }

  vector<int> ans(n + 1);
  for (int v = 0; v < n; ++v) {
    auto cur = bfs(v, n);
    if (cur.size() < ans.size()) ans = cur;
  }

  if (ans.size() == n + 1) {
    puts("-1");
  } else {
    printf("%lu\n", ans.size());
    for (int i = ans.size() - 1; i >= 0; --i) {
      printf("%d\n", ans[i] + 1);
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    double x,y,a,b;
    scanf("%lf%lf%lf%lf",&x,&y,&a,&b);
    printf("%lf ",(x*y)/2);
    if(a*2==x&&b*2==y)
        printf("1\n");
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        int five_count = 0;
        int seven_count = 0;
        for (int i=0; i<3; i++) {
            a[i] = Integer.valueOf(sc.next()).intValue();
            if ( a[i] == 5 ) {
                five_count++;
            } else if (a[i] == 7 ) {
                seven_count++;
            }
        }
        if (seven_count == 1 && five_count == 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 9300
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s,t;
  cin >> s;
  cin >> t;
  int slen = sz(s);
  int tlen = sz(t);
  vvi dp(slen+1,vi(tlen+1));
  rep(i,slen+1) {
    dp[i][0] = 0;
  }
  rep(i,tlen+1) {
    dp[0][i] = 0;
  }
  rep(i,slen) {
    rep(j,tlen) {
      if(s[i] == t[j]) {
        dp[i+1][j+1] = dp[i][j] + 1;
      } else {
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  int x = slen;
  int y = tlen;
  string ans = "";
  while(dp[x][y]) {
    if(s[x-1] == t[y-1]) {
      ans.push_back(s[x-1]);
      x--;
      y--;
    } else {
      
      if(dp[x-1][y-1] == dp[x][y]) {
        x--;
        y--;
      } else if(dp[x-1][y] == dp[x][y]) {
        x--;
      } else if(dp[x][y-1] == dp[x][y]) {
        y--;
      }
    }
  }
  reverse(rng(ans));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

int main() {
  ll q,h,s,d,n;
  cin >> q >> h >> s >> d >> n;

  if (2 * q < h) {
    h = 2 * q;
  }

  if (4 * q < s) {
    s = 4 * q;
  }

  if (2 * h < s) {
    s = 2 * h;
  }

  if (8 * q < d) {
    d = 8 * q;
  }

  if (4 * h < d) {
    d = 4 * h;
  }

  if (2 * s < d) {
    d = 2 * s;
  }

  ll ans = 0;
  if (n % 2 == 0) {
    ans += (n / 2) * d;
  } else {
    ans += (n / 2) * d;
    ans += s;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
near_A = 1e8
for i, H in enumerate(map(int, input().split())):
  ave_tem = T - H * 0.006
  if near_A > abs(ave_tem - A):
    near_A = abs(ave_tem - A)
    res = i + 1
print(res)

Measured memory_bytes: 9148
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 10000100
//#define NIL -1

int main() {
    LL n;
    set<LL> a;
    LL tmp_a;
    cin >> n;
    for(LL i=0; i<n; i++){
        cin >> tmp_a;
        a.insert(tmp_a);
    }

    if(a.size()%2==0){
        cout << a.size()-1 << endl;
    }else{
        cout << a.size() << endl;
    }



    return 0;
}


Measured memory_bytes: 8288
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int w, a, b; cin >> w >> a >> b;
    
    if(a+w<b){
        cout << b - a - w << endl;
    }
    else if(a>b+w){
        cout << a - w - b << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    //splitを使うことでStringがそれぞれ入る。
    String S[] = sc.next().split("");
    //＋の位置の場合は２の(n-1)乗
    int n = (int)Math.pow(2, S.length - 1);
    
    long total = 0;
    for (int i = 0; i < n; i++) {
      String s = S[0];//125の場合　最初の文字(1)は固定　あとの"2"5 "のどこに＋がはいるのか
      
      for (int j = 0; j < S.length - 1; j++) {
        if ((i>>j & 1) == 1) {
          total += Long.parseLong(s);
          s = S[j + 1];
        } else {
          s += S[j + 1];
        }
      }
      total += Long.parseLong(s);
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
typedef long long ll;
#define endl "\n"

using namespace std;

//ll const N = 32000;
int cnt[26];

int main()
{
    string w;
    int flag = 0;

    cin >> w;

    for(int i = 0; i < w.size(); i++)
    {
        cnt[w[i] - 97]++;
    }


    for(int i = 0; i < 26; i++)
    {
        if(cnt[i] % 2 != 0)
        {
            flag++;
            break;
        }
    }

    if(flag == 0)printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>tc>>n>>x;
	while(tc--)
	{
		cin>>m;
		x+=(n-1)/m+1;
	}
	cout<<x<<nw;
	
}


Measured memory_bytes: 3612
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

k = I()
s = 0
for i in range(k):
    s = 10*s+7
    s = s%k
    if s == 0:
        print(1+i)
        break
else:
    print(-1)

Measured memory_bytes: 63224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> v(N);
    for (ll i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(ALL(v), greater<ll> ());

    // for (ll i = 0; i < N; i++) {
    //     printf("%lld %lld\n", i, v[i]);
    // }


    ll AVE = 0;
    double ans;
    ll cnt = 0; double tmp;
    ll a;
    ll b;
    ll V;

    for (ll i = 0; i < A; i++) {
        AVE += v[i];
    }
    if( AVE == v[A-1] * A ){
        ans = (double)AVE / (double)A;
        a = N;
        for (ll i = 0; i < N; i++) {
            if(v[i] != v[A-1]){
                a = i;
                break;
            }
        }
        for (ll i = A; i < min(a, B)+1; i++) {
            tmp = 1;
            for (ll j = 0; j < i; j++) {
                tmp = tmp * (a - j) / (j+1);
            }
            cnt += (ll)(tmp+0.5);
        }
    }
    else{
        ans = (double)AVE / (double)A;
        V = v[A-1];
        a = A;
        for (ll i = 0; i < N; i++) {
            if(v[i] == V){
                a = i;
                break;
            }
        }
        b = N - a;
        for (ll i = 0; i < N; i++) {
            if(v[i] < V){
                b = i - a;
                break;
            }
        }

        tmp = 1;
        for (ll j = 0; j < A-a; j++) {
            tmp = tmp * (b - j) / (j+1);
        }
        cnt += (ll)(tmp+0.5);
        
    }

    printf("%40.18f\n", ans);
    printf("%lld\n", cnt);

}

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

int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n)cin >> a[i];
	vector<P> ch(m); rep(i,m)cin >> ch[i].second >> ch[i].first;
	sort(a.begin(), a.end());
	sort(ch.begin(), ch.end());
	reverse(ch.begin(), ch.end());
	ll r = 0; rep(i,n)r += a[i];
	ll ans = r;
	ll j = 0;
	rep(i,n){
		if(ch[j].second == 0)j++;
		if(j == m)break;
		r = r - a[i] + ch[j].first;
		ch[j].second--;
		ans = max(ans,r);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc, a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>x;
    if(x>=400 && x<600)cout<<8<<endl;
    else if(x>=600 && x<800)cout<<7<<endl;
    else if(x>=800 && x<1000)cout<<6<<endl;
    else if(x>=1000 && x<1200)cout<<5<<endl;
    else if(x>=1200 && x<1400)cout<<4<<endl;
    else if(x>=1400 && x<1600)cout<<3<<endl;
    else if(x>=1600 && x<1800)cout<<2<<endl;
    else if(x>=1800 && x<2000)cout<<1<<endl;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std; 

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

  int current = 0;
  int val = 0;
  for (int i = 0; i < S.size(); i++)
  {
    char s = S.at(i);
    if (s != 'A' && s != 'C' && s != 'G' && s != 'T')
    {
      if (current > val) val = current;
      current = 0;
    } 
    else 
    {
      current++;
    }
  }

  cout << max(val, current) << endl;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int a,b,c;
void solve(){
	cin >> a >> b >> c;
	cout << (a+b)*c/2 << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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


int merge(long int a1[], long int a2[], int a1_size, int a2_size, long int a[]);
int mergeSort(long int a[], int number);

int main(void)
{
	long int n;
	long int sum = 0;
	long int i, j, index = 0;
	long int work;
	long int max;
	long int mcount = 0;
	long int pcount = 0;
	long int a[100000] = {0};
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &a[i]);
		if(a[i] > 0) {
			pcount++;
		} else {
			mcount++;
		}
	}
	
	mergeSort(a, n);
	
	if(mcount == 0) {
		for(i = 1; i < n; i++) {
			sum += a[i];
		}
		printf("%ld\n", sum - a[0]);
		work = a[0];
		for(i = 1; i < n - 1; i++) {
			printf("%ld %ld\n", work, a[i]);
			work -= a[i];
		}
		printf("%ld %ld\n", a[n - 1], work);
	} else {
		if(pcount == 0) {
			for(i = 0; i < n - 1; i++) {
				sum += labs(a[i]);
			}
			printf("%ld\n", sum + a[n - 1]);
			work = a[n - 1];
			for(i = n - 2; i >= 0; i--) {
				printf("%ld %ld\n", work, a[i]);
				work -= a[i];
			}
		} else {
			for(i = 0; i < n; i++) {
				sum += labs(a[i]);
			}
			printf("%ld\n", sum);
			work = a[n - 1];
			for(i = 0; i < mcount - 1; i++) {
				printf("%ld %ld\n", work, a[i]);
				work -= a[i];
			}
			max = a[mcount - 1];
			for(i = mcount; i < n - 1; i++) {
				printf("%ld %ld\n", max, a[i]);
				max -= a[i];
			}
			printf("%ld %ld\n", work, max);
		}
	}
	
	/*
	for(i = 0; i < n; i++) {
		printf("%ld\n", a[i]);
	}
	
	for(i = 0; i < m; i++) {
		printf("%ld %ld\n", b[i], c[i]);
	}
	*/
	
	return 0;
}

int merge(long int a1[], long int a2[], int a1_size, int a2_size, long int a[])
{
	int i = 0, j = 0;
	
	while( (i < a1_size ) || (j < a2_size) ){
		if( (j >= a2_size ) || ( (i < a1_size) && (a1[i] < a2[j]) ) ) {
			a[i + j] = a1[i];
			i++;
		} else {
			a[i + j] = a2[j];
			j++;
		}
	}
	
	return 0;
}

int mergeSort(long int a[], int number)
{
	int m = number / 2, n = number - m;
	long int a1[m];
	long int a2[n];
	int i, j;
	
	if(number > 1) {
		for(i = 0; i < m; i++) {
			a1[i] = a[i];
		}
		for(i = 0; i < n; i++) {
			a2[i] = a[m + i];
		}
		mergeSort(a1, m);
		mergeSort(a2, n);
		merge(a1, a2, m, n, a);
	}
	
	return 0;
}


Measured memory_bytes: 4096
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

constexpr long long mod = 1e9 + 7;

int main() {

    int H, W;
    cin >> H >> W;

    vector<string> a(H);
    for (int i = 0; i < H; i++)cin >> a[i];

    vector<vector<long long>> dp(H, vector<long long>(W, 0));
    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '.') {
                if (i > 0 && a[i - 1][j] == '.') dp[i][j] += dp[i - 1][j], dp[i][j] %= mod;
                if (j > 0 && a[i][j - 1] == '.') dp[i][j] += dp[i][j - 1], dp[i][j] %= mod;
            }
        }
    }

    cout << dp[H - 1][W - 1] << endl;

    return 0;
}
















































Measured memory_bytes: 9216
import java.util.Scanner;

/**
 * ABC Swap
 */
public class Main {

	public static void main(String...args) {
		try (Scanner sc = new Scanner(System.in)){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int z = sc.nextInt();
			StringBuilder sb = new StringBuilder();
			sb.append(z).append(" ")
				.append(x).append(" ")
				.append(y);
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>

struct max_min
{
    int64_t max = 0;
    int64_t min = 0;
};

const int64_t cc = pow( 10, 9 ) + 7;
//std::cout<< std::fixed << std::setprecision(10) << ( double )( max ) / 2;
bool sort_pair( std::pair< int64_t, int64_t > origin, std::pair< int64_t, int64_t > another )
{
    return origin.first < another.first;
}


int main()
{
    std::string word = "aa";
    int64_t a,b,c,d,e,f;
 
    std::vector< std::pair< int64_t, int64_t > > list;
    std::cin>> a;
    std::cin>> b;

    c = -1;
    
    for( int i = 1; i <= 10000; i++ )
    {
        d = i * 0.08;
        f = i * 0.10;
        
        if( d == a
            && f == b )
        {
            c = i;
            break;
        }
    }

    std::cout<< c;
    
}


Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
using namespace std;
typedef long long ll;

int main()
{
		ll x, y;
		cin >> x >> y;

		ll ans = 0;
		ll m = abs(y) - abs(x);
		ll n1 = abs(y), n2 = abs(x);
		if (m == 0) {
			ans = 1;
		}
		else {
			ans += abs(m);
			if (n1 > n2) {
				if (x < 0)ans++;
				if(y < 0) ans++;
			}
			else{
				if (x > 0)ans++;
				if (y > 0)ans++;
			}
		}
		cout << ans << endl;
return	0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    
    while (!(H == 0 && W == 0)) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if ((i + j) % 2 == 0)
                    cout << '#';
                else
                    cout << '.';
            }
            cout << endl;
        }
        cout << endl;
        
        cin >> H >> W;
    }
    
    return 0;
}



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

int main() {
  int n;
  cin>>n;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  int ans2 = 0;
  for (int i=0; i<n-1; i++) {
    if (a[n-1] % 2 == 0) {
      if (abs(a[n-1] / 2 - a[i]) < abs(a[n-1] / 2 - ans2)) {
        ans2 = a[i];
      }
    } else {
      int t1 = a[n-1] / 2;
      int t2 = a[n-1] / 2 + 1;
      int s1 = min(abs(t1 - a[i]), abs(t2 - a[i]));
      int s2 = min(abs(t1 - ans2), abs(t2 - ans2));
      if (s1 < s2) {
        ans2 = a[i];
      }
    }
  }
  cout<<a[n-1]<<" "<<ans2<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

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

    if (a <= 0 && b >= 0) {
        cout << "Zero\n";
        return 0;
    }

    if (a > 0) {
        cout << "Positive\n";
        return 0;
    }
    else if ((b - a) % 2 == 1) {
        cout << "Positive\n";
        return 0;
    }
    else {
        cout << "Negative\n";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200005], T[200005];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i, N) cin >> A[i];
    if(N==2){
        cout << 0 << endl;
        return 0;
    }

    rep(i, N) T[i] = A[i] - i;
    map<ll, ll> mp;
    repe(i, 1, N) mp[T[i]]++;

    ll ans = 0;
    rep(i,N-2){
        mp[T[i + 1]]--;
        ans += mp[T[i] - 2 * A[i]];
    }

    cout << ans << endl;

    

}

Measured memory_bytes: 29372
N, M = gets.chop.split.map(&:to_i)
H = gets.chop.split(' ').map(&:to_i)
A = M.times.map { gets.chop.split(' ').map(&:to_i) }

ans = Array.new(N, nil)

A.each do |i|
  x = i[0] - 1
  y = i[1] - 1

  if H[x] == H[y]
    ans[x] = false
    ans[y] = false
  elsif H[x] > H[y]
    ans[x] = true if ans[x].nil?
    ans[y] = false
  else
    ans[y] = true if ans[y].nil?
    ans[x] = false
  end
end

cnt = ans.count{ |x| x.nil? || x == true }

puts cnt


Measured memory_bytes: 23312
#include<bits/stdc++.h>
using namespace std;
long long ans;
const int mod = 1e9+7;
const int maxN = 100010;
long long fac[maxN], facInv[maxN], inv[maxN];
void initComb() {
    fac[0] = fac[1] = 1;
    facInv[0] = facInv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < maxN; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        facInv[i] = facInv[i - 1] * inv[i] % mod;
    }
}
long long comb(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (facInv[k] * facInv[n - k] % mod) % mod;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (auto & a : A) cin >> a;
    sort(A.begin(), A.end());
    initComb();
    long long tmp;
    for (int i = K-1; i < N; ++i) {
        if ((tmp = A[i]-A[N-i-1]) < 0) tmp += mod;
        if ((ans += comb(i, K-1) * tmp % mod) >= mod) ans -= mod;
#ifdef DEBUG
        printf("%d, %d, %lld\n", i, K-1, comb(i, K-1) * tmp % mod);
#endif
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2944
import sys

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

min_a = 0
sum_a = 0
for i in range(n):
    sum_a += a[i]
    if i % 2 == 0:
        if sum_a <= 0:
            min_a += abs(sum_a) + 1
            sum_a += abs(sum_a) + 1
    else:
        if sum_a >= 0:
            min_a += abs(sum_a) + 1
            sum_a -= abs(sum_a) + 1

min_b = 0
sum_b = 0
for i in range(n):
    sum_b += a[i]
    if i % 2 == 0:
        if sum_b >= 0:
            min_b += abs(sum_b) + 1
            sum_b -= abs(sum_b) + 1
    else:
        if sum_b <= 0:
            min_b += abs(sum_b) + 1
            sum_b += abs(sum_b) + 1

print(min(min_a, min_b))


Measured memory_bytes: 14644
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
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; }

int main(){

	lli n;
	cin>>n;

	lli cnt=0;
	char prev = '0';

	REP(i,0,n){
		char c;
		cin>>c;
		if(i==n){}
		else{
			if(prev != c)cnt++;
		}
		prev = c;
	}


	cout<<cnt<<endl;






    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int a[100000];
int cnt[3];//現在の数
int main()
{
	int n;
	ll ans=1;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	fill(cnt,cnt+3,0);
	int c=0;
	for(int i=0;i<n;i++)
	{
		c=0;
		for(int j=0;j<3;j++)
		{
			if(cnt[j]==a[i])
				c++;
		}
		ans*=c;
		ans%=MOD;
		for(int j=0;j<3;j++)
		{
			if(cnt[j]==a[i])
			{
				cnt[j]++;
				break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
while True:
    n, x = [int(i) for i in input().split()]
    if (n == 0) and (x == 0):
        break
    count = 0
    for i in  range(1,n+1):
        for j in range(i+1, n+1):
            if j < x - i - j < n+1:
                count += 1
            elif x - i - j < 1:
                break
    print(count)


Measured memory_bytes: 5600
#D
from collections import deque
K=int(input())
lunlun=[str(i) for i in range(1,10)]
Q=deque([str(i) for i in range(1,10)])
while len(lunlun)<=2*(10**5):
    q=Q.popleft()
    i=int(q[-1])
    lunlun.append(q+str(i))
    Q.append(q+str(i))
    if i+1<10:
        lunlun.append(q+str(i+1))
        Q.append(q+str(i+1))
    if i-1>=0:
        lunlun.append(q+str(i-1))
        Q.append(q+str(i-1))
lunlun=list(int(i) for i in set(lunlun))
lunlun.sort()
print(lunlun[K-1])

Measured memory_bytes: 43372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5];
  for(int i=0;i<3;i++){
    cin>>a[i];
  }
  sort(a,a+3);
  cout<<a[1]-a[0]+a[2]-a[1]<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    string s;
    cin>>s;
    
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])cout<<"Bad"<<endl;
    else fin("Good");
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
using namespace std;

int main(){
  int d[10];
  for (int i=1;i<=4;i++)d[i] = 0;
  for (int i=0;i<6;i++){
    int z;
    scanf("%d", &z);
    d[z]++;
  }
  if(d[1]<=2&&d[2]<=2&&d[3]<=2&&d[4]<=2) printf("YES\n");
  else printf("NO\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin>>N;
    long long stone[N];
    long long dp[N+1];
    for(long long i=0;i<N;++i){
        cin>>stone[i];
        dp[i]=1000000002;
    }

    dp[0]=0;
    for(long long i=0;i<N;++i){
        if(i+1<N) dp[i+1]=min(dp[i+1],dp[i]+llabs(stone[i]-stone[i+1]));
        if(i+2<N) dp[i+2]=min(dp[i+2],dp[i]+llabs(stone[i]-stone[i+2]));
    }
    cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  char a[3];
  cin >> a[0] >> a[1] >> a[2];
  if ((int(a[0]) * 100 + int(a[1]) * 10 + int(a[2])) % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define gap ' '
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
#define mod  100000007
int dp[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
            cin>>a[i];
    dp[0]=0;
    for(int i=0;i<a[0];i++)
        dp[i]=0;
    for(int i=a[0];i<=k;i++)
    {
        int f=0;
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0 && dp[i-a[j]]==0)
            {
                f=1;
                break;
            }
        }
        if(f) dp[i]=1;

    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


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

//関数名：mod_pow
//概要：modつき指数関数
//第一引数a：指数の底
//第二引数b：指数
//第三引数mod：法となる値
//戻り値：a^b(m mod)
long long mod_pow(long long a, long long b, long long mod){
    if(b == 0) return 1;
    if(b % 2 == 0){
        long long d = mod_pow(a,b/2,mod);
        return (d*d)%mod;
    }else return a%mod*mod_pow(a,b-1,mod)%mod;
}

//関数名：mod_combination
//概要：modつき二項係数
//第一引数n：組み合わせの全体
//第二引数r：何個取り出すか
//第三引数mod：法となる値
//戻り値：nCr(m mod)
long long mod_combination(long long n,long long r,long long mod){
    if(r > n) return 0;
    if(n == r || r == 0) return 1;
    long long fact1 = 1,fact2 = 1;
    for(long long i = n; i >= n-r+1; i--) fact1 = fact1*i%mod;
    for(long long i = r; i >= 1; i--) fact2 = fact2*i%mod;
    return fact1*mod_pow(fact2,mod-2,mod)%mod;
}


int main(){
    const long long mod = 1e9+7;
    long long n,k; cin >> n >> k;
    for(long long i = 1; i <= k; i++) cout << mod_combination(n-k+1,i,mod)*mod_combination(k-1,i-1,mod)%(mod) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll ;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull ;
const double PI = acos(-1) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define for0(i,n)          for(int i=0;i<n;i++)
#define for1(i,n)          for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
//#define gcd(a, b)     __gcd(a, b)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
//#define abs(x)		fabs(x)
#define pcase(z,x)     cout<<"Case "<<z<<": "<<x<<"\n"
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define max 100003

using namespace std;
ll n,m,y,x,a,b,h,e,l,o,i,j;

int main()
{
	
	CIN;
	cin>>n;
	 db p=(sqrt(8*n)-1)*1.0/2;
	p=ceil(p);
	cout<<(ll)p<<nw;

	


}



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

int main(){
	
	int a,b,c;
	cin>>a>>b>>c;
	if((a == b && b != c) || ( b ==c && c != a) || ( c == a && a != b) ){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N,K,sum=0;
  cin>>N>>K;
  int l[N];
  for(int i=0;i<N;i++) cin>>l[i];
  sort(l,l+N);
  for(int i=0;i<K;i++) sum+=l[N-i-1];
  cout<<sum<<endl;
}	


Measured memory_bytes: 256
n,x=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])

if sum(a)==x:
    print(n)
elif sum(a)<x:
    print(n-1)
else:
    ans=0
    for i in a:
        x-=i
        if x>=0:
            ans+=1
        else:
            break
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int A, B;
	cin >> A >> B;
	if (A >= 10 || B >= 10) {
		cout << -1;
	}
	else {
		cout << A * B << endl;
	}
}

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 100000 + 10;
const int MOD = 1000000007;
const int LOG = 20;
const int INF = 1000000010;
const int delta = 11353;
 
int n, A[N];
bool Solve() {
	
	bool f = 1;
	for(int i = 1; i <= n; i++) if (A[i] != 1) f = 0;
	if (f) return 0;
	int Ev = 0, Od = 0; 
	int id = 0;
	for (int i = 1; i <= n; i++) {
		if (A[i] % 2 == 1) Od++, id = i;
		else Ev++;
	}
 
	if (Ev % 2 == 1) return 1; 
	if (Od > 1) return 0; 
	if (A[id] == 1) return 0; 
	A[id]--;
 
	int g = A[0];
	for (int i = 1; i <= n; i++) g = __gcd(g, A[i]);
	for (int i = 1; i <= n; i++) A[i] /= g;
 
	f = Solve();
	return !f;
}
 
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> A[i];
	if (Solve()) cout << "First" << endl; 
	else cout << "Second" << endl;
	return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	ll a,b;
	cin>>a>>b;
	if(b==1) ret(0)
	ans=a;
	cnt=1;
	if(ans>=b) ret(cnt);
	while(ans<b){
		ans=ans-1+a;
		cnt++;
	}
	// trace(ans,cnt);
	ret(cnt)
	
	return 0;
}


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

const int M = 100000;

ll n, x, m, a[M + 1];
int used[M];

int main() {
  cin >> n >> x >> m;
  a[0] = x;
  int l = 0;
  rep(i, m) used[i] = -1;
  while (1) {
    // printf("l = %d\n", l);
    if (used[a[l]] != -1) break;
    used[a[l]] = l;
    a[l + 1] = a[l] * a[l] % m;
    l++;
  }
  int si = used[a[l]];
  ll ans = 0;
  rep(i, si) ans += a[i];
  n -= si;

  // cout << ans << endl;

  ll sm = 0;
  for (int i = si; i < l; i++) sm += a[i];
  ll ln = l - si;
  ans += n / ln * sm;
  n %= ln;

  // cout << ans << endl;

  int i = si;
  rep(j, n) {
    ans += a[i++];
    if (i >= l) i = si;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4344