akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  ll a,b,k;
  cin >> a >> b >> k;
  ll gcd = __gcd(a,b);
  debug(gcd);
  vector<ll> fac;
  for (ll i=1;i<=sqrt(gcd);i++) {
    if (gcd%i == 0) {
      fac.eb(i);
      if (gcd/i != i) fac.eb(gcd/i);
    }
  }
  sort(ALL(fac),greater<ll>());
  debug(fac);
  cout << fac[k-1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<bool> A(101,false),B(101,false);
    for(int i=a;i<=b;i++){
        A[i]=true;
    }
    for(int i=c;i<=d;i++){
        B[i]=true;
    }
    int t=0;
    rep(i,101){
        if(A[i]&&B[i]){
            t++;
        }
    }
    if(t>0){
        t--;
    }
    cout<<t<<endl;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  ll R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;

  ll ans = 0;
  vector<char> hist(N + 1);
  for (int i = 0; i < N; ++i) {
    if(i < K) {
      ans += (T[i] == 's') ? R : (T[i] == 'p') ? S : P;
      hist[i] = T[i];
    } else {
      if(hist[i-K] == T[i]) {
        if((i+K) <= N) {
          hist[i] = (T[i+K] == 's') ? 'p' : (T[i+K] == 'p') ? 'r' : 's';
        } else { // don't care

        }
      } else {
        ans += (T[i] == 's') ? R : (T[i] == 'p') ? S : P;
        hist[i] = T[i];
      }
    }
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from collections import deque
N,M=map(int,input().split())
table=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    table[a].append(b)
    table[b].append(a)
Q=int(input())
X=[[int(i) for i in input().split()] for i in range(Q)]
color=[0]*Q
dp=[[-1]*N for i in range(11)]
for i in range(Q-1,-1,-1):
    v, d, c=X[i]
    v=v-1
    color[i]=c
    dp[d][v]=max(dp[d][v],i)

for d in range(10,0,-1):
    for x in range(N):
        for y in table[x]:
            dp[d-1][y]=max(dp[d][x],dp[d-1][y])
for i in range(N):
    s=-1
    for d in range(11):
        s=max(s,dp[d][i])
    if s==-1:
        print(0)
    else:
        print(color[s])




Measured memory_bytes: 92976
import numpy

n,m,q=map(int,input().split())
M=[]
Q=[]
for i in range(m):
    M.append(list(map(int,input().split())))
for i in range(q):
    Q.append(list(map(int,input().split())))

#print(M)
#print(Q)

A=[[0 for i in range(n+1)] for j in range(n+1)]

for i in range(m):
    A[M[i][0]][M[i][1]]+=1

B=[[0 for i in range(n+1)] for j in range(n+1)] #Aの累積和のリスト

#B[0][0]=A[0][0]
#for i in range(1,n+1):
#    B[i][0]=A[i][0]+B[i-1][0]
#    B[0][i]=A[0][i]+B[0][i-1]

#for i in range(1,n+1):
#    for j in range(1,n+1):
#        B[i][j]=A[i][j]+B[i-1][j]+B[i][j-1]

#print(A)
#print(B)

B = numpy.cumsum(A,axis=0)
C = numpy.cumsum(B,axis=1)

#print(C)

for i in range(q):
    le=Q[i][0]
    ri=Q[i][1]
    print(C[ri][ri]-C[ri][le-1]-C[le-1][ri]+C[le-1][le-1])


Measured memory_bytes: 83740
require 'matrix'

while input = gets do
  a, b, c, d, e, f = input.split.map(&:to_f)
  m = Matrix[[a, b], [d, e]]
  v = Vector[c, f]
  puts (m.inv * v).to_a.map{ |x| sprintf("%.3f", x.to_f)}.to_s.gsub(/[\[\]\,\"]/, "")
end

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

long long f(long long i, long long j) {
	return (i!=-1 ? i / j + 1 : 0);
}

int main() {
	long long a, b, x; cin >> a >> b >> x;
	cout << f(b, x) - f(a - 1, x) << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
  int n,a,b,ans;
  cin>>n>>a>>b;
  if(a+n<b){
    ans=b-a-n;
  }
  else if(b+n<a){
    ans=a-b-n;
  }
  else if(a<=b<=a+n){
    ans=0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int left = sc.nextInt();
        int right = sc.nextInt();
        right -= left;
        left = left % 2019;
        right += left;

        int ans = 2020;
        int rightLimit = Math.min(left+2018, right);
        for(int i = left; i <= rightLimit; i++){
            for(int j = i+1; j <= rightLimit; j++){
                int num = (i * j) % 2019;
                ans = Math.min(ans, num);
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  int N, i, l, r, ans;
  cin >> N;
  ans = 0;
  for(i=0;i<N;i++){
    cin >> l >> r;
    ans += r - l + 1; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#import math
import fractions
a,b,c,d = map(int,input().split())

def anti_div(a,b,c):
    aa = (a-1) - (a-1) // c
    bb = b - b // c
    return bb - aa

# c,dの最小公倍数を求める
# l = c*d / gcd
#lcd = c // math.gcd(c,d) * d
lcd = c // fractions.gcd(c,d) * d

ans = anti_div(a,b,c) + anti_div(a,b,d) - anti_div(a,b,lcd)
print(ans)

Measured memory_bytes: 5348
w,h,n = map(int,input().split())
x_max = w
x_min = 0
y_max = h
y_min = 0
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        x_min = max(x_min,x)
    elif a == 2:
        x_max = min(x_max,x)
    elif a == 3:
        y_min = max(y_min,y)
    elif a == 4:
        y_max = min(y_max,y)
    #print(x_max,x_min,y_max,y_min)
a= max(x_max-x_min,0) 
b =max(y_max-y_min,0)
print(a*b)

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

int main() {
  ll n, d;
  cin >> n >> d;
  int r = 0;
  while (n--) {
    ll x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d) r++;
  }
  cout << r << endl;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int[] ai = new int[N];

   for(int i=0;i<N;i++) ai[i] = sc.nextInt();
   
   int[] ans = new int[N];
   for(int i = 0;i<N;i++) ans[ai[i]-1]=i+1;
   for(int i=0;i<N;i++) System.out.print(ans[i]+" ");
 }
}

Measured memory_bytes: 63424
#include <iostream>
#include <vector>
using namespace std;
 
vector<string> getResult(uint K, uint N, vector<unsigned long long> A){
  vector<string> results;
  for(uint i = K; i < N; i++){
    results.push_back((A[i] > A[i - K])? "Yes" : "No");
  }
  return results;
}
 
int main(){
  uint N, K;
  cin >> N >> K;
  
  vector<unsigned long long> A(N);
  for(uint i = 0; i < N; i++){
    cin >> A[i];
  }
  
  vector<string> results = getResult(K, N, A);  
  for(string result : results){
	cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 14680
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<tuple<string, int, int>> v(N);
	for (int i = 0; i < N; i++) {
		string S;
		int P;
		cin >> S >> P;
		P *= -1;
		get<0>(v[i]) = S;
		get<1>(v[i]) = P;
		get<2>(v[i]) = i + 1;
	}
	sort(v.begin(), v.end());

	for (int i = 0; i < N; i++) {
		cout << get<2>(v[i]) << endl;
	}
}

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

struct Edge {
  int to;
};

typedef vector<vector<Edge> > Graph;

int dfsA(const Graph &g, int v, int pre, int &times, vector<int> &num,
         vector<int> &ap) {
  int res = num[v] = times++;
  bool flag = false;
  int c = 0;
  for(int i = 0; i < g[v].size(); ++i) {
    int nv = g[v][i].to;
    int t;
    if(num[nv] == -1) {
      t = dfsA(g, nv, v, times, num, ap);
      ++c;
      if(t >= num[v]) {
        flag = true;
      }
    } else {
      t = num[nv];
    }
    if(nv != pre) {
      res = min(res, t);
    }
  }
  if(pre == -1) {
    if(c > 1) ap.push_back(v);
  } else if(flag) ap.push_back(v);
  return res;
}

vector<int> getArticulationPoint(const Graph &g) {
  vector<int> res;
  int n = g.size();
  int times = 0;
  vector<int> num(n, -1);
  for(int i = 0; i < n; ++i) {
    if(num[i] == -1) {
      dfsA(g, i, -1, times, num, res);
    }
  }
  return res;
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph G(N);
  for(int i = 0; i < M; ++i) {
    int s, t;
    cin >> s >> t;
    G[s].push_back((Edge){t});
    G[t].push_back((Edge){s});
  }
  vector<int> ap = getArticulationPoint(G);
  sort(ap.begin(), ap.end());
  for(int i = 0; i < ap.size(); ++i) {
    cout << ap[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 2984
#include <iostream>
#include <algorithm>
#include <map>

const int lens = 1e5 + 1;
long long n,m,a[lens],sum[lens];
std::map<long long,long long> map;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        std::cin >> a[i];
    }   

    long long ans = 0;
    map[0]++; 
    for(int i = 1;i <= n;i++)
    {
        sum[i] = (sum[i - 1] + a[i]) % m;
        ans += map[sum[i]];
        map[sum[i]]++;
    }
    std::cout << ans;
    return 0;
}

Measured memory_bytes: 8972
def output(H,W):
    i=1
    while i<=H:

        if i%2==1:
            if W%2==0:
                print("#."*(W//2))
            else:
                print("#"+".#"*((W-1)//2))
                
        else:
            if W%2==0:
                print(".#"*(W//2))
            else:
                print("."+"#."*((W-1)//2))
        i=i+1
    print("")
#入力した文字を変数に格納する
input_number=input()

array=input_number.split()

#整数型に変換を行う
H=int(array[0])
W=int(array[1])

while not( H==0 and W==0):

    output(H,W)
    
    input_number=input()
    array=input_number.split()
    H=int(array[0])
    W=int(array[1])
  


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

#define int long long

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

int N, M;
int p[210000], q[210000], c[210000];
multimap<int, int> G[110000];
int d[110000];

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> p[i] >> q[i] >> c[i];
        G[p[i]].emplace(c[i], q[i]);
        G[q[i]].emplace(c[i], p[i]);
    }
    fill(d, d + N + 1, -1);
    d[1] = 0;
    queue<int> bfs;
    bfs.push(1);
    while (!bfs.empty()) {
        int cur = bfs.front();
        bfs.pop();
        while (!G[cur].empty()) {
            int color = G[cur].begin()->first;
            stack<int> dfs;
            dfs.push(cur);
            while (!dfs.empty()) {
                int curcur = dfs.top();
                dfs.pop();
                auto p = G[curcur].equal_range(color);
                for (auto it = p.first; it != p.second; ++it) {
                    int next = it->second;
                    if (d[next] == -1) {
                        bfs.push(next);
                        d[next] = d[cur] + 1;
                    }
                    dfs.push(next);
                }
                G[curcur].erase(color);
            }
        }
    }
    cout << d[N] << endl;
}

Measured memory_bytes: 38400
#include<bits/stdc++.h>
using namespace std;
int main(){
 long long N; cin >> N;
 long long ans = 1000000000000;
 for(int i = 1; i <= sqrt(N); i++){
   if(N % i == 0){
     long long a = i;
     long long b = N / i;
     if(ans > (a + b - 2)) ans = a + b - 2;
  }
 }
  cout << ans << endl;
}

Measured memory_bytes: 3548
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
#define ld long double
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

int main() {
	ios;
	ll a,b,c,k,count  = 0;
	cin>>a>>b>>c>>k;
	while(a>=b)
	{
	    b *=2;
	    count++;
	}
	while(b>=c)
	{
	    c *=2;
	    count++;
	}
	if(count<=k)
	{
	    cout<<"Yes"<<endl;
	}
	else
	{
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

#############
# Libraries #
#############
import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

schedule = []

last = [-1 for i in range(26)]
for d in range(D):
  MAX = -10**20
  temp = None
  for j in range(26):
    s = 0
    for i in range(26):
      if i == j:
        last[i] = d
        s += S[d][i]
      else:
        s -= C[i]*(d-last[i])
    if s > MAX:
      MAX = s
      temp = j
  schedule.append(temp)
  
score = 0
last = [[-1] for i in range(26)]  

for d in range(D):
  t = schedule[d]
  last[t].append(d)
  score += S[d][t]
  
for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 0

while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)


Measured memory_bytes: 83756
import java.util.*;

class Main {
   public static void main(String[] args)
   {
      Scanner scan  = new Scanner(System.in);
      int     N     = scan.nextInt();
      int     Alice = 0;
      int     Bob   = 0;

      int[] Card = new int[N];
      for(int i = 0; i < N; i++){
          Card[i] = scan.nextInt();
          }
      Arrays.sort(Card);
      for(int j = 0; j < N; j++){
          if(j % 2 == 0){
             Alice += Card[j];
             }
          else{
              Bob += Card[j];
              }
          }
      if(N % 2 == 0){
         System.out.println(-Alice + Bob);
         }
      else{
          System.out.println(Alice - Bob);
          }
   }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){

	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2,a_bottom,a_top,a_left,a_right,b_top,b_bottom,b_left,b_right;

	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xa1,&ya1,&xa2,&ya2,&xb1,&yb1,&xb2,&yb2)!=EOF){
		a_bottom = ya1;
		a_left = xa1;
		a_top = ya2;
		a_right = xa2;

		b_bottom = yb1;
		b_left = xb1;
		b_top = yb2;
		b_right = xb2;

		if(((a_right >= b_left && a_right <= b_right)||(b_right >= a_left && b_right <= a_right))
				&&((b_top >= a_bottom && b_top <= a_top)|| (a_top >= b_bottom && a_top <= b_top))){
			printf("YES\n");
		}else{
			printf("NO\n");
		}

	}

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
string table[10] = { "!", "',.!?", "abcABC", "defDEF", "ghiGHI",
"jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ" };

int main(){
	while (cin >> s){
		string ans;
		int num1 = -1, num2 = 0;
		REP(i, s.size()){
			if (num1 == -1){
				num1 = s[i] - '0';
				if (num1 == 0){
					num1 = -1;
					ans += ' ';
				}
			}
			else{
				if (num1 == s[i] - '0'){
					num2++;
					if (num2 >= table[num1].size()){
						num2 = 0;
					}
				}
				else{
					ans += table[num1][num2];
					num2 = 0;
					if (s[i] == '0')num1 = -1;
					else num1 = s[i] - '0';
				}
			}
		}
		//cout << ans << endl;
		if (num1 != 0)ans += table[num1][num2];
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>

using namespace std;

typedef long long ll;

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

int main(){
  ll a, b;
  std::cin >> a >> b;

  std::cout << a*b/gcd(a, b) << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  char ss[110];
  ll sum = 0;
  while(~scanf("%s",ss)){
    string s = string(ss);
    s += '.';
    ll cur = 0;
    REP(i,s.size()){
      char c = s[i];
      if('0'<=c && c<='9'){
        cur *= 10;
        cur += (c-'0');
      }else{
        sum += cur;
        cur = 0;
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1212
#include "bits/stdc++.h"

using namespace std;

std::string string_sort(std::string s, bool abcef=true) {

  std::vector<unsigned char> v(s.length());
  for (int i = 0; i < s.length(); ++i) {
    v[i] = s[i];
  }
  if (abcef) {
    std::sort(v.begin(), v.end());
  }
  else {
    std::sort(v.begin(), v.end(), std::greater<unsigned char>());
  }

  string t(s);
  for (int i = 0; i < s.length(); ++i) {
    t[i] = v[i];
  }
  return t;
}

long long nCr(long long n, long long r) {
  long long num = 1;
  for (long long i = 1; i <= r; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}
int main()
{

  int LEN = 10;
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; ++i) {
    string s;
    cin >> s;
    S[i] = string_sort(s);
  }

  map<string, int > C;
  for (int i = 0; i < N; ++i) {
    C[S[i]] ++;
  }

  long long v = 0;
  for (auto itr = C.begin(); itr != C.end(); ++itr) {
    long long n = (long long)itr->second;
    long long val = nCr(n,2);
    v += val;
  }
  cout << v;
  return 0;
}



Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
int main() {
   string s,t;
  cin >> s>> t;
  int l = s.size();
string ans = "No";
for(int i = 0;i < l ; i++){
  if(s==t){
ans = "Yes";
  }
  s = s.back()+s.substr(0,l-1);
}

cout << ans <<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

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

void Main() {
  int N, K, Q; cin >> N >> K >> Q;
  vector<int> A(Q);
  rep(i, 0, Q){
    cin >> A[i];
    A[i]--;
  }
  vector<int> C(N, K);
  rep(i, 0, Q){
    C[A[i]]++;
  }
  rep(i, 0, N){
    if(C[i] - Q > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

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

  Main();
}


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

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    multiset<int> s;
    rep(i, (1<<N)) {
        int si; cin >> si;
        s.insert(si);
    }
    
    multiset<int> s2;
    s2.insert(*--s.end());
    s.erase(--s.end());
    
    rep(i, N) {
        for (auto it=s2.begin(); it!=s2.end(); it++) {
            auto it2 = s.lower_bound(*it);
            if (it2==s.begin()) {
                cout << "No" << endl;
                exit(0);
            }
            s2.insert(*--it2);
            s.erase(it2);
        }
    }
    
    cout << "Yes" << endl;
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(N, vector<int>(N));
	for (int i = 0, a, b; i < M; i++) {
		cin >> a >> b;
		G[a - 1][b - 1]++;
		G[b - 1][a - 1]++;
	}
	long long res = 0;
	vector<int> g(N);
	for (int i = 0; i < N; i++) {
		g[i] = i;
	}
	do {
		if (g[0] == 0) {
			bool f = true;
			for (int i = 1; i < N; i++) {
				if (G[g[i - 1]][g[i]] == 0) {
					f = false;
					break;
				}
			}
			if (f) {
				res++;
			}
		}
	} while (next_permutation(g.begin(), g.end()));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define	show(x)	 copy( (x).begin(), (x).end(), ostream_iterator<int>(cout, ",") );	// container<int>を全て表示

using namespace std;

typedef long long ll;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);


map<ll, ll> prime_factor2(ll N)
{
	map<ll, ll> ret;

	for (ll i = 2; i * i <= N; ++i ) {
		while ( N % i == 0 ) {
			ret[i]++;
			N /= i;
		}
	}

	if (N != 1) ret[N]++;
	return ret;
}

int main()
{
	ll sx, sy;
	ll tx, ty;
	string ans = "";

	cin >> sx >> sy >> tx >> ty;

	// to (tx, ty)
	Rep(i, ty - sy) ans.push_back('U');
	Rep(i, tx - sx) ans.push_back('R');
	// to (sx, sy)
	Rep(i, ty - sy) ans.push_back('D');
	Rep(i, tx - sx) ans.push_back('L');

	// to (tx, ty)
	ans.push_back('L');
	Rep(i, ty - sy) ans.push_back('U');
	ans.push_back('U');
	Rep(i, tx - sx) ans.push_back('R');
	ans.push_back('R');
	ans.push_back('D');
	// to (sx, sy)
	ans.push_back('R');
	Rep(i, ty - sy) ans.push_back('D');
	ans.push_back('D');
	Rep(i, tx - sx) ans.push_back('L');
	ans.push_back('L');
	ans.push_back('U');

	cout << ans << endl;

	return 0;
}


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

using namespace std;
int main() {
    int Sum = 0, N;
    cin >> N;
    vector<int>L(N);
    for(int i = 0; i < N; i++) {   
        cin >> L[i];
    }

    sort(L.begin(), L.end());
    
    for(int i = 0; i < N-1; i++){
        Sum += L[i];
    }

    if (L[N-1] >= Sum) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N, K, L = map(int, input().split())
pq = [map(int, input().split()) for _ in range(K)]
rs = [map(int, input().split()) for _ in range(L)]

class UnionFind:
    def __init__(self, N):
        self.par = [None] * (N+1)
        self.rank = [None] * (N+1)
        for n in range(N+1):
            self.par[n] = n
            self.rank[n] = 1

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            if self.rank[rx] > self.rank[ry]:
                self.par[ry] = rx
            else:
                self.par[rx] = ry
                if self.rank[rx] == self.rank[ry]:
                    self.rank[ry] += 1

    def is_same(self, x, y):
        return self.root(x) == self.root(y)

uf_road = UnionFind(N)
uf_train = UnionFind(N)

for p, q in pq:
    uf_road.unite(p, q)
for r, s in rs:
    uf_train.unite(r, s)

from collections import Counter
c = Counter()
for i in range(1, N+1):
    k = (uf_road.root(i), uf_train.root(i))
    c[k] += 1

ret = []
for i in range(1, N+1):
    k = (uf_road.root(i), uf_train.root(i))
    ret.append(c[k])

print(" ".join(str(v) for v in ret))


Measured memory_bytes: 126028
#include <iostream>
using namespace std;
int main(void){
    int a=0;
    string s;
    while(cin >> s){
        if(a!=0){
            cout << " ";
        }
        a++;
        for(int i=0;i<s.size();i++){
            char c=s[i];
            if('A'<= c && c <= 'Z'){
                c=c+ 32;
            }
            else if('a'<= c && c <= 'z'){
                c=c- 32;
            }
            cout << c;
        }
        
    }
    cout << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {
    return sum(r-1) - sum(l-1);
  }
};



int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll num = n*(n+1)/2;
    ll half = (num+1)/2;
    ll l = 0;
    ll r = INF;
    
    while (r-l>1) {
        ll x = (l+r)/2;
        vector<ll> v(n);
        
        rep(i, n) {
            if (a[i]>=x) v[i] = 1LL;
            else v[i] = -1LL;
        }
        
        vector<ll> s(n+1);
        rep(i, n) s[i+1] = s[i] + v[i];
        BIT<ll> bit(2*n+3);
        ll res = 0;
        //debug(res);
        rep(i, n+1) {
            res += bit.sum(s[i]+n);
            bit.add(s[i]+n);
        }
        //debug(res);
        if (res>=half) l = x;
        else r = x;
        //debug(l);
        //debug(r);
    }
    int ans = l;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7148
#include<iostream>
using namespace std;
#define ll long long int
#define mod 1000000007
ll maxPoints(int n) {
	int a, b, c;

	ll prevA, prevB, prevC, nextA, nextB, nextC;
	cin >> a >> b >> c;
	prevA = a, prevB = b, prevC = c;

	for (int i = 2; i <= n; i++) {
		cin >> a >> b >> c;
		nextA = a + max(prevB, prevC);
		nextB = b + max(prevA, prevC);
		nextC = c + max(prevA, prevB);
		prevA = nextA;
		prevB = nextB;
		prevC = nextC;
	}
	return max(prevA, max(prevB, prevC));
}


int main() {
	int n;
	cin >> n;
	cout << maxPoints(n) << endl;

}

Measured memory_bytes: 3108
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m1,m2,d1,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;
    if(m2>m1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;        
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,f=0,i,j;
  char s[110][20];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s[i]);
    for(j=0;j<i;j++){//printf("%d %d %d\n",i,j,f);
      if(strcmp(s[i],s[j])==0)f=2;
    }
  }
  for(i=1;i<n;i++){
    if(s[i-1][strlen(s[i-1])-1]-s[i][0])f=1;
  }//printf("%d\n",f);
  printf("%s\n",f?"No":"Yes");
  return 0;
}


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

int main() {
  int a;
  cin>>a;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
 sort(vec.begin(),vec.end());
 long long int count=0;
  
  for(int i=0;i<a-2;i++){
    for(int j=i+1;j<a-1;j++){
      for(int k=j+1;k<a;k++){
        if(vec.at(i)+vec.at(j)>vec.at(k)){
          count++;
        }
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
# 黒板に, 3 つの正の整数 A,B,C が書かれています.
# E869120 君は, 以下の操作を K 回行います.
# 黒板に書かれている整数のうち 1 つを選び, これを 2 倍した値に書き換える.
# さて, K 回の操作を終えた後の,
# 黒板に書かれる整数の合計としてありうる最大の値はいくつでしょうか？

input = gets.chomp.split
a = input[0].to_i
b = input[1].to_i
c = input[2].to_i
integers = [a, b, c]

k = gets.to_i

index = integers.index(integers.max)

k.times do
  integers[index] *= 2
end

sum = 0
integers.each do |i|
  sum += i
end

puts sum


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<assert.h>

using namespace std;
#define repeat(i,n) for(int i=0;i<(n);i++)

int main(){

  int n, l; cin>> n>> l;
  vector<string> s(n);
  repeat(i, n) cin>> s[i];

  map<string, int> mp;
  for(auto t: s){
    mp[t]++;
  }

  sort(s.begin(), s.end());

  string ans="";
  for(auto t: s)if(mp[t]){
    string u=t;
    reverse(u.begin(), u.end());
    if(u==t){
      if(mp[t]>=2){mp[t]-=2; ans+=t;}
    }else{
      if(mp[u]>=1){mp[t]-=1; mp[u]-=1; ans+=t;}
    }
  }

  string A=ans;
  for(auto e: mp)if(e.second){
    string t=e.first;
    reverse(t.begin(), t.end());
    if(t==e.first){
      A+=t;
      break;
    }
  }

  reverse(ans.begin(), ans.end());
  cout<< A+ans<< endl;

  return 0;
}

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

using ll = long long;
using ld = long double;

int main()
{
    int n,m,sum=0;
    cin >> n;
    vector<int> t(n);
    
    for(int i = 0; i < n; i++)
    {
        cin >> t.at(i);
        sum+=t.at(i);
    }
    cin>>m;
    
    for(int i = 0; i < m; i++)
    {
        int p,x;
        cin >> p>> x;
        cout << sum-t.at(p-1)+x<<endl;
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

bool Isprime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {

    // greenbin 解答中
    
   int n;
   cin>>n;
   vector<string> vec(n);

   for(int i=0;i<n;i++){
       string s;

       cin>>s;

       sort(s.begin(),s.end());
       vec[i]=s;

   }

   sort(vec.begin(),vec.end());
  
  bool x=false;
  vector<ll> conti(0,0);  
           //　連続した回数の配列
  for(int i=0;i<n-1;i++){

   if(vec[i]==vec[i+1]){
     
       if(x){
         conti.back()++;
     }
       else{
         conti.emplace_back(1);

         x=true;
     }
     
   }

   else{
        x=false;
     }
  }

  ll ans=0;

  for(int i=0;i<conti.size();i++){

    ans+=conti[i]*(conti[i]+1)/2;

  }

  cout<<ans<<endl;

}
 


Measured memory_bytes: 6648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001



int main() {
    ll N; cin >> N;
    if(N%2==0) cout << N << endl;
    else cout << 2 * N << endl;
    
    return 0;
    
}





Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  if(S=="Sunny") cout<<"Cloudy"<<endl;
  else if(S=="Cloudy") cout<<"Rainy"<<endl;
  else cout<<"Sunny"<<endl;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    ll k;
    cin >> n >> k;

    vector<ll> v(n+1);
    REP(i, n){
        ll a;
        cin >> a;
        v[i+1] = (v[i] + a) % k;
    }

    map<ll,vector<int>> mp;
    ll ans = 0;
    
    REP(i, n+1){
        ll a = (v[i] - i%k + k) % k;
        debug(a);
        if(!mp[a].empty()){
            ans += std::distance(lower_bound(all(mp[a]), i - max(0LL,k-1)), mp[a].end());
        }
        mp[a].push_back(i);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
   char a[102],b[102];
   int i;
  scanf("%s %s",a,b);
  if (strlen(a) > strlen(b)) {
    printf("GREATER\n");
  }else if (strlen(b) > strlen(a)) {
    printf("LESS\n");
  }else{
    for (i = 0; i < strlen(a); i++) {
      if (a[i] > b[i]) {
        printf("GREATER\n");
        return 0;
      }else if (a[i] < b[i]) {
        printf("LESS\n");
        return 0;
      }
    }
    printf("EQUAL\n");
  }

  return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

namespace d
{
    class Program
    {
        static void Main(string[] args){
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            if(A.Count(x => x < 0) % 2 == 0){
                Console.WriteLine(A.Sum(x => Math.Abs(x)));
            }else{
                Console.WriteLine(A.Sum(x => Math.Abs(x)) - 2 * A.Min(x => Math.Abs(x)));
            }
        }
    }
}


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


int main()
{
	int n, k, c;
	string s;
	cin >> n >> k >> c >> s;

	vector<int> front;
	vector<int> end;

	int pos_f = 0;
	while (true) {
		if (s[pos_f] == 'x') {
			pos_f++;
		} else {
			front.push_back(pos_f);
			pos_f += c + 1;
		}
		if (front.size() == k) {
			break;
		}
	}

	int pos_e = n - 1;
	while (true) {
		if (s[pos_e] == 'x') {
			pos_e--;
		} else {
			end.push_back(pos_e);
			pos_e -= c + 1;
		}
		if (end.size() == k) {
			break;
		}
	}
	reverse(end.begin(), end.end());

	for (int i = 0; i < k; i++) {
		if (front.at(i) == end.at(i)) {
			cout << front.at(i) + 1 << endl;
		}
	}

}



Measured memory_bytes: 3448
a = int(input())
b,c = map(int,input().split())
lis = input().split()

li = [int(l) for l in lis]

judge = True

d = 0

li.sort()

while judge:
    if li == []:
        break
    
    s = []
    for n in li:
        if n <= b:
            s.append(n)
            li.remove(n)
            break
        else:judge = False

    for n in li:
        if n >= b+1 and n<=c:
            s.append(n)
            li.remove(n)
            break
        else:judge = False

    for n in li:
        if n>=c+1:
            s.append(n)
            li.remove(n)
            break
        else:
            judge= False

    if len(s) == 3:
        d+=1
        judge = True
    else:judge=False

print(d)

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }
	map<int, int>mp;
	for (auto a : A)mp[a]++;
	sort(all(A));
	int M = A.back();
	vector<int>f(M + 1);
	int ans = 0;
	for (auto a : A) {
		ans += not f[a] and mp[a] == 1;
		for (int i = a; i < M + 1; i += a) {
			f[i] = 1;
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int H, W;
string S[55];
int ans[55][55];

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

void solve() {
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if ('#' == S[y][x]) continue;
            int cnt = 0;
            for (int i = 0; i < 8; i++) {
                int ny = y + dy[i];
                int nx = x + dx[i];
                if (ny < 0 || ny >= H) continue;
                if (nx < 0 || nx >= W) continue;
                if ('#' == S[ny][nx]) cnt++;
            }
            ans[y][x] = cnt;
        }
    }
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            if ('.' == S[y][x]) {
                cout << ans[y][x];
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <vector>
 
#define ll long long
#define ull unsigned long long
#define ld long double
 
#define gc (c = getchar())
#define gi(x) scanf("%d", &x)
#define gid(x, y) scanf("%d%d", &x, &y)
#define gll(x) scanf("%lld", &x)
#define glld(x, y) scanf("%lld%lld", &x, &y)
#define gllt(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define git(x, y, z) scanf("%d%d%d", &x, &y, &z)
 
#define pi(x) printf("%d\n", x)
#define pid(x, y) printf("%d %d\n", x, y)
#define pcs(ch, cs, x) printf("Case %s%d: %d\n", ch, cs, x)
#define pll(x) printf("%lld\n", x)
#define pllcs(ch, cs, x) printf("Case %s%d: %lld\n", ch, cs, x)
#define plld(x, y) printf("%lld %lld\n", x, y)
#define pllt(x, y, z) printf("%lld %lld %lld\n", x, y, z)
 
#define mp(x, y) std::make_pair(x, y)
#define fcs(x) while (x--)
#define dbg(x) std::cerr << #x << " " << x << std::endl
#define fi freopen("in.txt", "r", stdin)
#define fo freopen("out.txt", "w", stdout)
#define siz(x) (int)x.size()
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#pragma GCC optimize(2)

const int maxn = 3e5 + 5;
long long seq[maxn];
const long long mod = 1e9 + 7;
long long bin(long long x, long long n){
    long long ret = 1;
    while(n){
        if (n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}
int main(){
    int n;
    gi(n);
    long long tn;
    for(int i = 1; i <= n; i ++) gll(seq[i]);
    long long ret = 0;
    for(int i = 0; i < 60; ++ i){
        //long long tret = 0;
        long long cnt = 0;
        for(int j = 1; j <= n; ++ j){
            if ((seq[j] >> i) & 1){
                cnt ++;
            }
        }
        ret = (ret + bin(2,i) * (cnt) % mod * (n - cnt) % mod) % mod;
    }
    pll(ret);
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

int main (void) {
    while (1) {
        vector<int> a(4), b(4);
        for (int i = 0; i < 4; i++) {
            cin >> a[i];
        }
        for (int i = 0; i < 4; i++) {
            cin >> b[i];
        }
        if (cin.eof()) break;
        int hi = 0, bl = 0;
        for (int i = 0; i < 4; i++) {
            if (a[i] == b[i]) {
                hi++;
            } else {
                for (int j = 0; j < 4; j++) {
                    if (b[i] == a[j]) {
                        bl++;
                        break;
                    }
                }
            }
        }
        cout << hi << ' ' << bl << endl;
    }
    return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	int a_i = n;
	int z_i = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A' && i < a_i) a_i = i;
		if (s[n - 1 - i] == 'Z' && n - 1 - i > z_i) z_i = n - 1 - i;
		if (a_i < n && z_i>0) break;
	}
	cout << z_i - a_i + 1;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    if(s == "RSR"){
        cout << 1 << endl;
        return 0;
    }
    rep(i, 3){
        if(s[i] == 'R') cnt++;
    }
    cout << cnt << endl;
    return 0; 
}

Measured memory_bytes: 3612
#include<stdio.h>
int SOSU[10000001];
main(){
  int i,j,a;
  for(i=2;i<=5000000;i++){
    if(SOSU[i]==0){
      for(j=2;i*j<=10000000;j++)SOSU[i*j]++;
    }
  }
 loop:
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    for(;;a--){
      if(SOSU[a]==0&&SOSU[a-2]==0&&SOSU[a-6]==0&&SOSU[a-8]==0){
	printf("%d\n",a);
	goto loop;
      }
    }
  }
  return 0;
}

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

using ll = long long;

int const nmax = 200000;
std::set<int> line[1 + nmax];

int block(int x, int y) {
  return line[y].find(x) != line[y].end();
}

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

  int n, m, q;
  std::cin >> n >> m >> q;
  for(int i = 1;i <= m; i++)
    line[i].insert(n + 1);
  for(int i = 1;i <= q; i++) {
    int x, y;
    std::cin >> x >> y;
    line[y].insert(x);
  }
  int x = 1, y = 1;
  int result = n, step = 0;

  while(true) {
    result = std::min(result, step + *line[y].lower_bound(x) - x);
    if(1 == block(x + 1, y))
      break;
    else {
      x++;
      if(y < m && block(x, y + 1) == 0)
        y++;
    }
    step++;
  }
  std::cout << result;
}


Measured memory_bytes: 31720