akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n+1];
		for(int i=1;i<=n;i++) {
			a[i] = sc.nextInt();
		}
		
		int idx = 1;
		int[][] arr = new int[w][h];
		for(int i=0;i<w;i++) {
			if(i%2==0) {
				for(int j=0;j<h;j++) {
					arr[i][j] = idx;
					a[idx]--;
					if(a[idx]==0)
						idx++;
				}
			}
			else {
				for(int j=h-1;j>=0;j--) {
					arr[i][j] = idx;
					a[idx]--;
					if(a[idx]==0)
						idx++;
				}
			}
		}
		
		for(int i=0;i<w;i++) {
			for(int j=0;j<h;j++) {
				System.out.print(j==0 ? arr[i][j] : " "+arr[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 32832
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
xy = [[LI() for _ in range(I())] for _ in range(N)]
ans = 0
for i in range(2**N):
    bit = [i>>j&1 for j in range(N)]
    if ans >= sum(bit):
        continue
    for j,a in enumerate(xy):
        if bit[j]==1:
            for x,y in a:
                if bit[x-1]!=y:
                    break
            else:
                continue
            break
    else:
        ans = max(ans,sum(bit))
print(ans)


Measured memory_bytes: 3064
a, b = map(int, input().split())
c, d = map(int, input().split())
e, f = map(int, input().split())

A = [a, b, c, d, e, f]
count= 0
for i in range(0, 5):
    ind = A.count(i)
    if(ind == 2):
        count+=1
if(count == 2):
    print("YES")
else:
    print("NO")

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }

    int hp, sum, ans;
    ans = 100 * 100 * 100;
    for (int i = 1; i <= 100; i++) {
        sum = 0;
        for (int p : x) {
            hp = (p - i) * (p - i);
            sum += hp;
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,i;
int main()
{
   cin>>a>>b>>c;
    for(i=1;i<=b;i++)
      if((a*i)%b==c)
       {
         cout<<"YES"<<endl;
         return 0;
       }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int x,a,b;cin>>x>>a>>b;
    string ans = b <= a ? "delicious" : b-a <= x ? "safe" : "dangerous";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;

signed main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
/* 拡張ダイクストラ */
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ll tmp = 100;
    while(1) {
        ans++;
        tmp = (double)tmp * 1.01;
        if(tmp >= x) break;
    }

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

Measured memory_bytes: 3632
N = int(input())
import numpy as np
A = np.array([[int(x) for x in input().split()],[int(x) for x in input().split()]], dtype='int64')
A = A.cumsum(axis=1)
Ans = [A[0,i]+A[1,N-1]-A[1,i-1] if i > 0 else A[0,i]+A[1,N-1] for i in range(N)]
print(max(Ans))

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

int main(){
    int N,a[100000];
    cin >> N;
    for(int i=0; i<N; i++)
    cin >> a[i];

    int n=a[0];
    for(int i=1; i<N; i++){
        if(n<a[i])
        n=a[i];
    }

    int r=a[0];
    if(r==n) r=a[1];
    for(int i=1; i<N; i++){
        if(a[i]==n) continue;
        int now=n/2-r,j=n/2-a[i];
        if(now<0) now*=-1;
        if(j<0) j*=-1;
        if(now>j) r=a[i];
    }

    cout << n << " " << r << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

ll dp[550][550];

int main() {
  ll n,m,q; cin >> n >> m >> q;
  FOR(i,0,m-1){
    int l,r; cin >> l >> r;
    ++dp[l][r];
  }
  FOR(i,1,n){
    FOR(j,2,n){
      dp[i][j] += dp[i][j-1];
    }
  }

  

  FOR(i,0,q-1){
    ll ans = 0;
    int P,Q; cin >> P >> Q;
    FOR(j,P,Q){
      ans += dp[j][Q] - dp[j][P-1];
    }
    cout << ans << endl;
  }

  

}



Measured memory_bytes: 3072
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Heap heap = new Heap();

        while (true){
            String action = in.next();
            int num = 0;
            if(action.equals("insert")){
                num = in.nextInt();
            }


            if(action.equals("insert")){
                heap.insert(num);
            } else if(action.equals("extract")){
                int popped = heap.extractMax();
                System.out.println(popped);
            } else{
                break;
            }
        }
    }
}

class Heap {
    private int [] heap;
    private int size;
    public Heap(){
        heap = new int[2000001];
        size = 0;
    }

    private int parent(int pos){
        if(pos == 1){
            return 1;
        }
        return pos/2;
    }

    private int leftChild(int pos){
            return (pos * 2);
    }

    private int rightChild(int pos){
        return (pos * 2)+1;
    }

    private boolean isLeaf(int pos) {
        if (pos>1 && pos >= (size / 2) && pos <= size) {
            return true;
        }
        return false;
    }
    //ta funcionando
    private void swap(int fpos, int spos){
        int tmp;
        tmp = this.heap[fpos];
        this.heap[fpos] = this.heap[spos];
        this.heap[spos] = tmp;

    }

    private void maxHeapify(int pos){
        if (isLeaf(pos)) {
            return;
        }
        if(heap[pos] < heap[leftChild(pos)] || heap[pos] < heap[rightChild(pos)]){
            if (heap[leftChild(pos)] > heap[rightChild(pos)]) {
                swap(pos, leftChild(pos));
                maxHeapify(leftChild(pos));
            }
            else {
                swap(pos, rightChild(pos));
                maxHeapify(rightChild(pos));
            }
        }
    }

    public void insert(int k){

        heap[size+1] = k;
        size++;

        int current = size;


        while (current>1 && heap[current]>heap[parent(current)]){
            swap(current, parent(current));
            current = parent(current);
        }


    }

    public int extractMax(){
        int popped = heap[1];
        heap[1] = heap[size];
        heap[size] = 0;
        size--;
        for (int i = 1; i <= size / 2; ) {
            if (heap[i * 2] > heap[(i * 2) + 1]) {
                if (heap[i] < heap[i * 2]) {
                    int aux3;
                    aux3 = heap[i];
                    heap[i] = heap[i * 2];
                    heap[i * 2] = aux3;
                    i = i * 2;
                } else {
                    break;
                }
            } else {
                if (heap[i] < heap[(i * 2) + 1]) {
                    int aux4;
                    aux4 = heap[i];
                    heap[i] = heap[(i * 2) + 1];
                    heap[(i * 2) + 1] = aux4;
                    i = (i * 2) + 1;
                } else {
                    break;
                }
            }
        }

        //maxHeapify(1);
        return popped;
    }
}


Measured memory_bytes: 557008
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

def lowlink(g, root=0):
    n = len(g)
    order = [n]*n
    low = [n]*n

    s = [root]
    cnt = 1
    par = [-1]*n
    seq = []
    while s:
        v = s.pop()
        if order[v] != n:
            continue
        order[v] = cnt
        seq.append(v)
        low[v] = cnt
        cnt += 1
        for u in g[v]:
            if order[u] < cnt:
                if par[v] != u:
                    low[v] = min(low[v], order[u])
                    continue
            else:
                par[u] = v
                s.append(u)
    child = [[] for _ in range(n)]
    for v in range(n):
        if par[v] != -1:
            child[par[v]].append(v)
    seq.reverse()
    for v in seq:
        for u in child[v]:
            low[v] = min(low[v], low[u])
    # bridge
    bridge = []
    for p in range(n):
        for c in child[p]:
            if order[p] < low[c]:
                bridge.append((p, c))

    # articulation points
    AP = []
    for v in range(n):
        if v == root:
            if len(child[v]) >= 2:
                AP.append(v)
        else:
            for c in child[v]:
                if order[v] <= low[c]:
                    AP.append(v)
                    break
    return AP, bridge

_, bridge = lowlink(g, 0)
print(len(bridge))

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

using std::sort;

const int N=1e5+10,Mod=1e9+7;

int n,k,que[N],dp[N];

void Init() {
	scanf("%d%d",&n,&k);
}

int pow(int x,int t) {
	int ret=1;
	while (t) {
		if (t&1) ret=1ll*ret*x%Mod;
		x=1ll*x*x%Mod;
		t=t>>1;
	}
	return ret;
}

void Solve() {
	int top=0;
	for (int i=1;i*i<=n;++i) {
		if (n%i) continue;
		que[++top]=i;
		if (i*i==n) continue;
		que[++top]=n/i;
	}
	sort(que+1,que+top+1);
	
	int ans=0;
	for (int i=1;i<=top;++i) {
		dp[i]=pow(k,(que[i]+1)>>1);
		for (int j=1;j<i;++j) if (que[i]%que[j]==0) {
			dp[i]=(dp[i]-dp[j]+Mod)%Mod;
		}
		if (que[i]&1) ans=(ans+1ll*dp[i]*que[i]%Mod)%Mod;
		else ans=(ans+1ll*dp[i]*que[i]/2%Mod)%Mod;
	}
	
	printf("%d\n",ans);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, M = map(int, readline().split())

WA = [0] * (N + 1)
wa = 0
AC = [False] * (N + 1)
for _ in range(M):
    p, S = readline().split()
    p = int(p)
    if AC[p]:
        continue

    if S == 'AC':
        AC[p] = True
        wa += WA[p]
    else:
        WA[p] += 1

print(sum(AC), wa)


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

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

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define maxn 1000000
#define int long long
#define mod 1000000007
int n, ans; char s1[maxn], s2[maxn];

signed main()
{
	cin >> n; scanf("%s%s", s1 + 1, s2 + 1);
	for(int i = 1; i <= n; i ++)
	{
		if(s1[i] == s2[i]) 
		{ 
			if(i != 1)  { if(s1[i - 1] == s2[i - 1]) ans = ans * 2 % mod; }
			else ans = 3;
			continue; 
		}
		if(i == 1) ans = 6;
		else if(s1[i - 1] == s2[i - 1]) ans = ans * 2 % mod;
		else ans = ans * 3 % mod; i ++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

int main(){
  li k; cin >>k;
  li n=50;
  li q=k/n,r=k%n;
  print(n);
  vector<li> v(n,k/n+n-1-r);
  rep(i,r){
    v[i]+=n+1;
  }
  print(v);
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 300000;

int n, cnt = 0, son[N][2]; ll l; 
string s;

ll dfs( int u, int dep ) 
{
	ll x = l - dep + 1;
	if( !u && dep ) return x & -x;
	return dfs( son[u][0], dep+1 ) ^ dfs( son[u][1], dep+1 );
}

int main()
{
	scanf( "%d%lld", &n, &l );
	
	for( int i = 1; i <= n; i ++ )
	{
		cin>> s;
		int u = 0, len = s.size();
		
		for( int j = 0; j < len; j ++ )
		{
			int w = s[j] - '0';
			if( !son[u][w] ) 
				son[u][w] = ++ cnt;
			u = son[u][w];
		}
	}
	
	if( dfs( 0, 0 ) ) puts( "Alice" ); 
	else puts( "Bob" );
	
	return 0;
}

Measured memory_bytes: 4352
N = int(input())
H = [int(i) for i in input().split()]

now = H[0]
ans = 0
m = 0

for h in H[1:]:
  if h <= now:
    ans += 1
    now = h
  else:
    m = max(m, ans)
    ans, now  = 0, h
    
m = max(m, ans)
print(m)

Measured memory_bytes: 63984
#pragma region Macros
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define IN(x, a, b) x >= a and x < b

using namespace std;
using ll = long long;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> constexpr T INF = numeric_limits<T>::max() / 2;
#pragma endregion

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

  int n;
  cin >> n;
  REP(_, n) {
    string a, b;
    cin >> a >> b;
    vector<vector<int>> dp(a.size() + 1, vector<int>(b.size() + 1, 0));
    REP(i, a.size()) {
      REP(j, b.size()) {
        if (a[i] == b[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        }
        chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        chmax(dp[i + 1][j + 1], dp[i + 1][j]);
      }
    }
    cout << dp[a.size()][b.size()] << endl;
  }

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int count = 0;
  int button = 0;
  while(count<N){
    if(button == 1){
      cout << count << endl;
      break;
    }
    button = vec.at(button) - 1;
    count++;
  }
  
  if(button != 1){
    cout << -1 << endl;
  }
  
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,ll int> data;
    rep(i,n){
        cin>>a.at(i);
        data[a.at(i)]++;
    }
    ll int sum=0;
    for(auto p:data){
        sum+=p.second*(p.second-1)/2;
    }
    rep(i,n){
        cout<<sum-data.at(a.at(i))+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n;
	cin>>n;
	vector<int>X(n);
	unordered_set<int>S;
	for(int i=0;i<n;i++)
	{
		cin>>X[i];
		S.insert(X[i]);
	}
if(X.size()==S.size())
{
	cout<<"YES";
}
else
{
	cout<<"NO";
}
	
}

Measured memory_bytes: 9288
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());
  
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }

  vector<int> B(N);
  B=A;
  
  sort(B.begin(),B.end());
  int max1=B.back();
  //cout<<max1<<endl;
  B.pop_back();
  int max2=B.back();
  //cout<<max2<<endl;


  for(int i=0;i<N;i++){
    if(A.at(i)!=max1){
      cout<<max1<<endl;
    }else{
      cout<<max2<<endl;
    }
  }

}

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

using namespace std;
typedef long long ll;
const int MAXN=1e5+10,MOD=1e9+7;
int n,k,dvs[MAXN],dp[MAXN],tot,res=0;

ll quick_pow(ll a,ll b)
{
	ll ret=1;
	for(;b;b>>=1,a=a*a%MOD)
		if(b&1) ret=ret*a%MOD;
	return ret;
}

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i*i<=n;i++)
		if(n%i==0)
		{
			dvs[++tot]=i;
			if(i*i!=n) dvs[++tot]=n/i;
		}
	sort(dvs+1,dvs+tot+1);
	for(int i=1;i<=tot;i++)
	{
		dp[i]=quick_pow(k,(dvs[i]+1)/2);
		for(int j=1;j<=i-1;j++)
			if(dvs[i]%dvs[j]==0) dp[i]=(dp[i]-dp[j]+MOD)%MOD;
		if(dvs[i]%2==0) (res+=1ll*dp[i]*dvs[i]/2%MOD)%=MOD;
		else (res+=1ll*dp[i]*dvs[i]%MOD)%=MOD;
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    cout << x2 - ( y2 - y1 ) << " " << y2 + ( x2 - x1 ) << " " << x1 - ( y2 - y1 ) << " " << y1 + ( x2 - x1 ) << endl;
    return 0;
}

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

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

    ll n, W, weight, value; cin>>n>>W;
    vector<ll> dp(W+1);//dp[i] = max value with weight i
    dp[0] = 0;
    loop(n){
        cin>>weight>>value;
        for(ll from = W-weight; from>=0; from--){
            dp[from+weight] = max(dp[from+weight], dp[from]+value);
        }
    }
    
    ll ans = 0;
    loop(W+1) ans = max(ans, dp[i]);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  while(cin>>n,n) {
    vector<int> v(n);
    REP(i,n)
      cin >> v[i];
    v.erase(max_element(ALL(v)));
    v.erase(min_element(ALL(v)));
    int sum = 0;
    FOR(i,v) {
      sum+=*i;
    }
    cout << sum/v.size() << endl;
  }
}

Measured memory_bytes: 0
s = gets.chomp
x, y = gets.split.map(&:to_i)

a = []
successive_f = 0
s.chars.each do |c|
  if c == 'T'
    a << successive_f
    successive_f = 0
  else
    successive_f += 1
  end
end
a << successive_f

x -= a[0]
x_moves = a[1..-1].select.with_index {|_, i| i.odd?}
y_moves = a[1..-1].select.with_index {|_, i| i.even?}

max_s = 8000
def finish_at?(x, x_moves)
  h = Hash.new {|h, k| h[k] = false}
  h[0] = true
  x_moves.each do |x_move|
    hh = Hash.new {|hh, k| hh[k] = false}
    h.each_key do |k|
      hh[k+x_move] = true
      hh[k-x_move] = true
    end
    h = hh
  end
  h[x]
end

puts finish_at?(x, x_moves) && finish_at?(y, y_moves) ? 'Yes' : 'No'

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

int g[30][30];

int main(){
  int n;
  while(cin >> n, n){
    vector<string> s(n);
    for(int i=0;i<n;i++)cin >> s[i];

    for(int i=0;i<26;i++){
      for(int j=0;j<26;j++){
	  g[i][j] = 1e9;
      }
      g[i][i] = 0;
    }

    bool f = true;
    for(int i=1;i<n;i++){
      int len = min(s[i-1].size(), s[i].size()), j;
      for(j=0;j<len;j++){
	if(s[i-1][j]!=s[i][j])break;
      }

      if(j==len){
	if(s[i-1].size() > s[i].size()){
	  f = false;
	}
      }else{
	g[s[i-1][j]-'a'][s[i][j]-'a'] = -1;
      }
    }

    for(int k=0;k<26;k++){
      for(int i=0;i<26;i++){
	for(int j=0;j<26;j++){
	  g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	}
      }
    }

    for(int i=0;i<26;i++){
      if(g[i][i] < 0) f = false;
    }

    cout << (f?"yes":"no") << endl;
  }   
}

Measured memory_bytes: 1244
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    long long int r[100001]={0};
    long long int sum=0;
    for(int i=0;i<n;i++)
       {
        cin>>a[i];
        r[a[i]]++;
        sum+=a[i];
       }
    int q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
            int b,c;
            cin>>b>>c;
            sum-=(long long int)(b*r[b]);
            sum+=(long long int)(r[b]*c);
            r[c]+=r[b];
            r[b]=0;
            cout<<sum<<"\n";
    }
}



Measured memory_bytes: 4780
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <vector>

int main() {
  std::int_fast64_t n, x;
  std::cin >> n >> x;
  std::vector<std::int_fast64_t> a(n);
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::cin >> a[i];
  }

  std::int_fast64_t result = 0;
  for (std::int_fast64_t i = 1; i < n; ++i) {
    const std::int_fast64_t right = std::max(static_cast<std::int_fast64_t>(0), std::min(a[i - 1] + a[i] - x, a[i]));
    a[i] -= right;
    const std::int_fast64_t left = std::max(static_cast<std::int_fast64_t>(0), std::min(a[i - 1] + a[i] - x, a[i - 1]));
    a[i - 1] -= left;
    result += left + right;
  }
  std::cout << result << std::endl;
  return 0;
}

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

int digit(ll n)
{
  int count=0;
  while (n>0)
  {
    n/=10;
    count++;
  }
  return (count);
}

int main()
{
  ll n;cin>>n;
  ll count=0;
  
  for (int i=1;i<=n;i++)
  {
    if (digit(i)%2==1)
      count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val (n, x) = readInputLine().split(" ").map { it.toInt() }
    
    val cities = readInputLine().split(" ").map { Math.abs(x - it.toInt()) }

    var gcdNum = cities[0]
    
    for (i in 1 until n) {
        gcdNum = 
            if (gcdNum > cities[i]) {
                gcd(gcdNum, cities[i])
            } else {
                gcd(cities[i], gcdNum)
            }
    }
    
    println(gcdNum)
}
 
fun readInputLine(): String {
    return readLine()!!
}

fun gcd(a: Int, b: Int): Int {
    // a >= b とする
    if (b == 0) {
        return a
    }
    return gcd(b, a % b)
}


Measured memory_bytes: 49652
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left

def main():
	A, B, Q = map(int, input().split(" "))
	S = []
	S.append(-100000000000)
	for _ in range(A):
		tmp = int(input())
		S.append(tmp)
	S.append(100000000000)
	
	T = []
	T.append(-100000000000)
	for _ in range(B):
		tmp = int(input())
		T.append(tmp)
	T.append(100000000000)
	
	X = []
	for _ in range(Q):
		tmp = int(input())
		X.append(tmp)
		
	#print(T)
	for i, val in enumerate(X):
		tmp = [[-1 for _ in range(2)] for _ in range(2)]
		tmp[0][0] = bisect_left(S, val)
		tmp[0][1] = tmp[0][0] - 1
		tmp[1][0] = bisect_left(T, val)
		tmp[1][1] = tmp[1][0] - 1
		
		ptn1 = abs(val - S[tmp[0][0]]) + abs(S[tmp[0][0]] - T[tmp[1][0]])
		ptn2 = abs(val - S[tmp[0][0]]) + abs(S[tmp[0][0]] - T[tmp[1][1]])
		ptn3 = abs(val - S[tmp[0][1]]) + abs(S[tmp[0][1]] - T[tmp[1][0]])
		ptn4 = abs(val - S[tmp[0][1]]) + abs(S[tmp[0][1]] - T[tmp[1][1]])
		
		ptn5 = abs(val - T[tmp[1][0]]) + abs(T[tmp[1][0]] - S[tmp[0][0]])
		ptn6 = abs(val - T[tmp[1][0]]) + abs(T[tmp[1][0]] - S[tmp[0][1]])
		ptn7 = abs(val - T[tmp[1][1]]) + abs(T[tmp[1][1]] - S[tmp[0][0]])
		ptn8 = abs(val - T[tmp[1][1]]) + abs(T[tmp[1][1]] - S[tmp[0][1]])
		
		print(min(ptn1,ptn2,ptn3,ptn4,ptn5,ptn6,ptn7,ptn8))
	
	
if __name__ == "__main__":
	main()


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

#define rep(i,n) for(int i;i<(int)(n);i++)
#define Rep(i,n) for(int i;i<=(int)(n);i++)
#define all(v) v.begin,v.end
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MX = 1000005;

int main(){
    int n,x,t;
    cin>>n>>x>>t;
    if(n%x==0) cout<<t*(n/x)<<endl;
    else cout<<t*(n/x+1)<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = n - 1;
	for(int i = 1; i * i <= n; i++){
		if(n % i == 0){
			ans = min(ans, i + n / i - 2);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
N=input()
L=list(map(int,input().split()))
L.sort()
C=list(itertools.combinations(L,3))
ans=0
for a in C:
    if a[0]==a[1] or a[0]==a[2] or a[1]==a[2]:
        continue
    else:
        # print(a)
        if (a[0]+a[1])>a[2]:
            ans+=1
print(ans)


Measured memory_bytes: 90432
from collections import deque

def queue(n, t):
    q = deque([])
    for i in range(n):
        process, time = input().split()
        time = int(time)
        q.append([process, time])

    finish = 0  # 終了時刻

    while len(q) > 0:
        top = q.popleft()  # 最も左側の要素を削除して返す
        s = min(top[1], t)  # クオンタムと先頭プロセスの残り時間の内，小さい方をsに代入
        top[1] -= s
        finish += s
        if top[1] == 0:
            print(top[0], finish)   # 終了プロセスと終了時刻を表示
        else:
            q.append(top)   # queueの後ろに追加

if "__main__" == __name__:
    n, t = map(int, input().split())
    queue(n, t)



Measured memory_bytes: 13272
#include<cstdio>
#include<iostream>
using namespace std;
int main(void)
{
    int l,r,mn=1e9;
    scanf("%d %d" ,&l,&r);
    if(l/2019!=r/2019)
    {
        printf("0");
        return 0;
    }
    for(int i=l;i<=r;i++)
        for(int j=i+1;j<=r;j++)
        {
            mn=min(mn,(i%2019)*(j%2019)%2019);
//            mn=min(mn, i*j%2019);
        }
    printf("%d" ,mn);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int a, b, c, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c >> d;
  cout << min(a, b)+min(c, d) << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
a = sorted([int(i) for i in input().split()])
ans = 0
if n > 1:
 for i in range(100005):
  tmp = bisect.bisect_right(a,i+2)-bisect.bisect_left(a,i)
  ans = max(ans,tmp)
else:
  ans = 1
print(ans)

Measured memory_bytes: 13964
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = INF;
    rep(i,1,sqrt(n)+1){
        if (n%i == 0){
            chmin(ans,i-1+n/i-1);
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m; cin>>n>>m;
    int q; cin>>q;
    int a[100010];
    for(int i=0; i<q; i++){
        cin>>a[i];
    }
    int ind[100010];
    fill(ind, ind+m+1, -1);
    int c=0;
    vector<int> v[100010];
    for(int i=q-1; i>=0; i--){
        if(ind[a[i]]==-1){
            ind[a[i]]=c;
            v[0].push_back(a[i]);
            c++;
        }else{
            int l=0, r=n;
            while(r-l>1){
                int mid=(l+r)/2;
                if(v[mid].size()<=ind[a[i]]) r=mid;
                else l=mid;
            }
            if(r<n && v[r].size()==ind[a[i]]){
                v[r].push_back(a[i]);
            }
        }
    }
    for(int i=1; i<=m; i++) if(ind[i]==-1) v[0].push_back(i);
    int mn=0;
    for(int i=m-1; i>=1; i--){
        if(v[0][i]<v[0][i-1]){
            mn=i; break;
        }
    }
    for(int i=0; i<n; i++){
        if(v[i].size()<mn){
            cout<<"No"<<endl; return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 7164
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
 
#define F first
#define S second
#define ll long long
#define pb push_back
#define db double
#define ld long double
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<long long, long long>
#define piii pair<int, pii>
#define all(x) (x).begin(),(x).end()
#define __ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define int long long
 
const int N = 1e5 + 1, inf = 2e9 + 7, mod = 1e9 + 7;
const ll INF = 2e18 + 7, MOD = 1e15 + 7;

int a[101];
int dp[101][N], pref[101][N];

int add(int a, int b) {
    return (a + b + mod + mod) % mod;
}

int sub(int a, int b) {
    return add(a, -b);
}

signed main() { __
//    freopen("lcm.in", "r", stdin);
//    freopen("lcm.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i <= a[1]; i++) dp[1][i] = 1;
    for (int i = 0; i <= k; i++) {
        if (i) pref[1][i] = pref[1][i - 1] + dp[1][i];
        else pref[1][i] = dp[1][i];
    }
    for (int i = 2; i <= n; i++) {
        for(int j = 0; j <= k; j++) {
            if(j - a[i] - 1 < 0) dp[i][j] = pref[i - 1][j];
            else dp[i][j] = sub(pref[i - 1][j], pref[i - 1][j - a[i] - 1]);
            if(j) pref[i][j] = add(pref[i][j - 1], dp[i][j]);
            else pref[i][j] = dp[i][j];
        }
    }
    cout<<dp[n][k];
    return 0;
}



Measured memory_bytes: 157312
#include <iostream>
using namespace std;
#define ll long long

int main()
{
	ll n, x, t, min_num;
	cin >> n >> x >> t;
	min_num = (n % x) ? (n / x) + 1 : n / x;
	cout << min_num * t << endl;
	return 0;
}


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

namespace ABC121_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var NMC = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NMC[0];
            var M = NMC[1];
            var C = NMC[2];

            var b = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var sum = 0;
                for (int j = 0; j < M; j++)
                {
                    sum += a[j] * b[j];
                }
                sum += C;
                if (sum > 0) ans++;
            }

            Console.WriteLine(ans);
        }
    }
}


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

vector<P>E[100];
int d[100][3];
struct st {
	int p, b, c;
};
bool operator<(st a, st b) { return a.c > b.c; }
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)E[i].clear();
		rep(i, m) {
			int a, b, c; scanf("%d%d%d", &a, &b, &c); a--; b--;
			E[a].push_back(P(c, b)); E[b].push_back(P(c, a));
		}
		priority_queue<st>que;
		memset(d, 0x3f, sizeof(d));
		d[0][0] = 0; que.push({ 0,0,0 });
		while (!que.empty()) {
			st p = que.top(); que.pop();
			if (d[p.p][p.b] != p.c)continue;
			for (P v : E[p.p]) {
				if (p.b == 0) {
					if (d[v.second][0] > p.c + v.first) {
						d[v.second][0] = p.c + v.first;
						que.push({ v.second,0,d[v.second][0] });
					}
					if (d[v.second][1] > p.c) {
						d[v.second][1] = p.c;
						que.push({ v.second,1,d[v.second][1] });
					}
				}
				if (p.b == 1) {
					if (d[v.second][2] > p.c) {
						d[v.second][2] = p.c;
						que.push({ v.second,2,d[v.second][2] });
					}
				}
				if (p.b == 2) {
					if (d[v.second][2] > p.c + v.first) {
						d[v.second][2] = p.c + v.first;
						que.push({ v.second,2,d[v.second][2] });
					}
				}
			}
		}
		printf("%d\n", d[n - 1][2]);
	}
}

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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int a[3];
    for(int i=0;i<3;i++) a[i] = 0;
    for(int i=0;i<2;i++) {
        int x;
        cin >> x;
        a[x-1] = 1;
    }
    for(int i=0;i<3;i++) {
        if(a[i] == 0) {
            cout << (i + 1) << '\n';
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> a(A), b(B);
  REP(i, A) cin >> a.at(i);
  REP(i, B) cin >> b.at(i);
  int ans = 200000;
  REP(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    int after_dis = a.at(x-1) + b.at(y-1) - c;
    if (after_dis < ans) ans = after_dis;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int cash = a.at(0) + b.at(0);
  if (cash < ans) ans = cash;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

long long pow_mod(long long a, long long b, long long mod){
    long long ans=1;
    a%=mod;
    while(b>0){
        if(b&1){
            ans*=a;
            ans%=mod;
        }
        b=b>>1;
        a=(a*a)%mod;
    }
    return ans;
}

void solve(){
    long long ans=0, sm=0, sqsm=0;
    int n;
    cin>>n;
    vector<long long> a(n,0ll);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        sm+=a[i];
        sqsm+=(a[i]*a[i])%MOD;
    }
    sqsm%=MOD;
    sm%=MOD;
    sm=((sm*sm)%MOD+MOD-sqsm)%MOD;
    cout<<(sm*(pow_mod(2ll,MOD-2,MOD)))%MOD<<"\n";
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 4784
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int q;
	cin >> q;
	deque<int> dq;
	while(q--){
		string op;
		cin >> op;
		if(op == "deleteFirst")dq.pop_front();
		else if(op == "deleteLast")dq.pop_back();
		else{
			int x;cin >> x;
			if(op == "insert")dq.push_front(x);
			else{
				vector<int> rems;
				while(!dq.empty()){
					rems.push_back(dq.front());
					dq.pop_front();
				}
				for(int i = 0; i < (int)rems.size(); i++){
					if(rems[i] == x){
						rems.erase(rems.begin() + i);
						break;
					}
				}
				reverse(rems.begin(), rems.end());
				for(auto i:rems)dq.push_front(i);
			}
		}
	}
	if(dq.empty());
	else{
		cout << dq.front();
		dq.pop_front();
		while(!dq.empty()){
			cout << ' ' << dq.front();
			dq.pop_front();
		}
	}
	cout << '\n';
	return 0;
}



Measured memory_bytes: 8840
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
// #define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
#define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()

//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    const int limbin = 500001;
    int fact[limbin], factinv[limbin] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,limbin)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();
        if(n<r) return 0;             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve()
{ 
    int l , r , d ;
    cin >> l >>  r >> d;
    cout << r/d - (l-1)/d << endl;
}

Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        string n = Read();
        Console.WriteLine(n.Sum(c => c - '0') % 9 == 0 ? "Yes" : "No");
    }
}

static class Scanner
{
    static Queue<string> que = new Queue<string>();
    public static string Read() { if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s); return que.Dequeue(); }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());
    public static IEnumerable<string> Read(long n) { for (long i = 0; i < n; i++) yield return Read(); }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}


Measured memory_bytes: 27284
shared void main(){
  assert(exists sve=process.readLine());
  value tve=sve.split();
  assert(exists e=parseInteger(tve.last));
  for(_ in 0:e+1){
    process.readLine();
  }
  assert(exists stmax=process.readLine());
  assert(exists tmax=parseInteger(stmax));
  for(_ in 0:tmax){
    print(-1);
  }
}

Measured memory_bytes: 195800
n, p = map(int, input().split())

pf={}
for i in range(2,int(p**0.5)+1):
    while p%i==0:
        pf[i]=pf.get(i,0)+1
        p//=i
if p>1:pf[p]=1

ans = 1
for key, value in pf.items():
    while value >= n:
        ans *= key
        value -= n
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>

/* template start */

using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

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

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
  std::cerr << " " << h;
  if (sizeof...(t) > 0) std::cout << " :";
  debug_out(t...);
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  return a > b && (a = b, true);
}

template <typename Num>
constexpr Num mypow(Num a, u64 b, Num id = 1) {
  if (b == 0) return id;
  Num x = id;
  while (b > 0) {
    if (b & 1) x *= a;
    a *= a;
    b >>= 1;
  }
  return x;
}

/* template end */

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

  i64 n;
  std::cin >> n;

  std::vector<i64> l(n);
  for (auto&& e : l) std::cin >> e;

  std::sort(all(l));

  i64 cnt = 0;

  rep(i, 0, n) {
    rep(j, i + 1, n) {
      rep(k, j + 1, n) {
        if (l[i] < l[j] && l[j] < l[k] && l[i] + l[j] > l[k]) cnt++;
      }
    }
  }

  std::cout << cnt << "\n";

  return 0;
}

Measured memory_bytes: 3664
v[50],p,n;f(X){for(;X>0;X-=v[p++]);n+=X;}main(s){for(;n=atoi(gets(v));printf("%d\n",s)){for(p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;n;)n=0,p=++s,f(5),f(7),f(5),f(7),f(7);}}

Measured memory_bytes: 532
#D セグ木
n,K=map(int,input().split())
A= [int(input()) for _ in range(n)]

#####segfunc#####
def segfunc(x, y):
    return max(x,y)
#################

#####ide_ele#####
ide_ele = -1
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

maxa=max(A)
z= [0 for i in range(maxa)]
seg = SegTree(z, segfunc, ide_ele)

for i in range(n):
    mini = max(0,A[i]-K)
    maxi = min(maxa,A[i]+K)
    tmp=seg.query(mini,maxi+1)
    seg.update(A[i],tmp+1)

print(seg.query(0,maxa+1))

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

int main()
{
    string s;
    cin >> s;

    string ans;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '0' || s[i] == '1')
        {
            ans.push_back(s[i]);
        }
        else
        {
            int len = ans.size();
            ans = ans.substr(0, len - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256