akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	long double ans = 2 * PI * n;
	cout << setprecision(20) << ans;
}

Measured memory_bytes: 3776
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a + b > d + c){
    cout << "Left" << endl;
  }
  else if(a + b < d + c){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
	
typedef long long v;
typedef long long b;

static const int MAX = 200000;


int main() {
	int n;
	cin >> n;
	int x = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		x += b - a + 1;
	}
	cout << x;
	return 0;
}










Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] defargs){
        int H,W,i,j;
        Scanner scanner = new Scanner(System.in);
        while(true){
        H = scanner.nextInt();
        W = scanner.nextInt();
        if(H == 0 && W == 0 ){
            break;
        }
        for(i = 1;i <= H; i++){   //行方向
            for(j = 1; j <= W; j++){    //列方向
                if(( i + j )%2 == 0){
                    System.out.print("#");
                }else{
                    System.out.print(".");
                } 
            }
            System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35596
//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#include <atcoder/dsu>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, a, b;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    atcoder::dsu g(n);
    for (int i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        --a;
        --b;
        g.merge(a, b);
    }
    cout << g.groups().size() - 1 << endl;
    return 0;
}

Measured memory_bytes: 8900
#include<bits/stdc++.h>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define Pair pair<int,int>
#define space putchar(' ')
using namespace std;

template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	

template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

#define int long long
const int maxn=1e5+10;
int n;
string s[maxn];
int buc[maxn][30];
int qz[maxn];
int gg[maxn];
map<string,int> vis;
map<string,int> flag;
signed main()
{
	read(n);
	for(RI i=1;i<=n;++i)
	{
		qz[i]=qz[i-1]+i;
		cin >> s[i];
	}
	for(RI i=1;i<=n;++i)
	{
		sort(s[i].begin(),s[i].end());
		vis[s[i]]++;
	}
	int ans=0;
	for(RI i=1;i<=n;++i)
	{
		if(flag[s[i]]) continue;
		int temp=vis[s[i]];
		flag[s[i]]=1;
		ans+=qz[temp-1];
	}
	print(ans);
	return 0;
} 

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

#define int long long
#define double long double

using namespace std;

#define REP(i, a, b) for (int(i) = (a); i < (b); (i)++)
#define rep(i, n) REP(i, 0, n)
#define PER(i, a, b) for (int(i) = (a - 1); i >= (b); (i)--)
#define per(i, n) PER(i, n, 0)
#define each(i, n) for (auto &i : n)
#define clr(a) memset((a), 0, sizeof(a))
#define mclr(a) memset((a), -1, sizeof(a))
#define all(a) (a).begin(), (a).end()
#define dum(val) cerr << #val " = " << val << " ";
#define dump(val) cerr << #val " = " << val << endl;
#define FILL(a, v) fill(a, a + sizeof(a) / sizeof(*a), v)

typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {
	int x, y;
	cin >> x >> y;

	if (x < y) {
		cout << x << endl;
		return 0;
	}

	if (x % y == 0) {
		cout << -1 << endl;
		return 0;
	}

	cout << x << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int w,h,grid[50][50];

void rec(int x,int y){
  grid[y][x]=false;
  for(int i=-1;i<2;i++){
    for(int j=-1;j<2;j++){
      int ny=y+i,nx=x+j;
      if(0<=nx && nx<w && 0<=ny && ny<h && grid[ny][nx])
	rec(nx,ny);
    }
  }
}

int main(void){

  while(cin >> w >> h,w|h){
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin >> grid[i][j];
    
    int ans=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(grid[i][j])rec(j,i),ans++;
  
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
  int N,Y;
  cin >> N >> Y;

  int x=-1,y=-1,z=-1;
  for(int a=0;a<=N;a++){
    for(int b=0;b<=N-a;b++){
      int c = N-(a+b);
      if(10000*a + 5000*b + 1000*c == Y){x=a;y=b;z=c;}
    }
  }
  
  cout << x << " " << y << " " << z << endl;

}

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

#define endl '\n'
#define PI acos(-1.0)
#define F first
#define S second

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	double r;
	cin >> r;
	
	printf("%lf\n", 2.0 * PI * r);
	
	return 0;
}


Measured memory_bytes: 3804
fun main (args:Array<String>){
    val num = readLine()
    if (num != null) {
        when {
            num.endsWith("3") -> {
                print("bon")
            }
            num.endsWith("0") -> {
                print("pon")
            }
            num.endsWith("1") -> {
                print("pon")
            }
            num.endsWith("6") -> {
                print("pon")
            }
            num.endsWith("8") -> {
                print("pon")
            }
            else -> {
                print("hon")
            }
        }

    }
}

Measured memory_bytes: 35644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
ll n;
cin>>n;
string s;
cin>>s;
ll r=0,d=0;
for(ll i=0;i<n;i++)
{
    if(s[i]=='R')
      r++;
}
for(ll i=0;i<r;i++)
{
    if(s[i]=='R')
    d++;
}
cout<<r-d<<endl;


}



   
      
    
        



Measured memory_bytes: 3756
N,M=map(int,input().split())
G=[]
x=dict()
for i in range(M):
    a,b=map(int,input().split())
    if a in x:
        x[a]+=1
    else:
        x[a]=1
    if b in x:
        x[b]+=1
    else:
        x[b]=1

flag=True
for idx in x:
    if x[idx]%2==0:
        pass
    else:
        flag=False

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 50392
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>

int main() {
  size_t N;
  intmax_t M;
  scanf("%zu %jd", &N, &M);

  intmax_t sum = 0;
  std::map<intmax_t, intmax_t> count;
  ++count[0];
  for (size_t i = 0; i < N; ++i) {
    intmax_t ai;
    scanf("%jd", &ai);
    ai %= M;
    (sum += ai) %= M;
    ++count[sum];
  }

  intmax_t res = 0;
  for (const auto& p: count)
    res += p.second * (p.second-1) / 2;

  printf("%jd\n", res);
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)


int main() {
	string str;
	cin >> str;
	multimap<int, int> m;
	int max = 0, min = 0, v[20010];
	v[0] = 0;
	m.insert(make_pair(0, 0));
	rep(i,str.size()) {
		if(str[i] == '\\') {
			v[i+1] = v[i] - 1;
			m.insert(make_pair(v[i+1], i+1));
			if(min > v[i+1]) min = v[i+1];
		} else if(str[i] == '/') {
			v[i+1] = v[i] + 1;
			m.insert(make_pair(v[i+1], i+1));
			if(max < v[i+1]) max = v[i+1];
		} else {
			v[i+1] = v[i];
			m.insert(make_pair(v[i+1], i+1));
		}
	}
	int f[20010];
	bool b[20010];
	rep(i,str.size()+1) {
		b[i] = true;
	}
	for(int i = max; i >= min; --i) {
		int c = m.count(i);
		int e[2];
		auto begin = m.find(i);
		e[0] = begin->second;
		if(c < 2) {
			if(b[e[0]]) {
				f[e[0]] = 0;
				b[e[0]] = false;
				continue;
			}
		}
		auto end = m.upper_bound(i);
		end--;
		e[1] = end->second;
		rep2(j,e[0],e[1]+1) {
			if(b[j]) f[j] = i - v[j];
			b[j] = false;
		}
	}
	//rep(i,str.size()+1){
	//	cout << f[i] << endl;
	//}
	vector<int> ret;
	int pre = 0, count = 0;
	rep(i,str.size()+1) {
		if(f[i]) {
			count += f[i];
			pre = f[i];
		} else {
			if(pre) {
				ret.push_back(count);
				count = pre = 0;
			}
		}
	}

	int total = 0;
	rep(i,ret.size()) {
		total += ret[i];
	}
	cout << total << endl;
	cout << ret.size();
	rep(i,ret.size()) {
		cout << " " << ret[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2372
#include<stdio.h>
long long dp[9][1001][101];
int main(){
	for(int i=0;i<101;i++)dp[0][i][i]=1;
	for(int i=0;i<8;i++){
		for(int j=0;j<1001;j++){
			for(int k=0;k<101;k++){
				if(!dp[i][j][k])continue;
				for(int l=k+1;l<101;l++){
					dp[i+1][j+l][l]+=dp[i][j][k];
				}
			}
		}
	}
	int a,b;
	while(scanf("%d%d",&a,&b),a+b){
		long long ret=0;
		for(int i=0;i<101;i++)ret+=dp[a-1][b][i];
		printf("%lld\n",ret);
	}
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        ll n,k;
        cin >> n >> k;
        if(n==0 and k==0) break;

        ll x,y;
        rep(i,1,inf){
            ll tmp=i*(pow(10,i)-pow(10,i-1));
            if(n-tmp>0) n-=tmp;
            else{
                x=pow(10,i-1);
                y=i;
                break;
            }
        }

        ll a=0;
        rep(i,1,11){
            if(n-y*x>0) n-=y*x;
            else{
                a=i;
                break;
            }
        }

        ll b=0;
        rep(i,1,11){
            if(n-y*x/10>0) n-=y*x/10;
            else{
                b=i-1;
                break;
            }
        }

        ll c=0;
        rep(i,1,11){
            if(n-y*x/100>0) n-=y*x/100;
            else{
                c=i-1;
                break;
            }
        }

        ll d=0;
        rep(i,1,11){
            if(n-y*x/1000>0) n-=y*x/1000;
            else{
                d=i-1;
                break;
            }
        }

        ll e=0;
        rep(i,1,11){
            if(n-y*x/10000>0) n-=y*x/10000;
            else{
                e=i-1;
                break;
            }
        }

        stringstream ss;
        rep(i,0,100000){
            ss << x*a+x*b/10+x*c/100+x*d/1000+x*e/10000+i;
            if(ss.str().size()>n+k) break;
        }
        cout << ss.str().substr(n-1,k) << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 3436
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n,ans,high;
	cin >> n;
	vector<int> m(n);
	for (int i = 0; i < n; i++){
		cin >> m.at(i);
	}

	for (int i = 0; i < n; i++){
		if (i == 0){
			ans = 1;
			high = m.at(i);
			continue;
		}
		else{
			if (m.at(i) >= high){
				ans++;
				high = m.at(i);
			}
		}
	}

	cout << ans << endl;


	system("pause");
	return 0;
}

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

int main ()
{
    int a,b,c,d,e,i;
    cin>>a>>b;
    e=1001;
    for(i=0;i<a;i++){
        cin>>c>>d;
        if(d<=b){
            e=min(c,e);
        }
    }
    if(e==1001){
        cout<<"TLE"<<endl;
    }else{
        cout<<e<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
	static int j =0;
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int x = sc.nextInt();
		 int y = sc.nextInt();
		 int c=0;
		 for(int i=0;i<x;i++) {
			 double a= sc.nextInt();
			 double b= sc.nextInt();
			 
			 if(Math.sqrt(a*a+b*b)<=y) {
				 c++;
			 }
		 }
		 System.out.println(c);
	}


}


Measured memory_bytes: 59468
#include<bits/stdc++.h>
using namespace std;
#define N 1116
#define inf 1111111116

int n,p[N],x[N],f[N][5555];

int read(){
	int x=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar());
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main(){
	n=read();
	for (int i=2;i<=n;i++) p[i]=read();
	for (int i=1;i<=n;i++) x[i]=read();
	for (int i=n;i>=1;i--){
		int t=inf;
		for (int j=0;j<=x[i];j++) t=min(t,f[i][j]);
		if (t==inf) {printf("IMPOSSIBLE\n");return 0;}
		for (int j=x[p[i]];j>=0;j--)
			f[p[i]][j]=min((j<t)?inf:(f[p[i]][j-t]+x[i])
					   ,(j<x[i])?inf:(f[p[i]][j-x[i]]+t));
	}
	printf("POSSIBLE\n");
	return 0;
}

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

if 1<=N<=9:
    print(N)
elif 10<=N<=99:
    print(9)
elif 100<=N<=999:
    print(9+N-100+1)
elif 1000<=N<=9999:
    print(909)
elif 10000<=N<=99999:
    print(909+N-10000+1)
else:
    print(909+90000)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
 
struct Edge { int to, cost; };
 
vector<vector<Edge>> G(101010);
vector<bool> visited(101010);
vector<int> x(101010);
 
bool dfs(int v) {
  visited[v] = true;
  for(auto nx : G[v]) {
    if(visited[nx.to]) {
      if(x[nx.to] != x[v] + nx.cost) return false;
    } else {
      x[nx.to] = x[v] + nx.cost;
      if(!dfs(nx.to)) return false;
    }
  }
  return true;
}
 
bool solve() {
  int N, M;
  cin >> N >> M;
  rep(i, 0, M) {
    int l, r, d;
    cin >> l >> r >> d;
    G[l].push_back({r, d});
    G[r].push_back({l, -d});
  }
  rep(i, 0, N) if(!dfs(i)) return false;
  return true;
}
 
int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}

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

int cur, maxi;
string s;

int main(){
	cin >> s;
	cur = maxi = 0;
	for(int i = 0; i < s.length(); i++){
		if(s[i]=='A') cur++;
		else if(s[i]=='C') cur++;
		else if(s[i]=='G') cur++;
		else if(s[i]=='T') cur++;
		else cur = 0;
		maxi = max(maxi, cur);
	}

	printf("%d\n", maxi);

	return 0;

}

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

class Dice{
public:
	int d[6];
	int dcopy[6];
	void MoveN();
	void MoveS();
	void MoveE();
	void MoveW();
};

void Dice::MoveN(){
	swap(d[0],d[1]);
	swap(d[1],d[4]);
	swap(d[1],d[5]);
}
void Dice::MoveS(){
	swap(d[0],d[1]);
	swap(d[0],d[4]);
	swap(d[4],d[5]);
}
void Dice::MoveE(){
	swap(d[0],d[3]);
	swap(d[2],d[3]);
	swap(d[3],d[5]);
}
void Dice::MoveW(){
	swap(d[0],d[2]);
	swap(d[2],d[3]);
	swap(d[2],d[5]);
}
int main(){
	int n,a,b;
	Dice dc;
	for(int i=0;i<6;i++){
		cin>>dc.d[i];
	}
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		while(dc.d[0]!=a){
			for(int i=0;i<3;i++){
				if(dc.d[0]==a) break;
				dc.MoveN();
			}
			if(dc.d[0]==a) continue;
			dc.MoveE();
		}
		if(dc.d[1]==b) cout<<dc.d[2]<<endl;
		else if(dc.d[2]==b) cout<<dc.d[4]<<endl;
		else if(dc.d[3]==b) cout<<dc.d[1]<<endl;
		else if(dc.d[4]==b) cout<<dc.d[3]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
N = int(input())
a = []
for i in range(N):
    a.append(input().split())

sum = 0
for i in range(len(a)):
    currency = a[i][1]
    if currency == 'JPY':
        sum += int(a[i][0])
    else:
        sum += float(a[i][0]) * 380000.0
print(sum)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();

        double prob = 0;
        for (int i = 1; i <= n; i++) {
            int score = i;
            int numFlips = 0;
            while (score < k) {
                score *= 2;
                numFlips++;
            }
            prob += Math.pow(0.5, numFlips) / n;
        }

        System.out.println(prob);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int a,b,c;
   cin>>a>>b>>c;
   swap(a,b);
   swap(a,c);
   cout<<a<<" "<<b<<" "<<c;
   return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int a[101000];
int main()
{
    int i,j,k,m,n,x;
    ll cnt=0;
    cin>>n>>x;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        if(a[i]>x)
        {
            cnt+=(a[i]-x);
            a[i]=x;
        }
    }
    for(i=1; i<n; i++)
    {
        if(a[i]+a[i+1]>x)
        {
            cnt+=(a[i]+a[i+1]-x);
            if(a[i+1]>(a[i]+a[i+1]-x))
            {
                a[i+1]-=(a[i]+a[i+1]-x);
            }
            else
            {
                a[i+1]=0;
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;

mt19937 mt(736);

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	ll n;

	cin >> n;

	ll ans = 0;

	for (ll m = 1; m * (m + 1) < n; m++)
		if (n % m == 0)
			ans += n / m - 1;

	cout << ans << endl;
}


void stress(istream &cin = std::cin, ostream &cout = std::cout)
{
	ll n;

	cin >> n;

	ll ans = 0;

	for (ll m = 1; m <= n; m++)
		if (n / m == n % m)
			ans += m;

	cout << ans << endl;
}


void gen(ostream &cout = std::cout)
{
	static uniform_int_distribution<int> uid(1, 100500);

	cout << uid(mt) << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	ifstream fin("../input.txt");

	int cnt = 0;

	while (true)
	{
		stringstream ss, in1, in2, out1, out2;
		gen(ss);

		in1 << ss.str();
		in2 << ss.str();

		solve(in1, out1);
		stress(in2, out2);

		if (out1.str() != out2.str())
		{
			cout << ss.str() << endl;
			cout << out1.str() << endl;
			cout << out2.str() << endl;

			break;
		}

		cnt++;

		if (cnt % 100 == 0)
			cout << "ok\t" << cnt << endl;
	}

	cout << setprecision(4) << "clock: " << clock() / (double) CLOCKS_PER_SEC << endl;
#else
	cout << setprecision(20);

	solve();
#endif

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;

int main(){
  int t,h,m;
  double l,s,ans;

  scanf("%d",&t);
  while(t--){
    scanf("%d:%d",&h,&m);
    s = m*6;
    l = h*30 + (double)m/2;

    ans = l-s;
    if(ans<0.0)ans *= -1.0;
    if(ans>180.0)ans = 360.0 - ans;

    if(ans<30.0)printf("alert\n");
    else if(ans<90.0)printf("warning\n");
    else printf("safe\n");
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int sum;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x;cin>>x;
		sum+=x;
	}
	if(n-sum<0) {
		cout<<-1<<endl;
		return 0;
	}
	cout<<n-sum<<endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        String S = sc.next();

        int happy = 0;
        int blocks = 1;

        for (int i = 0; i < N; i++) {
            if (i > 0 && S.charAt(i) == 'L' && S.charAt(i - 1) == 'L') happy++;
            if (i < N - 1 && S.charAt(i) == 'R' && S.charAt(i + 1) == 'R') happy++;
            if (i > 0 && S.charAt(i) != S.charAt(i - 1)) blocks++;
        }

        if (K >= blocks / 2) {
            happy = N - 1;
        } else {
            happy += K * 2;
        }

        System.out.println(happy);
    }

}

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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

int main(){
  using mint = modint<(int)1e9+7>;
  int n;
  cin >> n;
  vector<vector<mint>> dp(n+1,vector<mint>(n+1));
  dp[0][0] = 1;
  for(int i = 0; i < n; ++i){
    vector<vector<mint>> dp_(n+1,vector<mint>(n+1));
    char c;
    cin >> c;
    if(c == '-') continue;
    for(int j = 0; j <= n; ++j){
      for(int k = 0; k <= n; ++k){
        if(c == 'D'){
          dp_[j][k] += dp[j][k]*j;
          if(k > 0 and j > 0)
            dp_[j-1][k-1] += dp[j][k]*j*k;
        }
        if(c == 'U'){
          dp_[j][k] += dp[j][k]*k;
          if(j < n and k < n)
            dp_[j+1][k+1] += dp[j][k];
        }
      }
    }
    swap(dp,dp_);
  }
  cout << dp[0][0] << endl;
}



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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll vec_max(auto & , string);
ll vec_min(auto & , string);

int main(){
  faster();
  int a,b,ans = 0;
  cin >> a >> b;
  for(int i=1;i<=3;i++){
    if(i==a || i==b) continue;
    else cout << i << endl;
  }
}


























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x, auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
ll vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
ll vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

Measured memory_bytes: 256
def solve():
    N, K = map(int, input().split())
    ans = 0
    if K == 0: print(N ** 2)
    else:
        for b in range(K + 1, N + 1):
            a = N // b
            ans += a * (b - K)
            ans += max(0, N - (a * b + K) + 1)
            
        print(ans)

    return 0

if __name__ == "__main__":
    solve()

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

const int N = (int) 1e5;
int may[N];
int cnt[N];

int main() {
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int m; cin >> m;
    for (int i = 0; i < n; ++i) cnt[i] = 1;
    may[0] = 1;
    for (int i = 0; i < m; ++i) {
        int x, y; cin >> x >> y; --x; --y;
        if (may[x]) may[y] = 1;
        --cnt[x]; ++cnt[y];
        if (cnt[x] == 0) may[x] = 0;
    }
    cout << accumulate(may, may + n, 0) << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;


ll mod = 1000000000 + 7;

int main(){
    ll N;
    cin >> N;
    vs s(N);

    for (ll i = 0; i < N; ++i) {
        cin >> s.at(i);
        sort(s.at(i).begin(), s.at(i).end());
    }

    map <string, long long int> S;
    for (ll i = 0; i < N; ++i) {
        S[s.at(i)] += 1;
    }

    long long int sum = 0;
    for(auto c : S){
        sum += c.second*(c.second-1)/2;
    }

    cout << sum << endl;

}

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n;
	cin >> n;
	int a = 1;
	while (111*a < n) a++;
	cout << 111*a << ende;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意
int main(){
  int N,M,a,b; cin>>N>>M;
  vector<vector<int>> G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
  
  vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
  vector<int> sign(N,-1);
    queue<int> que;
  
  
  // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
            sign[nv]=v+1;////
        }
    }


  
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++)cout<<sign[i]<<endl;

}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }


vector<int> dist;
int S, T;


void bfs(int u, vector<vector<int>> & G) {
	queue<int> q;
	q.push(S);
	while (!q.empty()) {
		int u = q.front(); q.pop();

		for (int v : G[u]) {
			if (dist[v] != INF) continue;
			dist[v] = min(dist[v], dist[u] + 1);
			q.push(v);
		}
	}
}


signed main() {

	int N, M;
	cin >> N >> M;
	vector<vector<int>> G(3 * N);
	dist.assign(3 * N, INF);

	rep(i, M) {
		int u, v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v+N);
		G[u + N].push_back(v + 2 * N);
		G[u + 2 * N].push_back(v);
	}
	cin >> S >> T; S--; T--;

	dist[S] = 0;
	bfs(S, G);

	if (dist[T] == INF) cout << -1 << endl;
	else cout << dist[T]/3 << endl;

	return 0;
}


Measured memory_bytes: 18944
#include<iostream>
#include<string>
using namespace std;
int main() {
	int ans = 0;
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < 3; i++) {
		if (S[i] == T[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Dec 22 21:00:16 JST 2019
 **/

signed main() {
    Int a = in(), b = in();
    cout << 6 - a - b << endl;
}


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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;
    ll n;

    cin >> n;

    set<string>s;


    for(int i=0; i<n; i++)
    {

        string st;

        cin >> st;

        s.insert(st);
    }

    cout << s.size() << endl;






    return 0;
}



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

int gcd(int a, int b, int c){
  int minv = min(min(a,b),c);
  for( int i = minv; i>0; i--){
    if(a % i == 0 && b % i == 0 && c % i == 0)
      return i;
  }
}
  
int main(){
  int K;
  int total =0;
  cin >> K;
  for(int i =0; i< K; i++){
    for(int j =0; j < K; j++){
      for(int x =0; x < K; x++){
        total += gcd(i+1,j+1,x+1);
      }
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}

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

  ll N;
  cin >> N ;
  vector<ll>T;

  ll sum=0;
  rep(i,N){
    ll inp; cin >> inp;
    T.pb(inp);
    sum += inp;
  }
  ll M ;
  cin >> M;
  vector<ll> P,X;

  rep(i,M){
    ll pi,xi;
    cin >> pi >> xi;
    
    cout << sum-T[pi-1]+xi<< endl;
  }


  
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef long long ll;

int main()
{
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	int sum = 0;
	if (a + b > c * 2)
	{
		if (x > y)
		{
			sum += c * 2 * y;
			if (a > c*2)
				sum += (x-y) * (c * 2);
			else
				sum += (x-y) * a;
		}
		else if (x < y)
		{
			sum += c * 2 * x;
			if (b > c*2)
				sum += (y - x) * (c * 2);
			else
				sum += (y - x) * b;
		}
		else if (x == y)
			sum =  c * (x + y);
	}
	else
		sum = (a*x)+(b*y);
	printf("%d\n", sum);
	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{
    int n;
    cin>>n;
    int a[10][10];
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++)
    {
        string x = to_string(i);
        a[x[0]-'0'][x[x.size()-1]-'0']++;
    }
    ll ans=0;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans;
    
   
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'A') return 1;
  else  if(ch == 'C') return 2;
  else  if(ch == 'G') return 3;
  else  if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;

  for(i = 0; i < strlen(str); i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}

int h2(int key){
  return 1 + (key % (M - 1));
}

int find(char str[]){
  long long key, i, h;

  key = getKey(str);

  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i ,h;

  key = getKey(str);

  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h, N = 0;
  int yn[M];
  char str[L], com[9];
 

  for(i = 0; i < M; i++){
    H[i][0] = '\0';
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s %s", com, str);

    if(com[0] == 'i'){
      insert(str);
    }
    else {
      if(find(str)){
	yn[N] = 1;
	N++;
      }
      else{
	yn[N] = 0;
	N++;
      }
    }
  }
  for(i = 0; i < N; i++){
    if(yn[i] == 1) printf("yes\n");
    if(yn[i] == 0) printf("no\n");
  }
    
  
  return 0;
}
  
  



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

int main(){

	int i, j, k, len, flag=0;
	long int count = 0;
	char S[200000];

	scanf("%s", S);

	len = strlen(S);

	i = 0;
	while (i<len-2){
		if (S[i] == 'A'){
			flag++;
			while (1){
				if (S[i + 1] == 'A'){
					flag++;
					i++;
				}
				else if (S[i + 1] == 'B' && S[i + 2] == 'C'){
					count += flag;
					i += 2;
				}
				else{
					i++;
					flag = 0;
					break;
				}
			}

		}else{
			flag = 0;
			i++;
		}
//		printf("%d\n", i);
	}

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

  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner as = new Scanner(System.in);
		int n = as.nextInt();
		int[] x;
		x = new int[n];
		long a = as.nextLong();
		long b = as.nextLong();
		for(int i=0;i<n;i++){
			x[i]  = Integer.parseInt(as.next());
		}
		long l = 0;
		for(int i=0;i<n-1;i++){
			if(a*(x[i+1]-x[i])>=b){
				l+=b;
			}else{
				l+=a*(x[i+1]-x[i]);
			}
		}
		System.out.println(l);
	}
}

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

typedef long long ll;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll h[n];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  ll lb=-1,ub=1e9;
  while(ub-lb>1){
    ll mid=(lb+ub)/2;
    ll k[n];
    ll count=0;
    for(int i=0;i<n;i++){
      k[i]=h[i]-b*mid;
      if(k[i]>0){
        count+=(k[i]-1)/(a-b)+1;
      }
    }
    if(count<=mid){
      ub=mid;
    }
    else{
      lb=mid;
    }
  }
  cout << ub << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int t[1000],a[1000];
  long long int rt,ra,r,tt,aa;
  long long int nowt,nowa;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i]>>a[i];
  }
  nowt=t[0];nowa=a[0];
  for(int i=0;i<n;i++){
    rt=((nowt+t[i]-1)/t[i]);
    ra=((nowa+a[i]-1)/a[i]);
    r=max(rt,ra);
    nowt=r*t[i];nowa=r*a[i];
  }
  cout<<nowt+nowa<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  char a,b;
  cin>>a>>b;
  char max=(a>=b?a:b);
  char min=(a>=b?b:a);
  char arr[max];
  for(int i=0;i<((int)max-'0');i++){
  	arr[i]=min;
    cout<<arr[i];
  }
}

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

class Vector2 {
public:
  double x, y;
  ll t;

  Vector2(): x(0), y(0) {}
  Vector2(double x, double y): x(x), y(y) {}

  Vector2 operator+(Vector2 p) { return Vector2(x + p.x, y + p.y); }
  Vector2 operator-(Vector2 p) { return Vector2(x - p.x, y - p.y); }

  Vector2 operator*(double t) { return Vector2(x * t, y * t); }
  Vector2 operator/(double t) { return Vector2(x / t, y / t); }

  double dot(Vector2 p) { return x * p.x + y * p.y; }
  double det(Vector2 p) { return x * p.y - y * p.x; }

  double norm2() { return x * x + y * y; }
  double norm() { return sqrt(norm2()); }

  double distance2(Vector2 p) { return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y); }
  double distance(Vector2 p) { return sqrt(distance2(p)); }

  Vector2 normalize() {
    double d = norm();
    return Vector2(x / d, y / d);
  }

  friend ostream& operator<<(ostream &out, const Vector2 &v) {
    out << "(" << v.x << ", " << v.y << ")";
  }
};
using Point2 = Vector2;

/* 凸方, convex full */
vector<Point2> convex_hull(vector<Point2> ps) {
  ll n = ps.size();
  sort(ps.begin(), ps.end(), [](const Point2 &p, const Point2 &q) {
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
  });
  ll k = 0;
  vector<Point2> qs(n * 2);
  REP(i, 0, n) {
    while(k > 1 && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  for(ll i = n - 2, t = k; i >= 0; i--) {
    while(k > t && (qs[k - 1] - qs[k - 2]).det(ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  qs.resize(k - 1);
  return qs; /* clockwise, first vertix is lexicographically smallest */
}

int main(void) {
  ll N;
  cin >> N;
  vector<Point2> P(N);
  REP(i, 0, N) {
    cin >> P[i].x >> P[i].y;
    P[i].t = i;
  }

  vector<Point2> qs = convex_hull(P);
  ll s = qs.size();

  vector<double> ans(N, 0);
  REP(i, 0, qs.size()) {
    Vector2 p = qs[(i + s - 1) % s];
    Vector2 c = qs[i];
    Vector2 n = qs[(i + 1) % s];

    double a1 = n.y - c.y, b1 = -(n.x - c.x);
    double theta1 = atan2(b1, a1) + M_PI;

    double a2 = c.y - p.y, b2 = -(c.x - p.x);
    double theta2 = atan2(b2, a2) + M_PI;

    if(theta1 > theta2) ans[c.t] = (theta1 - theta2) / (M_PI * 2);
    if(theta1 < theta2) ans[c.t] = (theta1 - theta2 + M_PI * 2) / (M_PI * 2);
  }

  REP(i, 0, ans.size()) printf("%.15lf\n", ans[i]);
}


Measured memory_bytes: 384
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool check(pair<ll,ll>a,pair<ll,ll>b){
	return (a.first>b.first&&a.second>b.second);
}

bool fun(pair<ll,ll>b,pair<ll,ll>a){
	if(a.first==b.first)return a.second>b.second;
	else return a.first<b.first;
}

int main(){
	bool isOK=true;
	ll N;cin>>N;
	while(N--){
		ll a;cin>>a;
		if(a%2==0)if(!(a%5==0||a%3==0))isOK=false;
	}
	if(isOK)cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256