akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
from pprint import pprint
#from scipy.special import comb

n = int(input())

a_list = list(map(int,input().split()))

a_dict = defaultdict(int)

for i in a_list:
    a_dict[i] += 1

#pprint(a_dict)

#総数から(a_dict[k]-1)の値を引いていく。
#例えば5C2のものが一つ減った場合、4C2になる。この差分は5C2-4C2=10-6=4 
#例えば6C2のものが一つ減った場合、5C2になる。この差分は6C2-5C2=15-10=5 
#例えば7C2のものが一つ減った場合、6C2になる。この差分は7C2-6C2=21-15=6

total = 0

#組み合わせの総数を求める。
for j in a_dict.values():
    total += j*(j-1)/2

for k in a_list:
    print(int(total - (a_dict[k]-1)))

Measured memory_bytes: 26504
#include<iostream>
using namespace std;
int main()
{
	int a = 0;
	int b = 1;
	while (cin >> a)
	{
		if (a == 0)
		{
			break;
		}
		cout << "Case " << b << ": " << a << endl;
		b++;
	}
	return 0;
}

Measured memory_bytes: 3008
#include<bits/stdc++.h>
using namespace std;
#define maxk 100005 
#define maxn 105
#define mod 1000000007
int main()
{
	int n,k;
	int dp[2][maxk];
	scanf("%d%d",&n,&k);
	dp[0][k] = 1;
	for(int i=1; i<=n; i++)
	{	
		int sum = 0, x;
		scanf("%d",&x);
		for(int j=k; j>=0; j--)
		{
			sum = (sum + dp[(i+1)&1][j]) % mod;
			if(j+x+1<=k)
				sum = (sum + mod - dp[(i+1)&1][j+x+1]) % mod;
			dp[i&1][j] = sum;
		}
	}
	printf("%d\n",dp[n&1][0]);
	return 0;	
}

Measured memory_bytes: 1024
#include<iostream>
#include<stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
	for (int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v])return v;
	}
	return -1;
}

void dfs_visit(int r) {
	for (int i = 0; i < n; i++)nt[i] = 0;

	stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = ++tt;

	while (!S.empty()) {
		int u = S.top();
		int v = next(u);
		if (v != -1) {
			if (color[v] == WHITE) {
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}
		else {
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}
}

void dfs() {
	for (int i = 0; i < n; i++) {
		color[i] = WHITE;
		nt[i] = 0;
	}
	tt = 0;

	for (int u = 0; u < n; u++) {
		if (color[u] == WHITE)dfs_visit(u);
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
}

int main() {
	int u, k, v;

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

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	dfs();

	return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_H = 2005;
const int MAX_W = 2005;

int H, W;
char F[MAX_H][MAX_W];

int HH[MAX_H][MAX_W];
int WW[MAX_H][MAX_W];

signed main()
{
  cin >> H >> W;
  REP(h,H) {
    REP(w,W) {
      cin >> F[h][w];
    }
  }

  REP(h,H) {
    int sW = 0, eW = 0;
    while(eW < W) {
      if(F[h][eW] == '#') {
        FOR(w,sW,eW) {
          WW[h][w] = eW-sW;
        }
        eW++;
        sW = eW;
      } else {
        eW++;
      }
    }
    FOR(w,sW,eW) {
      WW[h][w] = eW-sW;
    }
  }

  REP(w,W) {
    int sH = 0, eH = 0;
    while(eH < H) {
      if(F[eH][w] == '#') {
        FOR(h,sH,eH) {
          HH[h][w] = eH-sH;
        }
        eH++;
        sH = eH;
      } else {
        eH++;
      }
    }
    FOR(h,sH,eH) {
      HH[h][w] = eH-sH;
    }
  }

  int ans = 0;
  REP(h,H) {
    REP(w,W) {
      ans = max(ans, HH[h][w] + WW[h][w] - 1);
    }
  }

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int x , y;
string s;

int main()
{
    _FastIO;
    cin >> x >> y;
    string ans = "No";
    for(int i = 0; i <= x; i++){
        int k = x - i;
        int t = i * 2 + k * 4;
        if(t == y)
            ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
main(){
  int a,b,c,d,e=0,f=0;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    for(b=0;b<a;b++){
      scanf("%d %d",&c,&d);
      if(c>d){
	e=e+c+d;
      }
      else if(c<d){
	f=f+c+d;
      }
      else{
	e=e+c;
	f=f+d;
      }
    }
    printf("%d %d\n",e,f);
    e=0;
    f=0;
  }
  return 0;
}
    

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

int main()
{
    int N;
    cin >> N;
    cout << 1000 * ((N-1) / 1000 + 1) - N << endl;
}


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

string s[3] = {};

void SentouDelete(int i) {
  s[i].erase(s[i].begin());
}

int SizeHa(int i) {
  return s[i].size();
}

int TsugiHaDare(char x) {
  if (x == 'a') {
    return 0;
  } else if (x == 'b') {
    return 1;
  } else if (x == 'c') {
    return 2;
  }
}

void DaregaKatta(int x) {
  switch (x) {
    case 0:
      cout << 'A' << endl;
      break;
    case 1:
      cout << 'B' << endl;
      break;
    case 2:
      cout << 'C' << endl;
      break;
    default:
      break;
  };
}

int main() {
  for (int i=0; i<3; i++) {
    cin >> s[i];
  }

  int dare = 0;
  int next_dare = 0;
  char toridashi;
  int size;

  while (1) {
    size = SizeHa(dare);
    if (0 == size) {
      DaregaKatta(dare);
      break;
    }

    toridashi = s[dare][0];
    SentouDelete(dare);
    next_dare = TsugiHaDare(toridashi);
    dare = next_dare;
  }
}


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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(15);
    int N;
    cin >> N;
    set<string> words;
    string w;
    cin >> w;
    words.insert(w);
    char wp(*w.rbegin());
    for (int i = 1; i < N; ++i) {
        cin >> w;
        if (w[0] != wp || words.find(w) != words.end()) {
            cout << "No\n";
            return 0;
        } else {
            wp = (*w.rbegin());
            words.insert(w);
        }
    }
    cout << "Yes\n";
    return 0;
}



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

 int main(){
 	int w,h,x,y,r;
 	cin>>w>>h>>x>>y>>r;
 	if(x-r<0||x+r>w||y-r<0||y+r>h){
 		cout<<"No"<<'\n';
 	}else{
 		cout<<"Yes"<<'\n';
 	}
 	return 0;
 }

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

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

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int n,m;
int dp[100010];
int x,y;
vector<int>v[100010];
int ans;

void dfs(int now){
	if(dp[now])return;
	for(int u:v[now]){
		dfs(u);
		dp[now]=max(dp[now],dp[u]+1);
	}
	return;
}

void input(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		x--,y--;
		v[x].eb(y);
	}
	return;
}

void solve(){
	for(int i=0;i<n;i++){
		dfs(i);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return;
}

int main(){
	input();
	solve();
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3592
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]


uf1=UnionFind(n)
for i in range(m):
    b=a[i][0]
    c=a[i][1]
    uf1.union(b-1,c-1)

ans=uf1.group_count()
print(ans)

Measured memory_bytes: 80472
#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define MAX 100000
vector<int>G[MAX];
int N;
bool visited[MAX];
int prenum[MAX];
int parent[MAX];
int lowest[MAX];
int timer;
void dfs(int current,int prev){
  //ノードcurrentを訪問した直後の処理
  prenum[current]=lowest[current]=timer;
  timer++;
  visited[current]=true;
  int next;
  for(int i=0;i<G[current].size();i++){
    next=G[current][i];
    if(!visited[next]){
      //ノードcurrentからノードnext訪問直前の処理
      parent[next]=current;
      dfs(next,current);
      //ノードnextの探索が終了した直後の処理
      lowest[current]=min(lowest[current],lowest[next]);
    }else if(next!=prev){
      //エッジcurrent-->がBack-edgeの場合の処理
      lowest[current]=min(lowest[current],prenum[next]);
    }
  }
  //ノードcurrentの探索が終了した直後の処理
}
void art_points(){
  for(int i=0;i<N;i++){
    visited[i]=false;
  }
  timer=1;
  //lowestの計算
  dfs(0,-1);//0==root
  set<int>ap;
  int np=0;
  for(int i=1;i<N;i++){
    int P=parent[i];
    if(P==0){
      np++;
    }else if(prenum[P]<=lowest[i]){
      ap.insert(P);
    }
  }
  if(np>1){
    ap.insert(0);
  }
  for(set<int>::iterator it=ap.begin();it!=ap.end();it++){
    cout<<*it<<endl;
  }
}
int main(){
  int m;
  cin>>N>>m;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();
  return(0);
}
    
  



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

using namespace std;
long double n,t1,a,t[1000002];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> a;
	long double p = 3.14159265358979323;
	cout << setprecision(10) <<  2*p*a << endl;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>

using namespace std;
 
template <class T> using V = vector<T>;
 
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;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
#define pb(a) push_back(a);
  
 

ll sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}




 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 


signed main() {
  ll n;
  	cin>>n;
  st s;
  	cin>>s;
 // ll n=s.sz;
  ll ans=1;
  FOR(i,1,n){
    if(s[i-1]!=s[i]){
      ans++;
    }
  }
  co(ans)
}


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



int main(){
  int N;
  cin>>N;
  
  vector<int> vec(100002);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    vec.at(a+1)++;
  }
  int kaz=0;
  for(int i=1;i<=100000;i++){
    int tmp;
    tmp+=vec.at(i-1)+vec.at(i)+vec.at(i+1);
    kaz=max(kaz,tmp);
  }
  cout<<kaz<<endl;
    
  
}

Measured memory_bytes: 3760
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

import string
al = list(string.ascii_lowercase)
n = inp()
ans = ""
while n:
    n -= 1
    rem = n%26
    ans = al[rem] + ans
    n = (n-rem)//26
print(ans)

Measured memory_bytes: 71768
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		
		int x = 0;
		int max = 0;
		for(int i = 0; i < n; i++){
			if(s.charAt(i) == 'I' ){
				x++;
			}else{
				x--;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
		sc.close();
	}
 
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

ll extgcd(ll a, ll b, ll& x, ll& y) {
  ll d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

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

template <typename T>
struct SegmentTree {
  using F = function<T(T, T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f, T ti) : f(f), ti(ti) {}

  void init(int n_) {
    n = 1;
    while (n < n_)
      n <<= 1;
    dat.assign(n << 1, ti);
  }

  void build(const vector<T>& v) {
    int n_ = v.size();
    init(n_);
    for (int i = 0; i < n_; i++)
      dat[n + i] = v[i];
    for (int i = n - 1; i; i--)
      dat[i] = f(dat[(i << 1) | 0], dat[(i << 1) | 1]);
  }

  void set_val(int k, T x) {
    dat[k += n] = x;
    while (k >>= 1)
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
  }

  // [a, b)
  T query(int a, int b) {
    T vl = ti, vr = ti;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1)
        vl = f(vl, dat[l++]);
      if (r & 1)
        vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

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

  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  auto f = [](ll a, ll b) {
    if (b == 0)
      return a;
    else
      return gcd(a, b);
  };
  SegmentTree<ll> seg(f, 0);
  seg.build(A);

  ll ans = 0;
  rep(i, N) {
    ll l = seg.query(0, i);
    ll r = seg.query(i + 1, N);
    chmax(ans, gcd(l, r));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int n = in.nextInt();

        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        long sum = 0;

        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            if (x < min) {
                min = x;
            }
            if (max < x) {
                max = x;
            }
            sum = sum + x;
        }

        System.out.printf("%d %d %d", min, max, sum);
        System.out.println();
        System.exit(0);
    }
}



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

int main()
{
    int n, m, l, a[100][100], b[100][100];
    cin >> n >> m >> l;
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j];
    for (int i = 0; i < m; i++) for (int j = 0; j < l; j++) cin >> b[i][j];

    long long c[100][100] = {};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            for (int k = 0; k < m; k++) {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            cout << c[i][j] << (j == l - 1 ? "" : " ");
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <algorithm>
#include <stdlib.h>   
using namespace std;
// [正]三角形
int main(void){
    
    int a[3];
    for (int i =0;i<3;i++){
        cin>>a[i];
    }
    if (a[2]==a[1] and a[0]==a[1]){
        cout<<"Yes";//
    }
    else{
        
        cout<<"No";//
    }
    //cout<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int a,c;
  string b;
  cin >> a >> b >> c;
  if (b=="+") cout << a+c << endl;
  else cout << a-c << endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    a,b,c = map(int,input().split())
    if a == -1 and b == -1 and c == -1:
        break
    if a == -1 or b == -1 :
        print("F")
    elif a + b >= 80:
        print("A")
    elif a + b >= 65:
        print("B")
    elif a + b >= 50:
            print("C")
    elif a + b >= 30:
        if c >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//22m
//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"


int a; string st;
bitset<11>bs;

bool getalpha() {
	if (st[a] == 'T')return true;
	else if (st[a] == 'F')return false;
	else {
		return bs[st[a] -'a'];
	}
}
bool getexpr();
bool getform() {
	if (st[a] == '-') {
		a++;
		return !getform();
	}
	else if (st[a] == '(') {
		a++;
		bool aok = getexpr();
		a++;
		return aok;
	}
	else {
		bool aa=getalpha();
		a++; return aa;
	}
}
bool getexpr() {
	bool aok = getform();
	while (1) {
		if (a == st.size() || st[a] == '='||st[a]==')')return aok;
		else if (st[a] == '*') {
			a++;
			aok &= getform();
		}
		else if (st[a] == '+') {
			a++;
			aok |= getform();
		}
		else if (st[a] == '-') {
			a += 2;
			if (!getform()&&aok)aok = false;
			else aok = true;
		}
		else {
			assert(false);
		}
	}
	return aok;
}
int main() {
	while (1) { cin >> st;
	if (st == "#")break;
		bool ok = true;
		for (int i = 0; i < (1 << 11); ++i) {
			a = 0;
			bs = i;

			bool from = getexpr();
			a++;
			bool to = getexpr();
			if (from != to)ok = false;
		}
		if (ok)cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
import numpy as np
n,k=map(int,input().split())
p=list(map(int,input().split()))
l=[]
for i in p:
  l.append(i+1)
t=np.cumsum(np.array(l),dtype=int)
ans=t[k-1]
for j in range(n-k):
  ans=max(ans,t[j+k]-t[j])
print(ans/2)

Measured memory_bytes: 33996
import bisect

N = int(input())
L = list(map(int, input().split()))

L.sort()
ans = 0
for i in range(N):
    for j in range(i+1, N):
        idx = bisect.bisect_left(L, L[i]+L[j])
        ans += max(0, idx-j-1)

print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll L;
ll ans = 0;

int main()
{
  scanf( "%lld", &L );

  double x = L/3.0;

  printf( "%.12f\n", x*x*x );

  return 0;
}

Measured memory_bytes: 256
//Induber
//PRAVEEN FULERA

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);
#define up cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define T int t; cin >> t; while(t--)

int main(){
  speed up
  string s;
  cin >> s;
  int mmyy , yymm;
  mmyy = (s[0]-'0')*10 + (s[1]-'0');
  yymm = (s[2]-'0')*10 + (s[3]-'0');
  if(mmyy > 0 && mmyy <= 12 && yymm > 0 && yymm <= 12){
      cout << "AMBIGUOUS\n";
  }
  else if(mmyy > 0 && mmyy <= 12 && (yymm == 0 || yymm > 12)){
      cout << "MMYY\n";
  }
  else if((mmyy == 0 || mmyy > 12) && (yymm > 0 && yymm <= 12)){
      cout << "YYMM\n";
  }
  else{
      cout << "NA\n";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<list>
#include<set>
#include<iomanip>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<sstream>
#include<algorithm>
using namespace std;
#define MAXN 10005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
typedef long long ll;
int a[100005];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	int num=0;
	for(int i=0;i<n;)
	{
		int x=a[i];
		int ans=1;
		int j;
		for(j=i+1;j<n;j++)
		{
			if(a[j]==x) ans++;
			else break;
		}
		if(ans>x) num+=(ans-x);
		else if (x>ans) num+=ans;
		i=j;   
	}
	cout<<num<<endl;
	return 0;
}















Measured memory_bytes: 640
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		if(n==1){

			System.out.println("Hello World");
		}else{

			int a = sc.nextInt();
			int b = sc.nextInt();
			
		System.out.println(a+b);
		}




	}

}

Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt[26] = {0};
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < s.size(); j++) {
            if (char('a'+i) == s[j]) {
                cnt[i]++;
            }
        }
        if (cnt[i] == 0) {
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout <<"None" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

vector<pair<ll,ll>> prime_factorization(ll N) {
    vector<pair<ll,ll>> res;
    for(ll i = 2; i * i <= N; i++) {
        if(N % i == 0) {
            ll ex = 0;
            while(N % i == 0) {
                ex++;
                N /= i;
            }
            res.push_back(make_pair(i,ex));
        }
    }
    if(N != 1) res.push_back(make_pair(N,1));
    return res;
}

int main() {
    ll N,P; cin >> N >> P;
    vector<pair<ll,ll>> res = prime_factorization(P);
    ll ans = 1;
    for(auto p:res) {
        for(int i = 0; i < p.second/N; i++) {
            ans *= p.first;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int N, ct, num, max;
    scanf("%d", &N);
    char S[N];
    scanf("%s", S);

    max = 0;
    for(int i=1;i<N;i++){
        ct = 0;
        char tmp_1[26] = {}, tmp_2[26] = {};
        for(int j = 0; j < i; j++){
            if(strchr(tmp_1, S[j]))
                continue;
            else
                tmp_1[ct++] = S[j];
        }
        ct = 0;
        for(int j = i; j < N; j++){
            if(strchr(tmp_2, S[j]))
                continue;
            else
                tmp_2[ct++] = S[j];
        }
        num = 0;
        for (int j = 0; j < ct; j++){
            if(strchr(tmp_1, tmp_2[j]))
                num += 1;
        }
        max = num>max ? num:max;
    }

    printf("%d", max);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define swap(a,b) a^=b^=a^=b

int partition(int *A,int p,int r){
  int x=A[r],i=p-1,j;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

int main(void){

  int n,A[100000],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  int res = partition(A,0,n-1);
  for(i=0;i<n;i++){
    if(i==res)printf("[%d]",A[i]);
    else printf("%d",A[i]);    
    if(i<n-1)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
def is_seeable(H):
    if len(H) == 1:
        return True
    for h in H[:-1]:
        if h > H[-1]:
            return False
    return True

N = int(input())
H = list(map(int, input().split()))

ans = 0
for i in range(len(H)):
    if is_seeable(H[:i+1]):
        ans = ans + 1
print(ans)


Measured memory_bytes: 2940
let iota ?(init=0) ?(step=1) n =
  let rec iota i n acc =
    if n = 0 then List.rev acc
    else iota (i + step) (pred n) (i :: acc) in
  iota init n []

let is_prime n =
  if n < 2 then false
  else if n mod 2 = 0 && n <> 2 then false
  else
    let rec is_prime d =
      if d * d > n then true
      else if n mod d = 0 then false
      else is_prime (d + 2) in
    is_prime 3

let rec solve () =
  try
    let n = int_of_string @@ read_line () in
    let xs = iota ~init:1 n in
    let pairs = List.combine xs @@ List.rev xs in
    print_endline @@ string_of_int
    @@ List.fold_left
         (fun s (a, b) -> if is_prime a && is_prime b then s + 1 else s)
         0
         pairs;
    solve ()
  with End_of_file -> ()

let () = solve ()

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

llint x;

llint solve(llint n) {
    if(n==-1) return 0;
    else return n/x+1;
}

int main(void) {
    llint a, b, ans1, ans2, ans;
    cin >> a >> b >> x;

    cout << solve(b)-solve(a-1) << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,z,w;cin >> n >> z >> w;
	vector<ll> a(n);REP(i,n)cin >> a[i];
	
	ll ans = 0;
	if(n > 1)ans =  max(0ll,abs(a[n-2]-a[n-1]));
	cout << max(abs(w-a[n-1]),ans) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
const long long int inf = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// ------------------------------------

int main(){
    ll n, m;
    cin>>n>>m;
    ll a[m];
    for(ll i=0;i<m;++i){
        cin>>a[i];
        n -= a[i];
    }
    ll ans;
    if(n>=0){
        ans=n;
    }else{
        ans=-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3712
N = input()

nagasa = len(N)
flag = 0
res = 0
for i in range(nagasa):
	s = nagasa - i - 1
	n = int(N[s])

	if flag == 2:
		if n <= 4:
			flag = 0
			res += n
		elif n == 5:
			flag = 1
			res += 4
		elif n >= 6:
			flag = 1
			res += 9 - n
	else:
		if flag == 1:
			n += 1
		if n == 5:
			flag = 2
			res += 5
		elif n > 5:
			flag = 1
			res += 10 - n
		else:
			flag = 0
			res += n

if flag == 1:
	print(res + 1)
else:
	print(res)

Measured memory_bytes: 53612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;

LL gcd(LL a,LL b)
{
	if(a<b)return gcd(b,a);
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
	LL n,x;cin>>n>>x;
	LL a[100010];
	for(LL i=0;i<n;i++)cin>>a[i];
	LL ans=0;
	for(LL i=0;i<n;i++)
	{
		if(i==0)ans=abs(a[0]-x);
		else ans=gcd(ans,abs(a[i]-x));
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

  string s;
  cin >> s;
  int n = s.size();

  int k;
  if (n % 2 == 1) k = (n + 1)/2 - 1;
  else k = (n + 1)/2;

  k++;

  //s[n-k]からs[k-1]
  int b = 0, w = 0;
  for (int i = n - k; i < k; i++) {
    if (s[i] == '0') w++;
    else b++;
  }

  while (w * b == 0 && k < n) {
    k++;
    if (s[n-k] == '0') w++;
    else b++;
    if (s[k-1] == '0') w++;
    else b++;
  }

  if (w*b == 0) cout << k << endl;
  else cout << k - 1 << endl;

  return 0;

}
   


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  string S;
  cin>>N>>S;
  for(int i=0;i<S.size();i++){
    cout<<(char)((S[i]-'A'+N)%26+'A');
  }
  return 0;
}


Measured memory_bytes: 256
s = input()
s.split()
a = [0]*len(s)
j = 0

if(s[j] in s[j+1:]):
  print("no")
  exit()
  
for i in range(1,len(s)):
  if(s[i] not in s[:j]):
    if(s[i] not in s[i+1:]):
      #print(s[i],s[i:])
      continue
    else:
      #print(s[i],s[i+1:])
      print("no")
      exit()
  else:
    #print("no")
    exit()
  j = j + 1

print("yes")
  
  

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <map>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int h,w,d;
cin >> h >> w >> d;

ll distw[90010];
ll disth[90010];
ll s[90010] = {}; //累積和。

for(int i = 1; i<=h; i++){
 for(int j = 1; j<=w; j++){
int a;
cin >> a;
disth[a] = i;
distw [a] = j;
 }
}

for(int i = d+1; i<=h*w; i++){
s[i] =s[i-d] + abs(disth[i] - disth[i-d]) + abs(distw[i] - distw[i-d]);
}
int q;
cin >> q;

for(int i = 0; i<q; i++){
int L,R;
cin >> L >> R;

cout << s[R] - s[L]<<endl;

}

return 0;
}

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

using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using usize = uint64_t;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    i64 n, k;
    cin >> n >> k;
    if (n > k) {
        n = n % k;
    }
    i64 ans = min(k - n, n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j, H, W;
	
	while(1) {
	
	scanf("%d %d", &H, &W);
	if (H ==0 && W == 0) break;
	
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			if (i == 1 || i == H) printf("#");
			else
			if (j == 1 || j == W) printf("#");
			else
			printf(".");
		}
		printf("\n");
	}
	printf("\n");
	
	}
						
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1e6;
const int INF = 1e18 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];

int32_t main() {
    IOS;
    cin>>n>>m;
    if(n<=5)cout<<0;
    else if(n<=12)cout<<m/2;
    else cout<<m;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool upper(char N){
	
	
return (N>=65&&N<97);	
	
}
int main(){
	
string A;
getline (cin,A);
int len=A.length();
if( upper(A[0]))
cout<<A[0];
for(int i=1;i<len;i++){
	
	if(upper(A[i])&& A[i-1]==' ')
              cout<<A[i];
 
	
}
	
	
	
	
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a_set = set()
for i in range(M):
    a_set.add(int(input()))
mod = 1000000007

ways = [0] * (N + 1)
if N not in a_set:
    ways[N] = 1
if N - 1 not in a_set:
    ways[N - 1] = 1

for n in reversed(range(N - 1)):
    if n in a_set:
        continue
    ways[n] = (ways[n + 1] + ways[n + 2]) % mod
print(ways[0])


Measured memory_bytes: 11884
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>inline bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    string s;
    cin >> s;
    int n=s.size();
    n+=n%2;
    while (n-=2){
        bool flug=true;
        for range(i,n/2){
            if (s[i]!=s[i+n/2]) { flug=false; }
        }
        if (flug) { cout << n<<  endl; return 0;}
    }
}

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

#A
def A():
    a, b = LI()
    print((a-1)*(b-1))
    return

#B
def B():
    def est(n):
        res = 0
        for i in range(1, int(n ** 0.5) + 1):
            if not n % i:
                res += 2
        res -= float.is_integer(n ** 0.5)
        return res == 8
    n = II()
    ans = 0
    for i in range(1, n + 1, 2):
        ans += est(i)
    print(ans)
    return

#C
def C():
    s = S()
    k = II()
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            return
    print(s[k-1])
    return

# D
# 解説AC
# 始点と終点を2次元座標に落とし込むことで解ける
# 難しい
def D():
    n, m, q = LI()
    c = [[0] * (n+1) for i in range(n+1)]
    for _ in range(m):
        l, r = LI()
        c[r][l] += 1
    for y in range(1, n + 1):
        for x in range(1, n + 1):
            c[y][x] += c[y][x - 1]
    for x in range(1, n + 1):
        for y in range(1, n + 1):
            c[y][x] += c[y - 1][x]
    for _ in range(q):
        p, q = LI()
        ans = c[q][q] - c[q][p - 1] - c[p - 1][q] + c[p - 1][p - 1]
        print(ans)
    return

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


Measured memory_bytes: 57308
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
 
const int MAXN = 3000 + 5;
 
string s, t, ans;
int dp[MAXN][MAXN], from[MAXN][MAXN];
 
void get(int x, int y) {
    if (x == 0 || y == 0) {
        return;
    }
 
    switch (from[x][y])
    {
    case 1:
        ans += s[x - 1];
        get(x - 1, y - 1);
        break;
 
    case 2:
        get(x - 1, y);
        break;
 
    case 3:
        get(x, y - 1);
        break;
    
    default:
        break;
    }
}
 
int main() {
    IOS
 
    cin >> s >> t;
 
    int n = s.length(), m = t.length();
    
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                from[i][j] = 1;
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]) {
                    dp[i][j] = dp[i - 1][j];
                    from[i][j] = 2;
                } else {
                    dp[i][j] = dp[i][j - 1];
                    from[i][j] = 3;
                }
                //dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
 
    get(n, m);
 
    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i];
    }
    cout << '\n';
}

Measured memory_bytes: 74096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, x[10], y[10];

    cin >> n;
    REP(i, n)
    cin >> x[i] >> y[i];

    vector<int> v(n);
    REP(i, n)
    v[i] = i;

    long double sum = 0;

    int t = 0;

    do
    {
        double s = 0;

        for (int i = 1; i < n; i++)
        {
            int j = v[i];
            int k = v[i - 1];
            s += sqrt((x[j] - x[k]) * (x[j] - x[k]) + (y[j] - y[k]) * (y[j] - y[k]));
        }

        sum += s;
        t++;
    } while (next_permutation(v.begin(), v.end()));

    cout << setprecision(20) << (sum / (double)t) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int x = scan.nextInt();
    int y = scan.nextInt();

    if(x < y){
      int swap = x;
      x = y;
      y = swap;
    }

    while(y > 0){
      int z = x % y;
      if(z == 0){
        break;
      }
      x = y;
      y = z;
    }

    System.out.println(y);
  }


}


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

int fibonacci[44];

int fib(int n){
    if(fibonacci[n]!=0){
        return fibonacci[n];
    }

    if(n==0||n==1){
        fibonacci[n] = 1;
        return 1;
    }

    fibonacci[n] = fib(n-1) + fib(n-2);
    return fibonacci[n];
}

int fib2(int n){
    if(n==1 || n==0){
        return 1;
    }
    return fib2(n-1) + fib2(n-2);
}

int main(){
    int n;
    cin >> n;
    int result = fib(n); 
    cout << result << endl;
}


Measured memory_bytes: 3120
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
        
    def insert(self, z):
        if z.key < self.key:
            if self.left:
                self.left.insert(z)
            else:
                self.left = z
                z.parent = self
        else:
            if self.right:
                self.right.insert(z)
            else:
                self.right = z
                z.parent = self

    def find(self, key):
        if self.key == key:
            return True
        elif not self.left and not self.right:
            return False
        else:
            if key < self.key:
                return self.left.find(key)
            else:
                return self.right.find(key)
            
    def delete(self, key):
        if self.key == key:
            if not self.left and not self.right:
                if self.key < self.parent.key:
                    self.parent.left = None
                else:
                    self.parent.right = None
            elif self.left and self.right:
                A = [int(i) for i in self.ino().split()]
                ind = A.index(self.key)
                y = A[ind+1]
                self.delete(y)
                self.key = y
            else:
                if self.left:
                    self.left.parent = self.parent
                    if self.key < self.parent.key:
                        self.parent.left = self.left
                    else:
                        self.parent.right = self.left
                else:
                    self.right.parent = self.parent
                    if self.key < self.parent.key:
                        self.parent.left = self.right
                    else:
                        self.parent.right = self.right
        else:
            if self.key < key:
                self.right.delete(key)
            else:
                self.left.delete(key)
        
    def preo(self):
        tmp = ""
        tmp += " " + str(self.key)
        if self.left:
            tmp += self.left.preo()
        if self.right:
            tmp += self.right.preo()
        return tmp
    
    def ino(self):
        tmp = ""
        if self.left:
            tmp += self.left.ino()
        tmp += " " + str(self.key)
        if self.right:
            tmp += self.right.ino()
        return tmp
m = int(input())
root = None
for i in range(m):
    com = input().split()
    if com[0] == "insert":
        node = Node(int(com[1]))
        try:
            root.insert(node)
        except AttributeError :
            root = node
    elif com[0] == "find":
        try:
            if root.find(int(com[1])):
                print("yes")
            else:
                print("no")
        except AttributeError:
            print("no")
    elif com[0] == "delete":
        try:
            root.delete(int(com[1]))
        except AttributeError:
            print("failed deletion")
    else:
        try:
            print(root.ino())
            print(root.preo())
        except AttributeError:
            print("None")


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


int main()
{
    int n;
    cin>>n;
    string x;
    cin>>x;
    if(x.length()<=n){
        cout<<x<<endl;
    }
    else{
        string  y= x.substr(0, n);
    string z= y+"...";
    cout<<z<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        S[i] = (char)((int)S[i] + N);
        if(S[i] > 'Z')
            S[i] -= 26;
        
    }
    cout << S << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
using namespace std;
const int N=107;
struct V {
	int x,y;
	bool operator < (const V &_) const {
		return atan2(y,x)<atan2(_.y,_.x);
	}
	V operator + (const V &_) const {
		return (V){x+_.x,y+_.y};
	}
	long long len2() {
		return 1LL*x*x+1LL*y*y;
	}
}A[N];
int n;
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d%d",&A[i].x,&A[i].y);
	sort(A+1,A+1+n);
	long long ans=0;
	For(i,1,n) {
		V r=(V){0,0};
		For(j,0,n-1) {
			r=r+A[(i+j-1)%n+1];
			ans=max(ans,r.len2());
		}
	}
	printf("%.14f",sqrt(ans));
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int arr[100001];
	int n;
	cin >> n;
	for(int i=0 ;i<n ; i++)
		cin >> arr[i];

	
	int a = 0;
	int b = 0;
	for(int i=0 ; i<n ; i++)
	{
		if(arr[i]%4 == 0)
			a++;
		else if(arr[i]%2 == 0)
			b++;
	}
	int temp = n-a-b;

	if(a+1 == temp && a+temp == n)
		cout << "Yes";
	else if(a >= temp)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict
N=int(input())
A=[input() for i in range(N)]
dd=defaultdict(int)
for s in A[0]:
    dd[s]+=1
for i in range(1,N):
    ddl=defaultdict(int)
    for s in A[i]:
        ddl[s]+=1
    for a in dd.keys():
        dd[a]=min(dd[a],ddl[a])
ans=[]
for a,j in sorted(dd.items(), key=lambda x: x[0]):
    ans+=[a]*j
print(''.join(map(str,ans)))

Measured memory_bytes: 40048