akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
 int n;
 cin >> n;
 long int sum = 0;
 while (n > 0)
 {
     if(n % 3 == 0 || n % 5 == 0){
         sum += 0;
     }
     else sum += n;
     n--;
 }
 cout << sum << endl;
 }

  

  


Measured memory_bytes: 3624
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N=303;
const ll B=1e15;
ll dp[N][N];
int n,k,arr[N];
int who[N][N];
ll rec(int x,int y){
	if(y>k)
		return B;
	if(x==n+1)
		return 0;
	ll &ret=dp[x][y];
	if(~ret)
		return ret;ret=B;
	for(int i=x+1;i<=n+1;i++)
		if(umin(ret,rec(i,y+(i-x-1))+max(0,arr[i]-arr[x])))
			who[x][y]=i;
	return ret;	
}
/*
void print(int x,int y){
	cout<<x<<" "<<y<<endl;
	assert(y<=k);
	if(x==n+1)
		return;
	print(who[x][y],y+(who[x][y]-x-1));
}*/
int main(){
    //freopen("file.in", "r", stdin);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    	scanf("%d",arr+i);
    memset(dp,-1,sizeof dp);
    printf("%lld\n",rec(0,0));
    //print(0,0);
	return 0;
}


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

int main()
{
    iostream::sync_with_stdio(0);
    int n,i,j;
    cin>>n;
    vector <int>v(n);
    for(i=0;i<n;i++)
    {
        cin>>v[i];
    }
    int q;
    cin>>q;
     int k;
    while(q--)
    {
       
        cin>>k;
       cout<< binary_search(v.begin(),v.end(),k)<<endl;

    }
    //cout << "Hello world!" << endl;
    return 0;
}



Measured memory_bytes: 3376
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

total = 0;
for i in range(len(a)):
    total += b[a[i] - 1]
    if n - 1 == i: 
        continue
    elif a[i] + 1 == a[i + 1]: 
        total += c[a[i] - 1]

print(total)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

#define M 100000

using namespace std;

int main() {
    int n, a, ans = 0;
    scanf("%d", &n);
    vector<int> d(M);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        ++d.at(a);
    }
    for (int i = 0; i < M - 2; ++i) ans = max(ans, accumulate(d.begin() + i, d.begin() + i + 3, 0));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main{

    int n,m;
    int a,b;
    Main(){
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        while(n>0){
            n--;
            a=sc.nextInt();
            b=sc.nextInt();
            m=a%b;
            if(m==0)m=b;
            System.out.println(m);
        }


    }

    public static void main(String[] args){
        new Main();
    }
}

Measured memory_bytes: 20364
#include <iostream>

using namespace std;

int main()
{
    long a , b , x;
    cin >> x >> a >> b;
    if(-a + b <= 0){
            cout << "delicious" << endl;
    }
    else{
            if(-a + b <= x){
                    cout << "safe" << endl;
            }
            else{
                    cout << "dangerous" << endl;
            }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


#define FLD_BAR 9999999
#define FLD_INF 8888888


struct dir_t
{
	int k[4];
};

struct solve
{
	int vx[4]={ 1, 0,-1, 0};
	int vy[4]={ 0, 1, 0,-1};

	solve(){}
	ll operator()(int k, int w, int h, vector<string>&c, int x1, int y1, int x2, int y2) {
		vvi f(h+2);
		for(auto&m:f) m.assign(w+2, FLD_BAR);

		vector<vector<dir_t>> d(h+2);
		for(auto&m:d) m.resize(w+2);

		for(int y=1;y<=h;y++)
		{
			for(int x=1;x<=w;x++)
			{
				if(c[y-1][x-1]=='.') f[y][x]=FLD_INF;
			}
		}

		queue<pair<int,int>> q;
		q.push(make_pair(x1, y1));
		f[y1][x1]=0;
		while(!q.empty())
		{
			int x, y;
			tie(x, y)=q.front();
			q.pop();
			if(x==x2 && y==y2) return f[y2][x2];
//cout << "(x,y,c)=" << x << "," << y << "," << f[y][x] << "\n";
			int nc=f[y][x]+1;
			for(int i=0;i<4;i++)
			{
				int i_=(i+2)%4;
				for(int j=0;j<=k;)
				{
					int nx=x+vx[i]*j;
					int ny=y+vy[i]*j;
					if(d[ny][nx].k[i]<0) break;
					if(d[ny][nx].k[i]>0)
					{
						j+=d[ny][nx].k[i];
						continue;
					}
					if(f[ny][nx]==FLD_BAR)
					{
						for(;j>0;j--)
						{
							nx-=vx[i];
							ny-=vy[i];
							d[ny][nx].k[i]=-1;
							if(j>1) d[ny][nx].k[i_]=-1;
						}
						break;
					}
					d[ny][nx].k[i]=k-j+1;
					if(j>0) d[ny][nx].k[i_]=-1;
					if(min_u(f[ny][nx], nc))
					{
						q.push(make_pair(nx, ny));
					}
					j++;
				}
			}
		}

		return -1;
	}
};

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

	for(;;)
	{
		int h, w, k;
		cin >> h >> w >> k;
		if(cin.fail()) break;

		int x1, y1, x2, y2;
		cin >> y1 >> x1 >> y2 >> x2;

		vector<string> c(h);
		for(auto&m:c) cin >> m;

		cout << solve()(k, w, h, c, x1, y1, x2, y2) << "\n";
	}
	return 0;
}


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

int main(){
  int K,A,B;
  cin >> K >> A >> B;
  bool a=false;
  for(int i=A;i<B+1;i++){
    if(i%K==0){
      a=true;
      break;
    }
  }
  if(a){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define modulo 998244353
#define endl '\n'
#define pb push_back
using namespace std;
vector <int> adj[100001];
ll fxp(ll a, ll b)
{
    if(b == 0)return 1;
	if(b%2 == 0){
		ll c = fxp(a,b/2);
		return (c*c)%1000000007;
	}
	return (a*fxp(a,b-1))%1000000007;
}
int lcm(int c,int d)
{
    int a=c;
    int b=d;
    int ans;
    if(a>=b)
    {
        while(b!=0)
        { 
            int x=b;
            b=a%b;
            a=x;
        }
        ans = ( c*d)/a;
    }
    else
    {
        while(a!=0)
        {
            int x=a;
            a=b%a;
            b=x;
        }
        ans = ( c*d)/b;  
    }
    return ans;
}
int root_find()
{
    ll x;
    for(int i=1;i<100001;i++)
    {
        if(adj[i].size()==1)
        {
            x = i;
            break;
        }
    }
    return x;
}
void dfs(int s,int y)
{
    for(int i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]==y)
        continue;
        dfs(adj[s][i],s);
    }
}
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return n/2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return n/i; 
    } 
  
    return n; 
}  
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll cnt[n+1]={0};
    for(int x=1;x*x<n;x++)
    {
        for(int y=1;y*y<n;y++)
        {
            for(int z=1;z*z<n;z++)
            {
                ll c = (((x+y)*(x+y)) + ((y+z)*(y+z)) + (( z+x)*(z+x)))/2;
                if(c<=n)
                {
                    cnt[c]++;
                }
            }
        }
    }
    for(int i=1;i<=n;i++)
    cout<<cnt[i]<<endl;

    return 0;
}

Measured memory_bytes: 6068
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int a,b,c,d,sum=0;
	string s;

	cin>>a>>b;
	if(a>=13)
	;	
	else if(a<=5)
		b=0;
	else
		b/=2;

	cout<<b;
	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main() {
	int n, m, cnt;

	while (1) {
		std::cin >> n >> m;
		if (n == 0 && m == 0) break;

		std::vector<int> people;
		for (int i = 1; i <= n; i++) {
			people.push_back(i);
		}

		cnt = -1;
		while (people.size() > 1) {
			cnt = (cnt + m) % people.size();
			people.erase(people.begin() + cnt);
			cnt -= 1;
		}

		std::cout << people[0] << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3140
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)


int main(){
    string s; cin >> s;
    int n = s.length();
    int num_one = 0;
    int num_zero = 0;
    REP(i, n){
        if (s.compare(i, 1, "1")==0){
            num_one++;
        }
        else{
            num_zero++;
        }
    }

    int ans = min(num_one, num_zero)*2;
    cout << ans << endl;
}

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

#define FOR(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define x first
#define y second

#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " _ " <<

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int n, m;
vector<int> E[100005];

vector<int> out;
bool bio[100005];
void f(int id){
  while (true){
    int nxt = -1;
    for (auto t : E[id])
      if (!bio[t])
	nxt = t;
    if (nxt == -1) break;
    out.pb(nxt);
    bio[nxt] = true;
    id = nxt;
  }
}

int main(){
  ios_base::sync_with_stdio(false);

  cin >> n >> m;
  REP(i,m){int a, b; cin >> a >> b; E[a].pb(b); E[b].pb(a);}

  bio[1] = true;
  out.pb(1);
  f(1);
  reverse(out.begin(), out.end());
  f(1);

  cout << out.size() << endl;
  for (auto t : out) cout << t << " "; cout << endl;

  return 0;
}


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

using namespace std;

int main()
{
    char ch[4];
    scanf("%s",ch);
    int num =0;
    for(int i=0;i<4;i++)
    {
        if(ch[i]=='+') num++;
        else num--;
    }
    printf("%d",num);
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
enum { chunk = 1 << 22 };
char buf[chunk];
struct Buffer{
    int idx;
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(notDigits[(int)buf[idx]]){ idx++; }
        if(buf[idx] == '-'){ sign = -1; idx++; }
        while(!notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        cout << accs[r] - accs[l - 1] << '\n';
    }
}


Measured memory_bytes: 2176
def f(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int((3*n)+1)


s = int(input())

a = []

a.append(s)

for i in range(1, 10000000):
    if f(a[i-1]) in a:
        print(i+1)
        exit()

    a.append(f(a[i-1]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
#define FIND(v,i) find(v.begin(),v.end(),i);

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,m;
    cin >> n >> m;
    string a[n],b[m];
    bool bb,ab;
	ab=0;
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];
    REP(i,n-m+1){
        REP(j,n-m+1){
            bb=1;
            REP(k,m){
                REP(l,m){
                    if(a[i+k][j+l]!=b[k][l]) bb=0;
                }
            }
            if(bb) ab=1;
        }
    }
    cout << (ab ? "Yes" : "No") << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}
 
void scerr(vi nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}
 
int n, dp[3004][3004];
string s, t, ans;
pii p[3004][3004];
 
int main() {
	data();
	cin >> s >> t;
	int n = sz(s);
	int m = sz(t);
	s = '#' + s;
	t = '#' + t;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
			if (s[i] == t[j])
				dp[i][j] = dp[i - 1][j - 1] + 1,
				p[i][j] = {i - 1, j - 1};
			else
				if (dp[i - 1][j] > dp[i][j - 1])
					dp[i][j] = dp[i - 1][j],
					p[i][j] = {i - 1, j};
				else
					dp[i][j] = dp[i][j - 1],
					p[i][j] = {i, j - 1};
	int i = n, j = m;
	while (dp[i][j] != 0) {
		if (p[i][j] == mp(i - 1, j - 1))
			ans += s[i],
			i--, j--;
		if (p[i][j] == mp(i - 1, j))
			i--;
		if (p[i][j] == mp(i, j - 1))
			j--;
	}
	reverse(all(ans));
	cout << ans;
	return 0;
}
 
/*
	Timus: 288481RF
	CodeForces: __fractal
*/

Measured memory_bytes: 105984
#include<iostream>
using namespace std;
int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)
			break;
		for (int i = 0; i < h; i++) {
			for (int k = 0; k < w; k++) {
				if (i == 0 || i == h - 1 || k == 0 || k == w - 1) {
					cout << '#';
				}
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include"bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int ra[200006], rb[200006];
signed main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> ra[i+1]; rb[i] = ra[i+1];
	}
	rep(i, n)ra[i + 1] = max(ra[i + 1], ra[i]);
	for (int i = n - 1; i > 0; i--)rb[i - 1] = max(rb[i - 1], rb[i]);
	rep(i, n) {
		cout << max(ra[i], rb[i + 1]) << endl;
	}
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll mod=1e9+7;

void solve(){
    int n; string s; cin>>n>>s;
    int dp[n][3];
    dp[n-1][0]=(s[n-1]=='R');
    dp[n-1][1]=(s[n-1]=='G');
    dp[n-1][2]=(s[n-1]=='B');
    ll ans=0;
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            dp[i][j]=dp[i+1][j];
        }
        if(s[i]=='R') dp[i][0]++;
        else if(s[i]=='G') dp[i][1]++;
        else dp[i][2]++;
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n-1;j++){
            if(s[i]==s[j]) continue;
            int k=0;
            if( (s[i]=='R' && s[j]=='G') || (s[i]=='G' && s[j]=='R') ) k=2;
            else if( (s[i]=='R' && s[j]=='B') || (s[i]=='B' && s[j]=='R') ) k=1;
            ans+=dp[j+1][k];
            if(j+j-i < n){

                if(s[j+j-i] =='R' && k==0) ans--;
                else if(s[j+j-i]=='G' && k==1) ans--;
                else if(s[j+j-i]=='B' && k==2) ans--;
            }
        }
    }
    cout<<ans<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}


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

const int N = 2505, M = 5005;
const long long INF = 1E18 + 7;

int n, m, p, u[M], v[M], w[M];
bool vis[2][N];
long long dst[N];
vector<int> adj[2][N];

void DFS(int u, bool *vis, vector<int> *adj)
{
    vis[u] = true;
    for (int &v : adj[u])
        if (!vis[v])
            DFS(v, vis, adj);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m >> p;
    fill(dst + 2, dst + n + 1, INF);
    for (int i = 1; i <= m; i++)
    {
        cin >> u[i] >> v[i] >> w[i];
        w[i] = p - w[i];
        adj[0][u[i]].push_back(v[i]);
        adj[1][v[i]].push_back(u[i]);
    }
    DFS(1, vis[0], adj[0]);
    DFS(n, vis[1], adj[1]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            dst[v[j]] = min(dst[v[j]], dst[u[j]] + w[j]);
    for (int i = 1; i <= m; i++)
        if (dst[u[i]] + w[i] < dst[v[i]] && vis[0][v[i]] && vis[1][v[i]])
            return cout << -1, 0;
    cout << -min(dst[n], 0LL);
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define pl pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912 2の29乗
const long double PI = acos(-1);
const ll DEP = 1e18;
const int I = 1001001001001001ll;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N;
int l[10];
int dfs(int num,int x,int y,int z){
}
int a[100300];
int main(){
    cin >> N;
    if(N == 1 || N == 2){
        cout << N << endl;
        return 0;
    }

    for(int i = 0; i < 1001; i++){
        a[i] = 0;
    }

    for(int num = 2; num <= N; num++){
        int tmp = num;
        for(int j = 2; j*j <= tmp; j++){
            if(tmp % j == 0){
                while(tmp % j == 0){
                    tmp /= j;
                    a[j]++;
                }
            }
        }
        if(tmp > 1) a[tmp]++;
    }
    ll ans = 1;
    for(int i = 1; i <= N; i++){
        //cout << "a[" << i << "]=" << a[i] << ", ";
        if(a[i] >= 1){
            ans *= a[i]+1;
            ans %= MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
while True:
  m, f, r = map(int, input().split())

  if m == f == r == -1:
    break
  else:
    if m == -1 or f == -1:
      print('F')
    elif 80 <= (m + f):
      print('A')
    elif 65 <= (m + f):
      print('B')
    elif 50 <= (m + f):
      print('C')
    elif 30 <= (m + f):
      if 50 <= r:
        print('C')
      else:
        print('D')
    else:
      print('F')



Measured memory_bytes: 5596
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> Paint;

__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
char alp[26];
int main(){
  //cout << fixed << setprecision(n)
  for(int i = 0; 26 > i; i++){
    alp[i] = 'A'+i;
  }
  int n;cin>>n;n%=26;
  string s;cin>>s;
  for(int i = 0; s.size() > i; i++){
    s[i] = (((s[i]-'A')+n)%26) + 'A';
  }
  cout << s << endl;
}

Measured memory_bytes: 256
n=int(input())
a,b=map(int,input().split())
p = [int(x) for x in input().split()]
A=0
B=0
C=0
for i in range(n):
    if p[i] <= a:
        A += 1
    elif p[i] > a and b >= p[i]:
        B += 1
    else:
        C += 1

print(min(A, B, C))

Measured memory_bytes: 9108
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lionadis
 */

#include <bits/stdc++.h>
using namespace std;
#define _ cin.tie(0);ios::sync_with_stdio(false);
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()

const ll oo = (ll) 1e18;
const int mod = (int) 1e9 + 7;
const double PI = acos((ll)-1.0);

const int N = 200010;
int a[N];
int b[N];
bool visited[N];

class TaskC {
public:
    bool test = false;
    int n,m;
    vector<vector<int> > a;
    
    void dfs(int x,int cnt){
        if(cnt>2)return;
        if(visited[x]) return;
        if(x == n) {
            test = true;
            return;
        }
        visited[x] = true;
        for(auto i:a[x]) dfs(i,cnt+1);
    }
    
    void solve(std::istream& in, std::ostream& out){
        in >> n >> m;
        a.resize(n+1);
        fill(visited,visited + 1 + n, false);
        while(m--){
            int x,y;
            in >> x >> y;
            a[x].push_back(y);
            a[y].push_back(x);
        }
        dfs(1,0);
        out << (test ? "POSSIBLE\n":"IMPOSSIBLE\n");
    };
    
};


int main() {
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(a-c)<=d) cout << "Yes" <<endl;
  else if(abs(b-a)<=d && abs(c-b)<=d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int n;
    cin>>n;
    vector<int>u(n);
    double a,b=0;
    for(int i=0;i<n;i++){
        cin>>u[i];
    }
    sort(u.begin(),u.end());
    //cout<<u[1]<<endl;
    double ans=u[0];
    for(int i=1;i<n;i++){
        ans=(ans+u[i])/2.0;
       //cout<<ans<<endl; 
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
ID: alec3
LANG: C++14
PROG:
*/
/*
Just use the ModInt struct to take care of the mod
operations and compute the sum exactly as is stated by the
problem.
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

//ifstream fin("maze1.in");
//ofstream fout("maze1.out");
struct UnionFind{
	int size;
	vector<int> parent;

	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};
ll n, m;
UnionFind uf(200005);
map<ll, ll> mp;


int main()
{
    io;
    cin >> n >> m;
    ll a, b;
    for (int i = 1; i <= m; i++){
        cin >> a >> b;
        uf.unite(a, b);
    }

    for (int i = 1; i <= n; i++)
        mp[uf.root(i)] ++;

    ll ans = 0;
    for (auto it = mp.begin(); it != mp.end(); it++)
        ans = max(ans, it->second);
    cout << ans << endl;
    return 0;
}


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

#define INF 114514

#define IN 1
#define OUT 2

using Data = pair<int, double>;
using Pair = pair<int, Data>;
using Seg = pair<int, int>;

int n;
double r;
vector<Pair> es;
map<Seg, double> mp;

bool check(double t) {
  for (auto &itr : mp) {
    Seg s = itr.first;
    int a = s.first;
    int b = s.second;
    if (b <= -r || r <= a) continue;

    int mid = 0;
    if (b <= 0) mid = b;
    else if (a >= 0) mid = a;

    if (sqrt(r*r - double(mid)*mid)-r+t > itr.second) return false;
  }
  return true;
}

int main() {
  while (1) {
    scanf("%lf%d", &r, &n);
    if (r == 0 && n == 0) return 0;
    es.clear();
    for (int i=0; i<n; i++) {
      int l, r;
      double h;
      scanf("%d%d%lf", &l, &r, &h);
      es.emplace_back(Pair(l, Data(IN, h)));
      es.emplace_back(Pair(r, Data(OUT, h)));
    }
    sort(es.begin(), es.end());

    multiset<double> hs;
    hs.insert(0.0);
    int prevx = -INF;
    mp.clear();
    for (auto &pa : es) {
      int x = pa.first;
      int type = pa.second.first;
      double h = pa.second.second;

      if (prevx != x) {
        mp[Seg(prevx, x)] = *hs.rbegin();
      }

      if (type == IN) {
        hs.insert(h);
      } else {
        hs.erase(hs.find(h));
      }
      prevx = x;
    }

    if (prevx < r) {
      mp[Seg(prevx, r)] = 0;
    }

    double low = 0.0;
    double high = INF;
    for (int i=0; i<40; i++) {
      double mid = (low+high)/2;
      if (check(mid)) low = mid;
      else high = mid;
    }
    printf("%.10f\n", low);
  }
}

Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		String s =scn.next();
		   res(s);

	}
	public static void res(String s){
		
		String s1= s.substring(0,s.length()/2);
	//	System.out.println(s1);
		String s2=s.substring((s.length()+2)/2);
	//	System.out.println(s2);
		if(ispaln(s1)&&ispaln(s2)&&ispaln(s)){
			System.out.println("Yes");
			return ;
		}
		
		
		System.out.println("No");
	}
	
	public static boolean ispaln(String s){
		int i=0;
		int j=s.length()-1;
		while(i<j){
			if(s.charAt(i)!=s.charAt(j)){
				return false;
			}
			i++;
			j--;
		}
		return true;
	}

}

Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(10**5)
def main():
    n = int(input())
    h = [int(x) for x in input().split()]
    memo = [None for i in range(n)]

    def rec(n):
        if memo[n-1] == None:
            if n <= 1:
                memo[n-1] = 0
            elif n == 2:
                memo[n-1] = abs(h[1]-h[0])
            else:
                d1 = rec(n-2)+abs(h[n-1]-h[n-3])
                d2 = rec(n-1)+abs(h[n-1]-h[n-2])
                memo[n-1] = min(d1,d2)
        return memo[n-1]
        
    print(rec(n))

if __name__ == "__main__":
    main()

Measured memory_bytes: 60668
N = int(input())
s = input()
s += s[0]
l = [0] * (N + 2)

# S: 1, W: 0
for a0, a1 in ((0, 0), (0, 1), (1, 0), (1, 1)):
  l[0], l[1] = a0, a1

  for i in range(1, N + 1):
    if s[i] == 'o': l[i + 1] = not (l[i] ^ l[i - 1])
    else: l[i + 1] = l[i] ^ l[i - 1]

  if (l[0] == l[-2]) and (l[1] == l[-1]):
    print(*['S' if i == 1 else 'W' for i in l[:-2]], sep='')
    exit()

print(-1)

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

int main() {
  int N,n;
  int fx;
  cin >> N;

  n = N;
  fx = 0;
  while (n>0) {
    //一桁目を取り出す
    fx += n%10;
    //桁数をひとつ減らす
    n /= 10;
  }
  
  //ハッシャード数か判定
  if (N%fx == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;


int factorize(long n) {

    map<long, long> prime;
    for(long i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            prime[i]++;
            n /= i;
        }
    }
    if(n != 1) {
        prime[n] = 1;
    }
    long res=1;
    for(auto it:prime){
        res*=it.second+1;
    }
    return res;
}


int main() {

    int n;
    cin>>n;
    long ans=0;
    for(int c=1;c<n;c++){
        int nc=n-c;
   
        ans+=factorize(nc);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <iomanip>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;
 
int main(){
  int N;
  cin >> N;
  cout << N*N*N << endl;
}


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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int min1 = h1 * 60 + m1;
  int min2 = h2 * 60 + m2;
  int ans = min2 - k - min1;
  cout << ans << endl;

  return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    REP(i,26){
        int32 cnt = 0;
        REP(j,4){
            if(s[j] - 'A' == i)cnt++;
        }
        if(cnt == 1 || cnt > 2){
            Yes(false);
            return 0;
        }
    }
    Yes(true);
    return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())
xyl = []
for i in range(n):
    x,y = map(int, input().split())
    xyl.append((x,y))

ans = 10**20+1
for a in range(n):
    for b in range(a+1,n):
        axy = xyl[a]
        bxy = xyl[b]
        ax,ay = axy
        bx,by = bxy
        l = min(ax,bx)
        r = max(ax,bx)
        t = max(ay,by)
        bo = min(ay,by)
        v = 0
        for x,y in xyl:
            if l <= x <= r and bo <= y <= t:
                v += 1
        if v >= k:
            area = (r-l)*(t-bo)
            ans = min(ans, area)

        for c in range(b+1,n):
            cxy = xyl[c]
            cx,cy = cxy
            l = min(ax,bx,cx)
            r = max(ax,bx,cx)
            t = max(ay,by,cy)
            bo = min(ay,by,cy)
            v = 0
            for x,y in xyl:
                if l <= x <= r and bo <= y <= t:
                    v += 1
            if v >= k:
                area = (r-l)*(t-bo)
                ans = min(ans, area)

            for d in range(c+1,n):
                dxy = xyl[d]
                dx,dy = dxy
                left = min(ax,bx,cx,dx)
                right = max(ax,bx,cx,dx)
                top = max(ay,by,cy,dy)
                bottom = min(ay,by,cy,dy)
                cnt = 0
                for x,y in xyl:
                    if left <= x <= right and bottom <= y <= top:
                        cnt += 1
                if cnt >= k:
                    area = (right-left)*(top-bottom)
                    ans = min(ans, area)


print(ans)

Measured memory_bytes: 82584
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long t1,t2,a1,a2,b1,b2;
  cin>>t1>>t2;
  cin>>a1>>a2;
  cin>>b1>>b2;
  long long saa=t1*a1-t1*b1;
  long long sab=t2*a2-t2*b2;
  long long sac=saa+sab;
  long long num=abs(saa/sac);
  long long num2=abs(saa%sac);
  if(sac==0){
    cout<<"infinity"<<endl;
  }else if(saa>0&&sac>0){
    cout<<"0"<<endl;
  }else if(saa<0&&sac<0){
    cout<<"0"<<endl;
  }else{
    if(num2==0){
      cout<<2*num<<endl;
    }else{
      cout<<2*num+1<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n=int(input())
a,b=map(int,input().split())
if n!=1:
	for _ in range(n-1):
		A,B=map(int,input().split())
		k=max(1,(a+A-1)//A,(b+B-1)//B)
		a=k*A
		b=k*B
print(a+b)

Measured memory_bytes: 3060
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,k;
vector<int> con[4011];
bool vis[4011];
void dfs(int x,int l)
{
	vis[x]=1;
	if(l==k)return;
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i];
		if(!vis[u])dfs(u,l+1);
	}
}
int main()
{
	getii(n,k);
	for(int i=1;i<n;i++)
	{
		int x,y;
		getii(x,y);
		con[x].PB(n+i);
		con[n+i].PB(x);
		con[y].PB(n+i);
		con[n+i].PB(y);
	}
	int mn=mod;
	for(int i=1;i<=2*n-1;i++)
	{
		memset(vis,0,sizeof(vis));
		dfs(i,0);
		int cur=0;
		for(int j=1;j<=n;j++)cur+=!vis[j];
		mn=min(mn,cur);
	}
	cout<<mn<<endl;
	return 0;
}


Measured memory_bytes: 512
A, B, K = [int(i) for i in input().split()]

numbers = set() 
for i in range(A, A+K):
    if i <= B:
        numbers.add(i)
    
for j in range(B-K, B):
    if j >= A:
        numbers.add(j+1)
        
numbers = sorted(numbers)

for n in numbers:
    print(n)

Measured memory_bytes: 3060
L, R = map(int, input().split())

ans = 3000

l = [-1] * 2019 
r = [-1] * 2019

flagl = False
for i in range(L, R):
    if l[i%2019] != -1:
        flagl = True
    l[i%2019] = i%2019
    flagr = False
    for j in range(i+1, R+1):
        if r[j%2019] != -1:
            flagr = True
            break
        r[j%2019] = j%2019
    if flagl == True and flagr == True:
        break

tmp = 0
for i in l:
    if i == -1:
        continue
    for j in r:
        if j == -1:
            continue
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  int count = 0;
  int M = 0;
  rep(i, N)
  {
    if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G')
    {
      count = 1;
      M = 1;
      break;
    }
  }
  rep(i, N - 1)
  {
    if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G')
    {
      if (S[i+1]=='A'||S[i+1]=='T'||S[i+1]=='C'||S[i+1]=='G')
      {
        count ++;
        M = max(M,count);
      }
    }
    else
    {
      count = 1;
    }
    
  }
  cout << M << endl;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"

using namespace std;
using pii = pair <int, int>;
using ppi = pair <pii, pii>;

#define f first
#define s second

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

    vector <ppi> ans;
    for (int i = 0; i < h; i++) {
        vector <int> odd;
        for (int j = 0; j < w; j++) {
            if (a[i][j] & 1) odd.push_back(j);
        }

        int sz = odd.size();
        for (int j = 0; j + 1 < sz; j += 2) {
            int c1 = odd[j], c2 = odd[j + 1];
            while (c1 != c2) {
                ans.push_back({pii(i, c1), pii(i, c1 + 1)});
                c1++;
            }
        }

        if (sz & 1) {
            int c1 = odd[sz - 1], c2 = w - 1;
            while (c1 != c2) {
                ans.push_back({pii(i, c1), pii(i, c1 + 1)});
                c1++;
            }

            if (i < h - 1) {
                ans.push_back({pii(i, w - 1), pii(i + 1, w - 1)});
                a[i + 1][w - 1]++;
            }
        }
    }

    cout << ans.size() << endl;
    for (auto step : ans) {
        cout << step.f.f + 1 << " " << step.f.s + 1 << " " << step.s.f + 1 << " " << 
        step.s.s + 1 << endl;
    }
}

Measured memory_bytes: 6332
n, x, y = map(int, input().split())
x -= 1 #グラフを0からn-1までの数に対応させる
y -= 1 #
ans = [0]*(n-1)

for i in range(n):
  for j in range(i+1, n):#各頂点の距離を一組ずつ調べる
    a = min(j-i, abs(x-i) + abs(y-j) + 1)
    '''
    j-i                     :1～nまでの普通のルートでの距離
    abs(x-i) + abs(y-j) + 1 :ショートカットルートを使ったときの距離
    ''' 
    ans[a-1] += 1 #距離の長さに対応したリストに+1
for p in ans:
  print(p)

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

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

    rep(i,n){
        cout<<s[i]<<t[i];
    }
    
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i=0; i<(int)(n); i++)
     
    int main(){
      int n,m;
      cin >> n >> m;
      vector<int> N(n+1,0);
      int tmp1,tmp2;
      rep(i,m){
        cin >> tmp1 >> tmp2;
        N.at(tmp1)++;
        N.at(tmp2)++;
      }
      rep(i,n) cout << N.at(i+1) << endl;
     
    	return 0;
    }

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int n,m[10000],i,a,flg;
	while(1){
	    scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
		    scanf("%d",&m[i]);
		}
		a=0;
		flg=0;
		for(i=0;i<n;i++){
		    if(m[i]>=2) flg=1;
			if(m[i]>0) a++;
		}
		if(flg==0) printf("NA\n");
		else if(a!=0) printf("%d\n",a+1);
	}
	return 0;
}

Measured memory_bytes: 2792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)998244353;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NK = Sarray();
            var N = NK[0];
            var K = NK[1];
            var Ai = Sarray();
            var dbl = Enumerable.Range(0, (int)N).Select(_ => new List<long>()).ToArray();
            for (var i = 0; i < N; ++i)
                dbl[i].Add(Ai[i] - 1);
            var lst = 0;
            var t = K;
            while (t != 0)
            {
                t >>= 1;
                ++lst;
            }
            for (var k = 1; k < lst; ++k)
            {
                for (var i = 0; i < N; ++i)
                    dbl[i].Add(dbl[dbl[i][k - 1]][k - 1]);
            }
            var next = 0L;
            var cnt = 0;
            while (K != 0)
            {
                if (K % 2 != 0)
                    next = dbl[next][cnt];
                K >>= 1;
                ++cnt;
            }
            WriteLine(next + 1);
        }
    }
}

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

#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int solve(string str) {
	int N = sz(str);
	int res = 1;
	int nicechk = -1, niceat = -1;
	rep(i,0,N-1) {
		if (str[i] == str[i+1] && nicechk <= i) {
			int j = i+1;
			while (j < sz(str) && str[j] == str[i]) j++;
			if (j == sz(str))
				break;
			if (str[j] > str[i+1]) i = j-1;
			niceat = j;
			nicechk = j-5;
		}

		if (str[i] >= str[i+1]) {
			res++;
			for (int j = N-1;; --j) {
				if (str[j]++ != '9') {
					if (j == niceat) nicechk = -1;
					break;
				}
				str[j] = '0';
			}
		}
	}

	// cerr << str << endl;
	return res;
}

int main() {
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	string str;
	cin >> str;
	cout << solve(str) << endl;
	exit(0);
}


Measured memory_bytes: 1308
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    s = tuple(map(int, input()))
    lens = len(s)

    d1 = defaultdict(int)
    ss = 0
    num10 = 1
    for i1 in range(1, lens+1):
        ss += (int(s[-i1]) * num10) % 2019
        ss = ss % 2019
        d1[ss] += 1
        num10 = (num10 * 10) % 2019
    r = d1[0]
    for v in d1.values():
        r += v * (v - 1) // 2
    print(r)

if __name__ == '__main__':
    main()

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

template <typename T>
void print(const T &v);

const int MAX = 510'000;

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

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<ll, ll>>
factorization(ll num)
{
    map<ll, ll> mp;

    ll tmp = num;
    for (ll i = 2; i * i <= num; i++)
    {
        while (tmp % i == 0)
        {
            mp[i]++;
            tmp /= i;
        }
    }
    if (tmp != 1)
    {
        mp[num]++;
    }
    vector<pair<ll, ll>> ret;
    for (auto m : mp)
    {
        ret.push_back(make_pair(m.first, m.second));
    }
    return ret;
}

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

    auto fac = factorization(m);
    ll ans = 1;
    for (int i = 0; i < fac.size(); i++)
    {
        int tmp = fac[i].second;
        ans = (ans * COM(n + tmp - 1, tmp)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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

int main()
{
  int N; cin >> N;
  vector<ll> d(N); REP(i, N) cin >> d[i];
  ll ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i+1; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define to first
#define cost second
const int inf=1e9+7;
using namespace std;
int main(){

  int n,tmp,r=0,flag[100]={},v=0;
  cin>>n;
  vector <pair<int,int> > gl[n];
  priority_queue <pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > >q;
  //for(int i=1;i<n;i++) mincost[i]=inf;                                                                                                                                                       

  for(int i=0;i<n;i++) for(int j=0;j<n&&cin>>tmp;j++) if(tmp!=-1) gl[i].push_back(make_pair(j,tmp));
  int now=0;
  for(int j=0;j<n-1;j++){
    for(int i=0;i<gl[now].size();i++) if(!flag[gl[now][i].to]) q.push(make_pair(gl[now][i].cost,gl[now][i].to));
    flag[now]=1;
    for(;flag[q.top().second];) q.pop();
    //if(q.empty()) break;                                                                                                                                                                     
    r+=q.top().first;
    now=q.top().second;
    q.pop();
  }
  cout<<r<<endl;
  return 0;

}

Measured memory_bytes: 3128