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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    vll d(n);
    rep(i, n) cin >> d[i];

    sort(all(d));

    cout << d[n/2]-d[n/2-1] << endl;

    return 0;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
const ll INF=1e18+5;
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];
 
    int m;
    if (n % 2 == 0) m = 1;
    else m = 2;
 
    vvl dp(n + 10, vl(m + 1, -INF));
    for (int i = 0; i <= m; i++) {
        dp[i][i] = 0;
    }
 
    rep (i, n) {
        rep (j, m + 1) {
            if (dp[i][j] == -INF) continue;
            chmax(dp[i + 2][j], dp[i][j] + a[i]);
            if (j + 1 <= m) {
                chmax(dp[i + 3][j + 1], dp[i][j] + a[i]);
            }
            if (j + 2 <= m) {
                chmax(dp[i + 4][j + 2], dp[i][j] + a[i]);
            }
        }
    }
 
    ll ans = -INF;
    int mi;
    if (n % 2 == 0) mi = 0;
    else mi = 1;
    for (int i = n; i <= n + 5; i++) {
        for (int j = mi; j <= m; j++) {
            chmax(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15868
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
const long long inf=1e9+7;
const long long mod=1e9+7;
const int64_t CYCLES_PER_SEC=2800000000;
//
inline uint32_t Xor128(){
	static uint32_t x=123456789;
	static uint32_t y=362436069;
	static uint32_t z=521288629;
	static uint32_t w=88675123;
	uint32_t t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct Timer{
	int64_t start;
	Timer(){reset();}
	void reset(){start=getcycle();}
	void plus(double a){start-=(a*CYCLES_PER_SEC);}
	inline double get(){return (double)(getcycle()-start)/CYCLES_PER_SEC;}
	inline int64_t getcycle(){
		uint32_t low,high;
		__asm__ volatile ("rdtsc":"=a"(low),"=d"(high));
		return ((int64_t)low)|((int64_t)high<<32);
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val Array(n, m, x, y) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	val a = scala.io.StdIn.readLine.split(" ").map(_.toInt).max
	val b = scala.io.StdIn.readLine.split(" ").map(_.toInt).min

	var f1 = false

	for(cnt <- x+1 to y){
		if(cnt > a && cnt <= b){
			f1 = true
		}
	}

	if(f1) println("No War")
	else println("War")
}

Measured memory_bytes: 27176
#include<stdio.h>
#include<string.h>
int main(void){
  int i, j, N, ac=0, wa=0, tle=0, re=0;
  scanf("%d", &N);
  char S[N][4];
  for(i=0; i<N; i++){
    scanf("%s", &S[i]);
    if(S[i][0]=='A'){
      ac++;
    }
    if(S[i][0]=='W'){
      wa++;
    }
    if(S[i][0]=='T'){
      tle++;
    }
    if(S[i][0]=='R'){
      re++;
    }
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ac,wa,tle,re);
  return 0;
}

Measured memory_bytes: 2116
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    ll n; cin >> n;
    ll dp[n+1];
    FOR(i, 1, n+1) {
        dp[i] = 0;
    }

    FOR(i, 1, n+1) {
        ll temp = i;
        ll counter = 1;
        while(temp<=n) {
            if (temp<=n) dp[temp]++;
            counter++;
            temp = i * counter;
        }
    }

    ll ans = 0;
    FOR(i, 1, n+1) {
        ans += dp[i] * i;
    } 
    print(ans);
    return 0;
}


Measured memory_bytes: 81704
def check(a,b):
  c = 0
  for i in range(max(0,a-1),min(h,a+2)):
    for j in range(max(0,b-1),min(w,b+2)):
      if s[i][j] == '#':
        c += 1
  return c
h,w = map(int,input().split())
s = [0] * h
for i in range(h):
  s[i] = list(input())
ns = [[0]*w for i in range(h)]
for a in range(h):
  for b in range(w):
    if s[a][b] != '#':
      ns[a][b] = str(check(a,b))
    else:
      ns[a][b] = '#'
for a in range(h):
  print(''.join(ns[a]))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

//////////////////////////////////////////////////////
//Union Find /////////////////////////////////////////
//////////////////////////////////////////////////////
int par[MAX_N];
int rak[MAX_N];

void init(int n) {
	rep(i, 0, n) {
		par[i] = i;
		rak[i] = 0;
	}
}

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

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rak[x] < rak[y]) par[x] = y;
	else {
		par[x] = y;
		if (rak[x] == rak[y]) rak[x]++;
	}
}

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

int main() {
	ll n, q; cin >> n >> q;
	init(n);

	rep(i, 0, q) {
		ll a, b, c; cin >> a >> b >> c;
		if (a == 0) {
			unite(b, c);
		}
		else if (a == 1) {
			cout << (same(b, c) ? 1 : 0) << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3280
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {	
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int ans=0;
	if (a + b > 2 * c) {
		ans += min(x, y) * 2 * c;
	}
	else {
		ans += min(x, y) * (a+b);
	}
		if (x > y) {
			if (a < 2 * c) {
				ans += (x - y)*a;
			}
			else {
				ans += (x - y) * 2 * c;
			}
		}
		else {
			if (b < 2 * c) {
				ans += (y - x)*b;
			}
			else {
				ans += (y - x) * 2 * c;
			}
		}
	cout << ans << endl;



	return 0;

}

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

using namespace std;

const int max_n = -1, inf = 1000111222;

int a, b, c;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

//0-indexed
class SegTree{

private:

    int n;
    vector<int> seg;
    int init = 0; //初期化の値（単位元）
    int combine(int a, int b){
        return max(a,b);
    }

public:

    SegTree(int size){
		n=1;
		while(n<size)n<<=1;
		seg=vector<int>(2*n,init);
	}

	SegTree(const vector<int> &in){
		n=1;
		while(n<in.size())n<<=1;
		seg=vector<int>(2*n,init);
		for(int i=n-1+in.size()-1;i>=0;i--){
			if(n-1<=i)seg[i]=in[i-(n-1)];
			else seg[i]=combine(seg[i*2+1],seg[i*2+2]);
		}
	}


    //k-th(0-indexd) wo a
    void update(int k,int a){
      k+=n-1;
      seg[k]=a;
      while(k>0){
        k=(k-1)/2;
        seg[k]=combine(seg[k*2+1],seg[k*2+2]);
      }
    }

    //[a,b)について調べる
    int query(int a,int b,int k=0,int l=0,int r=-1){
        if(r==-1)r=n;
        if(r<=a || b<=l)return init;
        if(a<=l &&r<=b)return seg[k];

        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);

        return combine(vl,vr);
    }
};


signed main(void) {
    int i,j;
    int n, c;
    cin >> n >> c;
    vector<pii> x(n),y(n);
    rep(i,n){
        int t,v;
        cin >> t >> v;
        x[i] = pii(t,v);
        y[i] = pii(c-t,v);
    }
    sort(all(x));
    sort(all(y));
    rep(i,n-1){
        x[i+1].second += x[i].second;
        y[i+1].second += y[i].second;
    }
    vi a(n),aa(n),b(n),bb(n);
    rep(i,n){
        a[i] = x[i].second - x[i].first;
        aa[i] = x[i].second - 2*x[i].first;
        b[i] = y[i].second - y[i].first;
        bb[i] =  y[i].second - 2*y[i].first;
    }

    SegTree a1(a),a2(aa),b1(b),b2(bb);

    int ans = 0;
    rep(i,n+1){
        ans = max(ans, a1.query(0,i) + b2.query(0,n-i));
        ans = max(ans, a2.query(0,i) + b1.query(0,n-i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#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 _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




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

struct UnionFind{
    vector<int> rank, p;
    UnionFind(int N){
            rank.resize(N, 0);
            p.resize(N, 0);
            for(int i=0; i < N; i++) makeSet(i);
    }
    void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
    }
    bool same(int x, int y){
            return findSet(x) == findSet(y);
    }
    void unite(int x, int y){
            link(findSet(x), findSet(y));
    }
    void link(int x, int y){
            if(rank[x] > rank[y]){
                    p[y] = x;
            }else{
                    p[x] = y;
                    if(rank[x] == rank[y]){
                            rank[y]++;
                    }
            }
    }
    int findSet(int x){
            if(x != p[x]){
                    p[x] = findSet(p[x]);
            }
            return p[x];
    }
};

int main() {
    ll n, m; cin >> n >> m;
    UnionFind ds = UnionFind(n+1);

    Vl x(m), y(m), z(m);
    rep(i, 0, m){
        cin >> x[i] >> y[i] >> z[i];
    }
    rep(i, 0, m){
        ds.unite(x[i], y[i]);
    }
    // Rep(i, 1, n) cout << ds.findSet(i) << " ";
    // coel;
    ll ans = 0;
    set<ll> se;
    Rep(i, 1, n){
        if(ds.findSet(i) == i){
            ans++;
        }
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 3328
// --------------
// Tejas Pandey  |
// 21 - 03 - 20  |
// AtCoder BC 159|
// --------------

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

#define mod 998244353
#define vi vector<int>
typedef long long int ll;

int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  int h,w,lk;
  cin >> h >> w >> lk;
  char mat[h][w];
  for(int i = 0;i < h;i++)
	for(int j = 0;j < w;j++)
		cin >> mat[i][j];
  int ans = -1;
  for(int i = 0;i < (1LL<<(h - 1));i++){
  	int cnt = 0;
  	int fk = 1;
  	for(int j = 10;j > -1;j--)
  		if(i&(1LL<<j)) fk++;
  	int sum[fk][w][2],flag = 0;
  	memset(sum,0,sizeof(sum));
  	for(int k = 0;k < w;k++){
  		int cur = 0;
  		for(int j = 0;j < h;j++){
  			sum[cur][k][1] += (mat[j][k] - '0'),sum[cur][k][0] += ('1' - mat[j][k]);
  			if(i&(1LL<<j)) cur++;
  		}
  		int flg = 0;
  		for(int ii = 0;ii < fk;ii++)
  		if(sum[ii][k][1] > lk){
  			//cout << ii << " " << k << " " << " " << i << " " << sum[ii][k][1] << " " << sum[ii][k][0] << "\n";
  			flg = 2;
  			break;
  		}
  		else if(k && (sum[ii][k][1] + sum[ii][k - 1][1] > lk)){
  			flg = 1;
  		}
  		if(!(flg - 2)){
  			flag = 1;
  			break;
  		}
  		if(!(flg - 1)) cnt++;
  		if(!flg && k){
  			for(int ii = 0;ii < fk;ii++)
  			sum[ii][k][1] += sum[ii][k - 1][1],sum[ii][k][0] += sum[ii][k - 1][0];
  		}
  	}
  	if(flag) continue;
  	if(ans == -1 || ans > cnt + fk - 1)
  		ans = cnt + fk - 1;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define sz 200002
#define pb push_back
#define ff first
#define ln '\n'
#define ss second
#define ll long long
#define VEC vector<ll int>v
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{

ll int n,m;
cin>>n>>m;
if(n==1||m==1)cout<<"1"<<endl;
else
cout<<(n*m+1LL)/2LL<<endl;


}


Measured memory_bytes: 256
S = input()
T = input()

ans = 10000000
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)


Measured memory_bytes: 9064
import System.IO
import Data.List

yummyAndPoisonedSumUp :: (Int, Int, Int) -> Int
yummyAndPoisonedSumUp tupple = do
  let (yuck, yummy, poisoned) = tupple
  poisoned + yummy

eatableCount :: Int -> Int -> Int -> (Int, Int, Int)
eatableCount yuck yummy poisoned
  | poisoned <= (unpoisoned) = (yuck, yummy, poisoned)
  | poisoned >  (unpoisoned) = (yuck, yummy, unpoisoned + 1)
  where unpoisoned = yuck + yummy


main = do
  args <- getLine
  let stringArray = words args
  let [a, b, c] = [ read numberStr | numberStr <- stringArray ] :: [Int]
  putStr $ show $ yummyAndPoisonedSumUp $ eatableCount a b c




Measured memory_bytes: 508
# 2019/03/30
# エクサウィザーズ 2019 - B

# Input
n = int(input())
s = input()

rcnt = 0

for i in range(n):
    if s[i] =="R":
        rcnt += 1

if (n - rcnt) < rcnt:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)


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

using ll=long long;
using P=pair<int,int>;

const int MOD=1e9+7;
const int INF=1<<30;
const int MAX=1e5;

int n;

template<class T>
inline void xmin(T &a, T b){a=(a<b)?a:b;}
template<class T>
inline void xmax(T &a, T b){a=(a>b)?a:b;}



void solve(){
    cin>>n;
    bool flag=false;    
    for(int i=1; i<10; i++){
        if(n%i==0 && (n/i)<10){
            flag=true;
            break;
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


signed main(){
    //while(1)
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> maze(n+1);
    for (int i=0;i<n+1;i++) maze[i] = 0;
    for (int i=0;i<m;i++){
        int a; cin >> a;
        maze[a] = 1;
    }
    int first=0;
    int last = 0;
    for (int i=0;i<x;i++){
        if (maze[i+1] ==1) first += 1;
    }
    for (int i=x;i<n;i++){
        if (maze[i+1] == 1) last += 1;
    }
    cout << min(first,last) << endl;

    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a;
  cin >> a;
  if(a==1)cout << 0;
    else cout << 1;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
using namespace std;
const int Max=1e5+7;
bool vis[Max];
int ns[Max];
int Ed(int n){
	int i,j;
	memset(ns,0,sizeof(ns));
	for(i=0;i<n;i++) vis[Max]=false;
	for(i=2;i<n;i++){
		ns[i]=ns[i-1];
		if(!vis[i]){
			for(j=2*i;j<n;j+=i) vis[j]=true;
			if(i>2 && !vis[(i+1)/2])	ns[i]+=1;
		}
			
	}
}
int main(){
	int n,k,i,j;
	cin>>n;
	int a[n], b[n],ans[n];
	for(i=0;i<n;i++) cin>>a[i]>>b[i];
	Ed(Max);
//	for(i=0;i<30;i++) cout<<"i="<<i<<" ns="<<ns[i]<<" ";cout<<endl;
	for(i=0;i<n;i++){
		cout<<ns[b[i]]-ns[a[i]-1];
		if(i<n-1) cout<<'\n';
	}
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	string s;
	cin >> s;
	if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3596
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Leaping Tak
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_K = 10;
const int MOD = 998244353;

/* typedef */

typedef pair<int,int> pii;

template <typename T, const int MAX_N, const int MOD>
struct BITMod {
  int n;
  T bits[MAX_N + 1];
  BITMod() {}

  void init(int _n) {
    n = _n;
    //memset(bits, 0, sizeof(bits));
  }

  void addmod(T &a, T b) { a = (a + b) % MOD; }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      addmod(s, bits[x]);
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      addmod(bits[x], v);
      x += (x & -x);
    }
  }
};

/* global variables */

pii lrs[MAX_K];
BITMod<int,MAX_N,MOD> bit;

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  for (int i = 0; i < k; i++) {
    scanf("%d%d", &lrs[i].first, &lrs[i].second);
    lrs[i].second++;
  }
  sort(lrs, lrs + k);

  bit.init(n);
  bit.add(1, 1);
  bit.add(2, MOD - 1);

  for (int i = 1; i < n; i++) {
    int di = bit.sum(i);
    for (int j = 0; j < k && i + lrs[j].first <= n; j++) {
      bit.add(i + lrs[j].first, di);
      if (i + lrs[j].second <= n)
	bit.add(i + lrs[j].second, MOD - di);
    }
  }

  printf("%d\n", bit.sum(n));
  //for (int i = 1; i <= n; i++) printf("%d ", bit.sum(i)); putchar('\n');
  return 0;
}


Measured memory_bytes: 4596
#include <stdio.h>
int main(){
  long long n,i,a,b,min=1000000,max=-1000000,sum,tem,t;
  scanf("%lld",&n);
  sum = 0;
  for(i=0;i<n;i++){
    scanf("%lld",&a);
    sum = sum + a;
    if(a<min){
      min=a;
    }
    if(a>max){
      max=a;
  }
  }
  printf("%lld ",min);
  printf("%lld ",max);
  printf("%lld\n",sum);
  return 0;
}
     
    


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int dy=tx-sx;
  int dx=ty-sy;
  if(dx>0){
    for(int i=0;i<dx;i++){
      cout<<"U";
    }
  }else{
    for(int i=0;i>dx;i--){
      cout<<"D";
    }
  }
  if(dy>0){
    for(int i=0;i<dy;i++){
      cout<<"R";
    }
  }else{
    for(int i=0;i>dy;i--){
      cout<<"L";
    }
  }

  if(dx>0){
    for(int i=0;i<dx;i++){
      cout<<"D";
    }
  }else{
    for(int i=0;i>dx;i--){
      cout<<"U";
    }
  }
  if(dy>0){
    cout<<"L";
    for(int i=0;i<dy;i++){
      cout<<"L";
    }
  }else{
    cout<<"R";
    for(int i=0;i>dy;i--){
      cout<<"R";
    }
  }

  if(dx>0){
    cout<<"U";
    for(int i=0;i<dx;i++){
      cout<<"U";
    }
  }else{
    cout<<"D";
    for(int i=0;i>dx;i--){
      cout<<"D";
    }
  }
  if(dy>0){
    cout<<"R";
    for(int i=0;i<dy;i++){
      cout<<"R";
    }
  }else{
    cout<<"L";
    for(int i=0;i>dy;i--){
      cout<<"L";
    }
  }
  
  if(dx>0){
    cout<<"D";
  }else{
    cout<<"U";
  }

  if(dy>0){
    cout<<"R";
  }else{
    cout<<"L";
  }

  if(dx>0){
    cout<<"D";
    for(int i=0;i<dx;i++){
      cout<<"D";
    }
  }else{
    cout<<"U";
    for(int i=0;i>dx;i--){
      cout<<"U";
    }
  }
  if(dy>0){
    cout<<"L";
    for(int i=0;i<dy;i++){
      cout<<"L";
    }
  }else{
    cout<<"R";
    for(int i=0;i>dy;i--){
      cout<<"R";
    }
  }

  if(dx>0){
    cout<<"U";
  }else{
    cout<<"D";
  }

  cout<<endl;
}


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

using pii = pair<int, int>;

struct unionfind {
    vector<int> par;
    unionfind(int n) : par(n, -1) {}
    void unite(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (size(a) > size(b)) swap(a, b);
        par[b] += par[a];
        par[a] = b;
    }
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    int same(int a, int b) { return root(a) == root(b); }
    int size(int x) { return -par[root(x)]; }
};

signed main() {
    int N, M;
    cin >> N >> M;
    vector<pii> p(N);
    REP(i, N) {
        int x, y;
        cin >> x >> y;
        p[i] = {x, y};
    }
    
    vector<pair<double, pii>> edge(M);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        double dx = p[a].first - p[b].first;
        double dy = p[a].second - p[b].second;
        double cost = sqrt(dx * dx + dy * dy);
        edge[i] = {-cost, {a, b}};
    }
    sort(begin(edge), end(edge));

    unionfind uf(N);
    double ans = 0;
    REP(i, M) {
        double cost = edge[i].first;
        int a = edge[i].second.first;
        int b = edge[i].second.second;
        if (uf.same(a, b)) {
            ans += -cost;
        } else {
            uf.unite(a, b);
        }
    }
    cout << setprecision(20) << fixed << ans << endl;
    return 0;
}



Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e9;

int main() {
  // 全探索
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X[i];
  int ans = INF;
  for (int i = 1; i < 101; i++) {
    int temp = 0;
    for (int x : X) {
      temp += pow((i - x), 2);
    }
    if (temp < ans) ans = temp;    
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int N, M;
double vv[16][16];
double dp[16][1 << 16];

double rec(int idx, int bit)
{
  if(idx == N) return (1.0);
  if(dp[idx][bit] >= 0) return (dp[idx][bit]);
  double ret = 0;
  for(int i = 0; i < M; i++) {
    if((bit >> i) & 1) continue;
    double beet = 0, fact = 1.0;
    for(int j = idx; j < N; j++) {
      beet += rec(j, bit | (1 << i)) * (1.0 - vv[i][j]) * fact;
      fact *= vv[i][j];
    }
    ret = max(ret, beet + fact);
  }
  return (dp[idx][bit] = ret);
}

int main()
{
  cin >> M >> N;
  for(int i = 0; i < M; i++) {
    for(int j = 0; j < N; j++) {
      cin >> vv[i][j];
    }
  }
  fill_n(*dp, (1 << 16) * 16, -1);
  cout << fixed << setprecision(13) << rec(0, 0) << endl;
}

Measured memory_bytes: 11460
/*input
1 1000000000
1000000000 10
*/
 
// author - Madhav Thakker
 
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace std;
 
#define ll long long
#define ld long double
#define int ll
#define endl '\n'

typedef pair<int, int> pii; 
typedef pair<ld, ld> pdd;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
const int MOD = 1e9+7;
 
 
int fast_pow(int a, int b){
	int res = a, ret = 1;
	while(b>0){
		if(b%2)
			ret = (ret*res)%MOD;
		res = (res*res)%MOD;b/=2;
	}
	return ret;
}
 
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';
// str = to_string(n)
// stoi , stoll, stol
// sort(arr, arr+n, greater<int>());
// fill(prefix.begin(), prefix.end(), 0);
// 
// 
 
 
 
////
const int maxN = 1e5+700;
pii arr[105];
int dp[maxN][105];
////


signed main(){
 
	fastio;
	time_t time_t1, time_t2;
	time_t1 = clock();
 
	////////////////////////////////

	int t = 1;
	// cin >> t ;

	while(t--){

		int n, w;
		cin >> n >> w;
		int wt, val;
		
		for (int i = 1; i <= n; ++i){
			cin >> wt >> val;
			arr[i] = {wt, val};
		}
		
		for (int i = 0; i <= 1e5; ++i){
			for (int j = 0; j <= n; ++j){
				dp[i][j] = 1e10;
			}
		}

		for (int i = 0; i <= n; ++i){
			dp[0][i] = 0;
		}
		
		for (int i = 1; i <= 1e5; ++i){
			for (int j = 1; j <= n; ++j){
				dp[i][j] = dp[i][j-1];
				if(arr[j].second > i){
					continue;
				}
				dp[i][j] = min(dp[i][j], dp[i-arr[j].second][j-1] + arr[j].first);
			}
		}
		// trace(dp[30][n]);
		int ans = 0;
		for (int i = 0; i <= 1e5; ++i){
			if(dp[i][n] <= w){
				ans = max(ans, i);
			}
		}
		cout << ans << endl;

	}
 	
	///////////////////////////////
	// 
 
	time_t2 = clock();
	// cerr << "time taken :" << time_t2 - time_t1 << endl;
 
	return 0;
}


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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.00000000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;

int p[N], a[N], h[N];
VI g[N];

void solve() {
    int n,m;
    cin >> n >> m;

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

    for (int i = 1; i <= m; i++){
        int a,b;
        cin >> a >> b;
        g[a].PB(b);
        g[b].PB(a);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++){
        int z = 0;
        for (int q : g[i]){
            if (h[q] < h[i]) z++;
        }
        if (z == SZ(g[i])) ans++;
    }

    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

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

int visit[100005][3];
vector<int> X[100005];

queue< pair<int, int> > Q;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N, M;
    cin >> N >> M;

    while(M--)
    {
        int u, v;
        cin >> u >> v;

        X[u].push_back(v);
    }

    int s, t;
    cin >> s >> t;

    Q.push({s, 0});
    visit[s][0] = 1;

    while(!Q.empty())
    {
        int indx = Q.front().first, f = Q.front().second;
        Q.pop();

        for(auto x : X[indx])
        {
            if(visit[x][(f+1)%3])
                continue;
            
            visit[x][(f+1)%3] = visit[indx][f] + 1;
            Q.push({x, (f+1)%3});
        }
    }

    cout << (visit[t][0] == 0 ? -1 : (visit[t][0] - 1) / 3) << "\n";
    return 0;
}


Measured memory_bytes: 6912
# 入力
N,M=map(int,input().split())

l1=[]
for i in range(N):
  l1.append(list(map(int,input().split())))

l2=[]
for i in range(M):
  l2.append(list(map(int,input().split())))

for i in range(N):
  # 距離の最小値（1つ目のチェックポイントへの距離で初期化している）
  d=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])

  # 最も近いチェックポイントの番号（1番目で初期化）
  b=1

  # 2つ目以降のチェックポイントへの距離を求める
  for j in range(1,M):
    x=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])

    # 距離がより小さい場合のみ更新
    if x<d:
      d=x
      # 0-index なので調整するために +1 している
      b=j+1

  # チェックポイントの番号を出力
  print(b)

Measured memory_bytes: 3064
// Problem : B - ROT N
// Contest : AtCoder - AtCoder Beginner Contest 146
// URL : https://atcoder.jp/contests/abc146/tasks/abc146_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    string s;
    int n;
    cin>>n>>s;
    for(char &c : s){
        int x = c-'A';
        x += n;
        x %= 26;
        c = x+'A';
    }
    cout<<s<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________


	int n;
	cin >> n;
	string s[n];
	zip(i, 0, n)
	{
		cin >> s[i];
		sort(all(s[i]));
	}
	map<string, int>m;
	zip(i, 0, n)
	{
		m[s[i]]++;
	}
	int ans = 0;
	for (auto it = m.begin(); it != m.end(); it++)
	{
		int x = it->ss;
		ans += (x * (x - 1)) / 2;
	}
	cout << ans << en;


	return 0;
}



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

constexpr ll INF = 1e14;
vector<ll> position;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<pair<int, int>>> G(N+1);
    vector<tuple<int, int, int>> LRD(M);
    for (int i = 0; i < M; i++) {
        int l, r, d; cin >> l >> r >> d;
        LRD[i] = tuple<int, int, int>(l, r, d);
        G[l].push_back(pair<int, int>(r, d));
        G[r].push_back(pair<int, int>(l, -d));
    }
    position.resize(N+1);
    fill(position.begin(), position.end(), INF);
    queue<int> q; q.push(1);
    for (int i = 1; i <= N; i++) {
        if (position[i] == INF) {
            q.push(i);
            position[i] = 0;
        }
        while (!q.empty()) {
            int x = q.front(); q.pop();
            for (auto y : G[x]) {
                if (position[y.first] == INF) {
                    position[y.first] = position[x] + y.second;
                    q.push(y.first);
                }
            }
        }
    }
    for (int i = 0; i < M; i++) {
        int l = get<0>(LRD[i]);
        int r = get<1>(LRD[i]);
        int d = get<2>(LRD[i]);
        if (position[r] - position[l] != d) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << (e - a > k ? ":(" : "Yay!") << endl;
    return 0;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
grid=[['#']*50+['.']*50 for i in range(100)]
A-=1
B-=1
for i in range(0,43,2):
    for j in range(0,100,2):
        if A<=0:
            break
        grid[j][i]='.'
        A-=1
for i in range(66,100,2):
    for j in range(0,100,2):
        if B<=0:
            break
        grid[j][i]='#'
        B-=1
print(100,100)
for i in range(100):
    print(''.join(grid[i]))

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define dbg(var) {std::cout << #var << "  = " << var << nl;}
#define vi vector<int>
typedef long long ll;

using namespace std;

constexpr int MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n , m;
	cin >> n >> m;
	
	vector<string> v{istream_iterator<string>(cin) , istream_iterator<string>()};
	vector<vi> dp(n , vi(m , 0));

	rep(i , n)
	{
		rep(j , m)
		{
			if(i == 0 && j == 0)
				dp[i][j] = (v[i][j] == '.');
			else if(v[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (i > 0 ? dp[i - 1][j] : 0) + (j > 0 ? dp[i][j - 1] : 0);
			dp[i][j] %= MOD;
		}
	}

	cout << dp[n - 1][m - 1] << endl;
	

	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	string S;
	cin >> N >> K >> S;

	vector<int> a(N, 0);
	
	if (S[0] == '0') {
		a[0] = 1;
	}
	for (int i = 1; i < N; ++i) {
		a[i] = a[i - 1];
		if (S[i - 1] == '1' && S[i] == '0') {
			a[i] += 1;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (i == 0 || S[i] == '1') {
			int val = a[i] + K;
			if (i == 0) {
				val -= 1;
			}
			auto it = upper_bound(a.begin() + i, a.end(), val);
			int result = it - (a.begin() + i);
			ans = max(ans, result);
		}
	}
	cout << ans << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;
int main() {
	int n; cin >> n;

	vector<int>a(n);
	rep(i, n)cin >> a[i];

	map<int, int>mp;
	rep(i, n) {
		mp[a[i]]++;
	}

	int count = 0;

	//ステップ1

	for (pair<int,int>p : mp) {
		if (p.second < p.first) {
			count += p.second;
		}
	}
	
	//ステップ2

	for (pair<int, int>p : mp) {
		if (p.second > p.first) {
			count += p.second - p.first;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 5120
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

def main():
    cnt = 0
    for i in range(N):
        val = C
        for j in range(M):
            val += A[i][j] * B[j]
        if val > 0:
            cnt += 1
    return cnt

print(main())


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int c[505],s[505],f[505];

int main ()
{
	int n;
	cin >> n;
	for(int i=0;i<n-1;i++){
		cin >> c[i] >> s[i] >> f[i];
	}
	for(int i=0;i<n-1;i++){
		int t = s[i];
		for(int j=i;j<n-1;j++){
			if(t<s[j]){
				t = s[j];
			}
			else{
				if((t-s[j])%f[j]!=0){
					t += f[j]-(t-s[j])%f[j];
				}
			}
			t += c[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
	return 0;
}

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

signed main(){
	int a,b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define MEM(x) memset(x,0,sizeof(x))
#define vc vector<int>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define inf 0x3f3f3f3f
#define t_case int tt; cin>>tt; while (tt--)
#define lnginf 9223372036854775807
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define For(i,j,k) for (int i=(int)(j);i<(int)(k);i++)
#define ins insert
#define in(x); { for (auto &i : x) cin >> i; }
#define out(x); { for (auto i : x) cout<<i<<' ' ; }
#define PI 3.14159265359
const long long LL_INF = (long long) 2e18 + 5;
using namespace std;
//const int N = 1e5 + 1;
void solve() {
	int n; cin >> n;
	int ans = 0;
	For(i, 1, n + 1) {
		int m = n / i;
		ans += i * (m * (m + 1)) / 2;
	}
	cout << ans << '\n';

}
int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	fastio   solve();


}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if(u.equals(s)) a--;
        else if(u.equals(t)) b--;
        System.out.println(a + " " + b);
    }
}

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

int H,W;
vector<string> a;
int dp[1100][1100] = {0};

void add(int& a, int b){
  a += b;
  if(a>=1000000007) a -= 1000000007;
}

int main(){
	cin >> H >> W;
  a.resize(H);
  for(int i=0;i<H;++i) cin >> a[i];
  // 1,1への経路は1通り
  dp[0][0] = 1;
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      // move below
      if(i+1<H && a[i+1][j]=='.') add(dp[i+1][j],dp[i][j]);
      // move right
      if(j+1<W && a[i][j+1]=='.') add(dp[i][j+1],dp[i][j]);
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}

Measured memory_bytes: 5632
D = int(input())
C = [int(T) for T in input().split()]
S = [[] for TD in range(0,D)]
for TD in range(0,D):
    S[TD] = [int(T) for T in input().split()]
Type = 26
Last = [0]*Type
Sats = 0
for TD in range(0,D):
    Test = int(input())-1
    Last[Test] = TD+1
    Sats += S[TD][Test]
    for TC in range(0,Type):
        Sats -= C[TC]*(TD+1-Last[TC])
    print(Sats)

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n;
string a,b;
int main()
{
 
    cin>>n>>a>>b;
    rep(i,0,n-1)
        cout<<a[i]<<b[i];

}




Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
int main(void){
    int N,M;
    cin>>N>>M;
    int X[M];
    for(int i=0;i<M;i++){
        cin>>X[i];
    }
    sort(X,X+M);
    int gap[M-1];
    for(int i=0;i<M-1;i++){
       gap[i]=X[i+1]-X[i];
    }
    sort(gap,gap+M-1);
    int ans=0;
    for(int i=0;i<M-N;i++){
       ans+=gap[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

typedef struct {
  int h;
  int w;
} Pos;

char m[400][400];
int main(){
  int H, W;
  cin >> H >> W;
  rep(h, H){
    cin >> m[h];
  }
  ll ans = 0;
  rep(h, H){
    rep(w, W){
      int sH = h;
      int sW = w;
      char c = m[sH][sW];
      if(c == ' ') continue;
      ll countB = 0;
      ll countW = 0;
      queue<Pos> qu;
      Pos p = {sH, sW};
      qu.push(p);
      while(qu.size()){
        Pos p = qu.front();
        qu.pop();
        int x = p.w;
        int y = p.h;
        if(m[y][x] == ' ') continue;
        if(m[y][x] == '#') countB++;
        if(m[y][x] == '.') countW++;
        //cout << "x = " << x << " y = " << y << endl;
        int dx[]={1,0,-1,0};
        int dy[]={0,1,0,-1};
        rep(i, 4){
          int xx = x + dx[i];
          int yy = y + dy[i];
          if(xx < 0) continue;
          if(yy < 0) continue;
          if(xx >= W) continue;
          if(yy >= H) continue;
          if(m[yy][xx] == ' ') continue;
          if(m[yy][xx] != m[y][x]){
            Pos p = {yy, xx};
            qu.push(p);
          }
        }
        m[y][x] = ' ';
      }
      //cout << "countB = " << countB;
      //cout << " countW = " << countW << endl;
      ans += countB * countW;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
# coding: utf-8
# Your code here!
A,B,C=map(int,input().split())

al=A*B*C

X=(A-A//2)*B*C
Y=A*(B-B//2)*C
Z=A*B*(C-C//2)

print(min(2*X,2*Y,2*Z)-al)


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
	int N,A,B;
	
	scanf("%d %d %d",&N,&A,&B);
	
	if(A+B>N){
		if(A<=B)	printf("%d %d",A,A+B-N);
		else	printf("%d %d",B,A+B-N);
	}else{
		if(A<=B)	printf("%d 0",A);
		else	printf("%d 0",B);
	}
	
	return 0;
}

Measured memory_bytes: 128