akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int table[1000][1000];
std::vector<int > ans[1000];
int main(){
  int N;
  scanf("%d", &N);
  std::vector<int > vec;
  bool find=false;
  int k;
  for (int i=2; i*i<200000; i++){
    if (i*(i-1)/2==N){
      find=true;
      k=i;
      break;
    }
  }
  if (find){
    std::cout << "Yes" << std::endl;
    printf("%d\n", k);
    int counter=1;
    for (int i=0; i<k-1; i++){
      for (int j=0; j<=i; j++){
	if (i==j){
	  ans[k-1].push_back(counter);
	  ans[i].push_back(counter);
	} else {
	  ans[i].push_back(counter);
	  ans[j].push_back(counter);
	}
	counter++;
      }
    }
    for (int i=0; i<k; i++){
      //printf("------\n");
      printf("%d", k-1);
      for (int j=0; j<ans[i].size(); j++){
	printf(" %d", ans[i][j]);
      }
      printf("\n");
    }
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<cstring>
//#include<string>
//#include<queue>
//#include<cmath>
//#include<algorithm>
//#define debug1 cout<<"?"<<endl;
//#define debug2 cout<<"?"<<i<<endl;
#define PII pair<int,int>
typedef long long ll;
const int maxn=3e5+9;
const double pi=acos(-1);
const int mod=998244353;
const int INF=0x3f3f3f3f;
const double ep=1e-7;
using namespace std;
int n,m,vis[maxn];
pair<int,int>p[maxn];
int ans[maxn],tot;
vector<PII>v[maxn];
inline int dfs(int x)
{
	vis[x]=1;
	for(PII U:v[x])
	{
		int id=U.second,u=U.first;
		if(vis[u])continue;
		if(dfs(u))
		{
			ans[++tot]=id;
			p[x].second^=1;
		}
	}
	return p[x].second;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+1+n);
	for(int i=1;i<=m;i++)
	{
		int l,r,U,V;
		scanf("%d%d",&l,&r);
		U=lower_bound(p+1,p+1+n,make_pair(l,0))-p;
		V=upper_bound(p+1,p+1+n,make_pair(r,1))-p;
		if(l>r)continue;
		v[U].push_back({V,i});
		v[V].push_back({U,i});
	}
	for(int i=n+1;i>=1;i--)p[i].second^=p[i-1].second;
	for(int i=1;i<=n;i++)
	{
		if(vis[i])continue;
		if(dfs(i))
		{
			puts("-1");return 0;
		}
	}
	sort(ans+1,ans+1+tot);
	printf("%d\n",tot);
	for(int i=1;i<=tot;i++)printf("%d ",ans[i]);puts("");
}

Measured memory_bytes: 19584
#include<iostream>
#include<vector>
#include<set>

using namespace std;

typedef long long int llint;

int N;
set<llint> s;

int main() {
	cin >> N;
	bool ans = true;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		if (s.find(A) == s.end()) {
			s.insert(A);
		}
		else {
			ans = false;
		}
	}
	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

def main():
  n = int(input())
  def dfs(s, mx):
    if len(s) == n:
      print(s)
      return
    for c in range(ord('a'), ord(mx)+1):
      dfs(s + chr(c), (chr(ord(mx) + 1) if ord(mx) == c else mx))
  dfs('', 'a')
      
if __name__=='__main__':
  main()



Measured memory_bytes: 4340
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REV(c) reverse((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main() {
  string r;
  cin >> r;
  if (r[0] == '9' || r[1] == '9') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
    int n; cin >> n;
    string s[n + 1];
    int t[n + 1];
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i];
    }
    string x; cin >> x;
    int flag = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (flag) ans += t[i];
        if (s[i] == x) flag = 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
int abs(int x){
	if(x<0)return 0-x;
	return x;
}
int mod(int x){
	return x%100000;
}
int main()
{
    int n,m,s[100000],a;
	cin >> n >> m;
	for(int i=0;i<n-1;i++)cin >> s[i];
	int dp[100010];
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=dp[i-1]+s[i-1];
	}
	int y=1,ans=0;
	for(int i=0;i<m;i++){
		int x=y;
		cin >> a;
		y+=a;
		ans+=abs(dp[y-1]-dp[x-1]);
		ans=mod(ans);
	}
	printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1928
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> vec(n,0);
for(int i=0;i<n;i++){
    int a;
    cin>>a;
    vec.at(a-1)=i+1;
}
    for(int i=0;i<n;i++){
        cout<<vec.at(i)<<" ";
    }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include<math.h>

int main(void)
{
    double pai = 3.1415926535;
    double a,b,h,m;
    double h1=0;
    double m1=0;
    double tmp=0;
    double ans=0;

    scanf("%lf %lf %lf %lf",&a,&b,&h,&m);
    // printf("%lf %lf %lf %lf\n",a,b,h,m);

    h1=h*30+m*0.5;
    m1=m*6;
    if (h1-m1<0)
        tmp=(h1-m1)*-1;
    else
        tmp=h1-m1;
    

    if (tmp>180)
        tmp=360-tmp;

    // printf("%f\n",tmp);
    
    // BC2=52+62−2⋅5⋅6⋅14=25+36−15=46
    // 5.00000000000000000000
    
    ans=sqrt(a*a+b*b-2*a*b*cos(pai*tmp/180));
    printf("%.20f\n",ans);

    // ans=n%10;
    // // printf("%d\n",ans);

    // if (ans==2 || ans==4 || ans==5 || ans==7 || ans==9)
    //     printf("hon");
    // else if (ans==0 || ans==1 || ans==6 || ans==8)
    //     printf("pon");
    // else if (ans==3)
    //     printf("bon");

    return 0;
    

}

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

string s;
bool letters[27];
int steps[27];
int ans=INT_MAX;

int findsteps (char letter)
{
    int maximum=0;
    int left=0;
    string temp=letter+s+letter;
    
    for (int right=0; right<temp.size(); right++)
    {
        if (temp[right]==letter)
        {
            maximum=max(maximum, right-left-1);
            left=right;
        }
    }

    return maximum;
}

int main()
{
    cin>>s;
    
    for (int i=0; i<s.size(); i++)
    {
        letters[s[i]-'a']=true;
    }

    for (int i=0; i<27; i++)
    {
        if (letters[i])
        {
            steps[i]=findsteps(i+'a');
        }
    }

    for (int i=0; i<27; i++)
    {
        if (letters[i]!=0)
        {
            ans=min(ans, steps[i]);
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3584
N=int(input())
E=[[] for _ in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  u-=1
  v-=1
  E[u].append((v,w))
  E[v].append((u,w))
color=[-1]*N
color[0]=0
stack=[0]
while stack:
  u=stack.pop()
  for v,w in E[u]:
    if color[v]==-1:
      stack.append(v)
      if w%2==0:
        color[v]=color[u]
      else:
        color[v]=1 if color[u]==0 else 0
for i in range(N):
  print(color[i])

Measured memory_bytes: 38828
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var k,x int
	fmt.Scan(&k,&x)

	ans := strconv.Itoa(x - k + 1)
	for i := x - k + 2; i <= x + k - 1; i++ {
		ans += " " + strconv.Itoa(i)
	}
	fmt.Println(ans)
}

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

using namespace std;

int main()
{
    long long int n,m,sum=0;

    cin>>n>>m;
    long long int a[m];

    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n>=sum)
        cout<<n-sum;
    else
        cout<<-1;
    return 0;
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    A--, B--;
    cout << 98 << " " << 99 << endl;
    vector<vector<int>> b(49, vector<int>(100, 0));
    vector<vector<int>> w(49, vector<int>(100, 1));
    for (int i = 0; i < 24; i++) {
        for (int j = 0; j < 49; j++) {
            if (A == 0) {
                break;
            }
            b[2 * i + 1][2 * j + 1] = 1;
            A--;
        }
    }
    for (int i = 0; i < 24; i++) {
        for (int j = 0; j < 49; j++) {
            if (B == 0) {
                break;
            }
            w[2 * i + 1][2 * j + 1] = 0;
            B--;
        }
    }
    for (int i = 0; i < 49; i++) {
        for (int j = 0; j < 99; j++) {
            cout << (b[i][j] == 0 ? '#' : '.');
        }
        cout << endl;
    }
    for (int i = 0; i < 49; i++) {
        for (int j = 0; j < 99; j++) {
            cout << (w[i][j] == 0 ? '#' : '.');
        }
        cout << endl;
    }

    return 0;
}


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

int main() {
  int H,W;
  while(H!=0 || W!=0) {
      cin >> H >> W;
      for (int i=0; i<H; i++) {
          for (int j=0; j<W; j++) {
              cout << "#";
              if (j==W-1) cout << endl;
          }
          if (i==H-1) cout << endl;
      }
  }
}


Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main(void) {
  int x;
  cin >> x;

  if(x==7 || x==5 ||x==3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

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

#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    int N, D;
    cin >> N >> D;

    int ans = 0;
    rep(i,N){
      double x,y;
      cin >> x >> y;
      double dist = sqrt((x*x+y*y));
      if(dist<=D){
        ans++;
      }
    }
    printl(ans);
}


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

int main() {
	int d;
	cin >> d;
	const int n = 26;
	vector<int> c(n);
	vector<vector<int>> s(d, vector<int>(n));
	rep(i, n) cin >> c[i];
	rep(i, d) rep(j, n) cin >> s[i][j];
	vector<int> t(d);
	
	random_device rnd;
    mt19937 mt(rnd());
	rep (i, d) t[i] = mt()%n + 1;
	int ans = -1;
	int cnt = 0;
	while(1) {
		// 局所探索法
		cnt++;
		if(cnt > 200000) break;
		vector<int> old = t;
		const int CH = mt()%5 + 1; // CH箇所変える
		rep(i, CH) {
			int nd = mt()%d;
			int nq = mt()%n + 1;
			t[nd] = nq;
		}
		
		// 点数の再計算
		vector<int> nlast(n);
		ll now = 0;
		rep(i, d) {
			now += s[i][t[i]];
			nlast[t[i]-1] = i+1;
			rep(j, n) {
				now -= c[j] * (i+1-nlast[j-1]);
			}
		}
		
		// 良くなれば更新
		if(now > ans) {
			ans = now;
		} else {
			t = old;
		}
	}
	
	rep(i, d) printf("%d\n", t[i]);
	return 0;
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int N = 1e5 + 1e3;
vector<int> par(N, -1);
int root(int v) {
    return par[v] < 0 ? v : (par[v] = root(par[v]));
}
void merge(int a, int b) {
    if ((a = root(a)) == (b = root(b)))
        return;
    if (par[b] < par[a])
        swap(a, b);
    par[a] += par[b];
    par[b] = a;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pii> a(n);
    vector<pii> byx(n), byy(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
        byx[i] = {a[i].fi, i};
        byy[i] = {a[i].se, i};
    }
    sort(byy.begin(), byy.end());
    sort(byx.begin(), byx.end());
    vector<pair<int, pii>> v;
    for (int i = 1; i < n; i++) {
        v.push_back({byx[i].fi - byx[i - 1].fi, {byx[i].se, byx[i - 1].se}});
        v.push_back({byy[i].fi - byy[i - 1].fi, {byy[i].se, byy[i - 1].se}});
    }
    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < sz(v);i++) {
        if (root(v[i].se.fi) != root(v[i].se.se)) {
            ans += v[i].fi;
            merge(v[i].se.fi, v[i].se.se);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 14064
def check_sum(num):
    sum = 0
    while num>0:
        sum += num%10
        num //= 10
    return sum

limit, bottom, top = [int(x) for x  in input().split()]
total = 0
for i in range(1,limit+1):
    sum = check_sum(i)
    if ((sum >= bottom) and (sum <= top)):
        total += i
print(total)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,j=n-(n%2);i<=m;i++,j--)
	{
		if(n%2==0&&(j-i==n/2-1||j-i==n/2)) j--;
		printf("%d %d\n",i,j);
	}
	return 0;
}

Measured memory_bytes: 1728
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    AKIBA = []
    for pattern in product([0, 1], repeat=4):
        L = list("AKIHABARA")
        for idx, p in enumerate(pattern):
            if p == 1:
                if idx == 0:
                    L[0] = ""
                elif idx == 1:
                    L[4] = ""
                elif idx == 2:
                    L[6] = ""
                else:
                    L[8] = ""
        AKIBA.append("".join(L))

    print("YES" if s in AKIBA else "NO")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(long long sx, long long sy, long long tx, long long ty)
{
    //1回目
    for (int i = 0; i < ty - sy; i++)
    {
        cout << "U";
    }
    for (int i = 0; i < tx - sx; i++)
    {
        cout << "R";
    }
    for (int i = 0; i < ty - sy; i++)
    {
        cout << "D";
    }
    for (int i = 0; i < tx - sx; i++)
    {
        cout << "L";
    }

    //2回目
    cout << "L";
    for (int i = 0; i < ty - sy + 1; i++)
    {
        cout << "U";
    }
    for (int i = 0; i < tx - sx + 1; i++)
    {
        cout << "R";
    }
    cout << "D";

    cout << "R";
    for (int i = 0; i < ty - sy + 1; i++)
    {
        cout << "D";
    }
    for (int i = 0; i < tx - sx + 1; i++)
    {
        cout << "L";
    }
    cout << "U" << endl;
}

int main()
{
    long long sx;
    scanf("%lld", &sx);
    long long sy;
    scanf("%lld", &sy);
    long long tx;
    scanf("%lld", &tx);
    long long ty;
    scanf("%lld", &ty);
    solve(sx, sy, tx, ty);
    return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while ( (*x).left != NIL )
    {
      x = (*x).left;
    }
  return x;

}

Node treeSearch(Node u, int k){
  while(u != NIL && k != (*u).key)
    {
      if(k < (*u).key)
	u = (*u).left;
      else 
	u = (*u).right;
    }
  return u; 
}

Node treeSuccessor(Node x){
  Node y;
  if((*x).right != NIL)
    return  treeMinimum((*x).right);
  y = (*x).parent;
  while(  (y != NIL ) && ( x == (*y).right ) )
    {
      x = y;
      y = (*y).parent;
    }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if((*z).left == NIL || (*z).right == NIL)
    y = z;
  else
    y = treeSuccessor(z);
  
  if((*y).left != NIL)
    x = (*y).left;
  else 
    x = (*y).right;
  
  if(x != NIL)
    (*x).parent = (*y).parent;

  if((*y).parent == NIL)
    root = x;
  else if(y == (y->parent)->left)
    (y->parent)->left = x;
  else 
    (y->parent)->right = x;

  if(y != z)
    {
      (*z).key = (*y).key;
      z = y;
    }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if((*z).key < (*x).key)
      x = (*x).left;
    else x = (*x).right;
    (*z).parent = y;
  }
  if(y == NIL)
    root = z;
  else if( (*z).key < (*y).key )
    (*y).left = z;
  else (*y).right = z; 
}

void inorder(Node u){
 if( u != NIL )
   {
     inorder((*u).left);
  
     printf(" %d", (*u).key);
  
     inorder((*u).right);
   }
}

void preorder(Node u){
 if(u != NIL)
    {   
      printf(" %d",(*u).key);

      preorder((*u).left);
    
      preorder((*u).right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;

}

Measured memory_bytes: 19364
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    vector<ll> a(n * 3);

    for(int i = 0; i < n * 3; i++) cin >> a[i];

    sort(a.begin(), a.end(), greater<int>());

    ll ans = 0;
    for(int i = 1; i < n * 2; i += 2){
        ans += a[i];
    }

    cout << ans << endl;
}


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


#define int long long int
#define ff first
#define ss second
#define pb push_back

#define N 1010

int32_t main()
{
	string s;
	cin >> s;
	int n = 1 + (int)s.length();
	vector<int> a(n, -1);
	for (int i = 0; i < n; ++i)
	{
		char left = '>', right = '<';
		if (i)
			left = s[i - 1];
		if (i != n - 1)
			right = s[i];
		if (left == '>' && right == '<')
			a[i] = 0;
	}
	for (int i = 1; i < n; ++i)
	{
		if (a[i - 1] != -1 && s[i - 1] == '<')
			a[i] = a[i - 1] + 1;
	}
	for (int i = n - 2; i >= 0; --i)
	{
		if (a[i + 1] != -1 && s[i] == '>')
			a[i] = max(a[i], a[i + 1] + 1);
	}
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		sum += a[i];
	}
	cout << sum << "\n";

	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	vector<int> B( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	for( int i = 0; i < N; i++ ) {
		cin >> B[i];
	}

	long long diff1 = 0;
	long long diff2 = 0;
	for( int i = 0; i < N; i++ ) {
		if( A[i] > B[i] ) {
			diff1 += A[i] - B[i];
		}
		if( A[i] < B[i] ) {
			int d = B[i] - A[i];
			if( d > 1 ) {
				diff2 += d / 2;
			}
		}
	}
	string ans = "No";
	if( diff2 >= diff1 ) {
		ans = "Yes";
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll n,maa=-1,mab=-1,e,f,g=0,h=0,z=0,mac=-1,mad=-1,ans;
	cin>>n;
	ll a[n/2],b[n/2],c[100001]={0},d[100001]={0};
	for(int i=0;i<n/2;i++){
		cin>>a[i]>>b[i];
		c[a[i]]++;
		d[b[i]]++;
	}
	for(int i=1;i<100001;i++){
		if(maa<=c[i]){
			if(maa<c[i]){
				g=0;
			}
			maa=c[i];
			e=i;
			g++;
		}
		if(mab<=d[i]){
			if(mab<d[i]){
				h=0;
			}
			mab=d[i];
			f=i;
			h++;
		}
	}
	if(e==f){
		if(g!=1 || h!=1){
			cout << (n/2-maa)+(n/2-mab)<<endl;
		}
		else{
			for(int i=0;i<100001;i++){
				c[i]=0;
			    d[i]=0;
			}
			ll x[n/2],y[n/2];
			for(int i=0;i<n/2;i++){
				x[i]=a[i];
				if(x[i]==e){
					x[i]=z;
					z--;
				}
				if(x[i]>0){
					c[x[i]]++;
				}
				y[i]=b[i];
				if(y[i]==f){
					y[i]=z;
					z--;
				}
				if(y[i]>0){
					d[y[i]]++;
				}
			}
			for(int i=1;i<100001;i++){
		        if(mac<=c[i]){
			        /*if(mac<c[i]){
				        g=0;
			        }*/
			        mac=c[i];
			        //e=i;
			        //g++;
		        }
		        if(mad<=d[i]){
			        /*if(mad<d[i]){
				        h=0;
		        	}*/
			        mad=d[i];
			        /*f=i;
			        h++;*/
		        }
	        }
	        ans=min((n/2-maa)+(n/2-mad),(n/2-mac)+(n/2-mab));
	        cout << ans<<endl;

		}
	}
	else{
		cout <<(n/2-maa)+(n/2-mab)<<endl;
	}
	return 0;
}




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

int main(){
  ll N; cin>>N;
  vector<pair<ll, ll>> W;
  for(ll i=0; i<N; i++){
    ll A, B; cin>>A>>B;
    W.push_back(make_pair(B, A));
  }
  sort(W.begin(), W.end()); //締め切り順
  ll t=0;
  bool ikeru=1;
  for(ll i=0; i<N; i++){
    t+=W[i].second;
    // cout<<t<<endl;
    if(t>W[i].first){
      ikeru=0;
      break;
    }
  }
  if(ikeru) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 6384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
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; }

int main() {
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.Stack;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b && a == c) {
            System.out.println(1);
        } else if (a == b || b == c || c == a) {
            System.out.println(2);
        } else {
            System.out.println(3);
        }
    }
}


Measured memory_bytes: 23636
def norm_s(S):
    num = 97
    al_dict = {}
    new = ''
    for i, moji in enumerate(S):
        if moji not in al_dict:
            al_dict[moji] = i
            new += chr(num)
            num += 1
        else:
            new += new[al_dict[moji]]
    
    return new

S = input()
T = input()

new = norm_s(S)
new2 = norm_s(T)
if new==new2:
    print('Yes')
else:
    print('No')

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

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
  
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long
#define fill fill_n
#define pf push_front
#define pb push_back
#define FOR(i,l,r) for(int i=l;i<r;i++)
#define ROF(i,r,l) for(int i=r;i>=l;i--)
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
typedef vector<int> vi;
typedef vector<ll> vli;
typedef vector<pair<int,int>> vpi;

const int M = 1e9+7;
const int N = 2e5;
ll po(int,int);


void solve(){
    int n;cin>>n;
    int ans=0;
    FOR(i,1,n){
        int z = n/i;
        if(n%i==0) z--;
        ans += z;
        
    }
    
    cout<<ans<<"\n";

}




int main() {
   
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
    
   #ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin);  
   freopen("output.txt", "w", stdout); 
   #endif 

    int t=1;
    //cin>>t;
    FOR(i,1,t+1){
        //cout<<"Case #"<<i<<": "; 
        solve();
        
    }
    
    return 0;
    
    
}


ll po(int a,int b){
    if(b==0) return 1;
    ll ans=1;
    if(b%2==0){
        ans = po(a,b/2)%M;
        ans=(ans%M * ans%M)%M;
    }
    else{
        ans = po(a,(b-1)/2)%M;
        ans = (ans%M * ans%M * a)%M;
    }
    return ans%M;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
    	int n,i,j,k;
    	cin>>n;
    	map<int,int>m;
    	for(i=1;i<=100;i++)
    	{
    		for(j=1;j<=100;j++)
    		{
    			for(k=1;k<=100;k++)
    			{
    				int x=i*i+j*j+k*k+i*j+j*k+k*i;
    				m[x]++;
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			cout<<m[i]<<"\n";
		}
    	
    	

    }

}

Measured memory_bytes: 5360
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}

int main(){
  fastIO();
  ll n,m,val;
  priority_queue<ll,vector<ll>,greater<ll>>q;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>val;
    q.push(val);
  }
  vector<pair<ll,ll>>cb;
  for(int i=0;i<m;i++){
    ll b,c;
    cin>>b>>c;
    cb.push_back(make_pair(c,b));
  }
  sort(cb.begin(),cb.end());
  for(int i=cb.size()-1;i>=0;i--){
    if(cb[i].first<=q.top()){
      break;
    }else{
      while(cb[i].second>0&&cb[i].first>q.top()){
        cb[i].second--;
        q.pop(),q.push(cb[i].first);
      }
    }
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ans+=q.top();
    q.pop();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
    int N, *a;
    cin >> N;
    a = new int[N]; // 動的メモリ確保
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());

    int pointAlice = 0;
    int pointBob = 0;

    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            pointAlice += a[i];
        }
        else
        {
            pointBob += a[i];
        }
    }

    delete[] a;

    cout << pointAlice - pointBob << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
a = []
w_lt = 0
flag = True
for i in range(len(S)):
    if S[i] == "W":
        a.append(i)
    else:
        flag = False
if not flag:
    suma = 0
    for i in range(len(a)):
        suma += a[i] - i
    print(suma)
else:
    print("0")

Measured memory_bytes: 11368
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 500 + 10;
int a[N][N];

struct Node {
  int x1, y1, x2, y2;
};

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  vector<Node> ret;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] % 2 == 1) {
        ret.push_back({i + 1, j + 1, i + 2, j + 1});
        a[i + 1][j] += 1;
      }
    }
  }
  for (int j = 0; j < m - 1; ++j) {
    if (a[n - 1][j] % 2 == 1) {
      ret.push_back({n, j + 1, n, j + 2});
      a[n - 1][j + 1] += 1;
    }
  }
  printf("%d\n", (int)ret.size());
  for (auto& it : ret) {
    printf("%d %d %d %d\n", it.x1, it.y1, it.x2, it.y2);
  }
  return 0;
}


Measured memory_bytes: 5232
#include <iostream>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
const int NICO = 200000+10;

LL bit[NICO], n, k;
LL sum(int i) {
    LL res = 0;
    while(i > 0) {
        res += bit[i];
        i -= i & (-i);
    }
    return res;
}
void add(int i, LL x) {
    while(i < NICO) {
        bit[i] += x;
        i += i & (-i);
    }
}

LL a[NICO], s[NICO], b[NICO];
set<LL> st;
map<LL, LL> id;
int main() {
    cin >> n >> k;
    for(LL i=1; i<=n; i++) {
        scanf("%lld", &a[i]); 
        s[i] = s[i-1] + a[i];
        b[i] = s[i] - k * i;
        st.insert(b[i]);
    }
    st.insert(0);

    LL cnt = 0; set<LL>::iterator it;
    for(it = st.begin(); it != st.end(); it++) {
        id[*it] = ++cnt; 
    }

    LL ans = 0;
    for(LL i=0; i<=n; i++) {
        ans += sum(id[b[i]]);
        add(id[b[i]], 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 28416
#include<cstdio>
#include<cmath>
#include<iostream>
#include<climits>
using namespace std;
int n,h[100001],f[100001],k;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
		f[i]=INT_MAX;
	}
	f[1]=0;
	f[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		for(int j=i;j>=i-k&&j>=1;j--){
			f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
		}
	}
	printf("%d",f[n]);
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

string s;cin>>s;
for(int i=0;i<s.size();i++)cout<<'x';
cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import bisect


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    X = get_next_ints()

    x_sorted = sorted(X)
    med_index = int((N-1)/2)
    # print(med_index, x_sorted)
    for num in X:
        index = bisect.bisect(x_sorted, num)-1
        if index > med_index:
            print(x_sorted[med_index])
        else:
            print(x_sorted[med_index+1])



solve()

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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  vector<bool> b(N); //bが一回でも押されたボタンであるか
  int number = 1;
  int count = 0; //ボタンを押すべき回数
  bool imp = false; //ボタン２を押すのが不可能かどうか
  
  for(int i = 0; i < N; i++){cin >> a.at(i);}
  for(int i = 0; i < N; i++)
  {
    b.at(number - 1) = true;    
    number = a.at(number - 1);
    count++;
    if(b.at(number - 1))
    {
      imp = true;
      break;
    }
    else if(number == 2){break;}
  }
  
  if(imp){cout << "-1" << endl;}
  else{cout << count << endl;}
}

Measured memory_bytes: 3796
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, m: usize,
        xyz: [(Usize1, Usize1, i64); m]
    }

    let mut uft = UFT::new(n);
    for (x, y, _) in xyz {
        uft.merge(x, y);
    }

    let mut set = HashSet::new();
    for i in 0..n {
        set.insert(uft.root(i));
    }
    println!("{}", set.len());
}

#[allow(dead_code)]
/// Union Find Tree
pub struct UFT {
    pub par: Vec<usize>,
    pub rank: Vec<usize>,
}
impl UFT {
    #[allow(dead_code)]
    pub fn new(n: usize) -> Self {
        UFT {
            par: (0..n).collect(),
            rank: vec![0; n],
        }
    }
    #[allow(dead_code)]
    pub fn root(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let p = self.par[x];
            let pp = self.root(p);
            self.par[x] = pp;
            pp
        }
    }
    #[allow(dead_code)]
    pub fn merge(&mut self, x: usize, y: usize) {
        let x = self.root(x);
        let y = self.root(y);
        if x == y {
            return;
        }
        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
        } else {
            self.par[y] = x;
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
}

Measured memory_bytes: 7328
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int n, c[10000];
  while (true) {
    cin >> n;
    if (n == 0) break;
    vector<int> a;
    rep (i, n - 1) a.push_back((i + 1) * (i + 1) % n);
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    rep (i, n) c[i] = 0;
    rep (i, a.size()) rep (j, a.size()) if (i != j) {
      int k = a[i] - a[j];
      if (k < 0) k += n;
      if (k > (n - 1) / 2) k = n - k;
      ++c[k];
    }
    rep (i, (n - 1) / 2) cout << c[i + 1] << endl;
  }
}

Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define N 500005
using namespace std;

char s[N];

int l[N],r[N];

int main(){
    scanf("%s",s+1);
    int n=strlen(s+1); long long ans=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='<') l[i]=l[i-1]+1;
    }
    for(int i=n;i>=1;i--){
        if(s[i]=='>') r[i]=r[i+1]+1;
    }
    for(int i=1;i<=n+1;i++){
        ans+=max(l[i-1],r[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4608
#include <stdio.h>
int main(){
	int A, B;
	char zip[20];
	bool valid= true; //kita anggap semua postal code awalnya valid 
	
	scanf("%d %d", &A, &B);
	scanf("%s",zip);
	
	if(zip[A]!='-'){//269-6650|| cek apakah di index A itu bukan -
	valid= false; //jika bukan, valid menjadi false
}
	for (int i=0; zip[i] !='\0'; i++){
		if(i !=A){//cek index selain a
			if (zip[i]<'0'||zip[i]>'9'){//jika dia di luar rentang 0--9
				valid=false;//valid menjadi false
				break;//keluar dari loop
			}
		}
	}	
//jika valid adalah true, puts yes, selain itu no	
	
	(valid)? puts("Yes"): puts("No");
	
	
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){   string s;   cin>>s;   int ans=0,ans1=0;   for(int i=0;i<3;++i){     if(s[i]=='R')    ++ans;    else{     ans1=max(ans1,ans);     ans=0;}    }    ans1=max(ans,ans1);  cout<<ans1;return 0;}

Measured memory_bytes: 3620
n, k, q = list(map(int, input().split()))
a = [int(input()) for i in range(q)]
member = [0] * n
for i in a:
    member[i - 1] += 1
for i in member:
    if i > q - k or k > q:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 13616
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    bool ans = false;
    rep(i, N + 1) {
        rep(j, M + 1) {
            ll cnt = i * (M - j) + j * (N - i);
            if (cnt == K){
                ans = true;
            }
        }
    }
    if(ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << ' '<< a << ' '<< b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define REPD(i,n) for(ll i=n-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=a; i<=ll(b); i++)
#define FORD(i,a,b) for(ll i=a; i>=ll(b); i--)

int main(){
	int L, R;
	int d;
	cin >> L >> R >> d;
	int i=1;
	int count=0;
	while(i*d <= R){
		if(L<=i*d){
			if(i*d<=R){
				count++;
			}
		}
		i++;
	}
	cout << count <<endl;
}





Measured memory_bytes: 3628
class BinaryIndexedTree:
    # a[i] = [0] * n
    def __init__(self, n):
        self.size = n
        self.data = [0] * (n+1)

    # return sum(a[0:i])
    def cumulative_sum(self, i):
        ans = 0
        while i > 0:
            ans += self.data[i]
            i -= i & -i
        return ans

    # a[i] += x
    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.data[i] += x
            i += i & -i

def main():
    from sys import stdin
    input = stdin.buffer.readline

    n, q = map(int, input().split())
    a = list(map(int, input().split()))

    bit = BinaryIndexedTree(n)
    for i, ai in enumerate(a):
        bit.add(i, ai)

    ans = []
    for _ in range(q):
        typ, i, j = map(int, input().split())
        if typ == 0:
            bit.add(i, j)
        else:
            ans.append(bit.cumulative_sum(j) - bit.cumulative_sum(i))

    for i in ans:
        print(i)

main()

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b; cin >> a >> b;
  char s[12]; cin >> s;
  for(int i = 0; i < a; i++){
    if(!('0' <= s[i] && s[i] <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a] != '-') {
    cout << "No" << endl;
    return 0;
  }
  for(int i = a+1; i<= a+b; i++) {
    if(!('0' <= s[i] && s[i] <= '9')) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    for (int i = 0; i < M; i++) cin >> X[i];

    if (N >= M) cout << 0 << endl;
    else {
        sort(X.begin(), X.end());
        if (N == 1) cout << X[M - 1] - X[0] << endl;
        else {
            vector<pair<int, int>> Xbet(M - 1);
            for (int i = 0; i < M - 1; i++) {
                Xbet[i].first = X[i + 1] - X[i];
                Xbet[i].second = i;
            }
            sort(Xbet.begin(), Xbet.end());
            reverse(Xbet.begin(), Xbet.end());

            vector<int> cnt;
            for (int i = 0; i < N - 1; i++) {
                cnt.push_back(Xbet[i].second);
            }
            sort(cnt.begin(), cnt.end());
            int ans = X[cnt[0]] - X[0];
            for (int i = 1; i < N - 1; i++) {
                ans += X[cnt[i]] - X[cnt[i - 1] + 1];
            }
            ans += X[M - 1] - X[cnt[N - 2] + 1];
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 2044
#include<iostream>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
		      
const double PI=acos(-1);

bool solve(int den,double eps){
  int l=den*2,r=den*4;
  double pi = PI+eps+1e-10;
  int ans=0;
  while(l<=r){
    int mid=(l+r)/2;
    double tmp=(double)mid/den;
    if ( abs(pi-PI)>abs(tmp-PI)){
      pi=tmp;
      ans=mid;
    }
    
    if ( tmp>PI ){
      r=mid-1;
    }else {
      l=mid+1;
    }    
  }
  

  if ( ans==0)return false;
  else cout << ans<<'/'<<den<<endl;
  return true;
}

main(){
  double eps;
  while(cin>>eps && eps >0.0){
    int i=1;
    while(true && solve(i++,eps)==false);
  }
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

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

const int N = 543;

pair<int, int> c[N], s[N];

int dist(int i, int j) {
	return abs(s[i].first-c[j].first)+abs(s[i].second-c[j].second);
}

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		s[i] = make_pair(u, v);
	}
	for (int i = 0; i < m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		c[i] = make_pair(u, v);
	}
	for (int i = 0; i < n; ++i) {
		int cur = 0;
		for (int j = 1; j < m; ++j) {
			if (dist(i, j) < dist(i, cur)) cur = j;
		}
		debug(dist(i, cur));
		printf("%d\n", cur+1);
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	cout << N/3 << endl;
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
G = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
l = [i for i in range(2,N+1)]
import itertools
ans = 0
for v in itertools.permutations(l):
    v = list(v)
    flag = 1
    s = 1
    t = 1
    while v:
        s = t
        t = v.pop(0)
        if t not in G[s]:
            flag = 0
            break
    ans += flag
print(ans)

Measured memory_bytes: 3064
def solve():
 seq1 = raw_input()
 seq2 = raw_input()
 a, b = len(seq1), len(seq2)
 x1 = [0 for i in range(b+1)]
 for i in range(a):
  e1 = seq1[i]
  x2 = x1+[]
  for j in range(b):
   if e1 == seq2[j]:
    x1[j+1] = x2[j] + 1
   elif x1[j+1]<x1[j]:
    x1[j+1] = x1[j]
 return x1[-1]
  
n = input()
for i2 in range(n):
 print solve()

Measured memory_bytes: 6452
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d%d%d",&a,&b,&c);
	
	if(a < b){
		if(a<c){
			if(b<c){
				printf("Yes\n");
			}
			else{
				printf("No\n");
			}
		}
		else{
		printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int N;
vector<pair<int, int>> G[100010];
int col[100010];

void dfs(int v, int c) {
    col[v] = c;
    for (auto e : G[v]) if (!col[e.first]) {
        if (e.second % 2 == 1) dfs(e.first, -c);
        else dfs(e.first, c);
    }
}

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

    cin >> N;
    REP (i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }
    dfs(0, 1);
    REP (i, N) cout << (col[i] > 0) << endl;
}

Measured memory_bytes: 10240
// After contest. O(N*M) dp.
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 2002;
const int mo = 1e9 + 7;

int n, m, s[maxn], t[maxn], f[maxn][maxn];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;

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

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

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			f[i+1][j+1] = ((f[i][j+1] + f[i+1][j]) % mo - f[i][j] + mo) % mo;
			if (s[i] == t[j])
				f[i+1][j+1] = (f[i+1][j+1] + f[i][j] + 1) % mo;
		}

	cout << (f[n][m] + 1) % mo << endl;

	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"s) cout<<"Cloudy"<<endl;
  if(s=="Cloudy"s) cout<<"Rainy"<<endl;
  if(s=="Rainy"s) cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256