akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int   N = in.nextInt();
			int[] a = new int[N];
			for(int i = 0; i < a.length; i++) {
				a[i] = in.nextInt();
			}
			Arrays.sort(a);
			out.println(a[a.length - 1] - a[0]);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 22868
h,w,k = map(int,input().split())

mas = [0]*h
for i in range(h):
    mas[i] = input()

#rows　行　columns 列

cnt = 0
for rows in range(1 << h):
    for columns in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i)%2 == 1:
                continue
            for j in range(w):
                if (columns >> j)%2 == 1:
                    continue
                if mas[i][j] == "#":
                    black += 1
        if black == k:
            cnt += 1
print(cnt)

Measured memory_bytes: 9028
N = int(input())
S = list(map(int,input().split()))
Q = int(input())
T = list(map(int,input().split()))

res = 0
for t in T: 
  l,r = 0,N-1
  while r>=l:
    m = (l+r)//2
    if S[m] == t:
      res += 1
      break
    if S[m] < t:
      l = m+1
    else:
      r = m-1

print(res)


Measured memory_bytes: 16716
#include<stdio.h>

int main(){
  int n,i,minj,j,t,c=0;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj]){
	minj=j;
      }
    }
    if(A[i]!=A[minj]){
      t=A[i];
      A[i]=A[minj];
      A[minj]=t;
      c++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",c);
  return 0;
}



Measured memory_bytes: 2104
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    cnt=0
    for i in range(N-2):
        if s[i:i+3]=="ABC":
            cnt+=1
    print(cnt)



if __name__ == "__main__":
    main()

Measured memory_bytes: 77044
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.print(a*b);
        System.out.print(" ");
        System.out.println(a*2 + b*2);
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll a, b, n; cin >> a >> b >> n;
    ll x = (n+1) / b * b - 1;
    if(n < b - 1) x = n;
    ll ans = floor(a * x / b) - a * floor(x / b);
    chmax(ans, (ll)(floor(a * n / b) - a * floor(n / b)));
    cout << ans << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s="";
    int even=0,odd=0;
    cin>>s;
    
    for(int i=0;i<s.length();i=i+2){
        if(s[i]=='1'){
            even++;
        }
        if(s[i+1]=='0'){
            even++;
        }
    }
    
    for(int i=0;i<s.length();i=i+2){
        if(s[i]=='0'){
            odd++;
        }
        if(s[i+1]=='1'){
            odd++;
        }
    }
    
    std::cout << min(odd,even) << std::endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cerr<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int n,a;
int32_t main(void) {
    boost;
    cin>>n>>a;
    n%=500;
    if(a>=n) cout<<"Yes\n";
    else cout<<"No";
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  vector<bool> T(N);
  ll now = A[0];
  REP(i, N - 1) {
    if(now>=A[i+1]){
      T[i+1] = true;
    }else{
      T[i+1] = false;
    }
    now = A[i+1];
  }
  ll ans = 0;
  now = 0;
  REP(i,N){
    if(T[i]==true){
      now++;
    }else{
      now = 0;
    }
    ans = max(ans, now);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
n=int(input())
rs=[]
for rId in range(n):
    s,p=input().split()
    p=int(p)
    rs.append((s,p,rId))

def comp(tsmall,tlarge):
    if tsmall[0]==tlarge[0]:
        return tsmall[1]>tlarge[1]
    else:
        return tsmall[0]<tlarge[0]
    
def sort(a):
    for i in range(0,n):
        for j in range(n-1,i,-1):
            if comp(a[j],a[j-1]):
                a[j],a[j-1]=a[j-1],a[j]

sort(rs)
for i in range(len(rs)):
    print(rs[i][2]+1)
        


Measured memory_bytes: 39536
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 118, 87
// 169, 133, 17, 98
// 180, 106, 125, 39
// 171, 42, 159, 14
// 45, 76, 101, 56
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	long long ret2=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		if(i==0)ret2=(ret2+ks)%d;
		ks=ks*2%d;
	}
	int sz=d%200;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

Measured memory_bytes: 165712
n = int(input())
l = list(map(int,input().split()))

cnt = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i != j and j != k and k != i and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                nagasa = sorted([l[i],l[j],l[k]])
                if nagasa[0] + nagasa[1] > nagasa[2]:
                    cnt += 1
print(cnt // 6)

Measured memory_bytes: 9076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            int[] a = new int[3];
            int[] b = new int[2];
            a[0] = int.Parse(Console.ReadLine());
            a[1] = int.Parse(Console.ReadLine());
            a[2] = int.Parse(Console.ReadLine());
            b[0] = int.Parse(Console.ReadLine());
            b[1] = int.Parse(Console.ReadLine());
            Array.Sort(a);
            Array.Sort(b);
            Console.WriteLine(a[0]+b[0]-50);
        }
    }
}

Measured memory_bytes: 9284
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (long long)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
const ll MOD = 1e9+7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}


const int N = 200001;
vi adj[N];
ll vis[N];
ll c;

void dfs(ll x){
	if(vis[x]){return;}
	c++;
	vis[x]=1;
	for(auto u : adj[x]){
		if(!vis[u]){
			
			dfs(u);
			
			}
		}
	
	}

int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,m;cin>>n>>m;
vi cnt;
rep(i,m){
	ll x,y;cin>>x>>y;
	adj[x].pb(y);
	adj[y].pb(x);
	}

for(int i=1; i<=n ; i++){
	 c = 0;
	if(!vis[i]){
		dfs(i);
		cnt.pb(c);
		}
	}

ll ans=0;
for(ll i = 0; i<sz(cnt); i++){
	ans = max(ans, (ll)cnt[i]);
	}
cout<<ans;




}





	
	




		



Measured memory_bytes: 22328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, M, S, T;
    cin >> N >> M >> S >> T;

    VVP Ga(N+1), Gb(N+1);
    rep(i, 0, M){
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        Ga[u].push_back({v, a});
        Ga[v].push_back({u, a});
        Gb[u].push_back({v, b});
        Gb[v].push_back({u, b});
    }

    VL Ca(N+1, 1e18), Cb(N+1, 1e18);
    
    // scope 1
    {
        priority_queue<PL, vector<PL>, greater<PL>> que;
        que.push({0, S});
        Ca[S] = 0;
        while(!que.empty()){
            auto q = que.top();
            que.pop();
            if(q.first > Ca[q.second]) continue;
            for(auto g : Ga[q.second]){
                if(Ca[g.first] <= q.first + g.second) continue;
                Ca[g.first] = g.second + q.first;
                que.push({Ca[g.first], g.first});
            }
        }
    }


    // scope 2
    {
        priority_queue<PL, vector<PL>, greater<PL>> que;
        que.push({0, T});
        Cb[T] = 0;
        while(!que.empty()){
            auto q = que.top();
            que.pop();
            if(q.first > Cb[q.second]) continue;
            for(auto g : Gb[q.second]){
                if(Cb[g.first] <= q.first + g.second) continue;
                Cb[g.first] = g.second + q.first;
                que.push({Cb[g.first], g.first});
            }
        }
    }

    //cerr << Ca[T] << endl;
    //cerr << Cb[S] << endl;
    /*
    cerr << "Ca" << endl;
    rep(i, 1, N+1) cerr << i << " " << Ca[i] << endl;
    cerr << "Cb" << endl;
    rep(i, 1, N+1) cerr << i << " " << Cb[i] << endl;
    */
    VL ans(N+1);
    ll mn = 1e18;
    ll frst = 1e15;
    //cerr << "min" << endl;
    for(ll i = N; i > 0; i--){
        //cerr << i << " " << mn << " " << Ca[i] + Cb[i];
        mn = min(mn, Ca[i] + Cb[i]);
        //cerr << " -> " << mn << endl;
        ans[i] = frst - mn;
    }

    rep(i, 1, N+1) cout << ans[i] << endl;    
    return 0;
}

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

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

    int n; cin >> n;
    vector<int> a, b;

    for(int i = 1; i < n; ++i){
        for(int j = i+1; j <= n; ++j){
            if((n%2 == 1 && i+j != n) || (n%2 == 0 && i+j != n+1)){
                a.push_back(i);
                b.push_back(j);
            }
        }
    }

    cout << a.size() << "\n";
    rep(i,a.size()) cout << a[i] << " " << b[i] << "\n";
}

Measured memory_bytes: 3624
n = int(input())
A = list(map(int, input().split(' ')))
A.insert(0,0)
A.append(0)
An = [abs(A[1] - A[0])]
Ann = []
i = 0
while i < n:
    An.append(abs(A[i+2] - A[i+1]))
    Ann.append(abs(A[i+2] - A[i]) - An[i] - An[i+1])
    i += 1
s = sum(An)
ans = ""
for q in Ann:
    ans += str(q + s) + '\n'
print(ans[:-1])

Measured memory_bytes: 18236
#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() {
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;

    if (U == S)
        --A;
    else
        --B;
    cout << A << " " << B << endl;
}

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

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

    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define int long long int
#define e 1000000007
using namespace std;

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 int t=1;
    // cin>>t;
    
  while(t--){
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   set<int> s;

//    sort(a,a+n);
   int cnt =0;
   for(int i=0;i<n-2;i++){
       for(int j=i+1;j<n-1;j++){
           for(int k=j+1;k<n;k++){
               if(a[i]+a[j] > a[k] && a[i]+ a[k] > a[j] && a[j] + a[k] > a[i] && a[i] != a[k] && a[j]!=a[k] && a[i]!=a[j]){
                   cnt++;
                //    s.insert(a[i]*a[j]*a[k]);
               }
           }
       }
   }
// int m = s.size();
   cout<<cnt;
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const string YES = "Yes";
const string NO = "No";

void solve(long long X){
    if(X>=30){
        cout << YES <<endl;
    }else{
        cout << NO << endl;
    }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

bool is_integer( double x ){
  return floor(x)==x;
}

void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

double Distance(int *p_1,int *p_2,int D){
    
    double sum = 0;
    
    for(int i=0;i<D;i++){
        int r,l;
        l = *(p_1 + i);
        r = *(p_2 + i);
        sum += pow((r-l),2);
    }
    
    return sqrt(sum);
}

int main(void){
    
    int N,D,ans = 0;
    cin >> N >> D;

    int data[N][D];
    vector<int> nums {};
    int *p = &data[0][0];
    for(int i=0;i<N;i++) nums.push_back(i);
    
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            cin >> data[i][j];
        }
    }
    
    foreach_comb(N, 2, [&](int *indexes) {
        if(is_integer(Distance((p+indexes[0] * D), (p+indexes[1] * D),D))) ans++;
    
    });
    
    cout << ans << endl;
}

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

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

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

    if(t.substr(0, s.length()) == s && s.length() + 1 == t.length()){
       cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int 
main(){
	int N;
	char S[110],T[110];
	
	scanf("%d",&N);
	scanf("%s %s",&S,&T);
	int i;
	for(i=0;i<N;i++){
		
		printf("%c%c",S[i],T[i]);
	}
	
	
	printf("\n");
 return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
    int n, h, w;
    int a, b;
    int ans = 0;
    scanf("%d %d %d", &n, &h, &w);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d", &a, &b);
        if (h <= a && w <= b)
            ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <set>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    set<int>st;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(st.count(x))
        {
            st.erase(x);
        }
        else
            st.insert(x);
    }
    cout<<st.size()<<endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


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

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
const int MX = 300000;
int row[MX], col[MX];
map<pair<int, int>, bool> mp;
int main() {
  int h, w, m, maxrow = 0, maxcol = 0;
  cin >> h >> w >> m;

  for (int i = 0; i < m; i++) {
    int r, c;
    cin >> r >> c;
    r--;
    c--;
    mp[{r, c}] = 1;
    row[r]++;
    col[c]++;
    maxrow = max(maxrow, row[r]);
    maxcol = max(maxcol, col[c]);
  }
  int r_size = 0, c_size = 0;
  vector<int> max_rows, max_cols;
  for (int i = 0; i < h; i++) if (row[i] == maxrow) { max_rows.push_back(i); r_size++; }
  for (int j = 0; j < w; j++) if (col[j] == maxcol) { max_cols.push_back(j); c_size++; }
  int ans = maxrow + maxcol;
  for (int i = 0; i < r_size; i++) for (int j = 0; j < c_size; j++) {
    if (!mp[{max_rows[i], max_cols[j]}]) {
      cout << ans << endl;
      return 0;
    }
  }
  cout << --ans << endl;
  return 0;
}

Measured memory_bytes: 28496
#include<bits/stdc++.h>
#define int long long 
#define pb push_back
//#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define N 1000000
#define INF 10000000000000

using namespace std;

const int mod=1e9+7;



void need_for_speed(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
//unordered_map<int,set<int> > mp;



int32_t main(){
	need_for_speed();
    //solve();
    int n;
    cin>>n;
    int arr[n];
    vector<int> freq(N+1,0),vis(N+1,0);;

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

    int cnt=0;
    for(int i=1;i<=N;i++){
        if(freq[i]==0 or vis[i]){
            continue;
        }
        if(freq[i]==1 and  !vis[i]){
            cnt++;
        }
        
        for(int j=i;j<=N;j+=i){
            vis[j]=true;
        }
    }
    cout<<cnt<<endl;
    return 0;
}
        
	

		
    

        
        
    
 

Measured memory_bytes: 20368
#include <iostream>
#include <set>
#include <vector>
using namespace std;
vector<int> A;
set<int> a;
void slove(int n,int sum)
{
	if(n<0){
		a.insert(sum);
		return;
	}
	slove(n-1,sum);
	slove(n-1,sum+A[n]);
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	int n,q,m;
	cin >> n;
	A.resize(n);
	for(int i=0;i<n;i++) cin >> A[i];
	slove(n-1,0);
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> m;
		if(a.find(m)==a.end()) cout << "no" << endl;
		else cout << "yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <cstddef>
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> b;
  b.reserve(n);
  for (size_t i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    auto it = ((i % 2 == 0)? b.end(): b.begin());
    b.insert(it, a);
  }

  if (n % 2 != 0)
    std::reverse(b.begin(), b.end());

  for (size_t i = 0; i < n; ++i)
    printf("%d%c", b[i], i+1<n? ' ': '\n');
}


Measured memory_bytes: 2944
#include <iostream>

int main(){
   int a, b;
   std::cin >> a >> b;
   if ((a < 0) && (b >= 0)){
      std::cout << "Zero" << std::endl;
   } else if (a > 0){
      std::cout << "Positive" << std::endl;
   } else{
      if ((b-a+1) % 2 == 0){
         std::cout << "Positive" << std::endl;
      } else{
         std::cout << "Negative" << std::endl;
      }
   }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N, K; cin >> N >> K;
  int ans = K;
  for(int i=2; i<=N; ++i)
    ans *= (K-1);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

using namespace std;

char ch[100100];
int N;
int K;
int cnt;

int get(char ch){
	if(ch == 'a') return 0;
	return 'z' - ch + 1;
}

void solve(){
	cnt = 0;
	N = strlen(ch);
	for(int i = 0; i < N - 1; ++i){
		int tmp = get(ch[i]);
		if(cnt + tmp <= K){
			cnt += tmp;
			ch[i] = 'a';
		}
	}
	int c = ch[N - 1] - 'a';
	c = (c + (K - cnt)) % 26;
	ch[N -1] = 'a' + c;
}

void input(){
	scanf("%s", ch);
	scanf("%d", &K);
}

int main(){
	input();
	solve();
	printf("%s\n", ch);
	return 0;
}


Measured memory_bytes: 384
MOD = 10**9 + 7
s = input()
 
old_dp = [0] * 13
new_dp = [0] * 13
old_dp[0] = 1
 
for c in s:
    for i in range(13):
        if c == '?':
            for d in range(10):
                new_dp[(i*10 + d) % 13] += old_dp[i]
        else:
            new_dp[(i*10+int(c)) % 13] += old_dp[i]
    old_dp = [x % MOD for x in new_dp]
    new_dp = [0] * 13
    
print(old_dp[5])

Measured memory_bytes: 74464
n = int(input())
an = list(map(int, input().split()))

d = 0
a0 = an[0]
for i in range(1, len(an)):
    a1 = an[i]
    if a0 >= a1:
        d += a0 - a1
    else:
        a0 = a1
    
print(d)


Measured memory_bytes: 32216
($sx,$sy,$tx,$ty,)=glob<>;
print
'R'x($tx-$sx).'U'x($ty-$sy).'L'x($tx-$sx).'D'x($ty-$sy),
'D'.'R'x($tx-$sx+1).'U'x($ty-$sy+1).'L'.
'U'.'L'x($tx-$sx+1).'D'x($ty-$sy+1).'R',$/

Measured memory_bytes: 768
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static long[][] dp;

    public static long f(int[] arr, int[] w, int n, int sum, int W) {
        if (n == arr.length)
            return 0;
        if (dp[n][sum] != -1)
            return dp[n][sum];
        if (w[n] + sum <= W) {
            return dp[n][sum] = Math.max(1l * arr[n] + f(arr, w, n + 1, sum + w[n], W), f(arr, w, n + 1, sum, W));
        }
        return dp[n][sum] = f(arr, w, n + 1, sum, W);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int W = sc.nextInt();
        int[] arr = new int[n];
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            arr[i] = sc.nextInt();
        }
        dp = new long[105][100000 + 5];
        for (int i = 0; i < dp.length; i++)
            for (int j = 0; j < dp[i].length; j++)
                dp[i][j] = -1;
        pw.println(f(arr, w, 0, 0, W));
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 126036
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	if(N == 1){

		printf("1\n");
		printf("0\n");

	}else if(N == 2){

		printf("2\n");
		printf("0\n");
		printf("11\n");

	}else{

		printf("%d\n",N-1);
		for(int i = 0; i <= N-2; i++){
			printf("0");
			for(int k = 0; k < i; k++){

				printf("1");
			}
			printf("0\n");
		}
	}

	return 0;
}



Measured memory_bytes: 3220
N, M = map(int, input().split())
pS = [list(input().split()) for i in range(M)]
c = [0 for _ in range(N)]
penalty = [0 for _ in range(N)]
ac = 0
sum_penalty = 0

for i in range(M):
    num = int(pS[i][0])
    if c[num - 1] == 0:
        if pS[i][1] == 'WA':
            penalty[num - 1] += 1
        else:
            c[num - 1] = 1
            sum_penalty += penalty[num - 1]
            ac += 1

print(ac, sum_penalty)


Measured memory_bytes: 27556
#include<stdio.h>

void rank(double w){
	if(w<=48)printf("light fly\n");
	else if(w>48 && w<=51)printf("fly\n");
	else if(w>51 && w<=54)printf("bantam\n");
	else if(w>54 && w<=57)printf("feather\n");
	else if(w>57 && w<=60)printf("light\n");
	else if(w>60 && w<=64)printf("light welter\n");
	else if(w>64 && w<=69)printf("welter\n");
	else if(w>69 && w<=75)printf("light middle\n");
	else if(w>75 && w<=81)printf("middle\n");
	else if(w>81 && w<=91)printf("light heavy\n");
	else printf("heavy\n");
}

int main(void){
	double w;
	
	while(scanf("%lf",&w)!=EOF)rank(w);
	
return 0;
}

Measured memory_bytes: 1036
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(usize);
    let (a, b) = scan!(usize, usize);
    let vs = scan!(usize;;);
    let prob1 = vs.iter().filter(|&&v| v <= a).count();
    let prob2 = vs.iter().filter(|&&v| a < v && v <= b).count();
    let prob3 = vs.iter().filter(|&&v| b < v).count();

    println!("{}", vec![prob1, prob2, prob3].iter().min().unwrap())
}


Measured memory_bytes: 4352
p = 2019 
D = input()
n=(len(D))
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)

Measured memory_bytes: 9340
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-12;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//AGCばちゃ 1700~
/*
010
101
010
*/
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint i,j,n,L;cin>>n>>L;
	vector<lldo>xza(n);
	vector<lldo>yza(n);
	vector<lldo>hxza(n);
	vector<lldo>hyza(n);
	lldo xans=0,yans=0;
	vector<llint>T(n);
	for(i=0;i<n;i++){
		cin>>T[i];
		xza[i]=cos(pai*2*T[i]/L);
		yza[i]=sin(pai*2*T[i]/L);
		hxza[i]=cos(pai*T[i]/L);
		hyza[i]=sin(pai*T[i]/L);
	}
	vector<lldo>xwa(n);
	vector<lldo>ywa(n);
	for(i=n-1;i>0;i--){
		xwa[i-1]=xwa[i]+cos(pai+pai*T[i]/L);
		ywa[i-1]=ywa[i]+sin(pai+pai*T[i]/L);
	}
	for(i=0;i<n-2;i++){
		for(j=i+1;j<n-1;j++){
			lldo xa=cos(pai*(T[i]+T[j])/L);
			lldo ya=sin(pai*(T[i]+T[j])/L);
			//cerr<<xza[i]-xa<<" "<<yza[i]-ya<<endl;
			//cerr<<xwa[j]<<" "<<ywa[j]<<endl;
			lldo xg=xwa[j]*(xza[i]-xa)-ywa[j]*(yza[i]-ya);
			lldo yg=ywa[j]*(xza[i]-xa)+xwa[j]*(yza[i]-ya);
			xans+=xg*hxza[i]+yg*hyza[i]+xa*(n-j-1);
			yans+=yg*hxza[i]-xg*hyza[i]+ya*(n-j-1);
		}
	}
	xans/=n*(n-1)*(n-2);xans*=6;
	yans/=n*(n-1)*(n-2);yans*=6;
	cout<<xans<<" "<<yans<<endl;
	return 0;
}


Measured memory_bytes: 512
n = int(input())
x = []
y = []
d = []
for i in range(n):
  s = input().split()
  x.append(int(s[0]))
  y.append(int(s[1]))
  if s[2] == 'U':
    d.append(0)
  elif s[2] == 'L':
    d.append(1)
  elif s[2] == 'D':
    d.append(2)
  else:
    d.append(3)

INF = float('inf')

def calc(p):
  #print(p)
  res = INF
  for k,v in p.items():
    v.sort()
    for i in range(1,len(v)):
      if v[i-1][1] == 0 and v[i][1] != 0:
        res = min(v[i][0]-v[i-1][0],res)
  return res

ans = INF
for r in range(4):
  #UD
  p = {}
  for i in range(n):
    if d[i] != 0 and d[i] != 2:
      continue
    if x[i] in p:
      p[x[i]].append((y[i],d[i]))
    else:
      p[x[i]] = [(y[i],d[i])]
  ans = min(calc(p)*5,ans)
  #UR
  p = {}
  for i in range(n):
    if d[i] != 0 and d[i] != 3:
      continue
    if x[i]+y[i] in p:
      p[x[i]+y[i]].append((y[i],d[i]))
    else:
      p[x[i]+y[i]] = [(y[i],d[i])]
  ans = min(calc(p)*10,ans)
  #rotate
  for i in range(n):
    x[i],y[i] = -y[i],x[i]
    d[i] = (d[i]+1)%4

print(ans if ans != INF else 'SAFE')

Measured memory_bytes: 230656
# 二項係数を"やるだけ"にしてくれるライブラリ
MAX = 510000
MOD = 1000000007
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX
 
 
# テーブルを作る前処理
def COMinit():
    global factrial, inverse, factrial_inverse
    factrial[0] = 1
    factrial[1] = 1
    inverse[1] = 1
    factrial_inverse[0] = 1
    factrial_inverse[1] = 1
    for i in range(2, MAX):
        factrial[i] = factrial[i-1] * i % MOD
        inverse[i] = MOD - inverse[MOD % i] * (MOD//i) % MOD
        factrial_inverse[i] = factrial_inverse[i-1] * inverse[i] % MOD
 
 
# 二項係数計算
def COM(n, k):
    global factrial, inverse, factrial_inverse
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return factrial[n] * (factrial_inverse[k] * factrial_inverse[n-k] % MOD) % MOD
 
# 前処理完了
COMinit()

N, K = map(int, input().split())
mod = 10 ** 9 + 7

red = N - K

for i in range(1, K+1):
  b = COM(K-1, i - 1)
  r = COM(red+1, red-(i-1))
  print(b*r%mod)

Measured memory_bytes: 63860
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		int ans = 0;
		Map<Long, Integer> map = new HashMap<Long, Integer>();
		if(n == 1) {
			System.out.println(0);
			return;
		}
		long tempN = n;
		long loop = (long)Math.sqrt(n);
		for(long z = 2; z < loop ; z++) {
			if(tempN % z == 0) {
				tempN = tempN / z;
				map = addValue(map, z);
				z = 1;
			}
		}
		ans = calcPrimeNumber(map);
		if(loop < tempN) {
			ans++;
		}
		System.out.println(ans);
	}
		
	private static Map<Long, Integer> addValue(Map<Long, Integer> map, long z) {
		if(map.get(z) == null) {
			map.put(z, 1);
		} else {
			int sum = map.get(z) + 1;
			map.put(z, sum);
		}
		return map;
	}
	
	private static int calcPrimeNumber(Map<Long, Integer> map) {
		int num = 0;
		for(long key : map.keySet()) {
			int minus = 1;
			int value = map.get(key);
			while (value >= minus) {
				value = value - minus;
				minus++;
				num++;
			}
		}
		return num;
	}
}

Measured memory_bytes: 27240
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>
#define INF 1000000000
#define M 1000005
using namespace std;
int k,nxt[M],head[M],to[M],adj[M],dist[M],tot;
void add(int u,int v,int w){
	nxt[++tot]=head[u];head[u]=tot;to[tot]=v;adj[tot]=w;
	return;
}
struct node{
	int dis,id;
	bool operator< (const node b) const{return dis<b.dis;}
	bool operator> (const node b) const{return dis>b.dis;}
};
int dijkstra(){
	priority_queue <node,vector<node>,greater<node> > Q;
	for (register int i=1;i<=k;i++) dist[i]=INF;
	dist[2]=1;Q.push((node){1,2});
	while (!Q.empty()){
		node now=Q.top();Q.pop();
		if (now.dis!=dist[now.id]) continue;
		for (register int i=head[now.id];i;i=nxt[i])
			if (dist[to[i]]>now.dis+adj[i]){
				dist[to[i]]=now.dis+adj[i];
				Q.push((node){dist[to[i]],to[i]});
			}
	}
	return dist[1];
}
int main(){
	scanf("%d",&k);
	for (register int i=1;i<k;i++){
		add(i+1,(i+1)%k+1,1);
		add(i+1,i*10%k+1,0);
	}
	printf("%d",dijkstra());
	return 0;
}


Measured memory_bytes: 15612
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Applicative
import Control.Monad
import Control.Monad.State
import Control.DeepSeq
import Data.Array
import Data.Bits
import Data.Char
import Data.Functor.Identity
import Data.List
import Data.Maybe
import Data.Ord
import Data.Tree
import Data.Tuple
import qualified System.IO
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.Sequence as Q
import qualified Data.ByteString.Char8 as B

main = do
  [n,x] <- readLnList
  if x == 1 || x == 2*n-1
  then putStrLn "No"
  else do
    putStrLn "Yes"
    let
      foo = if x == 2 then [3,2,1,4] else [x-1,x,x+1,x-2]
      bar = [1..2*n-1] \\ foo
      ans = if n == 2 then [1,2,3] else
        take (n-3) bar ++ foo ++ drop (n-3) bar
    mapM_ print ans

 
type Z = Int
type Q = Rational
type R = Double
type S = String

fint :: (Integral a, Num b) => a -> b
fint = fromIntegral

getInt = fst . fromJust . B.readInt <$> B.getLine
getIntPair = (\[a,b]->(a,b)) <$> getInts
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine
getStr = B.unpack <$> B.getLine

yesNo :: Bool -> String
yesNo True = "Yes"
yesNo False = "No"

printList :: (Show a) => [a] -> IO ()
printList = putStrLn . unwords . map show

readLnList :: (Read a) => IO [a]
readLnList = map read . words <$> getLine


-----  Union-find
type UnionFindT v m a = StateT (M.Map v (UnionFindVal v)) m a
newtype UnionFindVal v = UnionFindVal v

runUnionFindT :: (Monad m) => UnionFindT v m a -> m a
runUnionFindT = flip evalStateT $ M.empty

runUnionFind = runIdentity . runUnionFindT

ufFresh :: (Monad m, Ord v) => v -> UnionFindT v m ()
ufFresh v = modify $ M.insert v (UnionFindVal v)

ufClass :: (Monad m, Ord v) => v -> UnionFindT v m v
ufClass v = do
  (UnionFindVal pv) <- gets (M.! v)
  if v == pv
    then return v
    else do
      c <- ufClass pv
      modify $ M.insert v (UnionFindVal c)
      return c

ufUnify v w = do
  cv <- ufClass v
  cw <- ufClass w
  modify $ M.insert cw (UnionFindVal cv)
  return $ cv /= cw


Measured memory_bytes: 9212
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑




ll ans,current;
int main() {
	string h;
	cin >> h;
	for (int i = 0; i < h.length(); ++i) {
		if (h[i] == '1'){
			ans += mod_pow(2, current)*mod_pow(3, h.length() - i - 1);
			ans %= MOD;
			++current;
		}
	}
	ans += mod_pow(2, current);
	ans %= MOD;

	cout << ans%MOD << endl;
}

Measured memory_bytes: 512
loop {
	n = gets.to_i
	break if n == 0

	know = (1..n).map{
		bits = 0
		gets.split.map(&:to_i)[1..-1].each{|i|
			bits |= (1 << i-1)
		}
		bits
	}

	leaked = 0
	gets.split.map(&:to_i)[1..-1].each{|i|
		leaked |= (1 << i-1)
	}

	candidate = []
	(0..n-1).each{|i|
		candidate << i+1 if know[i] & leaked == leaked
	}

	if candidate.size == 1
		p candidate[0]
	else
		p -1
	end
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N, P;
  cin >> N >> P;
  string S;
  cin >> S;

  if (P==2) {
    ll ret = 0;
    REP(i, N) {
      int d = S[i]-'0';
      if (d%2==0) {
        ret += i+1;
      }
    }
    cout << ret << endl;
    return 0;
  }

  if (P==5) {
    ll ret = 0;
    REP(i, N) {
      int d = S[i]-'0';
      if (d%5==0) {
        ret += i+1;
      }
    }
    cout << ret << endl;
    return 0;
  }

  vi qs(P);

  ll ret = 0;
  int q = 0;
  int digits = 1;
  REP(i, N) {
    int d = S[N-1-i] - '0';
    q = (q + d*digits)%P;
    digits = (digits*10)%P;

    if (q==0) ret++;
    ret += qs[q];
    qs[q]++;
  }


  cout << ret << endl;

  return 0;
}

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

int main() {
  int P = 0, W = 0, G = 0, Y = 0;
  int N;
  cin >> N;
  
  int i;
  for (i = 0; i < N; i++){
  	string col;
    cin >> col;
    if (col == "P")
      P = 1;
    if (col == "W")
      W = 1;
    if (col == "G")
      G = 1;
    if (col == "Y")
      Y = 1;
  }
  int sum = P + W + G + Y;
  if (sum == 3)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

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

int main(){
    double R;
    cin >> R;

    cout << 2.0*R*3.14159265 << endl;
    return 0;
}

Measured memory_bytes: 3764