akhauriyash/Code-Regression huggingface dataset:
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc173_b.cpp"

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

  int n;
  cin >> n;
  map<string, int> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  string po[4] = {"AC", "WA", "TLE", "RE"};
  REP(i, 4) { cout << po[i] MM "x" MM mp[po[i]] << endl; }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
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++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
    if(x>y)return x;
    else return y;
}
ll min(ll x,ll y){
    if(x<y)return x;
    else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
    string s;cin >> s;
    /*
    アンバランスな文字列の条件
    aがn個、他の文字がn-1個以下
    そうすると,鳩ノ巣原理から必ずa?a or aaが存在する?
    存在しないならばa??a??a??...がaをもっともたくさんもつ文字列だが過半数になりえない
    よってa?a or aaが存在しないなら-1 -1
    else a?a or aaの箇所を出力して終わり
    */
    rep(i,s.size()-1){
        if(s[i]==s[i+1]){cout << i+1 << ' ' << i+2 << endl;return 0;}
        if(i<(int)s.size()-1 && s[i]==s[i+2]){cout << i+1 << ' ' << i+3 << endl;return 0;}
    }
    cout << -1 << ' ' << -1 << endl;
    return 0;
}

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

const int mod = 1000000007;
struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

signed main() {
  int n;
  cin >> n;

  mint fact = 1;
  for (ll i = 1; i <= n - 1; i++) fact *= i;

  vector<ll> a(n);
  vector<mint> cnt(n);
  rep(i,n) cin >> a[i];

  for (int i = 1; i < n; i++) {
    cnt[i] += fact/i + cnt[i - 1];
  }

  mint ans = 0;
  for (int i = 1; i < n; i++) {
    mint dist = a[i] - a[i - 1];
    ans += dist * cnt[i];
  }
  cout << ans.x << '\n';
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    while (true) {
        int n; cin >> n;
        if (!n) break;

        int ans = 0;
        int state = -1;
        rep(i, n) {
            string x; cin >> x;
            if (x[1]=='u') {
                if (state == 1) ans++;
                state = 1;
            } else {
                if (state == 0) ans++;
                state = 0;
            }
        }
        cout << ans << endl;
    }
}


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

#define FOR(i, a, b) for (int (i) = (a); (i) < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define eb emplace_back
#define _ << " " <<
typedef long long ll;
typedef std::pair<int, int> ii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;

const int MaxN = 200100;
const int Mod = 1e9 + 7;

int N;
ll x;
ll a[MaxN], p[MaxN];

void solve() {
  sort(a, a + N);

  p[0] = 0;
  REP(i, N)
    p[i+1] = p[i] + a[i];

  int minx = -1, maxx = -1;
  REP(i, N+1) {
    if (x >= p[i]) minx = i;
    if (x <= p[i]) maxx = i;
  }

  if (maxx == -1) {
    cout << N - 1;
    return;
  }
  
  if (minx == maxx) {
    cout << minx;
    return;
  }

  if (minx == -1) {
    cout << 0;
    return;
  }

  cout << minx;
  return;
}

void load() {
  cin>>N>>x;
  REP(i, N) cin>>a[i];
}

int main() {
  ios_base::sync_with_stdio(false);
  load();	
  solve();
  return 0;
}




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

int main(){
    int a, b;
    cin >> a >> b;
    if((a+12)%14 > (b+12)%14)cout << "Alice";
    else if((a+12)%14 < (b+12)%14)cout << "Bob";
    else cout << "Draw";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  [n, o] <- map read . words <$> getLine
  let
    ans = [[x, y, z] | x <- [0..n], y <- [0..n-x], z <- [n-x-y], 10000 * x + 5000 * y + 1000 * z == o]
  if null ans
    then putStrLn "-1 -1 -1"
    else putStrLn $ unwords $ map show $ head ans

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

char ID[256][11];

int check(char *T,int N){
    int i;
    for(i=0;i<N;i++){
        if(strcmp(T, ID[i])==0) return 1;
    }
    return 0;
}

int main(void){
    int N,M,i;
    int isLocked=1;
    char T[11];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%s",ID[i]);
    }
    scanf("%d",&M);
    for(i=0;i<M;i++){
        scanf("%s", T);
        if(check(T,N)){
            if(isLocked){
                printf("Opened by %s\n",T);
                isLocked=0;
            }else{
                printf("Closed by %s\n",T);
                isLocked=1;
            }
        }else{
            printf("Unknown %s\n",T);
        }
    } 
    return 0;
}

Measured memory_bytes: 604
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n);
	int e = 0;
	rep(i, 0, n) { read(v[i]); e ^= v[i]; }
	rep(i, 0, n) cout << (v[i]^e) << " ";
	cout << endl;
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    int cnt = 0;
    for(int i = a; i <= b; i++){
        if(c%i==0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3108
#include <stdio.h>

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

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main()
{
    int n,c=0,m=0;
    cin>>n;
    string a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];

        for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
        if(a[i]==a[j]){
          m=1 ;
          break;}}}



    for(int i=0;i<n;i++){
        int l=a[i].length();
        if(a[i].at(l-1)==a[i+1].at(0))
            c++;
    }
     if(c==n-1&&m!=1)
     cout<<"Yes";
     else
                  cout<<"No";


    return 0;
}


Measured memory_bytes: 256
//       THIS IS MY NINJA WAY
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ctime>
#include<vector>
#include<algorithm>

#define str string
#define dbl double
#define ll long long int
#define ull unsigned long long int
#define vl vector<ll> 
#define vs vector<str>
#define pll pair<ll,ll> 
#define vll vector<pll>
#define sl set<ll>
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define BS binary_search
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
#define fr(i,a,b) for(long long i=a; i<b; i++)
#define nfr(i,a,b) for(long long i=a; i<=b; i++)
#define psl pair<str,ll>
#define pls pair<ll,str>
#define pss pair<str,str>
#define lcm(a,b) (a*b)/__gcd(a,b)
#define ALL(a) a.begin(),a.end()
#define stl stack<ll>
#define coml complex<ll>
#define INF 0x3f3f3f3f3f3f3f3f
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define read(v,n) fr(i,0,n)cin>>v[i];
#define print(x) fr(i,0,x.size())cout<<x[i]<<" ";cout<<"\n";
const ll MOD = 1e9+7;
const ll N = 2e5 + 5;
using namespace std;
using namespace __gnu_pbds;
void solve(){
	ll n;
	cin>>n;
	vl v(n);
	read(v,n);
	vl dp(n,INF);
	dp[0]=0,dp[1]=abs(v[1]-v[0]);
	fr(i,2,n){
		dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
	}
	cout<<dp[n-1];
}
int main()
{
	fast
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r" , stdin);
		//freopen("output.txt", "w" , stdout);
	//#endif

	ll t;
	t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 4744
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a,b,c,d,ans;
int main(void){
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        cin>>c>>d;
        if(a<=c&&b<=d){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int c[3][3];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> c[i][j];
    }
  }

  // check horizontally
  if (!((c[0][0] - c[1][0]) == (c[0][1] - c[1][1]) && (c[0][1] - c[1][1]) == (c[0][2] - c[1][2]))) {
    cout << "No" << endl;
    return 0;
  }
  if (!((c[1][0] - c[2][0]) == (c[1][1] - c[2][1]) && (c[1][1] - c[2][1]) == (c[1][2] - c[2][2]))) {
    cout << "No" << endl;
    return 0;
  }

  // check vertically
  if (!((c[0][0] - c[0][1]) == (c[1][0] - c[1][1]) && (c[1][0] - c[1][1]) == (c[2][0] - c[2][1]))) {
    cout << "No" << endl;
    return 0;
  }

  if (!((c[0][1] - c[0][2]) == (c[1][1] - c[1][2]) && (c[1][1] - c[1][2]) == (c[2][1] - c[2][2]))) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int A, B;
    int add, sub, mul;

    scanf("%d %d", &A, &B);

    add = A + B;
    sub = A - B;
    mul = A * B;

    if(add >= sub && add >= mul){
        printf("%d\n", add);
    } else if (sub >= mul){
        printf("%d\n", sub);
    } else {
        printf("%d\n", mul);
    }

    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h> 
using namespace std;
int main(void){
  int n; cin >> n;
  string s[n]; 
  int t[n];
  for(int i = 0; i< n; i++){
    cin >> s[i] >> t[i];
  }
  string x; cin >> x;
  int time;
  for(int i = 0; i<n; i++){
    if(s[i] == x) time = i;
  }
  int ans = 0;
  for(int i = time + 1; i < n; i++){
    ans += t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int[] answers = new int[32]{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 k = int.Parse(Console.ReadLine());
		Console.WriteLine(answers[k-1]);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>

using namespace std;

vector<int> G[100000];
long A[100000];
bool used[100000];
bool judge = true;

long dfs(int v){
    used[v] = true;
    if(G[v].size() == 1){
        //cout << v << ' ' << A[v] << endl;
        return A[v];
    }
    long sum = 0;
    for(int i = 0; i < G[v].size(); i++){
        long tmp;
        if(!used[G[v][i]]) {
            tmp = dfs(G[v][i]);
            if(tmp > A[v]) judge = false;
            sum += tmp;
        }
    }
    long ret = 2*A[v]-sum;
    if(ret < 0) judge = false;
    if(ret > A[v]) judge = false;
    //cout << v << ' ' << ret << endl;
    return ret;
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        used[i] = false;
    }
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(N == 2){
        if(A[0] == A[1]) cout << "YES" << endl;
        else cout << "NO" << endl;
        return 0;
    }
    for(int i = 0; i < N; i++){
        if(G[i].size() != 1){
            if(dfs(i) != 0 || !judge){
                cout << "NO" << endl;
            }else{
                cout << "YES" << endl;
            }
            return 0;
        }
    }
}

Measured memory_bytes: 10624
#include<iostream>
using namespace std;
// Problem https://atcoder.jp/contests/abc057/tasks/abc057_c

int digitC(long long  number){
    int result=0;
    long long checkNumber;
    checkNumber = number;
    while(checkNumber != 0){
        checkNumber = checkNumber / 10;
        result = result + 1;
    }
    return result;
}

int solver(long long  givenNumber){
    int result = 12; // 最大数は(1,10000000000)
    for(long long j=1;j*j<= givenNumber;j++){
        if(givenNumber % j !=0){
            continue;// Nで割れないAは条件に合わないので以下の処理を飛ばす
        }
        long long  bigNumber;
        bigNumber = givenNumber / j;
        int nowDigit=digitC(bigNumber);
        if(nowDigit<result){
            result = nowDigit;
        }
    }
    return result;
}

int main(void){
    long long N;
    int answer=0;
    cin >> N;
    answer = solver(N);
    cout << answer << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int n;
    cin >> n;
    map<string, int> H;
    int mv = 0;
    FOR(i, n){
        string s;
        cin >> s;
        H[s]+=1;
        mv = max(mv, H[s]);
    }

    for(auto it : H) if (it.second == mv) cout << it.first << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 23808
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>  vll;

// code
// ------------------------------------------------
int main() {

  ll n,h,w;
  cin >> n >> h >> w;

  cout << (n - h + 1) * (n - w + 1) << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

vector<int> div(int n){
    vector<int> a;
    FOR(i,1,sqrt(n)+1){
        if(n%i == 0){
            a.push_back(i);
            if(i*i!=n) a.push_back(n/i);
        }
    }
    sort(ALL(a));
    return a;
}

int main() {
    int N,M; cin >> N >> M;
    vector<int> a = div(M);

    auto itr = upper_bound(ALL(a), M/N);
    itr--;
    cout << *itr << endl;

    return 0;
}

Measured memory_bytes: 3696
<>;
@a=glob<>;
for$a(@a){
	$x+=$a;
	$y+=$a;
	if(--$|){
		if($x<=0){
			$X+=1-$x;
			$x=1;
		}
		if($y>=0){
			$Y+=1+$y;
			$y=-1;
		}
	}else{
		if($x>=0){
			$X+=1+$x;
			$x=-1;
		}
		if($y<=0){
			$Y+=1-$y;
			$y=1;
		}
	}
}
print$X<$Y?$X+0:$Y+0,$/


Measured memory_bytes: 27008
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  map<int,int> A1,A2;
  rep(i,0,N/2){
    int X,Y;
    cin>>X>>Y;
    if(A1.count(X))
      A1.at(X)++;
    else
      A1[X]=1;
    if(A2.count(Y))
      A2.at(Y)++;
    else
      A2[Y]=1;
    }
  pii top1,second1(-1,0),top2,second2(-2,0);
  for(auto p:A1){
    int key=p.first,value=p.second;
    if(value>=top1.second){
      second1=top1;
      top1=make_pair(key,value);
      }
    else if(value>second1.second)
      second1=make_pair(key,value);
    }
  for(auto p:A2){
    int key=p.first,value=p.second;
    if(value>=top2.second){
      second2=top2;
      top2=make_pair(key,value);
      }
    else if(value>second2.second)
      second2=make_pair(key,value);
    }
  int ans=N-top1.second-top2.second;
  if(top1.first==top2.first){
    ans=N-max(top1.second+second2.second,top2.second+second1.second);
    }
  cout<<ans<<endl;
  }


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>

using namespace std;

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		(1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define	show(x)	 copy( (x).begin(), (x).end(), ostream_iterator<int>(cout, ",") );	// container<int>を全て表示

using namespace std;

typedef long long ll;

//constant
//--------------------------------------------
const double EPS = 1e-10;
//const double PI  = acos(-1.0);

ll kaijo( ll N )
{
	// 階乗
	if( N == 0 ) return 1;
	return N * kaijo(N - 1);
}

map<ll, ll> prime_factor(ll N)
{
	// 素因数分解
	map<ll, ll> ret;
	for( ll i = 2; i * i <= N; i++ ){
		while( N % i == 0 ){
			ret[i]++;
			N /= i;
		}
	}
	if(N != 1) ret[N] = 1;
	return ret;
}

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

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

ll max( ll a, ll b )
{
	if( a > b ) return a;
	return b;
}
ll min( ll a, ll b )
{
	if( a > b ) return b;
	return a;
}

class UnionFind
{
public:
	vector<int> parent;
	vector<int> rank;

	UnionFind(int n)
	{
		Rep(i, n){
			parent.push_back(i);
			rank.push_back(1);
		}
	}
	int root(int x)
	{
		if( parent[x] != x ) parent[x] = root(parent[x]);
		return parent[x];
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if( rx == ry ) return;
		if( rank[rx] > rank[ry] ){
			parent[ry] = rx;
			rank[rx] += rank[ry];
		}
		if( rank[rx] <= rank[ry] ){
			parent[rx] = ry;
			rank[ry] += rank[rx];
		}
	}
};

int main()
{
	string S = "";
	ll K = 0;
	ll ans = 0;

	cin >> S >> K;

	ll one_index = S.length();
	ll saved = 0;
	for(int i = 0; i < S.length(); ++i){
		if(S[i] != '1'){
			one_index = i;
			saved = S[i] - '0';
			break;
		}
	}

	if( K <= one_index ){
		ans = 1;
	}
	else{
		ans = saved;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define mod 1000000007
#define ll long long 


// int a[100000];

int main() {
	// int t, n;
	// string x;
	// cin>>n;
	// cin>>x;

	int a, b;
	cin>>a>>b;










	cout<< a*b<<endl;

}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <climits> 
#include <map>
using namespace std;

const int MAX_V = 1000; // ???????????°????????§???
const int INF = 1000000; // ???????????§?????????(int ???????????§???)
int v; // ????????°
int g[MAX_V][MAX_V]; // ??£??\??????
int d[MAX_V]; // ??????s ????????????????????¢
bool used[MAX_V]; // ?????§??????????????¢????¢??????????????????¨???????????°

void dijkstra(int s)
{
  // ??????
  fill(d, d + v, INF);
  fill(used, used + v, false);
  d[s] = 0;
  // ??????s ????????????????????????????????¢????¨????
  for(;;){
    // ???????¢???????????????????????????????????????¢???????°???????????????¢???
    // ?????????????????¢???????????????????????¢????¢??????????
    int i = -1;
    for(int j = 0; j < v; ++j)
      if(!used[j] && (i == -1 || d[i] > d[j]))
	i = j;
    if(i == -1)break; // ??¨??????????????????????????¢????¢????????????´???
    // ?????????????????¢???????????????????????¢?¢????
    used[i] = true;
    // ???????????¢????¢?????????????????????£??\????????????????????±?????´??°
    for(int j = 0; j < v; ++j)
      d[j] = min(d[j], d[i] + g[i][j]);
  }
}

int main()
{
  for(;;){
    int gv, ge;
    cin >> ge;
    if(ge==0){return 0;}
    set<int> s;

    fill(&g[0][0], &g[MAX_V][0], 100000);
    //for(int i=0;i<5;i++){for(int j=0;j<5;j++){cout << g[i][j] << " ";}cout << endl;}


    for(int i = 0; i < ge; ++i){
      int gs, gt, gd;
      cin >> gs >> gt >> gd;
      g[gs][gt]=gd;
      g[gt][gs]=gd;
      s.insert(gs);
      s.insert(gt);
    }

    gv=s.size();
    v = gv;

    vector<pair<int,int> > p(s.size());
    set<int>::iterator it= s.begin();



    int count=0;
    while(it!=s.end()){
      dijkstra(*it);
      //for(int i=0;i<v;i++)cout << d[i] << endl;

      int sum=0;
      for(int i=0;i<v;i++){sum+=d[i];}
      //cout << sum << ":" << *it << endl;
      p[count].first=sum;
      p[count].second=*it;
      it++;
      count++;
    }

    sort(p.begin(),p.end());
  
    //for(int i=0;i<p.size();i++)
    cout << p[0].second << " " << p[0].first << endl;
  }
  return 0;
}

Measured memory_bytes: 5108
#include<stdio.h>

int main(void)
{
  int a, b, d = 0, r = 0;
  double f = 0.0;

  scanf("%d %d", &a, &b);

  d = a/b;
  r = a%b;
  f = (double)a/b;

  printf("%d %d %f\n", d, r, f);

  return 0;
}

Measured memory_bytes: 636
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import qualified Data.Array.Unboxed as UA
import Data.Array.IO
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

getWords = getLine >>= return . words

readIntBS = fst . fromJust . BS.readInt

for = flip map

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- listArray (1,n) . map read . words <$> getLine :: IO (Array Int Int)

  print $ solve as (as!1) (as!1) 1 1 n

  where
    solve as b c l r n =
      if b == c then
        (r-l+1) + if r == n then 0 else solve as (b+as!(r+1)) (c`xor`as!(r+1)) l (r+1) n
      else
        solve as (b-as!l) (c`xor`as!l) (l+1) r n


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

int main() {
  int N,M;
  cin >> N >> M;
  long step[N+1];
  step[0]=1;
  bool brook[N];
  for(int i=0;i<N;i++)brook[i]=false;
  for(int i=0;i<M;i++){
    int x;
    cin >> x;
    brook[x]=true;
  }
  for(int i=1;i<N+1;i++){
    if(i==1){
      if(brook[1])step[1]=0;
      else step[1]=1;
    }
    else{
      if(brook[i])step[i]=0;
      else step[i]=(step[i-1]+step[i-2])%1000000007;
    }
  }
  cout << (step[N-2]+step[N-1])%1000000007;
}

Measured memory_bytes: 1152
N=int(input())
A=list(map(int,input().split()))
tmp=0
fugo=-1
ans=[]
for i in range(N):
    fugo*=-1
    tmp+=fugo*A[i]
ans.append(tmp)

for i in range(N-1):
    x=ans[i%N]
    ans.append(2*A[i%N]-x)

for x in ans:
    print(x, end=' ')
print()

Measured memory_bytes: 14028
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),cin.sync_with_stdio(0),cout.tie(0),cout.sync_with_stdio(0);
	int n;
	cin>>n;
	vector<string> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
		sort(v[i].begin(), v[i].end());
	}
	sort(v.begin(), v.end());
	/*for(auto x:v)
		cout<<x<<endl;*/
	long long int res=0;
	for(int i=0;i<n;){
		int j=i;
		while(j<n && v[j]==v[i]) j++;
		//cout<<v[i]<<" "<<v[j]<<endl;
		long long int cnt=j-i;
		cnt--;
		res+=(cnt)*(cnt+1)/2;
		i=j;
	}
	cout<<res;
}

Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

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

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  string S; cin >> S;
  if (S == "Sunny") cout << "Cloudy" << endl;
  else if (S == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}


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

int main()
{
    char a;
    cin >> a;
    if ('A' <= a && a <= 'Z')
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    // input
    int A, B, C, ans;
    cin >> A >>  B >> C;
    if ((A * C) <= B) {
        ans = C;
    } else {
        ans = B / A;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
XL = [list(map(int, input().split())) for _ in range(N)]

XLreach = []
for x, l in XL:
  XLreach.append((x+l,x,l))
  
XLreach.sort()

rmv = 0
reach = - 10 ** 12
for r, x, l in XLreach:
  if x - l < reach:
    rmv += 1
  else:
    reach = r
    
print(N - rmv)

Measured memory_bytes: 39080
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  ll N, A, B; cin >> N >> A >> B;
  vector<ll> X(N); REP(i, N) cin >> X[i];

  vector<ll> diff(N-1); REP(i, N-1) diff[i] = abs(X[i]-X[i+1]);
  ll ans = 0;
  for (int i = 0; i < N-1; ++i) {
    if (diff[i]*A <= B) {
      ans += diff[i]*A;
    } else {
      ans += B;
    }
  }
  cout << ans << endl;
}

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

typedef long long ll;

ll H, W;
ll R = 1ll << 60;

void calc(ll h, ll w) {
  R = min(R, w * (h % 3 == 0 ? 0 : 1));
  for (ll y : {h / 3, h / 3 + 1, h / 3 + 2}) {
    if (y < 1 || h - y < 1) continue;
    ll a = y * w, b = (h - y) * (w / 2), c = (h - y) * (w - w / 2);
    R = min(R, max({a, b, c}) - min({a, b, c}));
  }
}
int main() {
  cin >> H >> W;
  calc(H, W);
  calc(W, H);
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<vector<int>> alpha(N, vector<int>(26, 0));
    rep(i, N) {
        string s;
        cin >> s;
        rep(j, s.size()) { alpha[i][s[j] - 'a']++; }
    }

    string s = "";
    rep(j, 26) {
        int cnt = 10000;
        bool judge = 1;
        rep(i, N) {
            if (alpha[i][j] == 0)
                judge = 0;
            cnt = min(cnt, alpha[i][j]);
        }
        if (judge) {
            rep(k, cnt) { s += (j + 'a'); }
        }
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
 
using namespace std;
 
void func(int H){
    int table[H][5];
 
    for(int i = 0; i < H; i++){
        for(int k = 0; k < 5; k++)scanf("%d",&table[i][k]);
    }
 
    bool FLG;
    int count = 0;
 
    while(true){
 
        FLG = false;
 
        for(int i = 0; i < H; i++){
            for(int k = 0,p = 0; k <= 2; k++){
                if(table[i][k] == -1)continue;
                for(p = 1; k+p < 5 && table[i][k+p] == table[i][k]; p++);
                if(p >= 3){
                    for(int a = k; a < k+p; a++){
                        count += table[i][a];
                        table[i][a] = -1;
                        FLG = true;
                    }
                    break;
                }
            }
        }
 
        for(int col = 0; col < 5; col++){
            for(int row = H-2,i = 0; row >= 0; row--){
                if(table[row][col] != -1){
                    for(i = row+1; i < H && table[i][col] == -1; i++);
                    if(i > row+1){
                        table[i-1][col] = table[row][col];
                        table[row][col] = -1;
                    }
                }
            }
        }
 
        if(!FLG)break;
    }
 
    printf("%d\n",count);
}
 
 
int main(){
 
    int H;
 
    while(true){
        scanf("%d",&H);
        if(H == 0)break;
 
        func(H);
    }
 
    return 0;
}


Measured memory_bytes: 2712
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Vector.Unboxed as U

main = C.interact $ C.pack . show . sol . unfoldr (C.readInt . C.dropWhile (<'0'))

sol (n:s:as) = U.last $ foldr f (U.singleton 1 U.++ U.replicate s 0) as

f a = U.zipWith (\a b -> (a+b) `mod` p) <$> U.map (2*) <*> (U.replicate a 0 U.++)

p = 998244353 :: Int

Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,b,c;
  cin >> n >> b >> c;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=0;
  REP(i,1,n) {
    ll d=a[i]-a[i-1];
    ans+=min(b*d,c);
  }
  pr(ans);
}

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


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] array = new String[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.next();
        }
        Arrays.sort(array);
        
        for (int i = 0; i < n; i++) {
            System.out.print(array[i]);
        }
        System.out.println();
        
    }
}


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

#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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;
#define PI 3.14159265359 
bool dp[100100];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
    long long A,B,K;
    cin >> A >> B >> K;

    if( A <= K ){
        K -= A;
        B = max((long long) 0,B-K);
        cout << 0 <<" " << B <<endl; 
    }
    else{
        A -= K;
        cout << A << " " << B << endl;
    }


}


Measured memory_bytes: 256
N = gets.chomp.to_i
a = Array.new(N){Array.new(10)}
for i in 0...N do
    str = gets.chomp
    for j in 0...10 do
        a[i][j] = str[j]
    end
    a[i].sort!
end
a.sort!

answer = 0
x = 1
for i in 0...N-1 do
    if a[i] == a[i+1]
        answer += x
        x += 1
    else
        x = 1
    end
end

puts answer

Measured memory_bytes: 66808
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

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

func main() {
	defer stdout.Flush()
	N := readInt()
	M := readInt()
	K := readInt()
	for i := 0; i <= N; i++ {
		if i*M == K {
			println("Yes")
			return
		}
		for j := 0; j <= M; j++ {
			if j*N == K {
				println("Yes")
				return
			}
			if (i*j + (N-i)*(M-j)) == K {
				println("Yes")
				return
			}
		}
	}
	println("No")
}

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define N 200010
#define ll long long
using namespace std;
int n,m,fir[N],nxt[N<<1],to[N<<1],tot(1),vis[N],col[N],num,tag;

template <class Aqua>
inline void read(Aqua &s){
	s=0; char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) s=s*10+c-'0',c=getchar();
}

inline void add(int u,int v){
	to[++tot]=v; nxt[tot]=fir[u]; fir[u]=tot;
}

void dfs(int x){
	vis[x]=1; num++;
	for (int i=fir[x];i;i=nxt[i])
		if (!vis[to[i]])
			col[to[i]]=col[x]^1,dfs(to[i]);
		else
			if (col[to[i]]==col[x]) tag=1;
}

int main(){
	read(n),read(m);
	int u,v;
	for (int i=1;i<=m;i++){
		read(u),read(v);
		add(u,v),add(v,u);
	}
	ll x(0),y(0),z(0);
	for (int i=1;i<=n;i++)
		if (!vis[i]){
			num=col[i]=tag=0;
			dfs(i);
			if (num==1) x++;
			else
				if (tag) y++;
				else z++;
		}
//	printf("%lld %lld %lld\n",x,y,z);
	ll ans=2*x*n-x*x+y*y+2*y*z+2*z*z;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6400
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int n,m,x,y;
string s;

int main(){
	n=IN(),m=IN();
	For(i,0,n) For(j,0,m){
		cin>>s;
		if (s=="snuke") x=i,y=j;
	}
	printf("%c%d\n",'A'+y,x+1);
}

Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(!(n%2)) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll inv(ll a){
	return PowMod(a, MOD-2);
}

int main(void){
	ll n;
	cin >> n;
	Vec x(n), d(n-1);
	rep(i, n) cin >> x[i];
	rep(i, n-1) d[i] = x[i+1]-x[i];
	ll p = 1;
	repn(i, n-1){
		p *= i;
		p %= MOD;
	}
	Vec c(n);
	rep(i, n){
		c[i] = inv(i+1);
		if(i) c[i] += c[i-1];
		c[i] %= MOD;
	}
	ll ans = 0;
	rep(i, n-1){
		ans += d[i]*c[i]%MOD*p%MOD;
		ans %= MOD;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 2560
import itertools
def LI(): return list(map(int,input().split()))
N,M,Q = LI()
abcd = [LI() for _ in range(Q)]
ans = 0
for x in itertools.combinations_with_replacement(range(1,M+1),N):
    score = 0
    for y in abcd:
        a,b,c,d = y[0],y[1],y[2],y[3]
        if x[b-1]-x[a-1]==c:
            score += d
    ans = max(ans,score)
print(ans)


Measured memory_bytes: 9200
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int ll 
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#ifndef LOCAL
#define cerr if(0)cout
#endif
bool A[25][25];
int dp[2][2097155]; //ways for that possible combination of woman that have already been matched.
int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	FOR(i,0,n-1) {
		FOR(j,0,n-1) cin >> A[i][j];
	}
	
	bool alt = 0;
	dp[0][0] = 1;
	FOR(i,0,n-1) {
		alt=1-alt;
		memset(dp[alt],0,sizeof dp[alt]);
		FOR(j,0,(1ll<<n)-1) {
			if(__builtin_popcount(j) == i+1) {
				FOR(k,0,n-1) if(j&(1<<k)){
					// this is the new woman getting matched to the ith man
					int oldbm = j^(1<<k);
					if (A[i][k]) {
						if(dp[!alt][oldbm]){
							dp[alt][j] += dp[!alt][oldbm];
							dp[alt][j]%=MOD;
						}
					}
				}
			}
		}
	}
	cout << dp[alt][(1ll<<n)-1];
}



Measured memory_bytes: 36432
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[(n/2)-1]<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int digits(int i){
	int tensOfThousands = i / 10000;
	int thousands = (i % 10000) / 1000;
	int hundreds = (i % 10000 % 1000) / 100;
	int tens = (i % 10000 % 1000 % 100) / 10;
	int ones = i % 10000 % 1000 % 100 % 10;
	int check = tensOfThousands + thousands + hundreds + tens + ones;
	
	return check;
}

int main(){
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);
	
	int sum = 0;
	for(int i = a; i <= n; i++){
		if(digits(i) >= a && digits(i) <= b){
			sum += i;
		}
	}
	
	printf("%d\n", sum);
	
	return 0;
}

Measured memory_bytes: 1728