akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        ll m = n / i;
        ans += m * (m + 1) / 2 * i;
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if(A % (2 * B + 1) == 0){
    cout << A / (2 * B + 1) << endl;
  }
  else{
    cout << A / (B * 2 + 1) + 1 << endl;
  }

  
}


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

int main() {

	ll n, k; cin >> n >> k;
	vector<ll> c(n);
	for (ll i = 0; i < n; ++i) {
		cin >> c[i];
	}
	ll g = 1;
	while (true) {
		if (n <= k + (k - 1) * (g - 1)) {
			break;
		}
		else {
			g++;
		}
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, V[5010];
int dp[5010][5010];
map<int, int> go;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> V[i];
    sort(V, V + N);

    rrep(i, N - 1, 0) go[V[i]] = i;
    rep(sec, 0, N) rep(fir, sec + 1, N) {
        chmax(dp[sec][fir], 2);
        int d = V[fir] - V[sec];
        if (go.count(V[fir] + d)) chmax(dp[fir][go[V[fir] + d]], dp[sec][fir] + 1);
    }

    int ans = 0;
    rep(sec, 0, N) rep(fir, sec + 1, N) chmax(ans, dp[sec][fir]);
    cout << ans << endl;
}



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

int main(){

    char s1[100],s2[100],s3[200];
    scanf("%s", s1);
    scanf("%s", s2);
    strcpy(s3,s1);//s3にs1をコピー
    strcat(s3,s1);//s3にs1を連結

    if(strstr(s3,s2) == NULL){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    //printf("%s\n", s3);

    return 0;

}



Measured memory_bytes: 2060
n = int(input())
a=[]
for i in range(n):
    a.append(int(input()))
b ={}
for i in a:
    if i in b:
        b[i] += 1
    else:
        b[i] = 1

ans = 0
for i in b:
    if b[i]%2 == 1:
        ans += 1

print(ans)

Measured memory_bytes: 16268
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  string a;cin>>a;
  int b;cin>>b;
  rep(i,b){
    if(a[i]!='1'){
      cout<<a[i];
      return 0;
    }
  }
  cout<<1;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,k,a[27]={};
string s;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	REP(i,0,n){
		cin >> s;
		a[s[0]-'A']++;
	}
	
	bool used[26]={}; a[26]=-1;
	int ma,s,c=0;
	while(true){
		s=0; memset(used,false,sizeof(used));
		REP(j,0,26) if(a[j]) s++;
		if(s<k) break;
		REP(i,0,k){
			ma=26;
			REP(j,0,26) if(a[j]>0 and a[j]>a[ma] and (not used[j])) ma=j;
			used[ma]=true; a[ma]--;
		}
		c++;
	}
	
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin >> n;
    int ans = 1;
    for(int i = 1; i <= n; i++){
        ans = ans * 3;
    }
    int kisuu = 1;
    for(int i = 1; i <= n; i++){
        int in;
        cin >> in;
        if(in % 2 == 0){
            kisuu = kisuu * 2;
        }
    }
    cout << ans - kisuu << endl;

        return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

//Space-Time Sugoroku Road
public class Main{

	void run(){
		int LOOP = 1<<29;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n], nx = new int[n];
		Arrays.fill(nx, -1);
		for(int i=0;i<n;i++)p[i]=sc.nextInt();
		for(int i=0;i<n;i++){
			if(nx[i]!=-1)continue;
			if(p[i]==0){
				nx[i] = i; continue;
			}
			Set<Integer> s = new HashSet<Integer>();
			s.add(i);
			int v = i+p[i], r = 0;
			for(;;){
				if(nx[v]!=-1){
					r = nx[v]; break;
				}
				if(p[v]==0){
					r = v; s.add(v); break;
				}
				if(s.contains(v)){
					r = LOOP; s.add(v); break;
				}
				s.add(v);
				v+=p[v];
			}
			for(int x:s)nx[x] = r;
		}
		boolean[] u = new boolean[n];
		u[0] = true;
		List<Integer> l = new ArrayList<Integer>();
		l.add(0);
		int step = 0;
		while(!l.isEmpty()){
			List<Integer> next = new ArrayList<Integer>();
			for(int v:l){
				if(v==n-1){
					System.out.println(step); next.clear(); break;
				}
				for(int k=1;k<=6;k++){
					if(n<=v+k)break;
					int t = nx[v+k];
					if(t==LOOP||u[t])continue;
					u[t] = true; next.add(t);
				}
			}
			l = next;
			step++;
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main() {
  int N, counter=0;
  cin >> N;
  for (int i=1; i<N+1; i++) {
    if (i/10 < 1) {
      counter++;
    }
    if (10<=i/10 && i/10<100) {
      counter++;
    }
    if (1000<=i/10 && i/10<10000) {
      counter++;
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(int n){
    stringstream ss;
    ss << bitset<20>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
map<int, int> cnt;
int main()
{
    int n, s = 0; cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
        s += a[i];
    }
    int c1 = 0, c2 = 0;
    s /= n;
    rep(i,n){
        c1 += (s - a[i])*(s - a[i]);
        c2 += (s+1 - a[i])*(s+1 - a[i]);
    }
    cout << min(c1, c2) << endl;
    return 0;
} 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type dice struct {
	t int64
	e int64
	w int64
	s int64
	n int64
	b int64
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	d1 := &dice{
		t: nextInt(sc),
		s: nextInt(sc),
		e: nextInt(sc),
		w: nextInt(sc),
		n: nextInt(sc),
		b: nextInt(sc),
	}

	d2 := &dice{
		t: nextInt(sc),
		s: nextInt(sc),
		e: nextInt(sc),
		w: nextInt(sc),
		n: nextInt(sc),
		b: nextInt(sc),
	}

	if d1.same(d2) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func (d *dice) same(d2 *dice) bool {
	d2.setTopAndSouth(d.t, d.s)
	return d.t == d2.t && d.b == d2.b && d.n == d2.n &&
		d.e == d2.e && d.s == d2.s && d.w == d2.w
}

func (d *dice) setTopAndSouth(t, s int64) {
	d.setTop(t)
	switch s {
	case d.e:
		d.pitchL()
	case d.n:
		d.pitchR()
		d.pitchR()
	case d.w:
		d.pitchR()
	}
}

func (d *dice) setTop(t int64) {
	switch t {
	case d.s:
		d.rollN()
	case d.n:
		d.rollS()
	case d.e:
		d.rollW()
	case d.w:
		d.rollE()
	case d.b:
		d.rollN()
		d.rollN()
	}
}

func (d *dice) rollS() {
	oldB := d.b
	d.b = d.s
	d.s = d.t
	d.t = d.n
	d.n = oldB
}

func (d *dice) rollN() {
	oldB := d.b
	d.b = d.n
	d.n = d.t
	d.t = d.s
	d.s = oldB
}

func (d *dice) rollE() {
	oldB := d.b
	d.b = d.e
	d.e = d.t
	d.t = d.w
	d.w = oldB
}

func (d *dice) rollW() {
	oldB := d.b
	d.b = d.w
	d.w = d.t
	d.t = d.e
	d.e = oldB
}

func (d *dice) pitchR() {
	oldN := d.n
	d.n = d.e
	d.e = d.s
	d.s = d.w
	d.w = oldN
}

func (d *dice) pitchL() {
	oldN := d.n
	d.n = d.w
	d.w = d.s
	d.s = d.e
	d.e = oldN
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1108
import bisect
from collections import deque

newboard = [[False for i in range(3000)] for j in range(3000)]
q = deque([])
def bfs(yy,xx):
    global newboard
    q.append((yy,xx))
    while len(q) > 0:
        a = q.popleft()
        newboard[a[0]][a[1]] = True
        for d in [-1,1]:
            yyy = a[0]+d
            if(yyy < newh) and (0 <= yyy):
                if(newboard[yyy][a[1]] == False):
                    q.append((yyy,a[1]))
                    newboard[yyy][a[1]] = True
        for d in [-1,1]:
            xxx = a[1]+d
            if(xxx < neww) and (0 <= xxx):
                if(newboard[a[0]][xxx] == False):
                    q.append((a[0],xxx))
                    newboard[a[0]][xxx] = True

def compress(pointx,ww): #pointx:xory座標の列を圧縮して、圧縮後のworhを返す
    newx = []
    for x in pointx:
        for i in range(2):
            xx = x+i
            if(xx < ww) : newx.append(xx)
    newxuni = list(set(newx))
    newxuni.sort()
    for i in range(len(pointx)):
        pointx[i] = bisect.bisect_left(newxuni,pointx[i])

    return len(newxuni)

while True:
    w,h = map(int ,input().split())
    
    if (w == 0) : break
    
    n = int(input())
    ptx =[0]
    pty = [0]
    for i in range(n):
        xx1,yy1,xx2,yy2 = map(int ,input().split())
        ptx.append(xx1)
        ptx.append(xx2-1)
        pty.append(yy1)
        pty.append(yy2-1)
    
    neww = compress(ptx,w)
    newh = compress(pty,h)

    
    #新しい座標で塗りつぶし(imos法？) 0のところは塗られてない
    for i in range(newh):
        for j in range(neww):
            newboard[i][j] = False 
            
    for i in range(n):
        x1,y1,x2,y2 = ptx[2*i+1],pty[2*i+1],ptx[2*i+2],pty[2*i+2]
        for j in range(x1,x2+1):
            for k in range(y1,y2+1):
                newboard[k][j] = True
    
    '''   
    for i in range(n):
        x1,y1,x2,y2 = ptx[2*i+1],pty[2*i+1],ptx[2*i+2],pty[2*i+2]
        newboard[y1][x1] += 1
        if (x2+1 < neww) and (y2+1 < newh) : newboard[y2+1][x2+1] += 1
        if (x2+1 < neww) : newboard[y1][x2+1] -= 1
        if (y2+1 < newh) : newboard[y2+1][x1] -= 1

    for i in range(newh):
        for j in range(1,neww):
            newboard[i][j] += newboard[i][j-1]
    
    for i in range(neww):
        for j in range(1,newh):
            newboard[j][i] += newboard[j-1][i] 
    '''
    #幅優先
    ans = 0
    for i in range(newh):
        for j in range(neww):
            if(newboard[i][j]) : continue
            ans += 1
            bfs(i,j)
    
    print(ans)


Measured memory_bytes: 84600
#include<bits/stdc++.h>
using namespace std;
int dp[3][100001]={},arr[3][100001]={};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[0][i]>>arr[1][i]>>arr[2][i];
    }
    dp[0][1]=arr[0][1],dp[1][1]=arr[1][1],dp[2][1]=arr[2][1];
    for(int i=1;i<=n;i++){
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+arr[0][i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+arr[1][i];
        dp[2][i]=max(dp[1][i-1],dp[0][i-1])+arr[2][i];
    }

    cout<<max({dp[0][n],dp[1][n],dp[2][n]})<<'\n';
return 0;

}

//      *   *  *****  *   *  *   *   ****  ****    ****     **  ***
//     *   *  *      **  *  *   *  *      *   *  *        * *  *  *
//    *****  *****  * * *  *   *  *      ****   *       *  *    *
//   *   *      *  *  **  *   *  *      *  *   *       *****  *
//  *   *  *****  *   *   ***    ****  *   *   ****      *  ****

//     ****  *   *  *   *   ***   *   *  *****  *   *
//    *     *   *  *   *  *   *  *   *  *      *   *
//    ***  *****  *   *  *****  * * *  ****   *   *
//      *   *    *   *  *   *  * * *  *      *   *
//  ****   *     ***   *   *   * *   *****   ***


Measured memory_bytes: 5968
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    
    def COM(n, k, MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    
    fac,finv,inv=COMinit(N+K,MOD)
    sumcom=[0]*N
    sumcom[0]=1
    for i in range(N-1):
        sumcom[i+1]=sumcom[i]+COM(i+1+K-2,K-2,MOD)
    
    sum_min=0
    sum_max=0
    for i,x in enumerate(A):
        if i<=N-K:
            sum_min+=sumcom[(N-i)-K]*x
            sum_min%=MOD
        if i>=K-1:
            sum_max+=sumcom[i-(K-1)]*x
            sum_max%=MOD
    ans=sum_max-sum_min if sum_max-sum_min>=0 else sum_max-sum_min+MOD
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 63472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<char> x(6);
  for(int i=0;i<6;i++){cin>>x.at(i);}
  
  int count=0;
  if(x.at(0)==x.at(5)) count++;
  if(x.at(1)==x.at(4)) count++;
  if(x.at(2)==x.at(3)) count++;
  
  if(count==3)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set> 
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;
int gcd(int x,int y){
    if(y==0)return x;
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    int g=gcd(360,x);
    int n=360;
    n/=g;
    x/=g;
    int ans=n;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

const int N = 1e5 + 5;
int n, k, q, player;
vector< int > cnt( N, 0 );

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n >> k >> q;
	for( int i = 1; i <= q; ++i )
	{
		cin >> player;
		++cnt[ player ];
	}
	for( int i = 1; i <= n; ++i )
	{
		cout << ( k - q + cnt[ i ] > 0 ? "Yes" : "No" ) << "\n";		
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
int main()
{
	int l,c=0,t=0,m,n;
	while(1){
		scanf("%d",&l);
		if(l==0)break;
		for(int i=0;i<12;i++){
			scanf("%d %d",&m,&n);
			t+=m-n;
			c++;
			if(t>=l)c--;
		}
		if(t>=l)printf("%d\n",c+1);
		else
			printf("NA\n");
		t=c=0;
	}
	return 0;
}

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

int main(void){
    string s1,s2;
    cin>>s1>>s2;
    int dp[1010][1010];
    for(int i=0;i<=s1.size();i++){
        dp[0][i]=i;
    }
    for(int i=0;i<=s2.size();i++){
        dp[i][0]=i;
    }
    for(int i=1;i<=s2.size();i++){
        for(int j=1;j<=s1.size();j++){
            dp[i][j]=10000;
        }
    }
    for(int i=1;i<=s2.size();i++){
        for(int j=1;j<=s1.size();j++){
            int a=dp[i-1][j]+1,b=dp[i][j-1]+1;
            dp[i][j]=min(a,b);
            if(s2[i-1]==s1[j-1])dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
            else dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
        }
    }
    cout<<dp[s2.size()][s1.size()]<<endl;
    return 0;
}

Measured memory_bytes: 7156
q = int (input())

def pr(n):
    L = [1]*(n+1)
    L[0] = 0
    L[1] = 0
    for i in range(2,n+1):
        for j in range(2*i,n,i):
            L[j] = 0
    return L
    
a = pr(100001)

li = [0]*(100001)
for i in range(1,100000,2):
    if a[i] and a[(i+1)//2]:
        li[i] = 1
        
from itertools import accumulate
b = list(accumulate(li))

for i in range(q):
    l,r = map(int,input().split())
    print(b[r]-b[l-1])

Measured memory_bytes: 8124
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var A, B, C, K int

var MAX = pow(10, 18)

func main() {
	sc.Split(bufio.ScanWords)

	A, B, C, K = nextInt(), nextInt(), nextInt(), nextInt()
	if absInt(A-B) > MAX {
		fmt.Println("Unfair")
		return
	}
	if K%2 == 1 {
		fmt.Println(B - A)
	} else {
		fmt.Println(A - B)
	}

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, q;
    cin >> n >> q;
    priority_queue<P> que;
    que.push(P{0, 0});
    vector<int> cnt(n);
    for(int i=0; i<q; ++i) {
        int a, v;
        cin >> a >> v;
        a--;
        cnt[a] += v;
        que.push(P{cnt[a], -a});
        while(true) {
            P p = que.top();
            if(cnt[-p.second] != p.first) {
                que.pop();
            } else {
                cout << -p.second + 1 << ' ' << p.first << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 7716
using System;

namespace _0005 {

	public static class Program {

		public static void Main() {
			string input;
			while (!string.IsNullOrEmpty(input = Console.ReadLine())) {
				var splitStr = input.Split(' ');
				var a = long.Parse(splitStr[0]);
				var b = long.Parse(splitStr[1]);

				Console.WriteLine("{0} {1}", GCD(a, b), LCM(a, b));
			}
		}

		private static long LCM(long m, long n) {
			return m * n / GCD(m, n);
		}

		private static long GCD(long m, long n) {
			if (m < n) {
				return GCD(n, m);
			}
			return n == 0 ? m : GCD(n, m % n);
		}

	}

}

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  ll x = n;
  n = min(n, b-1);
  cout << (a*n)/b - a*(n/b) << endl;
  return 0;
}

Measured memory_bytes: 3636
import sys
import bisect
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    cor_v = a[0] * 2
    inc_v = a[-1] * 2 + 1
    while - cor_v + inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n-1, -1, -1):
            cost += n - bisect.bisect_left(a, bin_v - a[i])
        #costが制約を満たすか
        if cost >= m:
            cor_v = bin_v
        else:
            inc_v = bin_v
    acm = list(itertools.accumulate([0] + a))
    t = 0
    c = 0
    for i in range(n):
        p = bisect.bisect_left(a, cor_v - a[i])
        t += acm[-1] - acm[p] + a[i] * (n - p)
        c += n - p
    print(t - (c - m) * cor_v)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 54604
n , k = input().split()
n = int(n)
k = int(k)
lmin = list(range(0, k - 1))
lmax = list(range(n - k + 2, n + 1))
min = sum(lmin)
max = sum(lmax)
#print(lmin, min, lmax, max)
ans = 0
for i in range(k, n + 2):
    min += i - 1
    max += n - i + 1
    ans += max - min + 1
    #print(i, min, max, ans)

print(int(ans % (1e9 + 7)))


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

using namespace std;

int main()
{ 
    int n,m;
    cin>>n>>m;
    vector<bool> seen(n+1,false);
    vector<int> wrong(n+1,0);
    int rights = 0,wrongs = 0;
    for(int i = 0;i<m;i++)
    {
        int x;
        string s;
        cin>>x>>s;
        if(seen[x])
        {
            continue;
        }

        if(s == "WA")
        {
            wrong[x]++;
        }
        else if(s == "AC")
        {
            rights++;
            seen[x] = true;
        }
    }

    for(int i = 0;i<=n;i++)
    {
        if(seen[i])
        {
            wrongs += wrong[i];
        }
    }

    cout<<rights<<" "<<wrongs<<"\n";
    

    return 0;
}

Measured memory_bytes: 3692
from fractions import gcd
import math
A, B = map(int, input().split())
AB = gcd(A, B)

def prime_factorize(n) :
    res = []
    for i in range(2, int(math.sqrt(n))+1) :
        if n%i == 0 :
            ex = 0
            while (n%i == 0) :
                ex += 1
                n //= i
            res.append([i, ex])
    if n != 1 :
        res.append([n, 1])
    return res

print(len(prime_factorize(AB))+1)


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

public class Main {
    public static boolean solve(int N){
        for(int seven = 0; seven<=15; seven++){
        	for(int four=0;four<=25;four++){
        	    if(seven*7+four*4==N)return true;
        	}
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(solve(N) ? "Yes" : "No");
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 main(void){
    i32 *a=(i32 *)calloc(30LL,sizeof(i32));
    i64 d;
    for(i64 i=0LL;i<28LL;++i){
        scanf("%lli",&d);
        a[d-1LL]=1;
    }
    i64 x=llinf,y=llinf;
    for(i64 i=0LL;i<30LL;++i){
        if(!a[i]){
            if(x==llinf) x=i+1LL;
            else y=i+1LL;
        }
    }
    printf("%lli\n%lli\n",x<y?x:y,x>y?x:y);
    return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return 1;} return 0;}
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll, ll>;
int main() {
    int N; cin >> N;
    vector<pll> A(N);
    rep(i, N) {cin >> A[i].first, A[i].second = i;}
    sort(A.begin(), A.end(), greater<pll>());

    vector<vector<ll>> dp(N+1, vector<ll>(N+1, 0));
    rep(i, N){
        rep(j, N-i){
            chmax(dp[i+1][j], dp[i][j] + A[i+j].first * (A[i+j].second - i));
            chmax(dp[i][j+1], dp[i][j] + A[i+j].first * ((N-1-j) - A[i+j].second));
        }
    }
    ll res = 0;
    rep(i, N+1) chmax(res, dp[i][N-i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 34688
z[2002],*a=z,*b=z+1001,m,i,j,t;
main(n){for(;scanf("%d",&n),i=n;printf("%d\n",m)){
		for(memset(a,m=0,4004);i--;){
			for(j=scanf(" ");j++<n;)
				m=fmax(m,b[j]=getchar()-'*'?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);
			t=a;a=b;b=t;
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
 
using namespace std;
 
 
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
 
 
int main() {
	int n, m;
	cin >> n >> m;
	vector<int> ps;
	vector<int> rps;
	rps.resize(n);
	for (int i = 0; i < n; ++i) {
		int p;
		cin >> p;
		p--;
		ps.push_back(p);
		rps[p] = i;
	}
	vector<int> belong;
	for (int i = 0; i < n; ++i) {
		belong.push_back(i);
	}
	UnionFind uf(n);
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		uf.unionSet(x, y);
	}
	int sum = 0;
	for (int ind = 0; ind < n; ++ind) {
		int indnum = ps[ind];
		if (uf.findSet(ind, indnum)) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1912
import math

S = input()

sec = int(S)

h = math.floor(sec / 3600)
m = math.floor((sec - (h * 3600)) / 60)
s = math.floor(sec - (h * 3600) - (m * 60))

hms = [str(h), str(m), str(s)]

strhms = ':'.join(hms)

print(strhms)



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

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

int main(){
	int n,ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<1000;i++){
		int c[3]={i/100,(i/10)%10,i%10};
		int tmp=0;
		for(int j=0;j<n;j++){
			if(s[j]==c[tmp]+'0')tmp++;
			if(tmp==3)break;
		}
		if(tmp==3)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
x, k, d = map(int,input().split())
if x < 0: x = -x
mv = x // d
if mv >= k:
    # なるべく0に近づけば良い
    print(abs(x)-d*k)
else:
    nearest = x % d
    if (k - mv) % 2 == 1:
        print(abs(nearest - d))
    else:
        print(nearest)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;
int lp[N];
vector<int> prime;

void linear_sieve()
{
	mset(lp,0);
	prime.clear();
	loop(i,2,N)
	{
		if(lp[i] == 0)
		{
			prime.pb(i);
			lp[i] = i;
		}
		
		for(int j = 0; j < (int)prime.size() && i*prime[j] < N; j++)
		{
			lp[i*prime[j]] = prime[j];
		}
	}
}


void solve()
{
	linear_sieve();

	cin >> n;

	map<int,int> frq;

	loop(i,0,n)
	{
		cin >> A[i];
		int k = A[i];

		while(k > 1)
		{
			int rt = lp[k];
			while(k > 1 && k%rt == 0)k /= rt;
			frq[rt]++;	
		}
	}

	int ok = 0 , bok = 0;

	for(auto &it : frq)
	{
		if(it.ss >  1)ok = 1;
		if(it.ss == n)bok = 1;	
	}

	if(!ok)cout << "pairwise coprime";
	else if(!bok)cout << "setwise coprime";
	else cout << "not coprime";
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 32612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top = 0, S[1000];

void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
  	
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }
  	
  	else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
  	
  	else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } 
  	
  	else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}




Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
map<array<int, 4>, int> M;
array<int, 4> normalize(const array<int, 4>& A) {
    array<int, 4> ans = A, copy = A;
    for (int i = 0; i < 4; i++) {
        ans = min(ans, copy);
        rotate(begin(copy), begin(copy) + 1, end(copy));
    }
    return ans;
}
void mark(const array<int, 4>& A, int sign) {
    if (A[0] == A[1] && A[1] == A[2] && A[2] == A[3]) {
        M[A] += sign * 4;
    } else if (A[0] == A[2] && A[1] == A[3]) {
        M[A] += sign * 2;
    } else {
        M[A] += sign * 1;
    }
}
int main() {
    int N; cin >> N;
    vector<array<int, 4>> C(N);
    for (auto &sq : C) for (auto &c : sq) cin >> c;
    Int ans = 0;
    for (int i = 0; i < N; i++) {
        mark(normalize(C[i]), +1);
    }
    for (int i = 0; i < N; i++) {
        auto A = normalize(C[i]);
        mark(A, -1);
        int a[4] = { A[0], A[1], A[2], A[3] };
        for (int j = i + 1; j < N; j++) {
            auto B = normalize(C[j]);
            mark(B, -1);
            int b[4] = { B[1], B[0], B[3], B[2] };
            for (int k = 0; k < 4; k++) {
                array<int, 4> x = normalize({ a[0], b[0], b[1], a[1] });
                array<int, 4> y = normalize({ a[1], b[1], b[2], a[2] });
                array<int, 4> z = normalize({ a[2], b[2], b[3], a[3] });
                array<int, 4> w = normalize({ a[3], b[3], b[0], a[0] });
                Int res = 1;
                res *= M[x]; mark(x, -1);
                res *= M[y]; mark(y, -1);
                res *= M[z]; mark(z, -1);
                res *= M[w]; mark(w, -1);
                ans += res;
                mark(x, +1); mark(y, +1); mark(z, +1); mark(w, +1);
                rotate(begin(b), begin(b) + 1, end(b));
            }
            mark(B, +1);
        }
        mark(A, +1);
    }
    cout << ans / 3 << '\n';
    return 0;
}

Measured memory_bytes: 80128
#include <iostream>

using namespace std;

int main(void){
  int X=10;
  while(X<1 || 9<X)
    cin >> X;

  int flag[9] = {0};
  flag[2] = 1;
  flag[4] = 1;
  flag[6] = 1;

  if(flag[X-1])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

class Plogram
{
    static void Main()
    {
        long N = long.Parse(Console.ReadLine());

        long A = long.Parse(Console.ReadLine());
        long B = long.Parse(Console.ReadLine());
        long C = long.Parse(Console.ReadLine());
        long D = long.Parse(Console.ReadLine());
        long E = long.Parse(Console.ReadLine());

        long min = Math.Min(A, Math.Min(B, Math.Min(C, Math.Min(D, E))));

        Console.WriteLine(4 + Math.Ceiling((decimal)N / min));

    }
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(n), b(n), c(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; i++) cin>>c[i];

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    ll ans=0;
    for(int i=0; i<n; i++){
        ll sum=1;
        sum*=(lower_bound(a.begin(), a.end(), b[i])-a.begin());
        sum*=(n-(upper_bound(c.begin(), c.end(), b[i])-c.begin()));
        ans+=sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstring>
#include<deque>
using namespace std;
const int maxn=2e5+10;
char str[maxn],c;
deque<char> q;
int main()
{
	int len=0;
	while((c=getchar())!='\n')
    {
    	str[len]=c;
    	len++;
	}
	q.clear();
	q.push_back('#');
	for(int i=0;i<len;i++)
	{
		if(str[i]=='S')
			q.push_back(str[i]);
		else if(str[i]=='T')
		{
			char a=q.back();
			if(a=='T'||a=='#')
				q.push_back(str[i]);
			else if(a=='S')
				q.pop_back();
		}	
	}
	int ans=q.size();
	if(ans%2==1) ans--;
	printf("%d\n",ans); 
	return 0;
}

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

int main(){
    double a,b,h,m;
    cin >>a>>b>>h>>m;
    double ans;
    ans = pow(a,2)+pow(b,2)-2.0*a*b*cos(abs(60.0*h-11*m)*acos(-1)/360.0);
    ans=sqrt(ans);
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 4192
#include<bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    ll A,B,C;
    cin >> A >> B >> C;
    if(C >= A && C <= B){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import sys
while True:
    res = 0
    n, x = [int(i) for i in input().split()]
    if n == 0 and x == 0:
        sys.exit()
    else:
        for i in range(1, n+1):
            for j in range(1, n+1):
                if j == i:
                    break
                for k in range(1, n+1):
                    if k == j:
                        break
                    if i != j and j != k and k != i and i + j + k == x:
                        res += 1
    print(res)


Measured memory_bytes: 5604
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

int a, b, c, d, e;

int main(void)
{
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	int time = 0;
	bool frozen = (a < 0);
	while (a != b)
	{
		if (frozen)
		{
			if (a != 0)
			{
				time += c;
				++a;
			}
			else
			{
				time += d;
				frozen = false;
			}
		}
		else
		{
			time += e;
			++a;
		}
	}
	printf("%d\n", time);
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 998244353;
const int maxn = 3e5+10;

int dp[maxn];

void add(int l, int r, int x){
    if(l >= maxn) return;
    dp[l] += x;
    dp[l] %= MOD;
    if(r >= maxn) return ;
    dp[r + 1] -= x;
    dp[r + 1] %= MOD;
}

int32_t main(){
    fast_io;
    int n, k;
    cin >> n >> k;
    vector<pair<int, int > >v;
    for (int i = 0; i < k; ++i)
    {
        int l, r;
        cin >> l >> r;
        v.emplace_back(l, r);
    }
    add(1, 1, 1);
    fo(i, 1, n){
        dp[i] += dp[i - 1];
        dp[i] %= MOD;
        // show(i, dp[i]);
        for(const auto &it:v){
            add(i + it.first, i + it.second, dp[i]);
        }
    }
    if(dp[n] < 0) dp[n] += MOD;
    show(dp[n]);
    return 0;
}

Measured memory_bytes: 5992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		if(str.indexOf("a") != -1 &&
		   str.indexOf("b") != -1 &&
		   str.indexOf("c") != -1) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 22736
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k, a, cnt[200001];

int main(){
	cin >> n >> k;
	memset(cnt, 0, sizeof(cnt));
	
	for(ll i = 1; i <= n; i++){
		cin >> a;
		cnt[a]++;
	}
	
	sort(cnt+1, cnt+(n+1), greater<ll>());
	
	ll ans = n;
	for(ll i = 1; i <= k; i++){ans -= cnt[i];}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   vector<ll> div;
   for(ll i=1;i<=sqrt(n);i++)
   {
       if(n%i == 0)
           div.pb(i);
   }
   
   ll ans = n-1;
   for(ll i=0;i<div.size();i++)
   {
       ll temp = div[i]-1 + (n/div[i]) - 1;
       ans = min(ans,temp);
   }
   
   cout<<ans;
   
   return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int H,W;
int M[500][500];
VI com;
int com_cnt;


void greed(){
  REP0(i,H){
    REP0(j,W){
      if (M[i][j]%2==1) {  //0である場合は除外されている
        if (j+1 < W) {
          M[i][j]--; M[i][j+1]++; com_cnt++;
          com.PB(i); com.PB(j); com.PB(i); com.PB(j+1);
        }else if( i+1 < H ){
          M[i][j]--; M[i+1][j]++; com_cnt++;
          com.PB(i); com.PB(j); com.PB(i+1); com.PB(j);
        }else if( j-1 >= 0 && M[i][j-1]%2==1 ){
          M[i][j]--; M[i][j-1]++; com_cnt++;
          com.PB(i); com.PB(j); com.PB(i); com.PB(j-1);
        }else if( i-1 >= 0 && M[i-1][j]%2==1 ){
          M[i][j]--;  M[i-1][j]++; com_cnt++;
          com.PB(i); com.PB(j); com.PB(i-1); com.PB(j);
        }
      }
    }
  }
}


void input(){
  std::cin >> H >> W; int a;

  com_cnt = 0;
  com.reserve(H*W*4+1);

  REP0(i,H){
    REP0(j,W){
      std::cin >> a;
      M[i][j] = a;
    }
  }
}


void output(){
  std::cout << com_cnt << '\n';
  REP0(i,com_cnt){
    std::cout << com[i*4]+1 << " " << com[i*4+1]+1 << " " << com[i*4+2]+1 << " " << com[i*4+3]+1 << '\n';
  }
}


int main(int argc, char const *argv[]) {
  cin.tie(0); ios::sync_with_stdio(false);
  input();
  greed();
  output();
  return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    bool flag=true;
    for(int i=1;i<s.length()+1;i++){
        if(i%2==1){
            if(s.at(i-1)=='L'){
                flag= false;
            }
        }
        else{
            if(s.at(i-1)=='R'){
                flag=false;
            }
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

int main(){
    int a,b;
    
    cin >> a >> b;
    if (a > b){
        cout <<  "a > b" << endl;
    } else if  (a < b){
        cout <<  "a < b" << endl;
    } else if  (a == b)
        cout <<  "a == b" << endl;
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<char> c(n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> c.at(i);
        if (c.at(i) == 'R') cnt++;
    }
    int ans = cnt;
    for (int i = 0; i < cnt; i++) {
        if (c.at(i) == 'R') ans--;
    }
    cout << ans << endl;
    return 0;
}

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

int	modpow(int a, int n, int mod)
{
	int	res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int	main()
{
	const static int mod = 2019;
	int cnt_bin[2019] = {};
	string	S;
	cin >> S;
	int	size = S.size();
	int tmp = 0;
	for (int i = size - 1; i >= 0; --i) {
		int d = S.at(i) - '0';
		tmp += d * modpow(10, size - 1 - i, mod) % mod;
		tmp %= mod;
		++cnt_bin[tmp];
	}
	int64_t	sum = 0;
	sum += (cnt_bin[0] + 1) * cnt_bin[0] / 2;
	for (int i = 1; i < mod; ++i) {
		sum += (cnt_bin[i] - 1) * cnt_bin[i] / 2;
	}
	cout << sum << endl;
}


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

int main()
{
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        char c;
        cin >> c;
        if(c == 'Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
using namespace std;

int main(){
    long long int n,a=0,b=0;
    cin>>n;
    for(long long int i=0;a<n;i++){
        a+=i;
        b=i;
    }
    cout<<b<<endl;

    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, a, b, c, x;
        cin >> n >> a >> b >> c >> x;
        if(n == 0)
            return 0;

        vector<int> y(n);
        for(int i=0; i<n; ++i)
            cin >> y[i];

        int k = 0;
        for(int i=0; i<=10000; ++i){
            if(x == y[k])
                ++ k;
            if(k == n){
                cout << i << endl;
                break;
            }else if(i == 10000){
                cout << -1 << endl;
            }

            x = (a * x + b) % c;
        }
    }
}

Measured memory_bytes: 1196