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

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		
		int N = sc.nextInt();
		int cnt = 0;
		
		for(int i=0; i<=3000; i++) {
			for(int j=0; j<=3000; j++) {
				if((N - R*i - G*j)%B==0 && (N - R*i - G*j)>=0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<int> V(N);
    for(int i = 0;i < N;i++)cin >> V[i];

    int num = V[N-1];
    ll cnt = num;
    for(int i = N-2;i >= 0;i--){
        if(num - 1 != V[i]){
            cnt += V[i];
        }
        num = V[i];
    }
    if(V[0] != 0)cnt = -1;
    for(int i = 1;i < N;i++){
        if(V[i] - V[i-1] > 1)cnt = -1;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string ans="a";
void Func(ll n,ll cnt){
    if(n==N+1){
        cout<<ans<<endl;
        return;
    }
    for(ll i=1;i<=cnt;i++){
        ans.push_back('a'+i-1);
        if(i==cnt){
            Func(n+1,cnt+1);
        }else{
            Func(n+1,cnt);
        }
        ans.pop_back();
    }
}
int main(){
    cin>>N;
    Func(2,2);
    return 0;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> cal(m);
	REP(i, m)
		cin >> cal[i];
	int west=0;
	vi east(n,0);
	REP(i, n) {
		REP(j, m) {
			if (cal[j][i] == 'E') {
				east[i]++;
			}else{
				west++;
			}
		}
	}
	int mi=west;
	int now = west;
	int idx = 0;
	REP(i, n) {
		now += east[i]*2-m;
		if (now < mi) {
			mi = now;
			idx = i+1;
		}
	}

	cout << idx << " " << idx + 1 << endl;
}

Measured memory_bytes: 4504
import java.util.*;
import java.io.*;
public class Main  {
    public static void main(String args[]) {
      FastScanner fs=new FastScanner();    
      PrintWriter out=new PrintWriter(System.out);
      
      int n=fs.nextInt();
      long a[]=fs.readArray(n);
      long mod=(long)1e9+7;
      int i;
      
      long p[]=new long[n];
      p[n-1]=a[n-1];
      for(i=n-2;i>=0;i--)
      {
          p[i]=(a[i]%mod+p[i+1]%mod);
          p[i]%=mod;
      }
      long pro=1;
      long fp=0;
      long diff;
      for(i=0;i<n;i++)
      {
              diff=p[i]-a[i];
              pro=(diff*a[i]);
              pro%=mod;
              fp+=pro;
              fp+=mod;
              fp%=mod;
         
      }
      out.println(fp);
        
        out.flush();
        out.close();
    }
	static void ruffleSort(int[] a) {
 		Random random=new Random();
		int n=a.length;
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
}
        class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while (!st.hasMoreTokens())
				try {
				st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		String nextLine(){
		    String str="";
		    try{
		        str=br.readLine();
		    }catch(IOException e){
		        e.printStackTrace(); }
		    return str;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long[] readArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

int n;
int ans[100003];
iii A[100003];
priority_queue<int> can;
priority_queue<ii, vector<ii>, greater<ii> > pq;

int main()
{
	// freopen("input.in", "r", stdin);

	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &A[i].fi.fi);
	for(int i = 0; i < n; i++) scanf("%d", &A[i].fi.se);
	for(int i = 0; i < n; i++) A[i].se = i;
	sort(A, A+n, [](iii a, iii b) {return (a.fi.se == b.fi.se)? a.fi.fi < b.fi.fi : a.fi.se < b.fi.se;});

	for(int i = 0; i < n; i++) pq.push({A[i].fi.fi, i});

	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		if(A[i].fi.fi <= A[i].fi.se)
			continue;

		while(pq.size() && pq.top().fi <= A[i].fi.se)
		{
			if(pq.top().se > i) 
				can.push(pq.top().se);
			pq.pop();
		}
		if(!can.size())
		{
			printf("No\n");
			return 0;
		}
		else
		{
			++cnt;
			swap(A[i].fi.fi, A[can.top()].fi.fi);
			pq.push({A[can.top()].fi.fi, can.top()});
			can.pop();
		}
	}
	if(cnt <= n-2) printf("Yes\n");
	else printf("No\n");
	// printf("%d\n", cnt);
	// sort(A, A+n, [](iii a, iii b) {return a.se < b.se;});
	// for(int i = 0; i < n; i++) printf("%d%c", A[i].fi.fi, (i == n-1)? '\n' : ' ');
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
#define N 505
using namespace std;
int n,a[N];
int ans[N*N],arr[N];
bool cmp(int ta,int tb){
    return a[ta]<a[tb];
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),ans[a[i]]=i,arr[i]=i;
    sort(arr+1,arr+n+1,cmp);
    for(int i=1;i<=n;i++){
        int v=arr[i],cnt=v-1;
        for(int j=1;j<a[v];j++)
            if(ans[j]==0&&cnt!=0) ans[j]=v,cnt--;
        if(cnt!=0) return puts("No"),0;
    }
    for(int i=n;i>=1;i--){
        int v=arr[i],cnt=n-v;
        for(int j=n*n;j>a[v];j--)
            if(ans[j]==0&&cnt!=0) ans[j]=v,cnt--;
        if(cnt!=0) return puts("No"),0;
    }
    puts("Yes");
    for(int i=1;i<=n*n;i++) printf("%d ",ans[i]);
    return 0;
}

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

//string型文字列をint型整数にして返す
int str_to_num(string s) {return atoi(s.c_str());}

int main(){
  string a,b; cin >> a >> b;
  string s = ""; REP(i,str_to_num(b)){s += a;}
  string t = ""; REP(i,str_to_num(a)){t += b;}
  cout << (s<=t ? s: t) << "\n";
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b; cin >> n >> a >> b;
  cout << (n >= a
	   ? n / (a + b) * a + (n % (a + b) >= a ? a : (n % (a + b)))
	   : n);
}
  


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 405
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, a[MAXN];
LL f[MAXN][MAXN], b[MAXN];

int main()
{
	scanf("%d", &n);
	memset(f, 0x3f, sizeof(f));
	for(rint i=1; i<=n; ++i)
	{
		scanf("%d", &a[i]);
		b[i]=b[i-1]+a[i];
	}
	for(rint i=1; i<=n; ++i)
		f[i][i]=a[i];
	for(rint len=2; len<=n; ++len)
	{
		for(rint l=1; l+len-1<=n; ++l)
		{
			int r=l+len-1;
			for(rint k=l; k<r; ++k)
				f[l][r]=min(f[l][r], f[l][k]+f[k+1][r]);
			//printf("%d %d %lld!!\n", l, r, f[l][r]);
			f[l][r]+=b[r]-b[l-1];
		}
	}
	printf("%lld\n", f[1][n]-b[n]);
	return 0;
}

Measured memory_bytes: 1408
import math
N=input().split()
X=int(math.fabs(int(N[0])))
K=int(N[1])
D=int(N[2])
if X-K*D>=0:
    print(X-K*D)
else:
    syou=X//D
    x=X-syou*D
    y=X-(syou+1)*D
    if K%2==0:
        if syou%2==0:
            print(x)
        else:
            print(int(math.fabs(y)))
    else:
        if syou%2==0:
            print(int(math.fabs(y)))
        else:
            print(x)

Measured memory_bytes: 9212
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
//author_name:krij
//date:2018/11/18
//title:AGC 010 E Rearranging
//ÒòÎªÇÓÅ³£¬ËùÒÔÌÓ±ÜÉúÃü£¬ÒÔ²»µÖ¿¹ÔÚ×îºÚ°µµÄ³ÁÂÙÖÐÉú³ö½¾°Á£¬ÒòÎª½¾°Á£¬ËùÒÔ²»Ñ¡ÔñÉú£¬ËùÒÔ¾Ü³â´Ö±ÉµÄÀÖ¹ÛÖ÷Òå¡£
//Ìì²ÅµÄ±¯¾çµØÓÚ±»Ð¡¶øÊæÊÊµÄÃûÍûËùÊø¸¿¡£
//It's human to lie. Most of the time we can't even be honest with ourselves.

bool done[2020];
bool e[2020][2020];
int a[2020];
int n;

inline vector<int> merge(const vector<int> a,const vector<int> b)
{
	vector<int> ret(a.size()+b.size());
	int a1=0,b1=0;
	while(a1<a.size()||b1<b.size())
	{
		if(a1<a.size()&&(b1>=b.size()||b[b1]<a[a1])) ret[a1+b1]=a[a1++];
		else ret[a1+b1]=b[b1++];
	}
	return ret;
}

vector<int> dfs(int u)
{
	done[u]=true;
	vector<int> ret;
	for(int i=0;i<n;i++)
	{
		if(done[i]||!e[u][i])
			continue;
		vector<int> cur=dfs(i);
		cur.insert(cur.begin(),a[i]);
		ret=merge(ret,cur);
	}
	return ret;
}

void solve()
{
	sort(a,a+n);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(i!=j&&(__gcd(a[i],a[j])!=1||i==n||j==n))
				e[i][j]=e[j][i]=true;
	vector<int> ret=dfs(n);
	for(int i=0;i<ret.size();i++)
	{
		if(i) printf(" ");
		printf("%d",ret[i]);
	}
	printf("\n");
	return;
}

void run()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	solve();
	return;
}

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

Measured memory_bytes: 4736
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
    return 0;
}

Measured memory_bytes: 768
from collections import defaultdict

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
for w in range(10):
    for u in range(10):
        for v in range(10):
            if c[u][v] > c[u][w] + c[w][v]:
                c[u][v] = c[u][w] + c[w][v]

cost = 0
for _ in range(H):
    lv = map(int, input().split())
    for v in lv:
        if v >= 0:
            cost += c[v][1]
print(cost)

Measured memory_bytes: 40300
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    ll res = 0;

    string my_hand;
    for (int i = 0; i < n; i++)
    {
        if (t[i] == 'r') {
            if (i >= k) {
                if (t[i-k] == t[i] && my_hand[i-k] == 'p') {
                    if (t[i+k] == 'r') {
                        my_hand += 'r';
                    } else if (t[i+k] == 's') {
                        my_hand += 's';
                    } else if (t[i+k] == 'p') {
                        my_hand += 'p';
                    }
                } else {
                    my_hand += 'p';
                    res += p;
                }
            } else {
                 my_hand += 'p';
                    res += p;
            }

        } else if (t[i] == 's') {
            if (i >= k) {
                if (t[i-k] == t[i]  && my_hand[i-k] == 'r') {
                    if (t[i+k] == 'r') {
                        my_hand += 'r';
                    } else if (t[i+k] == 's') {
                        my_hand += 's';
                    } else if (t[i+k] == 'p') {
                        my_hand += 'p';
                    }
                } else {
                    my_hand += 'r';
                    res += r;
                }
            } else {
                 my_hand += 'r';
                    res += r;
            }
        } else if (t[i] == 'p') {
            if (i >= k) {
                if (t[i-k] == t[i]  && my_hand[i-k] == 's') {
                    if (t[i+k] == 'r') {
                        my_hand += 'r';
                    } else if (t[i+k] == 's') {
                        my_hand += 's';
                    } else if (t[i+k] == 'p') {
                        my_hand += 'p';
                    }
                } else {
                    my_hand += 's';
                    res += s;
                }
            } else {
                 my_hand += 's';
                res += s;
            }
        }
    }

    cout << res << "\n";
    

}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> e(n);
  int u,v;
  rep(i,m){
    cin >> u >> v;
    e[u-1].push_back(v-1);
  }
  int s,t;
  cin >> s >> t;
  s--,t--;
  vector<vector<int>> dist(n,vector<int>(3,-1));
  queue<pair<int,int>> q;
  dist[s][0]=0;
  q.push({s,0});
  while(!q.empty()){
    auto now=q.front();
    q.pop();
    int t=(now.second+1)%3;
    for(auto nx:e[now.first]){
      if(dist[nx][t]!=-1) continue;
      dist[nx][t]=dist[now.first][now.second]+(t?0:1);
      q.push({nx,t});
    }
  }
  cout << dist[t][0] << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define MaxN 100003

int N, M, Ans;
int f[MaxN], deg[MaxN], fir[MaxN], to[MaxN], nxt[MaxN], cnt;

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void add(int aa, int bb) {
	nxt[++cnt] = fir[aa], to[cnt] = bb, fir[aa] = cnt;
	return;
}

void topo() {
	queue<int> Que;
	for(int i = 1; i <= N; ++i)
		if(deg[i] == 0)
			Que.push(i);
	while(!Que.empty()) {
		int str = Que.front();
		Que.pop();
		for(int i = fir[str]; i; i = nxt[i]) {
			f[to[i]] = max(f[to[i]], f[str] + 1);
			--deg[to[i]];
			if(deg[to[i]] == 0) Que.push(to[i]);
		}
	}
	return;
}

int main() {
	int u, v;
	N = Rd(), M = Rd();
	for(int i = 1; i <= M; ++i)
		u = Rd(), v = Rd(), add(u, v), ++deg[v];
	topo();
	for(int i = 1; i <= N; ++i)
		if(f[i] > Ans)
			Ans = f[i];
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 2432
import sys


def solve(X):
    money = 100
    res = 0
    while (money < X):
        money *= 1.01
        money = int(money)
        res += 1
    return res


def main():
    input = sys.stdin.buffer.readline
    X: int = int(input())
    print(solve(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <map>

using namespace std;
 
int main(void) {
	long long N, Q;
	cin >> N;
	
	long long sum = 0;
	map<long long, long long> data;
	for (int i = 0; i < N; i++) {
		long long val;
		cin >> val;
		auto it = data.find(val);
		if (it == data.end()) {
			data.insert({val, 1});
		} else {
			it->second += 1;
		}
		sum += val;
	}
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		long long B, C;
		cin >> B;
		cin >> C;
		
		auto itB = data.find(B);
		auto itC = data.find(C);
		if (itB != data.end()) {
			long long d = (C - B) * itB->second;
			if (itC == data.end()) {
				data.insert({C, itB->second});
			} else {
				itC->second += itB->second;
			}
			data.erase(itB);
			sum += d;
		}
		cout << sum << endl;
	}
}


Measured memory_bytes: 7580
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	map<ll, ll> mp;
	for (ll i = 0; i < n; i++) mp[a[i]] = i % 2;

	sort(ALL(a));
	ll cnt = 0;
	for (ll i = 0; i < n; i++) {
		if (mp[a[i]] != i % 2) cnt++;
	}
	cout << cnt / 2 << endl;
}

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

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

	int d, t, s;
	cin >> d >> t >> s;
	if (d > t * s) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}

	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        greatestCommonDivisor(a, b);
    }

    private static void greatestCommonDivisor(int a, int b) {
        while (b > 0) {
            int mod = a % b;
            a = b;
            b = mod;
        }
        System.out.println(a);
    }
}



Measured memory_bytes: 26336
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){
        int n;
        scanf("%d ",&n);
        string a[n];
        for(int i=0;i<n;i++){
                getline(cin,a[i]);
                while(1){
                int index=0;
                index=a[i].find("Hoshino",index);
                if((int)string::npos==index)break;
                a[i][index+6]='a';
                }
        }
        for(int i=0;i<n;i++){
        cout<<a[i]<<"\n";
        }
        return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int dy[]={0,-1,0,1},dx[]={1,0,-1,0};

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int x; cin>>x;
	int ans=1;
	for(int i=2;i*i<=x;++i){
		int j=i;
		while(j<=x)j*=i;
		ans=max(ans,j/i);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	int n;
	cin>>n;
	for(int i=1; i<n+1; i++){
		int a=i*1.08;
		if(a==n){
			cout<<i<<endl;
			return 0;
		}
		if(a>n){
			cout<<":("<<endl;
			return 0;
		}
	}
	return 0;

}



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

using namespace std;
int factorial(int a)
{
    int fact=1;
    while(a>=1)
    {
        fact =fact*a;
        a--;
    }return fact;
}

int main()
{
    int n,x,x1,y,y1;
    cin>>n;
    int b[n];
    double k=0.0;
    int z=factorial(n);
    int a[n][2];
    for(int i=0; i<n; i++)
    {
        b[i]=i;
        for(int j=0; j<2; j++)
            cin>>a[i][j];
    }
    for(int i=0; i<n-1; i++)
    {
        x=a[b[i]][0];
        y=a[b[i]][1];
        x1=a[b[i+1]][0];
        y1=a[b[i+1]][1];
        k=k+sqrt(pow(x-x1,2)+pow(y-y1,2));
    }

    while(next_permutation(b,b+n))
    {
        for(int i=0; i<n-1; i++)
        {
            x=a[b[i]][0];
            y=a[b[i]][1];
            x1=a[b[i+1]][0];
            y1=a[b[i+1]][1];
            k=k+sqrt(pow(x1-x,2)+pow(y1-y,2));

        }

    }
    cout<<showpoint<<fixed<<setprecision(10);
    cout<<k/z<<endl;
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
res = 0

for ai in range(a + 1):
  for bi in range(b + 1):
    for ci in range(c + 1):
      total = 500 * ai + 100 * bi + 50 * ci
      if x == total:
        res += 1
        
print(res)

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

stack<char> st;
int main(){
    string s;
	cin>>s;
	int ans=s.size();
	for(int i=0;i<(int)s.size();i++){
		if(!st.empty()&&st.top()=='S'&&s[i]=='T'){
			ans-=2;
			st.pop();
		}
		else
		st.push(s[i]);
	}
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 644
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
typedef long long ll;

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

    int len = s.size();
    ll ans = 0;
    for (int i = 0; i < (1 << (len - 1)); i ++)
    {
        int bit[len];
        for (int j = 0; j < len - 1; j ++)
        {
            if (i & (1 << j))
            {
                bit[j] = 1;
            } else {
                bit[j] = 0;
            }
        }
        bit[len - 1] = 1;

        ll sum = 0;
        ll tmp = s[0] - '0';
        for (int k = 0; k < len; k ++)
        {
            if (bit[k]) {
                sum += tmp;
                tmp = s[k + 1] - '0';
            } else {
                tmp = tmp * 10 + (s[k + 1] - '0');
            }
        }
        ans += sum;
    }

    cout << ans << endl;



}


Measured memory_bytes: 256
def init(n):
    global par, rank
    par = [i for i in range(n)]
    rank = [0] * n

def find(x):
    global par
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    global par, rank
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

def same(x, y):
    return find(x) == find(y)

N, M = map(int, input().split())
init(N + M)
for i in range(N):
    a = list(map(int, input().split()))
    for L in a[1:]:
        unite(i, L - 1 + N)
ans = "YES"
for i in range(N):
    if not same(0, i):
        ans = "NO"
        break
print(ans)

Measured memory_bytes: 68484
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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(){
    ll N, K; cin >> N>>K;
    vll A(N);
    REP(i, N) {cin >> A[i]; A[i]--;}
    set<ll> visited;
    ll i = 0;
    ll loopHead;
    while(1){
        if(visited.count(i)){
            loopHead = i;
            break;
        }
        else{
            visited.insert(i);
            i = A[i];
        }
    }
    vll loop;
    i = loopHead;
    while(1){
        loop.push_back(i);
        i = A[i];
        if(i == loopHead) break;
    }
    if(K >= visited.size() - loop.size()){ //* enter the loop
        K -= (visited.size() - loop.size());
        K %= loop.size();
        cout << loop[K]+1<<endl;
    }
    else{ //* ends before the loop
        i = 0;
        while( K > 0){
            i = A[i];
            K --;
        }
        cout << i+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 15092
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int l, r;
	cin >> l >> r;
	if (r - l >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	int ans = Inf;
	for (int i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

vector<int> calc(vector<int> &x, vector<int> &v) {
	int N = x.size();
	vector<int> res(N+1);

	res[0] = 0;
	int sum = v[0];
	for(int i = 1; i <= N; ++i) {
		res[i] = max(res[i-1], sum - x[i-1]);
		sum += v[i];
	}
	return res;
}

signed main(){
	int N, C;
	cin >> N >> C;
	vector<int> x(N), v(N);
	for(int i = 0; i < N; ++i) {
		cin >> x[i] >> v[i];
	}

	vector<int> rx = x, rv = v;
	for(int i = 0; i < N; ++i) rx[i] = C - rx[i];
	reverse(ALL(rx));
	reverse(ALL(rv));

	vector<int> mx = calc(x, v), rmx = calc(rx, rv);

	int res = 0;
	for(int k = 0; k < 2; ++k) {
		res = max(res, mx[N]);
		for(int i = 0; i < N; ++i) {
			res = max(res, mx[i+1] + rmx[N - i - 1] - x[i]);
		}
		swap(x, rx);
		swap(v, rv);
		swap(mx, rmx);
	}
	cout << res << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

const int N = 1000;
ll x[N], y[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
  ll p = (llabs(x[0])+llabs(y[0]))%2, m = 0;
  bool ok = true;
  for (int i = 0; i < n; i++) {
    if (p != (llabs(x[i])+llabs(y[i]))%2) {
      ok = false;
      break;
    }
    m = max(m, llabs(x[i]) + llabs(y[i]));
  }
  if (ok) {
    vector<ll> v;
    v.push_back(1);
    if (p==0) v.push_back(1);
    while (v.back()*2 < m+p) v.push_back(v.back()*2);
    cout << v.size() << endl;
    for (int i = 0; i < v.size(); i++) {
      cout << v[i];
      if (i < v.size() - 1) cout << " ";
    }
    cout << endl;
    for (int i = 0; i < n; i++) {
      ll l = x[i], r = y[i];
      string s;
      for (int j = v.size() - 1; j >= 0; j--) {
        if (llabs(l) > llabs(r)) {
          if (l < 0) {
            l += v[j];
            s.push_back('L');
          } else {
            l -= v[j];
            s.push_back('R');
          }
        } else {
          if (r < 0) {
            r += v[j];
            s.push_back('D');
          } else {
            r -= v[j];
            s.push_back('U');
          }
        }
      }
      assert(!l); assert(!r);
      reverse(s.begin(), s.end());
      cout << s << endl;
    }
  } else cout << "-1\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = s.charAt(i) - '0';
		}
		long ans = 0;
		for(int i=0;i<1<<(n-1);i++) {
			long sum = 0;
			long now = 0;
			for(int j=0;j<n;j++) {
				now = now * 10 + a[j];
				if ((i >> j & 1) == 1) {
					sum += now;
					now = 0;
				}
			}
			sum += now;
			ans += sum;
		}
		System.out.println(ans);
	}

}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}


class RMQ{
public:
    int n;
    vector<int> dat;
    // 初期化
    void init(int n_){
        n=1;
        while(n<n_)n*=2;
        dat.resize(n * 2 - 1, INT_MAX);
    }
    // k番目の値(0-indexed)をaに変更
    void update(int k,int a){
        // 葉の節点
        k+=n-1;
        dat[k]=a;
        // のぼりながら更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    // [a,b)の最小値を求める
    // kは節点の番号、l,rはその節点が[l,r)に対応づいていることを表す
    // したがって、外からはquery(a,b,0,0,n)として呼ぶ
    int _query(int a,int b,int k,int l,int r){
        if(r<=a||b<=l)return INT_MAX;
        else if(a<=l&&r<=b)return dat[k];
        int vl=_query(a,b,k*2+1,l,(l+r)/2);
        int vr=_query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
    int query(int a,int b){
        return _query(a,b,0,0,n);	
    }
};



int N;
int P[200010];
int RP[200010];
RMQ rmq[2];


// [l, r)
pii query(int l, int r){
    int v1= rmq[l % 2].query(l, r);
    int x1 = RP[v1];
    int v2 = rmq[(l % 2) ^ 1].query(x1, r);
    int x2 = RP[v2];
    return pii(x1, x2);
}

struct state{
    int l;
    int r;
    int v1;
    int v2;
    bool operator<(const state &s)const{
        return v1 > s.v1;
    }
};

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

    for(int i = 0; i < 2; i++)
        rmq[i].init(N);

    for(int i = 0; i < N; i++){
        rmq[i % 2].update(i, P[i]);
    }


    // priority_queue<pair<pii, pii> , vector<pair<pii, pii>>, greater<pair<pii, pii> > > pq;    
    priority_queue<state> pq;
    
    int l = 0;
    int r = N;
    pii p = query(l, r);
    int x1 = p.first;
    int x2 = p.second;

    vector<int> ans;

    // [l, x1), (x1, x2), (x2, r)
    pq.push(state{0, N, P[x1], P[x2]});

    while(pq.size()){
        state s = pq.top(); pq.pop();

        // pair<pii, pii> pp = pq.top(); pq.pop();
        ans.push_back(s.v1);
        ans.push_back(s.v2);

        // ans.push_back(pp.first.first);
        // ans.push_back(pp.first.second);

        int l = s.l;
        int r = s.r;

        // [l, r)を分割する
        int x1 = RP[s.v1];
        int x2 = RP[s.v2];
        if(x1 - l != 0){
            pii p = query(l, x1);
            pq.push(state{l, x1, P[p.first], P[p.second]});
        }
        if(x2 - (x1 + 1) != 0){
            pii p = query(x1 + 1, x2);
            pq.push(state{x1 + 1, x2, P[p.first], P[p.second]});
        }
        if((r - (x2 + 1) != 0)){
            pii p = query(x2 + 1, r);
            pq.push(state{x2 + 1, r, P[p.first], P[p.second]});
        }
    }


    for(int a : ans){
        cout << a << " ";
    }
    cout << endl;
    

    return 0;
}


Measured memory_bytes: 8692
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0;i < N;i++)cin >> a[i];

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

	if(a[0] == a[N-1]){
		if(a[0] == N - 1 || a[0] * 2 <= N){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	else{
		if(a[0] != a[N-1] - 1){
			cout << "No" << endl;
			return 0;
		}
		
		int num = a[0];
		int id = 0;
		while(id < N && a[id] == num){
			id++;
		}

		int group_num = num + 1;

		if(group_num - id <= 0 || !(N - id >= 2 * (group_num - id))){
			cout << "No" << endl;
		}
		else{
			cout << "Yes" << endl;
		}
	}
}


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

int const N = 200000, M = 1000000;
int tr[M + 1][26], fr[M + 1][26], T;
bool g[26];
char in[M + 1];
ll an;

struct G{
	int sz;
	string s;
	void sc(){
		scanf("%s", in);
		s = in;
		reverse(s.begin(), s.end());
		sz = s.size();
	}
	bool operator <(G const &o)const { return sz > o.sz; }
}ss[N];

int m;
string s;

void ad(int i = 0, int u = 0){
	if (i == 0)f(j, 0, 26)g[j] = false;
	if (i == m)return;
	
	int z = s[i] - 'a';
	if (tr[u][z] == 0)tr[u][z] = ++T;
	u = tr[u][z];
	
	if (i + 2 == m)an += fr[u][s[i + 1] - 'a'];
	
	ad(i + 1, u);
	
	f(j, 0, 26)if (g[j])++fr[u][j];
	g[z] = true;
	
	if (i == 0)f(j, 0, 26)if (g[j])++fr[0][j];
}

int main(){
	int n;
	scanf("%d", &n);
	f(i, 0, n)ss[i].sc();
	sort(ss, ss + n);
	f(i, 0, n){
		s = ss[i].s;
		m = ss[i].sz;
		if (m == 1)an += fr[0][s[0] - 'a'];
		ad();
	}
	printf("%lld\n", an);
}

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

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(int)(a);i--)

#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define MOD 1000000007

typedef long long ll;

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

    string s,t;
    cin >> s;
    sort(s.begin(), s.end());

    cin >> t;
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) cout << "Yes\n";
    else cout << "No\n";
    
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int a,b,c;
    cin >> a >> b >> c;

    int count=0;
    while(!(a==b && b==c)){
        if(a==max(a,max(b,c))){
            if(a==b){
                c+=2;
            }else if(a==c){
                b+=2;
            }else if(b==c){
                b++;
                c++;
            }else{
                if(b<c)b+=2;
                else c+=2;
            }
        }else if(b==max(a,max(b,c))){
            if(b==c){
                a+=2;
            }else if(a==c){
                a++;
                c++;
            }else{
                if(a<c)a+=2;
                else c+=2;
            }
        }else{
            if(a==b){
                a++;
                b++;
            }else{
                if(a<b)a+=2;
                else b+=2;
            }
        }
        count++;
    }

    cout << count << endl;

    return 0;
}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
int n;cin>>n; vi v(n); repi(i,n) cin>>v[i];
	ll c=0;
	/*repi(i,n-1){
		rep(j,i+v[i]+1,n) if(j-i==v[i]+v[j]) c++; 
	}*/
	vi b(n,0);
	repi(i,n) if((i-v[i])>0) b[i-v[i]]++;
	//repi(i,n) cout<<b[i]<<" ";cout<<endl;
	repi(i,n) if((i+v[i])<n) c+=b[i+v[i]];
	
	db(c);
	return 0;
}
/*

1    3
 1 3


		  2  3  3  2  1
    +1            -2











*/


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e8;

//---main---------------------------------------------
int main(){
    //main
    int D,T,S;
    cin >> D >> T >> S;

    if(T > D/S) cout << "Yes" << endl;
    else if(T==D/S && D%S==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
// Last Change: 08/10/2019 21:43:00.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

bool CheckSame(vector<char> &a, vector<char> &b) {
  for (int i = 0; i < 10; ++i) {
    if (a[i] != b[i]) {
      return false;
    }
  }
  return true;
}

int main() {
  ll N;
  cin >> N;
  char ipt[11];
  ipt[10] = '\0';
  vector<string> s(N);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> ipt[j];
    }
    sort(ipt, ipt + 10);
    s[i] = string(ipt);
  }

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

  s.push_back("");
  ll ans = 0, cnt = 1;
  string last = "";
  for (int i = 0; i <= N; ++i) {
    if (last != s[i]) {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
      last = s[i];
    } else {
      ++cnt;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);
ll H,W;
vector<vector<ll> > f(21,vector<ll>(21,0));
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};

ll bfs(ll x,ll y){
    queue<P> que;
    que.push(P(x,y));
    
    ll d[21][21];
    rep(i,21)rep(j,21) d[i][j]=INF;
    d[x][y]=0;
    
    ll ret=0;
    while(que.size()){
        P p=que.front();
        ll tmp=d[p.a][p.b];
        que.pop();
        
        rep(i,4){
            ll nx=p.a+dx[i],ny=p.b+dy[i];
            if(1<=nx && nx<=H && 1<=ny && ny<=W && f[nx][ny]==0 && d[nx][ny]==INF){
                d[nx][ny]=tmp+1;
                chmax(ret,d[nx][ny]);
                que.push(P(nx,ny));
            }
        }
    }
    
    return ret;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    cin>>H>>W;
    rep1(i,H){
        string tmp; cin>>tmp;
        rep1(j,W){
            if(tmp[j-1]=='#') f[i][j]=1;
            else f[i][j]=0;
        }
    }
    
    ll ans=0;
    rep1(i,H)rep1(j,W){
        //(i,j)
        if(f[i][j]==0) chmax(ans,bfs(i,j));
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 3596
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

X = lines[0][0]
N = lines[0][1]

if N == 0 then
  print X
else
  found = false
  i = 0
  while found == false do
    if lines[1].include?(X-i) == false then
      ans = X - i
      found = true
    elsif lines[1].include?(X+i) == false then
      ans = X + i
      found = true
    end
    i += 1
  end
  print ans
end

Measured memory_bytes: 14328
#include<iostream> 
#include<cstring>
using namespace std;
int main()
{
	int i,j,k;
	string s;
	cin>>s;
	k=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(j=i+1;j<s.size();j++)
			{
				if(s[j]=='F')
				{
					k=1;
					break;
				}
			}
		}
		if(k==1)
		{
			break;
		}
	}
	if(k==0)
	cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
	return 0;
}

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

int main(){
  int k,a,b;
  cin >> k >> a >> b;
  string ans = "NG";
  for(int i=a;i<=b;i++){
    if(i%k==0){
      ans = "OK";
      break;
    }
  }
  cout << ans;
  
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> picture(H*W);
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> picture.at(i*W+j);
    }
  }
  for (int j=0; j<W+2; j++) {
    cout << "#";
  }
  cout << endl;
  for (int i=0; i<H; i++) {
    cout << "#";
    for (int j=0; j<W; j++) {
      cout << picture.at(i*W+j);
    }
    cout << "#" << endl;
  }
  for (int j=0; j<W+2; j++) {
    cout << "#";
  }
  cout << endl;
}

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

int main(){
	int n;
	cin>>n;
	int A=0,B=0,C=0,D=0;
	vector<string> s(n);
	vector<char> a(n);
	for(int i=0;i<n;i++){
		cin>>s[i];
		a[i]=s[i].at(0);
		if(a[i]=='A'){
			A++;
		}
		else if(a[i]=='W'){
			B++;
		}
		else if(a[i]=='T'){
			C++;
		}
		else if(a[i]=='R'){
			D++;
		}
	}
    cout<<"AC "<<"x "<<A<<endl;
    cout<<"WA "<<"x "<<B<<endl;
	cout<<"TLE "<<"x "<<C<<endl;
	cout<<"RE "<<"x "<<D<<endl;
}

Measured memory_bytes: 6408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int mmin(int &a, int b) {
	a = min(a, b);
	return a;
}
int mmax(int &a, int b) {
	a = max(a, b);
	return a;
}
int nibl(vector<long long> &v,long long tan) {
	int up = v.size() - 1;
	int lo = 0;
	if (v[up] == tan) {
		return up;
	}
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] <= tan) {
			lo = mi;
		}
		else if (tan < v[mi]) {
			up = mi;
		}
	}
	return lo;
}
int main() {
	int n, m;
	cin >> n >> m;
	string he = "WBR";
	vector<vector<int> > co(3, vector<int>(n, 0));
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < 3; k++) {
				if (he[k] == s[j]) {
					co[k][i]++;
				}
			}
		}
	}
	vector<vector<int> > sc(3, vector<int>(n+1));
	for (int i = 0; i < 3; i++) {
		sc[i][0] = 0;
		for (int j = 0; j < n; j++) {
			sc[i][j+1] = sc[i][j] + co[i][j];
		}
	}
	int ans = m * n;
	for (int i = 1; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int fi =sc[0][i]+sc[1][j]-sc[1][i]+sc[2][n]-sc[2][j];
			mmin(ans, m*n - fi);
		}
	}
	cout << ans << endl;
}



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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int j = 0; j < min(300, K); j++) {
        vector<int> B(N+1, 0);
        for (int k = 0; k < N; k++) {
            B[max(0, k-A[k])] += 1;
            B[min(N, k+A[k]+1)] -= 1;
        }
        for (int k = 0; k < N; k++) {
            B[k+1] += B[k];
        }
        swap(A, B);
    }
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

int main() {
    int N , M;
    cin >> N >> M;
    
    vector<int>oks(N+1,true);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        oks[a]=false;
    }
    
    vector<long long>dp(N+1);
    dp[0] = 1;
    for(int now = 0;now < N; now++){
        for(int next = now+1; next <= min(N,now+2); next++){
            if(oks[next]){
                dp[next]+=dp[now];
                dp[next]%=mod;
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 1408
//============================================================================
// Name        : Hello5.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

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

int main() {
string s;
cin>>s;
int m=s.size();
rep(i,m/2){
if (
s[i]!=s[m-i-1]){
	cout<<"No"<<endl;
	return 0;
}
}
rep(l,m/4)
if(s[l]!=s[m/2-l-1])
{
	cout<<"No"<<endl;
		return 0;
}

	cout<<"Yes"<<endl;


	 return 0;
}





Measured memory_bytes: 256