akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
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; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
int base;
bool valid(int k,int j,int w){return k * base + j + w <= W ;}
signed main(){
    int n;
    cin >> n >> W;
    vector<int>v(n),w(n);
    for(int i = 0; i < n; ++i){
        cin >> w[i] >> v[i];
    }
    base = w.front() - 1;
    auto dp = vectors(n,500,101, -INF);
    dp[0][0][0] = 0;
    dp[0][1][1] = (w.front() <= W ? v.front() : 0);
    rep(i,n-1)rep(j,301)rep(k,101){
        if(dp[i][j][k] == -INF)continue;
        cmax(dp[i+1][j][k],dp[i][j][k]);
        if(valid(k,j,w[i + 1]))
            cmax(dp[i+1][j + w[i+1] - base][k+1],dp[i][j][k] +v[i+1]);
    }
    int ans = -INF;
    rep(j,301)rep(k,101)if(dp[n-1][j][k] != -INF){
        cmax(ans,dp[n-1][j][k]);
    }
    cout << ans << endl;
}




Measured memory_bytes: 41728
using System;

namespace abc060_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split();
            Console.WriteLine(x[0][x[0].Length-1]==x[1][0]&&x[1][x[1].Length-1]==x[2][0]?"YES":"NO");
        }
    }
}

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

using namespace std;

int main()
{
    int32_t n, t;
    cin >> n >> t;

    vector<int32_t> v( n );
    for(auto& x : v) {
        cin >> x;
    }

    int64_t sum{ 0 };
    for(auto i = 1U; i < v.size(); ++i) {
        sum += min(t, v[i] - v[i - 1]);
    }

    sum += t;

    cout << sum << endl;
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	int amari = a % b,sum = 0;
	int count = 0;
	while (sum % b != c) {
		if (count == 1000) {
			P("NO");
			return;
		}
		sum += amari;
		count++;
	}
	P("YES");
}

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

Measured memory_bytes: 256
s = readline.chomp.to_i
h = {s => 1}

idx = 0
n = s

(2..1000000).each do |i|
  if n % 2 == 0
    n /= 2
  else
    n = 3*n + 1
  end
  #p n,i
  if h.has_key?(n)
    puts i
    break
  else
    h[n] = i
  end
end


Measured memory_bytes: 1788
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    s = list(input())

    s.reverse()

    devval = pow(10, 9) + 7

    dp = [[0 for i in range(13)] for i in range(100001)]

    # 初期値設定
    if s[0] == "?":
        for j in range(10):
            dp[0][j] += 1
    else:
        dp[0][int(s[0]) % 13] += 1

    # DP
    for i in range(1, len(s)):
        for j in range(10):
            if s[i] != "?" and s[i] != str(j):
                continue

            # ここを改善しないと無理。pow(10,100万)とか不可能・・。TLE・・。
            aaa = j * pow(10, i, 13)

            # 前DPの値を今DPに加算
            for k in range(13):
                dp[i][(aaa + k) % 13] = (dp[i][(aaa + k) % 13] + dp[i - 1][k] % devval) % devval

    # 余り5の要素数が答え
    print(dp[len(s) - 1][5])


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """??2??5"""
        output = """768"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """?44"""
        output = """1"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """7?4"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_4(self):
        test_input = """?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???"""
        output = """153716888"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def test_1original_1(self):
        test_input = """?"""
        output = """1"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 104432
#include <iostream>
#include<set>
#include <vector>
#include<algorithm>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 1e9
typedef long long int ll;

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

Measured memory_bytes: 256
<?php
        fscanf(STDIN, "%d", $d);
        switch ($d) {
        case 22:
            echo "Christmas Eve Eve Eve"."\n";
            break;
        case 23:
            echo "Christmas Eve Eve"."\n";
            break;
        case 24:
            echo "Christmas Eve"."\n";
            break;
        case 25:
            echo "Christmas"."\n";
            break;
    }
        ?>

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

int main() {
    vector<vector<int>> c(3, vector<int>(3));
    for (int j=0; j<3; ++j) {
        for (int i=0; i<3; ++i) {
            cin >> c[i][j];
        }
    }

    vector<int> a(3), b(3);
    for (int j=0; j<3; ++j) {
        b[j] = c[0][j];
    }
    for (int i=0; i<3; ++i) {
        a[i] = c[i][0] - b[0];
    }

    bool flag = true;
    for (int i=0; i<3; ++i) {
        if (flag != true) break;
        for (int j=0; j<3; ++j) {
            if (flag != true) break;
            if (c[i][j] != a[i] + b[j]) flag = false;
        }
    }

    if (flag == true) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
(let* ((n (read-line)))
  (if (and (string= n (reverse n))
           (string= (subseq n 0 (floor (length n) 2))
                    (reverse (subseq n 0 (floor (length n) 2))))
           (string= (subseq n (ceiling (length n) 2))
                    (reverse (subseq n (ceiling (length n) 2)))))
      (princ "Yes")
      (princ "No")))

Measured memory_bytes: 12260
using System;

namespace tes
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0,i=0;
            int[] x = new int[100000];
            int[] y = new int[100000];

            while (a < 20)
            {
                var line1 = Console.ReadLine().Split();

                x[i] = int.Parse(line1[0]);
                y[i] = int.Parse(line1[1]);
                if ((x[i] == 0) && (y[i] == 0))
                {
                    break;
                }
                i++;

            }

            for (int z = 0; z < i; z++)
            {
                if (x[z] < y[z])
                {
                    Console.WriteLine(x[z] + " " + y[z]);
                }
                else if (x[z] > y[z])
                {
                    Console.WriteLine(y[z] + " " + x[z]);
                }
                else
                {
                    Console.WriteLine(x[z] + " " + y[z]);
                }
            }


        }
    }
}

Measured memory_bytes: 10392
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
H = Counter(A)
K = {}

for k,v in H.items():
    K[k] = v*(v-1)//2
total = sum(K.values())

for i in A:
    print(total - K[i] + (H[i] - 1)*(H[i]-2)//2)

Measured memory_bytes: 96332
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; ++i) {
		while( n % i == 0 ) {
			res[i]++;
			n /= i;
		}
	}
	
	if( n != 1 ) res[n] = 1;

	return res;
}

int main(void) {
	ll n;
	cin >> n;

	map<int, int> mp;
	for(int i = 1; i <= n; ++i) {
		map<int, int> primef = prime_factor(i);
		
		for(auto& x : primef) {
			mp[x.first] += x.second;
		}
	}
	
	ll ans = 1LL;
	
	for(auto& v : mp) {
		ans *= (ll)(v.second + 1);
		ans %= MOD_LL;
	}
	
	cout << ans << endl; 
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<sstream>
#include<list>
#include<algorithm>
using namespace std;

int main(int argc,char* argv[]){
  std::ios_base::sync_with_stdio(false);
  int n,key;
  list<int> li;
  string str;
  list<int>::iterator itli;

  cin>>n;

  
  while(n--){
    cin>>str;

    if(str[6]=='F') li.pop_front();
    else if(str[6]=='L') li.pop_back();
    else{
      cin>>key;
      if(str[0]=='i')
	li.push_front(key);
      else{
	itli=find(li.begin(),li.end(),key);
	if(itli!=li.end())
	  li.erase(itli);
      }
    }
  }

  itli=li.begin();
  cout<<*itli++;
  while(itli!=li.end()){
    cout<<" "<<*itli++;
  }
  cout<<endl;
}

Measured memory_bytes: 32464
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Nans = combination(N);
        int Mans = combination(M);

		System.out.println(Nans + Mans);
	}
	public static int combination(int num){
        int ans = (num * (num - 1)) / 2;
		return ans;
	}
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
int main() {

    int A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    for(;A%2==0 && B%2==0 && C%2==0 && A!=0;ans++){
        int tmpA = B/2 + C/2;
        int tmpB = A/2 + C/2;
        int tmpC = A/2 + B/2;
        A = tmpA;
        B = tmpB;
        C = tmpC;
        if(A==B && B==C){
            ans = -1;
            break;
        }
    }
    

    cout << ans << endl;

    return 0;

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

  int n;
  while(true){
      cin>>n;
      if(n==0) break;
      std::vector<string> v(n);
      for(int i=0;i<n;i++){
          cin>>v[i];
      }
      int tanku[5]={5,7,5,7,7};
      for(int i=0;i<n-1;i++){
          int cnt=0,idx=0;
          for(int j=0;i+j<n;j++){
              cnt+=v[i+j].length();
              //cout<<cnt<<" "<<idx<<endl;
              if(cnt<tanku[idx]) continue;
              else if(cnt==tanku[idx]){
                  idx++;
                  cnt=0;
              }
              else{
                  break;
              }
          }
          if(idx==5){
              cout<<i+1<<endl;
              break;
          }
      }
  }
  return 0;
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;
static const int N = 10;
int main(){
  int H,i,j,k,l,com,cnt,start,score,flag;//com=compare
  char c;
  string str[N],cp[N];
  while(1){
    score=0;
    cin >> H;
    if(H==0) break;
    for(i=0;i<H;i++){
      str[i]="";
      for(j=0;j<5;j++){
	cin >> c;
	str[i]+=c;
      }
    }
    while(1){
      for(i=0;i<H;i++){
	cnt=0;
	com=str[i][0];
	start=0;
	for(j=0;j<5;j++){
	  if(com==str[i][j]) cnt++;
	  else{
	    if(cnt>=3){
	      if(com!='e'){
		score+=cnt*(com-'0');
	      }
	      for(k=start;k<=j-1;k++){
		str[i][k]='e';//e=end
	      }
	      com=str[i][j];
	      start=j;
	      cnt=1;
	    }else{
	      com=str[i][j];
	      start=j;
	      cnt=1;
	    }
	  }
	}
	if(cnt>=3){
	  if(com!='e'){
	    score+=cnt*(com-'0');
	  }
	  for(k=start;k<=j;k++){
	    str[i][k]='e';//e=end
	  }
	}
      }
      for(i=0;i<5;i++){
	for(j=H-1;j>=0;j--){
	  if(j-1>=0&&str[j][i]=='e'){
	    l=j;
	    while(1){
	      l--;
	      if(l==-1) break;
	      if(str[l][i]!='e'){
		str[j][i]=str[l][i];
		str[l][i]='e';
		break;
	      }
	    }
	  }
	}
      }
      flag=0;
      for(i=0;i<H;i++) if(cp[i]!=str[i]) flag=1;
      if(flag==0) break;
      for(i=0;i<H;i++) cp[i]=str[i];
    }
    cout << score << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;
typedef long long ll;

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

string s;

void solve(ll mo){
    ll ch = 0;
    bool dot = false;
    for(int i = 0; i < s.length(); i++){
        if(dot) mo *= 10;
        if(s[i] == '.') dot = true;
        else            ch = 10*ch + s[i]-'0';
    }
    ll g = gcd(ch, mo);
    ch /= g, mo /= g;
    printf("%lld/%lld\n", ch, mo);
}

int main(){
    cin >> s;
    int pos;
    for(pos = 0; pos < s.length(); pos++)   if(s[pos] == '(')   break;
    if(pos < s.length()){
        string t = "", u = "";
        ll tmp = 1;
        for(int i = 0; i < s.length()-pos-2; i++)   tmp *= 10;
        for(int i = 0; i < s.length()-1; i++){
            if(s[i] != '(') t += s[i];
            if(i < pos) u += s[i];
        }
        double a = stod(t) * tmp, b = stod(u);
        double c = a-b;
        tmp--;
        s = to_string(c);
        solve(tmp);
    }else{
        solve(1);
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

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

	string ans;
	while(1) {
		--n;
		ans.push_back('a' + n % 26);
		n /= 26;
		if (n == 0) {
			break;
		}
	}
	reverse(ans.begin(), ans.end());
	out(ans);
    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, z;
	cin >> x >> y >> z;
	cout << z <<" "<< x<<" " << y;
}

Measured memory_bytes: 256
n=int(input())
s=input()
left=[0]*(n+1)
right=[0]*(n+1)
for i in range(n):
    if s[i]=="W":
        left[i+1]=left[i]+1
    else:
        left[i+1]=left[i]
 
for i in range(n-1,0,-1):
    if s[i]=="E":
        right[i-1]=right[i]+1
    else:
        right[i-1]=right[i]
#print(left)
#print(right)
print(min([left[i]+right[i] for i in range(n)]))

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

const int INF = 1 << 30;

int a[100001];
int dp[100001];

int main() {
    int n, i;
    cin >> n;
    for (i = 0; i < n; i++) cin >> a[i];
    dp[0] = 0;
    for (i = 1; i < n; i++) dp[i] = INF;
    for (i = 0; i < n-1; i++) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(a[i] - a[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(a[i] - a[i+2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,k;cin>>a>>b>>k;
  if(k<=a)cout<<a-k<<' '<<b<<endl;
  else if(k<=a+b)cout<<0<<' '<<a+b-k<<endl;
  else cout<<"0 0"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n,m;
ll x[1000];
ll y[1000];
ll z[1000];

int main(){
    cin >> n >> m;
    rep(i,n)cin >> x[i] >> y[i] >> z[i];
    ll ans = -INF;
    rep(i,2){
        rep(j,2){
            rep(k,2){
                vector<ll> v;
                rep(ii,n){
                    ll sum = 0;
                    sum += (i==0 ? x[ii] : -x[ii]);
                    sum += (j==0 ? y[ii] : -y[ii]);
                    sum += (k==0 ? z[ii] : -z[ii]);
                    v.push_back(sum);
                }
                sort(ALL(v));
                reverse(ALL(v));
                ll s = 0;
                rep(ii,m)s += v[ii];
                ans = max(ans,s);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef int ss;
#define int long long

typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N, K;
ll A[200000],B[200000],C[2000000];
ll a;
ll cnt[26];
string s;
ll mod = 1000000007;

ss main()
{
  ll N;
  cin>>N;
  cin>>s;
  rep(i, s.size()){
    ll x = s[i] - 'a';
    cnt[x]++;
  }
  ll ans = 1;
  rep(i,26){
    ans = (ans * (cnt[i] + 1))%mod;
  }
  ans--;
  ans = (ans +mod)%mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

vector<bool> isprime;
vector<int> Era(int n) {
    isprime.resize(n, true);
    vector<int> res;
    isprime[0] = false; isprime[1] = false;
    for (int i = 2; i < n; ++i) isprime[i] = true;
    for (int i = 2; i < n; ++i) {
        if (isprime[i]) {
            res.push_back(i);
            for (int j = i*2; j < n; j += i) isprime[j] = false;
        }
    }
    return res;
}

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

	auto v = Era(202020);
	int x;
	cin >> x;

	while(!isprime[x]) x++;
	cout << x << endl;
}	


Measured memory_bytes: 512
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int x, y;
  readf (" %d %d", &x, &y);
  auto a = [x, y];
  int r;
  foreach (i; a) {
    if (i == 3) r++;
    if (i == 2) r+=2;
    if (i == 1) r+=3;
  }
  if (a.all!"a == 1") r += 4;
  writeln(r * 100_000);
}



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



int main() 
{
    int n;
    cin >> n;
    if(n%2==0)
    {
        cout << 0.5 << endl;
    }
    else
    {
        int a = n / 2;
        int b = n / 2 + 1;
        cout << (double(b)/double(n)) << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n'
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
	int k;
	cin>>k;
	int ans = 0;
	if(k%2==0)
	{
		ans = (k/2)*(k/2);
	}
	else 
	{
		k /= 2;
		ans = k*(k+1);
	}
	cout<<ans;
}


Measured memory_bytes: 256
// 2020-09-27 19:10:13
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  while (k > 0 && a >= b) {
    b *= 2;
    k--;
  }
  while (k > 0 && b >= c) {
    c *= 2;
    k--;
  }
  if (a < b && b < c) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3688
#include<vector>
#include"iostream"
#include"algorithm"
#include<random>
#include<string>
#include<map>
using namespace std;
#define int long long
typedef pair<int, int> P;
#define REP(i,n) for(int i=0;i<n;i++)

int digit(int a) {
	int res = 0;
	while (a) {
		res += a % 10; a /= 10;
	}
	return res;
}

signed main() {
	int n; cin >> n;
	int ans = 1145141919;
	for (int i = 1; i < n; i++) {
		int r = digit(i) + digit(n - i);
		ans = min(ans, r);
	}
	cout << ans << endl;
}

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

const double PI=acos(-1.0);

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int ans = 0;
    while(true) {
        bool can = true;
        rep(i, n) {
            if(a[i] % 2 != 0) can = false;
            a[i] /= 2;
        }
        if(!can) break;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,c,l,ll=0;
cin>>n>>c;
int t=1;
for(int i=0;i<n;i++)
{
    cin>>l;
    ll=ll+l;
    if(ll<=c)
    {
        t++;
    }
}
cout<<t<<endl;
}



Measured memory_bytes: 256
def main():
    n, threshould = [int(x) for x in input().split()]

    def gen():
        for _ in range(n):
            dist = sum(int(x) ** 2 for x in input().split())
            yield dist <= threshould ** 2

    print(sum(gen()))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9076
// ABC 50 B

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

typedef long long ll;

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; }
const long long INF = 1LL<<60;

int main() {
  int n, m;
  cin >> n;

  vector<int> t(n);

  rep(i, n) {
    cin >> t[i];
  }

  ll sum = accumulate(t.begin(), t.end(), 0LL);

  cin >> m;
  rep(i, m) {
    int p, x;
    cin >> p >> x;
    cout << sum - t[p-1] + x << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int a;
	string s;
	
	cin >> a >> s;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define for0(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{
  char car;
  int tab[2]={0};

for (int i =0 ; i<3 ; i++ ){
  cin >> car ;
  if(car=='A')tab[0]++;
  else tab[1]++;
}
if(tab[0]==3 || tab[1]==3 ) {
  cout << "No" ;
  return 0 ;
}
cout <<"Yes";



  return 0 ;
}


Measured memory_bytes: 256
n=int(input())
alf = list("abcdefghijklmnopqrstuvwxyz")
ans=""
i=0
while n-26**i>=0:
  n-=26**i
  i+=1

for j in range(i):
  n,b=divmod(n,26)
  ans+=str(alf[b])
print(ans[::-1])

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

int main(){
    int K;
    string S;
    cin >> K >> S;
    int si = S.size();
    if(K>=si) cout << S << endl;
    else{
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let s: String = read();
    let s: Vec<u8> = s.into_bytes();
    let k: i64 = read();
    let n = s.len();
    for i in 0..n {
        if s[i] == b'1' {
            if (i as i64) == k-1 {
                println!("1");
                break;
            }
        } else {
            println!("{}", s[i] as char);
            break;
        }
    }
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	public static void main(String[] arg)throws IOException{
		 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		 //今回の問題では求められていないが、こんな説明があると入力する側も理解しやすい。
		 //System.out.println("数値を２種類、半角スペースを開けて入力してください。");
		 //System.out.println("面積、周の長さが順番に表示されます。");

		 //br.readline(); = 入力された１行分を日本語変換して返してくれる。
		 String str = br.readLine();

		 //配列の型(intとかStringとか) [] 配列名 = 配列を用意
		 //今回はstrAryって配列にstrを入れてる。
		 //str.split = splitってのはString内に用意されてるメソッド
		 //文字列を分割するときに使用。今回は空白で区切ってって仕様なので
		 //split(" ")としてます。
		 String[] strAry = str.split(" ");

		 //おなじみの文字列から数値への変換。
		 //ただし今回は指定先が配列の何番って風になってる。
		 int x =  Integer.parseInt(strAry[0]);
		 int y =  Integer.parseInt(strAry[1]);

		 //いつも通りの出力。面積と周の長さを表示してる。
		 //出力も１つの空白で区切って１行と指示があるのでこんな具合に。
		 System.out.println(x*y + " " + 2*(x+y));
    }
}

Measured memory_bytes: 16900
#include <bits/stdc++.h> 
using namespace std; 
int main()
{
  string n;
  cin>>n;
  long long int sum=0;
  for(int i=0;i<n.size();i++)
  {
    int k = n[i]-'0';
    sum+=k;
  }
  if(sum%9==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 3748
from math import sqrt
itl = lambda: list(map(float, input().strip().split()))


def solve():
    N = int(input())
    if N == 1:
        return 0

    ans = 0
    for i in range(2, int(sqrt(N)) + 1):
        nxt = 1
        count = 0
        while N % i == 0:
            N //= i
            count += 1
            if count == nxt:
                count = 0
                ans += 1
                nxt += 1
    if N > int(sqrt(N)):
        ans += 1        
    return ans

 
if __name__ == '__main__':
    print(solve())

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


def main():
    n = int(input())
    a = list(map(int, input().split()))
    odd_patterns = 1

    for ai in a:
        if ai % 2 == 0:
            odd_patterns *= 2

    print(3 ** n - odd_patterns)


if __name__ == '__main__':
    main()


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

int main() {
   int a,b,c;
    cin >> a >> b;
    if(a<=9 && b<=9)
        {
            c=a*b;
            cout << c;
        }
   else
   {
       cout << "-1";
   }
                    
       
        return 0;
        
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
Pi a[100100];

int main(){
	cin>>n;
	REP(i,n){
		int a1;
		cin>>a1;
		a[i]=Pi(a1,i);
	}
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n;i+=2){
		if(a[i].second%2==1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
// Problem : C - Connect Cities
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
    T f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 100003, M = N << 1;

int n, fa[N], m;

int getf(int u)
{
	if (fa[u] == u) return u;
	return fa[u] = getf(fa[u]);
}

int main()
{
    //File("");
    n = gi <int> (), m = gi <int> ();
    for (int i = 1; i <= n; i+=1) fa[i] = i;
    for (int i = 1; i <= m; i+=1)
    {
    	int u = gi <int> (), v = gi <int> ();
    	fa[getf(u)] = getf(v);
    }
    set <int> s;
    for (int i = 1; i <= n; i+=1) s.insert(getf(i));
    cout << s.size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 7948
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
using ll=long long;
const ll MOD=1000003;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=b-1;i>=a;i--)
#define range(i) (i).begin(),(i).end()
#define rrange(i) (i).rbegin(),(i).rend()
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
inline constexpr int modf(ll n){
    ll ans=1;
    rep(i,0,n) {ans=ans*(n-i)%MOD;}
    return ans;
}
inline long double median(vector<ll> v){
    ll size=v.size();
    sort(v.begin(),v.end());
    if (size % 2 == 1) return v[(size - 1) / 2];
    else return v[(size / 2) - 1] ;
}
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;}
template<class T,class L>ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}

int main(){
 double w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<setprecision(15)<<w*h/2<<' ';
  if(x==w/2&&y==h/2) cout<<1;
  else cout<<0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
long long int gcd(long long int n, long long int m){
	long long int tmp;
	if (m< n){
		tmp = m;
		m = n;
		n = tmp;
	}
	long long int r = m%n;
	while (r != 0){
		m = n;
		n = r;
		r = m%n;
	}
	return n;
}
long long int LCM(long long int n, long long int m){
	long long int g=gcd(n,m);
	return (n/g)*m;
}

int main(){
	int n;
	long long int t[1000], lcm[1000];
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> t[i];
		if (i == 1){
			lcm[1] = t[1];
		}
		if (i >= 2){
			lcm[i] = LCM(lcm[i - 1], t[i]);
		}
	}
	cout << lcm[n] << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/

int main(){
    int n,m;cin>>n>>m;
    V a(m);rep(i,m)cin>>a[i];
    vector<bool> safe(n+1,true);
    rep(i,m){
        safe[a[i]]=false;
    }
    V dp(n+1,0);
    //dp[i]:i番目の階段にくることのできる場合の数
    dp[0]=1;
    REP(i,n){
        if(i==1){
            if(safe[i])dp[i]=1;
        }
        else{
            if(safe[i-2]){
                dp[i]+=dp[i-2];
            }
            if(safe[i-1]){
                dp[i]+=dp[i-1];
            }
            dp[i]%=MOD;
        }
        //printf("dp[%d]=%d\n",i,dp[i]);
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
#include<iostream>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;


bool strcmp_ignore(string s1, string s2) {
  int i;
  if (s1.length() != s2.length()) return false;
  rep(i, s1.length()) if (toupper(s1[i]) != toupper(s2[i])) return false; 
  return true;
}

int main () {
  string W, T;
  int count = 0;
  cin >> W;
  while (1) {
    cin >> T;
    if (T == "END_OF_TEXT") break;
    if (strcmp_ignore(W,T)) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	ll f[50][50] = {};
	rep(i,N){
		string s; cin >> s;
		ll v = 0;
		int after = 0;
		rep(i,si(s)){
			char c = s[i];
			if(c == '.'){
				after = si(s)-1-i;
			}else{
				v = v*10 + (c-'0');
			}
		}
		while(after != 9){
			v *= 10;
			after++;
		}
		int a2 = 0, a5 = 0;
		while(v%2==0){
			a2++;
			v/=2;
		}
		while(v%5==0){
			a5++;
			v/=5;
		}
		f[a2][a5]++;
	}
	ll ans = 0;
	rep(i,50) rep(j,50) rep(k,50) rep(l,50){
		if(i+k>=18 && j+l>=18){
			if(i==k && j==l){
				ans += f[i][j] * (f[i][j]-1);
			}else{
				ans += f[i][j] * f[k][l];
			}
		}
	}
	cout << ans/2 << endl;
	
}


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

int main(int argc, char const *argv[]) {
    /* code */
    string W, input;
    int cnt = 0;

    cin >> W;
    while (cin >> input) {
        if (input == "END_OF_TEXT") {
            break;
        }
        // 大文字化
        transform(W.begin(), W.end(), W.begin(), ::toupper);
        transform(input.begin(), input.end(), input.begin(), ::toupper);

        if (input == W) {
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3176
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int N;
	cin >> N;
	int a[50];

	int max_num = 0, min_num = mod;
	int max_ix, min_ix;
	REP(i, N) {
		cin >> a[i];
		if (max_num < a[i]) {
			max_num = a[i];
			max_ix = i;
		}
		if (min_num > a[i]) {
			min_num = a[i];
			min_ix = i;
		}
	}
	bool sign_p = true;
	if (min_num < 0 && max_num > 0) {
		cout << 2*N - 1 << endl;

		if (max_num > abs(min_num)) {
			REP(i, N) {
				a[i] += max_num;
				cout << max_ix+1 << " " << i+1 << endl;
			}
		}
		else {
			REP(i, N) {
				a[i] += min_num;
				cout << min_ix+1 << " " << i+1 << endl;
			}
			sign_p = false;
		}
	}
	else {
		cout << N - 1 << endl;
		if (max_num <= 0) sign_p = false;
	}

	if (sign_p) {
		REP(i, N - 1) {
			cout << i+1 << " "<< i + 2 << endl;
		}
	}
	else {
		for (int i = N - 1; i > 0; --i) {
			cout << i+1 << " " << i << endl;
		}
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>

using namespace std;

int main(void){
    int r, c;
    cin >> r >> c;
    int cell[r+1][c+1];
    int sum_r, sum_c;
    for (int i = 0; i < r; i++) {
        sum_r = 0;
        for (int j = 0; j < c; j++) {
            cin >> cell[i][j];
            sum_r += cell[i][j];
        }
        cell[i][c] = sum_r;
    }
    for (int i = 0; i <= c; i++) {
        sum_c = 0;
        for (int j = 0; j < r; j++) {
            sum_c += cell[j][i];
        }
        cell[r][i] = sum_c;
    }
    for (int i = 0; i <= r; i++) {
        for (int j = 0; j <= c; j++) {
            cout << cell[i][j];
            if (j < c) cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 1196
def check(s,i,j,h,w):
    if i > 0 and s[i-1][j] == '#':
        return True
    elif i < h-1 and s[i+1][j] == '#':
        return True
    elif j > 0 and s[i][j-1] == '#':
        return True
    elif j < w-1 and s[i][j+1] == '#':
        return True
    else:
        return False


h,w = map(int,input().split())
s = [input() for i in range(h)]
ans = 'Yes'
for i in range(h):
    for j in range(w):
        if s[i][j] == '#' and not check(s,i,j,h,w):
            ans = 'No'
            break
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N], b[N];
  for(int i=0;i<N;i++) cin >> a[i];
  for(int i=0;i<N;i++) cin >> b[i];
  ll suma = 0LL;
  ll sumb = 0LL;
  for(int i=0;i<N;i++){
    suma += a[i];
    sumb += b[i];
  }

  if(suma < sumb){
    cout << -1 << endl;
    return 0;
  }

  priority_queue<int> que;
  ll x = 0LL; //足りない分
  for(int i=0;i<N;i++){
    if(a[i] < b[i]) x += b[i] - a[i];
    else{
      que.push(a[i] - b[i]);
    }
  }

  while(x > 0){
    int q = que.top();
    que.pop();
    x -= q;
  }

  cout << N - que.size() << endl;
  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, m, mod;
llint dp[205][105][1<<10];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> mod;
	
	llint S = 1<<m;
	vector<llint> uvec, dvec;
	
	dp[1][1][1] = 1;
	for(int i = 1; i < 2*n; i++){
		for(int j = 1; j <= n; j++){
			llint u = j, d = i-j, nk;
			for(int k = 0; k < S; k++){
				//cout << i << " " << j << " " << k << endl;
				uvec.clear(), dvec.clear();
				for(int l = 0; l < m; l++){
					if(k & (1<<l)){
						if(i-l >= 1) uvec.push_back(i-l);
					}else{
						if(i-l >= 1) dvec.push_back(i-l);
					}
				}
				uvec.push_back(1), dvec.push_back(1);
				
				if(u < n){
					if(i+1 - uvec.front() <= m){
						nk = ((k << 1) % (1<<m)) | 1;
						dp[i+1][j+1][nk] += dp[i][j][k];
						dp[i+1][j+1][nk] %= mod;
					}
				}
				//cout << d << " " << u << endl;
				if(d < u){
					//cout << "*" << i << " " << j << " " << k << endl;
					//for(int p = 0; p < dvec.size(); p++) cout << dvec[p] << " "; cout << endl;
					//for(int p = 0; p < uvec.size(); p++) cout << uvec[p] << " "; cout << endl;
					
					if(i+1 - dvec.front() <= m && u-d <= m && i+1 - uvec[u-d-1] <= m){
						nk = ((k << 1) % (1<<m));
						dp[i+1][j][nk] += dp[i][j][k];
						dp[i+1][j][nk] %= mod;
					}
				}
			}
		}
	}
	
	/*for(int i = 1; i <= 2*n; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 0; k < S; k++){
				cout << dp[i][j][k] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}*/
	
	llint ans = 0;
	for(int i = 0; i < S; i++) ans += dp[2*n][n][i], ans %= mod;
	cout << ans << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 161528
#include<stdio.h>
int main(){
  int x;
  int ans=0;
  int temp=0;
  scanf("%d",&x);
  temp = x/500;
  ans += 1000*temp;
  temp = x-500*temp;//余り
  temp = temp/5;
  ans += temp*5;
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c1 = sc.nextInt();
        int c2 = sc.nextInt();
        int c3 = sc.nextInt();
        sc.close();

        String res;
        if (c1 == c2) {
            if (c2 == c3) {
                res = "1";
            } else {
                res = "2";
            }
        } else {
            if (c2 == c3) {
                res = "2";
            } else {
                if (c1 == c3) {
                    res = "2";
                } else {
                    res = "3";
                }
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 9684