akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

pair<int,int> dp[5010][5010];
bool need[5010];
bool use[5010];
int a[5010];

void solve(){
    ll n,k;
    cin>>n>>k;
    REP(i,n) cin>>a[i];
    sort(a,a+n,greater<int>());

    REP(i,n+1) REP(j,k+1) dp[i][j]={0,-1};
    dp[0][0]={1LL,-1};
    REP(i,n){
        REP(j,k+1){
            if(dp[i][j].first==0) continue;
            dp[i+1][j].first++;//何もしない
            if(j<k){
                if(j+a[i]<k) dp[i+1][j+a[i]].first++;
                else dp[i+1][k]={1,j};
            }
        }
    }

    REP2(i,n){
        REP(j,k+1){
            if(use[j]==false) continue;
            if(j-a[i]>=0 and dp[i][j-a[i]].first!=0){
                need[i]=true;
                use[j-a[i]]=true;
            }
            if(dp[i][j].first==0){
                use[j]=false;
            }
        }
        if(dp[i+1][k].second!=-1){
            use[dp[i+1][k].second]=true;
            need[i]=true;
        }
    }

    ll ans=0;
    REP(i,n) if(!need[i]) ans++;
    cout<<ans<<en;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 196096
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <iostream>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);

  string w;
  map<string, int> d;

  cin >> w;
  d[w] = 1;
  char last = w[w.size()-1];

  for (int i = 1; i < n; i++) {
    cin >> w;

    if (last != w[0]) {
      printf("No\n");
      return 0;
    }

    if (d.count(w)) {
      printf("No\n");
      return 0;
    }

    last = w[w.size()-1];
    d[w] = 1;
  }

  printf("Yes\n");

  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int matrixA[n][m];
    int vectorB[m];
    int input;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> matrixA[i][j];
        }
    }
    for(int j = 0; j < m; j++){
        cin >> vectorB[j]; 
    }
    
    int res = 0;
    for(int i = 0; i < n; i++){
        res = 0;
        for(int j = 0; j < m; j++){
            res += matrixA[i][j]*vectorB[j];
        }
        cout << res << endl;
    }
    
}


Measured memory_bytes: 3116
package main 

import (
  "fmt"
)

func main() {
  var H, W int64
  fmt.Scanf("%d %d\n", &H, &W)
  if H == 1 || W == 1 {
    fmt.Println(1)
    return
  }
  var tmpCnt int64 = (1 + int64((H - 1) / 2)) * W
  if (H - 1) % 2 == 0 {
    tmpCnt -= int64(W / 2)
  }
  
  fmt.Println( tmpCnt )
}

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

int main() {
    int n, l;
    string s[110];
    cin >> n >> l;
    for(int i = 0; i < n; ++i) cin >> s[i];
    
    sort(s, s + n);
    string t;
    for(int i = 0; i < n; ++i) t += s[i];
    
    cout << t << endl;
}


Measured memory_bytes: 256
A, B, C, D = map(int, input())
O = [B, C, D]

N = len(O)
ans = []

## 一桁目は、Plus固定かな

for i in range(2**(N)):
    tmp_list = []
    tmp_count = 0
    for j in range(N):
        if (i>>j)&1:
            tmp_list.append("+")
            tmp_count += O[j]
        else:
            tmp_list.append("-")
            tmp_count -= O[j]
            
    if A + tmp_count == 7:
        ans = []
        for k in range(N):
            ans.append(tmp_list[k] + str(O[k]))


print(str(A) + "".join(ans) + "=7")   

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
int main(){
	ll n;
	std::cin>>n;
	ll ans=1000000000005;
	for(ll i=1;i<=sqrt(n);i++){
		if(n%i==0){
			ll temp=i-1;
			temp+=(n/i)-1;
			ans=ans<temp?ans:temp;
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;
 
template<typename T>
struct is_vector : false_type{};
 
template<typename T>
struct is_vector<vector<T>> : true_type{};
 
template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

void solve() {
  int M; cin >> M;
  vl d(M), c(M);
  rep(i,M) cin >> d[i] >> c[i];

  ll ans = accumulate(all(c), 0LL) - 1;
  ll add = 0;
  rep(i,M) add += d[i] * c[i];
  ans += (add-1) / 9;
  cout << ans << endl;
}

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


Measured memory_bytes: 3456
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
int main() {
	int h, w,i,j;
	while (1) {
		scanf("%d%d", &h, &w);
		if (h + w == 0)break;
		for (i=0; i<h; ++i) {
			for (j = 0; j < w; ++j) {
				if((i*j==0)||(i==h-1)||(j==w-1))putchar('#');
				else putchar('.');
			}
			putchar('\n');
		}
		putchar('\n');
	}
		return 0;
}

Measured memory_bytes: 572
#!python3

# input
N = int(input())
txy = [tuple(map(int, input().split())) for _ in range(N)]


def judge(p1, p2):
    t = p2[0] - p1[0]
    d = abs(p1[1] - p2[1]) + abs(p1[2] - p2[2])
    if t < d:
        return False
    if (t - d) % 2 == 0:
        return True
    else:
        return False


def main():
    txy.sort()
    p1 = (0, 0, 0)
    for p2 in txy:
        if judge(p1, p2):
            continue
        else:
            print("No")
            return
    print("Yes")
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 17304
import collections
import math

def combinations_count(n, r):
    if n==1 or n==0:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
A = list(map(int, input().split()))
# A = list(range(10**5))
c = collections.Counter(A)

ks=list(c.keys())
vs=list(c.values())
cvs=collections.Counter(vs)
tmp_ans=0
# print('vs',vs)
for k,v in cvs.items():
    # print('kv',k,':',v)
    tmp_ans += v *combinations_count(k, 2)
# print('tmp',tmp_ans)
# tmp_ans = 

# ans_dict={}
# for i,k in enumerate(list(set(vs))):
#     ans = 0
#     for j in range(len(list(set(vs)))):
#         ans += combinations_count(j, 2)

    
#     ans_dict[i] = 

for i in A:
    print(tmp_ans-(c[i]-1))


# ans_dict={}
# ks=list(c.keys())
# vs=list(c.values())

Measured memory_bytes: 26780
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}




void solve()
{
  int cn = 0;

  int l,r,d;
  cin >> l >> r >> d;

  forf(i,l,r+1)
  {
    if(i%d==0) cn++;
  }

  cout<<cn;

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

string Dream(string t){
  if(t.size()==0)return t;
  if(t=="dream" || t=="dreamer")return "";
  else if(t.size()<=4 || t.substr(0,5)!="dream")return t;
  else{
    if(t.size()>=8 && t.substr(0,7)=="dreamer"){
      if(t[7]=='d' || t[7]=='e')return t.substr(7,t.size());
      else if(t[7]=='a')return t.substr(5,t.size());
      else return t;
    }
    else return t.substr(5,t.size());
  }
}
string Erase(string t){
  if(t.size()==0)return t;
  if(t.substr(0,6)=="eraser"){
    return t.substr(6,t.size());
  }
  else if(t.substr(0,5)=="erase"){
    return t.substr(5,t.size());
  }
  else return t;
}

int main(){
  string s;
  cin >> s;
  int temp=(int)s.size();
  while(s.size()>0){
    s=Dream(s);
    s=Erase(s);
    if(temp==(int)s.size())break;
    temp=s.size();
  }
  if(s.size()==0)cout << "YES" << endl;
  else cout << "NO" << endl;
return 0;}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

vector<pair<ll,ll>>r,b;
bool ch[100];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		r.push_back(make_pair(x,y));
	}
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		b.push_back(make_pair(y,x));
	}
	sort(r.begin(),r.end());
	sort(b.begin(),b.end());
	reverse(r.begin(),r.end());
	ll ans=0;
	for(int i=0;i<n;i++){
		ll now=r[i].first;
		ll NOW=r[i].second;
		for(int j=0;j<n;j++){
			ll next=b[j].second;
			ll NEXT=b[j].first;
			if(ch[j]){
				continue;
			}
			if(now<next&&NOW<NEXT){
				ch[j]=true;
				ans++;
				break;
			}
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


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);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n%2==0) cout << n;
    else cout << 2*n;
    cout << endl;
    return 0;
}




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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    sort(a.begin(), a.end());

    vector<int> vect(1000001, 0); //0なら未使用，1なら一回だけ出てきた，2なら二回以上出てきたもしくはより小さいAの要素の倍数

    for (int i = 0; i < N; i++) {
        if (vect[a[i]] == 0) {
            vect[a[i]] = 1;
            int j = 2;
            while (j * a[i] <= 1000000) {
                vect[j * a[i]] = 2;
                j++;
            }
        }
        else if (vect[a[i]] == 1) {
            vect[a[i]] = 2;
        }
    }

    int count = 0;
    for (int i = 0; i <= 1000000; i++) {
        if (vect[i] == 1) count++;
    }

    cout << count << endl;
}


Measured memory_bytes: 7996
#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int x; cin >> x;
	cout << 1-x << ln;
}


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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
vector<int> v[100001];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	int n,m,a1,b1;
	cin>>n>>m;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++){
		cin>>a1>>b1;
		v[a1].push_back(b1);
		v[b1].push_back(a1);
	}
	int count=0;
	for(int i=1;i<=n;i++){
		int flag=1;
		for(int x:v[i]){
			if(a[i]<=a[x]){
				flag=0;
				break;
			}
		}
		if(flag==1)
			count++;
	}
	cout<<count<<endl;

	return 0;
}

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

using namespace std;

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

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

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

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

    int n, k;
    ll v[55];

    cin >> n >> k;
    REP(i, n)
    cin >> v[i];

    ll res = 0;

    for (int i = -1; i < n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            int ln = i + 1;
            int rn = n - j;

            if (ln + rn > k)
                continue;

            int no = k - (ln + rn);

            vector<ll> ve;

            REP(l, ln)
            ve.push_back(v[l]);
            REP(l, rn)
            ve.push_back(v[n - l - 1]);

            SORT(ve);

            ll sum = 0;

            ll su = 0;
            for (int z = no; z >= 0; z -= 1)
            {
                su = 0;
                for (int l = z; l < ve.size(); l++)
                    su += ve[l];
                sum = max(su, sum);
            }

            res = max(res, sum);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int N;
    cin >> N;

    int biria=0, birib=0; // biri = max(A)
    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        if(biria < A){
            biria = A;
            birib = B;
        }
    }

    cout << biria+birib << endl;
}


Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
lcm = A[0]
MOD = 10**9 + 7
for a in A:
    lcm = (lcm // gcd(lcm,a) * a)
res = 0
for a in A:
    res += lcm //a
print(res % MOD)


Measured memory_bytes: 6112
#include<cstdio>
#include<algorithm>

using namespace std;
int main(void)
{
	int c1,c2,c3;
	while(scanf("%d%d%d",&c1,&c2,&c3)!= EOF)
	{
		int flag[10] = {0},check = 20;
		double safe = 0;
		check -= c1 + c2;
		flag[c1 - 1] = 1;
		flag[c2 - 1] = 1;
		flag[c3 - 1] = 1;
		for(int i = 0;i < 10;i++)
		{
			if(flag[i] == 0)
			{
				if(i >= check) safe++;
			}
		}
		if(safe/7 <= 0.5) printf("YES\n");
		else printf("NO\n");
	}


	return 0;
}

Measured memory_bytes: 1008
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int h,w;cin>>h>>w;
    vector<vector<string> > s(h,vector<string>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=="snuke"){
                cout<<(char)(j+'A')<<i+1<<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 sc = new Scanner(System.in);
        
        List<Integer> list = new ArrayList<>();
                
        
       while(true){
           
            int x = sc.nextInt();
           
            if(x == 0) break;
            
            list.add(x);
           
       }
       
       int count = 0;
       
       for(int a :list){
            count ++;
            System.out.println("Case "+count+": "+a);
        }
        
    }}
       
        


        



Measured memory_bytes: 43980
{-# LANGUAGE MultiParamTypeClasses,FlexibleContexts,FlexibleInstances,TypeSynonymInstances,BangPatterns,RankNTypes,TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Control.Arrow
import Debug.Trace
import Text.Printf

import Data.List
import Data.Int
import Data.Bits
import Data.Maybe
import Data.Monoid
import Data.Array.Unboxed
import Data.Array.ST
import Data.Array.Base
import Data.Function(on)
import Data.Tuple(swap)
import qualified Data.Map as M
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
    (k,s) <- readIntPair
    print $ length $ do
        x <- [0..k]
        y <- [0..k]
        let z = s - x - y
        guard $ 0 <= z && z <= k
        return ()

-- IO
readInt :: B.ByteString -> Int
readInt = fromJust . fmap fst . B.readInt
readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine
readIntPair :: IO (Int,Int)
readIntPair = l2p . map readInt . take 2 . B.words <$> B.getLine
readAllInts :: IO [[Int]]
readAllInts = map (map readInt . B.words) . B.lines <$> B.getContents
readLns :: Read a => IO [a]
readLns = map read . words <$> getLine

-- Utilities
l2p :: [a] -> (a,a)
l2p (a:b:_) = (a,b)
l2p _ = error "l2p: the input list is too short"
p2l :: (a,a) -> [a]
p2l (a,b) = [a,b]
itof :: Int -> Double
itof = fromIntegral
inf :: Int
inf = maxBound `div` 2

-- Monad
stepM_ :: Monad m => a -> (a -> Bool) -> (a -> a) -> (a -> m ()) -> m ()
stepM_ i0 judge incr step = sub i0 where 
    sub i | judge i = step i >> sub (incr i) 
          | otherwise = return ()
rep_ :: Monad m => Int -> (Int -> m ()) -> m ()
rep_ n = stepM_ 0 (<n) (+1)
thru :: Monad m => (v -> m ()) -> v -> m v
thru m v = m v >> return v
memoize :: (Monad m) => (k -> m (Maybe v)) -> (k -> v -> m ()) -> k -> m v -> m v
memoize getter setter key action = do
    mv <- getter key
    case mv of
        Just v -> return v
        Nothing -> action >>= thru (setter key)

-- Array
newUArray :: (MArray (STUArray s) e (ST s),Ix i) => 
             (i,i) -> e -> ST s (STUArray s i e)
newUArray = newArray
newBArray :: (Ix i) => (i,i) -> e -> ST s (STArray s i e)
newBArray = newArray
defaultArray :: (IArray a e,Ix i) => e -> (i,i) -> [(i,e)] -> a i e
defaultArray = accumArray $ curry snd
fromEdges :: Ix i => (i,i) -> [(i,e)] -> Array i [e]
fromEdges = accumArray (flip (:)) []


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

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

  int np=0;
  while(true){
    int ma=0;
    int mi=100;
    for(int i=0;i<m;i++){
      ma=max(ma,a[np]);
      mi=min(mi,a[np]);
      np++;
      np%=n;
    }
    ans+=ma-mi;
    if(np==0)break;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3096
# ABC144E - Gluttony
def binary_search(upper_bound: int = 1 << 60, lower_bound: int = -1) -> int:
    ok, ng = upper_bound, lower_bound
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):  # condition
            ok = mid
        else:
            ng = mid
    return ok


def check(x: int) -> bool:
    cost = sum(a - x // f for a, f in zip(A, F) if a * f > x)
    return cost <= K


def main():
    global K, A, F
    N, K, *AF = map(int, open(0).read().split())
    A, F = sorted(AF[:N]), sorted(AF[N:], reverse=1)
    ans = binary_search(A[-1] * F[0] + 1)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 127800
n,m=map(int,input().split())
max_l=0
min_r=n
for i in range(m):
	l,r=map(int,input().split())
	max_l=max(max_l,l)
	min_r=min(min_r,r)
print(max(0,min_r-max_l+1))

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

int main(){

  int w,a,b; cin >> w >> a >>b;
  int ans=0;
  if((w+a)<=b){
    ans=-a-w+b;
  }
  else if(a>b&&(b+w)<a){
    ans=a-(b+w);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

val br = BufferedReader(InputStreamReader(System.`in`))
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    // 回答をここに書く
    val x = nextInt()
    val a = nextInt()
    val b = nextInt()
    val r = (x - a) % b
    println(r)
}

// 入力取得
fun next() = br.readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

// 約数のList
fun divisor(value : Long) : List<Long> {
    val max = Math.sqrt(value.toDouble()).toLong()
    return (1..max)
            .filter { value % it == 0L }
            .map { listOf(it, value / it) }
            .flatten()
            .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j ->  i % j != 0L }
    }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a : Long, b : Long) : Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base : String, a : String, b : String) : String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 31264
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S;
    cin >> S;

    vector<int> ans(S.size(), 0);

    int i = 0;
    while(i < S.size()) {
        if (S[i] == 'R') {
            int j = i + 1;
            while(j < S.size() && S[j] != 'L') ++j;

            for(; i < j; ++i) {
                if(j - i & 1) ans[j - 1]++;
                else ans[j]++;
            }
        } else {
            // left must be R
            int j = i + 1;
            while(j < S.size() && S[j] != 'R') ++j;

            debug(i, j, S[i]);

            for(int k = i; k < j; ++k) {
                if (k - i & 1) ans[i - 1]++;
                else ans[i]++;
            }

            i = j;
        }
    }

    REP(i, S.size()) {
        if (i > 0) cout << " ";
        cout << ans[i];
    }

    cout << endl;
    
}


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

int n, m;
vector<int> a, b, c;
int main()
{
  cin >> n;
  for(int i = 1; i <= 2 * n; i++)
    c.push_back(i);

  cin >> m;
  for(int i = 1; i <= m; i++){
    int k;
    cin >> k;
    if(k){
      for(int i = 0; i < k; i++)
	a.push_back(c[i]);
      for(int i = k; i < 2 * n; i++)
	b.push_back(c[i]);

      c.clear();
      for(int i = 0; i < b.size(); i++)
	c.push_back(b[i]);
      for(int i = 0; i < a.size(); i++)
	c.push_back(a[i]);

      a.clear();
      b.clear();
    }

    else{
      for(int i = 0; i < n; i++)
	a.push_back(c[i]);
      for(int i = n; i < 2 * n; i++)
	b.push_back(c[i]);

      c.clear();
      for(int i = 0; i < 2 * n; i++)
	if(!(i % 2))
	  c.push_back(a[i / 2]);
	else
	  c.push_back(b[i / 2]);

      a.clear();
      b.clear();
    }
  }
  for(int i = 0; i < 2 * n; i++)
    cout << c[i] << endl;

  return 0;
}

Measured memory_bytes: 1224
import numpy as np
a = np.array([[int(i) for i in input().split()] for _ in range(3)])
n = int(input())
b = [int(input()) for _ in range(n)]
for i in b:
    a[np.where(i == a)] = 0

if a[0,0] + a[1,1] + a[2,2] == 0 or a[0,2] + a[1,1] + a[2,0] == 0:
    print('Yes')
elif 0 in np.sum(a, axis=0) or 0 in np.sum(a, axis=1):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12240
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.next();
		int kcount = 0, ucount = 0, pcount = 0, ccount = 0;
		for(int i = 0; i < str.length(); ++i)
		{
			if(str.charAt(i) == 'K')
			{
				++kcount;
			}
			else if(str.charAt(i) == 'U')
			{
				++ucount;
			}
			else if(str.charAt(i) == 'P')
			{
				++pcount;
			}
			else if(str.charAt(i) == 'C')
			{
				++ccount;
			}
		}
		int min = 999999999;
		if(kcount < min)
		{
			min = kcount;
		}
		if(ucount < min)
		{
			min = ucount;
		}
		if(pcount < min)
		{
			min = pcount;
		}
		if(ccount < min)
		{
			min = ccount;
		}
		System.out.println(min);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<string> s(N);
    rep(i,N){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    // sort済みの文字列をソートする
    sort(s.begin(),s.end());
    ll ans = 0;
    for(int i=0;i<N;i++){
        ll cnt = 0;
        for(int j=i+1;j<N;j++){
            if(s[i]==s[j]){
                cnt++;
                ans+=cnt;
                if(j==N-1){
                    i=N-1;
                }
            }else{
                i=j-1; // loopを抜けたあとi++されるので-1して帳尻を合わせる
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>
int main() {
    int a, b, c, d, p;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
    a = a * p;
    if (p > c) {
        b = b + (p - c) * d;
    }
    if (a < b) {
        printf("%d\n",a);
    }else{
        printf("%d\n",b);
    }
    return 0;
}

Measured memory_bytes: 596
//  Created by conan1024hao on 2019/11/19.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    char b;
    cin>>b;
    if(b=='A')
        cout<<'T'<<endl;
    else if(b=='T')
    cout<<'A'<<endl;
    else if(b=='C')
    cout<<'G'<<endl;
    else if(b=='G')
        cout<<'C'<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


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

int N, h[100000], dp[100000];

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", h + i);
    }
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < N; i++)
    {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    printf("%d\n", dp[N-1]);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> card(N+1,0);

  for(int i=0 ; i<N ; i++)
    cin >> card.at(i);
  
  int A = 0,B = 0;

  for(int i=0 ; i<N ; i++){
      int max = 0;
      int p = 0;
      for(int j=0 ; j<N ; j++){
          if(card.at(j) > max){
              max = card.at(j);
              p = j;
          }
      }
      card.at(p) = 0;
      A += max;
      i++;

      max = 0;
      p = 0;
      for(int j=0 ; j<N ; j++){
          if(card.at(j) > max){
              max = card.at(j);
              p = j;
          }
      }
      card.at(p) = 0;
      B += max;

      //cout << "A : " << A << endl << "B : " << B << endl;
  }

  cout << A - B << endl;
}


Measured memory_bytes: 256
N=int(input())
c=input()
t=c.count('R')
L=[[0,t]]
for i in range(N):
    if c[i]=='W':
        L.append([L[i][0]+1,L[i][1]])
    else:
        L.append([L[i][0],L[i][1]-1])
print(min([max(L[i]) for i in range(N+1)]))

Measured memory_bytes: 101280
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
g=a[-1]
def gcd(a,b):
  while b:a,b=b,a%b
  return a
for i in a:g=gcd(g,i)
if a[-1]<k or k%g!=0:print("IMPOSSIBLE")
else:print("POSSIBLE")

Measured memory_bytes: 14224
#include <iostream>
#include <math.h>
#define N 10000
using namespace std;

int isprime(int);

int main(){
  
  int i,n,x,count=0;

  cin>>n;

  for(i=0; i<n; i++){
  cin>>x;
  count+=isprime(x);
  }

  cout<<count<<endl;

return 0;

}

int isprime(int x){

if(x==2)return 1;
else if(x<2 || x%2==0)return 0;

int i=3;
for(i; i<=sqrt(x); i+=2)if(x%i==0)return 0;

return 1;

}

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

using namespace std;

int main(void){
	int n; cin >> n;
	string dic[] ={" ", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	for(int _=0; _<n; _++){
		string str; cin >> str;
		int cnt = -1;
		char val = '0';
		for(int i=0; i<str.size(); i++){
			if(str[i] == '0'){
				if(val == '0') continue;
				if(val == '1') cnt%=5;
				else if(val == '7' || val == '9') cnt %= 4;
				else cnt %= 3;
				cout << dic[val-'0'][cnt];
				cnt = -1;
				val = '0';
			} else{
				cnt++;
				val = str[i];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int64 exgcd(int64 a, int64 b, int64 &x, int64 &y) {
  if (!b) {
    x = 1;
    y = 0;
    return a;
  }
  int64 d = exgcd(b, a % b, x, y);
  int64 t = x;
  x = y;
  y = t - (a / b) * y;
  return d;
}
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int64 n, res = -1;
  cin >> n;
  if(n==1){
    cout<<1;return 0;
  }
  n *= 2;
  for (int64 i = 1; i * i <= n; ++i)
    if (n % i == 0) {
      int64 x, y, d;
      d = exgcd(i, n / i, x, y);
      if (d == 1 && x != 0 && y != 0) {
        int64 ans = min(abs(i * x), abs(n / i * y));
        res = res == -1 ? ans : min(ans, res);
      }
    }
  cout << res;
  return 0;
}
//2020.09.20 21:59:15


Measured memory_bytes: 3652
#include <iostream>
#include <unordered_set>
#include <set>
#include <queue>
#include <utility>
#include <numeric>
 
using namespace std;
 
int parent[100001];
set<int> blue[100001], red[100001];
queue<pair<int, int>> q;
 
int getRoot(int x) {
	return x == parent[x] ? x : parent[x] = getRoot(parent[x]);
}
 
void print(const set<int> &m) {
	for (auto &&x: m) cerr << x << ' ';
	cerr << endl;
}
 
int main() {
	int n;
 
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		blue[a].insert(b);
		blue[b].insert(a);
	}
 
	for (int i = 1; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		red[a].insert(b);
		red[b].insert(a);
		if (blue[a].find(b) != blue[a].end())
			q.emplace(a, b);
	}
 
	iota(parent + 1, parent + n + 1, 1);
 
	int cnt = 0;
	while (!q.empty()) {
		++cnt;
 
		auto p = q.front();
		q.pop();
 
		int x = getRoot(p.first), y = getRoot(p.second);
 
		if (blue[x].size() + red[x].size() < blue[y].size() + red[y].size()) swap(x, y);
		parent[y] = x;
 
		blue[x].erase(y);
		blue[y].erase(x);
		red[x].erase(y);
		red[y].erase(x);
		
		for (auto &&dest: blue[y]) {
			if (red[x].find(dest) != red[x].end()) q.emplace(x, dest);
		}
 
		for (auto &&dest: red[y]) {
			if (blue[x].find(dest) != blue[x].end()) q.emplace(x, dest);
			red[x].insert(dest);
			red[dest].erase(y);
			red[dest].insert(x);
		}
		red[y].clear();

		for (auto &&dest: blue[y]) {
			blue[x].insert(dest);
			blue[dest].erase(y);
			blue[dest].insert(x);
		}
		blue[y].clear();
	}
 
	if (cnt == n - 1) cout << "YES" << endl; else cout << "NO" << endl;
 
	return 0;
}

Measured memory_bytes: 29056
#include <iostream>
#include <algorithm>
#include <utility>
#define INF 100100100100100100
using namespace std;
typedef long long ll;

ll D,N;
ll T[210],A[210],B[210],C[210];
ll dp[2][110];
int main(){
	cin>>D>>N;
	for(ll i=1;i<=D;i++) cin>>T[i];
	for(ll i=1;i<=N;i++) cin>>A[i]>>B[i]>>C[i];

	ll in=0,ou=1;
	for(ll i=0;i<2;i++) fill(dp[i],dp[i]+110,-1);
	for(ll i=1;i<=N;i++){
		if(A[i]<=T[1]&&T[1]<=B[i]){
			dp[in][C[i]]=0;
		}
	}
	for(ll i=2;i<=D;i++){
		fill(dp[ou],dp[ou]+110,-1);
		for(ll j=1;j<=N;j++){
			if(A[j]<=T[i]&&T[i]<=B[j]){
				for(ll k=0;k<=100;k++){
					if(dp[in][k]!=-1){
						dp[ou][C[j]]=max(dp[ou][C[j]],dp[in][k]+abs(C[j]-k));
					}
				}
			}
		}
		swap(in,ou);
	}
	ll res=0;
	for(ll i=0;i<=100;i++){
		res=max(res,dp[in][i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3100
import collections
n = int(input())
a = list(map(int,input().split()))

aset = set(a)
col = collections.Counter(a)
N = len(aset)
s = 0
for i in range(N):
    k = col[aset.pop()]
    if k>1:
        s += k*(k-1)//2
for i in range(len(a)):
    l = col[a[i]]
    if (l-1)>1:
        c1=l*(l-1)//2
        c2=(l-1)*(l-2)//2
        print(s-c1+c2)
    else:
        c1=l*(l-1)//2        
        print(s-c1)

Measured memory_bytes: 94028
# -*- coding: utf-8 -*-

import os
import sys
import math
import numpy as np

n = int(input())

S = [input() for i in range(n)]

N = 26

alphabet = [chr(i) for i in range(65+26+6,65+26+26+6)]

# print(n)
M = np.zeros([n, 26])

offset = ord('a')

for i, strr in enumerate(S):
    for c in strr:
    	M[i, ord(c)-offset] += 1

ans = np.zeros(N)
for i in range(N):
	ans[i] = np.min(M[:, i])
# print(ans)
var = ''

for i, num in enumerate(ans):
	# print(a)
	for j in range(int(num)):
		var += alphabet[int(i)]

print(var)

Measured memory_bytes: 12788
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s;
	else cout << "red";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> odd;
    map<int, int> even;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i % 2 == 0) {
            if (even.find(x) != even.end()) {
                even[x]++;
            }
            else {
                even[x] = 1;
            }
        }
        else {
            if (odd.find(x) != odd.end()) {
                odd[x]++;
            }
            else {
                odd[x] = 1;
            }
        }
    }
    vector<pair<int, int>> even_v;
    vector<pair<int, int>> odd_v;
    //reverse pair.first, pair.second
    for (map<int, int>::iterator it = even.begin(); it != even.end(); it++) {
        even_v.push_back(make_pair(it->second, it->first));
    }
    for (map<int, int>::iterator it = odd.begin(); it != odd.end(); it++) {
        odd_v.push_back(make_pair(it->second, it->first));
    }
    //sort
    sort(even_v.begin(), even_v.end(), greater<pair<int, int>>());
    sort(odd_v.begin(), odd_v.end(), greater<pair<int, int>>());
    int ans = 0;
    if (even_v[0].second != odd_v[0].second) {
        ans = n - even_v[0].first - odd_v[0].first;
    }
    else {
        //index 1 not guaranteed
        if (even_v.size() == 1) {
            even_v.push_back(make_pair(0, 5 /*filler*/));
        }
        if (odd_v.size() == 1) {
            odd_v.push_back(make_pair(0, 5 /*filler*/));
        }
        ans = min(n - even_v[0].first - odd_v[1].first, n - even_v[1].first - odd_v[0].first);
    }
    cout << ans;
}

Measured memory_bytes: 8888
N,X,M = map(int,input().split())

d = {X:0}
l = [X]
s = X

for i in range(1,N):
  l+=[(l[i-1]**2)%M]
  s += l[i]
  if l[i] in d:
    dl = l[d[l[i]]+1:]
    s += sum(dl)*((N-i-1)//len(dl))
    if (N-i-1)%len(dl) != 0:
      s += sum(dl[0:(N-i-1)%len(dl)])
    break
  d[l[i]] = i
print(s)

Measured memory_bytes: 15628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int memo[100005];

int dfs(int N){
  if(N < 0) return 0;
  if(memo[N] != -1) return memo[N];
  int ret = 100000000;

  {
    int p = 6;
    rep(i,100000){
      if(N-p < 0) break;
      ret = min(ret, dfs(N-p) + 1);
      p *= 6;
    }
  }
  {
    int p = 9;
    rep(i,100000){
      if(N-p < 0) break;
      ret = min(ret, dfs(N-p) + 1);
      p *= 9;
    }
  }
  ret = min(ret, dfs(N-1) + 1);
  return memo[N] = ret;
}


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

  rep(i,100005){
    memo[i] = -1;
  }
  memo[0] = 0;
  memo[1] = 1;
  
  cout << dfs(N) << endl;
  
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int disc_1(int x){
    if(x==1) return 14;
    else return x;
}

int main(){
    int a, b, max_card;
    cin >> a >> b;
    a = disc_1(a);
    b = disc_1(b);

    if(a==b) out("Draw");

    else if(a>b) out("Alice");
    else out("Bob");
}


Measured memory_bytes: 256
N = int(input())
A = []
B = []
for _ in range(N):
    x, y = map(int, input().split())
    A.append(x+y)
    B.append(x-y)
    
A.sort()
B.sort()

print(max(A[N-1]-A[0],abs(B[N-1]-B[0])))

Measured memory_bytes: 99620
#include <iostream>
using namespace std;
const int N = 22;
int n,c[N],v[N];
int main() {
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    for(int i=1;i<=n;i++) scanf("%d",&c[i]), ans+=max(v[i]-c[i],0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<set>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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 = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   ll P[N + 1], pos[N + 1];
   for (int i = 0; i < N; i++) {
      cin >> P[i];
      pos[P[i]] = i + 1;
   }
   ll ans = 0;

   multiset<ll> s;
   s.insert(0);
   s.insert(0);
   s.insert(N + 1);
   s.insert(N + 1);

   for (ll now = N; now >= 1; now--) {
      auto it = s.lower_bound(pos[now]);
      
      ll pos_r = *it;
      it++;
      ll pos_rr = *it;
      it--;
      it--;
      ll pos_l = *it;
      it--;
      ll pos_ll = *it;

      ans += now * (pos_r - pos[now]) * (pos_l - pos_ll);
      ans += now * (pos_rr - pos_r) * (pos[now] - pos_l);

      s.insert(pos[now]);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

int n;
ll a;
int N;

int main()
{
  n=0;
   cin>>N;
   while(cin>>a)
  {
    if(a%2)
    n++;
  }
  if(n%2)
  puts("NO");
  else
  puts("YES");
  return 0;
}

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

#define N 30
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
int n, v[N], c[N], ans;

int main(){
    cin >> n;
    for (int i=1; i<=n; i++) cin >> v[i];
    for (int i=1; i<=n; i++) cin >> c[i];
    for (int i=1; i<(1<<n); i++){
        int v1 = 0, c1 = 0;
        for (int j=0; j<n; j++)
            if ((1<<j) & i) c1 += c[j+1], v1 += v[j+1];
        ans = smax(ans, v1 - c1);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256