akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> dist(n, -1);
    queue<int> q;
    q.push(0);
    dist[0] = 0;
    int ans[n] = {};
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int nv : g[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            q.push(nv);
            ans[nv] = v;
        }
    }
    cout << "Yes" << endl;
    rep(i, 1, n) cout << ans[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 10628
acgt = ['A', 'C', 'G', 'T']
s = input()
count = 0
max = 0
for i in s:
  if i in acgt:
    count += 1
  else:
    if count > max:
      max = count
      count = 0
if count > max:
  max = count
  count = 0
print(max)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll ans(ll T1, ll T2, ll A1, ll A2, ll B1, ll B2) {
	ll x = T1 * (A1 - B1) + T2 * (A2 - B2);

	if (x == 0) { return INF; }
	if (x < 0) { return ans(T1, T2, B1, B2, A1, A2); }

	if (A1 > B1) { return 0; }

	ll y = T1 * (B1 - A1);

	if (y%x == 0) { return 2 * (y / x); }
	return 2 * (y / x) + 1;

}



int main() {

	ll T1, T2, A1, A2, B1, B2;

	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	ll a = ans(T1, T2, A1, A2, B1, B2);

	if (a == INF) { cout << "infinity"; }
	else { cout << a; }




	system("PAUSE");
}

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

using namespace std;

const int MAXN = 5000 + 100;
char a[MAXN], b[MAXN];
int lena, lenb, dp[MAXN][MAXN], dir[MAXN][MAXN];

void dfs(int x, int y) {
	if(!x && !y) return;
	if (dir[x][y] == 1) dfs(x - 1, y - 1), printf("%c", a[x]);
	else if (dir[x][y] == 2) dfs(x - 1, y);
	else if (dir[x][y] == 3) dfs(x, y - 1);
}

int main() {
	scanf("%s%s", a + 1, b + 1);
	lena = strlen(a + 1);
	lenb = strlen(b + 1);
	
	for (int i = 1; i <= lena; i++) {
		for (int j = 1; j <= lenb; j++) {
			if (a[i] == b[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
				dir[i][j] = 1;
			}
			if (dp[i - 1][j] > dp[i][j]) {
				dp[i][j] = dp[i - 1][j];
				dir[i][j] = 2;
			}
			if (dp[i][j - 1] > dp[i][j]){
				dp[i][j] = dp[i][j - 1];
				dir[i][j] = 3;
			}
		}
	}
	if (dp[lena][lenb]) dfs(lena, lenb);
	else printf(" ");
	return 0;
}


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

    using namespace std;
    using namespace std::chrono; 

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()

    void __print(int x) {cerr << x;}
    void __print(long x) {cerr << x;}
    void __print(long long x) {cerr << x;}
    void __print(unsigned x) {cerr << x;}
    void __print(unsigned long x) {cerr << x;}
    void __print(unsigned long long x) {cerr << x;}
    void __print(float x) {cerr << x;}
    void __print(double x) {cerr << x;}
    void __print(long double x) {cerr << x;}
    void __print(char x) {cerr << '\'' << x << '\'';}
    void __print(const char *x) {cerr << '\"' << x << '\"';}
    void __print(const string &x) {cerr << '\"' << x << '\"';}
    void __print(bool x) {cerr << (x ? "true" : "false");}

    template<typename T, typename V>
    void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
    template<typename T>
    void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
    void _print() {cerr << "]\n";}
    template <typename T, typename... V>
    void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
    #ifndef ONLINE_JUDGE
    #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
    #else
    #define debug(x...)
    #endif

    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }

    /*CHECK FOR CORNER CASES FOR GOD'S SAKE*/
    int main()
    {
      //freopen("dislodging_logs_validation_input.txt", "r", stdin);
      //freopen("output.txt", "w", stdout);
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      string s;
      cin>>s;
      int n = s.size();
      int sum = 0;
      forn(i,0,n){
        sum += s[i]-'0';
      }
      if(sum%9 == 0){
        cout<<"Yes"<<endl;
      }
      else
        cout<<"No"<<endl;
  } 



     
    


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

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        int r = pint();
        int g = pint();
        out(2*g-r);
    }

    private int pint() throws IOException {
        return pint(rd.readLine());
    }

    private int pint(String s) {
        return Integer.parseInt(s);
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 23124
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# N: ノードの数
# Q: 数値をノードに付与する回数
N, Q = list(map(int, input().split()))

links =  [[] for _ in range(N)]
values = [0 for _ in range(N)]

for i in range(N - 1):
    edge1, edge2 = [x - 1 for x in list(map(int, input().split()))]
    links[edge1].append(edge2)
    links[edge2].append(edge1)

for i in range(Q):
    node, val = list(map(int, input().split()))
    values[node - 1] += val

# 値の計算
stack = [(0, -1)]  # [(ノードID, 親ノードID)] のリスト (-1 は番兵)
while stack:
    node = stack.pop()

    for linked_node in links[node[0]]:
        if linked_node == node[1]:  # link が親ノード向けでなければ
            continue

        values[linked_node] += values[node[0]]
        stack.append((linked_node, node[0]))

print(*values)

Measured memory_bytes: 72808
#include<stdio.h>
#define N 100

int main(void){
  int i,n,j,k;
  char ch[110];
  int digi;
  int status[N];
  int pCount=0;

  for(i=0;scanf("%s",&ch)==1;i++){
    for(j=0;;j++){
      if(ch[j]==0)
        break;
    }
    digi=j;
    status[i]=1;
    for(j=0,k=digi-1;j<=digi/2;j++,k--){
      if(ch[j]!=ch[k]){
        status[i]=0;
        break;
      }
    }
  }
  n=i;
  for(i=0;i<n;i++){
    if(status[i]==1)
      pCount++;
  }
  printf("%d\n",pCount);
  return 0;
}

Measured memory_bytes: 0
N=int(input())

dp=[[0 for _ in range(3)] for _ in range(N)]

a,b,c=map(int,input().split())
dp[0][0]=a
dp[0][1]=b
dp[0][2]=c
for i in range(1,N):
    a,b,c=map(int,input().split())
    dp[i][0]=a+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=b+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=c+max(dp[i-1][0],dp[i-1][1])

print(max(dp[-1][0],dp[-1][1],dp[-1][2]))

Measured memory_bytes: 62300
//
// Created on 2020/09/13.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
const int mod = 1000000007;


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

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};



int main() {
    int s;
    cin>>s;
    vector<mint>ans(2001,0);
    ans[0] = 1;
    ans[1]=0;
    ans[2]=0;
    for (int i = 3; i < 2001; ++i) {
        for (int j = 3; i - j >= 3 ; ++j) {
            ans[i] += ans[i-j];
        }
        ans[i] += 1;
    }
    cout<<ans[s].x<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) ((int)(x).size())
#define fill(v, h) memset((v), h, sizeof(v))
using namespace std;
const int MOD = 1000000007;

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 main(void)
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans2 = a * x + b * y;

    int ans = 0;
    int mi = min(x, y);
    ans += c * mi * 2;
    ans += a * (x - mi);
    ans += b * (y - mi);

    int ans3 = 0;
    if (x >= y)
    {
        ans3 = c * x * 2;
    }
    else
    {
        ans3 = c * y * 2;
    }

    cerr << ans << " " << ans2 << " " << ans3 << " " << endl;
    cout << min(min(ans, ans2), ans3) << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    if p[i-1] > p[i] and p[i] > p[i+1]:
        ans+=1
    elif p[i-1] < p[i] and p[i] < p[i+1]:
        ans+=1
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;

class Program
{
  static void Main()
  {
    Console.ReadLine();
    string[] str = Console.ReadLine().Split();
    List<int> a = new List<int>();
    
    foreach(string s in str)
      a.Add(int.Parse(s));
    
    a.Sort();
    
    for(int i = 0; i < a.Count - 1; i++)
    {
      if(a[i] == a[i + 1])
      {
        Console.WriteLine("NO");
        return;
      }
    }
    
    Console.WriteLine("YES");
  }
}

Measured memory_bytes: 38236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  ll a; cin >> a;
  ll b; cin >> b;
  ll c; cin >> c;
  if ((a==b&&b!=c) || (a!=b&&b==c) || (a==c&&a!=b)) {
    cout << yes << endl;
  } else {
    cout << no << endl;
  }

  return 0;
}


Measured memory_bytes: 256
package main

import(
  "fmt"
)

func main() {
  var n string
  fmt.Scan(&n)

  for bits := 0; bits < (1 << uint64(3)); bits++ {
    sum := int(n[0] - '0')
    op := make([]string, 3)
    for i := 0; i < 3; i++ {
      if (bits >> uint64(i) & 1) == 1 {
        op[i] = "+"
        sum += int(n[i+1] - '0')
      } else {
        op[i] = "-"
        sum -= int(n[i+1] - '0')
      }
    }
    if sum == 7 {
      // initial term
      expr := string(n[0])
      for j := 0; j < len(op); j++ {
        expr += op[j] + string(n[j+1])
      }
      // end term
      expr += "=7"
      fmt.Println(expr)
      return
    }
  }
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            Console.WriteLine((Input.NextInt() - 1) * (Input.NextInt() - 1));
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0
for i in range(n):
    ans += b[i]
    if i == 0:continue
    if a[i] - a[i-1] == 1:
        ans += c[a[i-1]-1]
print(ans)

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

int main()
  {
    int wa[105000];
    bool ac[105000];
    int n,m;
    int wasum=0,acsum=0;
    cin>>n>>m;
    for(int i=1;i<n;i++)
       {
         wa[i]=0;
         ac[i]=false;
       }
       while(m--)
       {
        int p;
        string q;
        cin>>p>>q;
          if(ac[p]) continue;
          if(q=="AC")
           {
             ac[p]=true;
             acsum++;
             wasum+=wa[p];
           }
           else
           {
             wa[p]++;
           }
       }
       cout<<acsum<<" "<<wasum;
  }


Measured memory_bytes: 768
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
# list(map(int, input().split()))
mod = 10 ** 9 + 7

N = getN()
A = getList()
lista = [[0, 0] for i in range(61)]
# bitの各桁が１か０かをlistaに収納
def splitbit(n):
    for i in range(61):
        if n & (1 << i):
            lista[i][1] += 1
        else:
            lista[i][0] += 1
for i in A:
    splitbit(i)
ans = 0
for i in range(61):
    ans += ((lista[i][0] * lista[i][1]) * (2 ** i)) % mod
print(ans % mod)

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int N, M; cin >> N >> M;
    int like[M] = {};
    rep(i, N){
        int K; cin >> K;
        rep(j, K){
            int a; cin >> a;
            a--;
            like[a]++;
        }
    }
    int ans = 0;
    rep(i, M){
        if(like[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long 
#define pi 3.1415926536
using namespace std;
const ll N=1e5+5;
void solve()
{ll n,k,l,h,r,z,w,mini,maxi=INT_MAX,prev;
  cin>>n;k=0;
  for(ll i=1;i<=n;i++)
  {
  	for(ll j=1;j<=n;j++)
  	{
  		for(ll m=1;m<=n;m++)
  		{ k+=__gcd(i,__gcd(j,m));
  			
		  }
	  }
  }
  cout<<k;
}
  
int main()
{
  fast
  //for(ll i=0;i<=9;i++)
  //cal(1,3234566667,i);
  //sort(v.begin(),v.end());
  //fact();
  //chk();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, W, N;
	int sr, sc;
	string S, T;
	cin >> H >> W >> N >> sr >> sc >> S >> T;
	--sr; --sc;
	
	int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
	map<char, int> mm;
	{
		string s = "LRUD";
		REP(i, s.size()) mm[s[i]] = i;
	}
	auto isinmap = [&](int cy, int cx) { return 0 <= cy && cy < H && cx >= 0 && cx < W; };
	
	bool ok = true;
	REP(dir, 4) { // 落とす方向
		int y = sr, x = sc;
		int ld = dir ^ 1; // 残る方向
		
		bool leave = true;
		REP(i, N) {
			int d = mm[S[i]];
			if (d == dir) {
				x += dx[d];
				y += dy[d];
			}
			leave &= isinmap(y, x);
			
			d = mm[T[i]];
			if (d == ld) {
				int nx = x + dx[d];
				int ny = y + dy[d];
				if (isinmap(ny, nx)) {
					x = nx;
					y = ny;
				}
			}
		}
		if (!leave) ok = false;
	}
	
	puts([&] {
		return ok;
	}() ? "YES": "NO");
	
	return 0;
}


Measured memory_bytes: 776
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(n - 1)]
PX = [[int(x) for x in input().split()] for _ in range(q)]

graph = [[] for _ in range(n + 1)]

for a, b in AB:
	graph[a].append(b)
	graph[b].append(a)

value = [0] * (n + 1)
for p, x in PX:
	value[p] += x

def dfs(v, parent, add):
	value[v] += add
	for x in graph[v]:
		if x == parent:
			continue
		dfs(x, v, value[v])

dfs(1, 0, 0)
print(*value[1:])


Measured memory_bytes: 284512
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, N) {
        cin >> C[i];
        rep(j, M) cin >> A[i][j];
    }
    int res = INF;
    for(int bit = 0; bit < (1 << N); bit++) {
        int sum = 0;
        vector<int> vec(M);
        for(int i = 0; i < N; i++) {
            if(bit & (1 << i)) {
                sum += C[i];
                rep(j, M) vec[j] += A[i][j];
            }
        }
        int ok = 1;
        rep(i, M) {
            if(vec[i] < X)
                ok = 0;
        }
        if(ok)
            res = min(sum, res);
    }
    cout << (res == INF ? -1 : res) << endl;

    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define sz(obj) ((int)(obj).size())

int main()
{
  int n;
  
  while (cin >> n, n){
    string str;
    cin >> str;
    while (n--){
      int cnt = 1;
      string tmp;
      
      REP(j, sz(str)){
        if (str[j] == str[j + 1]) cnt++;
        else {
          char tmp2[10000];
          sprintf(tmp2, "%d%c", cnt, (char)str[j]);
          tmp += tmp2;
          cnt = 1;
        }
      }
      str = tmp;
    }
    cout << str << endl;
  }
  return (0);
}

Measured memory_bytes: 1376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#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()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// 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 A, long long B, string S) {
  REP(i, A + B) {
    if (A == i) {
      if (S[i] != '-') {
        cout << "No" << endl;
        return;
      }
    } else if (S[i] < '0' || S[i] > '9') {
      cout << "No" << endl;
      return;
    }
  }
  if (A + B + 1 != S.size()) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string S;
  long long B;
  long long A;
  cin >> A;
  cin >> B;
  cin >> S;
  solve(A, B, S);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

R = []
G = []
B = []

for i, c in enumerate(S, start=1):
    if c == 'R':
        R.append(i)
    if c == 'G':
        G.append(i)
    if c == 'B':
        B.append(i)

ans = len(R) * len(G) * len(B)

for i in range(N):
    for k in range(1, (N-i)//2+1):
        if i + 2*k >= N:
            break
        if S[i] != S[i+k] and S[i] != S[i+2*k] and S[i+k] != S[i+2*k]:
            ans -= 1

print(ans)




Measured memory_bytes: 68536
#include <stdio.h>

int toindex(char c){///S->0 H->1 C->2 D->3
    if(c == 'S') return 0;
    if(c == 'H') return 1;
    if(c == 'C') return 2;
    return 3;
}
int main(void){
    
    
    int i,j,n,num;
    int card[4][14];  //13まで入れるから
    char c;
    for(i = 0; i<4; i++){
         for(j = 1; j<14; j++){
             card[i][j] = 0;
         }
    }
 
    scanf("%d\n",&n);
    for(i = 0; i<n; i++){
        scanf("%c %d\n",&c,&num);
        card[toindex(c)][num] = 1;
        
    }
    for(i = 0; i<4; i++){
        for(j = 1; j<14; j++){
            if (card[i][j] == 0) {
                if (i == 0)    printf("S %d\n",j);
                else if (i == 1)    printf("H %d\n",j);
                else if (i == 2)    printf("C %d\n",j);
                else if (i == 3)    printf("D %d\n",j);
            }
        }
    }


    return 0;
}



Measured memory_bytes: 2072
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    if(n%2==1) cout<<0<<endl;
    else{
    n/=2;
    while(n>=5)
{
        n/=5;
        ans+=n;
    }//For output
    cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A + B + C == 17 && ((A + B == 10)|| (A + B == 12)))
    cout << "YES" << endl;
  else 
   cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
#define N 200005

bool comp(int a, int b) {return a > b;}

int n, t[N];

int main()
{
	scanf("%d", &n);
	for(int i =1; i<=n; ++i)
		scanf("%d", t+i);
	
	sort(t+1, t+n+1, comp);
	int p;
	int bok1 = 0, bok2 = 0;
	for(int i = 1; i < n; ++i)  {
		if(t[i] == t[i+1]) {
			p = i+2;
			bok1 = t[i];
			break;
		}
	}
	for(int i = p; i < n; ++i) {
		if(t[i] == t[i+1]) {
			bok2 = t[i];
			break;
		}
	}
	printf("%lld", (long long)bok1 * bok2);
	
}


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

class Main {

    static boolean binarySearch(int[] a, int key, int begin, int end){     
        if(begin >= end){
            if(a[begin] != key){
                return false;
            }
        }

        int med = (begin + end) / 2;
        if (a[med] == key) {
            return true;
        } else if (a[med] > key) {
            return binarySearch(a, key, begin, med - 1);
        } else if (a[med] < key) {
            return binarySearch(a, key, med + 1, end);
        }

        return false; // unreachable
    }

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

        int result = 0;

        int n = Integer.parseInt(br.readLine());
        int[] S = new int[n];
        String[] inputs = br.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            S[i] = Integer.parseInt(inputs[i]);
        }

        int q = Integer.parseInt(br.readLine());
        String[] inputt = br.readLine().split(" ");
        for (String str : inputt) {
            if (binarySearch(S, Integer.parseInt(str), 0, n - 1)) {
                result++;
            }
        }

        System.out.println(result);
    }
}


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

int main()
{
  int x,n;
  int ans,ans1,ans2;
  int p[110],sa[110];
  
  cin >> x >> n;
  rep(i,n) cin >> p[i];
  
  if (n==0)
  {
    ans=x;
    goto OWARI;
  }
  
  rep(i,n)
    sa[i] = p[i] - x;

  ans=ans1=ans2=0;
  //+側
  rep(i,n)
  {
	  rep(j,n)
      {
        if (sa[j]==i)
          goto NEXT1;
      }
      ans1 = x + i;
//   cout << x << ":" << i << ":" << ans1 << endl;
	  break;

NEXT1:
    ;
  }

  //-側
  for (int i = 0; i < (int)(n); i++)
  {
	  rep(j,n)
      {
        if (sa[j]==-1*i)
          goto NEXT2;
      }
      ans2 = x - i;
//   cout << x << ":" << -1*i << ":" << ans2 << endl;
      break;

NEXT2:
    ;
  }
  
  ans=ans1;
//    cout << "abs(x - ans2)" << abs(x - ans2) << "abs(x - ans1)" << abs(x - ans1) << endl;
  if (abs(x - ans2) < abs(x - ans1))
  {
    ans=ans2;
  }
  else if (abs(x - ans2) == abs(x - ans1))
  {
    if (ans2 < ans1)
      ans=ans2;
  }

OWARI:
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 600000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
   
    
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
   
int TREE_MINIMUM(int x){
  while(left2[x] != NIL){
    x = left2[x];
  }
  return x;
}
   
   
int TREE_SUCCESSOR(int x){
  if(right2[x] != NIL)return TREE_MINIMUM(right2[x]);
  int y = p[x];
  while(y != NIL && x == right2[y]){
    x = y;
    y = p[y];
  }
  return y;
}
    
void TREE_DELETE(int z){
  int y,x;
  if(left2[z] == NIL || right2[z] == NIL)y = z;
  else y = TREE_SUCCESSOR(z);
   
  if(left2[y] != NIL)x = left2[y];
  else x = right2[y];
   
  if(x != NIL)p[x]=p[y];
  if(p[y] == NIL)root = x;
  else if(y == left2[p[y]])left2[p[y]] = x;
  else right2[p[y]] = x;
   
  if(y != z)key[z] = key[y];
   
}
   
   
bool SEARCH(int x,int k){
  if(k == key[x])return true;
  if(x == NIL)return false;
  if(k < key[x])return SEARCH(left2[x],k);
  else return SEARCH(right2[x],k);
}
   
    
void TREE_INSERT(int z){
  int y = NIL;
  int x = root;
    
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
    
}
   
int IndexSearch(int x){
  for(int i=0;i<MAX;i++){
    if(key[i] == x)return i;
  }
  return -1;
}
   
   
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
    
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
    
    
int main(){
  int val;
  string op;
  long long zr;                  
   
    
  scanf("%d",&n);
  Init();
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;      
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(SEARCH(root,val)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
          
    
    }
    else if(op == "delete"){
      scanf("%d",&val);
      int inthis = IndexSearch(val);
      if(inthis != -1){
      TREE_DELETE(inthis);
      }
    }
   
  }
    
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
   
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll crt=100;
  ll X,res=0;
  cin>>X;
  while(crt<X){
    ll r=crt/100;
    crt=crt+r;
    res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int N; cin >> N;
  vector<vector<ll>> num(10, vector<ll>(10, 0));
  
  reps(i,N){
    vector<int> d;
    int nn = i;
    while (nn){
      d.push_back(nn % 10);
      nn /= 10;
    }
    int a = d[0];
    int b = d.back();
    if (!a || !b) continue;
    num[a][b]++;
  }
  
  ll res = 0;
  
  reps(i,9){
    reps(j,9){
      res += num[i][j]*num[j][i];
    }
  }
  
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long int
const int INF=0x3f3f3f3f;
const int max_n=5e5+500;
char s[max_n];
int main()
{
	int n;
	char *l,*r;
	scanf("%s",s+200005);
	scanf("%d",&n);
	l=s+200005,r=s+200005+strlen(s+200005)-1;
	int flag=0;
	int f;
	while(n--){
		scanf("%d",&f);
		if(f==1){
			flag=!flag;
		}else{
			char ch;
			scanf("%d %c",&f,&ch);
			if(f==1){
				if(flag==0){
					--l;
					*l=ch;
				}else{
					++r;
					*r=ch;
				}
			}else{
				if(flag==1){
					--l;
					*l=ch;
				}else{
					++r;
					*r=ch;
				}
			}
		}
	}
	++r;
	*r='\0';
	if(flag==0){
		printf("%s\n",l);
	}else{
		char *k;
		for(k=r-1;k>=l;k--){
			//if(*k==0) printf("no");
			printf("%c",*k);
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int turn = 1;
  while (0 == 0) {
    ans++;
    turn = a[turn - 1];
    if (turn == 2) {
      break;
    }
    if (ans > N * 2){
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
//#include <ext/pb_ds/assoc_container.hpp> 
    // #include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e9+7;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
    // using namespace __gnu_pbds;
    // #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
    
    int32_t main()
    {
        IOS

      int n;
      cin>>n;
      int a[n][n];
      for(int i=0;i<n;++i)
        for(int j=0;j<n;++j)
            cin>>a[i][j];

    int dp[(1ll<<n)];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<(1ll<<n);++i) 
    {
        int cost=0;
        for(int j=0;j<n;++j)
        {
            if(i&(1ll<<j))
                for(int k=j+1;k<n;++k)
                {
                    if(i&(1ll<<k))
                        cost+=a[j][k];
                }
        }
        dp[i]=cost;
    }  
    int x[(1ll<<n)];
    memset(x,0,sizeof(x));
    for(int i=0;i<(1ll<<n);++i)
    {
        for(int j=i;j>=0;j=(j-1)&i)
        {
            int pr=i^j;
            x[i]=max(x[i],x[j]+dp[pr]);
            if(j==0)
                break;
        }
    }
    // for(int i=0;i<1ll<<n;++i)
    //     cout<<x[i]<<" ";

    cout<<x[(1ll<<n)-1];


     

    }       

Measured memory_bytes: 1280
a=int(input())
b=int(input())
c=int(input())
sum=int(input())
count=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if (i*500+j*100+k*50) == sum:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

ll N, A[200020];
map<ll,ll> m;

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
    ++m[A[i]];
  }
  sort(A, A + N, greater<ll>());

  int ans = 0;
  for(int i = 0; i < N; ++i) {
    if(m[A[i]] == 0) continue;

    // Ai < 2^n <= Ai*2
    ll j = 1;
    while(j <= A[i]) j <<= 1;
    if(A[i] * 2 == j) {
      if(m[A[i]] > 1) {
        ans += m[A[i]] / 2;
        m[A[i]] %= 2;
      }
    } else if(m[j - A[i]] > 0) {
      ans += min(m[A[i]], m[j - A[i]]);
      if(m[A[i]] >= m[j - A[i]]) {
        m[A[i]] -= m[j - A[i]]; m[j - A[i]] = 0;
      } else {
        m[j - A[i]] -= m[A[i]]; m[A[i]] = 0;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

const Int MAX = 510000;
const Int MOD = 1000000007;

Int fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (Int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
Int COM(Int n, Int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    Int n, k;
    cin >> n >> k;
    COMinit();
    Int blue = k;
    Int red = n - k;
    for (Int i = 1; i <= k; i++) {
        Int b = COM(blue - 1, i - 1);
        //if (b == 0) b = 1;
        Int r = COM(red - (i - 1) + i, i);
        //if (r == 0) r = 1;
        //cout << b << "  " << r << endl;
        dump(r * b % mod);
    }
    return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[100005];
ll a[100005];
ll func(ll i)
{
	ll d;
	if(dp[i]!=-1)
		return dp[i];
	if(i==1)
		return 0;
	d=func(i-1)+abs(a[i]-a[i-1]);
	if(i>2)
	d=min(d,func(i-2)+abs(a[i-2]-a[i]));
	dp[i]=d;
	return dp[i];
}
int main()
{
	ll i,n;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		dp[i]=-1;
	}
	cout<<func(n)<<endl;
}

Measured memory_bytes: 4864
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

from decimal import Decimal

def gcd(a, b):
	return gcd(b, a%b) if b else a

L = 10**9
LL = 10**18
N = ri()
A = []
for i in range(N):
	d = Decimal(rs())
	A.append(int(d*L))

h = defaultdict(int)
for i in range(N):
	g = gcd(A[i], LL)
	h[g] += 1

ans = 0
for g, c in h.items():
	for g2, c2 in h.items():
		if g == g2:
			if g*g % LL == 0:
				ans += c*(c-1)//2
		elif g < g2:
			if g*g2 % LL == 0:
				ans += c * c2
print(ans)



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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  vector<vector<int>> ans(H, vector<int>(W));
  rep(i,H) {
    rep(j,W) {
      if (i<H-B && j<A) cout << 0;
      else if (i<H-B) cout << 1;
      else if (j<A) cout << 1;
      else cout << 0;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
const char button[10][6] = {	{},
								{'.',',','!','?',' '},
								{'a','b','c'},
								{'d', 'e', 'f'}, 
								{'g', 'h', 'i'},
								{'j', 'k', 'l'},
								{'m', 'n', 'o'},
								{'p', 'q', 'r', 's'},
								{'t', 'u', 'v'},
								{'w', 'x', 'y', 'z',}};
const int num[10] = {0,5,3,3,3,3,3,4,3,4};
int main()
{
	int n;
	cin >> n;
	char line[1024];
	for (int i = 0; i < n; i++)
	{
		cin >> line;
		int len = strlen(line);
		int j = 0;
		while (j < len)
		{
			int next = j + 1;
			int count = 0;
			while(next < len  && line[next] == line[j])
			{
				next++;
				count++;
			}
			if ((line[j] - '0') != 0)
			{
				int number = line[j] - '0';
				int length = num[number];
				cout << button[number][count % length];
			}
			count = 0;
			j = next;
		}
		cout<<endl;

	}
	return 0;
}

Measured memory_bytes: 1156
L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];

K=int(input())

print(L[K-1])

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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int max_num=vec.at(0);
  for(int i=1;i<N;i++){
    if(max_num<vec.at(i)){
      max_num=vec.at(i);
    }
  }
  int sum=accumulate(vec.begin(),vec.end(),0);
  if(max_num<sum-max_num)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N, Cx = -1, Cy = -1, t = 0;
    cin >> N;
    vint x(N), y(N), h(N), dh(N), num(N);
    vector<bool> ok(N, true);
    rep(i, N)
    {
        cin >> x[i] >> y[i] >> h[i];
        if (i == 0)
            dh[i] = h[i];
        else
        {
            dh[i] = h[i] - h[i - 1];
        }
        if (h[i] == 0)
        {
            ok[i] = false;
            num.push_back(i);
        }
        else
        {
            t = i;
        }
    }
    rep(i, 101)
    {
        rep(j, 101)
        {
            if (i == 55 and j == 80)
            {
                int t9 = 0;
            }
            bool flag = true;
            rep(k, N)
            {
                if (k > 0 and ok[k] and ok[k - 1])
                {
                    if (dh[k] != abs(x[k - 1] - i) + abs(y[k - 1] - j) - abs(x[k] - i) - abs(y[k] - j))
                    {
                        goto R;
                    }
                }
            }
            Cx = i;
            Cy = j;
            rep(i, N - 1)
            {
                if (h[i] + abs(x[i] - Cx) + abs(y[i] - Cy) != h[i + 1] + abs(x[i + 1] - Cx) + abs(y[i + 1] - Cy))
                {
                    goto R;
                };
            }
            goto L;
        R:;
        }
    }
L:;
    int H = h[t] + abs(x[t] - Cx) + abs(y[t] - Cy);
    cout << Cx << " " << Cy << " " << H;
    return 0;
}

Measured memory_bytes: 256
e[4];t[]={10,50,100,500,e};i,z;main(n){for(;scanf("%d%d%d%d%d",&n,e,e+1,e+2,e+3),n;){for(i&&puts(""),i=4;i--;n-=e[i]*t[i]);for(;++i-4;z>0&&printf("%d %d\n",t[i],z))z=e[i]+n%t[i+1]/t[i];}}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void reverse_array_int(int* arr, int n)
{
    for (int i = 0; i < n / 2; i++) {
        int t = arr[i];
        arr[i] = arr[n - i - 1];
        arr[n - i - 1] = t;
    }
}

void reverse_array_char(char* arr, int n)
{
    for (int i = 0; i < n / 2; i++) {
        char t = arr[i];
        arr[i] = arr[n - i - 1];
        arr[n - i - 1] = t;
    }
}

int main(void)
{
    char s[100001];
    scanf("%s", s);

    int str_len = strlen(s);
    int* ans = calloc(str_len, sizeof(int));

    for (int times = 0; times < 2; times++) {
        int cnt = 0;
        for (int i = 0; i < str_len; i++) {
            if (s[i] == 'R') {
                cnt++;
            } else {
                ans[i] += cnt / 2;
                ans[i - 1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }
        reverse_array_char(s, str_len);
        reverse_array_int(ans, str_len);
        for (int i = 0; i < str_len; i++) {
            s[i] = (s[i] == 'R' ? 'L' : 'R');
        }
    }

    for (int i = 0; i < str_len; i++) {
        printf("%d%c", ans[i], i == str_len - 1 ? '\n' : ' ');
    }

    free(ans);
    return 0;
}


Measured memory_bytes: 896
///RAIYAN_MAHIN
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n,k; cin >> n >> k;
    vector<ll > rm;
    vector<ll >::iterator it;
    ll s = 0;
    for(int i = 1; i <= n; i++)
    {
        ll x; cin >> x;
        rm.push_back(x);
    }
    //ll w = accumulate(rm.begin(),rm.end(),0);
    sort(rm.begin(),rm.end());
    if(k >= n) cout << 0 << '\n';
    //if(k == 0 ) cout << w << '\n';
    if(k < n)
    {
        for(int i = 0; i < (n - k) ; i++)
        {
            s += rm[i];
            
        }
        cout << s << '\n';
        
    }
}
    

Measured memory_bytes: 2420
from collections import deque
#import re

n = int(input())
cmds = deque([])

que = deque([])

for i in range(n):
    stdin = input()
    #if re.search(' ', stdin):
    if stdin.find(' ') != -1:
        cmd, key = stdin.split()
    else:
        cmd = stdin

    if cmd == 'insert':
        que.appendleft(key)
    elif cmd == 'delete':
        if que.count(key) > 0:
            que.remove(key)
    elif cmd == 'deleteFirst':
        que.popleft()
    elif cmd == 'deleteLast':
        que.pop()

print(' '.join(list(que)))


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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int r=0,l=0,a;
    for(int i=0; i<m; i++){
        cin >> a;
        if(a<x)
        l++;
        else
        r++;
    }
    if(l>r)
    cout << r << endl;
    else
    cout << l << endl;
}

Measured memory_bytes: 256