akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
const int mod = 1000000007;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end();
#define pp pair<ll,ll>
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
using namespace std;
int main() {
	int n, v[200],ans=0;
	cin >> n;
	rep(i, n) { cin >> v[i]; ans += v[i]; }
	sort(v, v + n);
	int nn=-1;
	rep(i, n)if (v[i] % 10 != 0) { nn = v[i]; break; }
	cout<<(ans%10!=0?ans:(nn==-1?0:ans-nn))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;

ll n, nn,d=1;
int ans;

int main() {
	cin >> n;
	nn = n;
	while (nn / 10) {
		nn /= 10;
		ans += 9;
		d *= 10;
	}
	
	if ((nn + 1)*d - 1 <= n) ans += nn;
	else ans += (nn - 1);
	
	cout << ans;
	system("pause");
	return(0);
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    char a,b;
    cin >> a >> b;
    if(a == b) cout << "H" << endl;
    else cout << "D" << endl;
}

Measured memory_bytes: 256
from sys import stdin
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
s = list(map(int, input().split()))
ans = [0]*N
sum
for i in range(0, K):
    ans[i] = (s[i]+1)/2
sum = sum(ans)
mx = sum
for i in range(K, N):
    ans[i] = (s[i]+1)/2
    sum = sum+ans[i]-ans[i-K]
    if mx < sum:
        mx = sum
# print(s, ans, mx)
print(mx)


Measured memory_bytes: 25372
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
ll calc(ll x)
{
    ll res = 1;
    for (ll i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            res *= i;
            while (x % i == 0) {
                x /= i;
            }
        }
    }
    if (x != 1) res *= x;
    return res;
}
 
int main()
{
    ll p, q;
    cin >> p >> q;
    p = q / __gcd(p, q);
    cout << calc(p) << endl;
    return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define PI acos(-1)
using namespace std;
int main()
{
    int r;
    double red;
    while(cin>>r)
    {
        red=2*PI*r;
        cout<<fixed<<setprecision(20)<<red<<endl;
        return 0;
    }

}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%mod;
        x=x*x%mod;
        n>>=1;
    }
    return res;
}

ll dp[201][100001];

int main(){
    int n,x;
    cin>>n>>x;
    ll s[n];
    rep(i,n)cin>>s[i];
    sort(s,s+n,greater<ll>());
    dp[0][x]=1;
    for(int i=0;i<n;++i){
        ll p=modpow(n-i,mod-2);
        for(int j=0;j<=x;++j){
            dp[i+1][j%s[i]]=(dp[i+1][j%s[i]]+dp[i][j]*p)%mod;
            dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(mod+1-p))%mod;
        }
    }
    ll ans=0;
    for(int i=0;i<=x;++i){
        ans=(ans+i*dp[n][i])%mod;
    }
    rep(i,n){
        ans=(ans*(i+1))%mod;
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

ll n, x, d;

map<ll, vector<pair<ll,int>>> info;

int main(){
    cin>>n>>x>>d;
    if(d==0){
        if(x==0){
            cout<<1;
            return 0;
        }else{
            cout<<n+1;
            return 0;
        }
    }
    if(d<0){
        d *= -1;
        x *= -1;
    }
    ll left_sum = 0;
    ll right_sum = 0;
    for(ll k=0;k<=n;k++){
        info[k*x%d].emplace_back(k*x+left_sum*d, 0);
        info[k*x%d].emplace_back(k*x+right_sum*d, 1);
        left_sum += (k);
        right_sum += n-k-1;
    }

    ll ans = 0;

    for(auto k: info){
        vector<pair<ll,int>>& vec = k.second;
        sort(vec.begin(), vec.end());
        ll curr_val = 0;
        ll start_idx = -1;
        for(int i=0;i<vec.size();i++){
            ll a;
            int b;
            tie(a,b) = vec[i];
            if(b){
                curr_val--;
                if(curr_val == 0){
                    ans += (a - start_idx)/d + 1;
                }
            }else{
                //시작
                curr_val++;
                if(curr_val == 1){
                    start_idx = a;
                }
            }
        }
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
int ac[10001];

int last = -1;
int suff[10001];
int N,K;

vector<int> answer(10);

string gen(vector<int> &g,int l,int r){
	string w = string(N,'0');
	for(int i = l ; i < r ; i++) if( !ac[ g[i] ] ) w[ g[i] ] = '1';
	return w;
}

string gen2(){
	string w = string(N,'0');
	for(int i = 0 ; i < N ; i++) if( !ac[i] ) w[i] = '0' + suff[i];
	return w;
}

int get(string s){
	cout << "?" << s << endl;
	fflush(stdout);
	int ans = 0;
	//rep(i,K) ans += s[answer[i]] - '0';
	cin >> ans;
	fflush(stdout);

	return ans%2;
}


int odd(vector<int> &g,int l ,int r){
	if(l+1 == r){
		ac[g[l]] = true;
		last = g[l];
		return 0;
	}
	int m = (l+r)/2;
	if( get(gen(g,l,m)) == 1){
		odd(g,l,m);
	}else{
		odd(g,m,r);
	}
}
int even(){
	for(int i = 0 ; i < 200 ; i++){
		if(get(gen2()) == 1) break;
		random_shuffle(suff,suff+N);
	}
	vector<int> a;
	string w = gen2();
	rep(i,N) if(w[i] == '1') a.push_back(i);
	odd(a,0,a.size());
}
int main(){
	int k;
	cin >> N >> k;
	//K = k;
	//rep(i,K) cin >> answer[i];
	vector<int> awawa;
	for(int i = 0 ; i < N ; i++) awawa.push_back(i);
	for(int i = 0 ; i < N ; i++) suff[i] = i%2;
	while(k){
		if(k%2){
			odd(awawa,0,awawa.size());
		}else{
			even();	
		}
		awawa.erase(remove(awawa.begin(),awawa.end(),last),awawa.end());
		k--;
	}
	vector<int> ans;
	rep(i,N) if(ac[i])ans.push_back(i+1);
	cout << "!";
	rep(i,ans.size()) cout << (i?" ":"") << ans[i];
	cout << endl;
	fflush(stdout);
}

Measured memory_bytes: 0
using System;

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

            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            for(int i=0;i<N;i++)
            {
                int a = int.Parse(s[i]);

                while(a % 2 ==0)
                {
                    a = a / 2;
                    ans++;
                }
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 11744
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if((c-a-b)*(c-a-b)>4*a*b && c-a-b>0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int Max=0x3f3f3f3f;
int a[200005];
int main()
{
    int n,k;
    while(~scanf("%d%d",&n,&k))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a+1,a+1+n);
        if(k>=n)printf("0\n");
        else
        {
            ll sum=0;
            for(int i=n-k;i>=1;i--)
            {
                sum+=a[i];
            }
            printf("%lld\n",sum);
        }
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
//#define rep2(i, s, n) for (int i = (s); i < (int) (n); i++)
#define rep3(i, s, n) for (int i = (s); i <=(int) (n); i++)
//#define chmax(x,y) x = max(x,y)

	int a[3005][3005];
	long long dp[3005][3005][4];


int main() {
	int R,C,n;
	cin >> R >> C >> n;

	rep(i, n) {
	int r,c,v;
		cin >> r >> c >> v;
		a[r][c]=v;
	}

	rep3(i,1,R){
 		rep3(j,1,C) {
			dp[i][j][3]=max(dp[i][j][3],dp[i][j][2]+a[i][j]);
			dp[i][j][2]=max(dp[i][j][2],dp[i][j][1]+a[i][j]);
			dp[i][j][1]=max(dp[i][j][1],dp[i][j][0]+a[i][j]);
			dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][0]);
			dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][1]);
			dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][2]);
			dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][3]);
			dp[i][j+1][0]=max(dp[i][j+1][0],dp[i][j][0]);
			dp[i][j+1][1]=max(dp[i][j+1][1],dp[i][j][1]);
			dp[i][j+1][2]=max(dp[i][j+1][2],dp[i][j][2]);
			dp[i][j+1][3]=max(dp[i][j+1][3],dp[i][j][3]);
		}
	}
	long long ans;
	ans=max(dp[R][C][0],dp[R][C][1]);
	ans=max(ans,dp[R][C][2]);
	ans=max(ans,dp[R][C][3]);

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


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

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

	if(s == "SUN") cout << 7 << endl;
	else if(s == "MON") cout << 6 << endl;
	else if(s == "TUE") cout << 5 << endl;
	else if(s == "WED") cout << 4 << endl;
	else if(s == "THU") cout << 3 << endl;
	else if(s == "FRI") cout << 2 << endl;
	else if(s == "SAT") cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
pair = [["null","one pair","two pair"],["three card","full house"]]

while True:
	try:
		card = map(int,raw_input().split(","))
	except EOFError:
		break
	
	hand = [0,0,0,0,0,0,0,0,0,0,0,0,0]
	one  = 0
	three= 0
	four = 0
	straight = 0
	for i in range(0, 5):
		hand[card[i] - 1] += 1
		
	for i in range(0, 13):
		if hand[i] == 2:
			one += 1
		elif hand[i] == 3:
			three += 1
		elif hand[i] == 4:
			four = 1
		if hand[i] == 1:
			straight += 1
		elif straight != 5:
			straight = 0
			
	if straight == 4 and hand[0] == 1 or straight == 5:
		print "straight"
	elif four == 1:
		print "four card"
	else:
		print pair[three][one]

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

struct T{
	int y, p, i, j;
}a[100005];

bool cmp(T a, T b){
	if(a.y == b.y)
		return a.p < b.p;
	return a.y < b.y;
}

bool cmp1(T a, T b){
	return a.i < b.i;
}

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		scanf("%d %d",&a[i].y,&a[i].p);
		a[i].i = i;
	}
	sort(a+1,a+1+m,cmp);
//	for(int i = 1; i <= m; i++)
//		printf("%d %d\n",a[i].y,a[i].p);	
	int x = 1, y = 1;
	for(int i = 1; i <= m; i++){
		if(a[i].y > x){
			x = a[i].y;
			y = 1;	
		}
		a[i].j = y++;
//		printf("%06d%06d\n",x,y++);
	}
	sort(a+1,a+1+m,cmp1);
	for(int i = 1; i <= m; i++)
		printf("%06d%06d\n",a[i].y,a[i].j);
	return 0;
} 

Measured memory_bytes: 3072
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S2 = in.next();
            String T = in.next();

            Utils.debug(S2, T);

            boolean match = false;
            String minS = ""+(char)(1+(int)'z');
            String S = "";
            for (int i = 0; i < S2.length(); i++) {
                Utils.debug("match(S2, " + i + ", T)", match(S2, i, T));
                if (match(S2, i, T)) {
                    match = true;
                    String S3 = S + T;
                    for (int j = S3.length(); j < S2.length(); j++) {
                        char charAt = S2.charAt(j);
                        if (charAt == '?') {
                            S3 += 'a';
                            continue;
                        }
                        S3 += charAt;
                    }

                    Utils.debug("S3", S3);

                    if (S3.compareTo(minS) < 0) {
                        minS = S3;
                        Utils.debug("minS", minS);
                    }
                    // i += T.length();
                    // i--;
                    // break;
                    // continue;
                }
                if (S2.charAt(i) == '?') {
                    S += 'a';
                } else {
                    S += S2.charAt(i);
                }
                Utils.debug("S", S);
            }

            if (match) {
                System.out.println(minS);
            } else {
                System.out.println("UNRESTORABLE");
            }
        }
    }

    private static boolean match(String s2, int i, String t) {
        for (int k = 0; k < t.length(); k++) {
            if (i + k >= s2.length()) {
                return false;
            }

            if (s2.charAt(i + k) == t.charAt(k)) {

            } else if (s2.charAt(i + k) == '?') {

            } else {
                return false;
            }
        }
        return true;
    }
}

final class Utils {
    private Utils() {
    }

    public static final void debug(Object... o) {
        System.err.println(toString(o));
    }

    public static final String toString(Object... o) {
        return Arrays.deepToString(o);
    }

}


Measured memory_bytes: 22100
# C - Walk on Multiplication Table
n = (int)(input())

minimum = 1e18
i = 1
while(i*i <= n):
    if n % i != 0:
        i += 1
        continue;
    j = (int) (n / i)
    minimum = min(i + j - 2, minimum)
    i +=1

print(minimum)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	long long a,b,num;
	scanf("%lld %lld",&a,&b);
	if((a>0 && b>0) || a==b){
		printf("Positive\n");
	}
	if((a<=0 && b>=0) || a==0 || b==0){
		printf("Zero\n");
	}
	if(a<0 && b<0){
		num=(b-a)+1;
		if(num%2==0){
			printf("Positive\n");
		}else{
			printf("Negative\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
import collections
from itertools import chain
H,W,K=map(int, input().split())

grid=[list(map(str,input())) for i in range(H)]

ans=0

for i in range(2**W):
    for j in range(2**H):
        
        temp=[[grid[s][t] for t in range(W)]for s in range(H)]
        ww=bin(2**W+i)[3:]
        hh=bin(2**H+j)[3:]
        for ws in range(W):
            for hs in range(H):
                if ww[ws]=='1' or hh[hs]=='1':
                    temp[hs][ws]='.'
        temtemp=list(chain.from_iterable(temp))
        cc=collections.Counter(temtemp)
        if cc['#']==K:
            ans+=1

print(ans)



Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define int long long
#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
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll MOD=998244353;
const ll mod=MOD;
const int MAX=200010;

signed main(){
    ll n,k;cin>>n>>k;
    vector<ll>l(k),r(k);
    rep(i,k)cin>>l[i]>>r[i];
    vector<ll>dp(n+2);
    vector<ll>dp2(n+2);
    dp[1]=1;
    REP(i,1,n+1){
        dp2[i]=(dp2[i-1]+dp2[i])%mod;
        dp[i]=(dp[i]+dp2[i])%mod;
        rep(j,k){
            if(i+l[j]<=n)dp2[i+l[j]]=(dp2[i+l[j]]+dp[i])%mod;
            if(i+r[j]+1<=n)dp2[i+r[j]+1]=(dp2[i+r[j]+1]-dp[i])%mod;
        }
    }
    ll ans=dp[n];
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 6424
#include <iostream>

using namespace std;

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

  int coin = 0;
  for (int i = 0; i < 2; i++) {
    if (a > b) {
      coin += a;
      a--;
    } else {
      coin += b;
      b--;
    }
  }
  
  cout << coin << endl;
  
  return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int p[n + 1] = {};
    rep(i, n) cin >> p[i];

    int dp[n];
    fill(dp, dp + n, INF);
    dp[0] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, 0));
    while(!q.empty()) {
        P pp = q.top(); q.pop();

        dp[pp.se] = pp.fi;
        if (pp.se == n - 1) break;

        repl(i, 1, 7) {
            int next = pp.se + i;
            if (next >= n) next = n - 1;
            while(p[next] != 0 && p[next] != INF) {
                int tmp = p[next];
                p[next] = INF;
                next += tmp;
            }
            if (p[next] != INF) {
                q.push(P(dp[pp.se] + 1, next));
                p[next] = INF;
            }
        }
    }
    cout << dp[n - 1] << endl;

    return 0;
}

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

int main(){
  int n; cin>>n;
  int s=0,v=0;
  for(int i=0;i<n;i++){
    
    int c; cin>>c;
    s += c;
    v = max(v,c);
  }
  
  cout<<s-v/2<<endl;
  return 0;
}
    
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
            int N, M;
            double sum = 0;
            cin >> N >> M;
     
            vector<int> a(N);
            for(int i =0;i<N;++i){
                    cin >> a[i];
                    sum += a[i];
            }
            double b = sum /(4*M);
            int c = 0;
            for(int i =0;i<N;++i){
                    if(a[i] >= b){
                            c += 1;
                    }
            }
            if(c >= M){  
                  cout << "Yes" << endl;
            }else{
                  cout << "No" << endl;
            }
     
    
        return 0;
    }
                            

Measured memory_bytes: 256
/**
 *    author:  FromDihPout
 *    created: 2020-09-19
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n, x, m;
    cin >> n >> x >> m;
    
    vector<int> seen(m);
    long long sum = 0, move = 1;
    while (move <= n && seen[x] == 0) {
        sum += x;
        seen[x] = move;
        x *= x;
        x %= m;
        move++;
    }
    if (move == n) {
        cout << sum << '\n';
        return 0;
    }
    
    long long cycle_len = move - seen[x], rem = n - move + 1;
    long long extra_sum = 0, cycle_sum = 0;
    for (int i = 0; i < cycle_len; i++) {
        if (i < rem % cycle_len) {
            extra_sum += x;
        }
        cycle_sum += x;
        x *= x;
        x %= m;
    }
    
    sum += (rem / cycle_len) * cycle_sum + extra_sum;
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 3772
<?php
fscanf(STDIN,'%d',$N);
$X=explode(" ",trim(fgets(STDIN)));
$B=[];
$Y=$X;
sort($Y);
$center1=$Y[$N/2-1];
$center2=$Y[$N/2];
for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  if($X[$i]>$center2){
    $B[$i]=$center1;
  }elseif($X[$i]<$center1){
    $B[$i]=$center2;
  }elseif($X[$i]==$center2){
    $B[$i]=$center1;
  }elseif($X[$i]==$center1){
    $B[$i]=$center2;
  }else{
    $B[$i]=0;
  }
}

for ($i=0; $i <=$N-1 ; $i++) {
  // code...
  echo $B[$i];
  echo "\n";
}

 ?>


Measured memory_bytes: 78932
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
struct unionfind{
	vector<int> par,ran;
	unionfind(int n):par(n),ran(n,0){
		for(int i=0;i<n;i++){
			par[i]=i;
		}
	}
	int find(int x){
		return (x==par[x]?x:par[x]=find(par[x]));
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x!=y){
			if(ran[x]<ran[y]){
				par[x]=y;
			}else{
				par[y]=x;
				if(ran[x]==ran[y]){
					ran[x]++;
				}
			}
		}
	}
};
int memo[100000];
vector<int> out[100000];
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	unionfind nii(n);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		nii.unite(a,b);
		out[a].push_back(b);
		out[b].push_back(a);
	}
	for(int i=0;i<k;i++){
		int c,d;
		cin>>c>>d;
		c--;
		d--;
		out[c].push_back(d);
		out[d].push_back(c);
	}
	vector<pair<int,int> > f;
	set<int> hoge;
	for(int i=0;i<n;i++){
		hoge.insert(nii.find(i));
		f.push_back(make_pair(nii.find(i),i));
	}
	sort(f.begin(),f.end());
	int id=0;
	int cnt=0;
	vector<int> mii[hoge.size()];
	while(id<n){
		mii[cnt].push_back(f[id].second);
		memo[f[id].second]=cnt;
		while(id+1<n&&f[id].first==f[id+1].first){
			id++;
			mii[cnt].push_back(f[id].second);
			memo[f[id].second]=cnt;
		}
		cnt++;
		id++;
	}
	for(int i=0;i<n;i++){
		int ans=mii[memo[i]].size()-1;
		for(int j=0;j<out[i].size();j++){
			if(nii.same(i,out[i][j])){
				ans--;
			}
		}
		cout<<ans;
		if(i!=n-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 17396
import java.util.Arrays;
import java.util.Scanner;

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

        final int N = sc.nextInt();

        final int[] X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = Integer.parseInt(sc.next());
        }

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < 100; i++) {
            double total = 0;
            for (int j = 0; j < N; j++) {
                total += Math.pow(X[j] - (i+1), 2);
            }
            ans = Math.min(ans, (int)total);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <bitset>

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const llint inf = 1 << 29;

int main(void) {
	int n, m;
	cin >> n >> m;

	if (1 <= n && n <= 9 && 1 <= m && m <= 9) cout << n * m << endl;
	else cout << -1 << endl;

}



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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

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

int main(){
	char DIR[]="ENWS";
	int DIRR[128]; rep(k,4) DIRR[DIR[k]]=k;

	int h,w;
	for(ll l;scanf("%d%d%lld",&h,&w,&l),h;){
		static char B[100][101];
		int x,y,dir;
		rep(i,h){
			scanf("%s",B[i]);
			rep(j,w) if(isalpha(B[i][j])) x=j, y=i, dir=DIRR[B[i][j]];
		}

		int T[100][100][4];
		rep(i,h) rep(j,w) rep(k,4) T[i][j][k]=-1;

		ll t=0;
		while(l>0){
			// ツ偲シツ甘コツつェツづ敖づつつゥツづつスツづァツ暗ェツ気ツづ可進ツづ淞づゥ
			if(~T[y][x][dir]){
				ll dif=t-T[y][x][dir];
				t+=(l-1)/dif*dif;
				l-=(l-1)/dif*dif;
			}
			T[y][x][dir]=t;

			int xx=x+dx[dir],yy=y+dy[dir];
			// ツ陳シツ進
			if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]!='#'){
				t++;
				l--;
				x=xx;
				y=yy;
			}
			// ツ陛サツ古シツ転ツ環キ
			else{
				dir=(dir+3)%4;
			}
		}

		printf("%d %d %c\n",y+1,x+1,DIR[dir]);
	}

	return 0;
}

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

int gcd(int a, int b) {
    return b ? gcd(b, a%b) : a;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> l(n), r(n);
    l[0] = a[0];
    rep(i, n-1) l[i+1] = gcd(a[i+1], l[i]);
    r[n-1] = a[n-1];
    for (int i=n-1; i > 0; i--) r[i-1] = gcd(a[i-1], r[i]);
    int ans = 0;
    rep(i, n) {
        if (i==0) ans = max(ans, r[1]);
        else if (i==n-1) ans = max(ans, l[n-2]);
        else ans = max(ans, gcd(l[i-1], r[i+1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int a, b;
   cin >> a >> b;
   cout << (b - a)*(b-a+1)/2 - b << endl;


   return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int>vec(n);
  vector<int>sum(n);
  int count=0;
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  for(int i=0;i<n;){
    if(vec[i]>sum[i]){
      for(int j=i;j<n;j++){
        if(vec[j]>sum[j])
          sum[j]++;
        else
          break;
      }
      count++;
    }
    else
      i++;
  }
  cout<<count<<endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N; cin >> N;
  vi32 p(N); cin >> p;

  int ans = 0;
  rep(i, N) {
    if (i + 1 == p[i]) {
      if (i + 2 <= N) swap(p[i], p[i + 1]);
      ans++, i++;
    }
  }
  cout << ans << '\n';
}


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

int main() {
  int X, N;
  cin >> X >> N;
  set<int> data;
  for(int i = 0; i < N; i++) {
    int a;
    cin >> a;
    data.insert(a);
  }
  for(int i = 0; i < 51; i++) {
    if(!data.count(X - i)) {
      cout << X - i << endl;
      break;
    }
    else if(!data.count(X + i)) {
      cout << X + i << endl;
      break;
    }
  }  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int A[3000];
int N;
signed main() {
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];
    int ans=0;
    for(int i=0;i<N;i++)ans+=A[i]-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())
ta = 2*math.pi * (M/60.0)
tb = 2*math.pi * (H/12.0 + M/720.0)
print((A**2.0+B**2.0-2.0*A*B*math.cos(ta-tb))**0.5)

Measured memory_bytes: 62548
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  ll N;	cin>>N;
  vector<ll> A(5);
  REP(i,5) cin>>A[i];
  sort(A.begin(), A.end());
  ll ans = (N+A[0]-1LL)/A[0];
  ans += 4LL;
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int n; cin >> n;
	vector<int> room(4*3*10);

	int b, f, r, v;
	while(n-- && cin >> b >> f >> r >> v)
		room[30*--b + 10*--f + --r] += v;
	
	n = 1;
	for(const auto x : room) {
		cout << ' ' << x;
		if(n%10 == 0) cout << '\n';
		if(n%30 == 0 && n != 120) cout << "####################\n";
		++n;
	}

	return 0;
}



Measured memory_bytes: 3080
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>

using namespace std;

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b&&a==c) printf("No\n");
	else if(a==b||a==c||b==c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
Sn = [input() for _ in range(N)]

from collections import Counter
c = Counter()
for S in Sn:
    c[S[0]] += 1

t = 0
d = ['M','A','R','C','H']
from itertools import combinations
for combi in combinations(d, 3):
    v = 1
    for k in combi:
        v *= c[k]
    t += v
print(t)

Measured memory_bytes: 10008
#include<bits/stdc++.h>
#define re    return
#define pii   pair<int,int>
#define hell  1000000007
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define boost ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb  push_back
#define ff          first
#define ss          second
#define sz(x)       (int)x.size()
#define all(a)      (a).begin(),(a).end()

//v.resize(distance(v.begin(),unique(v.begin(),v.end())));

typedef long long  ll;
using namespace std;

const ll INF=(1LL<<60)-1;
const int nax=2e5+20;

int main(){

    boost;
    
	string s; cin >> s;
	int k; cin >> k;
	
	int n = s.size();
	
	vector<string> ans;
	
	rep(i,0,n){
	//	int len = min(k,n-i);
		string t;
		rep(j,0,k){
			if(i+j < n){
			 t.pb(s[i+j]);
			 ans.pb(t);
		    }   
		}
	}	
	
	sort(all(ans));
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	
	cout << ans[k-1];
	cout << endl;
	
   	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ---------------------------------------------------------------------------

struct edge {
    int to,id;
    edge(int to,int id) : to(to),id(id) {}
};

vector<edge> G[55];

vector<int> es;
bool dfs(int v,int tv,int p=-1){
    if(v == tv){
        es = vector<int>();
        return true;
    }
    for(auto e: G[v]){
        if(e.to == p) continue;
        if(dfs(e.to,tv,v)){
            es.push_back(e.id);
            return true;
        }
    }
    return false;
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].emplace_back(b,i);
        G[b].emplace_back(a,i);
    }
    int M;
    cin >> M;
    vector<ll> eset(M,0);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        dfs(a,b);
        for(auto e: es) eset[i] |= 1LL<<e;
    }
    ll ans = 0;
    for(int bit=0; bit<(1LL<<M); bit++){
        ll mask = 0;
        for(int i=0; i<M; i++){
            if(bit & (1LL<<i)) mask |= eset[i];
        }
        int white = __builtin_popcountll(mask);
        ll now = 1LL<<(N-1-white);
        if(__builtin_popcountll(bit)%2) ans -= now;
        else ans += now;
    }
    cout << ans << enld;
    return 0;
}

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

int main() {
  char c;
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u'||
    c == 'e' || c == 'o') 
    cout << "vowel" << endl;
  else 
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main() {
  	ll N, K;
  	cin >> N >> K; 
  	
  	ll d[K], A[N];
  
  	for(ll i=0; i<N; i++){
		A[i]=0;
    }
  
  	ll a;
  	for(ll i=0; i<K; i++){
    	cin >> d[i];
     	for(ll j=0; j<d[i]; j++){
          	cin >> a;
          	A[a-1]+=1;
          	//cout << A[a-1] << endl;
        }
    }
  	ll num=0;
  	for(ll i=0; i<N; i++){
      	//cout << A[i] << endl;
      	if(A[i]==0){
          	num++;
        }
    }
  	
	cout << num << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<ll> A(n);
    rep(i, n) A[i] = a[i] - (i + 1);
    sort(all(A));
    
    vector<ll> mid;
    mid.push_back(A[A.size() / 2]);

    ll mi = 1e18;
    rep (j, mid.size()) {
        ll score = 0;
        rep(i, n) score += abs(A[i] - mid[j]);
        mi = min(mi, score);
    }


    put(mi);

    return 0;
}

Measured memory_bytes: 6432
n,m=map(int,input().split())
if n==m:
    temp=1
    for i in range(1,n+1):
      temp=(temp*i)%(10**9+7)
    print((2*((temp*temp)%(10**9+7)))%(10**9+7))
elif abs(n-m)==1:
    temp1=1
    temp2=1
    for i in range(1,n+1):
        temp1=(temp1*(i%(10**9+7)))%(10**9+7)
    for j in range(1,m+1):
        temp2=(temp2*(j%(10**9+7)))%(10**9+7)
    print((temp1*temp2)%(10**9+7))
else:
    print(0)

Measured memory_bytes: 9048
#include<stdio.h>
#include<math.h>
int main(){
int a,b,z;
char op;

while(1){
scanf("%d %c %d",&a,&op,&b);

if(op=='+'){
  z=a+b;
}
if(op=='-'){
  z=a-b;
}
if(op=='*'){
  z=a*b;
}
if(op=='/'){
  z=a/b;
}
if(op=='?')break;
printf("%d\n",z);
}

}

Measured memory_bytes: 1796
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
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;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int a=in();
    cout<<a*800-a/15*200;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b;
    cin >> a >> b;
    if (a >= 13)
    {
        cout << b;
    }
    else if (a >= 6)
    {
        cout << b / 2;
    }
    else
    {
        cout << 0;
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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 main(){
    int k;cin>>k;
    if(k==7||k==1){cout<<1<<endl;return 0;}
    int cnt=1;
    int m=7%k;
    m=10*m+7;
    m%=k;
    while(cnt<1e7){
        cnt++;
        if(m==0){
            cout<<cnt<<endl;
            return 0;
        }
        m=10*m+7;
        m%=k;
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 3604
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 
#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppi                      pair <int , pii>               
#define    sp(x)                    setprecision(x)

int32_t main()
{
    speed upp
    string s;
    cin>>s;
    int n=sz(s)+1,c=0,ans=0;
    int a[n+2];
    f(i,0,n)
        a[i]=0;
    f(i,0,n-2)
    {
        if(s[i]=='<')
        {
            c++;
            a[i+1]=c;
        }
        else
            c=0;
    }
    c=0;
    r(i,n-2,0)
    {
        if(s[i]=='>')
        {
            c++;
            a[i]=max(a[i],c);
        }
        else
            c=0;
    }
    f(i,0,n-1)
        ans+=a[i];
    cout<<ans;
}

Measured memory_bytes: 4764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

bool loop(LL *a, int n, int k) {
	if (n % k != 0) {
		return false;
	}
	for (int i = 0; i < k; ++i) {
		LL b = a[i];
		for (int j = 0; j < (n / k); ++j) {
			if (a[j * k + i] != b) {
				return false;
			}
		}
	}
	return true;
}

int kmp(vector<LL> &S, vector<LL> &T) {
	int n = T.size();
	int *next = new int[n + 1];

	next[0] = -1;
	for (int i = 0; i < n - 1; ++i) {
		int p = next[i];
		while (p >= 0 && T[p] != T[i]) {
			p = next[p];
		}
		next[i + 1] = p + 1;
	}
	/*for (int i = 0; i < n; ++i) {
		cout << next[i] << ' ';
	}
	cout << endl;
	return false;*/

	int p = 0, q = 0;
	while (p < S.size()) {
		if (q == T.size()) {
			return (p - q) % n;
		}
		if ((q == -1) || (S[p] == T[q])) {
			++p; ++q;
		}
		else {
			q = next[q];
		}
	}
	return -1;

}

int main() {
	int n;
	LL *a, *b;
	LL *xa, *xb;
	cin >> n;
	a = new LL[n];
	b = new LL[n];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}

	xa = new LL[n];
	xb = new LL[n];
	for (int i = 0; i < n; ++i) {
		xa[i] = a[i] ^ a[(i + 1) % n];
		xb[i] = b[i] ^ b[(i + 1) % n];
	}
	/*for (int i = 0; i < n; ++i) {
		cout << xa[i] << ' ';
	}
	cout << endl;*/

	/*for (int i = 0; i < n; ++i) {
		cout << xb[i] << ' ';
	}
	cout << endl;*/
	int la = n, lb = n;
	for (int i = 1; i * i <= n; ++i) {
		if (n % i != 0) {
			continue;
		}
		if (loop(xa, n, i)) {
			la = min(la, i);
		}
		if (loop(xa, n, n / i)) {
			la = min(la, n / i);
		}

		if (loop(xb, n, i)) {
			lb = min(lb, i);
		}
		if (loop(xa, n, n / i)) {
			lb = min(lb, n / i);
		}
	}
	if (la != lb) {
		return 0;
	}

	vector<int> ks;

	vector<LL> S, T;
	for (int i = 0; i < la; ++i) {
		S.push_back(xa[i]);
		T.push_back(xb[i]);
	}
	for (int i = 0; i < la; ++i) {
		S.push_back(xa[i]);
	}
	int dlt = kmp(S, T);
	if (dlt != -1) {
		for (int i = dlt; i < n; i += la) {
			ks.push_back(i);
		}
	}

	sort(ks.begin(), ks.end());
	for (int i = 0; i < ks.size(); ++i) {
		cout << ks[i] << ' ' << (b[0] ^ a[ks[i]]) << endl;
	}
	return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int BUCKET = 400,SIZE = 300;
int N,Q;
bool updateFlag [BUCKET];
ll lazyUpdate [BUCKET];
ll A [100000];
const ll INF = (1ll << 31) - 1;

void update(int l,int r,ll val)
{
	FOR(i,0,BUCKET){
		int bucketL = i * SIZE,bucketR = (i + 1) * SIZE;
		if(r <= bucketL || bucketR <= l) continue;
		if(l <= bucketL && bucketR <= r){
			lazyUpdate [i] = val;
			updateFlag [i] = true;
			continue;
		}
		if(updateFlag [i]){
			FOR(j,bucketL,bucketR){
				A [j] = lazyUpdate [i];
			}
			updateFlag [i] = false;
		}
		FOR(j,bucketL,bucketR){
			if(l <= j && j < r){
				A [j] = val;
			}
		}
	}
}

ll get(int idx)
{
	if(updateFlag [idx / SIZE]){
		int bucketL = (idx / SIZE) * SIZE,bucketR = (idx / SIZE + 1) * SIZE;
		FOR(i,bucketL,bucketR){
			A [i] = lazyUpdate [idx / SIZE];
		}
		updateFlag [idx / SIZE] = false;
	}
	return A [idx];
}

int main()
{
	scanf("%d%d",&N,&Q);
	fill(A,A + N,INF);
	vector<ll> ans;
	FOR(i,0,Q){
		int com;
		scanf("%d",&com);
		if(com == 0){
			int s,t,x;
			scanf("%d%d%d",&s,&t,&x);
			update(s,t + 1,x);
		}
		else{
			int idx;
			scanf("%d",&idx);
			ans.push_back(get(idx));
		}
	}

	FOR(i,0,ans.size()){
		printf("%lld\n",ans [i]);
	}

	return 0;
}

Measured memory_bytes: 4596
import math
a,b,x=map(int,input().split())

if x>=(a*a*b)/2:
  l=2*b-(2*x)/(a*a)
  c=math.degrees(math.atan(l/a))
else:
  l=2*x/(a*b)
  c=math.degrees(math.atan(b/l))
print(c)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

int encode(vector<int> vi){
	int n = vi.size();
	vector<int> idx(8,0);
	int res = 0, cnt = 1;
	for(int i=0;i<n;i++){
		int cur = vi[(i+1)%n];
		if(cur != 0){
			if(idx[cur]==0) idx[cur] = cnt++;
			cur = idx[cur];
		}
		res = 8*res + cur;
	}
	return res;
}

int main(){
	int H, W;
	string s[11];
	while(cin >> H >> W){
		for(int i=0;i<H;i++) cin >> s[i];
		map< int, int > mp[2];
		mp[0][0] = 0;
		int cur = 0, next = 1;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				for(map<int,int>::iterator it=mp[cur].begin();it!=mp[cur].end();it++){
					int val = it->first;
					bool space = (s[i][j]!='#'), wall = (s[i][j]!='.');
					vector<int> state(W);
					for(int k=W-1;k>=0;val/=8) state[k--] = val%8;
					if((i!=0&&state[0]==0)||(j!=0&&state[W-1]==0)) space = false;

					if(W!=1){
						bool flg = state[0]!=0;
						for(int k=1;k<W;k++)
							if(state[0]!=0 && state[0]==state[k]) flg = false;
						if(flg) space = false;
					}

					if(W==1){
						if(i!=0&&state[0]==0&&it->second > 0) wall = false;
					}

					if(i!=0&&j!=0&&state[0]!=0&&state[0]==state[W-1]) wall = false;

					if(space){
						int t = state[0];
						state[0] = 0;
						int tmp = encode(state);
						if(!mp[next].count(tmp)) mp[next][tmp] = it->second;
						else                     mp[next][tmp] = max(mp[next][tmp], it->second);
						state[0] = t;
					}
					if(wall){
						if(j!=0&&state[W-1]!=0&&i!=0&&state[0]!=0){
							for(int k=1;k<W;k++) if(state[k]==state[W-1]) state[k] = state[0];
						}
						else if(j!=0&&state[W-1]!=0) state[0] = state[W-1];
						else if(i==0||state[0]==0) state[0] = 7;
						int tmp = encode(state);
						if(!mp[next].count(tmp)) mp[next][tmp] = it->second+1;
						else                     mp[next][tmp] = max(mp[next][tmp], it->second+1);
					}
				}
				mp[cur].clear();
				swap(cur, next);
			}
		}
		int res = -1;
		for(map<int,int>::iterator it=mp[cur].begin();it!=mp[cur].end();it++){
			bool ok = true;
			for(int i=0;i<W;i++)
				if(((it->first>>(3*i))%8) > 1) ok = false;
			if(ok) res = max(res, it->second);
		}
		cout << res << endl;
	}
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

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

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    ll ans = K;
    REP(i, N-1){
        ans *= (K-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3508