akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	double a,b,x;
	std::cin >> a>>b>>x;
	if(x<=a*a*b/2)std::cout<<std::setprecision(10)  << atan(a*b*b/x/2)*180/M_PI << std::endl;
	else{std::cout<<std::setprecision(10)  << atan(2*(a*a*b-x)/a/a/a)*180/M_PI << std::endl;}
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int a[2000];
int d[2000];
int f[2000];
vector <int> v[2000];
vector <int> w[2000];

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

void dfs(int x) {
    int i;
    
    f[x] = 1;
    
    for (i = 0; i < v[x].size(); i++) {
        int y = v[x][i];
        
        if (f[y] == 0) {
            d[y]++;
            w[x].push_back(y);
            dfs(y);
        }
    }
}

int main() {
    int n, i, j;
    vector <int> ans;
    priority_queue <int> q;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    sort(a, a + n);
    
    for (i = 0; i < n; i++) {
        for (j = i + 1; j < n; j++) {
            if (gcd(a[i], a[j]) > 1) {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }
    
    for (i = 0; i < n; i++) {
        if (f[i] == 0) {
            dfs(i);
            q.push(i);
        }
    }
    
    while (!q.empty()) {
        int x = q.top();
        
        q.pop();
        
        ans.push_back(a[x]);
        
        for (i = 0; i < w[x].size(); i++) {
            int y = w[x][i];
            
            d[y]--;
            
            if (d[y] == 0) q.push(y);
        }
    }
    
    for (i = 0; i < n; i++) {
        if (i > 0) putchar(' ');
        printf("%d", ans[i]);
    }
    puts("");
    
    return 0;
}


Measured memory_bytes: 17792
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    set<string> s;
    map<string,ll> mp;
    rep(i,n){
        cin >> str;
        sort(str.begin(),str.end());
        s.insert(str);
        mp[str]++;
    }
    for(auto itr=s.begin();itr!=s.end();itr++){
        if(mp[*itr]>=2){
            a=0;
            rep(i,mp[*itr]){
                a+=i;
            }
            sum+=a;
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>l(n);
  rep(i,n)cin>>l[i];
  
  sort(l.begin(),l.end(),greater<int>());
  int ans=0;
  rep(i,k)
    ans+=l[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
 
using namespace std;
 
int main(){
    int array[3];
    for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
    for(int i = 2; i > 0; i--){
        for(int j = 0; j < i; j++){
            if(array[j] > array[j+1])
            swap(array[j],array[j+1]);
        }
    }
    printf("%d %d %d\n",array[0],array[1],array[2]);
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  vector<int> a(5);
  rep(i,5) cin >> a[i];
  int check = 10;
  int last = 0;
  int num = 6;
  rep(i,5){
    if(a[i] % 10 != 0 && a[i] % 10 < check){
      last = a[i];
      num = i;
      check = a[i] % 10;
    }
  }
  rep(i,5){
      if(i == num) continue;
      a[i] = a[i] + (10 - a[i] % 10)%10;
  }
  int ans = 0;
  rep(i,5){
    if(i == num) continue;
    ans += a[i];
  }
  ans += last;
  cout << ans << endl;
}

Measured memory_bytes: 3556
package main

import (
	"fmt"
	"strings"
)

func main(){
	abc95a()
}

func abc95a(){
	var s string
	fmt.Scan(&s)

	sp := strings.Split(s,"")
	add := 0
	for v := range sp {
		if sp[v] == "o" {
			add += 100
		}
	}
	fmt.Print(700 + add)
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int gcd(int a,int b){
    int temp;
    while(b){
        temp=b;
        b=a%b;
        a=temp;
    }
    return a;
}

int main(){
    int n; cin>>n;
    int p=1,s=1;
    vector<int> a(n,0),cnt(1000001,0);
    rep(i,n) cin>>a[i];
    int g=a[0];
    rep(i,n){
        int N=a[i];
        for(ll j=2;j*j<=N;j++){
            if(N%j==0){
                if(cnt[j]>0) p=0;
                while(N%j==0){
                    N/=j; cnt[j]++;
                }
            }
        }
        if(N>1){
            if(cnt[N]>0) p=0;
            cnt[N]++;
        }
        g=gcd(g,a[i]);
    }
    if(g!=1) s=0;
    if(p==1){
        cout<<"pairwise coprime"<<endl;
    }
    else if(s==1){
        cout<<"setwise coprime"<<endl;
    }
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 11124
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define abs(a) ((a < 0) ? -(a) : a)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

int main() {
	int d = ri();
	int n = ri();
	
	int res = 1;
	for (int i = 0; i < d; i++) {
		res *= 100;
	}
	
	if (n == 100) n++;
	res *= n;
	
	printf("%d", res);
	
	return 0;
}


Measured memory_bytes: 128
/* ex 9_1
   person_A */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}


int main(void){
    stack stk;
    char keys[11],result[11];
    int i=0,stkSize;
    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);
    //文字列の入力
    scanf("%s", keys);

    //スタックで文字列を処理
    while(keys[i]!='\0'){
        if(keys[i]=='B'){
            if(stk.count>0){
                pop(&stk);
            }
        }
        else{
            push(&stk,keys[i]);
        }
        i++;
    }

    //結果の出力
    stkSize=stk.count;
    result[stkSize]='\0';
    for(i=0;i<stkSize;i++){
        result[stkSize-i-1]=pop(&stk);
    }
    printf("%s\n",result);
    return 0;
}

Measured memory_bytes: 1660
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int X = sc.nextInt();
    int a[] = new int[N+1];
    int sum = 0;
    for (int i = 0; i <= N; i++) {
      if (i == 0) a[0] = 0;
      else {
        a[i] = sc.nextInt();
        sum += a[i];
      }
      if (sum > X) {
        System.out.println(i);
        return;
      }
    }
    System.out.println(N+1);
  }
}


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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;
const int INF = 1000000000;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int heights[n];
    rep(i,n) cin>>heights[i];
    int dp[n];
    rep(i,n) dp[i] = 1e9;
    dp[0] = 0;
    rep(i,n){
    	for(int j = i+1;j<=i+k;j++)
    	{
    		if(j < n)
    			dp[j] = min(dp[j],dp[i] + abs(heights[i] - heights[j]));
    	}

    }
    //rep(i,n+1) cout<<dp[i]<<endl;
    cout<<dp[n-1]<<endl;

    
    return 0;
}

Measured memory_bytes: 1024
a,b = map(str, input().split())
 
lis = []
res_a = a
res_b = b
 
for i in range(int(b)-1):
  res_a += a
lis.append(res_a)
 
for i in range(int(a)-1):
  res_b += b
lis.append(res_b)
 
print(int(sorted(lis)[0]))

Measured memory_bytes: 3060
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;




int main(){
 
 int N;
 cin>>N;
 vector <ll> A(N);

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

 sort(A.begin(),A.end());
 
 int flag = 1;

 for(int i=1;i<N;i++){
   if(A[i] == A[i-1]) flag = 0;
 }

 if(flag ==1) {
   cout<<"YES"<<endl;
  
 }
else {
  cout<<"NO"<<endl;
}

   
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int l,a,b,c,d;
	int koku,koku2,suu,suu2;
	
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	koku=a/c;
	koku2=a%c;
	suu=b/d;
	suu2=b%d;
	if(koku2>0){
		koku=koku+1;
	}
	if(suu2>0){
		suu=suu+1;
	}
	if(koku>suu){
		l=l-koku;
	}
	else{
		l=l-suu;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> v;
    while (N != 0) {
        int b = N % (-2) != 0 ? 1 : 0;
        v.insert(v.begin(), b);
        N = (N - b) / (-2);
    }

    for (vector<int>::iterator it = v.begin(); it != v.end(); ++it) {
        printf("%d", *it);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
// E - Simple String Queries
// Segment Tree version
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

// Segment Tree: sum
template<class T> class SegmentTree{//0_origin
private:
	#define LEFT(i) (2*(i)+1)
	#define RIGHT(i) (2*(i)+2)
	int n;//最下段データ数
	vector<T> node;//セグ木
	T init = T(0);//sum
	T calc_func(T left, T right){return left + right;}//sum
	T bottom_up(int i){return calc_func(node[LEFT(i)], node[RIGHT(i)]);}
public:
	SegmentTree(const vector<T> &v){// 配列 をセグ木にする
		int size = v.size();
		for(n=1; n<size; n<<=1);//最下段データ数
		node.resize(2*n-1, init);//セグ木領域確保
		for(int i=0; i<size; ++i) node[n-1 + i] = v[i];//最下段設定
		for(int i=n-2; i>=0; --i) node[i] = bottom_up(i);
	}
	void update(int i, T val){
		i += n-1;//最下段のindex
		if(node[i] == val) return;
		node[i] = val;//最下段更新
		while(i){i = (i-1)/2; node[i] = bottom_up(i);}
	}
	int calc(int a, int b, int k=0, int l=0, int r=-1){// calc[a,b), k:self index, segT[l,r)
		if(r<0) r = n;//first time [l,r)=[0,n)
		if(r<=a || b<=l) return init;//unmatch: !(l<b & a<r)
		if(a<=l && r<=b) return node[k];//match: calc[l,r)
		return calc_func(calc(a, b, LEFT(k), l, (l+r)/2), calc(a, b, RIGHT(k), (l+r)/2, r));//calc_func(left,right)
	}
};

using SEGT = SegmentTree<int>;
using VSEG = vector<SEGT>;

int main(){
	int N,Q; string S; cin>>N>>S>>Q;

	VSEG segT;
	rep(i,26){
		vector<int> a(N); rep(j,N) if(S[j] == i+'a') a[j] = 1;
		segT.push_back(SEGT(a));
	}

	while(Q--){
		int t; cin>>t;
		if(t-1){//type2 out
			int l,r; cin>>l>>r; --l;
			int ans = 0;
			rep(i,26) if(segT[i].calc(l, r)) ans++;//[l,r)
			printf("%d\n",ans);
		}
		else{//type1 update
			int i; cin>>i; --i;
			segT[S[i]-'a'].update(i, 0);//del
			cin>>S[i];
			segT[S[i]-'a'].update(i, 1);//add
		}
	}
}

Measured memory_bytes: 109408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int rate[10];
int main() {
  double X;cin >> X;
  cout << ceil((-1+sqrt(1+8*X))/2) << endl;
  
  return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define inf 1e16
#define MOD 1e9+7
#define gcd __gcd //最大公約数,gcd(x,y)
int lcm(int a, int b){return a/gcd(a, b)*b;} //(int)最小公倍数,lcm(x,y)
ll llcm(ll a, ll b){return a/gcd(a, b)*b;}//(ll)最小公倍数,lcm(x,y)


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

    ll len,ans=0,tmp=0,i;
    len = S.length()+1;

    for(i=0 ; i<len ; i++){
        if((S[i] == 'A')||(S[i] == 'C')||(S[i] == 'G')||(S[i] == 'T')){
            tmp++;
        }else{
            ans = max(ans,tmp);
            tmp = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
using Graph = vector<vector<int>>;

signed main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  Graph G(N);
  for( int i = 0; i < N-1; i++ ){
    G.at(i).push_back(i+1);
    G.at(i+1).push_back(i);
  }
  X--;
  Y--;
  G.at(X).push_back(Y);
  G.at(Y).push_back(X);
  
  vector<int> ans(N+10, 0);
  
  for( int i = 0; i < N; i++ ){ //それぞれの頂点からBFS
    vector<int> dist(N, -1);
    queue<int> que;
    dist.at(i) = 0;
    que.push(i);
  
    while( !que.empty() ){
      int v = que.front();
      que.pop();
    
      for( int nv : G.at(v) ){
        if( dist.at(nv) != -1 ) continue; //すでに通っていたらスルー
        dist.at(nv) = dist.at(v)+1;
        ans.at(dist.at(v)+1)++;
        que.push(nv);
      }
    }
  }
  
  for( int i = 1; i < N; i++ ) cout << ans.at(i)/2 << endl;
  
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 1001001001;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef tuple<string, int, int> T;

int main() {

    int n;
    cin >> n;

    vector<T> ts;

    rep(i, n) {
        string c;
        int p;
        cin >> c;
        cin >> p;
        p = -p;
        T t(c, p, i + 1);
        ts.push_back(t);
    }

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

    for (auto t : ts) {
        cout << get<2>(t) << endl;
    }
}



Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    if ( L[i].value <= R[j].value ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( A[j].value <= x.value ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if ( p < r ){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1,a=0;
  a=kansu(a);
  if(a == 0){
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
}
}
void kansu(int a){
 int b=0,c=1;
 if(b == 0);
  if(c == 1);
   return a;
}


Measured memory_bytes: 4108
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
using namespace std;
 
typedef long long ll;
const int MAX = 1e5;
 
int n;
int a[MAX];
 
ll solve(bool flag, ll sum) {
  ll res = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (flag) {
      if (sum >= 0) {
        res += sum + 1;
        sum = -1;
      }
    }
    else {
      if (sum <= 0) {
        res += -sum + 1;
        sum = 1;
      }
    }
    flag = !flag;
  }
  return res;
}
 
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  cout << min(solve(true, 0), solve(false, 0)) << endl;
  return 0;
}

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

int main(){
  int N,max=0,Alice,Bob;
  cin >> N;
  vector<int> vec(N);
  for(int i=0 ; i < N ; i++) cin >> vec.at(i); //数列入力
  
  for(int i=0 ; i < (N+1)/2 ; i++){
    for(int j=0 ; j < N ; j++){
      if(vec.at(j) >= max) max = vec.at(j); //最大値を入力
      }
    Alice += max; //Aliceに最大値を入力
    for(int j=0 ; j < N ; j++){
      if(vec.at(j) == max) {
        vec.at(j) = 0 ; //最大値を0にする
        break;
      }
      }
    max = 0 ; //max初期化
    for(int j=0 ; j < N ; j++){
      if(vec.at(j) >= max) max = vec.at(j); //最大値を入力
      }
    Bob += max; //Bobに最大値を入力
    for(int j=0 ; j < N ; j++){
      if(vec.at(j) == max) {
        vec.at(j) = 0 ; //最大値を0にする
        break;
      }
      }
    max = 0 ; //max初期化
  }

  cout << Alice - Bob ; //AliceとBobの差を出力

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string num;
map<int,int> mp;

int main(){
    cin>>num;
    mp[0]=1;
    ll ans=0,cnt=0,p=1;
    for(int i=num.length()-1;i>=0;i--){
        cnt=(cnt+(ll)(num[i]-'0')*p)%2019;
        ans+=mp[cnt],mp[cnt]++;
        p=p*10%2019;
    }
    printf("%d",ans);
}


Measured memory_bytes: 3900
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define maxn zhi5968
typedef long long ll;
using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int mx=max(a,max(b,c));
	cout<<a+b+c+mx*9<<endl; 
	return 0;
}


Measured memory_bytes: 764
N,K = map(int,input().split())

A = list(map(int,input().split()))

reached = []

check = [0]*(N+1)
now = 1


for _ in range(N):
    check[now]+=1
    if check[now] == 1 :
        reached.append(now)
        now = A[now-1]

    if check[now] > 1:
        break

#print(reached)

for i in range(len(reached)):
    if reached[i]== now:
        cnt = i
        break


roop = len(reached)- cnt
init = len(reached) 

if K < init:
    print(reached[K])
else:
    print(reached[(K-init)%roop+cnt])


Measured memory_bytes: 32372
#include <iostream>
using namespace std;
int main(void){
   int a, b, c;
   cin >> a;
   cin >> b;
   cin >> c;

  if (a <= b&&a <= c){
      if(b <=c){
          cout << a;
          cout << " ";
          cout << b;
          cout << " ";
          cout << c;
      }else{
      cout << a;
      cout << " ";
      cout << c;
      cout << " ";
      cout << b;
      }
      
  }else if (b <= a&&b <= c){
      if(a <= c){
          cout << b;
          cout << " ";
          cout << a;
          cout << " ";
          cout << c;
      }else{
      cout << b;
      cout << " ";
      cout << c;
      cout << " ";
      cout << a;
      }
      
  }else if (c <= a&&c <= b){
      if(a <= b){
          cout << c;
          cout << " ";
          cout << a;
          cout << " ";
          cout << b;
      }else{
      cout << c;
      cout << " ";
      cout << b;
      cout << " ";
      cout << a;
      }
  }
  
   cout << endl;
}
//ITP1_2_C


Measured memory_bytes: 3072
"use strict";
function Main(input) {
    let N = input.split("\n")[0] - 0;
    const d = (v) => v * 100 + v * 10 + v;
    for (let n = 1; n <= 9; n++) {
        let ans = d(n);
        if (ans >= N) {
            console.log(ans);
            return;
        };
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int l=0, r=0;
    rep(i,4){
        int x; cin >> x;
        if(i<2) l+=x; else r+=x;
    }
    if(l>r) out("Left");
    else if(l<r) out("Right");
    else out("Balanced");
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  s = "";
  ll n, l;
  in2(n, l);
  vector<string> a(n);
  rep(i, n)
    in(a[i]);
  sort(all(a));
  rep(i, n)
    out(a[i]);
  memi;
}

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

int main() {
    int N;
    int K;
    string S;

    cin >> N;
    cin >> K;
    cin >> S;

    if(S[K-1]=='A') {   
        S[K-1]= 'a';
    }
    else if(S[K-1]=='B') {
        S[K-1]='b';
    }
    else if(S[K-1]=='C') {
        S[K-1]='c';
    } 

    cout << S << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        if(n % 500 <= a) {
        System.out.println("Yes");
        }
        else{
        	System.out.println("No");
        }
}
}

Measured memory_bytes: 21972
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int a = nextInt();
        int b = nextInt();

        int Answer = 0;

        if (b * 2 <= a) {
        	Answer = a - (b * 2);
        }

        println(Answer);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

}

Measured memory_bytes: 21844
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String C = sc.next();

		sc.close();

		out.println(((char) (C.charAt(0) + 1)));

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23252
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int l[200000];
int r[200000];
int p[100000];
int q[100000];
int dp[501][501];
int th[6];
int main() {
  int n;
  string s;
  cin >> n;
  map<char, int> m;
  m['M'] = 1;
  m['A'] = 2;
  m['R'] = 3;
  m['C'] = 4;
  m['H'] = 5;
  rep(i, n){
    cin >> s;
    th[m[s[0]]]++;
  }
  int c[] = {0,0,1,1,1};
  ll ans = 0;
  do{
    ll sum = 1;
    reps(i,5){
      if(c[i-1]){
        sum *= th[i];
      }
    }
    ans += sum;
  }while(next_permutation(c, c+5));
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int[][] c = new int[a][b];
    int counter = 0;
      for(int i = 0;i < a;i++){
        for(int j = 0;j < b;j++){
          c[i][j] = sc.nextInt();
        }
      }
      for(int x = 0;x < a;x++){
        for(int v = 1;v < a-x;v++){
          int d = 0;
          double e = 0;
          int f = 0;        
          for(int y = 0;y < b;y++){ 
              d += Math.pow(c[x][y] - c[x+v][y],2);
          }      
          e = Math.sqrt(d);
          f = (int)e;
          if(e - f == 0){
            counter++;
          }
        }
      }
    System.out.println(counter);
    sc.close();
  }
}

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

#define pb push_back
#define pob pop_back
#define st first
#define nd second
#define test printf("test\n");
#define endll printf("\n")
#define mp make_pair
#define sol (node*2)
#define sag ((node*2)*1)
#define orta (bas+son)/2
#define eps 1e-6


#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

#define FOR( i, L, U ) for(int i=(int)L ; i<=(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )

typedef long long ll;
typedef long long int lli;
typedef long long unsigned llu;
typedef pair < int,int > pii;
typedef pair < ll,lli > plli;

const int MAX = 1e5+7, N=1e5+3;
double pi = cos(-1);
int r,l,k,m,n,ans;

//-------------END OF DRAFT-------------


int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b>=c) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(A >= B) {
			System.out.println("delicious");
		}else if(B <= X+A) {
			System.out.println("safe");
		}else {
			System.out.println("dangerous");
		}
		
		
	}

}


Measured memory_bytes: 23764
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())

fib = [1]*50

for i in range(N+2):
    fib[i+2] = fib[i] + fib[i+1]

print(fib[i-1])




Measured memory_bytes: 6064
N,M = map(int,input().split())
d = [ [0]*(N+2) for _ in range(N+2) ]

for i in range(M):
  a,b,x = map(int,input().split())
  a -= 1
  b -= 1
  d[a][b] += 1
  d[a][b+1] -= 1
  d[a+x+1][b] -= 1
  d[a+x+2][b+1] += 1
  d[a+x+1][b+x+2] += 1
  d[a+x+2][b+x+2] -= 1

# for r in d: print(r)

# vertical
for i in range(N+2):
  for j in range(1, N+2):
    d[i][j] += d[i][j-1]

# print("=============vertical===============")
# for r in d: print(r)

# horizontal
for i in range(N+2):
  for j in range(1, N+2):
    d[j][i] += d[j-1][i]

# print("=============horizontal===============")
# for r in d: print(r)

# diagonal
for i in range(1, N+2):
  for j in range(1, N+2):
    d[i][j] += d[i-1][j-1]

# print("=============diagonal===============")
# for r in d: print(r)

res = 0
for i in range(N+2):
  for j in range(N+2):
    if d[i][j] != 0:
      res += 1

print(res)


Measured memory_bytes: 597076
#include <bits/stdc++.h>
#define N 100005
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define mset(x,y) memset(x,y,sizeof(x))
#define strL strlen
#define p_b push_back
#define mcpy(x,y) memcpy(x,y,sizeof(x))
#define lson l,mid,(o<<1)
#define rson mid+1,r,((o<<1)|1)
#define Ls (t[o].ls)
#define Rs (t[o].rs)
#define mod
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
vector<int> g[N];
int mch[N];
void dfs(int x,int f){
	for(auto to:g[x])
		if(to!=f){
			dfs(to,x);
			if(!mch[to]) mch[x]=to,mch[to]=x;
		}
	if(!mch[x]){
		if(mch[f] || f==0){
			puts("First");
			exit(0);
		} 
		mch[x]=f,mch[f]=x;
	}
}
int main(){
	int n,u,v;
	scanf("%d",&n);
	if(n==1) return puts("First"),0;
	For(i,1,n-1){
		scanf("%d%d",&u,&v);
		g[u].push_back(v),g[v].push_back(u);
	}
	dfs(1,0);
	puts("Second");
}

Measured memory_bytes: 6144
#include<iostream>

int main()
{
	int n;

	std::cin >> n;

	double x1,y1,x2,y2,x3,y3,x4,y4;

	for(int i=0;i<n;++i)
	{
		std::cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

		double m1 = (y1-y2)/(x1-x2);

		double m2 = (y3-y4)/(x3-x4);

		std::cout <<  (m1==m2 ? "YES":"NO") << '\n';
	}
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#define INF 0x3f3f3f3f
using namespace std;
inline int read(){
    int w=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        w=(w<<3)+(w<<1)+ch-48;
        ch=getchar();
    }
    return w*f;
}
int n,m,q,a[200010],b[200010],ans,vec[20010];
priority_queue<int> pq;
inline void work(){
    while(!pq.empty()){
        if(pq.size()>=m){
            vec[0]++;vec[vec[0]]=-pq.top();
        }
        pq.pop();
    }
}
signed main(){
    n=read();m=read();q=read();ans=INF;
    for(int i=1;i<=n;i++)a[i]=read();
    for(int i=1;i<=n;i++){
        int now=a[i];
        for(int j=1;j<=n;j++){
            if(a[j]>=now) pq.push(-a[j]);
            else work();
        }
        work();
        if(vec[0]>=1){
            sort(vec+1,vec+vec[0]+1);
        }
        if(vec[0]>=q&&vec[1]==now){
            ans=min(ans,vec[q]-now);
        }
        memset(vec,0,sizeof(vec));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


int main()
{
    ll n,d;
    cin >> n >> d;
    int res = 0;
    rep(i,n) {
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) res++;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,q;cin>>n>>q;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<ll>b(n);
    b[0]=a[0];
    REP(i,1,n){
        b[i]=b[i-1]+a[i];
    }
    vector<ll>c(n),d(n);
    c[0]=a[0];
    d[1]=a[1];
    REP(i,2,n){
        if(i%2==0){
            c[i]=c[i-2]+a[i];
        }else{
            d[i]=d[i-2]+a[i];
        }
    }
    vector<ll>K(n);
    REP(i,1,n/2+1){
        if(i==n/2&&n%2==0){
            K[i]=b[n-1]-b[n-i-1];
            continue;
        }
        K[i]=b[n-1]-b[n-i-1]+c[n-2*i-1]+d[n-2*i-1];
    }
    K[n/2+1]=b[n-1]-b[n/2-1];
    while(q){
        q--;
        ll x;cin>>x;
        if(a[n/2]-x>=x-a[0]){
            cout<<K[n/2+1]<<endl;
            continue;
        }
        if(2*x>a[n-2]+a[n-3]){
            cout<<K[1]<<endl;
            continue;
        }
        ll l=1,r=n/2+1;
        while(r-l>1){
            ll k=(r+l)/2;
            ll A,B;
            A=a[n-k*2-1];
            B=a[n-k-1];
            if(A+B<2*x)r=k;
            else l=k;
        }
        cout<<K[r]<<endl;
    }
}

Measured memory_bytes: 5632
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**6)
threading.stack_size(2**27)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]
size=0
def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)
def dfs(node,visited,adj):
    global size
    visited[node]=1
    size+=1
    for child in adj[node]:
        if not visited[child]:
            dfs(child,visited,adj)

def main():
    #t=int(input())
    t=1
    for _ in range(t):
        n,m=inar()
        visited=[0]*(n+1)
        adj=defaultdict(list)
        for i in range(m):
            u,v=inar()
            adj[u].append(v)
            adj[v].append(u)
        global size
        ans=1
        for i in range(1,n+1):
            if visited[i]==0:
                size=0
                dfs(i,visited,adj)
                ans=max(ans,size)
        print(ans)






BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    #main()
    threading.Thread(target=main).start()


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

const ll mod = 1000000007;
const ll INF = 1001001001;

ll dp[200000][5];

int main(){
    string s; cin >> s;
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < 4; j++){
            if(s[i] == '?'){
                dp[i+1][j] += dp[i][j] * 3 % mod;
                dp[i+1][j] %= mod;
            }
            else{
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= mod;
            }
        }
        if(s[i] == 'A' || s[i] == '?'){
            dp[i+1][1] += dp[i][0];
            dp[i+1][1] %= mod;
        }
        if(s[i] == 'B' || s[i] == '?'){
            dp[i+1][2] += dp[i][1];
            dp[i+1][2] %= mod;
        }
        if(s[i] == 'C' || s[i] == '?'){
            dp[i+1][3] += dp[i][2];
            dp[i+1][3] %= mod;
        }
    }
    cout << dp[s.size()][3] << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

//const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n, ll mod ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int T=1;
    //cin >> T;
    while(T--){
        ll k;
        cin>>k;
        ll r=0, tmp;
        rep(i,k){
            tmp = po(10,i,k);
            tmp*=7;
            tmp%=k;
            r+=tmp;
            r%=k;
            if(r==0){
                cout<<i+1<<el;
                return 0;
            }
        }
        cout<<-1<<el;

    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){

    vector<int> x(3);

    cin >> x[0] >> x[1] >> x[2];

    sort(ALL(x));

    cout << x[2] * 10 + x[0] + x[1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  ll k;
  cin >> n >>k;
  vector<ll> a(n);
  rep(i, n){
    cin >>a[i];
  }
  vector<ll> xcand;
  rep(ni, 42){
    ll x=0;
    for(int i=41;i>=0; i--){
      if(i==ni)continue;
      ll tmp=1ll<<i;
      if(x+tmp>k)continue;
      int zero=0, one=0;
      rep(j, n){
        if((a[j]>>i)&1){
          one++;
        } else {
          zero++;
        }
      }
      if(zero>one){
        x+=tmp;
      }
    }
    xcand.push_back(x);
  }

  ll ans=0;
  int xsz=xcand.size();
  rep(ni, xsz){
    ll num=0;
    rep(i, n){
      num+=a[i]^xcand[ni];
    }
    ans=max(ans, num);
  }

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


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,ans;
int main() {
	ios::sync_with_stdio(false);
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a; i++)
		for(int j = 0; j <= b; j++)
			for(int k = 0; k <= c; k++)
				ans += i * 500 + j * 100 + k * 50 == x;
	cout << ans << endl;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h, w;
  cin >> h >> w;
  
  vector<vector<char>> s(h + 2, vector<char>(w + 2, '#'));
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      cin >> s.at(i).at(j);
    }
  }
  
  int ans = 0;
  queue<pair<int, int>> q;
  vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      if(s.at(i).at(j) == '#') continue;
      vector<vector<int>> dis(h + 2, vector<int>(w + 2, -1));
      q.push(make_pair(i, j));
      dis.at(i).at(j) = 0;
      while(!q.empty()){
        int nowx, nowy;
        nowx = q.front().first;
        nowy = q.front().second;
        q.pop();
        for(int k = 0; k < 4; k++){
          if(s.at(nowx + dx[k]).at(nowy + dy[k]) == '.' && dis.at(nowx + dx[k]).at(nowy + dy[k]) == -1){
            dis.at(nowx + dx[k]).at(nowy + dy[k]) = dis.at(nowx).at(nowy) + 1;
            q.push(make_pair(nowx + dx[k], nowy + dy[k]));
          }
        }
      }
      
      for(int k = 1; k <= h; k++){
        for(int l = 1; l <= w; l++){
          if(dis.at(k).at(l) != -1) ans = max(ans, dis.at(k).at(l));
        }
      }
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//Prints the Longest common subsequence
void printLCS( char *s1, char *s2, int m, int n )
{
   int L[m+1][n+1];
 
   //Building L[m][n] as in algorithm
   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (s1[i-1] == s2[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }
 
   //To print LCS
   int index = L[m][n];
   //charcater array to store LCS
   char LCS[index+1];
   LCS[index] = '\0'; // Set the terminating character
   
   //Stroing characters in LCS
   //Start from the right bottom corner character
   int i = m, j = n;
   while (i > 0 && j > 0)
   {
      //if current character in s1 and s2 are same, then include this character in LCS[]
      if (s1[i-1] == s2[j-1])
      {
          LCS[index-1] = s1[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }
      // compare values of L[i-1][j] and L[i][j-1] and go in direction of greater value.
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
 
   // Print the LCS
   cout << LCS << endl;
//   cout << "LCS of " << s1 << " and " << s2 << " is "<<endl << LCS<<endl;
}
 
/* Driver program to test above function */
int main()
{
  //string a,b;

  char s1[4000];
  char s2[4000];
  cin >> s1 >> s2;
  printLCS(s1, s2, strlen(s1), strlen(s2));
  return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
template <typename T> using lim = numeric_limits<T>;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> A(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    vector<ll> mem(n + 1, -1);
    function<ll(int)> opt = [&](int i) {
        ll& ans = mem[i];
        if(ans == -1) {
            if(i == 0) {
                ans = 0;
            } else {
                ll a = A[i], b = A[i];
                ans = lim<ll>::max();
                for(int j = i - 1; j >= 0 and (i - j) <= m; j--) {
                    ans = min(ans, opt(j) + k + (i - j) * (a - b));
                    a = max(a, A[j]), b = min(b, A[j]);
                }
            }
        }
        return ans;
    };
    cout << opt(n) << endl;
    return 0;
}



Measured memory_bytes: 5484
#include <stdio.h>


int main(void){
  int x,a,b;

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

  if(a >= b){
    printf("delicious\n");
    return 0;
  }else if(a + x >= b){
    printf("safe\n");
    return 0;
  }
  printf("dangerous\n");

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  bool flag = true;
  for ( int i = 0; i < s.length(); i++){
    if ( i % 2 == 0){
      if ( s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
        flag = false;
        break;
      }
    } else {
      if ( s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
        flag = false;
        break;
      }
    }
  }

  if ( flag ){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

long long p10(int i){
  long long l=1;
  while(i--){
    l*=10;
  }
  return l;
}

int l10(long long l){
  int i=0;
  while(l>=10){
    i++;
    l/=10;
  }
  return i;
}

string fb(long long l){
  if(l%15==0){
    return "FizzBuzz";
  }else if(l%3==0){
    return "Fizz";
  }else if(l%5==0){
    return "Buzz";
  }else{
    stringstream ss;
    ss<<l;
    return ss.str();
  }
}

long long bs(long long s){
  for(long long c=0,l=0;;){
    if(s-c<=15){
      string str;
      for(long long i=c+1;i<=s;i++){
	l+=fb(i).size();
      }
      return l;
    }else if(l10(c)==l10(c+15)){
      long long nc=(min(p10(l10(c)+1)-1,s)-c)/15;
      l+=(8*(l10(c)+1)+32)*nc;
      c+=nc*15;
    }else{
      do{
	c++;
	l+=fb(c).size();
      }while(l10(c)==l10(c-1));
    }
  }
}

int main(){
  long long s;
  cin>>s;
  long long l=0,h=1000000000000000000;
  while(h-l>1){
    long long m=(l+h)/2;
    if(bs(m)<=s-1){
      l=m;
    }else{
      h=m;
    }
  }
  string str;
  for(int i=0;i<20;i++){
    str+=fb(i+l+1);
  }
  cout<<str.substr(s-bs(l)-1,20)<<endl;
}

Measured memory_bytes: 1224