akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct dfs{
    vector<int> color;
    vector<vector<int>> adj;
    int time = 0;
    int n_;
    vector<P> time_lst;
    dfs(int n):color(n,0),adj(n),time_lst(n){
        n_ = n;
    }    

    void init(){
        rep(i,n_){
            int u;cin>>u;u--;
            int k;cin>>k;
            rep(j,k){
                int tmp;cin>>tmp;tmp--;
                adj[u].push_back(tmp);
            }
        }
    }
    void visit(int u){
        //まずは0スタート
        color[u] = 1;
        time_lst[u].first = ++time;
        for(int v:adj[u]){
            if(color[v] == 0){
                visit(v);
            }
        }
        color[u] = 2;
        time_lst[u].second = ++time;
    }
    void solve(){
        init();
        rep(i,n_){
            if(color[i] == 0){
                visit(i);
            }
        }
        rep(i,n_){
            cout<<i+1<<" "<<time_lst[i].first<<" "<<time_lst[i].second<<endl;
        }
    }
};

int main(){
    int m;cin>>m;
    dfs df(m);
    df.solve();
    return 0;
}


Measured memory_bytes: 3172
import math

n = int(input())
s = list(map(int,input().split()))

mul2 = 0
mul4 = 0
for i in s:
    if i%4 == 0:
        mul4 += 1
    elif i%2 == 0:
        mul2 += 1

if mul4 >= math.floor(n/2):
    print("Yes")
elif mul2 == n:
    print("Yes")
elif n-mul2-mul4-1+mul2%2 <= mul4:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N = 233333, mo = 1e9+7;
int n,m,a[N],b[N],cnt,f[N],c[N],v[N];
struct dot{int x,y;}s[N];
inline bool operator <(dot a,dot b){return a.x!=b.x?a.x<b.x:a.y>b.y;}
inline void add(int x, int y){while(x<=n)v[x]=(v[x]+y)%mo,x+=x&-x;}
inline int query(int x){int res=0;while(x)res=(res+v[x])%mo,x-=x&-x;return res;}
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)scanf("%d",&a[i]);
	rep(i,1,m)scanf("%d",&b[i]);
	int p=1;
	rep(i,1,n){
		while(p+1<=m&&b[p+1]<=a[i])p++;
		if(a[i]<b[p]||p==m)continue;
		s[++cnt]=(dot){a[i]-b[p],b[p+1]-a[i]};
	}
	sort(s+1,s+cnt+1);int sum=0;rep(i,1,cnt)if((s[i]<s[i-1])||(s[i-1]<s[i]))s[++sum]=s[i];cnt=sum;
	int tot=0;rep(i,1,cnt)c[++tot]=s[i].y;sort(c+1,c+tot+1);tot=unique(c+1,c+tot+1)-c-1;
	rep(i,1,cnt)s[i].y=lower_bound(c+1,c+tot+1,s[i].y)-c;
	rep(i,1,cnt)f[i]=query(s[i].y-1)+1,add(s[i].y,f[i]);sum=0;
	rep(i,1,cnt)sum=(sum+f[i])%mo;cout<<(sum+1)%mo<<endl;
	return 0;
}

Measured memory_bytes: 5376
import java.util.Scanner;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int X = Integer.parseInt(sc.next());
		int Y = Integer.parseInt(sc.next());
		int Z = Integer.parseInt(sc.next());
		System.out.printf("%d %d %d\n", Z, X, Y);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

bool even(int n){
    if(n%2==0) return true;
    else return false;
}

string rev(string s){
    int n = s.size();
    string rev_s;
    rep(i,0,n){rev_s += s[n-1-i];}
    return rev_s;
}

int main(){
    string s;
    deque<char> deq;
    cin >> s;
    rep(i,0,s.length())deq.push_back(s[i]);
    int cnt = 0;
    int n;
    cin >> n;
    rep(i,0,n){
        int q;
        cin >> q;
        if(q==1){cnt++;}
        if(q==2){
            int t;char c;
            cin >> t >> c;
            if(t==1 && even(cnt)) deq.push_front(c);
            else if(t==1 && !even(cnt)) deq.push_back(c);
            else if(t==2 && even(cnt)) deq.push_back(c);
            else if(t==2 && !even(cnt)) deq.push_front(c);
        }
    }
    if(even(cnt)){
        rep(i,0,deq.size()){
            cout << deq.at(i);
        }
    }else{
        for(int i = deq.size()-1 ; i >= 0 ; i--){
            cout << deq.at(i);
        }
    }
}

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

int main(){
  while(1){
    int a0, L;
    scanf("%d%d", &a0, &L);
    if(L==0)break;
    int lst[1000000];
    for(int i=0;i<1000000;i++)lst[i]=-1;
    lst[a0]=0;
    for(int i=1;;i++){
      int a1=0, a2=0;
      int as[L];
      for(int j=0;j<L;j++){as[j]=a0%10;a0/=10;}
      sort(as, as+L);
      for(int j=0;j<L;j++){
        a1*=10;
        a2*=10;
        a1+=as[L-1-j];
        a2+=as[j];
      }
      a0=a1-a2;
      if(lst[a0]==-1)lst[a0]=i;
      else{
        printf("%d %d %d\n", lst[a0], a0, i-lst[a0]);
        break;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 7188
MAX_PRIME = 10**5
is_prime = [1] * MAX_PRIME
primes = set()
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.add(i)
        for j in range(2, ((MAX_PRIME-1)//i) + 1):
            is_prime[i*j] = 0
yearlike = set()
for i in range(1,10**5):
    if i in primes and (i+1)//2 in primes:
        yearlike.add(i)
cum = [0] * 2*10**5
for i in range(10**5+5):
    cum[i+1] = cum[i] + int(i in yearlike)
q = int(input())
query = [tuple(map(int, input().split())) for _ in range(q)]
for l, r in query:
    print(cum[r+1] - cum[l])

Measured memory_bytes: 22716
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <cstring>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//

int main(){
    int n; cin>>n;
    LLI m=INF,sum=0;
    FOR(i,0,n){
        LLI a,b; cin>>a>>b;
        sum+=a;
        if(a>b) m=min(m,b);
    }
    if(m==INF) cout<<0;
    else cout<<sum-m;
    cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
using namespace std;
map<string,int>dp;
int dir[4]={1,-1,4,-4};
void BFS()
{
    queue<string>que;
    que.push("01234567");
    dp["01234567"]=0;
    while(!que.empty())
    {
        string now=que.front();
        que.pop();
        int p=0;
        for(int i=0;i<8;i++)
        {
            if(now[i]=='0')
            {
                p=i;
                break;
            }
        }
        for(int j=0;j<4;j++)
        {
            int n=p+dir[j];
            if(n>=0&&n<8&&!(p==3&&j==0)&&!(p==4&&j==1))//右上角不可左移，左下角不可右移，出界均不可
            {
                string next=now;
                swap(next[n],next[p]);
                if(dp.find(next)==dp.end())
                {
                    dp[next]=dp[now]+1;
                    que.push(next);
                }
            }
        }
    }
}
int main()
{
    BFS();
    string line;
    while(getline(cin,line))
    {
        //remove(line.begin(),line.end(),' ');
        line.erase(remove(line.begin(), line.end(), ' '), line.end());
        //cout<<line<<endl;
        printf("%d\n",dp[line]);
    }
    return 0;
}


Measured memory_bytes: 5484
#include<stdio.h>
#include<iostream>
#define re register
#define ll long long
using namespace std;
int n,m,q;
int main(){
  scanf("%d%d",&n,&m);
  for(re int i=1;i*i<=m;i++){
    if(m%i!=0)continue;
    if(i>=n){q=i;break;}
    if(m/i>=n)q=m/i;
  }
  printf("%d\n",m/q);
  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::Ordering;

use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {
    input!{
        Q:usize,
        LR:[(usize,usize);Q],
    }

    let INF = 100_010;
    let primes = get_primes(INF);
    let mut N = vec![0;INF];
    for &i in primes.iter(){
        let j = (i+1)/2;
        if primes.contains(&j){
            N[i] = 1;
        }
    }
    for i in 1..INF{
        N[i] += N[i-1];
    }
    for &(l,r) in &LR{
        println!("{}",N[r]-N[l-1]);
    }
}

fn get_primes(n:usize)->HashSet<usize>{
    let mut ret = HashSet::new();
    let mut checked = vec![false;n+1];
    for i in 2..=n{
        if checked[i] {continue;}
        ret.insert(i);
        for j in 1..=(n/i){
            checked[i*j] = true;
        }
    }
    ret
}

Measured memory_bytes: 5484
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2e5 + 5;
const int MOD = 10000;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }

int main() {
	FIO;
	int a,b,c;cin>>a>>b>>c;
	cout<<c<<' '<<a<<' '<<b;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
double n,s1=0;
double x;
int32_t main(){
CODE_START;
cout<<fixed;
cin>>n;
for(ll i=1;i<=n;i++)
if(i%2==1){
    s1++;
}
x=s1/n;
cout<<setprecision(6)<<x<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
           
            c = int.Parse(word[2]);

            if ( c >= a && c <= b) 
                Console.WriteLine("Yes");
            else
            Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] l = new int[n];
    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l);
    int res = 0;
    for (int i = l.length - 1; i >= 2; i--) {
      for (int j = i - 1; j >= 1; j--) {
        for (int k = j - 1; k >= 0; k--) {
          if (l[i] < l[j] + l[k]) {
            res++;
          }
        }
      }
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 27768
#include <stdio.h>
int main(){
    
 int n, i;
 scanf("%d",&n);
    
 for(i = 1; i <= n; i++) {
  if(i%3 == 0) {
   printf(" %d",i);
  } else if(i%10 == 3) {
   printf(" %d",i);
  } else if((i-(i%10))%100 == 30 || (i-(i%100))%1000 == 300 || (i-(i%1000))%10000 == 3000) {
   printf(" %d",i);
  }
 }
 printf("\n");
    
 return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;
   int max_L=0;
   int total=0;
   cin>>n;
   for(int i=0;i<n;i++){
       int L;
       cin>>L;
       max_L=max(L,max_L);
       total+=L;
   }
   if(max_L<total-max_L){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
long long n, a[2000005], _max = -100, b[2000005];
int main() {
	scanf("%lld", &n);
	long long ans = 0;
	for(int i = 1;i <= n; i++) {
		scanf("%d", &a[i]);
		if(i != 1 && a[i] < a[i - 1]) {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 5384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int n;
		cin>>n;
		vector<int> vect(n);
		REP(i,n)
		{
			cin>>vect[i];
		}
		int currMin = vect[0];
		int cnt = 1;
		for(int i=1; i<n;i++)
		{
			if(currMin>vect[i])
			{
				cnt++;
			}
			currMin = min(currMin, vect[i]);
		}
		cout<<cnt<<"\n";
	}
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int n,k;
  int i,j;
  int point;
  double kakuritu,ans,tasu;
  ans =0;
  scanf("%d %d",&n,&k);

  double p;

  p=(double)1/n;//今日大事なことを学んだ。キャストするときはきゃすとする者にかっこを付けてはいけない。
 //printf("%lf\n",p);
  for(i=1;i<=n;i++){
    kakuritu=p;
    point=i;
    while(point<k){

      kakuritu=kakuritu/2;
      //printf("%f\n",kakuritu/2 );
      point=point*2;
    }
    ans=ans+kakuritu;
  }
  printf("%.12f",ans);//この書き方は一体何なんだ。教えてくれ。

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, D, X, ans = 0, a;
  cin >> N >> D >> X;
  D--;

  rep(i, N){
    cin >> a;
    ans = ans + D/a + 1;
  }
  print(ans + X);

}


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

#include <math.h>
#include <stdlib.h>


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

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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    const int offset = 8050;

    string s; cin >> s;
    int x, y; cin >> x >> y;
    
    vector<int> movx;
    vector<int> movy;
    bool gox = true;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'F') cnt++;
        if(s[i] == 'T'){
            if(gox) movx.push_back(cnt);
            else movy.push_back(cnt);
            cnt = 0;
            gox = !gox;
        }
    }

    if(gox) movx.push_back(cnt);
    else movy.push_back(cnt);

    int lx = movx.size();
    int ly = movy.size();

    vector<vector<bool>> px(offset * 2, vector<bool>(lx+1, false));
    vector<vector<bool>> py(offset * 2, vector<bool>(ly+1, false));
    
    px[offset+movx[0]][1] = true;
    py[offset][0] = true;

    for(int i = 1; i < lx; i++){
        for(int j = 0; j < offset*2; j++){
            if(px[j][i]){
                int ps = j + movx[i];
                int ng = j - movx[i];
                if(ps < offset * 2) px[ps][i+1] = px[j][i];
                if(ng >= 0) px[ng][i+1] = px[j][i];
            }
        }
    }

    for(int i = 0; i < ly; i++){
        for(int j = 0; j < offset*2; j++){
            if(py[j][i]){
                int ps = j + movy[i];
                int ng = j - movy[i]; 
                if(ps < offset * 2) py[ps][i+1] = py[j][i];
                if(ng >= 0) py[ng][i+1] = py[j][i];
            }
        }
    }

    if(px[offset+x][lx] && py[offset+y][ly]) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 17664
# include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int x,y;
	queue <int> q;
	vector <int> v[100005];
	for(int i=0;i<n-1;i++)
	{
		cin>>x>>y;
		x--;
		y--;
		v[y].push_back(x);
		v[x].push_back(y);
	}
	q.push(0);
	q.push(n-1);
	int color[n+10];
	memset(color,-1,sizeof color);
	color[n-1]=1;
	color[0]=0;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int j=0;j<v[u].size();j++)
		{
			if(color[v[u][j]]==-1)
			{
				color[v[u][j]]=color[u];
				q.push(v[u][j]);
			}
		}
	}
	int black=0,white=0;
	for(int i=0;i<n;i++)
	{
		if(color[i]==0)
		black++;
		else
		white++;
	}
	if(black>white)
	cout<<"Fennec";
	else
	cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 6272
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
	//priority_queue<int> q;
	//int h, w, a, b;
	int s[1003][1003] = {};
	double a, b;
	cin >> a;
	b = 0;
	for (int i = 1; i <= a; i++)
	{
		if (i%2==1)
		{
			b++;
		}
	}
	cout << setprecision(20) << b/a<< endl;

	//cout << "" << endl;
	return 0;
}


Measured memory_bytes: 256
class BIT:
    def __init__(self, n):
        self.n = n
        self.N = 1 << n.bit_length()
        self.data = [0] * (self.N +1)

    def add(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & -i

    def sum(self, i):
        total = 0
        while i > 0:
            total += self.data[i]
            i -= i&-i
        return total

    def search(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.N >> 1
        while k > 0:
            if x+k <= self.N and self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k = k >> 1
        return x+1

    def len(self):
        return self.data[self.N]

n = int(input())
p = list(map(int, input().split()))

index = [0] * (n+1)

for i in range(n):
    index[p[i]] = i+1

used = BIT(n)
result = 0
for i in range(1, n+1)[::-1]:
    x = index[i]
    if used.len() == 0:
        used.add(x, 1)
        continue
    dx = used.sum(x)
    # 左に１番目の数がある
    if dx > 0:
        lbl = 1
        if dx > 1:
            lbl = used.search(dx-1)+1
        lbr = used.search(dx)
        rbl = n
        if used.len() != dx:
            rbl = used.search(dx+1) -1
        result += (lbr-lbl+1) * (rbl-x+1) * i
    # 右に1番目の数がある
    if dx < used.len():
        rbr = n
        if dx < used.len() -1:
            rbr = used.search(dx+2)-1
        rbl = used.search(dx+1)
        lbr = 1
        if dx > 0:
            lbr = used.search(dx) +1
        result += (rbr-rbl+1) * (x-lbr+1) * i
    used.add(x, 1)
 
print(result)

Measured memory_bytes: 59244
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.hb", "r", stdin);
	string str = "";
	
	while (getline (cin, str ) ) {
		vector <int> A(4, 0);
		int i,j;

		stringstream ssa (str );
		for (i = 0; i < 4; ++i){
			ssa >> A[i];
		} // end for

		getline (cin, str );
		vector <int> B (4, 0 );

		stringstream ssb (str );
		for (i = 0; i < 4; ++i){
			ssb >> B[i];
		} // end for

		int hit = 0;
		int blow = 0;

		for (i = 0; i < 4; ++i){
			if (A[i] == B[i]){
				++hit;
				A[i] = B[i] = -1;
			} // end if
		} // end for
		
		for (i = 0; i < 4; ++i){
			for (j = 0; j < 4; ++j){
				if (A[i] != -1 && B[j] != -1 && A[i] == B[j]){
					++blow;
					A[i] = B[j] = -1;
				} // end if
			} // end for
		} // end for
		cout << hit << ' ' << blow << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 0
S = list(input())
B = 0
W = 0
for i in range(len(S)):
    if S[i] == 'B':
        B += 1
    else:
        W += 1
Num = 0
Count = 0
for i in range(len(S)):
    if S[i] == 'W':
        Count += (i-Num)
        Num += 1
print(Count)


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

int main(int argc, const char * argv[]) {
    int N;
    int minus_count = 0;
    long result = 0;
    
    cin >> N;
    
    vector<long> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] < 0) {
            minus_count++;
        }
    }
    
    if ((minus_count % 2) == 0) {
        for (int i = 0; i < A.size(); i++) {
            A[i] = abs(A[i]);
        }
    } else {
        for (int i = 0; i < A.size(); i++) {
            A[i] = abs(A[i]);
        }
        sort(A.begin(), A.end());
        A[0] = -A[0];
    }
    
    for (int i = 0; i < A.size(); i++) {
        result += A[i];
    }
    
    cout << result << endl;
    
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ARC095D
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            var X = ss.Next(int.Parse, N);

            var ai = X.Max();
            var aj = X.Where(x => x != ai).OrderBy(x => Math.Abs(x - ai / 2.0)).First();
            sw.WriteLine($"{ai} {aj}");
            //---------------------------------
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 25056
//tanzim bin nasir
#include<bits/stdc++.h>
typedef long long ll;
#define pii pair<ll,ll>
#define ff first
#define ss second
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}
int main()
{
    ll n;
    cin>>n;
    if(n>=30)
    cout<<"Yes\n";
    else
    cout<<"No\n";
}

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

int main(void){
    int n;
    vector <int> a;
    int i, j, x;
    int ans = INT_MAX;
    bool judge = true;
    int min_num = 100, max_num = -100;
    int cost;
    
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> x;
        a.push_back(x);
    }
    
    for(i = 0; i < n - 1; i++){
        if(a[i] != a[i + 1]){
            judge = false;
            break;
        }
    }
    
    for(i = 0; i < n; i++){
        min_num = min(min_num, a[i]);
        max_num = max(max_num, a[i]);
    }


    if(judge)    cout << 0 << endl;
    else{
        for(i = min_num; i <= max_num; i++){
            cost = 0;
            for(j = 0; j < n; j++){
                cost += (a[j] - i) * (a[j] - i);
            }
            ans = min(ans, cost);
        }
        cout << ans << endl;
    }
    
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

ll dp[2005][2005];

void Main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    rep(i, N) cin >> S[i];
    rep(i, M) cin >> T[i];
    dp[0][0] = 1;
    rep(i, 2005) dp[i][0] = 1;
    rep(i, 2005) dp[0][i] = 1;
    rep(i, N) {
        rep(j, M) {
            if (S[i] == T[j]) {
                dp[i + 1][j + 1] += dp[i+1][j] +  dp[i][j+1];
            } else {
                dp[i + 1][j + 1] += ((dp[i+1][j] +  dp[i][j+1])%MOD) -  dp[i][j];
            }
            if (dp[i+1][j+1] < 0 ) {
                dp[i+1][j+1] += MOD;
            }
            dp[i + 1][j + 1] %= MOD;
        }
    }
    cout << dp[N][M] %  MOD << endl;

}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 31616
#include <stdio.h>

int ball[3];

int swap(int a, int b){
  ball[a] += ball[b];
  ball[b] = ball[a] - ball[b];
  ball[a] = ball[b] - ball[a];
}

int main(){
  char x,y;
  ball[0]=1;
  ball[1]=ball[2]=0;
  while(scanf(" %c,%c", &x,&y)!=EOF){
    swap(x-'A', y-'A');
  }
  if(ball[0]) puts("A");
  else if(ball[1]) puts("B");
  else puts("C");
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1000 * 1000 * 1000 + 7;
const int N = 100;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
ll a , b ;
ll gcd ( ll a , ll b  ) // a > b
{

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

}
ll cal ( ll x )
{
    return ( b / x -  a / x ) + ( a % x == 0 );
}
int main()
{
    Fast_IO();
    ll  c ,d ;
    cin >>a >> b >> c >> d ;
    cout <<  ( b -a +1 )- (cal ( c ) + cal ( d ) - cal ( lcm ( c, d )));

    return 0 ;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int mod=1e9+7;
const int N=410,maxn=400;
int c[N][N],cj[N];
int dp[N][N][N];
int nxt[N][N][2];
int ans;
int vis[N];
int a[N],b[N];
int kind[N][N];
int n;

void init(){
	register int i,j;int now;
	nxt[0][0][0]=1;
	nxt[0][0][1]=1;
	rep(i,0,n){
		rep(j,1,n)	vis[j]=0;
		rep(j,1,i)	vis[a[j]]=1;
		now=i;
		nxt[i][0][0]=i+1;
		nxt[i][0][1]=1;
		while(vis[b[nxt[i][0][1]]])	nxt[i][0][1]++;
		rep(j,1,n){
			if(vis[b[j]]==0)	now++;
			vis[b[j]]=1;
			kind[i][j]=now;
			nxt[i][j][0]=nxt[i][j-1][0];
			nxt[i][j][1]=nxt[i][j-1][1];
			while(vis[a[nxt[i][j][0]]])	nxt[i][j][0]++;
			while(vis[b[nxt[i][j][1]]])	nxt[i][j][1]++;
		}
	}
	rep(i,0,n)	for(j=1,c[i][0]=1;j<=i;j++)	c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	for(cj[0]=1,i=1;i<=n;i++)	cj[i]=1ll*cj[i-1]*i%mod;
	/*rep(i,0,n){
		rep(j,0,n){
			//printf("nxt[%d][%d]=%d %d\n",i,j,nxt[i][j][0],nxt[i][j][1]);
			printf("kind[%d][%d]=%d\n",i,j,kind[i][j]);
		}
	}*/
}			

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	register int i,j,k,ni,nj,x;
	scanf("%d",&n);
	rep(i,1,n)	scanf("%d",&a[i]);
	rep(i,1,n)	scanf("%d",&b[i]);
	a[n+1]=n+1;b[n+1]=n+2;
	init();
	dp[0][0][0]=1;
	rep(k,1,n/3){
		rep(i,k-1,n)	rep(j,k-1,n)	if(dp[k-1][i][j]){
			ni=nxt[i][j][0];nj=nxt[i][j][1];//cerr<<i<<' '<<j<<' '<<ni<<' '<<nj<<endl;
			dp[k][ni][nj]=(dp[k][ni][nj]+dp[k-1][i][j])%mod;
		}
		rep(i,k,n)	rep(j,k,n)	if(dp[k][i][j]){
			ni=nxt[i][j-1][0];nj=a[i]==b[j]?nxt[i][j][1]:j;
			x=kind[i-1][j-1]-2*(k-1);
			if(k-1-x>0)	dp[k][ni][nj]=(dp[k][ni][nj]+1ll*dp[k][i][j]*(k-1-x))%mod;
		}
		rep(i,k,n)	rep(j,k,n)	if(dp[k][i][j]){
			if(a[i]==b[j])	continue;
			nj=nxt[i-1][j][1];
			x=kind[i-1][j-1]-2*(k-1);
			if(k-1-x>0) dp[k][i][nj]=(dp[k][i][nj]+1ll*dp[k][i][j]*(k-1-x))%mod;
		}
		rep(i,k,n)	rep(j,k,n)	if(a[i]==b[j])	dp[k][i][j]=0;
		/*rep(i,1,n){
			rep(j,1,n){
				printf("dp[%d][%d][%d]=%d\n",k,i,j,dp[k][i][j]);
			}
		}*/
	}
	rep(i,1,n)	rep(j,1,n)	if(dp[n/3][i][j]){
		x=n-kind[i][j];
		ans=(ans+1ll*dp[n/3][i][j]*cj[x])%mod;
	}
	//cerr<<ans<<endl;
	rep(i,1,n/3)	ans=1ll*ans*c[n-3*(i-1)-1][2]*2%mod;
	printf("%d",ans);
}
	
	
				
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

Measured memory_bytes: 90880
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int bigint;
/*---------------------------------------------------------------------------------------------------
????????????????????????????????? ??§?????§  
??????????????? ??§?????§ ???????´<_??? ?????? Welcome to My Coding Space!
???????????? ??? ?´_???`??????/??? ???i     
?????????????????????????????? ???  |???|     
????????? /?????? /??£??£??£??£/??????|  
??? ???_(__??????/???    ???/ .| .|????????????  
??? ????????????/????????????/??????u??????  
---------------------------------------------------------------------------------------------------*/
 




int N;
bigint A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) {
        cin >> A >> B;

        bigint ans = A + B;
        string str = ans.str();

        if (80 < str.size()) printf("overflow\n");
        else printf("%s\n", str.c_str());
    }
}

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

 using namespace std;

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

   if (A < B) {
     if (A < C && C < B) cout << "Yes" << endl;
     else cout << "No" << endl;
   }

   else if (B < A) {
     if (B < C && C < A) cout << "Yes" << endl;
     else cout << "No" << endl;
   }

 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2050;
int n,k,q;
int a[N],b[N],c[N];
int main()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int mini=0x3f3f3f3f;
	for(int i=1;i<=n;i++) 
	{
		int size=0;
		for(int j=1;j<=n;j++) 
		{
			if(a[j]<a[i]) continue;
			int now=j;
			while(now<=n&&a[now+1]>=a[i]) now++;
			int num=now-j+1-k+1;
			if(num<=0) continue;
			int cnt=0;
			for(int l=j;l<=now;l++) b[++cnt]=a[l];
			sort(b+1,b+cnt+1);
			for(int l=1;l<=num;l++) c[++size]=b[l];
			j=now;
		}
		if(size<q) continue;
		sort(c+1,c+size+1);
		mini=min(mini,c[q]-a[i]);
	}
	printf("%d\n",mini);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF LLONG_MAX / 2;
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;

const ll INF = LLONG_MAX;

#define ARRAY_MAX 100005
#define N_MAX 45
#define AB_MAX 15
#define INF 1e9

int dp[N_MAX][N_MAX * AB_MAX][N_MAX * AB_MAX];

int main(){

    int n,ma,mb;
    cin >> n >> ma >> mb;
    vector<int> a(n),b(n),c(n);
    REP(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }

    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= N_MAX*AB_MAX;j++){
            for(int k = 0;k <= N_MAX*AB_MAX;k++){
                dp[i][j][k] = INF;
            }
        }
    }


    dp[0][0][0] = 0;
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j <= N_MAX*AB_MAX;j++){
            for(int k = 0;k <= N_MAX*AB_MAX;k++){
                if(dp[i][j][k] == INF){
                    continue;
                }
                //dp[i+1][j][k] = dp[i][j][k];
                //dp[i+1][j+a[i]][k+b[i]] = dp[i][j][k]+c[i];
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
            }
        }
    }
    int ans = INF;

    for(int i = 1;i <= N_MAX*AB_MAX;i++){
        for(int j = 1;j <= N_MAX*AB_MAX;j++){
            if(i*mb == j*ma){
                ans = min(ans,dp[n][i][j]);
            }
        }
    }

    if(ans == INF){
        ans = -1;
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 73984
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())
s = list(input())

ruisekiwa = []
tmp = [0 for _ in range(3)]

for si in s:
    if si == "R":
        tmp[0] += 1
    elif si == "G":
        tmp[1] += 1
    else:
        tmp[2] += 1
    tmpra = copy.deepcopy(tmp)
    ruisekiwa.append(tmpra)

ans = 0
for j in range(1, n - 1):
    sj = 0
    if s[j] == "R":
        sj = 0
    elif s[j] == "G":
        sj = 1
    else:
        sj = 2

    tmpa = ruisekiwa[j - 1]
    tmpb = [0 for _ in range(3)]
    for tmp in range(3):
        tmpb[tmp]=ruisekiwa[n - 1][tmp] - ruisekiwa[j][tmp]

    for a in range(3):
        for b in range(3):
            if a == b:
                continue
            if a == sj or b == sj:
                continue
            ans += tmpa[a] * tmpb[b]

    hikukazu = 0
    for e in range(1, 4000):
        if not(-1< j-e < j+e < n):
            break
        if s[j-e] != s[j] and s[j] != s[j+e] and s[j-e] != s[j+e]:
            hikukazu += 1

    ans -= hikukazu

print(ans)


Measured memory_bytes: 10876
x_n = input()
x_n_list = x_n.split()
x = int(x_n_list[0])
n = int(x_n_list[1])
if n == 0:
  print(x)
else:
  allp = input()
  p_list = allp.split()
  p_l = [int(n) for n in p_list]
  if x not in p_l:
    print(x)
  else:
    for i in range(len(p_l)):
      if x - i - 1 not in p_l:
        print(x - i - 1)
        break
      elif x + i + 1 not in p_l:
        print(x + i + 1)
        break
      else:
        pass

Measured memory_bytes: 9148
fn main() {
    let s = read::<String>();
    let t = read::<String>();

    // どの文字が何番目にあるかのリスト。list[0]はaが何文字目に出るかのリスト
    let mut list: Vec<Vec<usize>> = vec![vec![]; 26];

    let mut ans: usize = 0;

    let len_s = s.len();
    let mut t_iter = t.chars();

    // リストの作成(昇順になる)
    for (e, c) in s.chars().enumerate() {
        list[(c as i32 - 0x61) as usize].push(e)
    }


    let mut prev_pos: usize;

    // 最初の文字を処理
    let l = &list[(t_iter.next().unwrap() as i32 - 0x61) as usize];
    if l.is_empty() == true {
        println!("-1");
        return;
    }
    else {
        prev_pos = l[0];
    }

    for c in t_iter {
        let l = &list[(c as i32 - 0x61) as usize];
        if l.is_empty() == true {
            println!("-1");
            return;
        }

        // prev_pos + 1の位置を探す
        prev_pos = match l.binary_search(&(prev_pos + 1)) {
            Ok(_) => {
                prev_pos + 1
            },
            Err(i) => {
                // iが最後尾なら、今見てるsには無い
                if i == l.len() {
                    ans += len_s;
                    l[0]
                }
                // そうでない場合、直後の位置が入る
                else {
                    l[i]
                }
            }

        };
    }
    ans += prev_pos + 1;

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T  {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse::<T>().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap())
    .collect()
}

Measured memory_bytes: 6396
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 桁DP, Lを超えないものと保留のもの
MOD = 10 ** 9 + 7
L = sr()
dp = [1, 2]
length = len(L)
for i in range(1, length):
    prev = dp[:]
    if L[i] == '1':
        dp[0] = prev[0] * 3 + prev[1]
        dp[1] = prev[1] * 2
    else:
        dp[0] = prev[0] * 3
        dp[1] = prev[1]

answer = sum(dp)
print(answer%MOD)


Measured memory_bytes: 46044
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	cin>>n;
	map<string,ll>mp;
	while(n--)
	{
		string str;cin>>str;
		sort(str.begin(),str.end());
		mp[str]++;
	}
	ll ans=0;
	for(map<string,ll>::iterator it=mp.begin();it!=mp.end();it++)
	ans+=(it->second*(it->second-1))/2;
	cout<<ans;
}

Measured memory_bytes: 11264
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

import math
K = int(input())
ans_list = []
ans = 0
for i in range(1, K + 1):
    for j in range(1,K+1):
        ans_list.append(math.gcd(i,j))
for i in range(1,K+1):
    for j in range(0,len(ans_list)):
        ans += math.gcd(i,ans_list[j])

print(ans)


Measured memory_bytes: 9448
#include <stdio.h>

int main(void){

  long k;
  scanf("%ld", &k);

	long number[10][10];

	for (long i = 0; i < 10; i++) {
		number[0][i] = 1;
	}
	for (long i = 1; i < 10; i++) {
		number[i][0] = number[i-1][0] + number[i-1][1];
		for (long j = 1; j <= 8; j++) {
			number[i][j] = number[i-1][j-1] + number[i-1][j] + number[i-1][j+1];
		}
		number[i][9] = number[i-1][8] + number[i-1][9];
	}

	long sum[10];
	for (long i = 0; i < 10; i++) {
		sum[i] = 0;
		for (long j = 1; j < 10; j++) {
			sum[i] += number[i][j];
		}
	}

	/*for (long i = 0; i < 10; i++) {
		printf("%ld\n", sum[i]);
	}*/

	long digits;
	long left = k;

	for (long i = 0; i < 10; i++) {
		if (left <= sum[i]) {
			digits = i;
			break;
		}
		left -= sum[i];
	}

	long answer_digits[10];
	for (long i = digits+1; i < 10; i++) {
		answer_digits[i] = 0;
	}

	long tmp;

	for (long i = digits; i == digits; i--) {
		tmp = 0;
		for (long j = 1; j < 10; j++) {
			tmp += number[i][j];
			if (tmp >= left) {
				answer_digits[i] = j;
				left -= tmp-number[i][j];
				//printf("%ld\n", j);
				break;
			}
		}
	}

	for (long i = digits-1; i >= 0; i--) {
		if (answer_digits[i+1] == 0) {
			if (number[i][0] >= left) {
				answer_digits[i] = 0;
				tmp = 0;
			} else {
				answer_digits[i] = 1;
				tmp = number[i][0];
			}
		} else if (answer_digits[i+1] == 9) {
			if (number[i][8] >= left) {
				answer_digits[i] = 8;
				tmp = 0;
			} else {
				answer_digits[i] = 9;
				tmp = number[i][8];
			}
		} else {
			if (number[i][answer_digits[i+1]-1] >= left) {
				answer_digits[i] = answer_digits[i+1] - 1;
				tmp = 0;
			} else if (number[i][answer_digits[i+1]-1] + number[i][answer_digits[i+1]] >= left) {
				answer_digits[i] = answer_digits[i+1];
				tmp = number[i][answer_digits[i+1]-1];
			} else {
				answer_digits[i] = answer_digits[i+1] + 1;
				tmp = number[i][answer_digits[i+1]-1] + number[i][answer_digits[i+1]];
			}
		}
		left -= tmp;
	}

	long answer = 0;
	for (long i = 9; i >= 0; i--) {
		answer *= 10;
		answer += answer_digits[i];
	}

	printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>

int main(void)
{


	char str[100];
	while(gets(str)){

	while(!strstr(str, "this") && !strstr(str, "the") && !strstr(str, "that")){
		for(int i = 0; i < strlen(str); i++){
			if(str[i] >= 'a' && str[i] <= 'a'+26)
				str[i] = 'a' + (str[i] - 'a' + 1) % 26;
		}
	}

	printf("%s\n", str);
	}

	return 0;
}

Measured memory_bytes: 928
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input():
    return sys.stdin.readline()[:-1]
def pri(x):
    if type(x) is list:
        print('\n'.join(map(str, x)))
    else:
        print(x)

L = int(input())

res = pow(L, 3)/27

print(res)


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

node *nil;

node* listSearch(int key){
  node *cur = nil->next;
  while ( cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (node *)malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  node *cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(node *t){
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  node *x = (node *)malloc(sizeof(struct node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      }
      else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

#define ll long long int 
ll mod=1e9+7;

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

double nthRoot(long long int A, long long int N) 
{ 
    // intially guessing a random number between 
    // 0 and 9 
    double xPre = rand() % 10; 
  
    //  smaller eps, denotes more accuracy 
    double eps = 1e-3; 
  
    // initializing difference between two 
    // roots by INT_MAX 
    double delX = INT_MAX; 
  
    //  xK denotes current value of x 
    double xK; 
  
    //  loop untill we reach desired accuracy 
    while (delX > eps) 
    { 
        //  calculating current value from previous 
        // value by newton's method 
        xK = ((N - 1.0) * xPre + 
              (double)A/pow(xPre, N-1)) / (double)N; 
        delX = abs(xK - xPre); 
        xPre = xK; 
    } 
  
    return xK; 
} 

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    int t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j,x;
        cin >> x;
        
        for(i=-100000;i<100000;i++)
        {
            ll a5 = (ll) pow(i,5);
            ll rem = a5 - x;
            ll b = nthRoot(rem,5);

            if((a5 - pow(b,5)) == x)
            {
                cout << i << " " << b << '\n';
                return 0;
            }


        }
        

        
    }

    
    
}

Measured memory_bytes: 4256
n,m = map(int,input().split())
lis = [False]*(n+1)
a = []
for i in range(m):
    a = int(input())
    lis[a] = True

mod = 10**9+7
dp =[0]*(n+1)
dp[0] =1
for i in range(n):
    dp[i] %= mod
    if (lis[i]):dp[i] = 0
    if i+1 <=n:
        dp[i+1] += dp[i]
    if i+2 <=n:
        dp[i+2] += dp[i]

print(dp[n]%mod)

Measured memory_bytes: 13424