akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    int n; cin>>n;
    map<ll,ll> mp;
    rep(i,0,n){
        ll x; cin>>x;
        mp[x]++;
    }
    vector<ll> box;
    for(auto &i:mp){
        if(i.second>=4){
            box.push_back(i.first);
            box.push_back(i.first);
        }else if(i.second>=2){
            box.push_back(i.first);
        }
    }
    if(box.size()==0){
        cout<<0<<endl;
        return 0;
    }
    sort(all(box));
    reverse(all(box));
    cout<<box[0]*box[1]<<endl;
}

Measured memory_bytes: 6528
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1 , input().split()))
b = [0]
z = [-1] * n
idx = 1
z[0] = idx
aloop = True
c = 0
while True:
    c = a[c]
    if z[c] > -1:
        break
    b.append(c)
    idx += 1
    z[c] = idx

#print(b, z, idx, z[c])
# 周期
ll = idx - z[c] + 1
# 切片
dd = z[c] - 1
if k < dd:
    print(b[k]+1)
    exit()
#print(ll, dd)
#print('-', (k - dd) % ll, (k - dd) % ll + dd)
print(b[(k - dd) % ll + dd]+1)

#print(b[k % ll]+1)


Measured memory_bytes: 32376
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-8;

bool is_prime[30001];

int main(){
  int side_sum;

  memset(is_prime,true,sizeof(is_prime));
  is_prime[0] = false;
  is_prime[1] = false;
  vector<int> prime;
  for(int i=0;i<=30000;i++){
    if(!is_prime[i]) continue;
    prime.push_back(i);
    for(int j=i+i;j<=30000;j+=i){
      is_prime[j] = false;
    }
  }

  while(~scanf("%d",&side_sum)){
    if(side_sum == 0) break;
    int res = 0;
    map<vector<int>,bool> visited;

    for(int prime_i = 0; prime_i < prime.size(); prime_i++){

      int center_side = prime[prime_i];
      if(2 * center_side >= side_sum) break;

      int remainings = side_sum - center_side;
      if(remainings <= 0) break;
      
      for(int prime_j = 0; prime_j < prime.size(); prime_j++){
        int left_side = prime[prime_j];
        int right_side = remainings - left_side;

        if(right_side <= 0) continue;
        if(!is_prime[right_side]) continue;
        if(left_side > right_side) break;

        vector<int> used;
        used.push_back(center_side);
        used.push_back(left_side);
        used.push_back(right_side);
        sort(used.begin(),used.end());
        if(used[0] + used[1] <= used[2]) continue;

        if(visited.find(used) != visited.end()) continue;

        visited[used] = true;
        res++;
      }
    }
    printf("%d\n",res);
  }
}

Measured memory_bytes: 7560
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
L,R = parseMap(split(readline()))
if R-L >= 2019
    println(0)
else
    best_ans = 2019^2 + 1
    for i in L:R 
        for j in i+1:R
            ans =  i*j % 2019
            ans < best_ans && (best_ans = ans)
            best_ans == 0 && break
        end
    end
    println(best_ans)
end         
                

Measured memory_bytes: 116404
s = input()

final = ""
length = len(s)
for i in range(length):
    if s[i] == "0":
        final = final + "0"
    elif s[i] == "1":
        final = final + "1"
    else:
        if len(final)!=0:
            last = len(final)
            final = final[0:last-1]
print(final)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
	int n, ac = 0, tle = 0, wa = 0, re = 0;
	char str[100] = {0};
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> str;
		if(str[0] == 'A'){
			ac++;
		}else if(str[0] == 'T'){
			tle++;
		}else if(str[0] == 'W'){
			wa++;
		}else{
			re++;
		}
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

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

int main(){
int n;
string str;
cin >> n >> str;
int f=0,b=n-1,count=0;
while(f<b){
    if(str.at(f) == 'R'){
        f++;
    }else{
        if(str.at(b) == 'R'){
            swap(str.at(f),str.at(b));
            count++;
            b--;
        }else{
            b--;
        }
    }
    /*for(int i=0;i<n;i++){
        cout << str.at(i) << " ";
    }
    cout << endl;*/
    
}
cout << count << endl;
}


Measured memory_bytes: 3720
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<int, int> P;
#define fs first
#define sc second

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

    int ans[N] = {};

    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) {
            int d = j - i;
            d = min(d, abs(x - i) + 1 + abs(y - j));
            ans[d]++;
            //cout << i << j << d << endl;
        }
    }

    for(int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(){
    int n;
    int a;
    int max = 0;
    int min = 1000000000;

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if( a >= max){
            max = a;
        }
        if( a <= min){
            min = a;
        }
    }

    cout << max - min << endl;
}

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

int n,t;
int x,y;

int main()
{
   scanf("%d%d",&n,&t);
   int ans = 100000;
   for(int i=1;i<=n;i++)
   {
      scanf("%d%d",&x,&y);
      if(y<=t) ans = min(ans,x);
   }
   if(ans>1000) printf("TLE\n");
   else printf("%d\n",ans);
 	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <vector>

#define ll long long

using namespace std;

ll facctorial(int k) {
  std::vector<int> v(k);
  std::iota(v.begin(), v.end(), 1);
  return std::accumulate(v.begin(), v.end(), 1LL,
                         [](ll acc, ll i) { return acc * i; });
}

/**
 * 順列組み合わせの個数計算
 * n! / (p! * q! * r! ...)
 */
ll count_permutation(const std::vector<char> &str) {
  std::map<char, int> m;
  for (const char c : str) {
    m[c]++;
  }

  const ll fraction = std::accumulate(m.begin(), m.end(), 1LL,
                                      [](ll acc, std::pair<char, int> p) {
                                        return acc * facctorial(p.second);
                                      });

  return facctorial(str.size()) / fraction;
}

int main() {
  int p;
  int q;
  int r;

  cin >> p >> q >> r;

  vector<int> vec;
  vec.push_back(p);
  vec.push_back(q);
  vec.push_back(r);

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

  cout << vec[0] + vec[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

int main(){
	int n;
	scanf("%d", &n);
	char str[205];
	scanf("%s", str);
	int count=0;
	if(n%2 == 1){
		printf("No");
	}
	else{
		int wa = n/2;
		for(int i=0; i<wa; i++){
			if(str[i] == str[i+wa]) count++;
		}
		if(count == wa) printf("Yes");
		else printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);
    if(x>=y&&y>=z)
    {
        printf("%d",x-z);
    }
    else if(x>=z&&z>=y)
    {
        printf("%d",x-y);
    }
    else if(y>=z&&z>=x)
    {
        printf("%d",y-x);
    }
    else if(y>=x&&x>=z)
    {
        printf("%d",y-z);
    }
    else if(z>=y&&y>=x)
    {
        printf("%d",z-x);
    }
    else if(z>=x&&x>=y)
    {
        printf("%d",z-y);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+3,oo=0x3f3f3f3f,mod=1e9+7;

string a,b;
int mem[N][N],sz,sza,szb;

int lcs(int i, int j){
    if(i>=sza||j>=szb) return 0;
    if(mem[i][j]!=-1)return mem[i][j];
    if(a[i]==b[j])return mem[i][j]=lcs(i+1,j+1)+1;
    return mem[i][j]=max(lcs(i+1,j),lcs(i,j+1));
}

void trace(int i,int j){
    if(i>=sza||j>=szb) return;
    int op1=lcs(i+1,j);
    int op2=lcs(i,j+1);
    int op3=a[i]==b[j]?lcs(i+1,j+1)+1:0;
    if(op3>op1&&op3>op2){
        cout << a[i];
        trace(i+1,j+1);
    }
    else if(op1>op2)trace(i+1,j);
    else trace(i,j+1);

}

int main(){
    cin >> a >> b;
    sza=a.size();szb=b.size();
    memset(mem,-1,sizeof mem);
    int ans=lcs(0,0);
    trace(0,0);
    return 0;
}

Measured memory_bytes: 35968
#include<stdio.h>

int main(void){
    int x, y;

    scanf("%d%d", &x, &y);  
    if((y <= 4*x && y >= 2*x)&&(y%2 == 0)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int n,m;
string s;

int main(){
	while(cin>>n){
		if(!n)return 0;
		cin>>m>>s;
		int a=0,b=0;
		for(int i=0;i<m;i++){
			if(s[i]=='I'&&b%2==0||s[i]=='O'&&b%2==1)b++;
			else{
				if(s[i]=='I')b=1;
				else b=0;
			}
			if(b%2==1&&b>=2*n+1)a++;
		}
		cout<<a<<endl;
	}
}

Measured memory_bytes: 1952
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod =  1000000007;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (int i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll ans = 0;
  REP(i, s.size()) {
    if(s[i] == '0' + (i%2 ? 1: 0)) ans++;
  }
  ll ans1 = 0;
  REP(i, s.size()) {
    if(s[i] == '0' + (i%2 ? 0: 1)) ans1++;
  }
  cout << min(ans, ans1) << endl;
}


Measured memory_bytes: 512
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    n <- getInt
    s <- getLine
    let nr = length $ filter (== 'R') s
        ng = length $ filter (== 'G') s
        nb = length $ filter (== 'B') s
        rgball = nr * ng * nb
        vs = V.fromList s
        rgb' = length [()| a <- [0..n-1], i <- [1..n], a+2*i <= n-1, check vs a (a+i) (a+2*i)]
    print $ rgball - rgb'

check vs a b c | va /= vb && vb /= vc && vc /= va = True
               | otherwise = False
    where va = vs V.! a
          vb = vs V.! b
          vc = vs V.! c

Measured memory_bytes: 4664
#include <iostream>

using namespace std;

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

int main()
{
  long a, b;
  cin >> a >> b;
  
  long g = gcd(a, b);
  long ans = 1;
  if (g % 2 == 0)
    ++ans;
  while (g % 2 == 0)
    g /= 2;
  for (long i = 3; i * i <= g; i += 2) {
    if (g % i == 0)
      ++ans;
    while (g % i == 0)
      g /= i;
  }
  if (g >= 3)
    ++ans;
  
  cout << ans;
}


Measured memory_bytes: 256
h,n= map(int, input().split())
a= [list(map(int, input().split())) for i in range(n)]

dp=[float('inf')]*(h+1)
dp[0]=0
for i in range(n):
    x=a[i][0]
    y=a[i][1]
    for j in range(h+1):
        if j>=x:
            dp[j]=min(dp[j-x]+y,dp[j])
        else:
            dp[j]=min(y,dp[j])

print(dp[-1])

Measured memory_bytes: 48860
#include<stdio.h>
int main(void)
{
	int m=0, f=0, r=0;
	while (m != -1 || f != -1 || r != -1)
	{
		scanf("%d %d %d", &m, &f, &r);
		if (m == -1 && f == -1 && r == -1)break;

		if (m ==-1||f==-1){
			printf("F\n");
		}
		else if (m + f >= 80){
			printf("A\n");
		}
		else if (m + f >= 65){
			printf("B\n");
		}
		else if (m + f >= 50){
			printf("C\n");
		}
		else if (m + f >= 30 && r >= 50){
			printf("C\n");
		}
		else if (m + f >= 30){
			printf("D\n");
		}
		else if (m + f < 30){
			printf("F\n");
		}
	}
	return 0;
}


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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define v vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    int h1, h2,m1,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int time1 = h1*60+m1, time2 = h2*60+m2;
    if(time2-time1-k > 0) cout << time2-time1-k << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3636
w, h, n = (int(x) for x in input().split())

squre_1 = 0
squre_2 = w
squre_3 = 0
squre_4 = h

for i in range(n):
    x, y, a = (int(x) for x in input().split())
    if a == 1 and squre_1 <= x:
        squre_1 = x
    elif a == 2 and squre_2 >= x:
        squre_2 = x
    elif a == 3 and squre_3 <= y:
        squre_3 = y
    elif a == 4 and squre_4 >= y:
        squre_4 = y

if squre_2 > squre_1 and squre_4 > squre_3:
    ans = (squre_2 - squre_1) * (squre_4 - squre_3)
    print(ans)
else:
    print('0')

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]){
  int a,b,c;
  cin >> a >> b >> c;
  if( (a==5 && b==5 && c==7) || (a==5 && b== 7 && c==5) || (a==7 && b==5 && c==5) ){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.weight = [0] * (n+1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def unite(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def is_same_group(self, x, y):
        return self.find(x) == self.find(y)
    
    def find_root(self,x):
        return self.find(x)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
    
f=lambda:map(int,input().split())
N,M=f()
wuf=WeightedUnionFind(N+1)

flg=True
for _ in [0]*M:
    l,r,w=f()
    if wuf.is_same_group(l,r):
        if wuf.diff(l,r)!=w:
            flg=False
    else:
        wuf.unite(l,r,w)
    if not flg:
        break
print(['No','Yes'][flg])

Measured memory_bytes: 82432
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
//#include <intrin.h>
//#include <chrono>
//#include <random>
//#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
	ll n;
	cin >> n;
	string res;
	while (n) {
		ll ost = n % 26;
		if (ost == 0)
			n--;
		ost = (ost + 25) % 26;
		res += 'a' + ost;
		n /= 26;
	}
	reverse(res.begin(), res.end());
	cout << res;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
    using namespace std;
    typedef unsigned long long ull;
    typedef long long ll;
    typedef long double ld;
    #define FOR(type,a,b,c,d) for(type i = a;i b c;i += d)
    #define QUICK ios_base::sync_with_stdio(0);cout << fixed;
    #define MOD 1000000007

    string upper(string);
    string lower(string);
    bool isalup(string);
    bool isalow(string);

    int main(){

    int a(7);
    int c,d = 1;
    cin >> c;
    if(c%2==0||c%5==0)
    {
        cout << "-1";
        return 0;
    }
    while(1){
        if(a%c==0){
            cout << d;
            break;
        }
        a = (a*10+7)%c;
        d++;
    }
        return 0;
    }









                string upper(string a){
                    for(char& c:a){
                        if(islower(c))
                            c -= 32;
                       }
                    return a;
                }
                    string lower(string a){
                        for(char& c : a){
                            if(isupper(c))
                                c += 32;
                        }
                        return a;
                    }
                    bool isalup(string a){
                        for(char& c: a){
                            if(islower(c))
                                return false;
                        }
                        return true;
                    }
                    bool isalow(string a){
                        for(char& c:a){
                            if(isupper(c))
                                return false;
                        }
                       return true;
                    }


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

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

void Main() {
  Cin(int, n, t);
  Cins(int, n, vt);

  int ans = 0;
  rep(i, n - 1) ans += min(t, vt[i + 1] - vt[i]);
  ans += t;

  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

        int a = in.nextInt();
        int b = in.nextInt();

        if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        } else {
            System.out.println("a > b");
        }

        System.exit(0);
    }
}



Measured memory_bytes: 26392
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<cstdlib> 
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a%10==9||a/10==9){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
pub fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x.abs()
    } else {
        gcd(y, x % y)
    }
}

fn solve() {
    input! {
        s: String,
    }
    if s=="A" {
        println!("T");
    }
    if s=="T" {
        println!("A");
    }
    if s=="C" {
        println!("G");
    }
    if s=="G" {
        println!("C");
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        a:[usize;n],
    }
    let mut c_map = HashMap::<usize, usize>::with_capacity(n);
    for ai in a.iter() {
        let mut c = *c_map.get(ai).unwrap_or(&0);
        c += 1;
        c_map.insert(*ai, c);
    }
    let mut sum = 0;
    for (_, &v) in c_map.iter() {
        sum += c_2(v);
    }
    let mut answers = String::with_capacity(n * 2);
    for ai in a.iter() {
        let c = c_map[ai];
        let b = c_2(c);
        let c = c_2(c - 1);
        let ans = sum - (b - c);
        answers.push_str(&format!("{}\n", ans));
    }
    answers
}

fn c_2(v: usize) -> usize {
    if v > 1 {
        (v * (v - 1)) / 2
    } else {
        0
    }
}
test! {
    include_str!("d1_in.txt") => include_str!("d1_out.txt"),
    include_str!("d2_in.txt") => include_str!("d2_out.txt"),
    include_str!("d3_in.txt") => include_str!("d3_out.txt"),
    include_str!("d4_in.txt") => include_str!("d4_out.txt"),
}


Measured memory_bytes: 10620
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
LL a,b,k,num[100005],ans=MMX,st=0,ed=MOD,mid,di;
int n;
bool ch(long long p)
{
    long long cc=p;
    for(int i=1;i<=n;i++)
    {
        if(num[i]<=p*b)continue;
        cc-=((num[i]-(p*b)+di-1)/di);
    }
    //printf("%lld %lld\n",cc,p);
    if(cc<0)return false;
    else return true;
}
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%d %lld %lld",&n,&a,&b);
    //printf("%d\n",n);
    di=a-b;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
    }
    while(st<=ed)
    {
        mid=(st+ed)/2;
        if(ch(mid))ans=min(ans,mid),ed=mid-1;
        else st=mid+1;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int A, B, C, temp, ans;
    scanf("%d %d %d", &A, &B, &C);
	
	if(A >= B && A >= C){
	temp = A;
	}
	if(B >= A && B >= C){
	temp = B;
	}
	if(C >= A && C >= B){
	temp = C;
	}
	ans = A + B + C + 9 * temp;
	printf("%d", ans);
	
    return 0;
	}

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

int main() {
    int N; cin >> N;
    int ans[10010] = {};
    pair<int, int> ma = make_pair(0, 1);
    for(int i=2; i<=N; i++) {
        printf("? 1 %d\n", i);
        fflush(stdout);
        int serve; scanf("%d", &serve);
        if(ma.first < serve) ma = make_pair(serve, i);
    }

    ans[0] = ma.second;
    for(int i=1; i<=N; i++) {
        printf("? %d %d\n", ma.second, i);
        fflush(stdout);
        int serve; scanf("%d", &serve);
        ans[serve] = i;
    }

    int l = ans[0], r = ans[N-1];
    printf("!");
    for(int i=0; i<N; i++) printf(" %d", ans[i]);
    printf("\n");
    fflush(stdout);
    return 0;
}

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

int main() {
	int K;
	cin >> K;
	int a = 7;
	int count = 1;
	for(int i=0;i<K;i++){
		if(a % K == 0){
			break;
		}
		count ++;
		a = (10 * a + 7) % K;
	}
	if(count == K+1){
		cout << -1 << endl;
	}
	else{
		cout << count << endl;
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	long a,b,c,x,y;

	cin >> a >> b >> c >> x >> y;

	long g = 0,gg = 0;

	gg += (a * x) + (b * y);

	if (x <= y)
	{
		g += x * c * 2;
		g += (y - x) * b;
	}
	else if (x > y)
	{
		g += y * c * 2;
		g += (x - y) * a;
	}
	int p = 0;
	p += max(x,y) * c * 2;

	if (min(g,gg) <= p)
	{
		cout << min(g,gg) << endl;
	}
	else
	{
		cout << p << endl;
	}
}


Measured memory_bytes: 256
s=list(input())
k=int(input())
if len(s)==1:
    print(k//2)
    exit()
from collections import Counter
l=Counter(s)
if len(l)==1:
    print(k*len(s)//2)
    exit()
ans=0
f=1
for i in range(len(s)-1):
    if s[i]==s[i+1] and f:
        ans+=1
        f=0
    else:
        f=1
cou=1
for i in range(1,len(s)):
    if s[i]==s[0]:
        cou+=1
    else:
        break
if s[0]==s[-1]:
    if f==0:
        print(ans*k)
    else:
        if s[0]!=s[1]:
            print(ans*k+k-1)
        else:
            if cou%2==1:
                print(ans*k+k-1)
            else:
                print(ans*k)


else:
    print(ans*k)


Measured memory_bytes: 38384
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define C getchar()-48
inline ll read()
{
    ll s=0,r=1;
    char c=C;
    for(;c<0||c>9;c=C) if(c==-3) r=-1;
    for(;c>=0&&c<=9;c=C) s=(s<<3)+(s<<1)+c;
    return s*r;
}
#define find __builtin_popcount 
//这个函数是找一个数的2进制中有几个1 
const int N=15,M=1<<15,p=1e9+7; 
int n,m;
int g[N],dp[M],cf[M];
inline int add(int x,int y)//算两数相加模p意义下的值 
{
    return ((x+=y)>p)?x-p:x;
}
int main()
{
    n=read(),m=read();
    dp[0]=cf[0]=1;//初始状态 
    for(int i=1;i<=m;i++) cf[i]=(cf[i-1]<<1)%p;//预处理2的x次方 
    for(int i=1;i<=m;i++){int x=read()-1,y=read()-1;g[x]|=(1<<y);}//2进制存x能到达的边 
    for(int s=1,sed=1<<n;s<sed;s++) if((s&1)==(s>>1&1))//枚举s  因为1和2的点的状态相同所以直接判掉  下面同理 
    for(int u=s;u;u=u-1&s) if((u&1)==(u>>1&1))//枚举u 
    {
        int ans=1;
        for(int i=0;i<n;i++) if(s>>i&1)//枚举被选到点 
        {
            if(u>>i&1) ans=1ll*ans*cf[find(g[i]&(s^u))]%p;//假如为点集u的点 
            else ans=1ll*ans*(cf[find(g[i]&u)]-1)%p;//假如为点集t的点 
        }
        dp[s]=add(dp[s],1ll*dp[s^u]*ans%p);//转移 
    }
    cout<<(cf[m]-dp[(1<<n)-1]+p)%p;
    return 0;
}

Measured memory_bytes: 384
def nx(t,s,f):
    if t<s:
        return s
    elif (t-s)%f==0:
        return t
    else:
        return t+f-t%f
n = int(input())
C,S,F = [0]*n, [0]*n, [0]*n
for i in range(n-1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(n):
    ans = 0
    for j in range(i, n-1):
        ans = nx(ans,S[j],F[j])+C[j]
    print(ans)

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

int main(){
	string s;
	cin>>s;
	long long ans=0;
	for(int i=0;i<(1<<s.size()-1);i++){
		long long last=-1;
		long long res=0;
		for(int j=0;j<s.size();j++){
			if(i&(1<<j)){
				long long cnt=0;
				for(int k=last+1;k<=j;k++){
					cnt=cnt*10+(long long)(s[k]-'0');
				}
				res+=cnt;
				last=j;
			}
		}
		long long cnt=0;
		for(int j=last+1;j<s.size();j++){
			cnt=cnt*10+(long long)(s[j]-'0');
		}
		res+=cnt;
		ans+=res;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int d[300+5][300+5];
int t[5][300+5],s[5][300+5];//3的余数为0,1,2——>枚举所有情况求最优值
int x,y,z,ans=(int)1E9;
int n,c;
int solve(int x,int y)
{
	int ret=0;
	for(int i=1;i<=c;i++)
		ret+=t[x][i]*d[i][y];
	return ret;
}
int main()
{
	scanf("%d %d",&n,&c);
	for(int i=1;i<=c;i++)
    	for(int j=1;j<=c;j++)
			scanf("%d",&d[i][j]);//颜色i变成颜色j的代价
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&x);
			t[(i+j)%3][x]++;//余数为i,颜色为j的方格个数+1
		}
	for(int i=0;i<=2;i++)
		for(int j=1;j<=c;j++)
			s[i][j]=solve(i,j);
	for(int i=1;i<=c;i++)
		for(int j=1;j<=c;j++)
			for(int k=1;k<=c;k++)
			{
				if(i!=j&&i!=k&&j!=k)
					ans=min(ans,(s[0][i]+s[1][j]+s[2][k]));
			}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <cstdio>
using namespace std;

int main() {
	char chr;

	int D[100]={};

	while(cin>>chr){
		if (chr=='a'||chr=='A')D[0]+=1;
		if (chr=='b'||chr=='B')D[1]+=1;
		if (chr=='c'||chr=='C')D[2]+=1;
		if (chr=='d'||chr=='D')D[3]+=1;
		if (chr=='e'||chr=='E')D[4]+=1;
		if (chr=='f'||chr=='F')D[5]+=1;
		if (chr=='g'||chr=='G')D[6]+=1;
		if (chr=='h'||chr=='H')D[7]+=1;
		if (chr=='i'||chr=='I')D[8]+=1;
		if (chr=='j'||chr=='J')D[9]+=1;
		if (chr=='k'||chr=='K')D[10]+=1;
		if (chr=='l'||chr=='L')D[11]+=1;
		if (chr=='m'||chr=='M')D[12]+=1;
		if (chr=='n'||chr=='N')D[13]+=1;
		if (chr=='o'||chr=='O')D[14]+=1;
		if (chr=='p'||chr=='P')D[15]+=1;
		if (chr=='q'||chr=='Q')D[16]+=1;
		if (chr=='r'||chr=='R')D[17]+=1;
		if (chr=='s'||chr=='S')D[18]+=1;
		if (chr=='t'||chr=='T')D[19]+=1;
		if (chr=='u'||chr=='U')D[20]+=1;
		if (chr=='v'||chr=='V')D[21]+=1;
		if (chr=='w'||chr=='W')D[22]+=1;
		if (chr=='x'||chr=='X')D[23]+=1;
		if (chr=='y'||chr=='Y')D[24]+=1;
		if (chr=='z'||chr=='Z')D[25]+=1;

	}

	cout<<"a"<<" : "<<D[0]<<endl;
	cout<<"b"<<" : "<<D[1]<<endl;
	cout<<"c"<<" : "<<D[2]<<endl;
	cout<<"d"<<" : "<<D[3]<<endl;
	cout<<"e"<<" : "<<D[4]<<endl;
	cout<<"f"<<" : "<<D[5]<<endl;
	cout<<"g"<<" : "<<D[6]<<endl;
	cout<<"h"<<" : "<<D[7]<<endl;
	cout<<"i"<<" : "<<D[8]<<endl;
	cout<<"j"<<" : "<<D[9]<<endl;
	cout<<"k"<<" : "<<D[10]<<endl;
	cout<<"l"<<" : "<<D[11]<<endl;
	cout<<"m"<<" : "<<D[12]<<endl;
	cout<<"n"<<" : "<<D[13]<<endl;
	cout<<"o"<<" : "<<D[14]<<endl;
	cout<<"p"<<" : "<<D[15]<<endl;
	cout<<"q"<<" : "<<D[16]<<endl;
	cout<<"r"<<" : "<<D[17]<<endl;
	cout<<"s"<<" : "<<D[18]<<endl;
	cout<<"t"<<" : "<<D[19]<<endl;
	cout<<"u"<<" : "<<D[20]<<endl;
	cout<<"v"<<" : "<<D[21]<<endl;
	cout<<"w"<<" : "<<D[22]<<endl;
	cout<<"x"<<" : "<<D[23]<<endl;
	cout<<"y"<<" : "<<D[24]<<endl;
	cout<<"z"<<" : "<<D[25]<<endl;

	return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

import java.util.Arrays;
import java.util.ArrayList;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();
		int cnt = 0;
		for (int i = 0; i< N/R + 1; i++) {
			Inner:
			for (int j = 0; j < N/G + 1; j++) {
				if (N - (R * i + G * j) < 0) {
					break Inner;
				}
				else if ((N - (R * i + G * j)) % B == 0) {
					cnt++;
				}
			}

		}
		
		
		System.out.println(cnt);
	}
}	


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 0; i <= n;i++){
        if(i % 3 != 0 && i%5 !=0){
            ans += i;
        }
    }
    cout << ans;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int h, w; std::cin >> h >> w;
  int n; std::cin >> n;
  vi a(n); rep(i, n) std::cin >> a[i];
  vvi grid(h, vi(w));
  bool right = true;
  int now = 0;
  rep(i, h) {
    if (right) {
      rep(j, w) {
        if (a[now] == 0) now++;
        grid[i][j] = now+1;
        a[now]--;
      }
    } else {
      drep(j, w) {
        if (a[now] == 0) now++;
        grid[i][j] = now+1;
        a[now]--;
      }
    }
    right ^= 1;
  }
  rep(i, h) rep(j, w) std::cout << grid[i][j] << (j+1<w ? " " : "\n");
}


Measured memory_bytes: 384
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

int main() {
    #ifdef LOCAL_JUDGE
        freopen("../input.txt", "rt", stdin);
        freopen("../output.txt", "wt", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    for (int n; cin >> n;) {
        int sol = false;

        for (int i = 1; i < 10; i++) {
            if (n % i == 0 && n / i < 10) {
                sol = true;
                break;
            }
        }

        if (sol) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if (n % 2) cout << n / 2 << endl;
    else cout << n / 2 - 1 << endl;
    return 0;
}



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

using namespace std;

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

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << endl; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int k; read(k);
    int p = 1;
    int x = 7;
    bool vis[k+1];
    ini(vis, 0);
    while(x % k != 0) {
        x = (10LL * x + 7) % k;
        if(vis[x]) {
            println(-1);
            return;
        }
        vis[x] = true;
        p++;
    }
    println(p);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

int main()
{
	long long t=1,w=1e9;
	for(;t<=w;)
	{
		long long mid=(t+w)>>1;
		cout<<"? "<<mid<<"000000000"<<endl;
		char ch[233];
		scanf("%s",ch);
		if(ch[0]=='N')t=mid+1;else w=mid-1;
	}
	//cout<<w<<endl;
	for(;t%10ll==0ll;t/=10ll);
	bool flag=(t==1ll);
	for(;;)
	{
		t*=10ll;
		cout<<"? "<<t-1ll<<endl;
		char ch[233];
		scanf("%s",ch);
		if((ch[0]=='N')^flag)break;
	}
	cout<<"! "<<t/10ll<<endl;
	return 0;
}


Measured memory_bytes: 596
using System;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        int length = int.Parse(Console.ReadLine());
        //初期値の用意
        long sum = 0;
        int min=10000000,max=-10000000;
        int[] output = new int[length + 1];
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < length; i++)
        {
            output[i] = int.Parse(input[i]);
            min = Math.Min(min,output[i]);
            max = Math.Max(max,output[i]);
            sum = sum + output[i];
        }

        //出力
        Console.WriteLine(min + " " + max + " " + sum);
    }
}



Measured memory_bytes: 19984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<ll> a(n);
    ll s = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s ^= a[i];
    }

    ll r = 0;
    int i0 = 0;
    for (int k = 60 - 1; k >= 0; k--) {
        ll l = 1LL << k;
        if (s & l) continue;
        for (int i = i0; i < n; i++) {
            if (a[i] & l) {
                ll t = a[i];
                for (int j = i + 1; j < n; j++) {
                    if (a[j] & l) {
                        a[j] ^= t;
                    }
                }
                swap(a[i0++], a[i]);
                if (!(r & l)) r ^= t;
                break;
            }
        }
    }

    r &= ~s;
    r *= 2;
    r += s;

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
    int n, ans;
    vector<int> a;
    map<int, int> num;
    cin >> n;
    ans = 0;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        if (num[tmp] == 0)
            a.push_back(tmp);
        num[tmp]++;
        if (num[tmp] > tmp)
            ans++;
    }
    for (int i = 0; i < a.size(); i++)
    {
        if (num[a[i]] < a[i])
            ans += num[a[i]];
    }
    cout << ans << endl;
    return 0;
}

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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

int main(){
    i32 Ans=read();
    f(i,1,I,read()) Ans-=read();
    if(Ans<0) Ans=-1;
    print(Ans);
    output();
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
const int M=1e5+10;
int n,k;
long long ans=0x7fffffff,a[M];
int main(){
	scanf("%d %d",&n,&k);
	if(n==0||k==0){printf("0\n");return 0;}
	for(int i=1;i<=n;++i)
	  scanf("%lld",&a[i]);
	for(int i=1;i<=n-k+1;++i){
	  if(a[i]<=0&&a[i+k-1]<=0){
	  	ans=min(ans,abs(a[i]));
	  	continue;
	  }
	  if(a[i]>=0&&a[i+k-1]>=0){
	  	ans=min(ans,a[i+k-1]);
	  	continue;
	  }
	  if(a[i+k-1]<abs(a[i])) ans=min(ans,2*a[i+k-1]+abs(a[i]));
	  else ans=min(ans,2*abs(a[i])+a[i+k-1]);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define N 100

int A[N + 1][N + 1] = {};
int n, u, k, v;
int t = 1; //tは時間
int t1[N + 1] = {}; //発見時刻
int t2[N + 1] = {}; //終了時刻

//sは始点
void dps(int s) {
    t1[s] = t;
    for(int a = 1; a <= n; ++a) A[a][s] = 0;
    for(int i = 1; i <= n; ++i) {
        if(A[s][i] == 1) {
            ++t;
            dps(i);
        }
    }
    ++t;
    t2[s] = t;
    
}

int main(void) {
    cin >> n;
    
    for(int i = 0; i < n; ++i) {
        cin >> u >> k;
        for(int j = 0; j < k; ++j) {
            cin >> v;
            A[u][v] = 1;
        }
    }
    
    for(int i = 1; i <= n; ++i) {
        if(t2[i] == 0) {
            dps(i);
            ++t;
        }
    }
    
    for(int i = 1; i <= n; ++i) {
        cout << i << ' ' << t1[i] << ' ' << t2[i] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3100