akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int total = 0;
		for (int i=1; i<N+1;i++) {
			char[] c = Integer.toString(i).toCharArray();
			int sum = 0;
			for (int j=0; j<c.length; j++) {
				sum += Integer.parseInt(String.valueOf(c[j]));
			}
			if (sum >= A && sum<=B ) total += i;
		}
		System.out.println(total);
	}
}


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

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	map<string, string> mp;
	mp["Sunny"] = "Cloudy";
	mp["Cloudy"] = "Rainy";
	mp["Rainy"] = "Sunny";
	string s;
	cin >> s;
	cout << mp[s] << endl;
	return 0;
}


Measured memory_bytes: 888
N = int(input())
L = list(map(int, input().split()))
count = 0
for i in range(0,N-2):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i] + L[j] > L[k]:
        if L[j] + L[k] > L[i]:
          if L[k] + L[i] > L[j]:
            if L[k] != L[i]:
              if L[k] != L[j]:
                if L[j] != L[i]:
                  count = count + 1            
print(count)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
 ll n,a,b;
 cin >> n >> a >> b ;
 ll c = a + b;
 ll ans = a * (n /c);
 ans += min ( n %c,a);
 cout << ans << endl;

}

Measured memory_bytes: 256
n = int(input())

dp = [[0,0,0] for _ in range(n+1)]

for i in range(1,n+1):
  a,b,c = map(int,input().split())
  dp[i][0] = max(dp[i-1][1]+a, dp[i-1][2]+a)
  dp[i][1] = max(dp[i-1][0]+b, dp[i-1][2]+b)
  dp[i][2] = max(dp[i-1][0]+c, dp[i-1][1]+c)
  #print(dp)
  
ans = max(dp[n])
print(ans)

Measured memory_bytes: 81840
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0;
  cin >> N;
  map<string, ll> mp;
  rep(i,N){
    string s;
    cin >> s;
    mp[s]++;
  }
  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<bitset>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<list>
#include<queue>
#include<map>
#include<numeric>
#include<set>
#include<iterator>
using namespace std;
#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)
int INF=1e9;
const long long mod=1e9+7;
#define ll long long

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==5&&B==5&&C==7){
    cout<<"YES"<<endl;
  }
  else if(A==5&&B==7&&C==5){
    cout<<"YES"<<endl;
  }
  else if(A==7&&B==5&&C==5){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

struct UnionFind
{
    vector<int> par;
    vector<int> sizes;

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

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

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sizes[x] < sizes[y])
            swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

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

    int size(int x) {
        return sizes[find(x)];
    }
};

int LL;

struct Edge
{
    int a, b, cost;

    bool operator<(const Edge &o) const {
        return abs(cost - LL) < abs(o.cost - LL);
    }
};

struct Graph
{
    int n;
    vector<Edge> es;

    int kruskal() {
        sort(es.begin(), es.end());

        UnionFind uf(n);
        int min_cost = 0;

        int mi = 1000000, ma = 0;
        int t = 0;
        for (int ei = 0; ei < es.size(); ++ei) {
            Edge &e = es[ei];
            if (!uf.same(e.a, e.b)) {
                uf.unite(e.a, e.b);
                mi = min(mi, e.cost);
                ma = max(ma, e.cost);
                ++t;
            }
        }

        return (t == n - 1) ? ma - mi : -1;
    }
};

int main()
{
    for (;;) {
        int n, m;
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0)
            break;

        Graph g;
        g.n = n;
        int w[10000];
        for (int i = 0; i < m; ++i) {
            Edge e;
            scanf("%d %d %d", &e.a, &e.b, &e.cost);
            --e.a;
            --e.b;
            w[i] = e.cost;
            g.es.push_back(e);
        }

        if (m == 0) {
            printf("-1\n");
            continue;
        }

        int ans = 10000000;
        for (int i = 0; i < m; ++i) {
            LL = w[i];
            ans = min(ans, g.kruskal());
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1220
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    bulbs = []
    for _ in range(M):
        b = tuple(map(int, input().split()))
        bulbs.append(b[1:])

    P = list(map(int, input().split()))

    ans = 0
    for switch in range(2**N):
        check = [0] * M
        for i, bulb in enumerate(bulbs):
            cnt = 0
            for b in bulb:
                if switch >> (b - 1) & 1:
                    cnt += 1

            if cnt % 2 == P[i]:
                check[i] = True
            else:
                check[i] = False

        if all(check):
            ans += 1

    return ans


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
n = int(input())
A = list(map(int, input().split()))

B = [-1]
ans = 0
for i in A:
    if B[-1] == i:
        B.append(i)
    elif B[-1] < i:
        B.append(i - 1)
    else:
        ans = 1
if ans == 1:
    print("No")
else:
    print("Yes")

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

template <class lambda_type>
class make_recursive
{
    const lambda_type &func;
public:
    make_recursive(lambda_type &&f) : func(std::move(f)) {}
    template <class... Args> auto operator()(Args &&... args) const
    {
        return func(*this, std::forward<Args>(args)...);
    }
};

main()
{
    int n; cin>>n;
    vector<int> a(n);
    for(auto &e: a) cin>>e;
    vector<vector<int>> tree(n);
    for(int i=0; i<n-1; ++i)
    {
        int u,v; cin>>u>>v; --u,--v;
        tree[v].emplace_back(u);
        tree[u].emplace_back(v);
    }
    vector nlow(n, INT_MAX),ans(n,0);
    make_recursive([&](auto dfs, int v, int p)->void
    {
        auto ptr=lower_bound(begin(nlow), end(nlow), a[v]);
        const int plow=*ptr;
        *ptr=a[v];
        ans[v]=lower_bound(begin(nlow), end(nlow), INT_MAX)-begin(nlow);
        for(int u: tree[v]) if(p!=u) dfs(u,v);
        *ptr=plow;
    })(0,-1);
    for(int e: ans) cout << e << "\n";
}


Measured memory_bytes: 30720
program circle_pond
  implicit none
  real(8), parameter :: pi = 3.14159265358979d0
  real(8) :: r
  character(64) :: s
  read(*,*) r
  write(s,'(f32.16)') 2.d0*pi*r
  write(*,'(a)') trim(adjustl(s))
end program circle_pond

Measured memory_bytes: 3032
import java.util.Scanner;

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

        try{
            int i = 1;
            int num = scanner.nextInt();
            while(num != 0){
                System.out.println("Case"+" "+i+":"+" "+num);
                i++;
                num = scanner.nextInt();
            }

            }finally{
                scanner.close();
            }
        }
    }


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

vector<string> anagrams;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long long N, ans = 0; string temp;
    cin >> N;
    while (N--) {
        cin >> temp;
        sort(temp.begin(), temp.end());
        anagrams.push_back(temp);
    }
    sort(anagrams.begin(), anagrams.end());
    //for (auto i : anagrams) cout << i << "\n";
    long long cnt = 0;
    for (long long i = 1; i < anagrams.size(); i++) {
        if (anagrams[i] == anagrams[i - 1]) {
            cnt++; // triangular numbers
        } else {
            ans += (cnt * (cnt + 1)) / 2;
            cnt = 0;
        }
        if (i == anagrams.size() - 1) {
            ans += (cnt * (cnt + 1)) / 2;
            cnt = 0;
        }
    }

    cout << ans << "\n";

    return 0;
}

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

using namespace std;

int n, m, q;
int num[501][501] = { 0 };

void make_num();
int ret_ans(int i, int j);

int main()
{
	cin >> n >> m >> q;

	int L, R;
	for (int i = 0; i < m; i++) {
		cin >> L >> R;
		num[L][R]++;
	}
	make_num();
	for (int i = 0; i <	q; i++) {
		cin >> L >> R;
		cout << ret_ans(L, R) << endl;
	}

	

	return 0;
}

void make_num()
{
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			num[i][j] += num[i][j - 1];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			num[i][j] += num[i - 1][j];
		}
	}
}

int ret_ans(int i, int j)
{
	return num[j][j] - num[i - 1][j] - num[j][i - 1] + num[i - 1][i - 1];
}

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

bool check(string s)
{
    string r;
    reverse_copy(s.begin(),s.end(),back_inserter(r));
    return s==r;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ld l;
    cin>>l;
    l/=3;
    cout<<fixed<<setprecision(10)<<l*l*l;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for (int i = (int)(j); i < (int)(n); ++i)
int main(){
  int n;
  cin>>n;
  char c[]={'M','A','R','C','H'};
  long long  a[5]={};
  string s;
  rep(i,0,n){
     cin>>s;
      if(s[0]==c[0]){
         a[0]++; 
      }else if(s[0]==c[1]){
         a[1]++; 
      }else if(s[0]==c[2]){
         a[2]++; 
      }else if(s[0]==c[3]){
         a[3]++; 
      }else if(s[0]==c[4]){
         a[4]++; 
      }
  }
  long long  sum=0;
  rep(i,0,3)
    rep(j,i+1,4)
    rep(k,j+1,5)
    sum+=a[i]*a[j]*a[k];
  cout<<sum; 
  return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    if(m < n) swap(n,m);
    rep(i,m) cout << n;
    cout << endl;
}


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

using namespace std;

#define MAX 100010
const int MAX_N = 1<<17;
typedef long long ll;

class RMQ{
public:
  ll n,dat[2*MAX_N-1];
  
  void init(int n_){
    n = 1;
    while(n < n_){ n *= 2; }
    for(int i = 0 ; i < 2*n-1 ; i++){
      dat[i] = 0LL;
    }
  }

  void update(ll k,ll a){
    k += n - 1;
    dat[k] = a;
    while(k > 0){
      k = (k - 1) / 2;
      dat[k] = max(dat[k*2+1],dat[k*2+2]);
    }
  }

  ll query(ll a,ll b,ll k,ll l,ll r){
    if(r <= a || b <= l){ return 0LL; }
    if(a <= l && r <= b){
      return dat[k];
    }else{
      ll vl = query(a,b,k*2+1,l,(l+r)/2);
      ll vr = query(a,b,k*2+2,(l+r)/2,r);
      return max(vl,vr);
    }
  }
};

int main(){
  ll N,x[MAX],sum = 0LL;
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> x[i];
    sum += x[i];
  }
  RMQ rmq;
  rmq.init(N);
  ll lis = 0LL;
  for(int i = 0 ; i < N ; i++){
    ll c = rmq.query(1,x[i]+1,0,0,rmq.n);
    rmq.update(x[i],c+x[i]);
    lis = max(lis,c);
  }
  cout << sum-rmq.query(1,N+1,0,0,rmq.n) << endl;
  return 0;
}

Measured memory_bytes: 3988
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
// #define y1 hsdhja
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int x1,x2,y1,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  cout << x2-y2+y1 << " " << y2+x2-x1 << " " << x1-y2+y1 << " " << y1+x2-x1 << endl;


return 0;
}
///....


Measured memory_bytes: 256
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
def near2017(n):
    if is_prime(n):
        return is_prime((n+1)//2)
    else:
        return False
#############################################################
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

N = 100000
prime = [0]*100001
cur = 0
ans = []
for i in range(1,N+1):
    if near2017(i):
        cur +=1
        prime[i] = cur
    else:
        prime[i] = prime[i-1]
#print(prime[N])
cur = int(0)
Q = I()
for i in range(Q):
    l, r = LI()
    cur = prime[r] - prime[l-1]
    ans.append(cur)

for v in ans:
    print(v)


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

const int N = 500;
const int oo = 0x3f3f3f3f;

int n;
int a[N + 5][N + 5];
int f[N + 5][N + 5];
char st[N + 5][N + 5];
int L[N + 5][N + 5], R[N + 5][N + 5];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%s", st[i] + 1);
        for(int j = 1; j <= n; ++j) {
            a[i][j] = (st[i][j] == '#') ? 0 : st[i][j] - '0';
        }
    }

    long long ans = 0;
    for(int j = n; j >= 1; --j) if(a[n][j] > 0) {
        L[n][j] = j; 

        if(a[n][j + 1] > 0) {
            f[n][j] = f[n][j + 1];
            R[n][j] = R[n][j + 1];
        } else {
            R[n][j] = j;
        }

        ans += a[n][j] * f[n][j];
        f[n][j] += a[n][j];
    }

    for(int i = n - 1; i >= 1; --i) {
        for(int j = n; j >= 1; --j) if(a[i][j] > 0) {
            bool r = (a[i][j + 1] > 0), d = (a[i + 1][j] > 0);

            if(!r && !d) {
                L[i][j] = R[i][j] = j;
                for(int k = i + 1; k <= n; ++k) L[k][j] = oo, R[k][j] = -oo;
            } else if(r && !d) {
                L[i][j] = j;
                R[i][j] = R[i][j + 1];
                f[i][j] = f[i][j + 1];
                for(int k = i + 1; k <= n; ++k) L[k][j] = L[k][j + 1], R[k][j] = R[k][j + 1];
            } else if(!r && d) {
                f[i][j] = f[i + 1][j];
                L[i][j] = R[i][j] = j;
            } else {
                L[i][j] = j; R[i][j] = R[i][j + 1];
                f[i][j] = f[i + 1][j] + f[i][j + 1];

                int lim = 0;
                for(int k = i + 1; k <= n; ++k) {
                    if(R[k][j] >= L[k][j + 1] && L[k][j + 1] > lim) {
                        f[i][j] -= f[k][L[k][j + 1]];
                    }
                    lim = R[k][j];
                    L[k][j] = min(L[k][j], L[k][j + 1]);
                    R[k][j] = max(R[k][j], R[k][j + 1]);
                }
            }
            
            ans += a[i][j] * f[i][j];
            f[i][j] += a[i][j];
        }
    }
    printf("%lld\n", ans);

    return 0;
}


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

using namespace std;
using ll = long long;

bool inside(ll h,ll w,ll y,ll x) {
    return (0 <= y && y < h && 0 <= x && x < w);
}

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

    ll ch, cw;
    cin >> ch >> cw;
    ch--; cw--;

    ll dh, dw;
    cin >> dh >> dw;
    dh--; dw--;

    vector<string> g(h);
    for (int i = 0; i < h; i++) {
        cin >> g[i];
    }

    queue<pair<int, int>> que;
    queue<pair<int, int>> warp;
    vector<vector<int>> dist(h, vector<int>(w, -1));

    que.push(make_pair(ch, cw));
    dist[ch][cw] = 0;

    vector<int> movey = {-1, 0, 1, 0};
    vector<int> movex = {0, 1, 0, -1};
    
    while (!que.empty() || !warp.empty()) {
        ll y, x;
        if (que.empty()) {
            tie(y, x) = warp.front();
            warp.pop();
        }
        else {
            tie(y, x) = que.front();
            que.pop();
        }

        for (int i = 0; i < 4; i ++) {
            ll ny = y + movey[i];
            ll nx = x + movex[i];
            if (inside(h, w, ny, nx) && g[ny][nx] == '.') {
                if (dist[ny][nx] == -1) {
                    que.push(make_pair(ny, nx));
                    dist[ny][nx] = dist[y][x];
                }
                else {
                    if (dist[y][x] < dist[ny][nx]) {
                        que.push(make_pair(ny, nx));
                        dist[ny][nx] = dist[y][x];
                    }
                }
            }
        }

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                ll ny = y + 2 - i;
                ll nx = x + 2 - j;
                if (inside(h, w, ny, nx) && g[ny][nx] == '.') {
                    if (dist[ny][nx] == -1 || dist[y][x] + 1 < dist[ny][nx]) {
                        warp.push(make_pair(ny, nx));
                        dist[ny][nx] = dist[y][x] + 1;
                    }
                }
            }
        }
    }
    
    cout << dist[dh][dw] << endl;
}

Measured memory_bytes: 9452
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define cl(x,y) memset(x,y,sizeof(x))
#define ct cerr<<"Time elapsed:"<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
const int N=1e6+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
using namespace std;
int a[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int k,n,i;
	cin>>k>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	a[n]=a[0]+k;
	int ans=inf;
	for(i=0;i<n;i++)
		ans=min(ans,k-(a[i+1]-a[i]));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			String[] spl = br.readLine().split(" ");
			System.out.println(spl[0].substring(0,1) + spl[1].substring(0,1) + spl[2].substring(0,1));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 22484
var N = Int(readLine()!)!
var p = 2
var ans = 0
while p * p < N {
    var z = p
    while N % z == 0 {
        ans += 1
        N /= z
        z *= p
    }
    while N % p == 0 {
        N /= p
    }
    p += 1
}
print(N > 1 ? ans + 1 : ans)


Measured memory_bytes: 7804
import java.util.Scanner;

class Main {

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[m];
        int[] d = new int[m];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        int min = Math.abs(a[0] - c[0]) + Math.abs(b[0] - d[0]);
        int s = 0;
        for (int i = 0; i < n; i++) {
            min = Integer.MAX_VALUE;
            for (int j = 0; j < m; j++) {
                if (min > Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j])) {
                    min = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
                    s = j;
                }
            }
            System.out.println(s + 1);
        }
    }
}


Measured memory_bytes: 21972
# -*- coding: utf-8 -*-
N = int(input())
Fizz = int(N // 3)
Buzz = int(N // 5)
FBzz = int(N // 15)

sFizz = (3 + 3 * Fizz) * Fizz //2
sBuzz = (5 + 5 * Buzz) * Buzz //2
sFBzz = (15 + 15 * FBzz) * FBzz //2
print(N * (N + 1) // 2 - (sFizz + sBuzz) + sFBzz)

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

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> V(M);
    for(int i=0;i<N;i++){
        int K;
        cin>>K;
        for(int j=0;j<K;j++){
            int a;
            cin>>a;
            V[a-1]++;
        }
    }
    int ans=0;
    for(auto v:V) ans+=(v==N);
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N,i,a[4]={0,0,0,0};
  string result;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> result;
    if(result=="AC") a[0]++;
    if(result=="WA") a[1]++;
    if(result=="TLE") a[2]++;
    if(result=="RE") a[3]++;
  }
  
  cout << "AC x " << a[0] << endl;
  cout << "WA x " << a[1] << endl;
  cout << "TLE x " << a[2] << endl;
  cout << "RE x " << a[3] << endl;
}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
import math

# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

N = int(input())
fac = prime(N)
ans = 0
for v in fac.values():
    tmp = 0
    for i in range(1, 10**9):
        if tmp + i <= v:
            tmp += i
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 63100
#include <stdio.h>
#include <stdlib.h>

#define MAX_LENGTH 200

long stack[MAX_LENGTH];
int top = 0;

int isFull() {
  if (top == 199) {
    // printf("満タンです。\n");
    return 1;
  } else {
    // printf("満タンではありません。\n");
    return 0;
  }
}

int isEmpty() {
  if (top == 0) {
    // printf("空です。\n");
    return 1;
  } else {
    // printf("空ではありません。\n");
    return 0;
  }
}

void push(long x) {
  if (!isFull()){
    stack[top + 1] = x;
    top++;
    // printf("%ldをプッシュしました。\n", x);
  } else {
    // printf("プッシュできません。\n");
  }
}

long pop() {
  if (!isEmpty()){
    top--;
    // printf("%ldをポップしました。\n", stack[top + 1]);
    return stack[top + 1];
  } else{
    // printf("ポップできません。\n");
  }
}

int main(void) {
  char temp[10];
  int i, a, b;

  while(scanf("%s", temp) != EOF) {

    if (temp[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
      // printf("+が入力されました。\n");
    } else if (temp[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
      // printf("-が入力されました。\n");
    } else if (temp[0] =='*') {
      a = pop();
      b = pop();
      // printf("*が入力されました。\n");
      push(a * b);
    } else if (temp[0] == EOF){
      // printf("終了です。\n");
      break;
    } else {
      push(atol(temp));
      // printf("整数%ldが入力されました。\n", atol(temp));
    }
  }

  printf("%ld\n", pop());

  return 0;
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define lol        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)        cerr << #x << " = " << x << endl;

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}


bool isPal(int x)
{
    int a1 = x%10;
    x /= 10;
    int a2 = x%10;
    x /= 10;
    int a3 = x%10;
    x /= 10;
    int a4 = x%10;
    x /= 10;
    int a5 = x%10;
    if(a1==a5&&a2==a4)
    {
        return true;
    }
    return false;
    
    
    
}


void solve()
{
	int a, b;
	cin>>a>>b;
	int ans=0;
	rep(i,a,b+1)
	{
	    if(isPal(i))
	    {
	        ans++;
	    }
	}
	cout<<ans<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX=101;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
    int u,minv;
    int d[MAX],p[MAX],color[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        p[i]=-1;
        color[i]=WHITE;
    }
    
    d[0]=0;
    
    while(1){
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++){
            if(minv>d[i] && color[i]!=BLACK){
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(int i=0;i<n;i++){
            if(color[i]!=BLACK && M[u][i]!=INFTY){
                if(d[i]>M[u][i]){
                    d[i]=M[u][i];
                    p[i]=u;
                    color[i]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(p[i]!=-1) sum += M[i][p[i]];
    }
    
    return sum;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> M[i][j];
            if(M[i][j]==-1) M[i][j]=INFTY;
        }
    }
    
    cout << prim() << endl;
    
    return 0;
}










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

const int MaxM = 110;
int N, M, A[ MaxM ], Sum, Num;

int main() {
	scanf( "%d%d", &N, &M );
	for( int i = 1; i <= M; ++i ) scanf( "%d", &A[ i ] );
	for( int i = 1; i <= M; ++i ) Sum += A[ i ];
	if( Sum != N ) {
		printf( "Impossible" );
		return 0;
	}
	for( int i = 1; i <= M; ++i )
		if( A[ i ] % 2 == 1 ) 
			++Num;
	if( Num > 2 ) {
		printf( "Impossible" );
		return 0;
	}
	if( Num == 0 ) {
		for( int i = 1; i <= M; ++i ) printf( "%d ", A[ i ] ); printf( "\n" );
		printf( "%d\n", M + 1 );
		printf( "%d ", A[ 1 ] - 1 );
		for( int i = 2; i <= M; ++i ) printf( "%d ", A[ i ] ); 
		printf( "%d\n", 1 );
		return 0;
	}
	if( Num == 2 ) {
		int a, b;
		for( int i = 1; i <= M; ++i )
			if( A[ i ] % 2 == 1 ) {
				a = A[ i ];
				break;
			}
		for( int i = M; i >= 1; --i ) 
			if( A[ i ] % 2 == 1 ) {
				b = A[ i ];
				break;
			}
		printf( "%d ", a );
		for( int i = 1; i <= M; ++i ) 
			if( A[ i ] % 2 == 0 ) 
				printf( "%d ", A[ i ] );
		printf( "%d\n", b );
		if( a > 1 ) {
			printf( "%d\n", M );
			printf( "%d ", a - 1 );
			for( int i = 1; i <= M; ++i )
				if( A[ i ] % 2 == 0 ) 
					printf( "%d ", A[ i ] );
			printf( "%d\n", b + 1 );
			return 0;
		}
		printf( "%d\n", M - 1 );
		for( int i = 1; i <= M; ++i ) 
			if( A[ i ] % 2 == 0 ) 
				printf( "%d ", A[ i ] );
		printf( "%d\n", b + 1 );
		return 0;
	}
	int t = 0;
	for( int i = 1; i <= M; ++i ) 
		if( A[ i ] % 2 == 1 ) {
			t = A[ i ];
			break;
		}
	printf( "%d ", t );
	for( int i = 1; i <= M; ++i ) 
		if( A[ i ] % 2 == 0 ) 
			printf( "%d ", A[ i ] );
	printf( "\n" );
	if( t > 1 ) {
		printf( "%d\n", M + 1 );
		printf( "%d ", t - 1 );
		for( int i = 1; i <= M; ++i ) 
			if( A[ i ] % 2 == 0 )
				printf( "%d ", A[ i ] );
		printf( "%d\n", 1 );
	} else {
		printf( "%d\n", M );
		for( int i = 1; i <= M; ++i ) 
			if( A[ i ] % 2 == 0 ) 
				printf( "%d ", A[ i ] );
		printf( "%d\n", 1 );
	}
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
typedef pair<int, int> P;
const long long mod = 1000000007;
const int maxN = 200000;
vector<int>G[200006];
int kj[200006],kji[200006];
int dp1[200006], dp2[200006];
int dp3[200006];
int V;
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res * a%mod;
		a = a * a%mod;
		x >>= 1;
	}
	return res;
}
void setkj() {
	kj[0] = 1;
	for (int i = 1; i <= maxN; i++)kj[i] = kj[i - 1] * i%mod;
	rep(i, maxN + 1)kji[i] = modpow(kj[i], mod - 2);
}

void dfs1(int now, int par) {
	dp1[now] = 1;
	for (int e : G[now]) {
		if (e == par)continue;
		dfs1(e, now);
		dp1[now] *= dp1[e]; dp1[now] %= mod;
		dp1[now] *= kji[dp2[e]]; dp1[now] %= mod;
		dp2[now] += dp2[e];
	}
	dp1[now] = dp1[now] * kj[dp2[now]] % mod;
	dp2[now]++;
}
void dfs2(int now, int par) {
	dp3[now] = kj[V - 1];
	for (int e : G[now]) {
		if (e == par) {
			int S = dp3[e];
			S = S*kji[V - 1]%mod *kj[dp2[now]]%mod* modpow(dp1[now], mod - 2)%mod*kj[V-dp2[now]-1]%mod;
			dp3[now] *= S; dp3[now] %= mod;
			dp3[now] *= kji[V - dp2[now]]; dp3[now] %= mod;
		}
		else {
			dp3[now] *= dp1[e]; dp3[now] %= mod;
			dp3[now] *= kji[dp2[e]]; dp3[now] %= mod;
		}
	}

	for (int e : G[now]) {
		if (e == par)continue;
		dfs2(e, now);
	}

}

signed main() {
	int n; cin >> n; V = n;
	setkj();
	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs1(0, -1);
	dfs2(0, -1);
	rep(i, n)cout << dp3[i] << endl;

}


Measured memory_bytes: 22512
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, k;
  cin >> n >> k;
  
  ll res = 0;
  for (int i = 0; i < n; i++){
    ll x;
    cin >> x;
    
    if (x < k-x){
      res += 2 * x;
    }
    else 
      res += 2 * (k - x);
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#include <vector>
#include <bitset>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

/********** TEMPLATE STARTS HERE ***********/

#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define pb push_back
#define PI 3.1415926535897932384626433832795
#define gcd __gcd 
#define digits(n) (int)(log10(n) + 1)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vl;
typedef vector <pll> vll;
typedef vector <pii> vii;

const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3f3f3f;

template <typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template <typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

main()
{
	IOS
	
	int n;
	cin >> n;
	
	if(n <= 999)
		cout << "ABC";
	else
		cout << "ABD";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,k;
    vector<int> s;
    cin >> a>>b>>k;
    for(int i=min(a,b);i>0;i--){
        if((a%i==0)&&(b%i==0)){
            s.emplace_back(i);
        }
    }
    cout << s.at(k-1) << endl;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <cstring>
#include <climits>

using namespace std;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;

const int MOD = 1e9+7;

class ADontBeLate {
public:
    void solve(std::istream& in, std::ostream& out) {
        double d, t, s;
        in >> d >> t >> s;
        if (d/s <= t)
            out << "Yes" << endl;
        else
            out << "No" << endl;
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ADontBeLate solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3732
def floor_sum(n: int, m: int, a: int, b: int) -> int:
    ans = 0
    while True:
        ans += (n - 1) * n // 2 * (a // m)
        a %= m
        ans += n * (b // m)
        b %= m
        y_max = (a * n + b) // m
        if y_max == 0:
            return ans
        x_max = y_max * m - b
        ans += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, (-x_max) % a

import sys
input = sys.stdin.readline
for _ in range(int(input())):
    print(floor_sum(*map(int, input().split())))

Measured memory_bytes: 71012
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_least8_t;
using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u8 = std::uint_least8_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <array>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  static constexpr usize n = 5;
  static constexpr u64 max_a = 1000000000000000;
  u64 m;
  std::cin >> m;
  u64 min = max_a + 1;
  for (const auto i : rep(0, n)) {
    u64 a;
    std::cin >> a;
    min = std::min(min, a);
  }
  std::cout << (m + min - 1) / min + n - 1 << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char mn[n][n],nm[m][m];
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            cin>>mn[i][j];
    for(int i=0; i<m; i++)
        for(int j=0; j<m; j++)
            cin>>nm[i][j];
    bool flag = false;
    for (int i = 0; i < n - m + 1; i++)
    {
        for (int j = 0; j < n - m + 1; j++)
        {
            bool flag1 = true;
            for (int k = 0; k < m; k++)
            {
                for (int l = 0; l < m; l++)
                {
                    if (mn[i + k][j + l] != nm[k][l])
                    {
                        flag1 = false;
                        break;
                    }
                }
                if (!flag1)
                    break;
            }
            if (flag1)
            {
                flag = true;
                break;
            }
        }
    }
    if (flag)
    {
        cout << "Yes" <<endl;
    }
    else
    {
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ans = [-1 for _ in range(n)]
for _ in range(m):
    s, c = map(int, input().split())
    if ans[s - 1] in [c, -1]:
        ans[s - 1] = c
    else:
        print(-1)
        exit()
if ans[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
    exit()
if ans[0] == -1:
    if n == 1:
        print(0)
        exit()
    ans[0] = 1
ret = str(ans[0])
for i in range(1, n):
    if ans[i] == -1:
        ans[i] = 0
    ret += str(ans[i])
print(int(ret))


Measured memory_bytes: 9152
import java.util.*;
 import java.math.BigInteger;
public class Main
{
	public static  void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		// String h[]=sc.nextLine().split(" ");
		// long n=Long.parseLong(sc.nextLine());
		String s[]=sc.nextLine().split(" ");
		long a=Long.parseLong(s[0]);
		long b=Long.parseLong(s[1]);
		long n=Long.parseLong(s[2]);
		long x=0;
		if(b>n){
		x=n;}
		else{x=b-1;}
		System.out.println((long)(a*x)/(long)b);
	}
	static int get(int [] arr, int k, int i, ArrayList<Pair>ch, int m)
	{
		if(i==arr.length)
		{
			int sum=0;
			for(int u=0;u<ch.size();u++)
			{
				if(arr[ch.get(u).b-1]-arr[ch.get(u).a-1]==ch.get(u).c){sum+=ch.get(u).d;}
			}
			return sum;
		}
		int max=0;
		for(int u=k;u<=m;u++)
		{
			arr[i]=u;
			max=Math.max(max,get(arr,u,i+1,ch,m));
			
		}
		return max;
	}

}
class Pair
{
	int a;
	int b;
	int c;
	int d;
	Pair(int e,int f, int g,int h){
		a=e;
		b=f;
		c=g;
		d=h;
	}
}



	


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

#define nn 200008
int xi[nn],n;
signed main(){
	scanf("%d",&n);for(int i=1;i<=n;i++) scanf("%d",&xi[i]);
	int lst=0,goon=0,ans=0;
	for(int i=1;i<=n;i++){
		if(xi[i]==lst) continue;
		if(goon==-1) goon=(xi[i]>lst);
		if((xi[i]<lst)^goon) ;
		else ans++,goon=-1;;
		lst=xi[i];
	}
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
ans=0
if a==1:
    ans+=300000
elif a==2:
    ans+=200000
elif a==3:
    ans+=100000
if b==1:
    ans+=300000
elif b==2:
    ans+=200000
elif b==3:
    ans+=100000
if ans==600000:
    ans+=400000
print(ans)


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

long long n_max = 300;

int main(){
    long long n;
    long long w[n_max + 1];
    long long i,j,d;
    long long dp[n_max + 1][n_max + 1];

    //input
    cin >> n;
    while(n > 0){
        for(i = 1; i <= n; i++){
            cin >> w[i];
        }

        //calc
        for(i = 1; i <= n-1; i++){
            dp[i][i+1] = 2*(abs(w[i]-w[i+1]) <= 1);
        }
        for(d = 3; d <= n-1; d += 2){
            for(i = 1; i <= n-d; i++){
                dp[i][i+d] = dp[i+1][i+d-1] + (dp[i+1][i+d-1] == d-1 ? 2*(abs(w[i]-w[i+d]) <= 1) : 0);
                for(j = i+1; j <= i+d-2; j += 2){
                    dp[i][i+d] = max(dp[i][i+d], dp[i][j] + dp[j+1][i+d]);
                }
            }
        }
        if(n % 2 == 1){
            dp[1][n] = max(dp[1][n-1], dp[2][n]);
        }

        //answer
        cout << dp[1][n] << endl;

        //input
        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int i,h,n,damage=0,a[100010]={};
    scanf("%d %d",&h,&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
        damage+=a[i];
    }
    if(damage>=h){
        printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 2092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    string s;
    int n;
    cin>>n>>s;
    rep(i,s.length()){
        cout<<(char)('A'+(s[i]-'A'+n+26)%26);
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Map<Integer, Integer>> al = new ArrayList<Map<Integer,Integer>>();
        for(int i = 0; i < N; i++){
            int A = sc.nextInt();
            HashMap<Integer,Integer> tmpl = new HashMap<Integer, Integer>();
            for(int j = 0; j < A; j++){
                int xn = sc.nextInt();
                int yn = sc.nextInt();
                tmpl.put(xn,yn);
            }
            al.add(tmpl);
        }
        int ans = 0;
        int max_q = (int)Math.pow(2,N);
        for(int i = 0; i < max_q; i++){
            boolean bool = true;
            int cnt = 0;
            for(int j = 0; j < N; j++){
                if((i >> j) % 2 == 0){
                    continue;
                }
                cnt++;
                for(Map.Entry<Integer, Integer> entry : al.get(j).entrySet()){
                    int key = entry.getKey()-1;
                    int val = entry.getValue();
                    if((i >> key) % 2 != val){
                        bool = false;
                    }
                }
            }
            if(bool){
                ans = Math.max(ans,cnt);
            }
        }
        System.out.println(ans);
    }
}



Measured memory_bytes: 33844
#include <stdio.h>
#include <math.h>
int main(){

  int x,y,i,n,tmp;
  
  /*入力*/
  scanf("%d %d",&x,&y);

  /*制約*/
  if(x>=1&&y<=pow(10,9)){

  if(x>=y){
    tmp = y;
    y = x;
    x = tmp;
  }

  n=y%x;
  while(n!=0){
    y = x;
    x = n;
    n = y%x;
  }
  printf("%d\n",x);
  
  }
}



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

int cnt1[250], cnt2[250], cnt3[250], cnt4[250];
int main()
{
    string a,b;
    cin>>a>>b;
    for(int i=0; i<a.size(); i++)
    {
        cnt1[a[i]]++;
        cnt3[a[i]]++;
    }
    for(int i=0; i<b.size(); i++)
    {
        cnt2[b[i]]++;
        cnt4[b[i]]++;
    }
    // sort(a.begin(), a.end());
    // cout<<a<<endl;
    bool flag = true;

    int j = 0, cnt = 0;
    for(int i='a'; i<='z'; i++)
    {
        while(cnt1[i]>0 && cnt2[i]>0)
        {
            cnt++;
            cnt1[i]--;
            cnt2[i]--;
        }
    }
    if(a.size()<b.size() && cnt==a.size())
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    else
    {
        cnt = 0;
        for(int i='a'; i<='z'; i++)
        {
            while(cnt3[i]>0 && cnt4[i]>0)
            {
                int i1, i2;
                for(int i='a'; i<='z'; i++)
                {
                    if(cnt3[i]>0)
                    {
                        i1 = i;
                        break;
                    }

                }

                for(int i='z'; i>='a'; i--)
                {

                    if(cnt4[i]>0)
                    {
                        i2 = i;
                        break;
                    }
                }
                //cout<<i1<<" "<<i2<<endl;
                if(i1<i2)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }

                cnt++;
                cnt3[i]--;
                cnt4[i]--;

            }
        }
        cout<<"No"<<endl;


        //string t1="", t2="";

    }




    return 0;
}


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

void run(void){
  int h,w;
  scanf("%d%d",&h,&w);
  char s[]="snuke";
  for(int i=0;i<h*w;i++){
    char t[6];
    scanf("%s",t);
    if(strcmp(s,t)==0){
      printf("%c%d\n",'A'+i%w,1+i/w);
    }
  }
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
table = [list(".,!? "), list("abc"), list("def"), list("ghi"),
        list("jkl"), list("mno"), list("pqrs"), list("tuv"),
        list("wxyz")]

n = int(raw_input())

for _ in range(n):
    msg = raw_input().replace("\r", "")
    ans = ""; j = 0; t = "";

    for i in msg:
        if i == "0":
            ans += t
            j = 0; t = ""
        else:
            t = table[int(i)-1][j]
            j += 1
            j %= len(table[int(i)-1])

    print ans



Measured memory_bytes: 4660
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] hi = new int[n];
    for (int i = 0; i < n; i++) {
      hi[i] = Integer.parseInt(sc.next());
    }
    boolean isOk = true;
    for (int i = 0; i < n - 1; i++) {
      int current = hi[i];
      int next = hi[i + 1];
      if (next > current) {
        next--;
      }
      if (current > next) {
        isOk = false;
        break;
      }
      hi[i + 1] = next;
    }
    if (isOk) {
      pw.println("Yes");
    } else {
      pw.println("No");
    }
  }
}


Measured memory_bytes: 48744
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
 
public class Main {
	private static FastScanner sc = new FastScanner();
	
	public static void main(String[] args) {
		char[] S = sc.next().toCharArray();
		boolean flag = false;
		for(int i=0; i<S.length; i++) {
			if(!flag) {
				if(S[i] == 'A') {
					flag = true;
				}
			} else {
				if(S[i] == 'C') {
					System.out.println("Yes");
					return;
				} else {
					flag = false;
				}
			}
		}
		System.out.println("No");
	}
	
	static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 23124