akhauriyash/Code-Regression huggingface dataset:
#include <map>  
#include <set>  
#include <cstdio>  
#include <cmath>  
#include <cstring>  
#include <vector>  
#include <queue>  
#include <iostream>  
#include <string>  
#include <sstream>  
#include <cstdlib>  
#include <ctime>  
#include <cctype>  
#include <algorithm>  
using namespace std;  
  
  
#define pb push_back  
#define mp make_pair  
#define fillchar(a, x) memset(a, x, sizeof(a))  
#define copy(a, b) memcpy(a, b, sizeof(a))  
#define S_queue<P> priority_queue<P, vector<P>,greater<P> >  
#define FIN freopen("D://imput.txt", "r", stdin)  
  
  
typedef long long LL;  
typedef pair<int, int > PII;  
typedef unsigned long long uLL;  
template<typename T>  
void print(T* p, T* q, string Gap = " "){int d = p < q ? 1 : -1;while(p != q){cout << *p;p += d;if(p != q) cout << Gap; }cout << endl;}  
template<typename T>  
void print(const T &a, string bes = "") {int len = bes.length();if(len >= 2)cout << bes[0] << a << bes[1] << endl;else cout << a << endl;}  
  
const int INF = 0x3f3f3f3f;  
const int MAXM = 2e1 + 5;  
const int MAXN = 1e2 + 5;  
const double eps = 1e-8;  
int A[MAXM], n;  
double M;  
  
bool DFS(int x, int id, double Max, double m){
    if(id >= n) {  
        M = min(Max, M); 
        return true;  
    }  
    bool flag = false;  
    int f = (int)(A[id] * m);  
    int cnt = 1,Ma = A[id] + f,Mi = A[id] - f > 1 ? A[id] - f: 1;  
    while(cnt * x <= Ma){  
        if(cnt * x < Mi) {  
            cnt ++;  
            continue;  
        }  
        if(cnt * x >= Mi && cnt * x <= Ma){  
            double f_t = fabs(cnt * x - A[id]) / A[id] * 1.0;  
            if(DFS(cnt * x, id + 1, max(Max, f_t), m)) {  
                    flag = true;  
            }  
        }  
        cnt ++;  
    }  
    return flag;  
}  
  
bool C(double m){  
    bool flag = false;  
    int f = (int)(A[0] * m);  
    int Mi = A[0] - f > 1? A[0] - f : 1, Ma = A[0] + f;  
    for(int i = Mi;i <= Ma;i ++){  
        if(DFS(i, 1, fabs(A[0] - i) / A[0] * 1.0, m)) {  
                flag = true;  
        }  
    }  
    return flag;  
}  
  
int main(){  
    //FIN;  
    while(cin >> n){  
        for(int i = 0;i < n;i ++){  
            cin >> A[i];  
        }  
        M = INF;  
        double lb = -1,ub = 1.0;  
        while(ub - lb > eps){  
            double mid = (ub + lb) / 2.0;  
            if(C(mid)) ub = mid;  
            else lb = mid;  
        }  
        printf("%.12lf\n", M);  
    }  
    return 0;  
}  

Measured memory_bytes: 1188
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
	string str;

	cin >> str;

	for (int i = 0; i < 4; i++)
		str[i] -= '0';

	int sum = 7 - str[0];
	if (+str[1] + str[2] + str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '+', str[1], '+', str[2], '+', str[3]);
	else if (+str[1] + str[2] - str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '+', str[1], '+', str[2], '-', str[3]);
	else if (+str[1] - str[2] + str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '+', str[1], '-', str[2], '+', str[3]);
	else if (+str[1] - str[2] - str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '+', str[1], '-', str[2], '-', str[3]);
	else if (-str[1] + str[2] + str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '-', str[1], '+', str[2], '+', str[3]);
	else if (-str[1] + str[2] - str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '-', str[1], '+', str[2], '-', str[3]);
	else if (-str[1] - str[2] + str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '-', str[1], '-', str[2], '+', str[3]);
	else if (-str[1] - str[2] - str[3] == sum) printf("%d%c%d%c%d%c%d=7\n", str[0], '-', str[1], '-', str[2], '-', str[3]);

	return 0;
}

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

int main()
{
    int a,b,c,S;
    cin>>S;
    a=S/3600;
    b=(S%3600)/60;
    c=S%60;

    cout<<a<<':'<<b<<':'<<c<<endl;
    return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
long long n,k,s[101010],minv=2000000200;
bool jud(long long a,long long b)
{
	if((a<=0&&b<=0)||(a>=0&&b>=0))return true;
	else return false;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=1;i<=(n-k+1);i++)minv=min(minv, jud(s[i],s[i+k-1]) ? max(abs(s[i]),abs(s[i+k-1])) : min( abs(s[i]),abs(s[i+k-1]) )*2+max( abs(s[i]),abs(s[i+k-1]) ) );
	cout<<minv;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int Maxn = 100000 + 100;
LL A[Maxn], Sum[Maxn];
LL N;
int main()
{
	scanf("%lld", &N);
	for (LL i = 1; i <= N; ++i) scanf("%lld", &A[i]);
	sort(A + 1, A + N + 1);
	for (LL i = 1; i <= N; ++i)
		Sum[i] = Sum[i - 1] + A[i];
	LL Ans = 1;
	for (LL i = N - 1; i >= 1; --i)
		if (2 * Sum[i] >= A[i + 1]) ++ Ans;
		else break;
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[101000];
    long long k,m,n;
    cin>>a;
    n=strlen(a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='e')      
        {
            if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e')       //erase或eraser
            {
                if(a[i+5]=='r')      
                {
                    i+=5;
                }
                else        
                {
                    i+=4;
                }
            }
        }
        else if(a[i]=='d')         
        {
            if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m')    
            {
                if(a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'&&a[i+8]=='s'&&a[i+9]=='e')     
                {
                    i+=4;
                }
                else
                {
                    if(a[i+5]=='e'&&a[i+6]=='r')     
                    {
                        i+=6;
                    }
                    else
                    {
                        i+=4;
                    }
                }
            }
        }
        else     
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;      
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	int n; cin>>n;
	VL a(n), b(n); rep(i,n) cin>>a[i]>>b[i];
	sort(ALL(a)); sort(ALL(b));
	if(n%2==1){
		cout<<b[(n-1)/2]-a[(n-1)/2]+1<<endl;
	}else{
		ll ans;
		if(b[n/2-1]<a[n/2]){
			ans=(b[n/2]+b[n/2-1])-(a[n/2-1]+a[n/2])+1;
		}else{
			ans=(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1;
		}
		// ll ans=(b[n/2]-a[n/2-1])*2-1;
		// if(b[n/2-1]<a[n/2]) ans-=(a[n/2]-b[n/2-1])*2
		// if(a[n/2]==a[n/2-1]) ans++;
		// if(b[n/2]==b[n/2-1]) ans++;
		cout<<ans<<endl;
	}

	return 0;
}


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

typedef pair<int,int> pii;
typedef pair<int,pii > pipii;

void solve();

int H,W,K;
int fid[1000][1000] = {0};
int sx,sy;
int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
int minx = 1000,maxx = -1,miny = 1000,maxy = -1;

int main()
{
    scanf("%d%d%d",&H,&W,&K);
    for(int i = 0; i < H; i++)
    {
        for(int j = 0; j < W; j++)
        {
            char c;
            scanf(" %c",&c);
            if(c == '#')
            {
                fid[i][j] = -1;
            }
            if(c == 'S')
            {
                sx = j;
                sy = i;
            }
        }
    }
    solve();
    return 0;
}

void solve()
{
    queue<pipii> Q;
    Q.push(make_pair(K,make_pair(sy,sx)));
    while(Q.size())
    {
        pipii now = Q.front();
        Q.pop();
        if(fid[now.second.first][now.second.second])continue;
        fid[now.second.first][now.second.second] = now.first;
        if(now.second.first < minx)minx = now.second.first;
        if(now.second.first > maxx)maxx = now.second.first;
        if(now.second.second < miny)miny = now.second.second;
        if(now.second.second > maxy)maxy = now.second.second;
        if(now.first == 0)continue;
        for(int i = 0; i < 4; i++)
        {
            int x = now.second.first + dx[i],
                y = now.second.second + dy[i];
            if(0 <= x && x < H && 0 <= y && y < W)
            {
                Q.push(make_pair(now.first - 1,make_pair(x,y)));
            }
        }
    }
    int ans = min(min(minx,H - maxx - 1),min(miny,W - maxy - 1));
    printf("%d",(ans + K - 1) / K + 1);
    return;
}


Measured memory_bytes: 3456
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<int> retval;
		retval.reserve(num);

		for (int i = 0; i < num; ++i)
		{
			std::getline(stream, buf, delim);
			retval.push_back(std::stoi(buf));
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num; ++i)
		{
			std::getline(sstr, buf, delim);
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}

	int gCount = 0;

	void InsertionSort(std::vector<int>& sequence, int step)
	{
		for (size_t i = step; i < sequence.size(); ++i)
		{
			int v = sequence[i];
			int j = i - step;

			while (0 <= j && v < sequence[j])
			{
				sequence[j + step] = sequence[j];
				j -= step;
				++gCount;
			}

			sequence[j + step] = v;
		}
	}

	void ShellSort(std::vector<int>& sequence)
	{
		std::vector<int> ar = { 1 };
		while (true)
		{
			size_t t = ar.back() * 3 + 1;

			if (sequence.size() <= t)
			{
				break;
			}

			ar.push_back(t);
		}
		std::reverse(ar.begin(), ar.end());

		for (int e : ar)
		{
			InsertionSort(sequence, e);
		}

		std::cout << ar.size() << '\n';
		PrintLine(ar);
		std::cout << gCount << '\n';

	}
}

int main(int argc, char* argv[])
{
	auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;

	int num = GetValue<1>(stream)[0];
	std::vector<int> values = GetValue(stream, num, '\n');

	ShellSort(values);

	Print(values);
}



Measured memory_bytes: 6840
# include"stdio.h"
int main(void){
  int a,b,c;
  scanf("%d %d",&a,&b);
  if(a>b){
      if((a-b)>=2) c=a+a-1;
      if((a-b)==1) c=a+b;
  }
   if(a<b){
      if((b-a)>=2) c=b+b-1;
      if((b-a)==1) c=a+b;
  }
  if(a==b){
    c=a+a;
  }
  printf("%d",c);
  return 0;
}

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

const int SIZE=310;
const int INF=1001001001;
int sumR[SIZE][SIZE];
int sumC[SIZE][SIZE];

int main()
{
    int N; cin>>N;
    vector<vector<int> > a(N, vector<int>(N));
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin>>a[i][j];
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            sumR[i][j+1]=sumR[i][j]+a[i][j];
        }
    }
    for(int j=0;j<N;j++){
        for(int i=0;i<N;i++){
            sumC[j][i+1]=sumC[j][i]+a[i][j];
        }
    }
/*
    for(int i=0;i<N;i++){
        for(int j=0;j<N+1;j++){
            cout<<sumR[i][j]<<' ';
        }
        cout<<endl;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N+1;j++){
            cout<<sumC[i][j]<<' ';
        }
        cout<<endl;
    }
*/
    int ans=-INF;
    for(int y1=0;y1<N;y1++){
        for(int x1=0;x1<N;x1++) for(int x2=x1;x2<N;x2++){
            int tmp=sumR[y1][x2+1]-sumR[y1][x1];
            ans=max(ans, tmp);
        }
    }
    for(int x1=0;x1<N;x1++){
        for(int y1=0;y1<N;y1++) for(int y2=y1;y2<N;y2++){
            int tmp=sumC[x1][y2+1]-sumC[x1][y1];
            ans=max(ans, tmp);
        }
    }

    for(int y1=0;y1<N;y1++) for(int y2=y1+1;y2<N;y2++){
        int diff=-INF;
        for(int x1=1;x1<N;x1++){
            int sum=sumC[x1][y2+1]-sumC[x1][y1]
                +sumR[y1][x1]+sumR[y2][x1];
            int dif=sumC[x1-1][y2]-sumC[x1-1][y1+1]
                -sumR[y1][x1-1]-sumR[y2][x1-1];
            diff=max(diff, dif);
            ans=max(ans, sum+diff);
        }
    }
    cout<<ans<<endl;
}



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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> A) {
  vector<vector<ll>> dp(N + 1, vector<ll>(2));
  dp.at(0).at(0) = 0;
  dp.at(0).at(1) = -LINF;

  rep(i, N) {
    dp.at(i + 1).at(0) =
        max(dp.at(i).at(0) + A.at(i), dp.at(i).at(1) - A.at(i));
    dp.at(i + 1).at(1) =
        max(dp.at(i).at(0) - A.at(i), dp.at(i).at(1) + A.at(i));
  }

  cout << dp.at(N).at(0) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 9592
fn main() {
    let v1=vec!["SUN","MON","TUE","WED","THU","FRI","SAT"];
    let mut i=0;
    let s ={
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap(); //1行読む。失敗を無視
        s.trim_right().to_owned()
    };
    for val in v1{
        if val == s
        {
            println!("{}",7-i);
        }
        i+=1;
    }
}


Measured memory_bytes: 2144
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    # 左から埋めていく場合と
    # 右から埋めていく場合
    #A = []
    #for i in range(n):
    #    A.append(int(input()))
    A = [int(input()) for _ in range(n)]

    left = [0] * (n+1)
    right = [0] * (n+1)
    for i in range(1,n):
        left[i] = max(left[i-1],A[i-1])
    for i in range(n-2,-1,-1):
        right[i] = max(right[i+1],A[i+1]) # right[i]なのか
    for i in range(n):
        print(max(left[i],right[i]))
if __name__ == '__main__':
  main()


Measured memory_bytes: 15712
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
  string s,t;
  cin>>s>>t;
  if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,pri[maxn],tot,vis[maxn],a[550][550];

void gen() {
    for(int i=2;tot<=n*2;i++) {
        if(!vis[i]) vis[i]=1,pri[++tot]=i;
        for(int j=1;j<=tot&&i*pri[j]<=10000;j++) {
            vis[i*pri[j]]=1;
            if(i%pri[j]==0) break;
        }
    }
}

int lcm(int a,int b) {return !min(a,b)?max(a,b):a/__gcd(a,b)*b;}

signed main() {
    read(n);gen();int p=1;
    if(n==2) return puts("4 7\n23 10"),0;
    for(int x=n&1?n-1:n-2;x>=-n+1;x-=2) {
        for(int i=1;i<=n;i++) {
            int j=i+x;
            if(j>n||j<1) continue;
            a[i][j]=pri[p];
        }
        p++;
    }
    for(int x=2;x<=n*2;x+=2) {
        for(int i=1;i<=n;i++) {
            int j=-i+x;
            if(j>n||j<1) continue;
            a[i][j]*=pri[p];
        }
        p++;
    }
    for(int i=1;i<=n;i++,puts("")) 
        for(int j=1;j<=n;j++) {
            if(!a[i][j]) {
                a[i][j]=lcm(a[i][j-1],a[i][j+1]);
                a[i][j]=lcm(lcm(a[i-1][j],a[i+1][j]),a[i][j])+1;
            }
            printf("%lld ",a[i][j]);
        }
    return 0;
}


Measured memory_bytes: 9216
#include<iostream>

using namespace std;
typedef long long ll;

int main() {
	int a, b, c, N;
	cin >> a >> b >> c >> N;
	ll dp[3000 + 4000][4] = {};
	dp[0][3] = 1;
	for (int i = 0; i <= N ; i++) {
		dp[i + a][0] += dp[i][0];
		dp[i + a][0] += dp[i][3];

		dp[i + b][1] += dp[i][1];
		dp[i + b][1] += dp[i][0];
		dp[i + b][1] += dp[i][3];

		dp[i + c][2] += dp[i][2];
		dp[i + c][2] += dp[i][1];
		dp[i + c][2] += dp[i][3];
		dp[i + c][2] += dp[i][0];
	}
	cout << dp[N][0] + dp[N][1] + dp[N][2] << endl;
	return 0;
}

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


int ctoi(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

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

  
  int A=ctoi(S.at(0));
  int B=ctoi(S.at(1));
  int C=ctoi(S.at(2));
  int D=ctoi(S.at(3));
  
  int AB=A*10+B;
  int CD=C*10+D;
  
  if(1<=AB&&AB<=12&&1<=CD&&CD<=12){
    cout<<"AMBIGUOUS"<<endl;
  }else if(0<=AB&&AB<=99&&1<=CD&&CD<=12){
    cout<<"YYMM"<<endl;
  }else if(1<=AB&&AB<=12&&0<=CD&&CD<=99){
    cout<<"MMYY"<<endl;
  }else{
    cout<<"NA"<<endl;
  }
  
  
  
  
}


  
  
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

ll n, x, m;

int t[100009];

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

    cin >> n >> x >> m;

    ll ans = 0;
    int time = 0;
    while(!t[x]) {
        t[x] = ++time;
        ans += x;
        x = (x * x) % m;
        n--;
        if(n == 0) {
            cout << ans << endl;
            return 0;
        }
    }

    int cy = 0;
    ll cost = 0, y = x;
    do {
        cost += y;
        y = (y * y) % m;
        cy++;
    } while(y != x);

    ans += (n / cy) * cost;
    n %= cy;

    while(n--) {
        ans += x;
        x = (x * x) % m;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
vector<int> generate_primes(int n) {
    vector<bool> is_prime(n+1);
    vector<int> primes;
    fill(is_prime.begin(), is_prime.end(), true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++) {
        if(is_prime[i]) {
            primes.push_back(i);
            for(int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<int> primes = generate_primes(55'555);
    vector<int> primes1;
    for(int p : primes) {
        if(p % 10 == 1) {
            primes1.push_back(p);
        }
    }
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        if(i > 0) cout << " ";
        cout << primes1[i];
    }
    cout << endl;
    return 0;
}


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

typedef double dbl;
typedef long long ll;
const int N = 200001;
int a[N];

int main(void) {
    int n, k; scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    
    dbl l = 0, r = 1145141919;
    for (int i = 1; i <= 100; ++i) {
        dbl m = (l + r) / 2;
        ll cnt = 0;
        for (int j = 1; j <= n; ++j)
            cnt += round(ceil(a[j] / m)) - 1;
        if (cnt > k)
            l = m;
        else
            r = m;
    }
    printf("%d\n", (int)ceil(r));

    return 0;
}

Measured memory_bytes: 4536
n = int(input())
tasks = []
for i in range(n):
    tasks.append(tuple(map(int,input().split())))
tasks.sort(key=lambda x:x[1])

can = 1
curtime = 0
for task in tasks:
    curtime += task[0]
    if curtime > task[1]:
        can = 0
        break

if can:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 31808
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  int Ans=0;
  for(int i=0;i<S.length();i++)
    Ans=(Ans+S[i]-'0')%9;
  if(Ans)
    puts("No");
  else	puts("Yes");
  return 0;
}

Measured memory_bytes: 3716
// ------------------------------------
// Date:2018/ 3/10
// Problem:ABC 070 TwoSwitches b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int timetable[101];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  fill_n(timetable, 101, 0);
  
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int left = max(a, c);
  int right = min(b, d);
  int ans = right - left;

  if (ans < 0) ans = 0;

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



Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B := getInt(), getInt()

	if A+B >= 10 {
		out("error")
	} else {
		out(A + B)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long int
using namespace std;
void solve() {
    string str;
    cin >> str;
    set <char> s;
    for(int i=0;i<str.length();i++)
        s.insert(str[i]);
    if(s.size() == 2)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
    return ;
} 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    if(n>=1 && m>=2) {
        ll lim = m/2;
        ans += min(n,lim); //まずsのピースを使えるだけ使い切る
        m -= 2*min(n,lim);
    }
    ans += m/4;
    cout << ans << endl;
    
}

Measured memory_bytes: 3544
from itertools import permutations
from itertools import combinations
from math import sqrt
from math import factorial
from collections import defaultdict

N = int(input())

points = [list(map(int, input().split())) for _ in range(N) ]

length = defaultdict(float)
l_sum = 0
res = 0

for a, b in combinations(range(N),2):
    length[(a, b)] = (sqrt( (points[a][0] - points[b][0])**2 + (points[a][1] - points[b][1])**2 ))

for a in permutations(range(N)):
    for i in range(N-1):
        l_sum += length[(min(a[i], a[i+1]), max(a[i], a[i+1]))]

res = l_sum/factorial(N)

print(res)

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

int count(vector<int> v, int n){
  int cnt = 0;
  bool chk = true;
  
  while(chk){
    for(int i=0; i<n; i++){
      if(v.at(i)%2 == 1){
        chk = false;
        break;
      }
    }
    for(int i=0; i<n; i++){
      v.at(i) = v.at(i)/2;
    }
    cnt++;
  }
  
  return cnt-1;
}

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0; i<n; i++){
    cin >> v.at(i);
  }
  
  int cnt = count(v, n);
  cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

// const ll LL_INF = 1LL<<60;

template <class T> inline void chmin(T& a, T b) {if (a > b) {a = b;}}
template <class T> inline void chmax(T& a, T b) {if (a < b) {a = b;}}

using namespace std;


ll n;
char dic[1LL<<(2*12)];
ll dic_size;

inline int decode_ch(const char ch) {
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else return 4;
}

inline ll decode(const string& str) {
    ll num = 0;
    rep(i, str.size()) {
        num += (1LL<<(2*i)) * decode_ch(str[i]);
    }
    return num-1;
}

inline bool search(const ll& num) {
    if (dic[num]=='Y') return true;
    return false;
}

inline void insert(const ll& num) {
    dic[num] = 'Y';
}

int main() {
    cin >> n;
    dic_size = 0;

    rep(i, n) {
        string ord, str;
        cin >> ord >> str;
        if (ord == "insert") {
            insert(decode(str));
        } else {
            if(search(decode(str))) cout << "yes\n";
            else cout << "no\n";
        }
    }
}


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

using namespace std;

typedef long long int big;

int main(){
  big t=1;
//   cin>>t;
  while(t--){
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;  
  }
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define reprs(i, s, e) for(int i=s-1; i>=s; i--)

int main(){

    int n; cin >> n;
    int a, b, c; cin >> a >> b >> c;
    int l[n];
    rep(i, n){
        cin >> l[i];
    }

    int cbmax = pow(4, n);
    int ans = 1e9;
    rep(bit, cbmax){
        int tbit = bit;
        int choose[n];

        rep(i, n){
            choose[i] = tbit % 4;
            tbit /= 4;
        }

        // rep(i, n){
        //     cout << chose[i] << " ";
        // }
        // cout << endl;

        int k[n] = {};
        int synscnt[3] = {};
        rep(i, n){
            switch(choose[i]){
                case 0:
                    k[0] += l[i];
                    synscnt[0]++;
                    break;
                case 1:
                    k[1] += l[i];
                    synscnt[1]++;
                    break;
                case 2:
                    k[2] += l[i];
                    synscnt[2]++;
                    break;
            }
        }

        bool nextbit = false;
        rep(i, 3){
            if(k[i] == 0){
                nextbit = true;
                break;
            }
        }
        if(nextbit) continue;

        
        // rep(i, 3){
        //     cout << k[i] << " ";
        // }
        // cout << endl;

        int p[] = {0, 1, 2};
        do{
            int cand = accumulate(synscnt, synscnt+3, -3) * 10;
            cand += abs( k[p[0]] - a);
            cand += abs( k[p[1]] - b);
            cand += abs( k[p[2]] - c); 

            // if(cand < 30){
            // cout << k[0] << " " << k[1] << " " << k[2] << " ";
            // cout << a << " " << b << " " << c << " " << cand << endl;
            // }
            ans = min(ans, cand);
        }
        while(next_permutation(p, p+3));


    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args)throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] A=br.readLine().split("\\s+");
		LinkedList<Integer> stack=new LinkedList<Integer>();
		for (int i = 0; i < A.length; i++) {
			if ('0'<=A[i].charAt(0) && A[i].charAt(0)<='9') {
					int num=Integer.parseInt(A[i]);				
					stack.push(num);
			}else{
				
				int b=stack.pop();
				int a=stack.pop();
			    int c=0;
			    if('+'==A[i].charAt(0)){
			    	c=a+b;
			    }else if('-'==A[i].charAt(0)){
			    	c=a-b;
			    }else if('*'==A[i].charAt(0)){
			    	c=a*b;
			    }else{
			    	System.out.println("bad");
			    }
			    stack.push(c);		    
			}
			
		}
		System.out.println(stack.pop());
	}
}

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

typedef long long int int64;
static const int64 mod = 1000000007LL;

int pair[603];
int cnt[603];
int64 g[603];
int64 dp[603][603];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);n *= 2;
	for(int i = 0;i < n;++i) {
		pair[i] = -1;
	}
	for(int i = 0;i < m;++i) {
		int a,b;
		scanf("%d%d",&a,&b);--a,--b;
		pair[a] = b;pair[b] = a;
	}
	g[0] = 1;
	for(int i = 2;i <= n;i += 2) {
		g[i] = g[i-2] * (i-1) % mod;
	}
	for(int i = 0;i < n;++i) {
		cnt[i] = (i == 0 ? 0 : cnt[i-1]) + (pair[i] == -1 ? 1 : 0);
	}
	int64 ans = 0;
	for(int i = 0;i < n;++i) {
		int minpair = n;
		int maxpair = -1;
		for(int j = i;j < n;++j) {
			if(pair[j] != -1 && pair[j] < minpair) minpair = pair[j];
			if(pair[j] != -1 && pair[j] > maxpair) maxpair = pair[j];
			if(minpair < i) break;
			if(maxpair > j) continue;
			int u = cnt[j]-(i==0?0:cnt[i-1]);
			int64 val = g[u];
			for(int k = i;k < j;++k) {
				int u2 = cnt[j]-cnt[k];
				val -= dp[i][k] * g[u2] % mod;
			}
			val %= mod;
			if(val < 0) val += mod;
			dp[i][j] = val;
			ans += val * g[cnt[n-1]-u] % mod;
		}
	}
	printf("%lld\n", ans % mod);
}


Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


int main() {
    char a; cin >> a;
    if((int)a >= 65 && (int)a <= 90) cout << "A" << endl;
    else cout << 'a' << endl;
}




Measured memory_bytes: 3632
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * size
        self.rank = [1] * size
        self.groups = size

    def get_root(self, node):
        parent = self.parent[node]
        if parent == -1:
            root = node
        else:
            root = self.get_root(parent)
            self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
        return root

    def in_same_group(self, node1, node2):
        root1 = self.get_root(node1)
        root2 = self.get_root(node2)
        return root1 == root2

    def unite(self, node1, node2):
        if self.in_same_group(node1, node2):
            return
        main_root = self.get_root(node1)
        sub_root = self.get_root(node2)
        if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
            main_root, sub_root = sub_root, main_root

        self.parent[sub_root] = main_root
        self.rank[main_root] += self.rank[sub_root]
        self.groups -= 1


n, m = map(int, input().split())
uf = UnionFind(n)

for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.unite(x, y)

print(uf.groups)


Measured memory_bytes: 5936
while True:
    h, w = map(int, raw_input().split())
    if (h == 0) & (w == 0):
        break
    line0 = ""
    line1 = "."
    for i in range(w):
        if i % 2 == 0:
            line0 += "#"
        else:
            line0 += "."
    line1 += line0[:-1]

    for j in range(h):
        if j % 2 == 0:
            print line0
        else:
            print line1
    print ""

Measured memory_bytes: 6304
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

int main() {

	int n,a,b; 
	cin >> n >> a >> b;

	cout << (n - a) % b << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
   int low,diff;
   int cost=0;
   if(y<x)
   {
       low=y;
       diff=x-y;
   }
   else
   {
         low=x;
         diff=y-x;
   }

    if(a*low+b*low>c*2*low)
    {
        cost+=c*2*low;
    }
    else
        cost+=a*low+b*low;

    if(x>y)
    {
       if(diff*a>c*2*diff)
            cost+=c*2*diff;
       else
           cost+=diff*a;
    }
   else if(y>x)
    {
        if(diff*b>c*2*diff)
            cost+=c*2*diff;
       else
           cost+=diff*b;
    }

    cout<<cost<<endl;
}



Measured memory_bytes: 256
// D - Widespread
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define roundup(a,b) (((a)+(b)-1)/(b))

int main(){
	int N,A,B; cin>>N>>A>>B;
	vector<LL> H(N); rp(i, N) cin>>H[i];

	int ans = INT_MAX;
	LL ab = (LL)A - B;//additional damage
	int L = 0, R = 1e9;
	while(L <= R){
		int t = (L + R)/2;//mid
		LL tb = (LL)t * B;
		LL s = 0;
		rp(i, N){
			LL h = H[i] - tb;
			if(h > 0) s += roundup(h, ab);
		}
		if(t >= s){
			R = t - 1;//mid-1
			ans = t;
		}
		else L = t + 1;//mid+1
	}
	cout<< ans <<endl;
}

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

//関数



    
//main関数
int main() {
    
    
    //入力
    string S;
    cin>>S;
    
    
    
    
    //計算
    vector<long> alp(26);
    for(int i=0;i<S.size();i++){
        alp.at(S.at(i)-'a')++;
    }
    
    
    long remain=S.size(),ans=1;
    for(int i=0;i<S.size();i++){
        remain--;
        alp.at(S.at(i)-'a')--;
        ans+=(remain-alp.at(S.at(i)-'a'));
    }
    
    
    
    
    //出力
    cout<<ans<<endl;
}



Measured memory_bytes: 640
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
using namespace std;

int n,now;
vector<int>pos[1000005];

int modpow(int x,int y,const int md){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=ret*ret%md;if(y&1)ret=ret*x%md;return ret;}

inline int inv(int x){
	return modpow(x,998244351,998244353);
}

int calc(vector<int>vec){
	if(!vec.size())return 0;
	int sum=0;
	for(int i=0;i<vec.size();i++){
		sum+=vec[i];
	}
	sum%=998244353;
	int ret=sum*sum%998244353;
	for(int i=0;i<vec.size();i++){
		int sub=vec[i]*vec[i]%998244353;
		ret-=sub;if(ret<0)ret+=998244353;
	}
	return ret;
}

vector<pair<int,int> >factor;

void dfs(int p,int cur){
	if(p==factor.size()){
		pos[cur].push_back(now);
		return;
	}
	int Mul=1;
	for(int i=0;i<=factor[p].second;i++){
		dfs(p+1,cur*Mul);
		Mul*=factor[p].first;
	}
}

void init(int v){
	factor.clear();now=v;
	for(int i=2;i*i<=v;i++){
		if(v%i==0){
			pair<int,int>ins(i,0);
			while(v%i==0){
				v/=i;ins.second++;
			}
			factor.push_back(ins);
		}
	}
	if(v!=1)factor.push_back(make_pair(v,1)); 
	dfs(0,1);
}

int ans[1000005];

void solve(){
	for(int Gcd=1000000;Gcd>=1;Gcd--){
		ans[Gcd]=calc(pos[Gcd])%998244353;
		for(int Mul=Gcd+Gcd;Mul<=1000000;Mul+=Gcd){
			ans[Gcd]-=ans[Mul];
		}
		ans[Gcd]%=998244353;if(ans[Gcd]<0)ans[Gcd]+=998244353;
	}
	int fuck=0;
	for(int i=1;i<=1000000;i++){
		fuck+=ans[i]*inv(i);
		fuck%=998244353;
	}
	cout<<fuck*inv(2)%998244353<<endl;
}

signed main(){
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		init(a[i]);
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 111224
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    string s;
    cin>>s;

    for(auto c:s)
    {
        if(c=='7')
        {
            cout<<"Yes";
            return;
        }
    }

    cout<<"No";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string>

using namespace std;
 
int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;
	int siz = s.size();

	int K;
	cin >> K;	

	string ret = "";
	for(int i = 0;i < siz - 1;i++){
		if(s[i] == 97) {
			ret += "a";
			continue;
		}
		
		int c = s[i];
		if(K >= 123 - c){
			K -= 123 - c;
			ret += "a";
		}else{
			ret += s[i];
		}
	}

	K %= 26;
	int c = s[siz - 1];
	if(c + K >= 123){
		ret += (c + K - 123 + 97);
	}else{
		ret += (c + K);
	}

	cout << ret << endl;
}

Measured memory_bytes: 768
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }

    static void Solve() {
        int N = ScanInt(), M = ScanInt(), X = ScanInt();
        Span<int> C = stackalloc int[N];
        var spanA = new Span<int[]>(new int[N][]);
        for (int i = 0; i < N; i++) {
            C[i] = ScanInt();
            spanA[i] = ScanIntArray(M);
        }
        var answer = int.MaxValue;
        for (int bit = 0; bit < 1 << N; bit++) {
            var levels = new int[M];
            var cost = 0;
            for (int i = 0; i < N; i++) {
                if (((bit >> i) & 1) == 0) continue;
                cost += C[i];
                if (cost > answer) break;
                for (int j = 0; j < M; j++) {
                    levels[j] += spanA[i][j];
                }
            }
            if (cost > answer) continue; 
            var isAchieved = true;
            for (int j = 0; j < M; j++) {
                if (levels[j] >= X) continue;
                isAchieved = false;
                break;
            }
            if (isAchieved) answer = cost;
        }
        Console.WriteLine(answer == int.MaxValue ? -1 : answer);
    }
}

public static class Scanner
{
    static readonly Stream stdin = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte StdIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stdin.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = StdIn();
        while ((by < '!' || '~' < by) && !isEof) by = StdIn();
        return (char) by;
    }
    public static int ScanInt() {
        var temp = 0;
        for (var ch = GetChar(); '0' <= ch && ch <= '9'; ch = (char) StdIn()) {
            temp = temp * 10 + ch - '0';
        }
        return temp;
    }
    public static int[] ScanIntArray(int len, int add = 0) {
        var array = new int[len];
        for (int i = 0; i < len; i++) array[i] = ScanInt() + add;
        return array;
    }
}

Measured memory_bytes: 25592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
  int main(){
    lint N,Q;
    string s;
    cin>>N>>Q;
    if(N==Q)cout<<"Yes";
    else cout<<"No";

  }
  

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,s,d,f[10],h[10],i,j;
	char g[16][10];
	for(i=1;i<=9;i++){
		scanf("%s %d %d",g[i],&s,&d);
		f[i]=s*200+d*300;
		h[i]=s+d;
		printf("%s %d %d\n",g[i],h[i],f[i]);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[5];
int main() {
    while(~scanf("%d,%d,%d,%d,%d", &a[0], &a[1], &a[2], &a[3], &a[4])) {
        sort(a, a + 5);
        if((a[0] == a[1] || a[3] == a[4]) && a[1] == a[2] && a[2] == a[3]) printf("four card\n");
        else if((a[0] == a[1] && a[2] == a[3] && a[3] == a[4]) || (a[0] == a[1] && a[1] == a[2] && a[3] == a[4])) printf("full house\n");
        else if((a[0] + 1 == a[1] || (a[0] == 1 && a[1] == 10)) && a[1] + 1 == a[2] && a[2] + 1 == a[3] && a[3] + 1 == a[4]) printf("straight\n");
        else if(((a[0] == a[1] || a[2] == a[3]) && a[1] == a[2]) || (a[2] == a[3] && a[3] == a[4])) printf("three card\n");
        else {
            int p = 0; for(int i = 1; i < 5; i++) if(a[i - 1] == a[i]) p++;
            if(p == 2) printf("two pair\n");
            if(p == 1) printf("one pair\n");
            if(p == 0) printf("null\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2624
def resolve():
    X = int(input())
    if X >= 1800:
        print("1")
    elif X >= 1600:
        print("2")
    elif X >= 1400:
        print("3")
    elif X >= 1200:
        print("4")
    elif X >= 1000:
        print("5")
    elif X >= 800:
        print("6")
    elif X >= 600:
        print("7")
    elif X >= 400:
        print("8")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9180