akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count0 = 0;        
        int count1 = 0;
        for (char c : s.toCharArray()) {
            if (c == '0') ++count0;
            if (c == '1') ++count1;
        }
        
        int min = Math.min(count0, count1);
        System.out.println(min * 2);
    }
}


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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF					INT_MAX
#define LLINF					LLONG_MAX
#define DEBUG					false

typedef long long				ll;
typedef pair <int, int> ii;

int main() {

	int n;
	cin >> n;
	
	cout << n * (n + 1) / 2 <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int N,count;
	double sum=0,s=100;
	cin >> N;
	int a[N+10];
	for(int i=0; i<N; i++){
		cin >> a[i];
		sum+=a[i];
	}sum=sum/N;
	for(int i=0; i<N; i++){
		if(sum==a[i]){
			cout << i << endl;
			return 0;
		}
		if(abs(sum-a[i])<s){
			s=abs(sum-a[i]);
			count=i;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> p(N);
  rep (i, N) cin >> p[i];
  long ans = 0;
  rep (i, N-1) {
    if (p[i] == i+1) {
      swap(p[i], p[i+1]);
      ans++;
    }
  }
  if (p[N-1] == N) ans++;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
   ll a,b,c,k,ans=0;
   cin>>a>>b>>c>>k;
   if(a>k){
       ans+=k;
   }else{
       ans+=a;
       k-=a;
       if(b>k){
           
       }else{
           k-=b;
           ans-=k;
       }
   }
   cout<<ans<<endl;
}
   



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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    LL i,k,n,ans=0,mod=1e9+7;
    cin >> n >> k;
    ++n;
    for(i=k;i<=n;i++)
    {
        ans+=i*(n-i)+1;
        ans%=mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
#include <vector>
#include <list>

using namespace std;
using namespace boost;


int main(int argc, char* argv[])
{
	using sprtr = char_separator<char>;
	using tknzr = tokenizer<sprtr>;
	sprtr sep(" ", "", keep_empty_tokens);

	int f, mf, mo;

	string line;
	while(1) {

		int n, m;
		{
			getline(cin, line);
			tknzr tkns(line, sep);
			auto it = tkns.begin();
			n = lexical_cast<int>(*it++);
			m = lexical_cast<int>(*it);
		}

		if( n == 0 && m == 0 ) {
			break;
		}
		
		list<int> ps;		
		{
			getline(cin, line);
			tknzr tkns(line, sep);
			for( auto p : tkns ) {
				//cout << p << endl;
				ps.push_back(lexical_cast<int>(p));
			}
		}

		ps.sort(greater<int>());

		int div = n / m;
		int mod = n % m;

		int sum = 0;
		auto it = ps.begin();
		for( int i = 0; i < div; i++ ) {
			for( int j = 0; j < m; j++ ) {
				auto p = *it++;
				if( j == m-1 ) continue;
				sum += p;
			}
		}

		if( mod ) {
			for( int i = 0; i < mod; i++ ) {
				auto p = *it++;
				sum += p;			   
			}
		}

		cout << sum << endl;

		ps.clear();
		
	}

    return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;
const ll n_MAX = pow(10, 5)+10;

// factorial(階乗)の計算

ll fac[n_MAX+1] ={};

ll c_fac(int n) {
  if (fac[n]!=0) return fac[n];
  if (n==0) return fac[n]=1;
  return fac[n] = (c_fac(n-1)*n)%MOD;
}

// inverse(逆元)の計算

ll inv(ll a,ll m) {
  ll b = m, x = 1, y = 0;
  while (b!=0) {
    ll d = a/b;
    a -= b*d; swap(a, b);
    x -= y*d; swap(x, y);
  }
  return x>=0 ? x : x+m;
}

// combinataionの計算

ll nck(ll n, ll k) { 
  if (n<k) return 0;
  ll nume = fac[n];
  ll deno = ( inv(fac[n-k],MOD) * inv(fac[k],MOD) ) % MOD;
  return ( nume * deno ) % MOD;
}

int main() {
  int n; cin >> n;
  int a[n+1]; rep(i, n+1) cin >> a[i];

  int count[n+1]={}; rep(i, n+1) count[a[i]]++;
  int d_num; rep(i, n+1) if (count[i] == 2) { d_num = i; break; }
  int x, y, z, d_app = 0;
  rep(i, n+1) {
    if (d_app == 0 && a[i] == d_num) {
      x = i;
      d_app = 1;
    }
    else if (d_app == 1 && a[i] == d_num) {
      y = i-x-1;
      z = n-i;
    }
  }

  // cout << x << " " << y << " " << z << endl;
  c_fac(n_MAX);
  for (int i=1; i<=n+1; i++) {
    ll result;
    if (i==1) result = n;
    else result = (MOD*2 + nck(n+1, i) - nck(x+z, i-1)) % MOD;
    cout << result << endl;
  }
  return 0;
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
    char c;

    cin>>c;

    if((c>='a')&&(c<='z')){
        cout << "a";
    }
    else if((c>='A')&&(c<='Z')){
        cout << 'A';
    }

    return 0;
}


Measured memory_bytes: 3628
use proconio::{*, marker::Usize1};
use std::collections::HashMap;

fn main() {
    input!{
        n: usize,
        q: usize,
        c: [Usize1; n],
        lr_bak: [(usize, usize); q],
    }

    let mut lr = lr_bak.clone();
    lr.sort_by(|(_, a), (_, b)| a.cmp(b));

    let mut color = vec![-1; n];
    let mut bit = Bit::new(n+1);
    let mut map = HashMap::new();

    let mut idx = 0;
    for &(l, r) in lr.iter() {
        while idx < r {
            idx += 1;
            if color[c[idx-1]] != -1 {
                bit.add(color[c[idx-1]] as usize, -1);
            }
            bit.add(idx, 1);
            color[c[idx-1]] = idx as i32;
        }

        map.insert((l, r), bit.sum(r) - bit.sum(l-1));
    }

    for &(l, r) in lr_bak.iter() {
        println!("{}", map.get(&(l, r)).unwrap());
    }
}

struct Bit {
    data: Vec<i64>,
}

impl Bit {
    pub fn new(n: usize) -> Bit {
        Bit {
            data: vec![0; n+1],
        }
    }

    pub fn add(&mut self, idx: usize, x: i64) {
        let mut idx = idx as i32;
        while idx as usize <= self.data.len()-1 {
            self.data[idx as usize] += x;
            idx += idx & -idx;
        }
    }

    pub fn sum(&self, idx: usize) -> i64 {
        let mut ret = 0;
        let mut idx = idx as i32;
        while idx > 0 {
            ret += self.data[idx as usize];
            idx -= idx & -idx;
        }

        ret
    }
}



Measured memory_bytes: 81976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n,i,j,k,m;
	cin>>n>>k;
	vector<int>a(n+1);
	for(i=1;i<=n;i++)
	cin>>a[i];
	int dp[n+1];
    memset(dp,-1,sizeof(dp));
    dp[1]=0;dp[2]=abs(a[2]-a[1]);
    for(i=3;i<=n;i++)
    {
    	m=INT_MAX;
    	for(j=1;j<=k;j++)
    	{
    		
    		if(i-j>=1)
    		{
    			m=min(m,dp[i-j]+abs(a[i]-a[i-j]));
    		}
    		else
    		break;
    	}
    	dp[i]=m;
    }
    cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
n = gets.chomp.to_i
lines = gets.chomp.split.map(&:to_i)

r = "Yes"
max = 1
prev = 0

for now in lines do

	max = now if (now > max)
	if (max - now > 1) then
		r = "No"
		break
	end
	if (now >= prev) then
		prev = now
	elsif ((now - 1) >= prev) then
		prev = now - 1
	elsif ((prev - 1) >= now) then
		prev -= 1
	else
		r = "No"
		break
	end

end

puts r


Measured memory_bytes: 9604
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN=1e6+1;
int dp[MAXN];
bool ispalin(string s){
  string a=s;
  reverse(all(s));
  return a==s;	
}
void solve(){
  int a,b,cnt=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
	   cnt+=(ispalin(to_string(i))); 
	 }
   cout<<cnt<<endl;	
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

int a[300005];

int main() {
	int n;
	scanf("%d", &n);
	n*=3;
	for (int i=0 ; i<n ; i++) {
		scanf("%d", a+i);
	}
	sort(a, a+n);
	reverse(a, a+n);
	ll sol = 0;
	for (int i=0 ; i<n/3 ; i++) {
		sol += a[i*2+1];
	}
	printf("%lld\n", sol);
	return 0;
}

Measured memory_bytes: 1408
import sys
n=int(input())
a=list(map(int,input().split()))
ct1=0
for i in range(n):
  if a[i]==1:
    ct1+=1
if ct1==0:
  print(-1)
  sys.exit()
x=1
ct=0
for i in range(n):
  if a[i]==x:
    x+=1
  else:
    ct+=1
print(ct)

Measured memory_bytes: 25716
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Not
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x;
  scanf("%d", &x);
  printf("%d\n", x ^ 1);
  return 0;
}


Measured memory_bytes: 3816
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    string s;
    cin >> N >> s;

    vector<int> w(N+1, 0), b(N+1, 0);
    
    rep(i, N){
        w[i+1] += w[i] + (s[i] == '.' ? 1 : 0);
        b[i+1] += b[i] + (s[i] == '#' ? 1 : 0);
    }

    int ans = INF;
    rep(left, N+1){
        int sum = 0;

        sum += b[left] - b[0];
        sum += w[N] - w[left];

        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int N;
vector<int> g[212345];
double dp[212345], dp2[212345];

double dfs1(int u, int pre) {
	double res = 0.0;
	REP(i, g[u].size()) if (g[u][i] != pre)
		res += dfs1(g[u][i], u) + 1;
	
	if (g[u].size() > 1) res /= g[u].size() - 1;
	return dp[u] = res;
}

void dfs2(int u, int pre, double par) {
	double sum = 0.0;
	REP(i, g[u].size()) {
		if (g[u][i] == pre) sum += par + 1;
		else sum += dp[g[u][i]] + 1;
	}
	
	if (g[u].size() > 0) dp2[u] = sum / g[u].size();
	
	REP(i, g[u].size()) if (g[u][i] != pre) {
		double d = sum - (dp[g[u][i]] + 1);
		if (g[u].size() > 1) d /= g[u].size() - 1;
		dfs2(g[u][i], u, d);
	}
}

int main() {
	cin >> N;
	REP(i, N - 1) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	dfs1(0, -1);
	dfs2(0, -1, 0);
	
	REP(i, N) printf("%.15f\n", dp2[i]);
	
	return 0;
}


Measured memory_bytes: 21248
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    stack<int>S1;
    stack<pair<int,int> >S2;
    char ch;
    int sum = 0;
    for(int i = 0;cin >> ch;i++)
    {
        if(ch=='\\')S1.push(i);
        else if(ch=='/'&&S1.size() > 0)
        {
            int j = S1.top();
            S1.pop();
            sum += i - j;
            int a = i - j;
            while(S2.size() > 0 && S2.top().first > j){
                a+=S2.top().second;
                S2.pop();
            }
            S2.push(make_pair(j,a));
        }
    }
    vector<int>ans;
    while(S2.size() > 0)
    {
        ans.push_back(S2.top().second);
        S2.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0;i < ans.size();i++)
    {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
}



Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#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()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    for(int c=0;c<n;c++){
        string in; cin>>in;
        cout<<"Case "<<c+1<<":"<<endl;
        rep(i,10){
                    int num=pow(stoi(in),2);
                    in=to_string(num);

                string t;
                int cnt=in.size();
                while(cnt++ <8)t.push_back('0');
                t+=in;
                string ans; for(int i=2;i<=5;i++){
                    ans.push_back(t[i]);
                }
                cout<<stoi(ans)<<endl;
            in=ans;
        }
    }
}

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

using namespace std;
bool isPrime(int n)  
{
    if (n <= 1)  return false;  
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (int i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
}  

int nextPrime(int N) 
{
    if (N <= 1) 
        return 2; 
    int prime = N - 1; 
    bool found = false;
    while (!found) { 
        prime++; 
        if (isPrime(prime)) 
            found = true; 
    } 
  
    return prime; 
} 

int main() {
    int n; cin >> n;
    cout << nextPrime(n) << "\n";
}

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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    ll x; cin >> x;
    ll y = 100;
    ll cnt = 0;
    while(1){
        y += (y / 100);
        cnt++;
        if(x <= y) break;
    }
    cout << cnt << endl;
}


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

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

int main(){
    int n, ini;
    cin >> n >> ini;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    
    int ans = abs(x[0]-ini);
    rep(i, n) {
        ans = gcd(ans, abs(ini-x[i]));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<ll> x(n), y(n);
    rep(n) cin >> x[i] >> y[i];

    ll ans = LLONG_MAX;
    rep(n-1){
        reppp(ii, i+1, n-1){
            ll xmin = min(x[i], x[ii]), xmax = max(x[i], x[ii]);
            repp(j, n-1){
                reppp(jj, j+1, n-1){
                    ll ymin = min(y[j], y[jj]), ymax = max(y[j], y[jj]);
                    int cnt = 0;
                    repp(k, n){
                        if(xmin <= x[k] && x[k] <= xmax && ymin <= y[k] && y[k] <= ymax) cnt++;
                    }
                    if(cnt >= m) ans = min(ans, (ymax-ymin)*(xmax-xmin));
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long n = long.Parse(input[0]);
		long m = long.Parse(input[1]);
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] sums = new long[n+1];
    long answer = 0;

    for(int i = 0; i < n; i++)
    {
      sums[i+1] += sums[i] + nums[i];
      sums[i+1] %= m;
    }
    Array.Sort(sums);//ソート
    long memo = 1;

    for(int i = 1; i <= n; i++)
    {
      if(sums[i] == sums[i-1])
      {
        answer += memo;
        memo++;
      }
      else memo = 1;
    }
    
		Console.WriteLine(answer);
	}
}


Measured memory_bytes: 19936
import math
a,b,x=map(float,input().split())
h=2*x/(a*b)
if(h>a):
    s=a*a*b-x
    d=2*s/(a*a)
    print(180/math.pi*math.atan(d/a))
else:
    print(90-180/math.pi*math.atan(h/b))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int p=1e9+7;
int mx,n,m,k,i,j,nt,pr,s,ns,ans,x,y,w,a[22][22],f[2][1200010];
int lowbit(int x){
	return x&(-x);
}
int main(){
	scanf("%d%d%d",&n,&m,&k);n--;
	for(i=1;i<=k;i++){
		scanf("%d%d%d",&x,&y,&w);
		a[x][y-1]=w+1;
	}
	mx=1<<n;
	f[0][0]=1;
	for(i=1;i<=m;i++){
		for(j=0;j<n;j++){
			nt^=1;pr=nt^1;
			memset(f[nt],0,sizeof(f[nt]));
			for(s=0;s<mx;s++)if(f[pr][s]){
				if((s&(1<<j))==0&&a[i][j]!=2)f[nt][s]=(f[nt][s]+f[pr][s])%p;
				if(a[i][j]!=1){
					if(s&(1<<j))ns=s;
					 else{
					 	int tmp=((-1)^((1<<(j+1))-1))&s,Ds=!tmp?0:lowbit(tmp);
                            ns=s^(1<<j)^Ds;
					 }
					 f[nt][ns]=(f[nt][ns]+f[pr][s])%p;
				}
			}
		}
	}
	for(s=0;s<mx;s++)ans=(ans+f[nt][s])%p;
	printf("%d",ans);
}

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

using namespace std;

void solve() {
    string s;
    cin >> s;
    string ans = "";
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == 'B')
        {
            if (ans.length() > 0)
            {
                ans.pop_back();
            }
        }
        else
        {
            ans += s[i];
        }
    }
    cout << ans << endl;
    
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  
  int ans=1,ansx=0;
  for(int i=1;i<=N;i++){
    int x=i;
    int count=0;
    for(;;){
      if(x%2==0){
        count++;
        x/=2;
      }
      else  break;
    }
    if(ansx < count){
      ansx=count;
      ans=i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long mod=1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    
    vector<int>ana(n+1,true); //全部の階段にtrueを入れる。
    for(int i=0;i<m;i++){
        int a;
        cin >> a;
        ana[a]=false; //穴抜けの階段にfalseを入れる
    }
    
    vector<long long int>b(n+1);
    b[0]=1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(n,i+2);j++){ //最後だけ1通りになる。
            if(ana[j]){
                b[j]+=b[i];
                b[j]%=mod;
            }
        }
    }
    
    cout << b[n] << endl;
    return 0;
}

Measured memory_bytes: 1408
n = int(raw_input())
tp = 0; hp = 0
for i in range(n):
    tw,hw = raw_input().split()
    if tw == hw:
        tp += 1
        hp += 1
    elif tw > hw:
        tp += 3
    elif tw < hw:
        hp += 3
print '%s %s' % (tp,hp)

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

using namespace std;

bool isTriangle(int i, int j, int k){
	return (i+j>k)&&(j+k>i)&&(k+i>j);
}

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  int ans = 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(v[i]!=v[j] && v[j]!=v[k] && v[k]!=v[i] && isTriangle(v[i], v[j], v[k])){
          ans++;
        }
      }
    }
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(void) {
	char c, a[5] = { 'a','i','u','e','o' }, f = 0;
	cin >> c;
	for (int i = 0; i < 5; i++)
		if (a[i] == c) f = 1;
	cout << (f == 1 ? "vowel" : "consonant") << endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    ans = 0
    li = [0, 0, 0, 0]
    for _ in range(int(input())):
        s = input()
        ans += s.count("AB")
        flg = 0
        if s[0] == 'B':
            flg = 1
        if s[-1] == 'A':
            flg += 2
        li[flg] += 1
    if li[3] > 0:
        if li[1] > 0:
            ans += 1
            li[1] -= 1
        if li[2] > 0:
            ans += 1
            li[2] -= 1
        ans += li[3] - 1
    print(ans + min(li[1], li[2]))
solve()


Measured memory_bytes: 3064
import sys
from collections import deque

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

edges = [[] for _ in range(N)]
for _ in range(M):
    l, r, d = map(int, sys.stdin.readline().split())
    edges[l-1].append((r-1, d))
    edges[r-1].append((l-1, -d))

visited = {}
# その人へのパスが複数あり、距離が異なる場合は矛盾
for i in range(N):
    if i in visited:
        continue

    # 連結グラフごとに相対的な距離を決定
    # dist = [0 for _ in range(N)]
    q = deque([(i, 0)])
    while q:
        l, c = q.popleft()
        if l in visited:
            if visited[l] != c:
                print("No")
                sys.exit()
            continue
        
        visited[l] = c
        # dist[l] = c

        for r, nd in edges[l]:
            q.append((r, c+nd))
    # print(dist)

print("Yes")

Measured memory_bytes: 101444
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

vi a = {3,5,7};

void dfs (vi &v, int n, ll num = 0, ll mul = 1){

  for(int i : a){
    ll nnum = num + i*mul;
    ll nmul = mul*10;
    if(nnum > n) continue;
    v.push_back(nnum);
    dfs(v, n, nnum, nmul);
  }
}

int main(){
  int n, ans = 0; cin >> n;
  vi v;
  dfs(v,n);
  rep(i, v.size()){
    string s = to_string(v[i]);
    
    int check[10] = {0};
    rep(j, s.size()) check[s[j]-'0'] = 1;
    if(check[3] && check[5] && check[7]) ans++;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    int n;
    double d,x,y;
    int sum = 0;

    cin >> n >> d;

    for(int i = 0; i < n; i++){
        cin >> x >> y;
        if(x*x + y*y <= d*d)sum++; 
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3784
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	string s;
	cin >> s;
	string a = s;
	long long int ans = 0;
	long long int t = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B')t++;
		else {
			ans += t;
		}
	}
	cout << ans << endl;
	return 0;


}

Measured memory_bytes: 1284
#include <stdio.h>

int main(void) {
	int A, B, C;
	if (scanf("%d%d%d", &A, &B, &C) != 3) return 1;
	if (A <= C && C <= B) puts("Yes");
	else if (B <= C && C <= A) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    double a[55] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = 1; i < n; i++) a[i] = (a[i - 1] + a[i]) / 2;
    cout << a[n - 1];
}


Measured memory_bytes: 3780
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = Integer.parseInt(sc.next());
		long total = 0;
		
		for(int i = 1; i <= N ;i++){
			if(i % 3 != 0 && i % 5 != 0){
				total += i;
			}
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 35468
#include<iostream>
using namespace std;
int main() {
	int a, b, temp=0;
	int i=0,ans=0;

	cin >> a>>b;
	while (1) {
		i++;
		ans += i;
		if (ans - temp == b - a)break;
		temp = ans;
	}
	cout <<ans-b<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){

    int n, h, w; cin >> n >> h >> w;
    vector<int> imos_x(h + 2, 0);
    vector<int> imos_y(w + 2, 0);

    for(int i = 0; i < n; i++){
        int x, y, l; cin >> x >> y >> l;
        int lx = max(0LL, x - l);
        int rx = min(h, x + l);
        int ly = max(0LL, y - l);
        int ry = min(w, y + l);
        imos_x[lx]++;
        imos_x[rx]--;
        imos_y[ly]++;
        imos_y[ry]--;
    }

    for(int i = 1; i <= h; i++) imos_x[i] += imos_x[i - 1];
    for(int i = 1; i <= w; i++) imos_y[i] += imos_y[i - 1];

    bool flag1 = true;

    bool flag2 = true;
    for(int i = 0; i < h; i++) if(imos_x[i] <= 0) flag1 = false;
    for(int i = 0; i < w; i++) if(imos_y[i] <= 0) flag2 = false;
    

    if(flag1 || flag2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}




Measured memory_bytes: 4432
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
char buf[1<<12],*p1=buf,*p2=buf,nc;int ny;
inline char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}int a,b,c,d,k;
inline bool chk(int x){int A=a-x/(k+1)*k-x%(k+1),B=b-x/(k+1);return B<=1ll*A*k;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	for(int t=read();t;t--){
		a=read(),b=read(),c=read(),d=read(),k=(a+b)/(min(a,b)+1);
		int l=0,r=a+b,ans=0;
		for(int mid;l<r;)(chk(mid=l+r>>1)?l=mid+1:r=mid);ans=l;
		int A=a-ans/(k+1)*k-ans%(k+1),B=b-ans/(k+1),tmp=ans+1+B-A*k;
		Rep(i,c,d)if(i<=ans)putchar(i%(k+1)?'A':'B');else putchar((i-tmp)%(k+1)?'B':'A');puts("");
	}
	return 0;
}




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

int main(){
	int a,b;
	cin >> a >> b;
	string ans = "Yay!";

	if(a>8 || b > 8){
		ans = ":(";
	}
	cout << ans << endl;

	return 0;


}




Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include<numeric>

using namespace std;

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

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

int main() {
    int A,B;
    cin>>A>>B;
    if(A==1)A=A+13;
    if(B==1)B=B+13;
    if(A>B)cout<<"Alice"<<endl;
    if(A<B)cout<<"Bob"<<endl;
    if(A==B)cout<<"Draw"<<endl;
    return 0;
}

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


using namespace std;


int main(){
  string str;
  while(cin >> str){
    //    cout << str << endl;
    string strtmp;
    for(int i=0;i<str.size();i++){
      strtmp.push_back(str[str.size()-1-i]);
    }
    cout << strtmp << endl;
  }

} 

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

int main(void)
{
  char moji[20],ans[20]="\0";
  scanf("%s",moji);
  
  for(int i = 0;i < strlen(moji);i++)
  {
    if(moji[i] == 'B')
    {
      ans[strlen(ans)-1] = '\0';
    }else
    {
      ans[strlen(ans)] = moji[i];
    }
  }
  printf("%s",ans);
  return 0;
}


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

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

  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int num_a, num_b, answer;
char operator;

int main() {
	for (;;) {
		scanf("%d %c %d", &num_a, &operator, &num_b);
		if (operator == '?') break;
		switch (operator) {
		case '+':
			answer = num_a + num_b;
			break;
		case '-':
			answer = num_a - num_b;
			break;
		case '*':
			answer = num_a * num_b;
			break;
		case '/':
			answer = num_a / num_b;
			break;
		}
		printf("%d\n", answer);
	}

	return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
ll ans[500010];
ll cnt[500010];
ll a[500010];
priority_queue<ll,vector<ll>,greater<ll> > q;
priority_queue<ll,vector<ll>,greater<ll> > p;
ll n;
void run(){
	cin>>n;
	for(int i=0;i<3*n;i++)cin>>a[i];
	ll sum=0;
	for(int i=0;i<n;i++){
		sum+=a[i];
		q.push(a[i]);
	}
	ans[n-1]=sum;
	for(int i=n;i<2*n;i++){
		sum+=a[i];
		q.push(a[i]);
		sum-=q.top();
		q.pop();
		ans[i]=sum;
	}
	sum=0;
	for(int i=3*n-1;i>=2*n;i--){
		sum+=a[i];
		p.push(-a[i]);
	}
	cnt[2*n]=sum;
	for(int i=2*n-1;i>=n;i--){
		sum+=a[i];
		p.push(-a[i]);
		sum-=-p.top();
		p.pop();
		cnt[i]=sum;
	}
	ll mx=-LLINF;
	for(int i=n-1;i<2*n;i++){
		mx=max(mx,ans[i]-cnt[i+1]);
	}
	cout<<mx<<endl;
}
int main(){
	run();
	return 0;
}


Measured memory_bytes: 10100
N=int(input())
F=[int(input().replace(" ",""),2) for i in range(N)]
P=[list(map(int,input().split())) for j in range(N)]
print(max(sum([p[bin(i&f).count("1")] for f,p in zip(F,P)]) for i in range(1,2**10)))

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <math.h>
#include <string>
#include <stdlib.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mset(a, b) memset(a, b, sizeof(a))
#define LL long long
#define P pair<int, int>
using namespace std;
const int MAX = 1e5 +5;

int main()
{
    string s;
    cin >> s;
    if(s[0] == s[1] || s[1] == s[2] || s[3] == s[2])
        cout << "Bad" <<endl;
    else cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Bool
import Data.List
import qualified Data.Vector as V

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
readNInts = flip replicateM readInts

main :: IO ()
main = do
  [_, q] <- readInts
  s <- getLine
  lr <- readNInts q
  mapM_ print $ g lr $ f s

f :: String -> V.Vector Int
f = V.fromList . f' 0
  where
    f' :: Int -> String -> [Int]
    f' n [] = []
    f' n [_] = [n]
    f' n ('A':'C':xs) = n : n + 1 : f' (n + 1) xs
    f' n (x:xs) = n : f' n xs

g :: [[Int]] -> V.Vector Int -> [Int]
g [] _ = []
g ([l, r]:lr) xs = (xs V.! (r - 1)) - (xs V.! (l - 1)) : g lr xs

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

using namespace std;

int main() {

	string s;
	cin >> s;

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

	char a = 'a';
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != a) { cout << a << endl; return 0; }
		if (i != s.size() - 1) {
			if(s[i + 1] != a) { a++; }
		}
		else if (a != 'z') { cout << (char)(a + 1) << endl; return 0; }
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  rep(i, n) {
    rep(j, n) {
      if (i + j < n) {
        auto ss = s.substr(0, i);
        auto tt = s.substr(i + j, n);

        ss += tt;
        if (ss == "keyence") {
          cout << "YES" << endl;
          return 0;
        }
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv){
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

int main(void) {
	ll n; cin >> n;
	ll ans = (n)*(n-1)/2;
	out(ans);
}




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

int main(void)
{
    std::string S;
    std::cin >> S;

    bool flg = false;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] == S[i + 1]) {
            flg = true;
            break;
        }
    }
    if (flg == true) {
        std::cout << "Bad" << std::endl;
    } else {
        std::cout << "Good" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define INF 1e12
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int ns[9]={111,222,333,444,555,666,777,888,999};
	int n; cin>>n;
	int i;for(i=0;ns[i]<n;i++);
	cout<<ns[i]<<"\n";
	return 0;
}

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


int main() {
    int A,B;
    cin >> A >> B;
    int p = A/10000;
    int q = (A - p*10000)/1000;

    int r = B/10000;
    int s = (B - r*10000)/1000;
    int t = (A - p*10000 - q*1000)/100;
    //cout << t;
    int count=0;
    for(int i=p;i<=r;i++){
        for(int j=0;j<=9;j++){
            for(int k = 0;k<=9;k++){
                int ans = i*10000+ j*1000 + 100*k+j*10 + i;
                if(ans >=A && ans <=B) {
                    count++;
                }
            }
        }
    }
    cout << count <<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}

int main(){
    ll a,b; cin>>a>>b;
    ll c=gcd(a,b);
    cout<<a*b/c<<endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

code = input()

def isInt(c):
    try:
        int(c)
        return True
    except ValueError:
        return False

for i, c in enumerate(code):
    if i == a:
        if c != '-':
            print('No')
            exit()
    else:
        if not isInt(c):
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3188
#include <stdio.h>

int main(void)
{
	int i, j;
	int x[10000];
	
	for (i = 0; i < 10000; i++) {
		scanf("%d", &x[i]);
		if (x[i] == 0)
			break;
	}
	
	for (j = 0; j < i; j++) {
		printf("Case %d: %d\n", j + 1, x[j]);
	}
	
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using P = pair<int, int>;

int main() {
  int n, a;
  ll o = 0;
  scanf("%d", &n);
  set<P> p;
  for(int i = 0; i < n; i++) {
    scanf("%d", &a);
    if(i) {
      auto it = p.lower_bound(P(i - a, 0));
      if(it != p.end())
        if((*it).first == i - a) o += (*it).second;
    }
    auto it = p.lower_bound(P(i + a, 0));
    if(it == p.end())
      p.insert(P(a + i, 1));
    else if((*it).first != i + a)
      p.insert(P(a + i, 1));
    else {
      int nw = (*it).second + 1;
      p.erase(it);
      p.insert(P(a + i, nw));
    }
  }
  printf("%lld\n", o);
}

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

int main(){
  string s;
  cin>>s;
  for(int i=0;i<3;i++){
    if(s[i]=='1')cout<<'9';
    else{
      if(s[i]=='9')cout<<'1';
      else cout<<s[i];
    }
  }
  cout<<endl;
}


Measured memory_bytes: 256
gos = input()
ans = 0
longgo = len(gos)
whites = 0

for i in range(longgo):
    if gos[i] == 'W':
        ans += i
        whites += 1
    else:
        pass

def triangle(n):
    ret = 0
    i = n
    while (i > 0):
        ret += i
        i = i - 1
    return ret

print(ans - triangle(whites - 1))

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

int main(){
    int k, a, b;
    cin >> k >> a >> b;
    vector<int> ran(b-a+1);
    for(int i =0; i<ran.size(); i++) {
        ran.at(i) = a;
        a++;
    }
    bool ans=false;

    for(int i=0; i<ran.size(); i++){
        if(ran.at(i) % k == 0) ans = true;
    }

    if(ans) cout << "OK" << endl;
    else cout << "NG" << endl;
}

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

using namespace std;

int A[200002],B[200002];

int main(){
    int t=1;
//    cin >> t;
    while (t--) {
        int n, m ,ms;
        scanf("%d%d%d", &n, &m, &ms);
 
        for(int A_i = 0; A_i < n; A_i++){
            scanf("%d",&A[A_i]);
        }
        for(int B_i = 0; B_i < m; B_i++){
           scanf("%d",&B[B_i]);
        }

        long long sum = 0;
        int x = 0, y = 0;

        while (x < n && sum + A[x] <= ms) {
            sum += A[x++];
        }

        int ans = x;

        while (y < m && x >= 0) {
            sum += B[y++];
            while (sum > ms && x > 0) {
                sum -= A[--x];
            }

            if (sum <= ms && ans < x + y) {
                ans = x + y;
            }
        }

        printf("%d\n",ans);
    }
    return 0;
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}


int main(){
  ll n;

  cin>>n;

  map<ll, ll> m;
  ll tmp = 0;
  rep(i, n){
    cin>>tmp;
    rep(j, 3){
      m[tmp-1+j]++;
    }
  }
  ll ans = 0;
  tmp = 0;
  for(auto x:m){
    //cout << x.first<<" "<<x.second<<endl;
    if(x.second>tmp){
      ans = x.first;
      tmp = x.second;
    }
  }
  cout<<tmp<<endl;
}


Measured memory_bytes: 6144
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
    ll a, b, c, ans;
    cin >> a >> b >> c;
    if (a + b >= c)
        ans = b + c;
    else
        ans = a + 2 * min(b, c - a) + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		if((N & 1) == 1)System.out.println("No");
		else if(S.subSequence(0, (N / 2)).equals(S.subSequence((N / 2), N)))System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
constexpr long long mod1 = 1e9+7;
using namespace std;

vector<int> zalgo(string s){
  int i = 1, j = 0, n = s.size();
  vector<int> v(n);
  v[0] = n;
  while(i < n){
    while(i + j < n && s[j] == s[i+j]) ++j;
    v[i] = j;
    if(j == 0) ++i;
    else{
      int k = 1;
      while(k < j && k + v[k] < j){
        v[i+k] = v[k];
        ++k;
      }
      i += k;
      j -= k;
    }
  }
  return v;
}

int main(){
  int n, ans = 0; string s; cin >> n >> s;
  vector<vector<int>> v(n-1);
  vector<string> u(n-1);
  rep(i, n-1){
    string tmp = "";
    rep(j, n-i) tmp += s[i+j];
    u[i] = tmp;
  }
  rep(i, n-1) v[i] = zalgo(u[i]);
  rep(i, n-1) rep(j, v[i].size()) ans = max(ans, min(v[i][j], j));
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 73856
//Treasure Hunt ?
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

int main(){
  int n;
  while(cin>>n){
    if(n==-1)break;
    P a;
    real(a)=1.0; imag(a)=0.0;
    for(int i=1; i<n; i++){
      P u=(a*P(0, +1))/abs(a);
      a+=u;
    }
    printf("%.8f\n%.8f\n", real(a), imag(a));
  }
  return 0;
}

Measured memory_bytes: 1216