akhauriyash/Code-Regression huggingface dataset:
MOD = 10**9+7
def factorize(N):
    n = N
    fact = []
    for i in range(2,int(N**0.5)+1): # intに変換すること
        while(n%i==0):
            n //= i #  整数除算(//)を使うこと
            fact.append(i)
    if n!=1:
        fact.append(n)
    return fact
N = int(input())
cnt = [0] * (N+1)
for n in range(1,N+1):
    fact = factorize(n)
    for f in fact:
        cnt[f] += 1

ans = 1
for n in range(N+1):
    ans *= (cnt[n]+1)
    ans %= MOD
print (ans)

Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> A) {
  if (N == 1) {
    cout << "YES" << endl;
    return;
  }

  ll sum = 0;
  REP(i, N) { sum += A[i]; }

  cout << (sum % 2 == 0 ? "YES" : "NO") << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> A[i];
  }
  solve(N, A);
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
    
#define Max 500000
    
void insert(int); 
void find(int, int);
int successor(int);
void delete(int);
void Preorder(int);  
void Inorder(int);  
     
typedef struct{    /* p = parent, l = child, s = brother */
  int key;
  int p;
  int l[2];
} Node;
    
Node T[Max];
    
int main(){
  int i, n, k;
  char s[7];
    
  scanf("%d", &n);
    
  T[0].key = -1;
     
  for(i = 0; i < n; i++){
    T[i].l[0] = -1;
    T[i].l[1] = -1;
    
    scanf("%s", s);
    
    if(strcmp(s, "insert") == 0){
      scanf("%d", &T[i].key);
      insert(i);
    }
    else if(strcmp(s, "print") == 0){
      Inorder(0);
      printf("\n");
      Preorder(0);
      printf("\n");
    }
    else if(strcmp(s, "find") == 0){
      scanf("%d", &k);
      find(0, k);
    }
    else if(strcmp(s, "delete") == 0){
      scanf("%d", &k);
      delete(k);
    }
  }
      
  return 0;
}
    
    
void insert(int z){
  int x, y;
    
  y = -1;
  x = 0;
    
  if(z != 0){
    while(x != -1){
      y = x;
      if(T[z].key < T[x].key) x = T[x].l[0];
      else x = T[x].l[1];
    }
  }
    
  T[z].p = y;
    
  if(y != -1){
    if(T[z].key < T[y].key) T[y].l[0] = z;
    else T[y].l[1] = z;
  }
}
    
void find(int x, int k){
    
  if(x == -1) printf("no\n");
  else if(T[x].key == k) printf("yes\n");
  else if(k < T[x].key) find(T[x].l[0], k);
  else find(T[x].l[1], k);
}
    
int successor(int x){
  int y;
    
  if(T[x].l[1] != -1){
    x = T[x].l[1];
    while(T[x].l[0] != -1) x = T[x].l[0];
    return x;
  }
      
  else {
    y = T[x].p;
    while(y != -1 && x == T[y].l[1]){
      x = y;
      y = T[y].p;
    }
    return y;
  }
}
    
void delete(k){
  int x, y, z = 0;
    
  while(1){
    if(T[z].key == k) break;
    else if(k < T[z].key) z = T[z].l[0];
    else z = T[z].l[1];
  }
    
  if(T[z].l[0] == -1 || T[z].l[1] == -1) y = z;
  else y = successor(z);
    
  if(T[y].l[0] != -1) x = T[y].l[0];
  else x = T[y].l[1];
    
  if(x != -1) T[x].p = T[y].p;
    
  if(T[y].p != -1){
    if(y == T[T[y].p].l[0]) T[T[y].p].l[0] = x;
    else T[T[y].p].l[1] = x;
  }
    
  if(y !=  z) T[z].key = T[y].key;
    
}
    
    
void Preorder(int a){
  printf(" %d", T[a].key);
    
  if(T[a].l[0] != -1) Preorder(T[a].l[0]);
  if(T[a].l[1] != -1) Preorder(T[a].l[1]);
}
    
    
void Inorder(int a){
  if(T[a].l[0] == -1){
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
  else{
    Inorder(T[a].l[0]);
    printf(" %d", T[a].key);
    if(T[a].l[1] != -1) Inorder(T[a].l[1]);
  }
}

Measured memory_bytes: 8428
n, m = map(int, input().split())

drink = []
for i in range(n):
  a, b = map(int, input().split())
  drink.append((a,b))
drink.sort(key=lambda x: x[0])
ans = 0
for ai in drink:
  ans += ai[0] * min(ai[1], m)
  m -= ai[1]
  if m <= 0:
    print(ans)
    break


Measured memory_bytes: 18164
#include<bits/stdc++.h>
using namespace std;
#define N 100005
long long n,m,a[N],ans;
int main()
{
	scanf("%lld%lld",&n,&m);
	if(m==0) {cout<<n*n<<endl;return 0;}
	for(long long i=m+1;i<=n;i++)
	{
		ans+=(n/i)*(i-m);
		if(n%i>=m) ans+=n%i-m+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>

#define MAX 3
using namespace std;

int main() {
    string text1, text2;
    cin >> text1;
    cin >> text2;

    bool flag=true;

    for (int i=0; i<MAX; i++){
        if (text1[i] != text2[MAX-i-1]){
            flag = false;
        }
    }
    if(flag == true){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for (int(i) = a; (i) <= (b); ++(i))
#define rep(i, n) FOR(i, 0, n-1 )
#define FFOR(i, a, b) for (int(i) = a; (i) > (b); --(i))
#define rrep(i, n) FFOR(i, 0, n)
#define vsort(v) sort((v).begin(), (v).end());           //小さい順
#define rvsort(v) sort(v.begin(), v.end(), greater<>()); //大きい順
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define all(c) (c).begin(), (c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout << (p) << endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn = 1e5 + 10;

signed main() {

  int n;cin>>n;

  int keta;
  int preketa;
  bool first = true;

  if(n==0) 
  {
    cout << 0 << endl;
    return 0;
  }

  while(n)
  {
    int dai =0,syou = 0;
    int cnt =1;
    rep(i,40)
    {
      if(cnt>0)dai+=cnt;
      else syou +=cnt;
      cnt*=-2;

      if((n>0&&dai>=n) || (n<0 && n>=syou))
      {
        keta = i;
        if(first)
        {
          preketa = keta;
          first = false;
        }
        n -= -cnt/2;
        break;
      }
    }
    rep(i,preketa-keta-1) cout << 0;
    cout << 1;
    preketa = keta;
}

rep(i,preketa) cout << 0;
cout << endl;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 100;
ll a[N];


int main() {
    int cnt;
    cin>>cnt;
    for(int i=0;i<cnt;i++) {
        scanf("%lld", &a[i]);
    }
    
    int flag = 1;
    for(int i=cnt-2;i>=0;i--) {
        if(a[i] <= a[i + 1]) {
            continue;
        }else {
            if(a[i] - 1 > a[i + 1]) {
                flag = 0;
                break;
            }else {
                a[i] -= 1;
            }
        }
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
  for(int n; cin >> n && n; ) {
    vector<int> in(1000, 0), sum(1000, 0);
    int prev = 0;
    while(n--) {
      int h, m, id; char c;
      cin >> h >> c >> h >> h >> c >> m >> c >> id;
      m += h * 60;
      for(int i = 1; in[0] && i < 1000; ++i) {
        if(in[i]) sum[i] += m - prev;
      }
      in[id] = c == 'I';
      prev = m;
    }
    cout << *max_element(sum.begin(), sum.end()) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <map>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 200000;
int a[1 + nmax], b[1 + nmax];
int a2[1 + nmax], b2[1 + nmax];

std::map<int,int> mp;

void normalize(int n) {
  std::vector<int> aux;
  for(int i = 1; i <= n; i++)
    aux.push_back(a[i]);
  std::sort(aux.begin(), aux.end());
  aux.erase(std::unique(aux.begin(), aux.end()), aux.end());
  for(int i = 0; i < aux.size(); i++)
    mp[aux[i]] = 1 + i;
  

  for(int i = 1;i <= n; i++)
    a[i] = mp[a[i]];
  for(int i = 1;i <= n; i++)
    b[i] = mp[b[i]];
}

int seen[1 + nmax];

class Dsu{
public:
  std::vector<int> mult;
  std::vector<int> sz;

  Dsu(int n) {
    mult.resize(1 + n);
    sz.resize(1 + n);
    for(int i = 1;i <= n; i++)
      mult[i] = i;
  }
  int jump(int gala) {
    if(gala != mult[gala])
      mult[gala] = jump(mult[gala]);
    return mult[gala];
  }
  void increment(int gala) {
    sz[jump(gala)]++;
  }
  void unite(int gala, int galb) {
    gala = jump(gala);
    galb = jump(galb);
    if(gala == galb)
      return ;
    mult[gala] = galb;
    sz[galb] += sz[gala];
  }
};

int main() {
  int n;
  std::cin >> n;
  for(int i = 1;i <= n; i++)
    std::cin >> a[i];
  for(int i = 1;i <= n; i++)
    std::cin >> b[i];

  for(int i = 1;i <= n; i++) {
    a[n + 1] ^= a[i];
    b[n + 1] ^= b[i];
  }
  for(int i = 1;i <= n + 1; i++) {
    a2[i] = a[i];
    b2[i] = b[i];
  }
  std::sort(a2 + 1, a2 + n + 1 + 1);
  std::sort(b2 + 1, b2 + n + 1 + 1);
  
  for(int i = 1;i <= n + 1; i++)
    if(a2[i] != b2[i]) {
      std::cout << -1;
      return 0;
    }
  normalize(n + 1);

  Dsu myset(n + 1);
  for(int i = 1;i < n + 1; i++)
    if(a[i] != b[i]) {
      myset.increment(a[i]);
    }
  
  for(int i = 1;i <= n + 1; i++)
    if(a[i] != b[i])
      myset.unite(a[i], b[i]);
  
  int result = 0;

  for(int i = 1;i <= n + 1; i++) {
    int id = myset.jump(a[i]);
    if(seen[id] == 0) {
      if(myset.sz[id] == 0)
        continue;

      if(myset.jump(a[n + 1]) != id)
        result += myset.sz[id] + 1;
      else 
        result += myset.sz[id];
      seen[id] = 1;
    }
  }
  std::cout << result;
  return 0;
}


Measured memory_bytes: 13672
#include <iostream>
#define MAXNUM 100000
using namespace std;
bool f[MAXNUM + 1];
int c[MAXNUM + 1];
int main(void) {
  for (int i = 2; i <= MAXNUM; i++) {
    if (!f[i]) {
      for (int j = i + i; j <= MAXNUM; j += i) {
        f[j] = 1;
      }
    }
  }
  for (int i = 3; i <= MAXNUM; i++) {
    if (!f[i] && !f[(i + 1) / 2]) c[i] = 1;
  }
  for (int i = 3; i <= MAXNUM; i++) {
    c[i] += c[i - 1];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << c[r] - c[l - 1] << endl;
  }
  return 0;
}

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

#define MAX 100002
int n;
vector<int> v;
struct st{
	int first;
	int second;
	int id;
};
bool same(st a, st b){
	bool f1 = (a.first & 1) ^ (a.second & 1) ^ (a.id & 1);
	bool f2 = (b.second & 1) ^ (b.first & 1) ^ (b.id & 1);
	return f1 == f2;
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	sort(v.begin(), v.end());
	int cur = 1;
	int pr = v.size() - 1;
	for (int i = (int)(v.size()) - 2; i >= 0; i--){
		cur++;
		if (cur > v[i]){
			cur--;
			break;
		}
		pr = i;
	}
	int rest = v[pr] - cur;
	if (rest & 1){
		puts("First");
	}
	else{
		int ii = pr;
		int cc = 0;
		while (ii >= 0 && v[ii] >= cur){
			cc++;
			ii--;
		}
		if (!(cc & 1)){
			puts("First");
		}
		else{
			puts("Second");
		}
	}
	return 0;
}

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

bool binSearch(int A[], int target, int size) {
	int left = 0, right = size, mid;
	while (left < right) {
		mid = (left + right) / 2;
		//cout <<  "left : " << left << ", right : " << right << ", mid : " << mid << endl;
		if (A[mid] == target) {
			// cout << target << " found." << endl;
			return true;
		}
		else {
			if (A[mid] < target) left = mid + 1;
			else right = mid;
		}
	}
	return false;
}

int main() {
	int size, query, queryNum, count = 0;

	cin >> size;
	int* A = new int[size];
	for (int i = 0; i < size; i++) scanf("%d", &A[i]);

	cin >> queryNum;
	for (int i = 0; i < queryNum; i++) {
		scanf("%d", &query);
		if (binSearch(A, query, size)) count++;
	}

	cout << count << endl;

	delete[] A;
}

Measured memory_bytes: 3224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
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;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

char s[102345];

int main(){
	scanf("%s", s);
	
	int len = strlen(s);
	
	int cnt = 0;
	
	REP(i,len-1){
		if (s[i+1] != s[i]) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 384
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	抓住数据范围哪里小
	dfs or bfs
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	树的直径:随便找一点再走到它最远的点A，再从A最远的点走到最远B的点。AB就是树的直径
	匹配括号 左减右>=0
	字符串赋值字符加单引号
	double> printf("%lf")输出小数点6位，%.16lf输出后十六位
	多组数据清空？
	dp优化用g？
	线段树：大小为n的8倍
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
	1<<int(ceil(log2(double(n))))
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define LL long long
#define IT iterator
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int boss[100001];
int flag[100001];
int find(int now){
	if(boss[now]==now) return now;
	return boss[now]=find(boss[now]);
}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	rb(i,1,n) boss[i]=i;
	rb(i,1,m){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		boss[find(x)]=find(y);
	}
	int res=0;
	rb(i,1,n){
		if(flag[find(i)]==0) res++;
		flag[find(i)]=1;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
  int N,M;
  cin >> N >> M;

  vector<vector<int> >person(N,vector<int>(2,0));
  for(int i=0;i<N;i++){
    cin >> person[i][0];
    cin >> person[i][1];
  }

  vector<vector<int> >point(M,vector<int>(2,0));
  for(int i=0;i<M;i++){
    cin >> point[i][0];
    cin >> point[i][1];
  }

  for(int i=0;i<N;i++){
    int distance_to_point = 1000000000;
    int ans;
    for(int j=0;j<M;j++){
      int distance = abs(person[i][0] - point[j][0]) + abs(person[i][1] - point[j][1]);
      if(distance_to_point > distance){
        distance_to_point = distance;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int a[200010];
signed main(){
	int n;
	cin >> n;
	int cnt = 0;
	Rep(i, n) {
		cin >> a[i]; cnt += a[i];
	}
	int ans = cnt, sum = 0;
	Rep(i, n) {
		sum += a[i];
		ans = min(ans, abs(sum - (cnt - sum)));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

/*
a = b * q + r と表して、(b,q,r) の個数を求めます。
b を固定して数えます。
まず 余りがなんでも大丈夫な q は q in [0,Q[ where Q = floor((n+1) / b) です。
q = Q のときは Θ(b) 書けて全探索です。
  - これは嘘で、間に合わないので R = n - Q*b として、[k,R] です。
k = 0 のとき、(0,b) がなみ入るので n 引いておきましょう。
*/

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, k; std::cin >> n >> k;
  lint ans = 0;
  rep(b,k+1,n+1) {
    lint Q = (n+1) / b;
    lint rs = b - k;
    lint now = Q * rs;
    lint R = n - Q * b;
    lint add = R - k + 1;
    if (0 <= add) {
      now += add;
    }
    ans += now;
  }
  if (k==0) {
    ans -= n;
  }
  std::cout << ans << std::endl;
  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol result{0};
    lol money{100};
    lol n; cin >> n;
    //lol k; cin >> k;
    /*
    vector<lol> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */
    while(1)
    {
        money += money/100;
        result++;
        if(money >= n)
            break;
    }
    

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}	

	private String solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int [] array = new int[N+1];
		for(int i=1;i<=N;i++){
			array[i] = sc.nextInt();
		}
		int [] dp = new int[K+1];
		//Arrays.fill(dp, -1);
		dp[0] = 0;
		for(int i=1;i<=N;i++){
			dp[array[i]]=1;
		}
		//System.out.println(Arrays.toString(dp));
		 

	 	for(int i=1;i<=K;i++){	 
	 		if (dp[i]==1) continue;		
	 		for(int j=1;j<=N;j++) {
	 			int x = array[j];	 			 
	 			if ((i-x)<0) {
	 				dp[i]=0;
	 				continue;
	 			} else {
	 				if (dp[i-x]==0) {
	 					dp[i]=1;
	 					break;
	 				} else {
	 					dp[i]=0;
	 				}
	 			}	 			
	 		}
	 		//System.out.printf("dp[%d]: %d\n", i, dp[i]);
	 		//System.out.println(Arrays.toString(dp));
	 	}

		return dp[K]==1 ? "First" : "Second";


	}

}

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

using namespace std;

vector<ll> frac(200010);

ll modinv(ll a) {
  ll M = MOD, b = M, u = 1, v = 0;
  while (b)
    u -= a / b * v, swap(u, v), a %= b, swap(a, b);
  return (u % M + M) % M;
}

ll binarypow(ll a, ll p) {
  if (!p)
    return 1;
  ll t = binarypow(a, p / 2);
  return (p & 1 ? a : 1) * t % MOD * t % MOD;
}

ll aaaaa(ll x, ll n) {
  ll ret = 1;
  rep (i, x) {
    ret *= n - i;
    ret %= MOD;
  }
  ret *= modinv(frac[x]);
  ret %= MOD;
  return ret;
}

void solve() {
  ll n, a, b;
  cin >> n >> a >> b;

  cerr << "--- foo 1" << endl;

  ll ans = binarypow(2, n);
  cerr << "--- foo 2" << endl;

  ans -= 1;

  frac[0] = 1;
  for (ll i = 1; i < 200010; i++) {
    frac[i] = frac[i-1] * i;
    frac[i] %= MOD;
  }

  cerr << "--- foo 3" << endl;
  ll foo = aaaaa(a, n);
  cerr << "--- foo 4" << endl;
  ll bar = aaaaa(b, n);
  cerr << "--- foo 5" << endl;

  ans -= foo;
  ans -= bar;
  ans %= MOD;
  ans += MOD;
  ans %= MOD;
  cerr << "--- foo 6" << endl;

  ans = max(ans, 0ll);

  cout << ans << endl;
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d;
long long calc(long long hp) {
	long long bb = b - (b % hp);
	long long aa = a;
	if (a % hp != 0)
		aa += hp - (a % hp);
//	cout << aa << ' ' << bb << ' ' << '\n';
	if (aa > bb)
		return 0;
	
	return ((bb - aa) / hp) + 1;
}
int main() {
	//ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> a >> b >> c >> d;
//	cout << calc(c) << '\n'  << calc(d) << '\n' <<  << '\n';
	cout << b - a + 1 - calc(c) - calc(d) + calc(c * d / __gcd(c, d));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long k,s=0;
int a[1000100];
int b[1000100];
bool cmp(int &s1,int &s2)
{
    return s1>s2;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++){cin>>a[i];}
	for(int i=1;i<=n;i++)cin>>b[i];
	sort(a+1,a+1+n);
	sort(b+1,b+1+n,cmp);
	long long l=0,r=1e14;
	while(l<r)
    {
        long long mid=(l+r)/2;
        s=0;
        for(int i=1;i<=n;i++)
            s+=max(0LL,a[i]-mid/b[i]);
        if(s<=k)r=mid;
        else l=mid+1;
    }
    cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 5120
#include <cstdio>

const int mod = 1e9 + 7;
const int MAXN = 5005;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

struct edge
{
	int to, nxt;
}Graph[MAXN << 1];

int tmp[MAXN];
int f[MAXN][MAXN], g[MAXN];
int head[MAXN], siz[MAXN];
int N, cnt;

void sub( int &x, const int v ) { x = ( x < v ? x + mod - v : x - v ); }
void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

void addEdge( const int from, const int to )
{
	Graph[++ cnt].to = to, Graph[cnt].nxt = head[from];
	head[from] = cnt;
}

void DFS( const int u, const int fa )
{
	f[u][1] = 1, siz[u] = 1;
	for( int i = head[u], v ; i ; i = Graph[i].nxt )
		if( ( v = Graph[i].to ) ^ fa )
		{
			DFS( v, u );
			for( int i = 0 ; i <= siz[u] + siz[v] ; i ++ ) tmp[i] = 0; 
			for( int j = siz[u] ; j ; j -- )
				for( int k = siz[v] ; ~ k ; k -- )
					add( tmp[j + k], 1ll * f[u][j] * f[v][k] % mod );
			siz[u] += siz[v];
			for( int i = 0 ; i <= siz[u] ; i ++ ) f[u][i] = tmp[i];
		}
	for( int i = 1 ; i <= siz[u] ; i ++ )
		sub( f[u][0], 1ll * f[u][i] * g[i] % mod );
}

int main()
{
	read( N );
	for( int i = 1, a, b ; i < N ; i ++ )
		read( a ), read( b ), addEdge( a, b ), addEdge( b, a );
	g[2] = 1;
	for( int i = 4 ; i <= N ; i += 2 )
		g[i] = 1ll * g[i - 2] * ( i - 1 ) % mod;
	DFS( 1, 0 );
	write( ( mod - f[1][0] ) % mod ), putchar( '\n' );
	return 0;
}

Measured memory_bytes: 56232
s, t = [], []

N = int(input())
for i in range(N):
  s.append(input())
M= int(input())
for i in range(M):
  t.append(input())
  
dic = list(set(s + t))
result = 0
for i in range(len(dic)):
  result = max(result, s.count(dic[i]) - t.count(dic[i]))
print(result)

Measured memory_bytes: 3064
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	int x1 = 0;
	int mae = 0;
	int ato = 0;
	int[] a = new int[n];
	for(int i = 0; i < n; i++){
		a[i] = Integer.parseInt(sc.next());
		if(i%2 == 0){
			x1 += a[i];
		}else{
			x1 -= a[i];
		}
	}
	System.out.println(x1);
	mae = x1;
	for(int i = 0; i < n - 1; i++){
		ato = 2 * a[i] - mae;
		System.out.println(ato);
		mae = ato;
	}
}
}

Measured memory_bytes: 47816
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fir first
#define sec second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>

typedef long long ll;
typedef unsigned long long ull;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

inline int read() {
    int res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}

ll n;
struct Tuple {
    ll price, volume;
    double single;

    bool operator<(const Tuple &other) const {
        if (single != other.single) return single < other.single;
        return volume > other.volume;
    }

    void print() {
        printf("%lld %lld %lf\n", price, volume, single);
    }
} a[4];

int main() {
    int last = 1;
    for (int i = 0; i < 4; i++) {
        std::cin >> a[i].price;
        a[i].volume = last;
        a[i].single =  (double)a[i].price / a[i].volume;
        last *= 2;
    }
    std::cin >> n;
    std::sort(a, a + 4);
    n *= 4;
    ll ans = 0;
    for (int i = 0; i < 4; i++) {
        ans += n / (a[i].volume) * a[i].price;
        n = n % a[i].volume;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b;
    cin>>a>>b;
    if(a<b){
        rep(i,b){
            cout<<a;
        }
        cout<<endl;
    }else{
        rep(i,a){
            cout<<b;
        }
        cout<<endl;
    }
    return 0;
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  for (int i = 0; i < K; i++) {
    if (i % 2 == 0) {
      if (A % 2 == 1) A--;
      B += A / 2;
      A /= 2;
    } else {
      if (B % 2 == 1) B--;
      A += B / 2;
      B /= 2;
    }
  }

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

a.sort(reverse= True)

cnt = 0
top = []

for i in range(n-1):
    #print(i)
    if len(top) == 2:
        break    
    if a[i] == a[i+1]:
        if len(top) == 2:
            break
        if cnt%2 == 0:
            top.append(a[i])
        cnt += 1
    else:
        cnt = 0

if len(top) < 2:
    print(0)
    exit()

print(int(top[0]*top[1]))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  string ans="Yes";
  for(int i=0;i<s.size();i++){
    if(((i==a)+(s.at(i)=='-'))%2){
      ans="No";
    }
  }
  cout << ans << endl;
}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) vc<vc<T>> xs(n, vc<T>(m)); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

bool p(int n){
    if(n < 2) return false;
    for(int i = 2; i*i <= n; i ++){
        if(n % i == 0) return false;
    }
    return true;
}

int main(void){
    Cin(int, a, b);
    Cout((ll)a*b/gcd(a, b));
}


Measured memory_bytes: 256
def price(N,K):
    Kn = input().split()
    Flag = False

    for i in range(N,10*N,1):
        value = str(i)
        for j in range(K):
            if(Kn[j] not in value):
                Flag = True
            elif(Kn[j] in value):
                Flag = False
                break

        if(Flag == True):
            print(i)
            break

N,K = (int(x) for x in input().split())
price(N,K)

Measured memory_bytes: 9120
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
        print(ans)
    else:
        print(0)
    return

#D
def D():
    n = II()
    a = LI()
    a = a + [a[0]]
    ans = [0] * n
    x = 0
    for i in range(1, n, 2):
        x = x + a[i + 1] - a[i]
    ans[1] = a[0] - x
    ans[0] = ans[1] + 2 * x
    for i in range(2, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(" ".join(map(str, ans)))

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n ;
  vector<char> S(n);
  for(int i=0;i<n;i++){
    cin >> S.at(i) ;
  }
  int Wc=0,Ec=0;
  for(int i=1;i<n;i++){
    if(S.at(i) =='E') Ec ++;
  }
  int ans =  Ec;
  for(int i=1;i<n;i++){
    if(S.at(i-1)=='W'){
      Wc ++;
    }
    if(S.at(i) =='E'){
      Ec --;
    }
  ans = min(ans,Ec+Wc);
  }
  cout << ans <<endl;
}

      
    

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define INF 9223372036854775807 / 2
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair


using namespace std;

std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

int cou[31];

signed main() {
	int N, M;
	cin >> N >> M;
	rep(i, N) {
		int K;
		cin >> K;
		rep(j, K) {
			int a;
			cin >> a;
			cou[a]++;
		}
	}
	int ans = 0;
	rep(i, M+1) {
		if (cou[i] == N) ans++;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int[] a = new int[26];
		for (int i=0;i<n;i++) {
			a[s.charAt(i)-'a']++;
		}
		long ans = 1;
		for (int i=0;i<26;i++) {
			ans=ans*(a[i]+1)%1_000_000_007;
		}
		System.out.println(ans-1);

	}
}

Measured memory_bytes: 24404
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
using namespace std;

int main() {
    int a,b,c,n,f=0;
	string st;
	map<int,string> mp;
	map<int,string>::reverse_iterator it;
	while (cin >> n) {
		if (n==0) break;
		for (n--;n>=0;n--) {
			cin >> st >> a >> b >> c;
			mp.insert(map<int,string>::value_type((a*3+c)*10+n,st));
		}
    if (f==0) f=1; else cout << endl;
	for (it=mp.rbegin();it!=mp.rend();it++) cout << (*it).second << ',' << (*it).first/10 << endl;
	mp.clear();
	}
    return 0;
}

Measured memory_bytes: 1212
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int h = sc.nextInt();
		int w = sc.nextInt();
        String edge = "";
        for(int i = 0; i < w + 2; i++) {
          edge += "#";
        }
        // 出力
		System.out.println(edge);
       
        for(int i = 0; i < h; i++) {
          // 文字列の入力
		  String s = sc.next();
          String ans = "#";
          ans += s + "#";
          // 出力
		  System.out.println(ans);
        }
      
        // 出力
		System.out.println(edge);
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n,m,k;
    cin >> n >> m;
    vvi s(m);
    ll ts;
    rep(i,m){
        cin >> k;
        rep(j,k) cin >> ts, s.at(i).push_back(ts);
    }
    vi p(m);
    rep(i,m) cin >> p.at(i);
    vi b(n,0);
    ll res = 0;
    rep(i,1<<n){
        rep(j,n){
            b.at(j) = (i>>j&1);
        }
        rep(j,m){
            ll sum = 0;
            for(ll ts:s.at(j)){
                sum += (b.at(ts-1)==1);
            }
            if(sum%2!=p.at(j)){
                break;
            }
            if(j==m-1) res++;
        }
    }
    cout << res << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int x;
  cin >> x;
  
  if(x>=30) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    int n, k; cin >> n >> k;
    int R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    int ans = 0;
    int is_win[T.size()];
    map<char, int> score_dict;
    score_dict['r'] = P;
    score_dict['s'] = R;
    score_dict['p'] = S;
    rep(i,0,T.size()){
        is_win[i] = 0;
    }
    rep(i,0,T.size()){
        if(i < k){ans += score_dict[T[i]]; is_win[i] = 1;}
        else{
            if(T[i] != T[i-k] || is_win[i-k] == 0){
                ans += score_dict[T[i]]; is_win[i] = 1;
            }
        }
    }

    cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 848
#include <stdio.h>
#include <algorithm>

using namespace std;

#define MOD 1000000007

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

struct point {
    int y, x;
};

bool operator<(point a, point b) {
    return a.y + a.x < b.y + b.x;
}

mint F[202020] = {1, 1};
mint IF[202020] = {1, 1};
mint I[202020] = {0, 1};

mint dp[3002][2];
int H, W, N;

point P[3002];

mint C(int n, int r) {
    if (n < 0 || r < 0 || n < r) return 0;
    return F[n] * IF[r] * IF[n - r];
}

int main() {
    for (int i = 2; i < 202020; i++) {
        I[i] = I[MOD % i] * (MOD - MOD / i);
        F[i] = i * F[i - 1];
        IF[i] = I[i] * IF[i - 1];
    }
    scanf("%d %d %d", &H, &W, &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d %d", &P[i].y, &P[i].x);
    }
    P[0].y = 1;
    P[0].x = 1;
    P[N + 1].y = H;
    P[N + 1].x = W;
    N += 2;
    sort(P, P + N);
    dp[0][1] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = i + 1; k < N; k++) {
                int dy = P[k].y - P[i].y;
                int dx = P[k].x - P[i].x;
                dp[k][j ^ 1] += dp[i][j] * C(dy + dx, dy);
            }
        }
    }
    mint ans = dp[N - 1][0] - dp[N - 1][1];
    printf("%d\n", ans.n);
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
unordered_map<int,int> id;
vector<int> v;
int ct = 1;
int a[100005], b[100005];
int p[100005], sz[100005];
int xa[100005], xb[100005];
int num;
int n;
void init(int n){
    num = n;
    for (int i = 1; i <= n; i++) p[i] = i;
}
int find(int x){
    return p[x] == x ? x : p[x] = find(p[x]);
}
void unionset(int x, int y){
    x = find(x), y=  find(y);
    if (x == y) return;
    num--;
    p[x] = y;
    sz[y] += sz[x];
}
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
        a[n] ^= a[i];
    }
    for (int i = 0; i < n; i++){
        scanf("%d",&b[i]);
        b[n] ^= b[i];
    }
    for (int i = 0; i <= n; i++){
        xa[i] = a[i], xb[i] = b[i];
    }
    sort(xa,xa+n+1);
    sort(xb,xb+n+1);
    for (int i = 0; i <= n; i++){
        if (xa[i] != xb[i]){
            printf("-1");
            return 0;
        }
    }
    for (int i = 0; i <= n; i++){
        if (a[i] != b[i] || i == n){
            v.push_back(a[i]);
        }
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for (auto x : v){
        id[x] = ct++;
    }
    ct--;
    init(ct);
    for (int i = 0; i <= n; i++){
        if (a[i] != b[i] || i == n){
            //printf("%d\n",a[i]);
            sz[id[a[i]]]++;
        }
    }
    for (int i = 0; i <= n; i++){
        if (a[i] != b[i] || i == n){
            unionset(id[a[i]],id[b[i]]);
        }
    }
    unordered_set<int> sets;
    for (int i = 1; i <= n; i++){
        if (a[i] != b[i] || i == n) {
            sets.insert(find(id[a[i]]));
        }
    }
    int ans = 0;
    for (auto x : sets){
        //printf("%d ",x);
        if (find(id[a[n]]) == x){
            //printf("A cycle %d\n",sz[x]);
            ans += sz[x]-1;
        }
        else{
            //printf("B cycle %d\n",sz[x]);
            ans += sz[x]+1;
        }
    }
    printf("%d",ans);
}


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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    stin(s);
    stin(t);
    ll k=0;
    FOR(i,0,2){
        if(s[i]==t[i]) k++;
    }
    sal(k)
}


Measured memory_bytes: 256