akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdbool.h>

#define Pre 0//for switch
#define Meiji 1
#define Taisho 2
#define Showa 3
#define Heisei 4

//declare function
void print_gengo(int nen,int tuki, int hi);

/*==============end of delaration====================================*/

int main(void){
    int impyear;
    int impmonth;
    int impday;
    while(scanf("%d %d %d", &impyear, &impmonth, &impday) != EOF) {
        print_gengo(impyear, impmonth, impday);
    }
    return 0;
}

void print_gengo(int nen,int tuki,int hi)
{
    int gengo;//using defined number

    //judging statement
    if(nen > 1989 ||
      (nen == 1989 && (tuki > 1  || 
                      (tuki == 1 && hi >= 8)))) {
        gengo = Heisei;
    }else if(nen > 1926 ||
            (nen == 1926 && (tuki > 12 || 
                            (tuki == 12 && hi >= 25)))) {
        gengo = Showa;
    }else if(nen > 1912 ||
            (nen == 1912 && (tuki > 7 ||
                            (tuki == 7 && hi >= 30)))) {
        gengo = Taisho;
    }else if(nen > 1868 ||
            (nen == 1868 && (tuki > 9 ||
                            (tuki == 9 && hi >= 8)))) {
        gengo = Meiji;
    }else{
        gengo = Pre;
    }

    //printing statement
    switch (gengo) {
        case Pre:
            printf("pre-meiji\n");
            break;
        case Meiji:
            printf("meiji %d %d %d\n", nen - 1867, tuki, hi);
            break;
        case Taisho:
            printf("taisho %d %d %d\n", nen - 1911, tuki, hi);
            break;
        case Showa:
            printf("showa %d %d %d\n", nen - 1925, tuki, hi);
            break;
        case Heisei:
            printf("heisei %d %d %d\n",nen - 1988, tuki, hi);
            break;
    }
}

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

int n, m;

int main(void){
	cin >> n;
	vector<lli> t(n);
	lli total = 0;
	rep(i, n){
		cin >> t[i];
		total += t[i];
	}
	cin >> m;
	rep(i, m){
		int p;
		lli x;
		cin >> p >> x;
		p--;
		cout << total-t[p]+x << endl;
	}
	return 0;
}


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

ll K;
vector<ll> a;
int main() {
  cin >> K;

  if (K == 0) {
    cout << 2 << endl;
    cout << "0 0" << endl;
    return 0;
  }

  ll N = min(K + 1, 50LL);
  ll rest = K;
  ll c = (K - N + 1 + N) / (N + 1);
  a.resize(N, N - 1 + (N + 1) * c - K);
  rest -= c * N;

  rep(i, N) {
    if (rest == 0) break;
    ll d = min((10000000000001000LL - a[i]) / (N + 1), rest);
    a[i] += (N + 1) * d;
    rest -= d;
  }

  cout << N << endl;
  rep(i, N) {
    if (i != 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<stack>
#include<tuple>
using namespace std;
#define INF 1100000000000
#define MAX 100000
#define MOD 100000
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll dp[110000];

int main(){
    int N,K,h[110000];
    cin>>N>>K;
    for(int i=0;i<N;i++) cin>>h[i];
    for(int i=0;i<110000;i++) dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=1;j<=K;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout<<dp[N-1]<<endl;

}



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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int a = 0;
  for(int i = 0; i < S.size()-1; i++) {
    if(S.at(i) == S.at(i+1)) {
      a++;
    }
  }
  cout << S.size() - a << endl;
}


Measured memory_bytes: 1020
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,c=INTM()
    print(min(b//a,c))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    ll ret = 0;
    int right = 0;
    ll Sum = 0;
    ll Xor = 0;
    for(int left = 0;left < N;left++) {
        while(right < N && Sum == Xor) {
            if(Sum + vec.at(right) != (Xor ^ vec.at(right))) {
                break;
            }
            else {
                Sum += vec.at(right);
                Xor = (Xor ^ vec.at(right));
            }
            right++;
        }
        ret += (right - left);
        Sum -= vec.at(left);
        Xor = (Xor ^ vec.at(left));
        if(right == left) {
            right++;
        }
    }
    cout << ret << endl;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

vector <int> dx = { 1,-1,0,0,1,1,-1,-1 };
vector<int> dy = { 0,0,1,-1,1,-1,1,-1 };


char c[410][410];

ll ans = 0;
ll h, w;
vector<vector<bool>> b(410, vector<bool>(410, false));
ll tmp = 0;
ll tmpa = 0;


void dfs(ll x, ll y) {
	if (c[x][y] == '#')tmp++;
	else tmpa++;
	b[x][y] = true;
	//cout << x << ' ' << y  << endl;
	REP(i, 4) {
		ll nx = x + dx[i];
		ll ny = y + dy[i];

		if (nx < 0 || h <= nx || ny < 0 || w <= ny)continue;
		if (b[nx][ny])continue;
		if (c[x][y]==c[nx][ny])continue;
		else {
			dfs(nx, ny);
		}
	}
}


int main() {

	cin >> h >> w;


	REP(i, h)REP(j, w)cin >> c[i][j];
	
	REP(i, h)REP(j, w) {
		if (b[i][j]==false) {
			dfs(i, j);
			ans += tmp * tmpa;
			//cout << ans << ' ' << tmp << ' ' << tmpa << endl;
			tmp = tmpa = 0;
		}

	}
	cout << ans << endl;


	return 0;
}


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

using namespace std;

int n;
double dp[301][301][301];

void solve(){
    cin >> n;
    int i,j,k;
    double in = 1.0/n;
    for(i = 0;i <= n;i++) for(j = 0;j <= n;j++) for(k = 0;k <= n;k++) dp[i][j][k] = 0;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n-i;j++){
            for(int k = 0;k <= n-i-j;k++){
                if(i) dp[i][j][k] += i*(dp[i-1][j+1][k])/(i+j+k);
                if(j) dp[i][j][k] += j*(dp[i][j-1][k+1])/(i+j+k);
                if(k) dp[i][j][k] += k*(dp[i][j][k-1])/(i+j+k);
                if(i+j+k) dp[i][j][k] += 1/(1-(n-i-j-k)*in);
                //cout << i << ' ' << j << ' ' << k << ' ' << dp[i][j][k] << endl;
            }
        }
    }
    int a[4] = {0};
    for(i = 0;i < n;i++){
        int ai;
        cin >> ai;
        a[ai]++;
    }
    printf("%.11f\n",dp[a[3]][a[2]][a[1]]);
}

int main(){
    solve();
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll X;
ll ans = 0;
ll i, j, k;
int main(){
    scanf("%lld", &X);
    i = 100;
    while(i<X){
        i += i / 100;
        ++ans;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3828
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        int n=sc.nextInt();
        int k=sc.nextInt(),p=n/k;
        long ans=0;
        for (int i=0; i<k; i++) {
            if((2*i)%k!=0)continue;
            if(i>0 && i<=n%k)p++;
            ans+=(long)p*p*p;
            p=n/k;
        }   

        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23124
x,n=map(int,input().split())
lis = []
if(n!=0):
    lis = list(map(int,input().split()))
ans = 0
msf = 1000
for i in range(101):
    tmp1 = x-i
    if tmp1 not in lis:
        print(x-i)
        exit()
    tmp2 = x+i
    if tmp2 not in lis:
        print(x+i)
        exit()

Measured memory_bytes: 9212
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
#define int ll
signed main(){
    int n,t; cin>>n>>t;
    vi v(n); rep(i,n)cin>>v[i];
    int ans=0;
    ans+=t;
    rep(i,n){
        if(!i)continue;
        if(v[i]>v[i-1]+t){
            ans+=t;
        }else{
            ans+=v[i]-v[i-1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
def function(a):
	s=0
	d=a
	for i in range(d,600-d+1,d):
		s+=a*(d**2)
		d+=a
		#print("%10d %10d"%(d,s))
	return s

while True:
	try:
		n=int(input())
		print(function(n))
	except EOFError:
		break

Measured memory_bytes: 7564
#include <stdio.h>
#include <iostream>

using namespace std;

int N;
int A[210];

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

  int res;

  while (true)
  {
    bool exist_odd = false;
    for (int i = 0; i < N; i++)
    {
      if (A[i] % 2 != 0)
        exist_odd = true;
    }
    //奇数があったら、処理を抜ける。
    if (exist_odd)
      break;

    //操作を行えるなら、実際に行う
    //上で奇数か調べている。
    //そのため、ここまで来るA[i]は全て偶数になる。
    for (int i = 0; i < N; ++i)
    {
      A[i] /= 2;
    }
    ++res;
  }

  cout << res << endl;
}

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

int main(){

	string S;
	cin>>S;
	int ans = 0;
	for (int i = 0; i < S.length(); ++i)
	{
		ans += (S[i]-'0');
		ans%=9;
	}
	if(ans==0)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3748
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A = nextInt();
		int B = nextInt();

		int N = 1;
		int cnt = 0;
		while(N<B) {
			N += A-1;
			cnt++;
		}
		out.println(cnt);
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

}

Measured memory_bytes: 23764
#include <stdio.h>
 
int main(void){
  unsigned long long i = 0, sum, a, b, x;
  
  scanf("%llu", &a);
  scanf("%llu", &b);
  scanf("%llu", &x);
  
  if(a%x == 0)
    i = 1;
  
  sum = i + (b/x) - (a/x);
  
  printf("%llu", sum);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;

int main(){
    int r,g,b,n;
    int ans=0;
    std::cin >> r>>g>>b>>n;
    rep(i,3001)rep(j,3001){
        if(n-i*r-j*g>=0&&(n-i*r-j*g)%b==0)ans++;
    }
    std::cout << ans << std::endl;
}


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

int main() {
	int a,b,c,x;
	cin >> a>>b>>c>>x;
	
	int ans=0;
	for(int i=0; i<=a; i++){
	for(int j=0; j<=b; j++){
	for(int k=0; k<=c; k++){
		
		if(i*500 + j*100 + k*50 == x){ans++;}
		
	}
	}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int k, s;
  cin >> k >> s;

  int cnt = 0;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (0 <= s - i - j && s - i - j <= k) cnt++;
    }
  }

  cout << cnt << endl;
}


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

long long f(long long n)
{
	return (n*(n+1))/2;
}

int main()
{
	long long n;
	scanf("%lld", &n);
	long long ans = 0;
	for(int i = 1; i <= n; i++) {
		ans += i*f(n/i);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3780
s = io.read()
ans = "Yes"

for i = 1, s:len(), 1 do
  if i % 2 == 1 and
       s:sub(i,i) ~= 'R' and s:sub(i,i) ~= 'U' and
       s:sub(i,i) ~= 'D' or 
     i % 2 == 0 and
       s:sub(i,i) ~= 'L' and s:sub(i,i) ~= 'U' and
       s:sub(i,i) ~= 'D' then
    ans = "No"
    break
  end
end

print(ans)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};

ll n,m; 


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m;
  vpll ab(m);
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    ab[i]={a,b};
  }
  ll ans=0;
  rep(i,m){
    UnionFind uf(n);
    rep(j,m){
      if(i==j) continue;
      uf.connect(ab[j].first,ab[j].second);
    }
    bool ok=true;
    rep(i,n){
      if(!uf.isSame(0LL,i)) ok=false;
    }
    if(!ok) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };



int main() {
	int n;
	vector<PII> _array;
	while ( scanf( "%d", &n ) && n ) {
		_array.resize( n );
		for ( int i = 0; i < n; i++ ) {
			int h, m, s;
			scanf( "%2d:%2d:%2d", &h, &m, &s );
			_array[ i ].first = s + m * 60 + h * 3600;
			scanf( "%2d:%2d:%2d", &h, &m, &s );
			_array[ i ].second = s + m * 60 + h * 3600;
		}
		sort( _array.begin(), _array.end() );
		int ans = 0;
		for ( int i = 0; i < n; i++ ) {
			bool is_add = true;
			for ( int j = 0; j < i; j++ ) {
				if ( _array[ i ].first >= _array[ j ].second ) {
					is_add = false;
					_array[ j ].second = INF;
					break;
				}
			}
			ans += is_add;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1320
#include <iostream>

using namespace std;

int main(){
	int n;
	while (cin>>n){
		int cnt=0;
		for (int a=0;a<10;a++){
			for (int b=0;b<10;b++){
				for (int c=0;c<10;c++){
					for (int d=0;d<10;d++){
						if (a+b+c+d==n){
							cnt++;
						}
					}
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n, C;
    cin >> n >> C;

    int max_t = 0;
    vector<tuple<int, int, int>> seg(n);
    for (int i = 0; i < n; ++i) {
        cin >> get<0>(seg[i]) >> get<1>(seg[i]) >> get<2>(seg[i]);
        --get<2>(seg[i]);
        max_t = max(max_t, get<1>(seg[i]));
    }

    max_t += 2;
    vector<vector<int>> cnt(C, vector<int>(max_t));
    for (int i = 0; i < n; ++i) {
        ++cnt[get<2>(seg[i])][get<0>(seg[i])];
        --cnt[get<2>(seg[i])][get<1>(seg[i]) + 1];
    }

    for (int i = 0; i < C; ++i)
        for (int j = 0; j < max_t; ++j)
            cnt[i][j] += cnt[i][j - 1];

    int ans = 0;
    for (int i = 0; i < max_t; ++i) {
        int num = 0;
        for (int j = 0; j < C; ++j)
            num += (0 < cnt[j][i]);
        ans = max(ans, num);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> A(n);
  rep(i,n) cin >> A[i];
  ll ans = 0;
  while(1){
    rep(i,n){
     if(A[i] % 2 == 1){
       cout << ans/n << endl;
       return 0;
     }
     else{
       ++ans;
       A[i] /= 2;
     }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define  ll  long long int
#define  sz  200010
using namespace std;




int main()
{


    string s,x="";

    ll r,ss,p,d=0,k,a,b,c,z,y,n,m,l,i;

    cin>>n>>k;
    cin>>r>>ss>>p;

    cin>>s;

    for(i=0; i<k; i++)
    {
        if(s[i]=='r')x+='p';
        else if(s[i]=='p')x+='s';
        else
            x+='r';
    }

    for(i=k; i<n; i++)
    {
        if(s[i]=='r')
        {
            if(x[i-k]!='p')x+='p';
            else
                x+='*';
        }
        else if(s[i]=='p')
        {

            if(x[i-k]!='s')x+='s';
            else
                x+='*';
        }
        else
        {
            if(x[i-k]!='r')x+='r';
            else
                x+='*';
        }
    }

  // cout<<x<<endl;

    for(i=0;i<n;i++)
    {
      if(x[i]=='r')d+=r;
      else if(x[i]=='s')d+=ss;
      else if(x[i]=='p')d+=p;
    }
    cout<<d<<endl;

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char str[10];
int N;
int summ[4];
int main(){
    scanf("%d",&N);
    while(N--){
        scanf(" %s",str);
        if(str[0]=='A')
            ++summ[0];
        if(str[0]=='W')
            ++summ[1];
        if(str[0]=='T')
            ++summ[2];
        if(str[0]=='R')
            ++summ[3];
    }
    printf("AC x %d\n",summ[0]);
    printf("WA x %d\n",summ[1]);
    printf("TLE x %d\n",summ[2]);
    printf("RE x %d\n",summ[3]);
    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int n;
int h;
int u;
int main(){
	cin>>h>>n;
	while(n--){
		cin>>u;
		h-=u;
		if(h<=0){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
string s[100000];
int main() {
  int n, a, b, c, cnt = 0;
  vector<char> ans;
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == "AB") {
      if (s[i] == "AB" && a == 0 && b == 0) {
        cout << "No" << endl;
        return 0;
      } else if (s[i] == "AB" && (a > b || a == b && a > 1)) {
        ans.push_back('B');
        a--;
        b++;
      } else if (s[i] == "AB" && a < b) {
        ans.push_back('A');
        a++;
        b--;
      } else if (s[i] == "AB" && i + 1 < n && s[i + 1] == "BC") {
        ans.push_back('B');
        a--;
        b++;
      } else {
        ans.push_back('A');
        a++;
        b--;
      }
    }
    if (s[i] == "BC") {
      if (b == 0 && c == 0) {
        cout << "No" << endl;
        return 0;
      }
      if (b > c || b == c && b > 1) {
        ans.push_back('C');
        c++;
        b--;
      } else if (b < c || i + 1 < n && s[i + 1] == "AB") {
        ans.push_back('B');
        c--;
        b++;
      } else {
        ans.push_back('C');
        c++;
        b--;
      }
    }
    if (s[i] == "AC") {
      if (a == 0 && c == 0) {
        cout << "No" << endl;
        return 0;
      } else if (a < c || a == c && c > 1) {
        ans.push_back('A');
        a++;
        c--;
      } else if (a > c || i + 1 < n && s[i + 1] == "BC") {
        ans.push_back('C');
        c++;
        a--;
      } else {
        ans.push_back('A');
        a++;
        c--;
      }
    }
  }
  cout << "Yes" << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
}


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

def solve():
    S = input()  # 1以上S以下の整数
    n = len(S)   # n:整数Sの桁数
    K = int(input())

    # 桁DP
    # dp[i][j][k] := i桁目まで決めて
    #                j個の非ゼロを使って
    #                k:0なら、そこまでの桁はNと一致
    #                k:1なら、そこまでの桁ですでにN以下であることが確定
    #                したときの場合の数
    dp = [[[0 for _ in range(2)] for __ in range(4)] for ___ in range(n+1)]
    dp[0][0][0] = 1  # 何も決めていない状態で、非ゼロを0個使ってるときは1（空集合）

    for i in range(n):
        for j in range(4):
            for k in range(2):
                nd = int(S[i]) # 今の桁の値
                for d in range(10):
                    # 次の桁の値dを全部試す
                    ni = i + 1
                    nj = j
                    nk = k

                    if d != 0: nj += 1
                    if nj > K:
                        # 範囲を超えるなら
                        continue
                    if k == 0:
                        # 今の状態がNと一致しているなら
                        if d > nd:
                            # 次の桁が、今の桁の値より大きかったらダメ
                            continue
                        elif d < nd:
                            # 次の桁が、今の桁より小さかったら、「N以下」になることが確定する
                            nk = 1

                    dp[ni][nj][nk] += dp[i][j][k]

    ans = dp[n][K][0] + dp[n][K][1]
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
  int A, B, C;
  int sum = 0;
  int i;
  
  scanf("%d %d %d", &A, &B, &C);
  for(i = 0; i < B; i++) {
    sum += A;
    if(sum % B == C) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <iostream>

using namespace std;

int main()
{
	int H, W, K, sx, sy, tx, ty;

	cin >> H >> W >> K;

	vector<string> M(H);

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

	vector<vector<int> > J(H, vector<int>(W, 0));
	vector<vector<int> > O(H, vector<int>(W, 0));
	vector<vector<int> > I(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (M[i][j] == 'J')
			{
				J[i][j] = 1;
			}

			if (M[i][j] == 'O')
			{
				O[i][j] = 1;
			}

			if (M[i][j] == 'I')
			{
				I[i][j] = 1;
			}

			if (i != 0)
			{
				J[i][j] += J[i - 1][j];
				O[i][j] += O[i - 1][j];
				I[i][j] += I[i - 1][j];
			}

			if (j != 0)
			{
				J[i][j] += J[i][j - 1];
				O[i][j] += O[i][j - 1];
				I[i][j] += I[i][j - 1];
			}

			if (i != 0 && j != 0)
			{
				J[i][j] -= J[i - 1][j - 1];
				O[i][j] -= O[i - 1][j - 1];
				I[i][j] -= I[i - 1][j - 1];
			}
		}
	}

	for (int i = 0; i < K; i++)
	{
		cin >> sy >> sx >> ty >> tx;

		int J_, O_, I_;

		J_ = J[ty - 1][tx - 1];
		O_ = O[ty - 1][tx - 1];
		I_ = I[ty - 1][tx - 1];

		if (sx != 1 && sy != 1)
		{
			J_ += J[sy - 2][sx - 2];
			O_ += O[sy - 2][sx - 2];
			I_ += I[sy - 2][sx - 2];
		}

		if (sx != 1)
		{
			J_ -= J[ty - 1][sx - 2];
			O_ -= O[ty - 1][sx - 2];
			I_ -= I[ty - 1][sx - 2];
		}

		if (sy != 1)
		{
			J_ -= J[sy - 2][tx - 1];
			O_ -= O[sy - 2][tx - 1];
			I_ -= I[sy - 2][tx - 1];
		}

		cout << J_ << ' ' << O_ << ' ' << I_ << endl;
	}

	return 0;
}

Measured memory_bytes: 15572
n, m = map(int, input().split())
a = [int(_) for _ in input().split()]
aa = [0] * n

for i in range(n):
    aa[i] = a[i] * (4*m)

lim = sum(a)
ans = 0
for i in range(n):
    if aa[i] >= lim:
        ans += 1
    else:
        pass
if m <= ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string s[102] = {};
    for (int i = 0 ; i < 50 ; i++) {
        for (int j = 0 ; j < 100 ; j++) s[i] += '.';
    }
    for (int i = 50 ; i < 100 ; i++) {
        for (int j = 0 ; j < 100 ; j++) s[i] += '#';
    }
    b--;
    for (int i = 0 ; i < 50 ; i += 2) {
        for (int j = 0 ; j < 100 ; j += 2) {
            if (b == 0) break;
            s[i][j] = '#';
            b--;
        }
        if (b == 0) break;
    }
    a--;
    for (int i = 52 ; i < 100 ; i += 2) {
        for (int j = 0 ; j < 100 ; j += 2) {
            if (a == 0) break;
            s[i][j] = '.';
            a--;
        }
        if (a == 0) break;
    }
    cout << 100 << ' ' << 100 << '\n';
    for (int i = 0 ; i < 100 ; i++) cout << s[i] << '\n';
}

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N = II()
    A = LI()
    mx = max(A)+1
    B = np.zeros(mx)

    for a in A:
        for b in range(a, mx, a):
            B[b] = B[b] + 1
    # print(B)

    cnt = 0
    for a in A:
        if B[a] == 1:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    solve()


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

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    rep(i, h) {
        rep(j, w) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    for (int tmph = 0; tmph < (1 << h); tmph++) {
        bitset<6> th(tmph);
        for (int tmpw = 0; tmpw < (1 << w); tmpw++) {
            bitset<6> tw(tmpw);
            int count = 0;

            for (int i = 0; i < h; i++) {
                if (th.test(i)) continue;

                for (int j = 0; j < w; j++) {
                    if (tw.test(j)) continue;
                    if (c[i][j] == '#')
                        count++;
                }
            }
            if (count == k) ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include<tuple>

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

int main(){
    int n;
    int a1=0;
    int n1=-1;
    int a2=-1;
    int a;
    scanf("%d",&n);
    REP(i,n){
        scanf("%d",&a);
        if(a1<a){
            a2=a1;
            a1=a;
            n1=i;
        }
        else if(a2<a){
            a2=a;
        }
    }
    REP(i,n){
        if(i==n1)printf("%d\n",a2);
        else printf("%d\n",a1);
    }
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define ll long long
#define inf (ll)1e18
#define all(x) x.begin(), x.end()

const int MX = 200020;
const int N = 1000060;
const int mod = (int)1e9 + 7;


int main(){
/*
     ___     ___
    (^_^)   (^_^)
   /( | )\ /( | )\
     | |     | |
*/
    cin.tie(0);
    cin.sync_with_stdio(0);

    #ifdef Cyborg101
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

   	int k;
   	cin >> k;

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

   	ll mn = 2, mx = 2;
   	for(int i = k - 1; i >= 0; --i){
   		mn = (mn + a[i] - 1) / a[i] * a[i];
   		mx = mx / a[i] * a[i] + a[i] - 1;
   		if(mn > mx)
   			return puts("-1"), 0;
   	}

   	cout << mn << " " << mx << endl;

	return 0;
}

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


int main() {
    int n, a, b, ans, high;
    cin >> n >> a >> b;

    if(n < a+b){
        high = max(a, b);
        ans = n - min(a, b);
        ans = max(ans, high) - min(ans, high);
    } else {
        ans = 0;
    }
    cout << min(a, b) << " " <<ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
	string s, t,u;
	int a, b;

	cin >> s >> t >> a>>b>>u;


	if (u == s) {
		a = a - 1;
	}
	else {
		b = b - 1;
	}
	cout << a<< " "<< b;
}


Measured memory_bytes: 256
import itertools

s = input()
n = len(s)

l = []
for i in range(1,n):
	l.append(i)

ans = []

for i in range(1,n):
	index = list(itertools.combinations(l,i))
	for j in range(len(index)):
		start = 0
		for k in index[j]:
			ans.append(int(s[start:k]))
			start = k
		ans.append(int(s[k:n]))

print(sum(ans) + int(s))


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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin  >> n;
    map<string, int> cnt;
    int mx= 0;
    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        cnt[s]++;
        mx = max(mx, cnt[s]);
    }
    
    vector<string> ans;
    for (auto i : cnt) {
        if(i.second == mx){
            ans.push_back(i.first);
        }
    }
    
    for (auto s : ans) {
        cout << s << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 25584
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] d = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; i * j <= n; j++) {
                d[i * j]++;
            }
        }
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            ans += i * d[i];
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 116268
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	string s;cin>>s;
	puts(s=="ani"?"square1001":"e869120");
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 



int main(){
    int n;cin >> n;
    double t=0.0;
    for (int i = 0; i < n; i++) {
        double a;cin >> a;
        t += 1/a;
    }
    cout <<setprecision(10) <<  1/t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DUMP(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;
const double EPS = 1e-9;
FILE *fp;

void init();
void last();

void init() {
#ifdef MYLOCAL
	if ((fp = freopen("../comp_programming/in.txt", "r", stdin)) == nullptr) {
		assert(false);
	}
#endif
}

void last() {
#ifdef MYLOCAL
	fclose(fp);
#endif
	exit(0);
}

const int MAX = 1510;
int h[MAX], w[MAX];
const int MAX2 = MAX * 1000;
int hcnt[MAX2], wcnt[MAX2];
void solve(int n, int m) {
	memset(h, 0, sizeof(h));
	memset(w, 0, sizeof(w));
	memset(wcnt, 0, sizeof(wcnt));
	memset(hcnt, 0, sizeof(hcnt));
	for (size_t i = 0; i < n; i++)
	{
		scanf("%d", h + i);
	}
	for (size_t i = 0; i < m; i++)
	{
		scanf("%d", w + i);
	}
	for (size_t i = 0; i < n; i++)
	{
		int sum = 0;
		for (size_t j = i; j < n; j++)
		{
			sum += h[j];
			hcnt[sum]++;
		}
	}
	for (size_t i = 0; i < m; i++)
	{
		int sum = 0;
		for (size_t j = i; j < m; j++)
		{
			sum += w[j];
			wcnt[sum]++;
		}
	}
	long long ans = 0;
	for (size_t i = 0; i < MAX2; i++)
	{
		ans += hcnt[i] * wcnt[i];
	}
	printf("%lld\n", ans);
}

signed main(void) {
	LL n, m, p, a, b, c, x, y, z, q;
	string s;
	bool f = false;
	init();
	while (cin >> n >> m, n) {
		solve(n, m);
		//return 0;
	}
	last();
}

Measured memory_bytes: 14900
import java.util.*;

class Main{
    public static void main(String[] agrs){
	Scanner sc = new Scanner(System.in);

	while(true){
	    int n = sc.nextInt();

	    if(n==0)break;

	    int c=0;
	    for(int i=n+1;i<=2*n;i++){
		if( prim(i) ) c++;
	    }
	    System.out.println( c );
	}
	
    }

    static boolean prim(int n){
	for(int i=2;i<=Math.sqrt(n);i++){
	    if(n%i==0) return false;
	}
	return true;
    }
}

Measured memory_bytes: 12000
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	if(c^'-')k=1,x=c&15;else k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (200010)
#define P (10010)
int n,p,pw[N]{1},ans,b[N],iv[P]{0,1};
char s[N];
void slv(int l,int r);
signed main(){
	Rd(n),Rd(p),cin>>s+1;
	Frn1(i,1,n)s[i]^='0',pw[i]=pw[i-1]*10%p;
	Frn1(i,2,p)iv[i]=(p-p/i)*iv[p%i]%p;
	slv(1,n),wr(ans),exit(0);
}
void slv(int l,int r){
	if(l==r){ans+=!(s[l]%p);return;}
	int md((l+r)>>1);
	slv(l,md),slv(md+1,r);
	int u(0);
	Frn_(i,md,l)++b[u=(u+pw[md-i]*s[i])%p];
	u=0;
	Frn1(i,md+1,r){
		u=(u*10+s[i])%p;
		ans+=u?pw[i-md]?b[(p-u)*iv[pw[i-md]]%p]:0
			:pw[i-md]?*b:md-l+1;
	}
	u=0;Frn_(i,md,l)--b[u=(u+pw[md-i]*s[i])%p];
}

Measured memory_bytes: 2176
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int C[20];

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

  for(int i=0;i<N;i++){
    cin>>temp;
    C[temp/400]++;
  }

  for(int i=0;i<=7;i++){
    if(C[i]>0) ans++;
  }
  if(ans==0){
    ans++;
    C[8]--;
  }
  cout<<ans<<" "<<ans+C[8]+C[9]+C[10]+C[11]+C[12]<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ct = 0;
    int digit;
    for (int i=1;i<=N;i++){
      digit = 0;
      double tmp = i;
      while (tmp>=1){
        tmp = Math.floor(tmp/10);
        digit++;
      }
      if ((digit%2) == 1){
        ct++;
      }
    }
    
    
    System.out.println(ct);
  }
}

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

void print(int a[], int n)
{
	for (int i = 0; i < n; i++) {
		if (i > 0)
			cout << " ";
		cout << a[i];
	}
	cout << endl;
}

void insertionsort(int a[], int n)
{
	int v, j;
	for (int i = 1; i < n; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
		}
		a[j + 1] = v;
		print(a, n);
	}
}

int main(void) 
{
	int n, m;
	int a[150];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	print(a, n);
	insertionsort(a, n);

	return 0;
}



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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;

    i64 ans = 0;
    for (i64 i = 1; (f64) i <= sqrt(n); i++) {
        if (n % i != 0) continue;
        if ((i - 1) != 0 && n % (i - 1) == n / (i - 1)) ans += i - 1;
        if (i == n / i) continue;
        if ((n / i - 1) != 0 && n % (n / i - 1) == n / (n / i - 1)) ans += n / i - 1;
    }
    cout << ans << endl;
}

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


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int f[2020];
void solve(){
    string s;
    cin>>s;
    f[0]=1;
    int cur=1,mod=0;
    ll ans=0;
    for(int i=sz(s)-1;i>=0;i--){
        mod=(mod+cur*(s[i]-'0'))%2019;
        cur=cur*10%2019;
        ans+=f[mod];
        f[mod]++;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3716
package main

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

var scanner *bufio.Scanner

func printIt() {
	for {
		n := nextInt()
		x := nextInt()

		if n == 0 && x == 0 {
			break
		}

		ans := 0
		for i := 1; i <= n-2; i++ {
			target := x - i
			l := i + 1
			r := n
			for l < r {
				if l+r < target {
					l++
				} else if l+r > target {
					r--
				} else {
					ans++
					l++
					r--
				}
			}
		}
		fmt.Println(ans)
	}

}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1060
#define _CRT_SECURE_NO_WARNINGS
#define MaxSize 16777215
#include <stdio.h>
#include <stdlib.h>


void insert(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p <<= 2;
			p += 4;
			break;
		case 'C':
			p <<= 2;
			p += 5;
			break;
		case 'G':
			p <<= 2;
			p += 6;
			break;
		case 'T':
			p <<= 2;
			p += 7;
			break;
		}
	}
	D[p] = 'Y';
}

int find(char *D, char s[]) {
	int i = -1;
	char c;
	int p = -1;
	while (c = s[++i]) {
		switch (c) {
		case 'A':
			p <<= 2;
			p += 4;
			break;
		case 'C':
			p <<= 2;
			p += 5;
			break;
		case 'G':
			p <<= 2;
			p += 6;
			break;
		case 'T':
			p <<= 2;
			p += 7;
			break;
		}
	}
	return D[p] == 'Y';
}

int main() {
	char *D = (char *)malloc(sizeof(char) * MaxSize);
	int i;
	//zuru
	//for (i = 0; i < MaxSize; ++i) {
	//	D[i] = 'N';
	//}

	char com[7];
	char s[13];
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s%s", com, s);
		if (com[0] == 'i') {
			insert(D, s);
		}
		else {
			if (find(D, s)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}


	free(D);

	return 0;
}

Measured memory_bytes: 3380