akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;
long long n,q;
vector<long long> seg;
vector<long long> v;
vector<long long> last;
vector<pair<pair<long long,long long>,long long>> que;//ltoRgyaku;

long long solve(long long i,long long a,long long b,long long l,long long r){
	if(b<=l || r<=a) return 0;
	if(a<=l && r<=b) return seg.at(i);
	else{
		long long A=solve(i*2+1,a,b,l,(l+r)/2);
		long long B=solve(i*2+2,a,b,(l+r)/2,r);
		return A+B;
	}
}

int main(){
	cin>>n>>q;
	v.resize(n);
	last.assign(n+1,-1);

	for(long long i=0;i<n;i++){
		cin>>v.at(i);
		v.at(i)--;
	}

	que.resize(q);

	for(long long i=0;i<q;i++){
		cin>>que.at(i).first.second>>que.at(i).first.first;
		que.at(i).second=i;
	}

	long long N=2;
	while(N<n){
		N*=2;
	}
	seg.assign(2*N-1,0);
	long long pre=0;
	priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> ans;

	sort(que.begin(),que.end());
	for(long long i=0;i<q;i++){
		long long now=que.at(i).second;
		long long l=que.at(i).first.second;
		long long r=que.at(i).first.first;//cout<<now<<"! "<<l<<" "<<r<<endl;

		if(i==0) pre=1;
		for(long long j=pre-1;j<=r-1;j++){
			if(last.at(v.at(j))<j){
				long long I=N+last.at(v.at(j))-1;
				if(last.at(v.at(j))!=-1){
					while(I>0){
						seg.at(I)--;
						I=(I-1)/2;
					}
					seg.at(I)--;
				}
				I=N+j-1;
				while(I>0){
					seg.at(I)++;
					I=(I-1)/2;
				}
				seg.at(I)++;

				last.at(v.at(j))=j;
			}
		}
//		for(long long j=N-1;j<2*N-1;j++) cout<<seg.at(j)<<" ";cout<<endl;
		ans.push(make_pair(now,solve(0,l-1,r,0,N)));
		pre=r;
	}

	while(!ans.empty()){
		cout<<ans.top().second<<endl;
		ans.pop();
	}

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 39480
s = int(input())
def f(n):
    if n%2==0:
        return(int(n/2))
    if n%2!=0:
        return(3*n+1)
a = []
a.append(s)
while(1):
    a_next = f(a[-1])
    a.append(a_next)
    for i in a[:-1]:
        if(a[-1]==i):
            break
    if(a[-1]==i):
        break
print(len(a))

Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>

using namespace std;

int main() {
    long long x, k, d;
    cin >> x >> k >> d;

    if (x > 0) {
        if (abs(x) / abs(d) > k) {
            cout << abs(x - d * k) << endl;
        } else {
            long long zero1 = x - abs(x) / abs(d) * d;
            long long zero2 = x - (abs(x) / abs(d) + 1) * d;
            if (abs(zero1) > abs(zero2)) {
                long long tyuusin = zero2;
                if ((k - abs(x) / abs(d) + 1) % 2 == 0) {
                    cout << abs(tyuusin) << endl;
                } else {
                    if (tyuusin > 0) {
                        cout << abs(tyuusin - d) << endl;
                    } else {
                        cout << abs(tyuusin + d) << endl;
                    }
                }

            } else {
                long long tyuusin = zero1;
                if ((k - abs(x) / abs(d) ) % 2 == 0) {
                    cout << abs(tyuusin) << endl;
                } else {
                    if (tyuusin > 0) {
                        cout << abs(tyuusin - d) << endl;
                    } else {
                        cout << abs(tyuusin + d) << endl;
                    }
                }
            }
        }
    } else {
        if (abs(x) / abs(d) > k) {
            cout << abs(x + d * k) << endl;
        } else {
            long long zero1 = x + abs(x) / abs(d) * d;
            long long zero2 = x + (abs(x) / abs(d) + 1) * d;
            if (abs(zero1) > abs(zero2)) {
                long long tyuusin = zero2;
                if ((k - abs(x) / abs(d) + 1) % 2 == 0) {
                    cout << abs(tyuusin) << endl;
                } else {
                    if (tyuusin > 0) {
                        cout << abs(tyuusin - d) << endl;
                    } else {
                        cout << abs(tyuusin + d) << endl;
                    }
                }

            } else {
                long long tyuusin = zero1;
                if ((k - abs(x) / abs(d) ) % 2 == 0) {
                    cout << abs(tyuusin) << endl;
                } else {
                    if (tyuusin > 0) {
                        cout << abs(tyuusin - d) << endl;
                    } else {
                        cout << abs(tyuusin + d) << endl;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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



int main(){fastio
    ll n;cin>>n;
    ll a[n+2];rep(i,1,n)cin>>a[i];
    a[0]=a[n+1]=0;
    ll d[n+1];rep(i,0,n)d[i]=abs(a[i+1]-a[i]);
    ll sl[n+2],sr[n+2];
    sl[0]=0;sr[n+1]=0;
    rep(i,1,n+1)sl[i]=sl[i-1]+d[i-1];
    for(ll i=n;i>=0;i--)sr[i]=sr[i+1]+d[i];
    
    //rep(i,0,n+1)cout<<sl[i]<<" ";cout<<endl;
    //rep(i,0,n+1)cout<<sr[i]<<" ";cout<<endl;
    
    rep(i,1,n){
        cout<<sl[i-1]+sr[i+1]+abs(a[i+1]-a[i-1])<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 4352
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

const int MAX_N = 200001;

vector<vector<int>> G(MAX_N);
vector<ll> imos(MAX_N);
vector<ll> ans(MAX_N);

void dfs(int cv, int pv){
    if(pv != -1){
        imos[cv] += imos[pv];
        ans[cv] = imos[cv];
    }
    else{
        ans[cv] = imos[cv];
    }

    for(auto nv : G[cv]){
        if(nv == pv) continue;
        dfs(nv, cv);
    }

    return ;
}

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

    int n, q; cin>>n>>q;
    
    for(int i=0; i<n-1; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    for(int i=0; i<q; i++){
        int p, x; cin>>p>>x;
        p--;
        imos[p] += x;
    }

    dfs(0, -1);

    for(int i=0; i<n; i++){
        cout << ans[i] << " \n"[i == n-1];
    }
}


Measured memory_bytes: 22400
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from collections import Counter
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = [int(ai) for ai in input().split()]
    ca = Counter(a)

    s = sum(a)

    q = int(input())
    for _ in range(q):
        b, c = map(int, input().split())
        s = (s - b * ca[b]) + (c * ca[b])
        print(s)
        ca[c] += ca[b]
        ca[b] = 0


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 96476
#include<iostream>
using namespace std;
int main(){
  long num;
  cin >> num;
  int sum;
  long temp=num;
  while(num){
    sum+=num%10;
    num/=10;
  }
  if(temp%sum==0){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;

}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    query = []
    for _ in range(M):
        a, b = map(int, input().split())
        query.append([a,b])

    sort_query = sorted(query)

    cnt = 1
    left = 0
    right = float('inf')
    for i, j in sort_query:
        if max(left,i) >= min(right,j):
            cnt += 1
            left = i
            right = j
            continue
        left = max(left,i)
        right = min(right,j)

    print(cnt)
main()

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

int main(){
	int N;
	cin >> N;
	for(int i=0; 4*i<=N; i++){
		for(int j=0; 7*j<=N; j++){
			int TOTAL = 4*i + 7*j;
			if(TOTAL == N){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=100010;
int main()
{
    IO;
    int T=1;
    //cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        int cnt=0;
        bool ok=0;
        while(n--)
        {
            int a,b;
            cin>>a>>b;
            if(a==b) 
            {
                cnt++;
                if(cnt==3) ok=1; 
            }
            else cnt=0;
        }
        if(ok) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define MEM 1000
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
int t,n;
string s;
int main()
{
    sanic;
    cin >> s;
    for(int i=0; i<s.size(); i++)
        if(s[i]=='A') n++;
    if(!n || n==s.size()) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

const int INF = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int j = 0, k = 0;
    bool ok = true;
    while(ok){
        ok = false;
        for(int i = 0; i < n; i++){
            if (i == j) continue;
            a[i] %= a[j];
            if (a[i] != 0 && a[i] < a[k]) {
                k = i;
                ok = true;
            }
        }
        j = k;
    }
    cout << a[j] << endl;
}

Measured memory_bytes: 3740
# coding: utf-8
# Your code here!
K, S = list(map(int, input().split(' ')))

ccc = 0

for i in range(S+1):
    #x = i のとき
    if i>K:
        break
    #print(f'x={i}')

    for j in range(S-i+1):
        #y = j のとき
        #z = S - i - j
        #print(f'y={j}')
        #print(f'z={S-i-j}')
        if (j<=K) and (S - i - j <= K):
            ccc += 1
        
print(ccc)

Measured memory_bytes: 2940
S = input()
T = input()
a = ""
for i in range(len(S)+1):
    if i == 0:
        a = (S[-1] + S[:-1])
    else:
        a = a[-1] + a[:-1]
    if a == T:
        print("Yes")
        break
else:
    print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>s;
    n=s.size();
    int req_sz=(n/2)-(n%2==0);
    for(int i=req_sz;i>=1;i--)
    {
        int l=0;
        int r=i;
        int c=i;
        while(s[l]==s[r] and c>0)
        {
            c--;
            l++;
            r++;
        }
        if(c==0)
        {
            cout<<i*2;
            return 0;
        }
    }
    cout<<0;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
string a;
int ans=1073741824; 
int main()
{
    cin>>a;
    for(int i=1;i<a.length();i++)
        if(a[i]!=a[i-1])
            ans=min(ans,max(i,int(a.size())-i));
    cout<<min(ans,int(a.size()))<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	int k, a, b;
	cin >> k >> a >> b;
	for(int i = a; i <= b; i++)
	{
		if(i % k == 0)
		{
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  DV(P,lli,2,N,0);
  rep(i,0,2)rep(j,0,N)cin >> P[i][j];
  rep(i,1,N)P[0][i]+=P[0][i-1];
  rrep(i,N-1,0)P[1][i]+=P[1][i+1];
  rep(i,0,N)chmax(sum,P[0][i]+P[1][i]);
  Out(sum);
}

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

int main(){
  int w,h;
  char c;

  cin >> w >> h >> c;

  for(int i=0;i < h;i++){
    for(int j=0;j < w;j++){
      
      if( ( i == 0 || i == h-1 ) && ( j == 0 || j == w-1 ) ){
	cout << "+";
      }
      else if( ( i == 0 || i == h-1 ) && ( j > 0 && j < w-1 ) ){
	cout << "-";
      }
      else if( i == (h-1)/2 && j == (w-1)/2 ){
	cout << c;
      }
      else if( ( i > 0 && i < h-1 ) && ( j == 0 || j == w-1 ) ){
	cout << "|";
      }
      else if( ( i > 0 && i < h-1 ) && ( j > 0 && j < w-1 ) ){
	cout << ".";
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3104
using System;
using System.Linq;
public class Hello{
    public static void Main()
    {
        //入力Kを保持する
        var K = int.Parse(Console.ReadLine());
        //入力ABを保持する
        var AB = Console.ReadLine().Split().Select(e =>int.Parse(e)).ToArray();
        //AからBに至るまでKの倍数がないかチェックする
        for(var num =AB[0];num <= AB[1];num++)
        {
            if (num % K == 0)
            {
                //もし見つかればOKとしてループを抜け、処理終了
                Console.WriteLine("OK");
                return;
            }
        }
        //見つからなければ、NGとする
        Console.WriteLine("NG");
    }
}


Measured memory_bytes: 28252
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
int V,E;
vector<int> g[100100];
int dep[100100],low[100100],ord[100100];
int cnt = 0;
void dfs(int v,int p,int d){
	dep[v] = d;
	ord[v] = cnt++;
	low[v] = ord[v];
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]==p)continue;
		int ch = g[v][i];
		if(ord[ch]==-1){
			dfs(ch,v,d+1);
			low[v] = min(low[v],low[ch]);
		}else{
			low[v] = min(low[v],ord[ch]);
		}
	}
}
int main(){
	scanf("%d %d",&V,&E);
	vector<P> es(E);
	for(int i=0;i<E;i++){
		int s,t;
		scanf("%d %d",&s,&t);
		g[s].pb(t);
		g[t].pb(s);
		if(s>t)swap(s,t);
		es[i]=P(s,t);
	}
	memset(ord,-1,sizeof(ord));
	dfs(0,-1,0);
	vector<P> ans;
	for(int i=0;i<E;i++){
		int s = es[i].fi,t = es[i].sec;
		if(dep[s]>dep[t])swap(s,t);
		if(ord[s]<low[t])ans.pb(es[i]);	
	}
	sort(all(ans));
	for(int i=0;i<ans.size();i++)printf("%d %d\n",ans[i].fi,ans[i].sec);
	return 0;
}

Measured memory_bytes: 7624
l=list(map(int,input().split()))
n=l[0]
w=l[1]
va=[0]*n
wa=[0]*n
for i in range(n):
        
    x=list(map(int,input().split()))
    wa[i]=x[0]
    va[i]=x[1]
dp=[[0 for i in range(w+1)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(1,w+1):
    if wa[i-1]>j:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-wa[i-1]]+va[i-1])
print(dp[-1][-1])


Measured memory_bytes: 171528
#include<iostream>

using namespace std;

int main(){
  int X;
  cin >> X;
  int c = X / 100;
  int d = X % 100;
  int ans = 0;
  if(d <= 5 * c) ans = 1;
  if(X < 100) ans = 0;
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
ans = 0

n.times.map { gets.split.map(&:to_i) }.sort!.each do |a, b|
  if b > m
    ans += a * m
    m = 0
  else
    ans += a * b
    m -= b
  end

  break if m <= 0
end

puts ans


Measured memory_bytes: 10488
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 200000

int main(){

  int n; cin >> n;
  int A[MAX];

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

  int maxv = A[1] - A[0];
  int minv = A[0];
  
  for(int j=1;j<n;j++){
      maxv = max(maxv,A[j] - minv);
      minv = min(minv, A[j]);
    }

  cout << maxv << endl;
  
  return 0;
}



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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};

ll GCD(ll a, ll b){
  if(b==0) return a;
  else return GCD(b, a%b);
}

ll LCM(ll a, ll b){
  if(a<b) swap(a,b);
  return a/GCD(a,b)*b;
}
 
int main(){
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> s(n, k-q);
  for(int i=0; i<q; i++){
    int a;
    cin >> a;
    a--;
    s[a]++;
  }
  for(int i=0; i<n; i++){
    if(s[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int N;
      	cin>>N;
      	int a = N/7;
      	int count=0;
      	for(int i=0; i<=a; i++){
          if((N - i*7) % 4 == 0){
            count++;
            break;
          }
        }
      	if(count == 1){
        cout<<"Yes"<<endl;
        }else{
          cout<<"No"<<endl;
        }
    
    
    }

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N,ans=0;
	cin >> N;

	eFOR(i, 1, N) {
		if (i >= 1 && i <= 9)ans++;
		if (i >= 100 && i <= 999)ans++;
		if (i >= 10000 && i <= 99999)ans++;
		if (i >= 1000000 && i <= 9999999)ans++;
	}

	cout << ans << endl;

	return 0;
}



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

#define f(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define gcd(x,y)         __gcd(x,y)
#define lcm(x,y)        (x/gcd(x,y))*y
#define mod             1000000007
#define all(a)           a.begin(),a.end()
// for lightoj cin cout #define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



void solve(){

  int a,b;cin>>a>>b;
  int x=min(a,b);
  int y=max(a,b);
  string r;
  f(i,y) r+=to_string(x);
  cout << r << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


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

int main()
{
	int x,t=1,y=360;
    cin>>x;
    int k=360/x;
    if(k*x==360)
    {
        cout<<k;
        return 0;
    }
    else
    {
        
        while(true)
        {
            if(x%2==0 && y%2==0)
        	{
            	x/=2;
                t*=2;
                y/=2;
        	}
            else if(x%3==0 && y%3==0)
        	{
            	x/=3;
                t*=3;
                y/=3;
        	}
            else if(x%5==0 && y%5==0)
        	{
            	x/=5;
                t*=5;
                y/=5;
        	}
            else{
                break;
            }
        }
        cout<<360/t;
    }
}

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

using namespace std;

int main()
{
    long long a,b,g;
    cin >> a >> b;
    long long cnt = 1, d = 2;
    g = __gcd(a,b);
    while (g>1)
    {
        bool ok = 0;
        while (g%d == 0)
        {
            g/=d;
            ok = 1;
        }
        if (ok)
            cnt++;
        d++;
        if (d*d>g)
            d = g;
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int N = s.size();
    int C[200010];
    memset(C, 0, sizeof(C));
    set<char> K;
    int crt = 0;
    queue<int> G[26];
    for (int n = N - 1;n >= 0;n--) {
    	char c = s[n];
    	K.insert(c);
    	if (K.size() == 26) {
    		crt++;
    		K.clear();
    	}
    	C[n] = crt;
    }
    K.clear();
    for (int i = 0;i < N;i++) {
    	char c = s[i];
    	G[c - 'a'].push(i);
    }
    string sol;
    while (1) {
    	int crt = 1E9;
    	int idx = -1;
    	int q = 0;
    	for (int i = 0;i < 26;i++) {
    		if (G[i].size() == 0) {
    			sol.push_back('a' + i);
    			cout << sol << endl;
    			return 0;
    		}
    		int sz = C[G[i].front() + 1];
    		if (sz < crt) {
    			crt = sz;
    			idx = i;
    			q = G[i].front();
    		}
        }
        sol.push_back('a' + idx);
        for (int i = 0;i < 26;i++) {
        	while (G[i].size() > 0 && G[i].front() <= q) G[i].pop();
        }
    }
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 2068
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  s <- B.getLine
  putStrLn . toString . none' $ s

none'
  :: B.ByteString -> Maybe Char
none' x 
  | B.null fx = Nothing
  | otherwise = Just $ B.head fx
  where
    fx = B.dropWhile (`B.elem` x) $ B.pack ['a' .. 'z']

toString
  :: Maybe Char -> String
toString (Just c) = [c]
toString Nothing  = "None"

Measured memory_bytes: 636
#include<iostream>
#include<stack>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long n;
    cin >> n;
    stack<char>st;
    if(n <= 26){
        char a = 'a' + n - 1;
        cout << a << endl;
        return 0;
    }else{
        rep(i,10000){
            long long a;
            a = n % 26;
            if(a == 0) st.push('z');
            else st.push('a' + a - 1);
            n /= 26;
            /*if(n % 26 == 0 && n > 26 && st.top() != 'z'){
                rep(i,1000){
                    st.push('z');
                    n /= 26;
                    if(n == 1) break;
                    if(n == 1) break;
                    long long m = n - 1;
                    if(m % 26 == 0) continue;
                    else break;
                }
                if(n == 1) break;
            }*/
            if(st.top() == 'z') n -= 1;
            if(n == 0) break;
        }
    }
    while(!st.empty()){
        cout << st.top();
        st.pop();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
R0, W0, C, R = list(map(int, input().split()))
f=0
if R0 == W0 == C == R == 0:
    f+=1
while f==0:
    for X in range(10**5):
        if ((R0-W0*C)+R*X)>=0:
            y = ((R0-W0*C)+R*X)/C
            print(X)
            break
        else:
            continue
    R0, W0, C, R = list(map(int, input().split()))
    if R0 == W0 == C == R == 0:
        f+=1


Measured memory_bytes: 5592
def make_prime_factors_compress(n: int):
    """自然数nの素因数を列挙した圧縮済みリストを出力する
    計算量：O(sqrt(N))
    入出力例：156 -> [(2, 2), (3, 1), (13, 1)]
    """
    prime_factors = []
    for k in range(2, int(n**0.5) + 1):
        cnt = 0
        while n % k == 0:
            cnt += 1
            n = n // k
        if cnt != 0:
            prime_factors.append((k, cnt))
    if n != 1:
        prime_factors.append((n, 1))
    return prime_factors

def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a: int, b: int) -> int:
    """a, bの最小公倍数(least common multiple: LCM)を求める
    計算量: O(log(min(a, b)))
    """
    return (a * b) // gcd(a, b)

  
a, b = map(int, input().split())
gcd_ = gcd(a, b)
print(len(make_prime_factors_compress(gcd_)) + 1)

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

using namespace std;

const int N=305;

typedef long long LL;

int n,m,mo,f[N][N],s[N][N],ss[N][N],C[N][N],ans;

int main()
{
	scanf("%d%d%d",&n,&m,&mo); n++;
	C[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		C[i][0]=1;
		for (int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	f[1][0]=1;
	for (int i=0;i<=m;i++) s[1][i]=1,ss[1][i]=(i+1)%mo;
	for (int i=2;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			for (int x=1;x<i;x++) f[i][j]=(f[i][j]+(LL)s[x][j]*ss[i-x][j-1]%mo*C[i-2][x-1])%mo;
		}
		for (int j=m;j;j--) f[i][j]=((LL)f[i][j]-f[i][j-1])%mo;
		for (int j=1;j<=m;j++)
		{
			s[i][j]=(s[i][j-1]+f[i][j])%mo; ss[i][j]=(ss[i][j-1]+s[i][j])%mo;
		}
	}
	for (int i=1;i<=m;i++) ans=(ans+f[n][i])%mo;
	if (ans<0) ans+=mo;
	printf("%d\n",ans);
	return 0;
}

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

#define all(c) c.begin(),c.end()

template <class T>
struct knapsack {
  T c; 
  struct item { T p, w; };
  vector<item> is;
  void add_item(T p, T w) {
    is.push_back({p, w});
  }
  T det(T a, T b, T c, T d) {
    return a * d - b * c;
  }
  T z;
  void expbranch(T p, T w, int s, int t) {
    if (w <= c) {
      if (p >= z) z = p;
      for (; t < is.size(); ++t) {
        if (det(p - z - 1, w - c, is[t].p, is[t].w) < 0) return;
        expbranch(p + is[t].p, w + is[t].w, s, t + 1);
      }
    } else {
      for (; s >= 0; --s) {
        if (det(p - z - 1, w - c, is[s].p, is[s].w) < 0) return;
        expbranch(p - is[s].p, w - is[s].w, s - 1, t);
      }
    }
  }
  T solve() {
    sort(all(is), [](const item &a, const item &b) { 
      return a.p * b.w > a.w * b.p;
    });
    T p = 0, w = 0;
    z = 0;
    int b = 0; 
    for (; b < is.size() && w <= c; ++b) {
      p += is[b].p;
      w += is[b].w;
    }
    expbranch(p, w, b-1, b);
    return z;
  }
};

int main() {
  int s, n;
  scanf("%d %d", &n, &s);
  knapsack<long long> solver;
  solver.c = s;
  for (int i = 0; i < n; ++i) {
    int v, w; 
    scanf("%d %d", &w, &v);
    solver.add_item(v, w);
  }
  printf("%lld\n", solver.solve());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

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

	int ans = 0;
	for(int i = 1; i < N; i++)
		if(S[i] == 'E') ans++;

	int tmp = ans;
	for(int i = 1; i < N; i++) {
		if(S[i - 1] == 'W') tmp++;
		if(S[i] == 'E') tmp--;
		ans = min(ans, tmp);
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  int N, cntneg = 0, minn = 1000000000;
  long long cnt = 0;
  bool haszero = false;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    if (a == 0) haszero = true;
    if (a < 0) {
      cntneg++;
      a *= -1;
    }
    minn = min(a, minn);
    cnt += a;
  }
  if (cntneg % 2 == 0 || haszero) minn = 0; 
  cout << cnt - 2 * minn << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
 
const int MAXN = 200005;
 
int N;
long long A[MAXN];
long long Answer[MAXN];
 
void Read() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
 
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
}
 
bool used[MAXN];
long long pref[MAXN][2]; // (even, odd) only
 
void Solve() {
  priority_queue<pair<long long, pair<int, int>>> pq;
  set<int> unused;
 
  for (int i = 1; i <= N; i++) {
    pq.push({A[i], {i, i + 1}});
  }
 
  for (int i = 0; i <= N + 2; i++) {
    unused.emplace(i);
  }
 
  for (int i = 1; i <= N + 2; i++) {
    pref[i][0] = pref[i - 1][0];
    pref[i][1] = pref[i - 1][1];
    pref[i][i & 1] += A[i];
  }
  
  int num = 0;
  long long ans = 0;
 
  while (!pq.empty()) {
    long long w = pq.top().first;
    int u = pq.top().second.first;
    int v = pq.top().second.second;
    pq.pop();
    if (used[u] || used[v]) continue;
    
    used[u] = true, used[v] = true;
    unused.erase(u);
    unused.erase(v);
 
    Answer[++num] = (ans += w);
 
    int L = *prev(unused.lower_bound(u));
    int R = *unused.lower_bound(v);
 
    if (1 <= L && R <= N + 1) {
      long long NotTakeUV = (pref[R - 1][L & 1] - pref[L - 1][L & 1]);
      long long TakeUV = (pref[R - 1][(L & 1) ^ 1] - pref[L - 1][(L & 1) ^ 1]);
      pq.push({NotTakeUV - TakeUV, {L, R}});
    }
  }
}
 
void Write() {
 cout<<Answer[N/2];
}
 
int main() {
  Read();
  Solve();
  Write();
  return 0;
}

Measured memory_bytes: 21400
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <string>
#include <iostream>

using namespace std;

int main() {
  int n;
  int a[20], b[50], c[50];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n-1; i++) cin >> c[i];
  
  int before = 999;
  int hara = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] - before == 1) {
      hara += c[before-1];
    }
    hara += b[a[i]-1];
    before = a[i];
  }
  cout << hara << endl;
}

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 100050;

int n, l[maxn], r[maxn];
long long ans;

int main()
{
	#ifdef MPS
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	sf("%d",&n);
	fo(i,1,n) sf("%d%d",&l[i],&r[i]);
	sort(l,l+n+1); reverse(l,l+n+1);
	sort(r,r+n+1);
	fo(i,0,n) if(l[i]-r[i]>0) ans += 2*(l[i]-r[i]);
	pf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
def judge(L,y,x):
    T=[0]*10
    for i in range(y,y+3):
        for j in range(x,x+3):
            T[L[i][j]]+=1
    for t in range(1,10):
        if T[t]>1:
            for i in range(y,y+3):
                for j in range(x,x+3):
                    if L[i][j]==t:
                        P[i][j]="*"

def judgeRow(L,y):
    T=[0]*10
    for i in range(9):
        T[L[y][i]]+=1
    for i in range(1,10):
        if T[i]>1:
            for j in range(9):
                if L[y][j]==i:
                    P[y][j]="*"

def judgeCul(L,x):
    T=[0]*10
    for i in range(9):
        T[L[i][x]]+=1
    for i in range(1,10):
        if T[i]>1:
            for j in range(9):
                if L[j][x]==i:
                    P[j][x]="*"

n=input()
for dt in range(n):
    L=[map(int,raw_input().split()) for i in range(9)]
    P=[[" "]*9 for i in range(9)]
    for i in range(0,9,3):
        for j in range(0,9,3):
            judge(L,i,j)

    for i in range(9):
        judgeRow(L,i)
    for i in range(9):
        judgeCul(L,i)
    for i,j in zip(P,L):
        s=""
        for k,l in zip(i,j):
            s+=k+str(l)
        print s
    if dt!=n-1:
        print

Measured memory_bytes: 4328
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String name = in.next();
		int cnt=0;
		for(int s=0;s<n;s++){
			boolean sw=false;
			String a = in.next();
			for(int i=0;i<a.length();i++){//初期位置
				if(a.charAt(i)!=name.charAt(0))continue;
				for(int k=1;k<a.length();k++){
					String test="";
					for(int g=i;g<a.length();g+=k){
						if(test.length()>name.length())break;
						test+=a.charAt(g);
						if(test.equals(name)){
							sw=true;
							break;
						}
					}
					if(sw==true)break;
				}
				if(sw==true)break;
			}
			if(sw==true)cnt++;
		}
		System.out.println(cnt);
	}
}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define endl            "\n"

#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>

#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))


#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

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...);
}

const int N = 2e3 + 7;
vector <vi > adj;
bool vis[N];

void solve()
{
	int r, c;
	cin >> r >> c;
	if (r == 1 or c == 1)
	{
		cout << 1 << endl;
		return;
	}
	long long ans = 0;
	if (r % 2 == 0)
	{
		if (c % 2 == 0)
		{
			ans = r * c / 2;
		}
		else
		{
			ans += ((c / 2) + 1) * (r / 2);
			ans += ((c / 2)) * (r / 2);
		}
	}
	else
	{
		if (c % 2 == 0)
		{
			ans = r * c / 2;
		}
		else
		{
			ans += ((c / 2) + 1) * ((r / 2) + 1);
			//bug(ans);
			ans += (c / 2) * (r / 2);
			//bug(ans);
		}

	}
	cout << ans << endl;


	return;
}

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



	cout << setprecision(9) << fixed;

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}


	return 0;
}

Measured memory_bytes: 256
import math

n=int(input())
cnt=0

for i in range(2,int(math.sqrt(n))+1):
  c=0
  while n%i==0:
    c+=1
    n//=i
  for j in range(1,c+1):
    c-=j
    if c<0:
      break
    cnt+=1
if n!=1:
  cnt+=1

print(cnt)


Measured memory_bytes: 64224
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = int(input())

if n % 2 == 1:
    print(0)
else:
    c = 1
    s = 0
    while 2 * 5**c <= n:
        s += n // (2 * 5**c)
        c += 1
    print(s)

Measured memory_bytes: 2940
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, op, B = input().split()

    print(int(A) + int(B)) if op == '+' else print(int(A) - int(B))

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int n;
    int count=0;
    cin >> n;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        if(tmp==2){
            count++;
            continue;
        }
        for(int j=2;j<tmp;j++){
            if(j*j>tmp){
                count++;
                break;
                }
            if(tmp%j==0){
                break;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define fi first
#define se second
#define pb push_back
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
#define L(i,u) for (int i=head[u]; i!=0; i=edge[i].nxt)
#define abs(a) ((a)>0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
const int N = 202000;


inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=10*x+c-'0'; c=getchar();} x*=f;
}
int n,k,c[N],x[N],y[N];
int sum[2][4004][4004],v[2][4002][4002];
inline int getsum(int x0, int y0, int x1, int y1, int k) {
	x0--; y0--;
	return sum[k][x1][y1]-sum[k][x1][y0]-sum[k][x0][y1]+sum[k][x0][y0];
}
inline int getans(int x, int y) {
	return getsum(x,y,x+k-1,y+k-1,1)+getsum(x,y+k,x+k-1,y+k+k-1,0);
}
int main() { //freopen("1.in","r",stdin);
	memset(v,0,sizeof(v));
	read(n); read(k); rep(i,1,n) {
		read(x[i]),read(y[i]); char s[3]; scanf("%s",s); c[i]=s[0]=='W';
	}
	rep(i,1,n) {
		x[i]%=k*2; y[i]%=k*2;
		rep(j,-1,4) rep(J,-1,4) if (x[i]+k*j>=0&&x[i]+k*j<=4*k&&y[i]+k*J>=0&&y[i]+k*J<=4*k&&((j&1)==(J&1)))
			v[c[i]][x[i]+k*j][y[i]+k*J]++;
	}
	rep(i,1,k*4) rep(j,1,k*4) rep(p,0,1) {
		sum[p][i][j]=sum[p][i-1][j]+sum[p][i][j-1]-sum[p][i-1][j-1]+v[p][i][j];
	} int ans=0;
	rep(i,1,k*2) rep(j,1,k*2) ans=max(ans,getans(i,j));
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 252544
#include <iostream>
#include <algorithm>
#include <string>
#include <memory>
#include <vector>
int main() {
	int a, b; std::cin >> a >> b;
	if (a == b) std::cout << 2 * a << std::endl;
	else if (a > b) std::cout << 2 * a - 1 << std::endl;
	else std::cout << 2 * b - 1 << std::endl;
}

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

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];

    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}
   
int main(){
    int N,i,position[2]={};
    int count=1;
    int nums[8];
    int ans;
    cin>>N;
    vector<int> P(N);
    vector<int> Q(N);

    rep(i,N) cin>>P[i];
    rep(i,N) cin>>Q[i];

    rep(i,N) nums[i]=i+1;

    do{
        if(position[0]==0){
            for(i=0;nums[i]==P[i] && i<N;i++);
            if(i==N) position[0]=count;
        }
        if(position[1]==0){
            for(i=0;nums[i]==Q[i] && i<N;i++);
            if(i==N) position[1]=count;
        }
        count++;
    }while(next_permutation(nums,nums+N) &&(position[0]==0 || position[1]==0));

    ans=position[0]-position[1];
    if(ans<0) ans*=-1;

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


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

int main() {
  string tap;
  cin >> tap;
  
  for(int i = 0; i < tap.length(); i++){
    if(i % 2 == 0){
      if(tap.at(i) == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      
      if(tap.at(i) == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  cout << "Yes" << endl;
  return 0;

}


Measured memory_bytes: 256
n,d=gets.split.map(&:to_i)
p=[]
n.times{p<<gets.split.map(&:to_i)}
c=0
p.combination(2){|a,b|sum=0;0.upto(d-1){|i| sum+=(a[i]-b[i])**2};c+=1 if(Math.sqrt(sum).to_i)**2==sum}
puts c

Measured memory_bytes: 1788
#include <stdio.h>

#define ramen 700

int main(){
  char s[3];
  int count = 0;
  int total_value;
  
  scanf("%s" ,&s);
  
  for(int i=0;i <3; i++){
    if(s[i] == 'o')
      count ++;
  }
  
  total_value = ramen + 100*count;
  
  printf("%d" ,total_value);
  
  return 0; 
}


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

int main() {
	
	int n; cin >> n;
	string a, b, c; cin >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
			ans += 2;
		}
		else if (a[i] == b[i] && b[i] == c[i] && c[i] == a[i]) {}
		else {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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


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

    llong ans=0;
    for(llong i=1; i<=n; ++i)
    {
        llong tmp=n/i;
        ans+=i*tmp*(tmp+1)/2;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3624