akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////


signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int m;
	cin>>m;
	vector<int> gr[n+1];
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		gr[x].push_back(y);
	}
	int ans[n+1];
	for(int i=1;i<=n;++i)
		ans[i]=inf;
	int vis[n+1][3]={};
	int s,t;
	cin>>s>>t;
	set<pair<int,pair<int,int>>> q;
	q.insert({0,{s,0}}); 
	while(q.size()!=0)
	{
		pair<int,pair<int,int>> p=*q.begin();
		q.erase(q.begin());
		if(p.S.S==0)
		{
			ans[p.S.F]=p.F;
		}
		for(auto r:gr[p.S.F])
		{
			if(vis[r][(p.S.S+1)%3]==0)
			{
				vis[r][(p.S.S+1)%3]=1;
				q.insert({p.F+1,{r,(p.S.S+1)%3}});
			}
		}
	}
	if(vis[t][0]==0)
		cout<<"-1";
	else
		cout<<ans[t]/3;
}

Measured memory_bytes: 8960
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100];
    scanf("%s",a);
    long int k;
    scanf("%ld",&k);
    int initial=1,last=1;long int ans=0;
    for(int i=0;i<strlen(a);i++)
    {
        int j=i+1;
        int c=1;
        if(i==0)
        {
            while(a[j]==a[i] && j<strlen(a))
            {
                initial++;
                j++;
            }
            ans+=(j-i)/2;
            i=j-1;
            if(i==strlen(a)-1)
                ans=-1;
        }
        else
        {
            while(a[j]==a[i] && j<strlen(a))
            {
                c++;
                j++;
            }
            ans+=(j-i)/2;
            i=j-1;
            if(i==strlen(a)-1)
                last=c;
        }
    }
    if(ans==-1)
    {
        ans=(initial*k)/2;
    }
    else
    {
        if(a[0]==a[strlen(a)-1])
        {
            if(initial%2==1 && last%2==1)
                ans=k*ans+(k-1);
            else
                ans=k*ans;
        }
        else
            ans=k*ans;
    }
    printf("%ld\n",ans);
    return 0;
}







Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  int t;
  cin >> t;
  while(t--){
    int n,k;
    cin >> n >> k;
    vector<int> dist;
    int pre;
    dist.push_back(0);
    REP(i,n){
      int tmp;
      cin >> tmp;
      if(i) dist.push_back(tmp-pre);
      pre=tmp;
    }
    SORT(dist);
    REP(i,n-1) dist[i+1]+=dist[i];
    cout << dist[max(n-k,0)] << endl;
  }
  return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s,t;
    cin >> s >> t;
    int n = s.size();
    REP(i, n){
        bool flag = true;
        REP(j, n){
            if(i+j<n){
                if(s[j] != t[i+j])flag = false;
            }
            else{
                if(s[j] != t[i+j-n])flag = false;
            }
        }
        if(flag){
            pr("Yes");
            return 0;
        }
    }
    pr("No");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int p = 0;
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
            if (a[i] == 1) {
                p = i + 1;
            }
        }
        int c = 0;
        int temp = p;
        int temp2 = p;

        if (n == k) {
            System.out.println(1);
            return;
        }
        if (p < k && p > n - k + 1) {
            System.out.println(2);
            return;
        }else if (p < k && p <= n - k + 1) {
            c++;
            temp = k;
            while (temp < n) {
                temp += (k - 1);
                c++;
            }
            System.out.println(c);
            return;
        }else if (p >= k && p > n - k + 1) {
            c++;
            temp = n - k + 1;
            while (temp > 1) {
                temp -= (k - 1);
                c++;
            }
            System.out.println(c);
            return;
        } else {
//            while (temp < n ) {
//                temp += (k - 1);
//                c++;
//            }
//            while (temp2 > 1) {
//                temp2 -= (k - 1);
//                c++;
//            }
            temp = 1;
            while (temp < n) {
                temp += (k - 1);
                c++;
            }
            System.out.println(c);
        }



    }

}

Measured memory_bytes: 50168
N,T=gets.chomp.split(' ').map(&:to_i)
c0=2000
N.times do
c1,t1=gets.chomp.split(' ').map(&:to_i)
if t1<=T && c1<=c0
c0=c1
end
end
if c0==2000
puts 'TLE'
else
puts c0
end

Measured memory_bytes: 3836
n,k=map(int,input().split())
*a,=map(int,input().split())

mod=10**9+7
ans=0
cnt=0
for i in range(n):
    for j in range(i+1,n):
        ans+=k if a[i]>a[j] else 0
        cnt+=0 if a[i]==a[j] else 1

ans%=mod
ans+=(cnt*k*(k-1)//2)
ans%=mod


print(ans)

Measured memory_bytes: 69512
// Example program
#include <iostream>
#include <string>

int main()
{
    unsigned char Triple_Numbers_Arr[3] = {0};
    
    
    for (int i = 0; i < 3; i++)
    {
        std::cin >> Triple_Numbers_Arr[i];
    }
        
        
    if (Triple_Numbers_Arr[0] == Triple_Numbers_Arr[1] && Triple_Numbers_Arr[1] == Triple_Numbers_Arr[2])
    {
        std::cout << "No";
    }
    else if (Triple_Numbers_Arr[0] == Triple_Numbers_Arr[1])
    {
        std::cout << "Yes";
    }
    else if (Triple_Numbers_Arr[0] == Triple_Numbers_Arr[2])
    {
        std::cout << "Yes";
    }
    else if (Triple_Numbers_Arr[1] == Triple_Numbers_Arr[2])
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
x = []
for i in range(n):
  x.append((a[i][0]+a[i][1],i))
x.sort(reverse=True)
tk,ao = 0,0
for i in range(n):
  if i%2 == 0:
    tk += a[x[i][1]][0]
  else:
    ao += a[x[i][1]][1]
print(tk-ao)

Measured memory_bytes: 68952
/*      Author : Kaustubh Gangwar
        Institute : IIITA        */
#include <bits/stdc++.h>
using namespace std;
#define modo 1000000007
#define F first
#define S second 
#define pb push_back
#define gcd __gcd
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x).begin(),(x).end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fe(i,a,b) for(int i=a;i<=b;i++)
#define CODING ios_base::sync_with_stdio(false); 
#define SAMRAT cin.tie(0),cout.tie(0);
#define mii map<int,int>
#define nl '\n'
typedef long long  ll;
typedef pair<int,int> pii;
 
ll bpow(ll a, ll b) {
    a=a; ll ans = 1;
    while(b){
        if (b & 1)
        ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}

int32_t main()
{ 
   CODING SAMRAT
   int test=1;
 //  cin>>test;
   while(test--)
   {
    int n;cin>>n;
    double d; cin>>d;
    int ans=0;
    f(i,0,n)
    {
    	double x,y; cin>>x>>y;
    	if(sqrt(x*x + y*y)<=d) ans++;
    	
    }
    cout<<ans<<nl;
   }

return 0;
}

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int num;
		int i = 0;
		while(true) {
			num = in.nextInt();
			if (num == 0) {
				break;
			} else {
				sb.append("Case " + (++i) + ": " + num + "\n");
			}
		}
		
		System.out.print(sb);
	}
}

Measured memory_bytes: 43404
import sys

n, m = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
a = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
b = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]

for i in range( n ):
	c = 0
	for j in range( m ):
		c += ( a[i][j] * b[j][0] )
	print( c )

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

#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, n) for(int i = 0; i < n; ++i)
typedef unsigned long long llint;

const int maxN = 100;

void run() {
    int n, ans = 0;
    cin >> n;
    map<int, int> a, b;
    REP(i, n) {
        int v;
        cin >> v;
        if (i % 2 == 0) {
            a[v] += 1;
        } else {
            b[v] += 1;
        }
    }

    vector<pair<int, int>> c, d;
    for (auto e: a) {
        c.emplace_back(e.second, e.first);
    }
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    for (auto e: b) {
        d.emplace_back(e.second, e.first);
    }
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());


    if (c[0].second != d[0].second) {
        cout << n - (c[0].first + d[0].first) << "\n";
    } else {
        if (c.size() > 1 && d.size() > 1) {
            cout << n - max(c[0].first + d[1].first, c[1].first + d[0].first);
        } else {
            if (c.size() == 1 && d.size() == 1) {
                cout << n - max(c[0].first, d[0].first) << "\n";
            } else {
                if (c.size() == 1) {
                    cout << n - max(c[0].first + d[1].first, d[0].first) << "\n";
                } else {
                    cout << n - max(d[0].first + c[1].first, c[0].first) << "\n";
                }
            }
        }
    }
}


int main() {
#ifdef LOCAL
    freopen("input", "r", stdin);
#endif
//    freopen("output", "w", stdout);
    run();
//    fclose(stdout);
#ifdef LOCAL
    fclose(stdin);
#endif
    return 0;
}

Measured memory_bytes: 6136
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;

ll f(ll x,ll y){
  if(x==-1){
    return 0;
  }
  else{
    return (x/y)+1;
  }
}


int main() {
  ll a,b,x;
  cin>>a>>b>>x;
  ll ans=0;
  if(a==0) ans=b/x+1;
  else ans=b/x-(a-1)/x;
  cout<<ans<<endl;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int x = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        //for(int i = 0; i < s.length(); i++){
        //}
        
        if(a + b >= x && a <= x){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
        
        //System.out.println();
        //System.out.print();
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>num(1e5+10);
  for(int i=0;i<n;i++){
    int a;cin>>a;
    num[a]++;
  }
  int cnt=0;
  sort(num.begin(),num.end(),greater<int>());
  for(int i=0;i<n;i++){
    if(num[i]>0)cnt++;
  }
  if(cnt%2)
    cout<<cnt<<endl;
  else
    cout<<cnt-1<<endl;
  return 0;
}


Measured memory_bytes: 640
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
    int n;
    cin>>n;
    if(n<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int a, b, k;

int main()
{
    cin >> a >> b >> k;
    for (int i = a;; i--)
    {
        k -= a % i == 0 && b % i == 0;
        if (k == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

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


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

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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  if (A > B) {
    cout << 0 << endl;
    return 0;
  }
  if (A == B) {
    cout << 1 << endl;
    return 0;
  }
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  cout << (N-2)*(B-A)+1 << endl;
  return 0;
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sortd(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

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

  int c = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == t[i]) {
      c++;
    }
  }
  p(c);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a, b, i, ans = 0;
    float c;
    scanf ("%d%d%f", &a, &b, &c);
    for (i = 1; i * a <= c + 0.5; i++) ans = i * b;
    printf ("%d", ans);
    return (0);
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

//in gcd(in a, in b) {return b != 0 ? gcd(b, a % b) : a;}//最大公約数

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in k;
    cin>>k;
    in sum=0;
    in gc;
    REP(i,1ll,k+1ll){
        REP(j,1ll,k+1ll){
            gc=gcd(i,j);
            REP(m,1ll,k+1ll){
                sum +=gcd(gc,m);
            }
        }
    }
    cout<<sum<<endl;
}
//./problem.exe

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, tmp;
    cin >> n;
    vll a(MAX, 0);
    FOR(i, 1, 100){
        FOR(j, 1, 100){
            FOR(k, 1, 100){
                tmp = i*i + j*j + k*k + i*j + j*k + k*i;
                a[tmp] ++;
            }
        }
    }
    FOR(i, 1, n) cout << a[i] <<"\n";
	return 0;
}

Measured memory_bytes: 3920
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;

int main() {
    while (cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2) {
        bool xf = ( max(xa1, xb1) <= min(xa2, xb2) );
        bool yf = ( max(ya1, yb1) <= min(ya2, yb2) );
        if (xf && yf) puts("YES");
        else puts("NO");
    }
    return 0;
}


Measured memory_bytes: 1184
#include <iostream>

using namespace std;

int main()
{

int nums[5] ;

for(int i = 0 ; i<5;i++){

    cin >> nums[i];
}
for(int i = 0 ; i <5;i++){
    if(nums[i] == 0){
        cout<<i+1;

    }

}

}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(int argc, char const *argv[]) {
    ll a,b; cin>>a>>b;
    map<int64_t, int> ma = prime_factor(a);
    map<int64_t, int> mb = prime_factor(b);

    int ans = 0;
    for (auto &&e: ma) {
        if (mb.count(e.first)) ans++;
    }

    cout << ++ans << '\n';
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

a_2 = []

if k == 0:
    print(sum(a))
    exit()

for i in range(n):
    a_2.append(list(format(a[i], '#042b')[2:]))

a_bit = len(bin(max(a))) - 2
k_bit = len(bin(k)) - 2

X = ''

for i in range(40 - k_bit, 40):
    cnt1 = 0
    for j in range(n):
        if a_2[j][i] == '1':
            cnt1 += 1

    if cnt1 >= (n + 1) // 2:
        X += '0'
    else:
        if 40 - i <= 2:
            s = X + '1' * (40 - i)
        else:
            s = X + '1' + '0' * (40 - i - 1)

        if s == '':
            X += '1'
        elif int(s, 2) > k:
            X += '0'
        else:
            X += '1'

ans = 0
for i in range(n):
    ans += a[i] ^ int(X, 2)

print(ans)


Measured memory_bytes: 192080
#include <stdio.h>
 
class Dice{
public:
    Dice(){
        number = new int[6];
        work = new int[6];
    };
    ~Dice(){
        delete[] number;
        delete[] work;
    };
 
    void setLabel(int index,int num){
        number[index] = num;
    };
 
    void roll(char dst){
        for(int i = 0; i < 6; i++) work[i] = number[i];
        switch(dst){
        case 'E':
            setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
            break;
        case 'N':
            setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
            break;
        case 'S':
            setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
            break;
        case 'W':
            setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
            break;
        }
    };
 
    int returnPeek(){
        return number[0];
    }
 
private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
private:
    int* number;
    int* work;
};
 
int main(){
    Dice dice;
    int label;
    char ch;
    for(int i = 0; i < 6; i++){
        scanf("%d",&label);
        dice.setLabel(i,label);
    }
    getchar(); 
    while((ch = getchar()) != '\n'){
        dice.roll(ch);
    }
    printf("%d\n",dice.returnPeek());
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    string a, b;
    cin>>a>>b;
    int size_a=a.length();
    int size_b=b.length();
    for(int i=0; i<size_b; i++){
        cout<<a[i]<<b[i];
    }
    if(size_a>size_b){
        cout<<a[size_a-1]<<endl;
    }
    else{
        cout<<endl;
    }
    return 0;
}

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


#define ll long long int

using namespace std;

int main() {
  int n;
  ll a[200];
  cin >> n;

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

  int c = 0;
  for (int i = 0; ; i++) {
    if (a[i]%2 == 1) {
      break;
    }

    a[i] = a[i]/2;

    if (i == n - 1) {
      i = 0;
      c++;
    }
  }

  cout << c << endl;

}


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

const int N = 1e5 + 100;

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio( false );
    
    int a, b, c;
    cin >> a >> b;
    cout << 6-a-b;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define mod 1000000007
using namespace std;
typedef long long ll;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,f[105][4][4][4];//0...3: A,C,G,T
bool legal(int a,int b,int c,int d){
  if(b == 0 && c == 2 && d == 1) return false;
  if(b == 0 && c == 1 && d == 2) return false;
  if(b == 2 && c == 0 && d == 1) return false;
  if(a == 0 && c == 2 && d == 1) return false;
  if(a == 0 && b == 2 && d == 1) return false;
  return true;
}
int main(){
  n = getint();
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 4;j++){
      for(int k = 0;k < 4;k++){
        if(legal(2535,i,j,k)) f[3][i][j][k] = 1;
      }
    }
  }
  for(int w = 3;w < n;w++){
    for(int i = 0;i < 4;i++){
      for(int j = 0;j < 4;j++){
        for(int k = 0;k < 4;k++){
          for(int l = 0;l < 4;l++){
            if(legal(i,j,k,l)) (f[w + 1][j][k][l] += f[w][i][j][k]) %= mod;
          }
        }
      }
    }
  }
  int ans = 0;
  for(int i = 0;i < 4;i++){
    for(int j = 0;j < 4;j++){
      for(int k = 0;k < 4;k++){
        (ans += f[n][i][j][k]) %= mod;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

int main() {
	int A, B, K;
	int k[999];
	int count = 1;

	cin >> A >> B >> K;

	for (int i = B; i >= 1; i--) {
		if (A % i == 0 && B % i == 0) {
			k[count] = i;
			count++;
		}
	}

	cout << k[K];

	return 0;
}


Measured memory_bytes: 256
count = 0
l = []
for i in range(5):
    A = input()
    if int(A[-1]) != 0:
        l.append(int(A[-1]))
        A = round(int(A)+5,-1)
    count = count + int(A)
print(count+(-10 + min(l) if l else 0 ))

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }
  
  
  for (int i = 0; i < H; i++) {
    bool is_all_dot = false;
    for (int j = 0; j < W; j++) {
      if (table.at(i).at(j) == '#') {
        break;
      }
      if (j == W - 1) {
        is_all_dot = true;
      }
    }
    if (is_all_dot) {
      table.erase(table.begin() + i);
      i--;
      H--;
    }
  }
  
    
  for (int i = 0; i < W; i++) {
    bool is_all_dot = false;
    for (int j = 0; j < H; j++) {
      if (table.at(j).at(i) == '#') {
        break;
      }
      if (j == H - 1) {
        is_all_dot = true;
      }
    }
    if (is_all_dot) {
      for (int j = 0; j < H; j++) {
        table.at(j).erase(table.at(j).begin() + i);
      }
      i--;
      W--;
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << table.at(i).at(j);
      if (j == W - 1) {
        cout << endl;
      }
    }
  }

  
}


Measured memory_bytes: 3564
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>


using namespace std;


typedef long long ll;
	ll n;
	ll a[100000];
	ll tmp;
	ll A, B, C;



int main() {

	

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0)A++;
		else if (a[i] % 2 == 0)B++;
		else C++;
	}

	if (B==0) {
		if (A>=C-1) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (A >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e5+50,P=1e9+7;
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
 
int n,m,v,p,a[N];
bool chk(int pos){
	if(a[pos]+m<a[p])return false;
	ll sum=1ll*(p-1+n-pos)*m;
	dec(i,pos-1,p)sum+=a[pos]+m-a[i];
	return sum>=1ll*m*(v-1);
}

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n),read(m),read(v),read(p); 
	rep(i,1,n)read(a[i]); 
	sort(a+1,a+n+1); 
	reverse(a+1,a+n+1); 
	int l=p,r=n+1; 
	while(r-l>1){
		int mid=(l+r)>>1; 
		if(chk(mid))l=mid;else r=mid;
	}
	printf("%d\n",l); 
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a[100],b[100],sa,sb,mi,mj,i,j,n,m,min;
  while(scanf("%d %d",&n,&m),n||m){
    for(i=sa=0;i<n;i++){
      scanf("%d",&a[i]);
      sa+=a[i];
    }
    for(i=sb=0;i<m;i++){
      scanf("%d",&b[i]);
      sb+=b[i];
    }
    min=10000000;
    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	if(sa-a[i]+b[j]!=sb-b[j]+a[i])continue;
	if(min>a[i]+b[j])min=a[mi=i]+b[mj=j];
      }
    }
    if(min==10000000)printf("-1\n");
    else             printf("%d %d\n",a[mi],b[mj]);
  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
int main()
{
  ll ans=1;
  ll n;
  cin>>n;
  for(ll i=2;i<=n;i++)
  {
    ans=(ans*i)%mod;
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9 + 7;
int n, k;
map<int, ll> f;

ll add(ll x, ll y) {
	return (x + y + mod) % mod;
}

void Add(ll &x, ll y) {
	x = (x + y + mod) % mod;
}

ll mul(ll x, ll y) {
	return (x * y) % mod;
}

void Mul(ll &x, ll y) {
	x = (x * y) % mod;
}

ll q_pow(ll x, int y) {
	ll ans = 1;
	for(; y; y >>= 1) {
		if(y & 1) Mul(ans, x);
		Mul(x, x);
	}
	return ans;
}

ll get(int x) {
	if(!f.count(x)) {
		int len = sqrt(x);
		ll pos = q_pow(k, (x / 2) + (x & 1));
		for(int i = 2; i <= len; ++i) {
			if(x % i) continue;
			Add(pos, -get(i));
			if(i * i != x) Add(pos, -get(x / i));
		}
		if(x != 1) Add(pos, -k);
		return f[x] = pos;
	} else return f[x];
}

int main() {
	scanf("%d%d", &n, &k);
	int len = sqrt(n);
	ll ans = 0;
	for(int i = 1; i <= len; ++i) {
		if(n % i) continue;
		if(i & 1) Add(ans, mul(i, get(i)));
		else Add(ans, mul(i / 2, get(i)));
		if(i * i != n) {
			int now = n / i;
			if(now & 1) Add(ans, mul(now, get(now)));
			else Add(ans, mul(now / 2, get(now)));
		}
	}
	printf("%lld\n", (ans + mod) % mod);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace  std;
#define ll long long
#define vll vector<long long>
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define nitro   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    nitro;
    ll s,w;
    cin>>s>>w;
    if(w>=s)
        cout<<"unsafe";
    else cout<<"safe";

}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll mod_pow(ll x, ll n) {
   ll res = 1;
   while (n > 0) {
      if (n & 1) res = (res * x) % MOD;
      x = x * x % MOD;
      n >>= 1;
   }
   return res;
}
ll dp[100005];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n, k;
   cin >> n >> k;
   rep(i, 1, k + 1) {
      ll cnt = k / i;
      dp[i] = mod_pow(cnt, n);
   }
   ll ans = 0;
   rrep(i, k, 1) {
      for (int j = 2 * i; j <= k; j += i) {
         dp[i] -= dp[j];
      }
      dp[i] %= MOD;
      ans += dp[i] * i;
      ans %= MOD;
   }
   if (ans < 0) ans += MOD;
   cout << ans << endl;
   return 0;
}

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

int main()
{
	long long N;
	while(cin >> N, N)
	{
		int s = 1;
		int X[32] = {0};

		if(N<0)
		{
			s = -1;
			N = -N;
		}

		for(int i=0; i<31; N/=10,s*=-1,i++)
		{
			X[i] += s*(N%10);

			if(X[i]<0)
			{
				X[i]   += 10;
				X[i+1] +=  1;
			}

			if(X[i]>9)
			{
				X[i]   -= 10;
				X[i+1] -=  1;
			}
		}

		
		for(int i=31,s=0; i>=0; i--)
		{
			if(X[i]!=0)
			{
				s=1;
			}

			if(s)
			{
				cout << X[i];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define in_range(x,l,r) (l<=x && x<r)
using namespace std;
typedef pair<int,int> pii;

const int INF = 1e9+7;
const int dy[] = {-1,-1,0,1,1,1,0,-1}, dx[] = {0,1,1,1,0,-1,-1,-1};

bool check(int y, int x, int k, vector< vector<int> > &d, int t){
  int h = d.size(), w = d[0].size();
  int cnt = 0;
  rep(i,8){
    int ny = y+dy[i], nx = x+dx[i];
    if(!in_range(ny,0,h) || !in_range(nx,0,w))continue;
    if(d[ny][nx] <= t)cnt++;
  }
  //cout << y << " " << x << " " << cnt << endl;

  return (k <= cnt);
}

int main(){
  int h,w;
  cin >> h >> w;

  vector<string> g(h);
  vector< vector<int> > d(h,vector<int>(w,INF));

  queue<pii> q;
  rep(i,h){
    cin >> g[i];
    rep(j,w){
      if(g[i][j] == '.'){
	q.push(pii(i,j));
	d[i][j] = 0;
      }
    }
  }

  int res = 0;
  while(q.size()){
    pii p = q.front(); q.pop();
    int y = p.first, x = p.second;

    res = max(res, d[y][x]);

    rep(i,8){
      int ny = y+dy[i], nx = x+dx[i];      
      if(!in_range(ny,0,h) || !in_range(nx,0,w))continue;
      
      if(g[ny][nx] != '.' && check(ny,nx,g[ny][nx]-'0',d,d[y][x])){
	g[ny][nx] = '.';
	d[ny][nx] = d[y][x] + 1;
	q.push(pii(ny,nx));
      }
    }
  }
  /*
  rep(i,h){
    rep(j,w)cout << d[i][j] << " ";
    cout << endl;
  }
  */

  cout << res << endl;
}

Measured memory_bytes: 6284
n = int(input())
l = list(map(int,input().split()))
sa = []
for i in range(n-1):
    sa.append(l[i+1]-l[i])

mod = 10**9+7
ans = 0
count = 0
kai = 1
for i in range(1,n):
    kai *= i
    kai %= mod
    
for i in range(n-1):
    count += pow((i+1),mod-2,mod)
    
    ans += sa[i]*count
    ans %= mod


print(int(kai*ans%mod))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)

void solve(){
	ll n,d;
	cin >> n >> d;
	ll count = 0;
	while(n--){
		ll ele1,ele2;
		cin >> ele1 >> ele2;
		double ele = sqrt(pow(ele1,2)+pow(ele2,2));
		if(ele<=d) count++;
	}
	cout<<count;
	return;
}
int main()
{
	fast;
	// int test;
	// cin >> test;
	// while(test--){
		solve();
	// 	cout<<"\n";
	// }
}

Measured memory_bytes: 3696
#include <stdio.h>
int main(void) {
  while(1) {
    int n, x;
    int count = 0;
    scanf("%d %d\n", &n, &x);
    if ((n == 0) && (x == 0)) break;
    {
      int i, j, k;
      for (i = 1; i <= (x-2); i++)
        for (j = i + 1; (i + j) <= (x-1); j++)
          for (k = j + 1; ((i + j + k) <= x) && (k <= n); k++)
            if ((i + j + k == x) && (i != j) && (j != k) && (i != k)) {
              //              printf("%d + %d + %d = %d\n", i, j, k, x);
              count++;
            }
    }
    printf("%d\n", count);
  }
  return 0;
}

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

typedef long long ll;

int main() {
    int N, A, B, c = 0, d = 0;
    string S;
    cin >> N >> A >> B >> S;
    rep(i, S.size()) {
        if (S[i] == 'a') {
            if (c < A + B) {
                cout << "Yes\n";
                c++;
            } else {
                cout << "No\n";
            }
        } else if (S[i] == 'b') {
            if (c < A + B && d < B) {
                cout << "Yes\n";
                c++;
                d++;
            } else {
                cout << "No\n";
            }
        } else {
            cout << "No\n";
        }
    }
}

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

using namespace std;

int N, M, a[102];
vector < int > sol;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
for (int i=1; i<=M; i++)
    scanf ("%d", &a[i]);
for (int i=2; i<M; i++)
    if (a[i] % 2 == 1)
    {
        if (a[1] % 2 == 0) swap (a[1], a[i]);
        else
        if (a[M] % 2 == 0) swap (a[M], a[i]);
    }
int oddCount = 0;
for (int i=1; i<=M; i++)
    oddCount += a[i] % 2;
if (oddCount > 2)
{
    printf ("Impossible\n");
    return 0;
}
if (M == 1)
{
    if (N == 1) printf ("1\n1\n1\n");
    else printf ("%d\n2\n%d %d\n", N, 1, N - 1);
    return 0;
}
for (int i=1; i<=M; i++)
{
    printf ("%d ", a[i]);
    int curr = (a[i] + (i == 1) - (i == M));
    if (curr > 0) sol.push_back (curr);
}
printf ("\n%d\n", sol.size ());
for (auto it = sol.begin (); it != sol.end (); it ++)
    printf ("%d ", *it);
printf ("\n");
return 0;
}


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int t[4],n[4];

  for(int i=0;i<4;i++){

    cin>>t[i]>>n[i];

    if(t[i]==1){
      cout<<n[i]*6000<<endl;
    }else if(t[i]==2){
      cout<<n[i]*4000<<endl;
    }else if(t[i]==3){
      cout<<n[i]*3000<<endl;
    }else if(t[i]==4){
      cout<<n[i]*2000<<endl;
    }
  }
  return 0;

}



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

using namespace std;

void Solve(){
    int n;
    cin>>n;
    long long res = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                int x = __gcd(i, j);
                x = __gcd(x, k);
                res += x;
            }
        }
    }
    cout<<res<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test_case = 1;
    //cin>>test_case;
    while(test_case--){
        Solve();
    }
}

Measured memory_bytes: 3648
def main():
    n = int(input())
    abc = [list(map(int,input().split())) for _ in range(n)]

    # min -> inf, max -> -1
    #dp = [[-1]*3]*n # <-NGNGNGNG
    dp = [[-1]*3 for _ in range(n)]

    # shoki joken
    dp[0] = abc[0]
    for i in range(1,n):
        # j != k
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i][j] = max(dp[i][j],dp[i-1][k]+abc[i][j])

    print(max(dp[-1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 74264
#include<bits/stdc++.h>
using namespace std;
int n,mn[205],arr[205],type=0;
char s[55][55];
int main()
{
	for(int i='a';i<='z';i++)
	{
		mn[i]=1e9;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		memset(arr,0,sizeof arr);
		for(int j=1;s[i][j];j++)
		{
			++arr[s[i][j]];
		}
		for(int j='a';j<='z';j++)
		{
			mn[j]=min(mn[j],arr[j]);
		}
	}
	for(int i='a';i<='z';i++)
	{
		if(mn[i]!=0)
		{
			type=1;
		}
	}
	if(type==0)
	{

	}else
	{
		for(int i='a';i<='z';i++)
		{
			for(int j=1;j<=mn[i];j++)
			{
				printf("%c",i);
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 3672
import sys, math, collections, heapq, itertools
sys.setrecursionlimit(100000000)
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b

def bfs(initialnode, edge, nodeNum):
    visited = [False] * nodeNum
    dist = []
    search_que = collections.deque()
    search_que.append((0, initialnode))
    count = 0
    while count < nodeNum:
        nowDist, nowNode = search_que.popleft()
        if not visited[nowNode]:
            visited[nowNode] = True
            dist.append((nowDist, nowNode))
            count += 1
            for nextNode in edge[nowNode]:
                if not visited[nextNode]:
                    search_que.append((nowDist+1, nextNode))
    return dist[-1]


def solve():
    N = int(single_input())
    Edge = [[] for i in range(N)]
    for _ in range(N-1):
        a, b = map(int, line_input())
        Edge[a-1].append(b-1)
        Edge[b-1].append(a-1)

    most_far_from_zero = bfs(0, Edge, N)
    tree_d, node_on_otherside = bfs(most_far_from_zero[1], Edge, N)

    if tree_d % 3 == 1: print("Second")
    else: print("First")
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 61916
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  ll N, A, B;
  cin >> N >> A >> B;
  if (A % 2 == 0 && B % 2 == 0)
  {
    cout << (B - A) / 2 << endl;
    return 0;
  }
  else if (A % 2 != 0 && B % 2 != 0)
  {
    cout << (B - A) / 2 << endl;
    return 0;
  }
  cout << min(A - 1LL, N - B) + 1 + (B - A - 1LL) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
typedef pair<P,int>P2;
struct RSQ{
  int n=(1<<17),data[(1<<18)];
  RSQ(){
    memset(data,0,sizeof(data));
  }
  // 0 index
  void add(int i,int v){
    i++;
    while(i<=n){
      data[i]+=v;
      i+=i&-i;
    }
  }
  int sum(int i){
    int res=0;
    while(i>0){
      res+=data[i];
      i-=i&-i;
    }
    return res;
  }
  //[a,b) 
  int sum(int x,int y){
    return sum(y)-sum(x);
  }
};

struct Sweap{
    int n;
    vector<int>ye,ys,xs,xe;
    vector<P2>vx,vy;
    Sweap(vector<int>X1,vector<int>X2,vector<int>Y1,vector<int>Y2,int sz,int flag_zaatsu){
        n=sz;xs=X1;xe=X2;ys=Y1;ye=Y2;
        if(flag_zaatsu!=0)zaatsu();
        for(int i=0;i<n;i++){
            if(ys[i]>ye[i])swap(ys[i],ye[i]);
            if(xs[i]>xe[i])swap(xs[i],xe[i]);
            if(xs[i]==xe[i]){
                vx.push_back(P2(P(xs[i], 2), i));
                vy.push_back(P2(P(ys[i], 1), i));
                vy.push_back(P2(P(ye[i], 3), i));
            }
            else{
                vx.push_back(P2(P(xs[i], 1), i));
                vx.push_back(P2(P(xe[i], 3), i));
                vy.push_back(P2(P(ys[i], 2), i));
            }
        }
        sort(vx.begin(),vx.end());
        sort(vy.begin(),vy.end());
    }
    void zaatsu(){
        map<int,int>Mx,My;
        vector<int>tvx,tvy;
        for(int i=0;i<n;i++){
            tvx.push_back(xs[i]);
            tvx.push_back(xe[i]);
            tvy.push_back(ys[i]);
            tvy.push_back(ye[i]);
        }
        sort(tvx.begin(),tvx.end());
        sort(tvy.begin(),tvy.end());
        tvx.erase(unique(tvx.begin(),tvx.end()),tvx.end());
        tvy.erase(unique(tvy.begin(),tvy.end()),tvy.end());
        for(int i=0;i<tvx.size();i++)Mx[tvx[i]]=i;
        for(int i=0;i<tvy.size();i++)My[tvy[i]]=i;
        for(int i=0;i<n;i++){
            xs[i]=Mx[xs[i]];
            xe[i]=Mx[xe[i]];
            ys[i]=My[ys[i]];
            ye[i]=My[ye[i]];
        }
    }
    int build(){
        RSQ rsq;
        int sum=0;
        for(int i=0;i<vx.size();i++){
            int id=vx[i].second;
            int seed=vx[i].first.second;
            if(seed==1){
                rsq.add(ys[id],1);
            }
            else if(seed==3){
                rsq.add(ye[id],-1);
            }
            else{
                sum+=rsq.sum(ys[id],ye[id]+1);
            }
            //cout<<id<<' '<<seed<<' '<<sum<<"    "<<vx[i].first.first<<endl;
        }
        return sum;
    }
};
 
 
int main(){
    int n;
    scanf(" %d", &n);
    vector<int>X1(n),X2(n),Y1(n),Y2(n);
    for(int i = 0; i < n; i++)cin>>X1[i]>>Y1[i]>>X2[i]>>Y2[i];
    Sweap s(X1,X2,Y1,Y2,n,1);
    cout<<s.build()<<endl;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int n;
    cin>>n;
    ll a[n+10];
    ffor(i,0,n) cin>>a[i];
    if(n==2)
    {
        cout<<max(a[0],a[1]);
        return 0;
    }

    ll dp[n+10][3];

    ffor(i,n,n+10) 
    {
        a[i]=-1e17;
        dp[i][0]=dp[i][1]=dp[i][2]=-1e17;
    }
    mem(dp,0);
    dp[n-1][0]=a[n-1];
    dp[n][1]=0;
    dp[n+1][2]=0;

    bfor(i,n,0)
    {
        dp[i][0]=a[i]+dp[i+2][0];
        dp[i][1]=max(dp[i+3][0]+a[i],dp[i+2][1]+a[i]);
        dp[i][2]=max({dp[i+3][1]+a[i],dp[i+4][0]+a[i],dp[i+2][2]+a[i]});
        
    }

   // ffor(i,0,n) cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    
    if(n&1)
    {
        cout<<max({dp[0][0],dp[0][1],dp[0][2],dp[1][0],dp[1][1],dp[2][0]});
    }
    else cout<<max({dp[0][0],dp[0][1],dp[1][0]});

    return 0;
}



Measured memory_bytes: 9844
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int pre = 0;
		int now = 0;
		Boolean result = true;
		pre = sc.nextInt() - 1;
		for(int i = 1 ; i < n ; i++){
			now = sc.nextInt();
			if(now < pre){
				result = false;
				break;
			}else if(now == pre){
				pre = now;
			}else{
				pre = now-1;
			}
		}	

		if(result){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 46320
while True:
	h,w=map(int, input().split())
	if h==0 and w==0:
		break
	for i in range(h):
		for j in range(w):	
			if i==0 or i==h-1 or j==0 or j==w-1:
				print("#",end="")
			else:
				print(".",end="")
		print()					
	print()


Measured memory_bytes: 7000