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


int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> a(n);
    rep(i,n) {
        if(s.at(i) == 'R') a.at(i) = 0;
        if(s.at(i) == 'G') a.at(i) = 1;
        if(s.at(i) == 'B') a.at(i) = 2;
    }
    vector<long long> count(3);
    rep(i,n) count.at(a.at(i))++;
    long long ans = 1;
    rep(i,3) ans *= count.at(i);
    rep(j,n)rep(i,j) {
        int k = 2*j - i;
        if(k < n) {
        if(a.at(i) == a.at(j)) continue;
        if(a.at(j) == a.at(k)) continue;
        if(a.at(k) == a.at(i)) continue;
        ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
require 'scanf'
sum = {}
sum["A"] = 0
sum["B"] = 0
sum["AB"] = 0
sum["O"] = 0
while line = gets
  n,t = line.split(',').map(&:to_s)
  sum[t.chomp] += 1
end
puts sum["A"]
puts sum["B"]
puts sum["AB"]
puts sum["O"]

Measured memory_bytes: 8932
import sys
#sys.exit()
#sorted( ,reverse=True)
#N = int(input())
S,T = map(int, input().split())
#A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]

#cnt = 0
#cnt += 1



#print(N)
#print(S,T)
#print(A)
#print('Yes')
#print('No')
print(S*T)

Measured memory_bytes: 9152
#include <stdio.h>

#define Max 500000
#define INFTY 1000000000

void  swap(int *x, int *y)
{
    int  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

void printA(int A[Max], int N) {
	int i;

	for (i = 0; i < N - 1; i++)
		printf("%d ", A[i]);
	printf("%d\n", A[N - 1]);
}

int merge(int A[Max], int left, int mid, int right) {
	int i, j, k;
	int count = 0;

	int n1 = mid - left;
	int n2 = right - mid;

	// L[0...n1], R[0...n2] ?????????
	int L [Max], R[Max];
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + i];

	L[n1] = INFTY;
	R[n2] = INFTY;
	i = 0;
	j = 0;

	for (k = left; k < right; k++) {
		count++;
		if (L[i] <= R[j])  A[k] = L[i++];
		else  A[k] = R[j++];
	}

	return count;
}

int mergeSort(int A[Max], int left, int right) {
	int count = 0;
	int mid;

	if (left + 1 < right) {
		mid = (left + right)/2;
		count += mergeSort(A, left, mid);
		count += mergeSort(A, mid, right);
		count += merge(A, left, mid, right);
	}

	return count;
}

int main( ) {
	int N, i, count;
	int A[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &A[i]);

	count = mergeSort(A, 0, N);

	printA(A, N);

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

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;

int main(){
    int n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    str[k-1]=str[k-1]-('A'-'a');
    cout<<str<<endl;

}

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

#define ll long long
#define ar array

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

	int x;
	cin >> x;
	int y=x/500, z=x%500;
	cout << 1000*y+z/5*5;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;

void solve()
{
    ll q;
    cin>>n>>m>>q;
    map<ll,ll>r,c;
    map<pair<ll,ll>,ll>f;
    vector<pair<ll,ll>>v(q);
    ll ans1=0,ans2=0;
    ll row,col;
    for(ll i=0;i<q;i++)cin>>v[i].first>>v[i].second,r[v[i].first]++,c[v[i].second]++,f[{v[i].first,v[i].second}]++,ans1=max(ans1,r[v[i].first]),ans2=max(ans2,c[v[i].second]);
    for(ll i=1;i<=n;i++)
    {
        if(r[i]==ans1){row=i;break;}
    }
    for(ll i=1;i<=m;i++)
    {
        if(c[i]==ans2){col=i;break;}
    }
    /*if(f[{row,col}]==1)
    {
        if(ans1>=ans2)r[row]--;
        else c[col]--;
    }*/
    if(ans1>ans2)
    {
        for(ll i=1;i<=m;i++)
        {
            if(f[{row,i}]==1)c[i]--;
        }
        ans2=0;
        for(ll i=0;i<q;i++)ans2=max(ans2,c[v[i].second]);
        cout<<ans1+ans2;
    }
    else
    {
        for(ll i=1;i<=n;i++)
        {
            if(f[{i,col}]==1)r[i]--;
        }
        ans1=0;
        for(ll i=0;i<q;i++)ans1=max(ans1,r[v[i].first]);
        cout<<ans1+ans2;
    }
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 82904
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int a,b,c;
	while (cin>>a>>b>>c) {
		int sum=a+b;
		vector<int> flag(10,0);
		flag[a-1]=flag[b-1]=flag[c-1]=1;
		int cnt=0;
		for (int i=0; i<20-sum; i++) {
			if (flag[i]==0) {
				cnt++;
			}
		}
		if (cnt/7.0>=0.5) {
			cout << "YES" << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 0
/*
	*#*#*#* Author GaryMr *#*#*#*
########################################################################
	是否可以简化问题：
	是否可以化具体为抽象
	字符串问题是否可以用数学模拟递归过程（取c[i]或不取来算结果）
	二分？左闭右开？
	long long？
	逆向思维？
	dp？
	贪心？
	匹配括号 左减右>=0
	多组数据清空？
	dp优化用g？
	线段树：左闭右开！
	线段树：find： if(l>=b||r<=a) return 0x3f3f3f3f; if(r<=b&&l>=a) return tree[k];
	线段树：满二叉树 
	循环跳出条件 
	代数设出每个值寻找关系？
	优先队列：priority_queue<类型> q;   
	priority_queue<类,vector<类>, less<类> > pq1; 　　　 // 使用递减	
	priority_queue<类，vector<类>, greater<类> > pq2; 　　// 使用递增
	判断括号，判断是否长度为偶数
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;a++)
#define rl(a,b,c) for(int a=b;a>=c;a--)
#define niv vector<int>
#define IT iterator
#define FIR first
#define SEC second
using namespace std;
const int MAX=0x3f3f3f3f;
const int MAXN=1e5+10;
int a[MAXN];int n,dp[MAXN][2];
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int gcd(int A,int B){
	if(B==0) return A;
	return gcd(B,A%B);
}
int main(){
	scanf("%d",&n);
	rb(i,1,n) scanf("%d",&a[i]);
	dp[3][1]=max(gcd(a[1],a[2]),max(gcd(a[1],a[3]),gcd(a[2],a[3])));
	dp[2][1]=max(a[1],a[2]);
	dp[1][0]=a[1];
	rb(i,2,n){
		dp[i][0]=gcd(dp[i-1][0],a[i]);
		if(i<=3) continue;
		dp[i][1]=max(dp[i-1][0],gcd(dp[i-1][1],a[i]));
	}
	printf("%d\n",dp[n][1]);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n, cnt = 0;
	scanf("%d", &n);
	string s = to_string(n);
	if(s.length()%2==0){
		for (int i = 0; i < s.length(); i+=2){
			cnt += 9*pow(10,i);
		}
	}else{
		cnt = n;
		for (int i = 1; i < s.length(); i+=2){
			cnt -= 9*pow(10,i);
		}
	}
	printf("%d\n", cnt);
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char> > pic(H + 2,vector<char>(W + 2,'#'));

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> pic.at(i + 1).at(j + 1);
        }
    }

    for(int i = 0; i < H + 2; i++) {
        for(int j = 0; j < W + 2; j++) {
            cout << pic.at(i).at(j);
        }
        cout << endl;
    }


    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back

using namespace std;

vector<vector<int>> G;
vector<int> dist;

void print(int a, int b){ cout << a+1 << " " << b+1 << endl; }
void dfs(int v, int p){
    dist[v]++;
    for(auto nv : G[v]){
        if(nv == p) continue;
        if(dist[nv] >= 0){
            if(v < nv) print(v,nv), dist[v]++;
        }
        else{
            dfs(nv,v);
        }
    }
    if(p >= 0){
        if(dist[v]%2) print(v,p), dist[v]++;
        else print(p,v), dist[p]++;
    }
}

int main(){
    int n, m; cin >> n >> m;
    if(m%2){ cout << -1 << endl; return 0; }
    G.assign(n,vector<int>());
    dist.assign(n,-1);
    rep(i,m){
        int a, b; cin >> a >> b; a--; b--;
        G[a].pb(b); G[b].pb(a);
    }
    dfs(0,-1);
    return 0;
}

Measured memory_bytes: 15328
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
 
int main() {
  long n,a,b,ans=10000000000000000;
  cin >> n;
  long nn=n;
  ans=2*n-1;
  map<long,long> mp;
  for(long i=2;i*i<=n;i++) {
    while(n%i==0) {
      n/=i;
      mp[i]++;
    }
  }
  if(n!=1) mp[n]++;
  mp[2]++;
  vector<long> aaa;
  for(auto itr=mp.begin();itr!=mp.end();itr++) {
    aaa.push_back(1);
    for(long i=0;i<(*itr).second;i++) {
      aaa.back()*=(*itr).first;
    }
  }
  for(long bit=0;bit<(1<<aaa.size());bit++) {
    a=1,b=1;
    for(long i=0;i<aaa.size();i++) {
      if(bit&(1<<i)) {
        a*=aaa[i];
      } else {
        b*=aaa[i];
      }
    }
    if(min(a,b)==1) continue;
    vector<long> x,y;
    x.push_back(a);
    x.push_back(b);
    while(x.back()!=1) {
      y.push_back(x[x.size()-2]/x.back());
      x.push_back(x[x.size()-2]%x.back());
    }
    long aa=1,bb=y.back();
    for(long i=y.size()-2;i>=0;i--) {
      if(i%2==1) {
        aa+=bb*y[i];
      } else {
        bb+=aa*y[i];
      }
    }
    if(a*aa-b*bb==1) ans=min(ans,b*bb);
    if(a*aa-b*bb==-1) ans=min(ans,a*aa);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
xx = [0]*n
yy = [0]*n
hh = [0]*n
for i in range(n):
    x,y,h = map(int,input().split())
    xx[i] = x
    yy[i] = y
    hh[i] = h

for i in range(n):
    if hh[i] == 0:
        continue
    else:
        x = xx[i]
        y = yy[i]
        h = hh[i]
        break

for cx in range(101):
    for cy in range(101):
        H = abs(x-cx) + abs(y-cy) + h
        for i in range(n):
            if max(H-abs(xx[i]-cx)-abs(yy[i]-cy),0) != hh[i]:
                break
        else:
            print(cx,cy,H)
            exit()

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> X(N), SX;
  for (int i = 0; i < N; i++) {
    scanf("%lld", &X[i]);
  }
  SX = X;

  sort(all(SX));
  int mid = N / 2;

  rep(i, 0, N) {
    if (X[i] < SX[mid]) {
      put(SX[mid]);
      continue;
    }

    put(SX[mid - 1]);
  }
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <cmath>
#define EPS (1.0e-12)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;


int S, A, C;
int M;
int N;
int R[256], I[256], O[256];

double m_log[300];

void calcR() {
  for(int i = 0; i < N; ++i) {
    if(i == 0) R[i] = (A*S+C)%M;
    else       R[i] = (A*R[i-1]+C)%M;
  }
}

void calcO() {
  calcR();
  for(int i = 0; i < N; ++i) {
    O[i] = (I[i]+R[i]) % M;
  }
}

double H() {
  double ans = 0;
  int buf[256];
  fill(buf, buf+256, 0);

  calcO();

  for(int i = 0; i < N; ++i) {
    ++buf[O[i]];
  }

  for(int i = 0; i < 256; ++i) {
    if(buf[i] == 0) continue;
    ans += -buf[i] * (m_log[buf[i]] - m_log[N]);
  }
  return ans;
}

void solve() {
  int aS, aA, aC;
  double minH = 99999999;
  for(S = 0; S <= 15; ++S) {
    for(A = 0; A <= 15; ++A) {
      for(C = 0; C <= 15; ++C) {
	double tmp = H();
	if(S == 8 || A == 7 || C == 14) {
	  // for(int i = 0; i < N; ++i) cout << O[i] << " ";
	  //cout << endl;
	}
	//if(tmp == 0) printf("%d %d %d %.20f\n", S, A, C, tmp);
	if(equals(tmp, minH)) {
	  if(aS > S || aS == S && aA > A || aS == S && aA == A && aC > C) {
	    aS = S;
	    aA = A;
	    aC = C;
	  }
	} else if(tmp < minH) {
	  minH = tmp;
	  aS = S;
	  aA = A;
	  aC = C;
	}
      }
    }
  }
  cout << aS << " " << aA << " " << aC << endl;
}

main() {
  M = 256;
  for(int i = 1; i <= 300; ++i) m_log[i] = log(i);
  while((cin >> N) && N) {
    for(int i = 0; i < N; ++i) cin >> I[i];
    solve();
  }
}

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

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

  if (S == "SUN") {
    cout << "7" << endl;
  }
  else if (S == "MON") {
    cout << "6" << endl;
  }
  else if (S == "TUE") {
    cout << "5" << endl;
  }
  else if (S == "WED") {
    cout << "4" << endl;
  }
  else if (S == "THU") {
    cout << "3" << endl;
  }
  else if (S == "FRI") {
    cout << "2" << endl;
  }
  else {
    cout << "1" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def prime(t):
    i=2
    while i**2<=t:
        if t%i==0: return 0
        i+=1
    return 1

mod=10**9+7

p=[]
for i in range(2,1008):
    if prime(i):
        p.append(i)

d={i:0 for i in p}
n=int(input())

ans=tmp=1
for i in range(1,n+1):
    tmp*=i
    for j in p:
        while tmp%j==0:
            d[j]+=1
            tmp//=j
        if tmp<j: break

for i in d:
    ans*=d[i]+1
    ans%=mod
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a>8||b>8)printf(":(\n");
	else printf("Yay!\n");
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

struct point {
    double x, y;
    char d;
    point(int _x, int _y, char _d) {
        x = _x; y = _y; d = _d;
    }
};

vector<point> points;

double score(double time) {
    double mxx = -1e9, mnx = 1e9, mxy = -1e9, mny = 1e9;

    for(point p : points) {
        if(p.d == 'U') {
            mxx = max(mxx, p.x);
            mnx = min(mnx, p.x);
            mxy = max(mxy, p.y+time);
            mny = min(mny, p.y+time);
        } else if(p.d == 'D') {
            mxx = max(mxx, p.x);
            mnx = min(mnx, p.x);
            mxy = max(mxy, p.y-time);
            mny = min(mny, p.y-time);
        } else if(p.d == 'R') {
            mxx = max(mxx, p.x+time);
            mnx = min(mnx, p.x+time);
            mxy = max(mxy, p.y);
            mny = min(mny, p.y);
        } else {
            mxx = max(mxx, p.x-time);
            mnx = min(mnx, p.x-time);
            mxy = max(mxy, p.y);
            mny = min(mny, p.y);
        }
    }

    return (mxx-mnx)*(mxy-mny);
}

int32_t main() {

    int n; cin >> n;
    
    for(int i = 0; i < n; ++i) {
        double x, y; cin >> x >> y;
        char c; cin >> c;

        points.emplace_back(x, y, c);
    }

    double l = 0, r = 1e9;

    for(int i = 0; i < 500; ++i) {
        double lmid = (l+l+r)/3.0, rmid = (l+r+r)/3.0;

        if(score(lmid) < score(rmid)) {
            r = rmid;
        } else {
            l = lmid;
        }
    }

    cout << setprecision(10) << score(l) << endl;
    
    return 0;
}


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

int main()
{
  string Marbles;
  cin >> Marbles;
  int res = 0;
  int i = 0;
  while (i<4)
  {
    if (Marbles[i] == '1') res ++;
    i++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef vector<long long> Array;
typedef vector<Array> Matrix;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, m, l; cin >> n >> m >> l;
	Matrix a(n, Array(m)), b(m, Array(l)), c(n, Array(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];

	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];
			}
			cout << c[i][j];
			if (j != l - 1) cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3180
import collections

n = int(input())
s = [input() for i in range(n)]

c = collections.Counter(s)
count = c.most_common()[0][1]

s2 = [i[0] for i in c.items() if i[1] == count]
s2 = sorted(s2)

for i in range(len(s2)):
    print(s2[i])

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


int main(void) {
	int N, M;
	cin >> N >> M;
	bool *passed = new bool[N+1];
	for (int i = 1; i <= N; i++) passed[i] = false;
	vector <int> *path = new vector <int>[N+1];

	for (int i= 1; i <= M; i++) {
		int A, B;
		cin >> A >> B;
		path[A].push_back(B);
		path[B].push_back(A);
	}

	int top = 1;
	int end = path[top].at(0);

	vector <int> ans;
	ans.push_back(top);
	ans.push_back(end);
	passed[top] = passed[end] = true;

	for (;;) {
		bool isNext = false;
		for (int i = 0; i < path[top].size(); i++) {
			int next = path[top].at(i);
			if (passed[next]) continue;
			else {
				passed[next] = true;
				ans.insert(ans.begin(), next);
				top = next;
				isNext = true;
				break;
			}
		}
		if (!isNext) break;
	}

	for (;;) {
		bool isNext = false;
		for (int i = 0; i < path[end].size(); i++) {
			int next = path[end].at(i);
			if (passed[next]) continue;
			else {
				passed[next] = true;
				ans.push_back(next);
				end = next;
				isNext = true;
				break;
			}
		}
		if (!isNext) break;
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans.at(i);

		if (i < ans.size()-1) cout << " ";
		else                  cout << endl;
	}

	delete [] path;
	delete [] passed;
	return 0;
}


Measured memory_bytes: 6908
import Control.Applicative
import qualified Data.IntMap.Strict as I
import Data.IntMap.Strict (IntMap)
import System.IO (isEOF)

readTrades :: IntMap Int -> IO (IntMap Int)
readTrades m = do
    c <- isEOF
    if c then return m
         else do
            l <- getLine
            case l of
                "" -> return m
                ss -> readTrades (I.insertWith (+) custNum 1 m)
                    where
                        custNum = read . takeWhile (/= ',') $ ss

main = do
    lastMonth <- readTrades I.empty
    thisMonth <- readTrades I.empty
    mapM_ (\(i,t) -> putStrLn . unwords . map show $ [i,t]) .  I.toAscList $
        I.intersectionWith (+) thisMonth lastMonth

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

class Program
{
	static void Main(string[] args)
	{
		var C1 = Console.ReadLine();
		var C2 = Console.ReadLine();
		for (int i = 0; i < 3; i++)
		{
			if (C1[i] != C2[2 - i])
			{
				Console.WriteLine("NO");
				return;
			}
		}
		Console.WriteLine("YES");
	}
}

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


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;

// #define  part ..
#define listi vector<int >
#define listll vector<long long >
#define pii pair<int ,int >
#define pll pair<long long ,long long >
#define heap priority_queue<long long >
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define mod 998244353
#define maxx 200006
#define ll long long
#define quick   ios_base::sync_with_stdio(NULL),cin.tie(0);
#define rep(i,a,b) for(int i=a;i<b;i++)
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}
 
// #define test int t;cin>>t;while(t--)
// end of #define 

// define globals ...


long long ni() {
  int c = getchar();
  while (c < '0' || c > '9') c = getchar();
  long long ret = 0.0;
  while (c >= '0' && c <= '9') {
    ret = ret * 10 + c - '0';
    c = getchar();
  }
  return ret;
}





int Main ()
{

 
 int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 int a;
 cin>>a;
 cout<<arr[a-1];

  return 0;


}























// main function..
int main ()
{
  quick;

#ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif

  Main ();


}


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

int main() {

  int K,N;
  cin >> K >>N;
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  
}
 int b=a[N-1]-a[0];
  for (int i = 1; i < N; i++) {
    b=min(b,K-a[i]+a[i-1]);
  
}
  cout<<b<<endl;
}  
 


Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main() {

    int N;
    std::string text;
    std::cin >> N >> text;

    int R = 0;
    int B = 0;

    for( int i = 0; i < N; ++i ) {
        if( text[i] == 'R' ) { ++R; }
        if( text[i] == 'B' ) { ++B; }
    }

    std::cout << (R > B ? "Yes" : "No") << std::endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		List<String> charLineList = new ArrayList<String>();

		while(stdIn.hasNext()){
			charLineList.add(stdIn.next());
		}
		for(String i:charLineList){
			for(int j = 0;j < i.length();j++){
				if(i.charAt(j) == '@'){
					j++;
					for(int k = 0;k < Integer.parseInt(""+i.charAt(j)); k++){
						System.out.print(i.charAt(j + 1));
					}
					j++;
				}else{
					System.out.print(i.charAt(j));
				}
			}
			System.out.println();
		}
	}
}

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

class MainClass
{
    public static int Main()
    {
        List<int> results=new List<int>();

        while(true)
        {
            string[] str=Console.ReadLine().Split(' ');

            int a=Convert.ToInt32(str[0]);
            int b=Convert.ToInt32(str[2]);

            switch(str[1])
            {
                case "+":
                    results.Add(a+b);
                    break;
                case "-":
                    results.Add(a-b);
                    break;
                case "*":
                    results.Add(a*b);
                    break;
                case "/":
                    results.Add(a/b);
                    break;
                default:
                    break;
            }

            if(str[1]=="?") break;
        }

        foreach(int r in results)
        {
            Console.WriteLine(r);
        }

        return 0;
    }
}

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

long long N; pair<long long, long long> D[1 << 18];
long long M, C[1 << 18];

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> D[i].second >> D[i].first;
	for (int i = 0; i < M; i++) cin >> C[i];
	sort(D, D + N);
	sort(C, C + M);

	int ret = M - 1;
	for (int i = N - 1; i >= 0; i--) {
		if (C[ret] >= D[i].second) ret--;
		if (ret < 0) break;
	}
	cout << (M - 1) - ret << endl;
	return 0;
}


Measured memory_bytes: 5520
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,d=mp()
l=[]
for i in range(n):
    l.append(lmp())
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        a=0
        for k in range(d):
            a+=(l[i][k]-l[j][k])**2
        if (a ** .5).is_integer():
            ans+=1
print(ans)

Measured memory_bytes: 10700
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;

//-----------------------------------------------------------------------------
struct node_t{
  i8t color;
  vector<i8t> adj;

  i8t parent_ikeru;
};

void tree_make_directed_by_root(std::vector<node_t>& vtx, i8t root){
  std::vector<char> mark(vtx.size(), 0);
  std::vector<i8t> stk;
  std::vector<i8t> ind;
  i8t p,i;
  mark[p=root]=1;
  i=0;
  while(1){
    node_t& node=vtx[p];
    if (i<node.adj.size()) {
      i8t& p2=node.adj[i];
      if(mark[p2]){
        p2=-1;
        i++;
      }else{
        stk.push_back(p);
        ind.push_back(i+1);
        mark[p=p2]=1;
        i=0;
      }
    }else{
      // remove parents
      node.adj.erase(
        std::remove(node.adj.begin(),node.adj.end(),-1),
        node.adj.end());

      if (stk.size()){
        p=stk.back();
        i=ind.back();
        stk.pop_back();
        ind.pop_back();
      }else{
        break;
      }
    }
  }
}

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

int main() {
  R(N);
  vector<node_t> vtx;
  F(I,N){
    R(c);c--;
    vtx.push_back(node_t{c});
  }
  F(I,N-1){
    R(a)R(b);
    a--;b--;
    vtx[a].adj.push_back(b);
    vtx[b].adj.push_back(a);
  }
  tree_make_directed_by_root(vtx,0);

  i8t nvisit = 0;
  std::vector<i8t> ikenai(N, 0);
  std::vector<i8t> ans(N, 0);
  std::vector<i8t> last_added_nvisit(N, 0); // color -> last nvisit
  auto _update_ans=[&](i8t color){
    ans[color]+=(nvisit-last_added_nvisit[color])*ikenai[color];
    last_added_nvisit[color]=nvisit;
  };
  auto _visit=[&](i8t p){
    //std::cout<<"visit "<<p<<std::endl;
    vtx[p].parent_ikeru = nvisit-ikenai[vtx[p].color];
    _update_ans(vtx[p].color);
    nvisit++;
    ikenai[vtx[p].color]=nvisit;
  };
  auto _leave=[&](i8t p, i8t parent){
    if (parent<0)return;
    _update_ans(vtx[p].color);
    _update_ans(vtx[parent].color);
    ikenai[vtx[p].color] = nvisit-vtx[p].parent_ikeru;
    ikenai[vtx[parent].color]=nvisit;
  };

  std::vector<i8t> stk,ind;
  i8t p,i;
  p=0;
  i=0;
  _visit(p);
  while(1){
    auto& node=vtx[p];
    if (i<node.adj.size()){
      stk.push_back(p);
      ind.push_back(i+1);
      p=node.adj[i];i=0;
      _visit(p);
    }else{
      if(stk.size()){
        _leave(p, stk.back());
        p=stk.back();
        i=ind.back();
        stk.pop_back();
        ind.pop_back();
      }else{
        _leave(p, -1);
        break;
      }
    }
  }

  F(I,N){
    _update_ans(I);
    P(ans[I]);
  }

  return 0;
}


Measured memory_bytes: 28008
from collections import Counter

N = int(input())
S = list(input())

ans = 0
for i in range(1,N):
    temp = 0
    left = S[:i]
    right = S[i:]
    left_words = Counter(left)
    right_words = Counter(right)
    for key1 in left_words.keys():
        for key2 in right_words.keys():
            if key1 == key2:
                temp += 1
    if temp > ans:
        ans = temp
print(ans)

Measured memory_bytes: 3316
# import numpy as np
# from itertools import permutations
# n=int(input())

# a=np.arange(n)+1
# maxv=0
# for i in permutations(a, n):
#     print(a, "%", np.array(i), ":", a%np.array(i), sum(a%np.array(i)))
#     maxv=max(sum(a%np.array(i)), maxv)
# print(maxv)

n=int(input())
print(n*(n-1)//2)

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

int main() {
  int N, M;
  cin >> N >> M;
  string A[50], B[50];
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < M; i++) cin >> B[i];

  int same;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      same = 0;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A[i + k][j + l] == B[k][l]) same++;
        }
      }
      if (same == M * M) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
def kaibun?(s)
  s == s.reverse
end

def skaibun?(s)
  return false unless kaibun?(s)
  p = (s.length - 1) / 2
  return false unless kaibun?(s.slice(0..p - 1))
  q = (s.length + 3) / 2
  return false unless kaibun?(s.slice((q - 1)..(s.length - 1)))
  return true
end

S = gets.chomp

puts skaibun?(S) ? "Yes" : "No"


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

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll N, K; cin >> N >> K;
  vector<pair<ll, ll> > pr;
  ll sum = 0;
  for(int i=0;i<N;i++){
    ll a, b; cin >> a >> b;
    pr.push_back(make_pair(a, b));
  }
  sort(pr.begin(), pr.end());
  for(int i=0;i<N;i++){
    sum += pr[i].second;
    if(sum >= K){
      cout << pr[i].first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 2420
#include <iostream>
int main() {
	int n;
	std::cin >> n;
	bool can_buy = false;
	for (auto i = 0; i * 7 <= n; ++i) {
		can_buy |= (n - i * 7) % 4 == 0;
	}
	if (can_buy) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a;
	while(scanf("%d",&a)!=EOF){
		int time=a,t,i,m=0;
		
		for(i=0;i<3;i++){
			scanf("%d",&t);
			time+=t;
		}
		while(time>59){
			m++;
			time-=60;
		}
		printf("%d\n%d\n",m,time);
	}
	
	return 0;
}

Measured memory_bytes: 0
N = int(input())
for h in range(1, 3501):
    for n in range(h, 3501):
        if (4*h*n-N*n-N*h)>0 and (N*h*n)%(4*h*n-N*n-N*h)==0:
            print(h, n, (N*h*n)//(4*h*n-N*n-N*h))
            exit()

Measured memory_bytes: 40556
#include <stdio.h>

int main() {
    char S[3];
    int i;

    for(i = 0; i < 3; i++) {
        scanf("%c", &S[i]);
    }

    if(S[1] == 'B') {
        printf("ARC");
    } else {
        printf("ABC");
    }

    return 0;
}

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

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

  int n;
  cin >> n;
  vector<int> arr(n);

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

  sort(begin(arr), end(arr), greater<int>());
  int a = 0, b = 0;

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

  cout << a - b << "\n";

}


Measured memory_bytes: 3656
MOD=10**9+7
cnt=0; sum=0; prev=nil; ha=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n = gi
l = desc gsmi

max = l.shift
puts_yesno(max<l.inject(:+))

Measured memory_bytes: 1788
while True:
    a, b = map(int, input().split())
    if(a == 0 and b == 0):
        break
    for i in range(a):
        for j in range(b):
            if(i % 2 == 0):
                if(j % 2 == 0):
                    print("#", end = "")
                else:
                    print(".", end = "")
            elif(i % 2 == 1):
                if(j % 2 == 1):
                    print("#", end = "")
                else:
                    print(".", end = "")
        print()
    print()


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

int main() {
	int n;cin>>n;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	int ans=0;
	for(int i=1;i<n-1;i++){
		if(p[i]>p[i-1]){
			if(p[i]<p[i+1]){
				ans++;
			}
		}
		if(p[i]<p[i-1]){
			if(p[i]>p[i+1]){
				ans++;
			}
		}
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN() {cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	int n ; cin >> n;
	For(i,1,10){
		if(n%i==0&& n / i < 10){
			coY();
			return 0;
		}
	}
	coN();

}


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

int main(){
    int n;
    cin >> n;
    rep(i,10) rep(j,10) if(i*j == n){
        cout << "Yes" << endl;
        return 0;
    } 
    cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};
    static int[] x8 = {-1, -1, 0, 1, 1, 1, 0, -1};
    static int[] y8 = {0, -1, -1, -1, 0, 1, 1, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        int score = 0;
        int h = Math.max(a,Math.max(b,c));
        score = h*10 + a + b + c - h;
        System.out.println(score);
    }

    static public void printArray2D(char[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%c\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }

    static public void printArray2D(int[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%d\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

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

int main() {
    string S, T; cin >> S >> T;
    int n = S.size();
    int cnt = 0;
    rep(i, n) {
        if(S[i] != T[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3852
package main

import (
  "fmt"
)

func main() {
  var sa, sb, sc string
  fmt.Scanf("%s", &sa)
  fmt.Scanf("%s", &sb)
  fmt.Scanf("%s", &sc)
  
  ans := ""
  turn := "a"
  
end:
  for {
    switch turn {
      case "a" :
        if len(sa) == 0{
          ans = "A"
          break end
        }
      	turn = sa[0:1]
      	sa = sa[1:len(sa)]
      case "b" :
        if len(sb) == 0{
          ans = "B"
          break end
        }
      	turn = sb[0:1]
      	sb = sb[1:len(sb)]      
      case "c" :
        if len(sc) == 0{
          ans = "C"
          break end
        }
      	turn = sc[0:1]
      	sc = sc[1:len(sc)]
    }
  }
  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1836
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int a[100233];
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<n;i++)
	{
		if (a[i]>a[i+1])
		{
			printf("No");
			return 0;
		}
		if (a[i+1]-a[i]>=1) a[i+1]--;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	string  s = "";
	while(n){
		--n;
		int x = n%26;
		s += x+ 'a';	
		n/=26;
	}
	reverse(s.begin(), s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

int main(){
	int k;
	cin >> k;
	if(k % 2 == 0)cout << k * k / 4 << endl;
	else cout << (k + 1) / 2 * (k - 1) / 2 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    static Scanner sc = new Scanner();

    public static void main(final String[] args) throws IOException {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[sc.nextInt() - 1] = i + 1;
        }
        for (int i = 0; i < n; i++) {
            System.out.print(a[i] + " ");
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 43208
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{

    int K;
    cin >> K;

    ll sum = 0;

    rep2(i,1,K+1){
        rep2(j,1,K+1){
            rep2(k,1,K+1){
                sum += gcd(gcd(i,j),k);
            }
        }
    }



    cout << sum << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;

const int MAXN = 1e5;
int sz[MAXN], par[MAXN];
 
void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        sz[i] = 1;
    }
}
 
int get_par(int v) {
    if (v != par[v]) {
        par[v] = get_par(par[v]);
    }
    return par[v];
}
 
void unite(int v, int u) {
    v = get_par(v);
    u = get_par(u);
    if (sz[v] > sz[u]) {
        swap(v, u);
    }
    par[v] = u;
    sz[u] += sz[v];
}
 

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    init(n);
    vector <pair <int, int> > e;
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--; u--;
        e.push_back({v, u});
    }
    int ans = (n * (n - 1)) / 2;
    reverse(e.begin(), e.end());
    vector <int> answer;
    for (auto ed : e) {
        answer.push_back(ans);
        if (get_par(ed.x) != get_par(ed.y)) {
            ans -= sz[get_par(ed.x)] * sz[get_par(ed.y)];
            unite(ed.x, ed.y);
        }
    }
    reverse(answer.begin(), answer.end());
    for (auto a : answer) {
        cout << a << "\n";
    }

    return 0;
}

Measured memory_bytes: 6256
//2018-1-28
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)
 
#define N (100000 + 5)
const int P = 1e9 + 7;
 
inline int Mod(int a){return a >= P? a - P: a;}
 
struct node{
	int v, d;	
};
 
int n, m, s, t, fs[N], ft[N];
LL ds[N], dt[N];
vector<node> G[N];
 
bool inq[N];
 
void Spfa(int st, LL *dis){
	For(i, 1, n) dis[i] = 1ll << 60, inq[i] = false;
	queue<int> q;
	
	dis[st] = 0;
	q.push(st); inq[st] = true;
 
	while(!q.empty()){
		int now = q.front(); q.pop();
		inq[now] = false;
 
		For(i, 0, G[now].size() - 1){
			int v = G[now][i].v, md = G[now][i].d;
			
			if(dis[v] > dis[now] + md){
				dis[v] = dis[now] + md;
				if(!inq[v]){
					q.push(v); inq[v] = true;
				}
			}
		}
	}
}
 
vector<node> g[N];
int in[N];
 
void Work(int st, LL *dis, int *f){
	For(i, 1, n) g[i].clear(), in[i] = 0;
	For(u, 1, n) For(i, 0, G[u].size() - 1){
		int v = G[u][i].v, d = G[u][i].d;
		if(dis[u] + d == dis[v]){
			g[u].pb(G[u][i]); ++in[v];
		}
	}
 
	queue<int> q;
 
	f[st] = 1;
	For(i, 1, n) if(!in[i]) q.push(i);
 
	while(!q.empty()){
		int now = q.front(); q.pop();
 
		For(i, 0, g[now].size() - 1){
			int v = g[now][i].v;
			f[v] = Mod(f[v] + f[now]); --in[v];
			if(!in[v]) q.push(v);
		}
	}
}
 
int Solve(){
	int ret = 0;
	LL D = ds[t];
 
	For(i, 1, n) if(2 * ds[i] <= D){
		if(2 * ds[i] == D && 2 * dt[i] == D){
			ret = Mod(ret + 1ll * fs[i] * ft[i] % P * fs[i] % P * ft[i] % P);
			continue;
		}
 
		For(j, 0, G[i].size() - 1){
			int v = G[i][j].v, d = G[i][j].d;
			if(2 * dt[v] >= D) continue;
			if(ds[i] + d != ds[v]) continue;
			if(dt[v] + d != dt[i]) continue;
			if(ds[i] + d + dt[v] != D) continue;
			
			ret = Mod(ret + 1ll * fs[i] * ft[v] % P * fs[i] % P * ft[v] % P);
		}
	}
 
	return ret;
}
 
int main(){
	int u, v, w;
	
	scanf("%d%d%d%d", &n, &m, &s, &t);
	For(i, 1, m){
		scanf("%d%d%d", &u, &v, &w);
		G[u].pb((node){v, w}); G[v].pb((node){u, w});
	}
 
	Spfa(s, ds); Work(s, ds, fs);
	Spfa(t, dt); Work(t, dt, ft);

//	printf("Min = %lld f = %d\n", ds[t], fs[t]);
//	For(i, 1, n) printf("fs[%d] = %d ft[%d] = %d\n", i, fs[i], i, ft[i]);
	int ans = 1ll * fs[t] * fs[t] % P - Solve();
	
	if(ans < 0) ans += P;
	printf("%d\n", ans);
 
	return 0;
}

Measured memory_bytes: 17968
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

ll h,w,n;
ll sr,sc;
string s,t;

vector<ll>dpr,dpl,dpu,dpd;

void input(){
    cin >> h >> w >> n;
    cin >> sr >> sc;
    cin >> s >> t;
}

void initial(){
    dpr.resize(n+1,INF);
    dpl.resize(n+1,-1);
    dpu.resize(n+1,-1);
    dpd.resize(n+1,INF);
}

void ex(){
    cout << "NO" << endl;
    exit(0);
}

int main(){
    input();
    initial();
    for(int i=n-1;i>=0;i--){
        //right
        dpr[i]=dpr[i+1];
        if(t[i]=='L')dpr[i]++;
        if(s[i]=='R')chmin(dpr[i],min(dpr[i]-1,w));
        //left
        dpl[i]=dpl[i+1];
        if(t[i]=='R')dpl[i]--;
        if(s[i]=='L')chmax(dpl[i],max(1LL,dpl[i]+1));
        //up
        dpu[i]=dpu[i+1];
        if(t[i]=='D')dpu[i]--;
        if(s[i]=='U')chmax(dpu[i],max(1LL,dpu[i]+1));
        //down
        dpd[i]=dpd[i+1];
        if(t[i]=='U')dpd[i]++;
        if(s[i]=='D')chmin(dpd[i],min(dpd[i]-1,h));
        if(dpr[i]==1||dpl[i]==w||dpu[i]==h||dpd[i]==1)ex();
    }
    bool ans = false;
    if(dpr[0]<=sc||dpl[0]>=sc)ans=true;
    if(dpu[0]>=sr||dpd[0]<=sr)ans=true;
    if(ans)cout<<"NO" << endl;
    else cout << "YES" << endl;
    return 0;
}



Measured memory_bytes: 9816
#include<iostream>
using namespace std;
int main()
{
    int N,p;
    cin>>N;
    int flag=0;

    for(int i=1;i<N;i++)
    {
        cin>>p;
        if(p!=i)
            flag++;
    }
    if(flag<=2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}



Measured memory_bytes: 3572