akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;

int n,m;
int maxeven,maxodd;

int32_t main() {
	FAST	
	cin >> n >> m;
	
	if (m % 2 == 0) {
		maxeven = m;
		maxodd = m-1;
	} else {
		maxeven = m-1;
		maxodd = m;
	}
	
	int co = 1;
	for (int i =maxodd; i >= 1; i -= 2) {
		cout << co << " " << co + i << "\n";
		co++;
	}
	co = maxodd + 2;
	
	for (int i = maxeven; i >= 2; i -= 2) {
		cout << co << " " << co + i << "\n";
		co++;
	}
	
	
	
}



Measured memory_bytes: 3608
import itertools
import math

A,B,H,M=map(int,input().split())

H=H+M/60
#Ado=(H/12)+(M/60)/12
#Arad=Ado*math.pi/180
Arad=2*math.pi / 12 * (3-H)
Ax=A*math.cos(Arad)
Ay=A*math.sin(Arad)

#Bdo=(M/60)
#Brad=Bdo*math.pi/180
Brad=2*math.pi / 60 * (15-M)
Bx=B*math.cos(Brad)
By=B*math.sin(Brad)

Dist=math.sqrt((Ax-Bx)**2 + (Ay-By)**2)

print(Dist)


Measured memory_bytes: 9544
def main():
    S = input()
    str_dict = {}
    for s in S:
        if s not in str_dict:
            str_dict[s] = 0
        str_dict[s] += 1

    if len(str_dict) == 2:
        for value in str_dict.values():
            if value != 2:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> S = new HashSet<String>();
        for(int i = 0;i<n;i++ ){
            String cmd = sc.next();
            String word = sc.next();
            if(cmd.equals("insert"))
                S.add(word);
            else if(cmd.equals("find")){
                if(S.contains(word)){
                    System.out.println("yes");
                }
                else{
                    System.out.println("no");
                }
            }
        }

    }
}


Measured memory_bytes: 251304
import collections
import sys

S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()

for i, j in enumerate(sys.stdin.readline()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while S2 and (S2[-1] > left_edge):
                if S2[-1] > left_edge:
                    S2.pop()
                    new_puddle += S3.pop()
            S2.append(left_edge)
            S3.append(new_puddle)
        else:
            pass


print(sum(S3))

print(len(S3), *S3)

Measured memory_bytes: 8368
#include<iostream>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    string s;
    cin >> s;
    map<char, int> mp{{'L', -1}, {'R', 1}};
    vector<int> ans(s.size(), 0);

    for (int i = 0; i < s.size(); i++) {
        int t = i, cnt = 1;
        char now = s[i];
        int m = mp[now];
        while(now == s[t + m]) {
            t += m;
            cnt++;
        }
        if (cnt % 2 == 0) ans[i + m * cnt]++;
        else ans[i + m * (cnt - 1)]++;
    }


    for (int i = 0; i < s.size(); i++) cout << ans[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 3876
N = int(input())
ans = 10**9+7
for A in range(1,N//2+2):
    B = N - A
    A_ = [int(i) for i in list(str(A))]
    B_ = [int(i) for i in list(str(B))]
    ans = min(ans,sum(A_)+sum(B_))
print(ans)


Measured memory_bytes: 3060
// ALDS1_12_A.cpp
// Graph II - Minimum Spanning Tree
#include <iostream>
using namespace std;

const int maxN = 100;
const int INF = 2001;
int w[maxN][maxN];
int color[maxN];
int n;
static const int WHITE = 0;
static const int BLACK = 1;

int prim(int x)
{
    int res = 0;
    int cnt = 1;
    color[x] = BLACK;
    while (cnt++ != n) {
        int minCost = INF;
        int pos = 0; // ??°?????°?????????
        for (int i = 0; i < n; i++) {
            if (color[i] != BLACK) continue;
            for (int j = 0; j < n; j++) {
                if (color[j] != WHITE) continue;
                if (w[i][j] < minCost) {
                    pos = j;
                    minCost = w[i][j];
                }
            }
        }
        res += minCost;
        color[pos] = BLACK;
    }
    return res;
}

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

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{int N,M,B,X,C,x,i,a,b,c,l,r,g,flag,m,tmp;
	long long int sum;
	scanf("%d",&N);
	sum=1;
	flag=0;
	int A[100000];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);}
		qsort(A, N, sizeof(int), compare_int);
if(N%2==0){
	for(i=0;2*i+1<N;i++){
		if(A[2*i]!=2*i+1||A[2*i+1]!=2*i+1){
			flag=1;
			break;}}
			if(flag==0){
			
			x=N/2;
			for(a=1;a<=x;a++){
			sum*=2;
			if(sum>=1000000007){
				sum%=1000000007;}}}
	}
	else{
	for(i=0;2*i+1<N-1;i++){
		if(A[2*i]!=2*i||A[2*i+1]!=2*i+2||A[N-1]!=N-1){
			flag=1;
			break;}}
			if(flag==0){
			x=N/2;
			for(a=1;a<=x;a++){
			sum*=2;
			if(sum>=1000000007){
				sum%=1000000007;}}}}
	
	if(flag==0){
	printf("%lld",sum);}
	else
	printf("0");
			


	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << setw(4) << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

struct point{
    int x;
    int y;
};

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

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

    vector<vector<int>> d(h*w, vector<int>(h*w, 9999));
    for(int i=0; i<h*w; i++){ // 点1
        bool flag = c[i/w][i%w] == '#';
        for(int j=0; j<h*w; j++){ // 点2
            if(i == j){
                d[i][i] = 0;
            }else if(flag){
                d[i][j] = 9999;
            }else if((abs(i/w - j/w) == 1 && i%w == j%w) || (abs(i%w - j%w) == 1 && i/w == j/w)){
                if(c[j/w][j%w] == '#') d[i][j] = 9999;
                else d[i][j] = 1;
            }else{
                d[i][j] = 9999;
            }
        }
    }

    // for(int i=0; i<h*w; i++){
    //     DUMPL(d[i]);
    // }
    for(int k=0; k<h*w; k++) // 中継点
        for(int i=0; i<h*w; i++) // 始点
            for(int j=0; j<h*w; j++) // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);


    int mmax = 0;
    for(int i=0; i<h*w; i++){
        for(int j=0; j<h*w; j++){
            if(d[i][j] < 9999 && d[i][j] > mmax){
                mmax = d[i][j];
            }
        }
    }
    COUT(mmax);

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;

ll solve(ll num, int& cnt){
	if(!num){ cnt = 1; return 0; }
	ll tens[] = {
		10,
		100,
		1000,
		10000,
		100000,
		1000000,
		10000000,
		100000000,
		1000000000,
		10000000000,
		100000000000,
	};
	ll ret = 0;
	for(ll t : tens) if(num * 10 >= t){
		int lcnt = 0;
		ll tmp = solve(num / t, lcnt);
		tmp += num % t * max(1, lcnt);
		ret += tmp;
		// cout<<tmp<<' '<<num<<' '<<t<<' '<<lcnt<<endl;
		// cnt++;
		cnt += max(0, lcnt);
	}
	return ret;
}

int main(){
	string s;
	cin >> s;
	ll num = atol(s.c_str());
	// cout<<num<<endl;
	int hoge;
	cout << solve(num, hoge) << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int K, S;
    int count = 0;
    cin >> K >> S;

    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (z >= 0 && z <= K) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using  namespace std;
int main ()
{
    int a,b,ar[100],i=0;
    cin>>a>>b;
    while(b>0){
        int c=b%10;
        ar[i]=c;
        i++;
        b=b/10;
    }
    for(int j=i-1;j>=0;j--){
        a=(a*10)+ar[j];

    }
    int p=sqrt(a);
    if((p*p)==a){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

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

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }

inline ll Msq(ll x){ return (x*x) %MOD; }
inline ll Mpot(ll x, ll e){
	if(!e) return 1;
	return Msq(Mpot(x, e>>1)) * (e & 1 ? x : 1)%MOD;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 2e5+5;

int n, a[MAXN], x[MAXN];

int main(){
	scan(n);
	for(int i=0; i<n; i++) scan(a[i]);
	for(int i=0; i<n; i++) x[i] = a[i];
	sort(x, x+n);

	for(int i=0; i<n; i++){
		int v = a[i];
		int i1 = (n-1)/2;
		if(v <= x[i1]) printf("%d\n", x[i1+1]);
		else printf("%d\n", x[i1]);
	}
}


Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define MAX 2020
inline ll read()
{
	ll x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX*MAX];
int h[MAX],cnt=1,dg[MAX];
vector<int> E[MAX];
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;dg[v]+=1;}
inline void ADD(int u,int v){E[u].push_back(v);}
int n;
ll a[MAX];
priority_queue<int> Q;
bool vis[MAX];
void dfs(int u)
{
	vis[u]=true;
	for(int v:E[u])if(!vis[v])dfs(v),Add(u,v);
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	sort(&a[1],&a[n+1]);
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if(__gcd(a[i],a[j])>1)ADD(i,j),ADD(j,i);
	for(int i=1;i<=n;++i)if(!vis[i])dfs(i);
	for(int i=1;i<=n;++i)if(!dg[i])Q.push(i);
	while(!Q.empty())
	{
		int u=Q.top();Q.pop();printf("%lld ",a[u]);
		for(int i=h[u];i;i=e[i].next)
			if(!--dg[e[i].v])Q.push(e[i].v);
	}
	return 0;
}


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


vector<int> prime_division(ll x)
{
	vector<int> ret;
	Rep(i,2,sqrt(x)+1)
	{
		while(x%i==0)
		{
			ret.emplace_back(i);
			x/=i;
		}
	}
	if(x!=1) ret.emplace_back(x);
	return ret;
}
int main()
{
	ll A,B;
	cin>>A>>B;
	vector<int> p_a=prime_division(A);
	map<int,int> m_a;
	for(int a : p_a)
	{
		m_a[a]=1;
	}
	vector<int> p_b=prime_division(B);
	map<int,int> m_b;
	for(int b : p_b)
	{
		m_b[b]=1;
	}	
	int ans=1;
	for(auto p : m_a)
	{
		ans+=m_b[p.first];
	}
	cout<<ans<<endl;
	return 0;
}


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

a_list = [int(input()) for i in range(N)]

pre = 1
flg = False
cnt = 0
for i in range(N+1):
  if pre == 2:
    flg = True
    break
  if pre == a_list[pre-1]:
    break
    
  pre = a_list[pre-1]
  cnt += 1
    
if flg:
  print(cnt)
else:
  print(-1)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n;
int arr[402];
int pre[402];
int s(int i,int j)
{ 
    return (pre[j]-pre[i-1]);
} 
int dp[402][402];
int solve(int i ,int j)
{
    if(i == j)
      return 0;

    if(dp[i][j]!= -1)
      return dp[i][j];

    int ret = LONG_MAX;
    for(int k = i;k<j;k++)
    {
        ret = min(ret,(solve(i,k)+solve(k+1,j)+s(i,j)));
    }
    return dp[i][j] = ret;
}
signed main(void)
{
   memset(dp,-1,sizeof(dp));
   cin>>n;
   pre[0]=0;
   for(int  i = 1;i<=n;i++)
    {
     cin>>arr[i];
     pre[i]=(pre[i-1]+arr[i]);
    }

    cout<<solve(1,n)<<endl;

}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, h[100009], dp[100009];
int main() {
    //ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i=3;i<=n;i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout<<dp[n];
}


Measured memory_bytes: 5192
N = gets.to_i
uvw_list = (N - 1).times.map { gets.split.map(&:to_i) }
graph = Array.new(N) { [] }
uvw_list.each do |(u, v, w)|
  u -= 1
  v -= 1
  graph[u].push([v, w])
  graph[v].push([u, w])
end

def bfs(graph)
  w_list = Array.new(N)
  queue = [[0, 0, nil]] # u, w, parent
  while !queue.empty?
    u, w, parent = queue.shift
    w_list[u] = w
    graph[u].each do |(v, w2)|
      next if v == parent
      queue.push([v, w + w2, u])
    end
  end
  w_list
end

w_list = bfs(graph)
w_list.map do |w|
  puts(w.even? ? '0' : '1')
end


Measured memory_bytes: 29436
#define NAAN_TIKE_PLATYPUS
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

#include <vector>
using namespace std;
using LL = long long;

namespace scc_space {
	void dfs(int v_, vector<bool>& used_, vector<int>G_[], vector<int>& vs_) {
		used_[v_] = true;
		for (int nxt : G_[v_]) {
			if (!used_[nxt])dfs(nxt, used_, G_, vs_);
		}
		vs_.push_back(v_);
	}

	void rdfs(int v_, int k_, vector<bool>& used_, vector<vector<int>>& rG_, vector<int>& top) {
		used_[v_] = true;
		top[v_] = k_;
		for (int nxt : rG_[v_]) {
			if (!used_[nxt])rdfs(nxt, k_, used_, rG_, top);
		}
	}
}

//頂点数n_のグラフG_の強連結成分分解をする
//topに強連結成分のトポロジカル順序が格納される
//(top[i]==top[j]のとき、iとjは強連結である。)
//戻り値:強連結成分の個数
int scc(vector<int>G_[], int n_, vector<int>& top) {
	using namespace scc_space;
	top.resize(n_);
	vector<vector<int>>rG_(n_);
	for (int i = 0; i < n_; ++i) {
		for (int to : G_[i]) {
			rG_[to].push_back(i);
		}
	}
	vector<bool>used(n_, false);
	vector<int>vs;
	for (int v = 0; v < n_; ++v) {
		if (!used[v])dfs(v, used, G_, vs);
	}
	fill(used.begin(), used.end(), false);
	int k = 0;
	for (int i = vs.size() - 1; i >= 0; --i) {
		if (!used[vs[i]])rdfs(vs[i], k++, used, rG_, top);
	}
	return k;
}

int N, M;
vector<int>G[1234];

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
	}
	vector<int>top;
	scc(G, N, top);
	map<int, vector<int>>mp;
	for (int i = 0; i < N; ++i) {
		mp[top[i]].push_back(i);
	}
	for (auto& p : mp) {
		sort(p.second.begin(), p.second.end());
	}
	for (int i = 0; i < N; ++i) {
		for (int x = 0; x < mp[top[i]].size(); ++x) {
			cout << mp[top[i]][x] + 1 << " \n"[x + 1 == mp[top[i]].size()];
		}
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  ll N,A,B; cin >> N >> A >> B;
  ll ans=0;
  if(A+B<=N){
      ans = N/(A+B) * A;
      ans += min(N%(A+B),A);
  }
  else{
      ans = min(N,A);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
K = int(input())
N = 50
div_K, rem_K = divmod(K, N)
ans = [l + div_K for l in range(N)]
for i in range(rem_K):
    idx = ans.index(min(ans))
    for i in range(N):
        if i == idx:
            ans[i] += N
        else:
            ans[i] -= 1
print(N)
print(*ans)


Measured memory_bytes: 9184
#include <stdio.h>
#include <string.h>
#include <map>
#include <queue>
#define MN 100000
#define MM 200000
int n,m,vn;
int hd[MN*5+5],to[MM*6+5],nxt[MM*6+5],val[MM*6+5];
int dis[MN*5+5];
bool vis[MN*5+5];
void add(int u,int v,int w){
	static int rn=0;
	to[rn]=v,nxt[rn]=hd[u],val[rn]=w;
	hd[u]=rn++;
}
int gid(int u,int c){
	static std::map<int,int> tb[MN+5];
	if(tb[u].find(c)==tb[u].end()){
		tb[u][c]=(++vn);
		add(u,tb[u][c],1);
		add(tb[u][c],u,0);
	}
	return tb[u][c];
}
void bfs01(){
	static std::deque<int> q;
	memset(dis,0x3f,sizeof(dis));
	dis[1]=0; q.push_front(1);
	while(!q.empty()){
		int u=q.front(); q.pop_front();
		if(vis[u]) continue; vis[u]=true;
		for(int i=hd[u];~i;i=nxt[i]){
			if(vis[to[i]]) continue;
			if(dis[u]+val[i]<dis[to[i]]){
				dis[to[i]]=dis[u]+val[i];
				if(val[i]==0)
					q.push_front(to[i]);
				else
					q.push_back(to[i]);
			}
		}
	}
}
int main(){
	memset(hd,0xff,sizeof(hd));
	scanf("%d%d",&n,&m);
	vn=n;
	for(int i=1,u,v,c;i<=m;i++){
		scanf("%d%d%d",&u,&v,&c);
		u=gid(u,c),v=gid(v,c);
		add(u,v,0),add(v,u,0);
	}
	bfs01();
	if(dis[n]==0x3f3f3f3f) puts("-1");
	else printf("%d\n",dis[n]);
}

Measured memory_bytes: 42624
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
	return a.second < b.second;
}
int main() {
	run();
	int n;
	cin >> n;
	multiset<ll> t;
	for(int i = 0; i < n; i++) {
		int a; cin >> a;
		auto it = t.lower_bound(a);
		if(it == t.begin()) {
			t.insert(a);
		}
		else {
			it--;
			t.erase(it);
			t.insert(a);
		}
	}
	cout << t.size() << endl;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int st[100010];
vector<int> edge[100010];
int bro[100010],vis[100010],cnt[100010]; 
int n,k;
void dfs(int u,int fa,int deep)
{
    int w;
    if(deep<2)  w = deep+1;
    else
    {
        w = 2;
    }
    int x = edge[u].size();
    int bro = 0;
    for(int i=0;i<edge[u].size();i++)
    {
        int v = edge[u][i];
        if(v==fa) continue;
        cnt[v] = k-bro-w;
        bro++;
        dfs(v,u,deep+1);
    }
}
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=1;i<n;i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    cnt[1] = k;
    dfs(1,0,0);
    // for(int i=1;i<=n;i++)
    // {
    //     printf("%d ",bro[i]);
    // }
    long long ans = 1;
    for(int i=1;i<=n;i++)
    {
        ans = ans * cnt[i] % mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 15404
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            var s = Console.ReadLine();
			var sLength = s.Length;

			var count = 0;

			for(int i = 1; i < sLength; i++)
			{
				if(s[i] != s[i - 1])
				{
					count++;
				}
			}

			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13280
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N,K;
vint ac;
int dp[5000][5001];
int huyosu(int MIN,int MAX){
	if(MIN+1==MAX) return MIN;
	int MID=(MIN+MAX)/2;
	vint a;
	int noted;
	rep(i,N){
		if(i!=MID) a.push_back(ac[i]);
		else noted=ac[i];
	}
	rep(i,N){
		rep(k,K+1){
			dp[i][k]=INF;
		}
	}
	dp[0][0]=0;
	rep(i,N-1){
		rep(j,K+1){
			dp[i+1][j] = dp[i][j];
			if(j>=a[i]){
				dp[i+1][j] = min(dp[i][j-a[i]]+1,dp[i+1][j]);
			}
		}
	}
	int flag=0;
	for(int k=K-noted;k<K;k++) if(dp[N-1][k]<INF) flag=1;
	//printf("MIN:%d MAX:%d MID:%d flag:%d\n",MIN,MAX,MID,flag);
	if(flag) return huyosu(MIN,MID);
	else return huyosu(MID,MAX);
}
int main(){
	int a[5001];
	scan(N);scan(K);
	rep(i,N){
		scan(a[i]);
		ac.push_back(a[i]);
	}
	sort(ac.begin(),ac.end());
	if(ac[0]>=K){
		prin(0);
	}
	else{
		prin(huyosu(-1,N)+1);
	}
	return 0;
}


Measured memory_bytes: 98304
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = sc.nextInt();

        int[] ref = new int[a];
        int[] chin = new int[b];
        int[] discount = new int[m];

        for (int i = 0; i < a; i++) {
            ref[i] = sc.nextInt();
        }
        for (int i = 0; i < b; i++) {
            chin[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            discount[i] = ref[sc.nextInt() - 1] + chin[sc.nextInt() - 1] - sc.nextInt();
        }

        Arrays.sort(ref);
        Arrays.sort(chin);
        Arrays.sort(discount);

        System.out.println(Math.min(discount[0], ref[0] + chin[0]));
    }
}

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

int main() {
    int N;
   double n,s;
    cin >> N;
  	n = N;

    if (N % 2 == 0)  {
        s = N / 2;
    }
    else {
        s = (N + 1) / 2;
    }
    cout << s / n << endl;
}

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

int main(int argc, char* argv[])
{
  int i, n, a, b, cmp;
  char s1[200], s2[100];

  scanf("%d", &n);
  a = b = 0;
  for(i = 0; i < n; i++){
    scanf("%s %s", s1, s2);
    cmp = strcmp(s1, s2);
    if(0 < cmp){
      a += 3;
    }else if(cmp < 0){
      b += 3;
    }else if(cmp == 0){
      a += 1;
      b += 1;
    }
  }
  printf("%d %d\n", a, b);
  return(0);
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c ;
    int tmp[a], tmp1[b];
    for(int i=0; i<a; i++)
        cin >> tmp[i];
    for(int i=0; i<b; i++)
        cin >> tmp1[i];
    sort(tmp1, tmp1+b);
    sort(tmp, tmp+a);
    reverse(tmp, tmp+a);
    reverse(tmp1, tmp1+b);
    vector<int> v(c, 0);
    for(int i=0; i<c; i++)
        cin >> v[i];
    for(int i=0; i<x; i++)
        v.push_back(tmp[i]);
    for(int i=0; i<y; i++)
        v.push_back(tmp1[i]);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    ll s = 0;
    for(int i=0; i<x+y; i++)
        s += (ll)v[i];
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  string C;
  int i;
  int p=0, y=0, w=0, g=0;
  int x=0;
  
  for(i=0;i<N;i++){
    cin >> C;
  	if(C == "P"){
    p++;
    }
    
    if(C == "Y"){
    y++;
    }
    
    if(C == "W"){
    w++;
    }
    
    if(C == "G"){
    g++;
    }  
  }
  
  if(p != 0){x++;}
  if(y != 0){x++;}
  if(w != 0){x++;}
  if(g != 0){x++;}
  
  if(x == 3){cout << "Three" <<endl;}
  if(x == 4){cout << "Four" <<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n, x;
    scanf("%d %d", &n, &x);
    vector<int> m(n);
    rep(i, n) scanf("%d", &m[i]);
    sort(m.begin(), m.end());
    rep(i, n) x -= m[i];
    int count = m.size();
    while (x >= m[0])
    {
        x -= m[0];
        count++;
    }
    printf("%d\n", count);
    return 0;
}

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

ll euclidean_gcd(ll  a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    a %= b;
    if(a==0) break;
  }
  return b;
}

main () {
  ll a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

  ll gcd = euclidean_gcd(c, d);
  ll lcm = c*d/gcd;
  printf("%lld\n", (b-a+1)
                    - (b/c - (a-1)/c)
                    - (b/d - (a-1)/d)
                    + (b/lcm - (a-1)/lcm));
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int t,x,y,sum=0;
  for(int i=0;i<N;i++) {
    cin >> t >> x >> y;
    int jg=(x%2)+(y%2);
    //cout << jg << t%2 << endl;
    if(t>=x+y && t%2==jg%2) sum++;
    else break;
  }
  if(sum==N) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
def get_prime_list(n):
    l = [0 for _ in range(n)]
    i = 1
    while (i < n):
        for j in range(2, int((i + 1)**0.5) + 1):
            if not (i + 1) % j:
                break
        else:
            l[i] = 1
        i += 1

    return l


n_max = 10**5
is_prime = get_prime_list(n_max)
is_2017 = [0 for _ in range(n_max)]
for i in range(2, n_max + 1):
    if is_prime[i - 1] and is_prime[(i + 1) // 2 - 1]:
        is_2017[i - 1] = 1

s = [0]
for i in range(n_max):
    s.append(s[i] + is_2017[i])

q = int(input())
for _ in range(q):
    li, ri = map(int, input().split())
    print(s[ri] - s[li - 1])

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

int main() {
  LL l, r;
  cin >> l >> r;

  LL ans = 2019;
  for (LL i = l; i <= min(r, l + 2019); i ++) {
    for (LL j = i + 1; j <= min(r, l + 2019); j ++) {
      LL t = (i * j) % 2019;
      ans = min(ans, t);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a<b&&b<c){
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 26236
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]
t = [int(input()) for _ in range(D)]

last = [-1] * 26
S = 0
for d in range(D):
    S += s[d][t[d] - 1]

    last[t[d] - 1] = d
    for i in range(26):
        S -= c[i] * (d - last[i])

    print(S)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<string>s(n);
    map<string,ll> mp;
    for (int i = 0; i < n; ++i) {
        cin >>s[i];
        mp[s[i]]++;
    }
    sort(all(s));
    s.erase(unique(all(s)),s.end());
    vector<pair<ll,string>>ans;
    for(auto c:s){
        ans.push_back({mp[c],c});
    }
    sort(all(ans));
    reverse(all(ans));
    ll mx=ans[0].first;
    for (int i =ans.size(); i >=0; --i) {
        if(mx==ans[i].first){
            cout <<ans[i].second<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 30964
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	int seq[2];
	while(tin2(seq[0],seq[1]) && seq[0]+seq[1]){
		sort(seq,seq+2);
		cout << seq[0] << " " << seq[1] << endl;
        }
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=2e5+7;
string s[mn],t;

int main()
{
	int n,ans=0;
	scanf("%d",&n);
	FOR(i,1,n) cin>>s[i];
	sort(s+1,s+n+1);
	FOR(i,1,n) if(s[i]!=t) t=s[i],ans++;
	cout<<ans;
}

Measured memory_bytes: 10016
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

template <class Abel = ll>
struct UnionFind
{
  vector<int> par;
  vector<int> rank;
  vector<Abel> diff_weight;

  UnionFind(int N = 100010, Abel SUM_UNITY = 0)
  {
    init(N, SUM_UNITY);
  }

  void init(int N = 100010, Abel SUM_UNITY = 0)
  {
    par.resize(N);
    rank.resize(N);
    diff_weight.resize(N);
    for (int i = 0; i < N; ++i)
      par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
  }

  int root(int x)
  {
    if (par[x] == x)
    {
      return x;
    }
    else
    {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }

  Abel weight(int x)
  {
    root(x);
    return diff_weight[x];
  }

  bool issame(int x, int y)
  {
    return root(x) == root(y);
  }

  bool unite(int x, int y, Abel w)
  { //weight[y] = weight[x] + w
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (rank[x] < rank[y])
      swap(x, y), w = -w;
    if (rank[x] == rank[y])
      ++rank[x];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }

  Abel diff(int x, int y)
  {
    return weight(y) - weight(x);
  }
};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, m;
  cin >> n >> m;
  UnionFind<> uf;
  rep(i, m)
  {
    ll l, r, d;
    cin >> l >> r >> d;
    if (!uf.issame(l, r))
    {
      uf.unite(l, r, d);
    }
    else if (uf.diff(l, r) != d)
    {
      Yes(false);
      return 0;
    }
  }
  Yes(true);
  return 0;
}


Measured memory_bytes: 1920
# input
H, W = map(int, input().split())
A = []
for i in range(H):
  A.append(input())

mod = 1000000007

# DP
dp = [[0] * W for i in range(H)]

for i in range(H):
  if A[i][0] == '#':
    break
  dp[i][0] = 1

for j in range(W):
  if A[0][j] == '#':
    break
  dp[0][j] = 1

for i in range(1, H):
  for j in range(1, W):
    if A[i][j] == '#':
      continue
    else:
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod

print(dp[H - 1][W - 1])

Measured memory_bytes: 51568
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;


int main() {
    string s;
    cin >> s;
    REP(i,0,s.size()){
        if(i % 2 == 0){
            cout << s[i];
        }
    }
    cout << endl;

    return 0;

}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += min(A[i] + A[i+1], B[i])
    A[i+1] -= min(max(B[i] - A[i], 0), A[i+1])

print(ans)


Measured memory_bytes: 24096
#include<bits/stdc++.h>
using namespace std;
int mape[505][505];
int ans[505][505];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie();
	int n,m,q;
	cin>>n>>m>>q;
	memset(mape,0,sizeof(mape));
	memset(ans,0,sizeof(ans));
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		mape[l][r]++;
	}
	for(int i=1;i<=500;i++){
		for(int j=1;j<=500;j++){
			ans[i][j]=ans[i][j-1]+mape[i][j]; 
		}
	}
	for(int i=0;i<q;i++){
		int l,r;
		cin>>l>>r;
		int now=0;
		for(int j=l;j<=r;j++){
			now+=ans[j][r];
		}
		cout<<now<<endl;
	}
} 

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
const int Mod = 1e9 + 7;
const int MAXN = 1e5;

int cnt[26];
char s[MAXN+5];
int main() {
	int n; scanf("%d", &n);
	scanf("%s", s);
	for(int i = 0; i < n; i++){
		cnt[s[i] - 'a']++;
	}
	ll ans = 1;
	for (int i = 0; i < 26; i++) {
		ans = ans * (cnt[i] + 1) % Mod;
	}
	printf("%lld\n", (ans - 1 + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 384
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
 int a,b,c;
 cin>>a>>b>>c;
 vector<int> vec(110,0);
 rep(i,b){
     int s;
     cin>>s;
     vec.at(s)=1;
 }
 int st=0;
 int en=0;
 rep(i,c){
     if(vec.at(i)==1){
         st++;
     }
 }
 for(int i=a;i>=c;i--){
     if(vec.at(i)==1){
         en++;
     }
 }
 cout<<min(st,en)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long fibo[31]={0,1,2,4};
  for(int i=4;i<=30;i++){
    fibo[i] = fibo[i-2]+fibo[i-1]+fibo[i-3];
  }
  int n;
  while(cin >> n,n){
    cout << (fibo[n]%3650?fibo[n]/3650+1:fibo[n]/3650) << endl;
  }
}


Measured memory_bytes: 3096
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
  int n,m,l,r;
  cin >> n;
  vector<int> x,y;
  REP(i,n){
    cin >> m;
    x.push_back(m);
    y.push_back(m);
  }
  SORT(y);
  l = y[(n/2)-1];
  r = y[(n/2)];
  REP(i,n){
    if (x[i] >= r) {
      cout << l << endl;
    } else {
      cout << r << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#include <iostream>
#include <string>

using namespace std;

int gcd(int x ,int y){
  if(y==0) return x;
  else return gcd(y, x%y);
  
}

int main(){
int n;
  
  cin >>n;
  
  long long int ans = 0;
  
  for(int i=1;i<=n;i++){
  for(int j=1;j<=n;j++){
    for(int k=1;k<=n;k++){
      ans += gcd( gcd(i,j),k);
    }
  }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

constexpr int N = 26;
constexpr int D = 365;

signed main() {
    int D;
    cin >> D;
    int c[N];
    rep(i, N) {
        cin >> c[i];
    }
    int s[D][N];
    rep(i, D) {
        rep(j, N) {
            cin >> s[i][j];
        }
    }
    int t[D];
    rep(i, D) {
        cin >> t[i];
        t[i]--;
    }
    int m;
    cin >> m;
    int d[m], q[m];
    rep(i, m) {
        cin >> d[i] >> q[i];
        d[i]--;
        q[i]--;
    }
    int last[N];
    fill(last, last + N, -1);
    int score = 0;
    rep(i, D) {
        last[t[i]] = i;
        score += s[i][t[i]];
        rep(j, N) {
            score -= c[j] * (i - last[j]);
        }
    }
    rep(i, m) {
        int precontest = t[d[i]];
        int nxtcontest = q[i];
        score -= s[d[i]][precontest];
        score += s[d[i]][nxtcontest];
        int last = d[i];
        while (last >= 0 && t[last] != nxtcontest) {
            last--;
        }
        for (int j = d[i]; j < D; j++) {
            if (t[j] == nxtcontest) break;
            score += c[nxtcontest] * (j - last);
            score -= c[nxtcontest] * (j - d[i]);
        }
        t[d[i]] = nxtcontest;
        last = d[i];
        while (last >= 0 && t[last] != precontest) {
            last--;
        }
        for (int j = d[i]; j < D; j++) {
            if (t[j] == precontest) break;
            score -= c[precontest] * (j - last);
            score += c[precontest] * (j - d[i]);
        }
        cout << score << endl;
    }
    return 0;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

int n, m;

vector <vector <int>> adj;
vector <int> p;

void bfs (int node) {
	queue <int> q;
	q.push(node);
	p[node] = 0;
	while (!q.empty()) {
		int from = q.front();
		q.pop();
		for (int to : adj[from]) {
			if (p[to] == -1) {
				p[to] = from;
				q.push(to);
			}
		}
	}
}

int main() {

	FAST;

	cin >> n >> m;
	adj.resize(n + 1);
	p.assign(n + 1, -1);
	while (m -- ) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	bfs(1);
	bool flag = true;
	for (int i = 1; i <= n; i ++) {
		if (p[i] == -1) {
			flag = false;
			break;
		}
	}
	if (!flag) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
		for (int i = 2; i <= n; i ++) {
			cout << p[i] << '\n';
		}
	}
	return 0;
}

Measured memory_bytes: 10300
# 最大公約数
def gcd(a, b)
  a, b = b, a if a > b
  loop do
    b, a = a, b%a
    break if a == 0
  end
  b
end

# 最小公倍数
def lcm(a, b)
  a*b/gcd(a, b)
end

while gets do
  a, b = $_.split(' ').map(&:to_i)
  puts "#{gcd(a, b)} #{lcm(a, b)}"
end

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

const lint MAX = 2010;
const lint MOD = 1000000007;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

lint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

signed main(){
  lint N, K; cin >> N >> K;
  COMinit();
  for(lint i = 0; i < K; i++){
    cout << (COM(K - 1, i) * COM(N - K + 1, i + 1)) % MOD << endl;
  }
}


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

public class Main {

    public static void main(String[] args) {
        //System.setIn(Main.class.getClassLoader().getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = sc.nextInt();
        String s = sc.next();
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            char c1 = (char) ((((c - 'A') + n) % 26) + 'A');
            res.append(c1);
        }
        System.out.println(res.toString());
    }
}


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

int main(){
    long double a, b, c, d;
    cin>>a>>b>>c>>d;
    long double pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286;
    long double angle1=(((c+(d/60.0))*pi)/6.0);
    long double angle2=((d*pi)/30.0);
    long double x=((a*cos(angle1))-(b*cos(angle2)));
    long double y=((a*sin(angle1))-(b*sin(angle2)));
    cout<<fixed<<setprecision(20)<<pow(((x*x)+(y*y)), 0.5)<<endl;
}


Measured memory_bytes: 4176
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N;
	public void solve() {
		N = nextInt();
		for(int i = 0;i < N;i++){
			int m = nextInt();
			int n = nextInt();

			int cnt = 0;

			int MAX = m * m + n * n;

			for(int p = 0;p * p <= MAX;p++){
				for(int q = 0;q * q <= MAX;q++){
					if(p * p + q * q > 0){

						if((m * p + n * q) % (p * p + q * q) == 0 && (m * q - n * p) % (p * p + q * q) == 0){
							cnt++;
						}

					}
				}
			}

			if(cnt*2 <= 8){
				out.println("P");
			}else{
				out.println("C");
			}
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24908