akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<ll, pair<ll, ll>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
const ll MOD = 1e9 + 7;

//ll MOD  = 998244353;
vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};


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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll N;
vector<ll> C(200010);
vector<ll> dp(200010);



int main(void){
  cin >> N;
  rep(i, N) cin >> C[i];
  vector<ll> last(200010, -1);
  dp[0] = 1;
  for(int i = 1; i <= N; i++){
    if(last[C[i-1]] == -1 || last[C[i-1]] == i-2){
      dp[i] = dp[i-1];
    }else{
      dp[i] = dp[i-1] + dp[last[C[i-1]]+1];
      dp[i] %= MOD;
    }
    last[C[i-1]] = i-1;
  }
  cout << dp[N] << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;

#define M 1000010


int main(){
	IOS;
	tihs;

	ll n,m,x;
	cin>>n>>m>>x;
	ll c[n],a[n][m];
	rep(i,0,n){
		cin>>c[i];
		rep(j,0,m)cin>>a[i][j];
	}
	ll ans=inf;
	rep(i,0,(1ll<<n)){
		ll sum=0;
		ll cnt[m]={0};
		rep(j,0,n){
			if(i&(1ll<<j)){
				sum+=c[j];
				rep(k,0,m)cnt[k]+=a[j][k];
			}
		}
		bool ok=1;
		rep(j,0,m)if(cnt[j]<x)ok=0;
		if(ok)ans=min(ans,sum);
	}
	if(ans==inf)cout<<"-1";
	else cout<<ans;
	return 0;
}

	

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

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

int main() {
  ll A,B,C,D; cin >> A >> B >> C >> D;
  ll div = C * D;
  A--;
  ll lcm = div/gcd(C,D);
  int c = 0;
  /*
  for(int i = A; i <= B; i++) {
      if(i % C != 0 && i % D != 0) {
        cout << i << endl;
        c++;
      }
  }
  */
  //cout << c << endl;
  cout << B-(B/C+B/D-B/lcm) - (A-(A/C+A/D-A/lcm)) << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for (int i=0; i<N; i++) {
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

Measured memory_bytes: 21844
using System;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int n = int.Parse(s);

        string[] input = Console.ReadLine().Split(' ');
        int[] h = new int[n];
        for(int i = 0; i < n; i++)
        {
            h[i] = int.Parse(input[i]);
        }


        for (int i = n-1; i > 0; i--)
        {
            if (h[i - 1] > h[i] + 1) // 2つ以上大きかったら不可能
            {
                Console.WriteLine("No");
                return;
            }
            else if (h[i - 1] > h[i] ) // 1つ以上大きかったら下げる
            {
                h[i - 1]--;
            }
        }


        Console.WriteLine("Yes");

    }
}



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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }

    int ans = 0;
    rep(i, N){
        if (i%2 == 0 && A[i]%2 == 1)ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if N - 2 * i ==0:
        for j in range(M):
           now += M
    elif (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= M and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        print("No")
        exit(0)
    else:
        now += M


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

int main(){
  ll N; cin>>N;
  map<ll, ll> R;
  for(ll i=0; i<N; i++){
    ll A; cin>>A;
    if(R.count(A)) R[A]++;
    else R[A]=1;
  }
  priority_queue<int> pq;
  ll count=0;
  for(auto p:R){
    auto k=p.first;
    auto v=p.second;
    if(v>=2){
      while(v>=2){
        pq.push(k);
        v=v/2;
      }
      count++;
    }
  }
  if(count<2) cout<<0<<endl;
  else{
    ll ans=pq.top();
    pq.pop();
    cout<<ans*pq.top()<<endl;
  }
}

Measured memory_bytes: 6528
#define Kafuu signed
#define Chino main

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define maxn 100005
#define inf 0x3f3f3f3f
#define px putchar
#define pn px('\n')
#define ps px(' ')
#define pd puts("======================")
#define pj puts("++++++++++++++++++++++")

using namespace std;

inline int read(){
	int x=0,y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')y=1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return y?-x:x;
}
template<typename T>
inline T read(){
	T x=0;
	int y=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')y=1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return y?-x:x;
}
int a[maxn],tax[16],f[1<<16];
int dfs(int s){
	if(~f[s])return f[s];
	int x;
	f[s]=inf;
	for(register int i=1;i<=15;++i)
		for(register int j=1;j<=15;++j){
			if(i==j||!(s>>i-1&1)||!(s>>j-1&1))continue;
			x=i^j;
			if(s>>x-1&1)f[s]=min(f[s],dfs(s^(1<<i-1)^(1<<j-1)^(1<<x-1))+2);
			else f[s]=min(f[s],dfs(s^(1<<i-1)^(1<<j-1)^(1<<x-1))+1);
		}
	return f[s];
}
Kafuu Chino(){
	int n=read(),x,y,z,state=0;
	long long ans=0;
	for(register int i=1;i<n;++i)x=read()+1,y=read()+1,z=read(),a[x]^=z,a[y]^=z;
	for(register int i=1;i<=n;++i)++tax[a[i]];
	for(register int i=1;i<=15;++i){
		ans+=tax[i]>>1;
		if(tax[i]&1)state|=1<<i-1;
	}
	memset(f,-1,sizeof f),f[0]=0;
	printf("%lld\n",ans+dfs(state));
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<int,int> pii;
map<int,int>M;
vector<int> V[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        if(a%2 && i%2)
            sum++;
    }
    cout<<sum;
    return 0;
}


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

int main()
{
  string A,B,C;
  cin >> A >> B >> C;
  cout << 'A' << B.at(0) << 'C' << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int ans = INF;
    vector<int> use(n, 0);
    use[0] = -1;
    while (use[n - 1] != 4)
    {
        use[0]++;
        for (int i = 0; i < n - 1; i++)
            if (use[i] == 4)
                use[i] = 0, use[i + 1]++;
        int A = 0, B = 0, C = 0, tmp = 0;
        rep(i, n)
        {
            if (use[i] == 1)
            {
                if (A != 0)
                    tmp += 10;
                A += l[i];
            }
            if (use[i] == 2)
            {
                if (B != 0)
                    tmp += 10;
                B += l[i];
            }
            if (use[i] == 3)
            {
                if (C != 0)
                    tmp += 10;
                C += l[i];
            }
        }
        if (A * B * C == 0)
            continue;
        tmp += abs(A - a) + abs(B - b) + abs(C - c);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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


int main(){
    map <char,int> m;
    char c,a,b;
    for (int i=0;i<4;i++)
     { c=getchar();
       m[c]++;
      }
    bool r=true;
    for(auto v:m)
     { if (v.second != 2) r=false;    }
     
    if (r) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
t = [0]*(N)
for i in range(N-1):
  t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0) 
for i in range(Q):
  L, R = map(int, input().split())
  print(t[R-1]-t[L-1])

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

int main(void)
{
    int n;
    int play[3][201];
    int score[201];
    int i, j, k;
    int flag;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        for (j = 0; j < 3; j++){
            scanf("%d", &play[j][i]);
        }
    }
    
    memset(score, 0, sizeof(score));
    for (i = 0; i < 3; i++){
        for (j = 0; j < n; j++){
            flag = 0;
            for (k = 0; k < n; k++){
                if (play[i][j] == play[i][k]){
                    flag++;
                }
            }
            if (flag == 1){
                score[j] += play[i][j];
            }
        }
    }
    
    for (i = 0; i < n; i++){
        printf("%d\n", score[i]);
    }

    return (0);
}

    

Measured memory_bytes: 600
const MOD: i64 = 1000000007;

fn main () {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let x: Vec<i64> = {
		(0..n - 1).scan(s.next().unwrap().parse::<i64>().unwrap(), |st, _|{
			let x = s.next().unwrap().parse().unwrap();
			let r = x - *st;
			*st = x;
			Some(r)
		}).collect()
	};

	let mut fact = 1;
	let mut a = vec![0, 1];
	for i in 2..x.len() {
		let (b, c) = (a[i - 1], a[i - 2]);
		let i = i as i64;
		fact = fact * i % MOD;
		a.push((((2 * i + 1) * b % MOD - (i * i) % MOD * c % MOD) + MOD) % MOD);
	}
	let n = n as i64;
	fact = fact * (n - 1) % MOD;
	let mut ans = 0;
	let mut pr = 1;
	for (i, (a, x)) in a.into_iter().zip(x).enumerate().rev() {
		let i = i as i64 + 1;
		ans = (ans + x * (a * pr % MOD + fact) % MOD) % MOD;
		pr = pr * i % MOD;
	}
	println!("{}", ans);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define INF 1e9
using namespace std;
typedef long long ll;

signed main() {
  // std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());

  int n;
  cin >> n;
  
  map<string, ll> counter;
  REP(i, n){
    string s;
    cin >> s;
    sort(ALL(s));
    counter[s]++;
  }  

  ll ans = 0;
  for (auto x : counter){
    ans += x.second * (x.second - 1) / 2;
  }

  cout << ans << endl;
}


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

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

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

void solve(long long A, long long B)
{
    int cnt = 0;
    int ansA = 0;
    int ansB = 0;
    while (1)
    {
        ansA = floor(cnt * 0.08);
        ansB = floor(cnt * 0.1);
        if (ansA > 100 || ansB > 100)
        {
            cout << "-1" << endl;
            break;
        }
        if (ansA == A && ansB == B)
        {
            cout << cnt << endl;
            break;
        }
        cnt++;
    }
}

int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function gcd(a,b){return b?gcd(b,a%b):a;}

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  var c = gcd(a,b);
  return solve(c);
}

function solve(x){
  var r = 1;
  for(var i = 2; i*i <= x; i++){
    if(x%i === 0){
      r++;
      while(x%i === 0)x /= i;
    }
  }
  if(x > 1)r++;
  return r;
}

Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
const double PI = acos(-1);
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  double r;
  cin >> r;
  printf("%.7f\n", r*2.0*PI);
  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define PB push_back
#define MP make_pair
#define ll long long
#define ull unsigned long long 
#define pii pair<int,int>
#define all(X) (X).begin(),(X).end()
#define F first
#define S second
#define endl cout<<'\n';
#define __IO ios::sync_with_stdio(false),cin.tie(0);
using namespace std;
#define int long long
int dp[100005][4] , a[100005] , b[100005] , c[100005];
signed main(){
__IO
	int n; cin >> n ;
	for(int i=0 ; i<n ; ++i) cin >> a[i] >> b[i] >> c[i];
	dp[0][1] = a[0] , dp[0][2] = b[0] , dp[0][3] = c[0];
	for(int i=1 ; i<n ; ++i){
		for(int j=1 ; j<4 ; ++j){
			int now;
			if(j == 1) now = a[i];
			if(j == 2) now = b[i];
			if(j == 3) now = c[i];
			dp[i][j] = max( (j==1?-1111:dp[i-1][1]) + now , max((j==2?-111:dp[i-1][2]) + now , (j==3?-111:dp[i-1][3]) + now));
		}
	}
	int ans = 0;
	for(int i=1 ; i<4 ; ++i) ans = max(dp[n-1][i] , ans);
	cout << ans;endl
}

Measured memory_bytes: 5760
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,a[100000+2],cnt[100000+2],q,b,c;
int main(){
	fastio;
	cin>>n;
	rb(i,1,n)
		cin>>a[i],cnt[a[i]]++;
	LL res=0;
	rb(i,1,n){
		res+=a[i];
	}
	cin>>q;
	rb(i,1,q){
		cin>>b>>c;
		cnt[c]+=cnt[b];
		res-=(LL)cnt[b]*(b-c);
		cnt[b]=0;
		cout<<res<<endl;		
	}
	
	return 0;
}


Measured memory_bytes: 4392
// Problem : A - Payment
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cerr << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cerr << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define all(x) (x).begin() , (x).end()
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
		int n;
		cin >> n;
		
		cout << (1000 - (n % 1000))%1000 << "\n";
    return 0;
}

Measured memory_bytes: 3576
package main

import (
	"fmt"
)

func main() {
	var a, b, c int

	fmt.Scanf("%d %d %d", &a, &b, &c)

	fmt.Println(logic(a, b, c))
}

func logic(a, b, c int) int {
	result := b + c - a
	if result < 0 {
		return 0
	}
	return result
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    int N, Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    int s[N-1]={0};
    rep(i, N-1){
        if(S.at(i)=='A'&&S.at(i+1)=='C'){
            if(i==0){
                s[i]=1;
            }
            else{
                s[i]=s[i-1]+1;
            }
        }
        else{
            if(i==0){}
            else{
                s[i]=s[i-1];
            }
        }
    }
    int l, r;
    int count;
    rep(i, Q){
        cin>>l>>r;
        if(l==1){
            cout<<s[r-2]<<endl;
        }
        else{
            cout<<s[r-2]-s[l-2]<<endl;
        }
    }
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    static Deque<String> list = new ArrayDeque<>();

    public static void main(String[] args) throws IOException{
        StringBuilder ans = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] sp = new String[2];
        
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                sp = br.readLine().split(" ");
                if (sp[0].equals("insert")) {
                    list.addFirst(sp[1]);
                } else if (sp[0].equals("delete")) {
                    list.remove(sp[1]);
                } else if (sp[0].equals("deleteFirst")) {
                    list.removeFirst();
                } else if (sp[0].equals("deleteLast")) {
                    list.removeLast();
                }
            }
            ans.append(list.poll());
            for (String s : list) {
                ans.append(" ");
                ans.append(s);
            }
            System.out.println(ans.toString());
       
    }
}



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

int N, P, cur, ten = 1, cnt[10000];
string S;
int64_t ans;

int main() {
    cin >> N >> P >> S;
    if (10 % P == 0) {
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) {
                ans += i + 1;
            }
        }
    } else {
        cnt[0] = 1;
        for (int i = N - 1; i >= 0; i--) {
            (cur += (S[i] - '0') * ten) %= P;
            ans += cnt[cur]++;
            ten = ten * 10 % P;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  int S, upper, lower;
  cin >> S;
  upper = S / 100;
  lower = S % 100;
  if(((1 <= upper) && (upper <= 12)) && ((1 <= lower) && (lower <= 12)))cout << "AMBIGUOUS" << endl;
  else if(((1 <= upper) && (upper <= 12)) && (lower > 12 || lower == 0))cout << "MMYY" << endl;
  else if((upper > 12 || upper == 0) && ((1 <= lower) && (lower <= 12)))cout << "YYMM" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,AC = 0, WA = 0, TLE = 0, RE = 0;
  cin >> N;
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S == "AC"){
      AC++;
    }
    else if(S == "WA"){
      WA++;
    }
    else if(S == "TLE"){
      TLE++;
    }
    else{
      RE++;
    }
  }
   cout << "AC x " << AC << endl;
   cout << "WA x " << WA << endl;
   cout << "TLE x " << TLE << endl;
   cout << "RE x " << RE << endl;  
}

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

int main()
{
    int A,B,C,D,E,F;

    cin >> A>>B>>C>>D>>E>>F;

    float max_density = 0.0;
    int opt_w = 0;
    int opt_s = 0;
    float limit_density = 100.0*E/(100+E);
    for(int a=0; 100*A*a <= F; a++){
        for(int b=0;100*A*a+100*B*b<=F; b++){
            int w = 100*A*a + 100*B*b;
            if(w==0) continue;
            for(int c=0;c<=F-w;c++){
                for(int d=0;c+d<=F-w;d++){
                    
                    int s = C*c + D*d;
                    if(w+s> F) break;
                    
                    float density = 100.0*s/(w+s);
                    //cout << density << endl;
                    if(density>limit_density) break;

                    if (max_density <= density){
                        opt_w = w;
                        opt_s = s;
                        max_density = density;

                        //cout << opt_w<< " "<<opt_s << endl;
                    }
                }
            }
        }
    }
    

    //cout <<max_density <<" "<<opt_w<<" " << opt_s << endl;
    cout <<opt_w+opt_s<<" " << opt_s << endl;
    

   return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_M
    {
        public static void Main()
        {
            var nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];

            const long mod = 1000000007;
             
            var dp = new long[n + 1, k + 1];

            var acc = new long[n];
            acc[0] = a[0];
            for (int i = 1; i < n; i++)
                acc[i] = acc[i - 1] + a[i];

            for (int i = 1; i <= n; i++)
            {
                dp[i, 0] = 1;
                for (int j = 1; j <= Math.Min(acc[i - 1], k); j++)
                {
                    dp[i, j] = dp[i - 1, j] + dp[i, j - 1];
                    if (j > a[i - 1])
                        dp[i, j] -= dp[i - 1, j - 1 - a[i - 1]];
                    dp[i, j] %= mod;
                }
            }
            Console.WriteLine(dp[n, k] < 0 ? dp[n, k] + mod : dp[n, k]);
        }
    }
}


Measured memory_bytes: 90976
#include<bits/stdc++.h>
using namespace std;
int a[100001][3];
int dp[100001][3];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
    for(int i=1;i<=n;i++)
    {
        for(int k=0;k<3;k++)
        {
            for(int j=0;j<3;j++)
            {
                if(j==k)
                    continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    int mx=dp[n][0];
    for(int i=1;i<3;i++)
        mx=max(mx,dp[n][i]);
    cout<<mx<<endl;;
    return 0;
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
s=list(ss())
rarr = []
garr=[]
barr=[]

for i in range(n):
    if s[i]=="R":
        rarr.append(i)
    elif s[i]=="G":
        garr.append(i)
    else:
        barr.append(i)

#組み合わせ全通り
ans=len(rarr)*len(barr)*len(garr)

#[0, 2, 5, 11, 12, 16, 17, 18, 23, 27, 31] 11
#[4, 7, 8, 13, 20, 21, 25, 29, 35] 9
#[1, 3, 6, 9, 10, 14, 15, 19, 22, 24, 26, 28, 30, 32, 33, 34, 36, 37, 38] 19
if len(rarr)>len(garr):
    rarr,garr=garr,rarr
if len(barr)>len(garr):
    barr,garr=garr,barr

garr=Counter(garr)

for r in rarr:
    for b in barr:
        #GRB
        if r-b >0 and garr[r + r-b]:
            ans-=1
        #GBR
        elif b-r >0 and garr[b + b-r]:
            ans-=1
        #RGB BGR
        if r-b >0 and (r-b)%2==0 and garr[b+((r-b)//2)]:
            ans-=1

        elif b-r >0 and (b-r)%2==0 and garr[r+((b-r)//2)]:
            ans-=1
        #RBG
        if r-b>0 and garr[b-(r-b)]:
            ans-=1
        elif b-r>0 and garr[r-(b-r)]:
            ans-=1

print(ans)


Measured memory_bytes: 74280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans;
  ans = 0;
  for (int i = 1; i < 10; i++) {
    
    for (int s = 1; s < 10; s++) {
      int is;
      is = i * s;
      if (N == is) {
        ans = is;
      }
    }
  }
  if (ans != 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import static java.lang.Math.min;
import static java.lang.Math.max;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) throws Exception {
      int n = sc.nextInt();
      int arr[]  = new int[n];
      Map<Integer,Integer> hm = new HashMap<>();
      for(int i=0; i<n; i++){
          arr[i] = sc.nextInt();
          if(hm.containsKey(arr[i])){
              hm.put(arr[i],1+hm.get(arr[i]));
          }else hm.put(arr[i],1);
      }
      int count=0;
      for(int i=0; i<n; i++){
          int x = arr[i];
          boolean flag = true;
          for(int j=1; j*j<=x; j++){
              if(x%j==0){
                  int y = x/j;
                  if(j!=x){
                      if(hm.containsKey(j)) flag = false;
                  }
                  if(y!=x){
                      if(hm.containsKey(y)) flag= false;
                  }
              }
          }
          if(hm.containsKey(x) && hm.get(x) > 1) flag =false;
          if(flag) count++;
      }
      out.println(count);
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}
class Pair implements Comparable<Pair>{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }
    public int compareTo(Pair p){
        return (int)(this.x - p.x);
    }

}

Measured memory_bytes: 70556
(let ((n (read))
      (pre 0)
      (flg T)
      temp)
     (loop repeat n
           do (setf temp (read))
              (cond ((> pre temp) (setf flg nil))
                    ((< pre (1- temp)) (setf pre (1- temp)))))
     (princ (if flg "Yes" "No")))

Measured memory_bytes: 57704
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;

// テァツつケテ・ツコツァテヲツィツ凖」ツつ津・ツ楪凝」ツ?ィテ」ツ?凖」ツつ?
typedef complex<double> P;
// テ渉?」ツ?ョテ・ツョツ堙ァツセツゥ
#define PI 3.1415926535898

// ティツィツアテ・ツョツケテ」ツ?凖」ツつ凝ィツェツ、テ・ツキツョテ篠オ
#define EPS (1e-10)
//XYテ・ツコツァテヲツィツ?
#define X real()
#define Y imag()

//テッツシツ津」ツ?、テ」ツ?ョdoubleテ・ツ楪凝」ツ?ョテヲツ閉ーテ・ツ?、テ」ツ?古ァツュツ嘉」ツ?療」ツ??」ツ?凝」ツ?ゥテ」ツ??」ツ??
bool equal(double a, double b){
	return ( abs( a-b ) < EPS )? true : false ;
}
	
// テ、ツクツ嘉ィツァツ津・ツスツ「テ」ツつッテ」ツδゥテ」ツつケ
class Triangle{

private:
	//テ、ツクツ嘉ィツァツ津・ツスツ「テ」ツ?ョテッツシツ禿ァツつケテ」ツ?ョテ・ツコツァテヲツィツ?
	P a, b, c;
	//テ、ツクツ嘉ィツァツ津・ツスツ「テ」ツ?ョテッツシツ禿ィツセツコテ」ツ?ョテゥツ閉キテ」ツ??
	double edgeA,edgeB,edgeC;
	//テ、ツクツ嘉ィツァツ津・ツスツ「テ」ツ?ョテッツシツ禿ィツァツ津」ツ?ョテ・ツ、ツァテ」ツ?催」ツ??テ」ツδゥテ」ツつクテ」ツつ「テ」ツδウ)
	double angleA,angleB,angleC;
	//テ、ツスツ凖・ツシツヲテ・ツョツ堙ァツ青?」ツ?凝」ツつ嘉ッツシツ禿」ツ?、テ」ツ?ョティツァツ津・ツコツヲテ」ツつ津ヲツアツづ」ツつ?」ツつ凝ゥツ鳴「テヲツ閉ー
	double LawOfCosines(double a,double b, double c){
		return acos( (b*b+c*c-a*a) / (2.0*b*c) );
	}
	
public:
	//テ」ツつウテ」ツδウテ」ツつケテ」ツδ暗」ツδゥテ」ツつッテ」ツつソ(テッツシツ禿」ツ?、テ」ツ?ョテァツつケテ」ツ?ィティツセツコテ」ツ?ィティツァツ津・ツコツヲテ」ツつ津・ツ按敕ヲツ慊淌・ツ個?
	Triangle(P p1, P p2, P p3){
		a = p1;
		b = p2;
		c = p3;
		edgeB = abs(c-a);
		edgeA = abs(b-c);
		edgeC = abs(a-b);
		angleA = LawOfCosines(edgeA,edgeB,edgeC);
		angleB = LawOfCosines(edgeB,edgeC,edgeA);
		angleC = LawOfCosines(edgeC,edgeA,edgeB);
	}
	double getAngleC(){//ティツァツ辰テ」ツ?ョティツァツ津・ツコツヲテ」ツつ津・ツ、ツ嘉」ツ?暗」ツ??
		return angleC;
	}
};

int main(){
	double x1, x2, x3, y1, y2, y3, xp, yp, angle;

	while( cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp ){
		P a( x1 , y1 );
		P b( x2 , y2 );
		P c( x3 , y3 );
		P p( xp , yp );
		Triangle Tr1(a,b,p);
		Triangle Tr2(b,c,p);
		Triangle Tr3(c,a,p);
		angle = Tr1.getAngleC() + Tr2.getAngleC() + Tr3.getAngleC();
		( equal( 2.0*PI , angle) )? cout << "YES" : cout << "NO" ;
		cout << endl;
	}
}

Measured memory_bytes: 1284
N = int(input())
A = [input() for i in range(N)]
dic={}
for a in A:
  if a not in dic:
    dic[a] = 1
  elif dic[a] != 1:
    dic[a] = 1
  else:
    dic[a] = 0
print(list(dic.values()).count(1))

Measured memory_bytes: 19468
#include<iostream>
#include<queue>
using namespace std;
int x[10000], a, b, n, c[10000], d[10000];
int main() {
	while (true) {
		for (int i = 0; i < 10000; i++) { d[i] = 0; }
		cin >> n; if (n == 0) { break; }
		for (int i = 0; i < n*n; i++) {
			cin >> a >> b;
			x[i] = b * n + a;
		}
		int cnt = 0;
		for (int i = 0; i < n*n; i++) {
			if(d[i]==0)
			for (int j = 0; j < 10000; j++) { c[j] = 0; }
			int cx = i;
			while (true) {
				c[cx] = 1;
				cx = x[cx];
				if (c[cx] == 1) { break; }
			}
			int C = 0;
			for (int j = 0; j < 10000; j++) {
				if (c[j] == 1 && d[j] >= 1) {
					C = d[j];
				}
			}
			if (C == 0) {
				cnt++; C = cnt;
			}
			for (int j = 0; j < 10000; j++) {
				if (c[j] == 1) { d[j] = C; }
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

struct Sphere
{
  double x, y, z, r;
  double getDist(const Sphere &other)
  {
    double res = sqrt(pow(x - other.x, 2) + pow(y - other.y, 2) + pow(z - other.z, 2)) - r - other.r;
    if (res <= 0)
    {
      return 0;
    }
    return res;
  }
};

struct UnionFind
{
  vector<int> rank, p;
  UnionFind(int n)
  {
    rank.resize(n, 0);
    p.resize(n, 0);
    for (int i = 0; i < n; i++)
    {
      p.at(i) = i;
    }
  }

  int find(int x)
  {
    if (x != p.at(x))
    {
      p.at(x) = find(p.at(x));
    }
    return p.at(x);
  }

  bool same(int x, int y)
  {
    return find(x) == find(y);
  }

  void link(int x, int y)
  {
    if (rank.at(x) > rank.at(y))
    {
      p.at(y) = x;
    }
    else
    {
      p.at(x) = y;
      if (rank.at(x) == rank.at(y))
      {
        rank.at(y)++;
      }
    }
  }

  void unite(int x, int y)
  {
    link(find(x), find(y));
  }
};

int main()
{
  while (1)
  {
    int n;
    cin >> n;
    if (!n)
    {
      break;
    }
    vector<Sphere> sp(n);
    for (int i = 0; i < n; i++)
    {
      double x, y, z, r;
      cin >> x >> y >> z >> r;
      sp.at(i) = Sphere{x, y, z, r};
    }
    UnionFind uf(n);
    vector<tuple<double, int, int>> edge;
    for (int i = 0; i < n; i++)
    {
      for (int j = i + 1; j < n; j++)
      {
        double d = sp.at(i).getDist(sp.at(j));
        if (d == 0)
        {
          uf.unite(i, j);
          continue;
        }
        edge.push_back(make_tuple(d, i, j));
      }
    }
    sort(edge.begin(), edge.end());
    double ans = 0;
    for (int i = 0; i < edge.size(); i++)
    {
      double d;
      int s, t;
      tie(d, s, t) = edge.at(i);
      if (uf.same(s, t))
      {
        continue;
      }
      ans += d;
      uf.unite(s, t);
    }
    printf("%.3f\n", ans);
  }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 1e5+5;

int h[maxn];
int dp[maxn];

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i<= n; i++) scanf("%d", &h[i]);
	dp[n] = 0;
	for(int i = n-1; i>= 1; i--)
	{
		dp[i] = dp[i+1]+abs(h[i]-h[i+1]);
		if(i+2<= n) dp[i] = min(dp[i], dp[i+2]+abs(h[i]-h[i+2]));
	}
	printf("%d\n", dp[1]);
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ans := calc(N, 31, "", true)
	if len(ans) == 0 {
		ans = "0"
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}

func calc(n, bit int, ans string, isStart bool) string {
	for i := bit; i >= 0; i-- {
		base := pow(-2, i)
		mi := base
		ma := base
		for j := 0; j < i; j++ {
			num := pow(-2, j)
			if num < 0 {
				mi += num
			} else {
				ma += num
			}
		}
		if mi <= n && n <= ma {
			return calc(n-base, i-1, ans+"1", false)
		}
		if !isStart {
			ans += "0"
		}
	}
	return ans
}


Measured memory_bytes: 640
import sys
from math import gcd
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())

    res = 0
    for a in range(1, k + 1):
        for b in range(1, k + 1):
            g1 = gcd(a, b)
            for c in range(1, k + 1):
                g2 = gcd(g1, c)
                res += g2

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, otsuri,answer;
  cin >> N;
  for (int i=1; (i-1)*1000<N; i++) {
    answer=i;
  }
  otsuri=answer*1000-N;
  cout<< otsuri<< endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

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

const int INF = 1e7;

int dp[1<<14][14];
int conn[14][14];

int main() {
	int n;
	while(cin >> n, n) {
		vector<string> ins(n);
		rep(i, n) {
			cin >> ins[i];
		}

		vector<string> in;
		rep(i, n) {
			bool dup = false;
			rep(j, n) {
				if(i==j) continue;
				if( ins[j].find(ins[i]) != string::npos ) {
					dup = true;
					break;
				}
			}
			if(!dup) in.push_back(ins[i]);
		}
		n = in.size();

		rep(i, n) {
			rep(j, n) {
				if( in[i].find(in[j]) != string::npos ) {
					conn[i][j] = 0;
				} else {
					int t = min(in[i].length(), in[j].length()) - 1;
					while(t>0 && in[i].substr(in[i].length()-t) != in[j].substr(0, t)) t--;
					conn[i][j] = in[j].length() - t;
				}
			}
		}

		rep(i,(1<<n)) rep(j,n) dp[i][j] = INF;
		for(int i=0; i<n; i++) {
			dp[1<<i][i] = in[i].length();
		}
		for(int i=0; i<(1<<n); i++) {
			for(int x=0; x<n; x++) {
				if(i & (1<<x)) {
					rep(j, n) {
						if( (i & (1<<j)) == 0 ) {
							int k = i | (1<<j);
							int st = dp[i][x] + conn[x][j];
							if( dp[k][j]==0 || dp[k][j] > st ) {
								dp[k][j] = st;
							}
						}
					}
				}
			}
		}

		int mini = INF;
		rep(i, n) {
			mini = min( mini, dp[(1<<n)-1][i] );
		}
		cout << mini << endl;
	}
	return 0;
}

Measured memory_bytes: 2112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int n;
struct CHECK {
	int	l;
	int	r;
	int	x;
};
CHECK check_roules[301][300];
int m[301] = {0};
int c[301][301][301];

int new_chk(int i, int r, int g, int b)
{
	vector<int> v;
	v.push_back(r);
	v.push_back(g);
	v.push_back(b);
	sort(v.begin(), v.end());
	int& ret = c[i][v[0]][v[1]];
	if (ret != -1) {
		return ret;
	}
	for (int j = 0 ; j < m[i] ; j++) {
		if (check_roules[i][j].l <= v[0]) {
			if (check_roules[i][j].x != 3) {
				return ret = 0;
			}
		} else if (check_roules[i][j].l <= v[1]) {
			if (check_roules[i][j].x != 2) {
				return ret = 0;
			}
		} else if (check_roules[i][j].l <= v[2]) {
			if (check_roules[i][j].x != 1) {
				return ret = 0;
			}
		}
	}
	if (i == n) {
		return ret = 1;
	}

	return ret = (((new_chk(i + 1, i + 1, g, b) + new_chk(i + 1, r, i + 1, b)) % 1000000007) + new_chk(i + 1, r, g, i + 1)) % 1000000007;
}

int main()
{
	cin >> n;

	int M;
	cin >> M;

	for (int i = 0 ; i < M ; i++) {
		CHECK check_roule;
		cin >> check_roule.l;
		cin >> check_roule.r;
		cin >> check_roule.x;
		check_roules[check_roule.r][m[check_roule.r]] = check_roule;
		(m[check_roule.r])++;
	}

	memset(c, -1, sizeof(c));
	cout << new_chk(0, 0, 0, 0) << endl;

	return 0;
}


Measured memory_bytes: 107904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long l = sc.nextLong();
		long r = sc.nextLong();
		long ans = 0;
		long min = Long.MAX_VALUE;

		for (long i = l; i < r; i++) {
			for (long j = i + 1; j <= r; j++) {
				long calc = (i * j) % 2019;
				min = Math.min(min, calc);
				if (min == 0) {
					break;
				}
			}
			if (min == 0) {
				break;
			}
		}
		System.out.println(min);


		//		if (r < 2019) {
		//			ans =  (l * (l + 1)) % 2019;
		//
		//		} else if (r - l >= 2019 ) {
		//			ans = 0;
		//
		//		} else if (l < 2019 && 2019 < r) {
		//
		//
		//		} else {
		//			ans =  (l * (l + 1)) % 2019;
		//		}

		//		System.out.println(ans);


	}
}

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

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double d = pow(a, 2) + pow(b, 2);
    double th =  (double)(2 * M_PI * abs((60 * h + m) - 12 * m))/720;
    double ab = 2 * a * b * cos(th);
    d -= ab;
    d = sqrt(d);
    cout << fixed << setprecision(10) << d << endl;
    return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ans = 1, mi = 0;
  for(int i=n; i>=1; i--){
    int tmp = i;
    int cnt = 0;
    while(tmp % 2 == 0){
      cnt++;
      tmp /= 2;
    }
    if(cnt > mi){
      mi = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define int long long
#define mod (int)1000000007
#define N 64000
vector<int> vec;
int tot[N];
int pow(int base,int up)
{
    int ans=1;
    while(up)
    {
        if(up&1) ans*=base,ans%=mod;
        base*=base;
        base%=mod;
        up>>=1;
    }
    return ans;
}
signed main()
{
    int n,k,len;
    cin>>n>>k;
    len=sqrt(n);
    for(int i=1;i<=len;i++) if(n%i==0)//获取所有可能的循环节长度
    {
        vec.push_back(i);
        if(i!=n/i) vec.push_back(n/i);
    }
    sort(vec.begin(), vec.end());
    int ans=0;
    for(int i=0;i<vec.size();i++)
    {
        tot[i]=pow(k,(vec[i]+1)/2);//循环节长度为vec[i]时循环节的数量。因为是回文串，所以只需要知道前面半截即可确定出整个回文串，下面也是同理
        for(int j=0;j<i;j++) if(vec[i]%vec[j]==0)
        tot[i]-=tot[j],tot[i]=(tot[i]+mod)%mod;//去除【长度为vec[i]的循环节】内部含有循环节的情况
        if(vec[i]&1) ans+=tot[i]*vec[i],ans%=mod;
        else ans+=tot[i]*(vec[i]/2),ans%=mod;
    }
    cout<<ans;
}

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

int main()
{
	
	int n;
	cin >> n;
	
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];

	
	int count = 0;
	bool flag = true;
	while(true)
	{
		for(int i = 0; i < n; i++)
		{
			if(arr[i] % 2 != 0)
			{
				flag = false;
				break;
			}
			else
				arr[i] /= 2;
		}
		if(flag)
			count++;
		else
			break;
	}
	cout << count;
}

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

int main() {
  


    int n,sum=0;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];

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

    for(int i=0;i<n;i++)
    {
    	sum=sum+b[i];

    	if(a[i+1]==a[i]+1)
    	{
    		int p=(a[i]-1);

    		sum=sum+c[p];
    	}

    }

    cout<<sum;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////
struct UnionFind {
	vector<int>par;

	UnionFind(int n) :par(n) {
		for (int i = 0; i < n; ++i) {
			par[i] = i;
		}
	}

	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unit(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int  rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
int main() {
	int n, m; cin >> n >> m;
	vector<int>p(n);
	for (int i = 0; i < n; ++i)cin >> p[i];
	UnionFind tree(n);
	for (int i = 0; i < m; ++i) {
		int x, y; cin >> x >> y;
		tree.unit(x-1, y-1);
	}
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (tree.same(i, p[i] - 1)) {
			cnt++;
		}
	}
	cout << cnt << endl;
	//02,1,34
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define pb             emplace_back
#define mp             make_pair
#define F              first
#define S              second
#define rep(i, x)      for (__typeof(x) i = 0; i < x; i++)
#define repp(i, x, y)  for (__typeof(x) i = x; i < y; i++)
#define all(a)         (a).begin(),(a).end()
#define sz(x)          (int)x.size()
#define endl           '\n'
#define DB(x)          cerr << #x << " is " << x << endl;
#define TEST(T)        int T; cin >> T; rep(i, T)
#define MOD            1000000007
typedef long long          ll;
typedef vector<int>        vi;
typedef pair<int, int>     ii;
typedef vector<ii>        vii;

int main(){ _
    int n; string s;
    cin >> n >> s;
    int x=0, m=0;
    for(auto i: s){
        if (i=='I') x++;
        else if (i=='D') x--;
        m = max(m, x);
    }
    cout << m << endl;
}

Measured memory_bytes: 256