akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i+=2){
    int cnt=0;
    for(int j=1;j<=i;j++){
      if(i%j==0)cnt++;
    }
    if(cnt==8)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n,w;
	while(cin>>n>>w,n||w){
		int D =100/w+1;
		int t[D] ,maxi  =0;
		for(int i =0;i< D;i++){
			t[i]  =0;
		}
		for(int i = 0;i < n;i++){
			int tmp;
			cin>>tmp;
			t[tmp/w]++;
			maxi  =max(t[tmp/w],maxi);
		}
		int cnt = 0;
		for(int i = 0;i < D;i++){
			int now = D-1-i;
			if(t[now]!=0)break;
			cnt++;
		}
		double sum = 0.01;
		int W = D-cnt;
		for(int i = 0;i < W;i++){
			sum +=((double)t[i]/maxi)*((double)(W-i-1)/(double)(W-1));
		}
		printf("%.7f\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	while (true)
	{
		int t[5];
		for (int i = 0; i < 5; ++i)
			scanf("%d", t+i);
		if (t[0] == 0)
			break;

		int c[3];
		memset(c, 0, sizeof(c));
		for (int i = 0; i < 5; ++i)
			++c[t[i]-1];
		if (c[0] && c[1] && c[2]
		|| c[0] == 5 || c[1] == 5 || c[2] == 5)
			for (int i = 0; i < 5; ++i)
				puts("3");
		else
			for (int i = 0; i < 5; ++i)
				if (c[(t[i])%3])
					puts("1");
				else
					puts("2");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
struct edge{
    ll p;//点
    ll w;//辺の重み*-1
};
vector<vector<edge> > graph(100000);
vector<ll> dis(100000);
ll v,e,r;//vは頂点,eは辺,rは始点
void dijkstra(){
  for(int i = 0;i < v;i++)dis[i] = pow(10,18);
    dis[r] = 0;
    priority_queue<pair<ll,ll> > que;//重み、頂点
    que.push(make_pair(0,r));
    while(!que.empty()){
        edge now;
        now.p = que.top().second;
        now.w = que.top().first * -1;
        que.pop();
        if(dis[now.p] < now.w)continue;
        for(int i = 0;i < (int)graph[now.p].size();i++){
            if(dis[graph[now.p][i].p] > now.w + graph[now.p][i].w){
                dis[graph[now.p][i].p] = now.w + graph[now.p][i].w;
                que.push(make_pair(dis[graph[now.p][i].p] * -1,graph[now.p][i].p));
            }
        }
    }
}
int main(){
  ll h,w;
  cin >> h >> w;
  v = 10;
  e = 100;
  vector<ll> cost(10);
  for(int i = 0;i < 10;i++){
    for(int j = 0;j < 10;j++){
      ll in;
      cin >> in;
      edge memoa = {j,in};
      graph[i].push_back(memoa);
    }
  }
  for(int i = 0;i < 10;i++){
    r = i;
    dijkstra();
    cost[i] = dis[1];
  }
  
  ll res = 0;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      ll num = 0;
      cin >> num;
      if(num == -1)continue;
      res += cost[num];
    }
  }
  cout << res << endl;
}

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};
int N;
vector<pair<int, int>> A[20];

int main() {
  
    cin >> N;
    REP(i, N) {
        int a;
        cin >> a;
        REP(k, a) {
            int x, y;
            cin >> x >> y;
            A[i].push_back(make_pair(x, y));
        }
    }
    int ans = 0;
    FOR(bit, 1, (1 << N) - 1) {
        bool frag = 0;
        int S = bit;
        REP(i, N) {
            if (S & (1 << i)) {
                REP(k, A[i].size()) {
                    int x = A[i][k].first - 1, y = A[i][k].second;
                    if ((!y && (S & (1 << x))) || (y && !(S & (1 << x)))) {
                        frag = 1;
                        break;
                    }
                }
            }
            if (frag)break;
        }
        if (frag)continue;
        ans = max(ans, (int) bitset<20>(S).count());
    }
    cout << ans << endl;


    return 0;
}


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

# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define p(s) std::cout << s << endl;

int main()
{
    int a,b,k;cin >> a >> b >> k;
    for(int i=a;i<min(a+k,b);i++){
        p(i)
    }
    for(int i=max(min(a+k,b),b-k+1);i<=b;i++){
        p(i)
    }
}

Measured memory_bytes: 256
N,Q=map(int,input().split())
S=input()
TD=[]
for q in range(Q):
	TD.append(list(map(str,input().split())))
L=S[:]
R=S[::-1]
lw=0
rw=0
ansl = 0
ansr = 0
for q in range(Q)[::-1]:
	if TD[q][1] == 'L': 
		if TD[q][0] == L[lw]: #now word is OK
			ansl = max(ansl, lw+1)
			if lw+1 == N: #all clear
				break
			else:
				lw += 1
		if rw>0: 
			if TD[q][0] == R[rw-1]: #before word is wrong
				ansr = max(ansr-1, 0)
				rw -=1
	if TD[q][1] == 'R':
		if TD[q][0] == R[rw]: #now word is OK
			ansr = max(ansr, rw+1)
			if rw+1 == N: #all clear
				break 
			else:
				rw += 1
		if lw>0: 
			if TD[q][0] == L[lw-1]: #before word is wrong
				ansl = max(ansl-1, 0)
				lw -=1


print(max(0,N-(ansr+ansl)))

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

int main() {
  long d,g,ans=1000000000000;
  cin >> d >> g;
  vector<long> p(d);
  vector<long> c(d);
  for(long i=0;i<d;i++) cin >> p[i] >> c[i];
  for(long bit=0;bit<(1<<d);bit++) {
    long aaa=0;
    long bbb=0;
    for(long i=0;i<d;i++) {
      if(bit&(1<<i)) {
        aaa+=(i+1)*p[i]*100+c[i];
        bbb+=p[i];
      }
    }
    if(aaa>=g) {
      ans=min(ans,bbb);
    } else {
      for(long i=0;i<d;i++) {
        if(!(bit&(1<<i))) {
          if(aaa+(i+1)*(p[i]-1)*100>=g) ans=min(ans,bbb+((g-aaa)/100+i)/(i+1));
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[101];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> g;
    for (int i = 0; i < h; ++i)
    {
        string s;
        cin >> s;
        bool b = false;
        for (char c : s)
            if (c == '#')
                b = true;
        if (b)
            g.push_back(s);
    }
    h = g.size();
    for (int i = 0; i < w; ++i)
        for (int j = 0; j < h; ++j)
            if (g[j][i] == '#')
                a[i] = 1;

    for (int j = 0; j < h; ++j)
    {
        for (int i = 0; i < w; ++i)
        {
            if (a[i])
                cout << g[j][i];
        }
        cout << '\n';

    }
}


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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i, n) for (ll i=0;i<(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
//using ll=long long;
typedef long long ll;
typedef pair<ll, ll> pi;

ll h,w;
ll ans;
//vector<char> masu;


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

  map<ll,ll> m;
 vector<ll> v(n);
 ll tmp;
 rep(i,n){
   cin >> tmp;
   m[tmp]++;
   v[i]=tmp;
 }

 ll S=0;
 for(auto&& x: m){
   S += x.second*(x.second-1)/2;
 }
 
 rep(i, n){
   //cout << m[v[i]]<<endl;
   tmp = S - (m[v[i]]) * (m[v[i]]-1) /2 + (m[v[i]]-1)*(m[v[i]]-2) /2; 
   cout <<tmp<<endl;

 }

  
}


Measured memory_bytes: 11776
S = input()

import sys
N = 3
for i in range(2**N):
    L = ["-", "-", "-"]
    ZZ = []
    for j in range(N):
        if ((i>>j) & 1):
            L[j] = "+"
            ZZ = [S[0], L[0], S[1], L[1], S[2], L[2], S[3]]
            if eval("".join(ZZ)) == 7:
                print("".join(ZZ) + "=7")
                sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
    REP(i,9)
        REP(j,9)
            cout << i+1 << 'x' << j+1 << '=' << (i+1)*(j+1) << '\n';
}

Measured memory_bytes: 1112
//A
#include <iostream>
using namespace std;
string n;
int main(){
  cin >> n;
  if (n.at(2) == '9'){
    n.at(2) = '1';
  } else if (n.at(2) == '1'){
    n.at(2) = '9';
  }
  if (n.at(1) == '9'){
    n.at(1) = '1';
  } else if (n.at(1) == '1'){
    n.at(1) = '9';
  }
  if (n.at(0) == '9'){
    n.at(0) = '1';
  } else if (n.at(0) == '1'){
    n.at(0) = '9';
  }
  cout << n  << endl;
  return 0;
}


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

bool check(int x){
  if( (x%10==(x/10000)%10) && ((x/10)%10==(x/1000)%10) )
  	return 1;
  return 0;
}

int main(){
  int A;
  int B;
  cin >> A >> B;
  int count=0;
  for(int i=A;i<=B;i++){
	if(check(i))
      count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    n%=10
    if n==3:print("bon")
    elif n in [0,1,6,8]:print("pon")
    else:print("hon")

main()

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


void solve(long long N, std::vector<long long> A){
    map<ll, ll> R;
    for(ll i=0; i< N; i++){
        if(!R.count(A[i])) R[A[i]] = 1;
        else R[A[i]]++;
    }
    ll cnt = 0, res = 1;
    for(auto it = R.rbegin(); it!= R.rend(); it++){
        //cout << it->first << endl;
        if(cnt == 0 && it->second >=4) {
            cout << it->first * it->first << endl;
            return;
        }
        if(it->second >=2) {
            cnt ++;
            res *= it->first;
        }
        if(cnt >= 2) break;
    }
    if(cnt >= 2)
        cout << res << endl;
    else
        cout << 0 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

using namespace std;

#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;

// 46786 - 106

void oneCase() {
    int n, a;
    cin >> n >> a;
    cout << n * n - a << "\n";
}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}


Measured memory_bytes: 256
S=input()
res=[1]*len(S)
for i in range(1,len(S)):
  if S[i-1]==S[i]=='R':
    res[i+1]+=res[i-1]
    res[i-1]=0
for i in range(len(S)-2,0,-1):
  if S[i+1]==S[i]=='L':
    res[i-1]+=res[i+1]
    res[i+1]=0
print(*res)

Measured memory_bytes: 6400
import java.util.*;

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

        int codeNum = sc.nextInt();
        int statusNum = sc.nextInt();
        int passScore = -sc.nextInt();

        int[] coefficient = new int[statusNum];
        for(int i  = 0; i < statusNum; i++)coefficient[i] = sc.nextInt();
        
        int ans = 0;
        for(int i = 0; i < codeNum; i++){
            int score = 0;
            for(int j  = 0; j < statusNum; j++){
                score += coefficient[j] * sc.nextInt();
            }
            if(score > passScore)ans++;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22484
k = int(input())
mod = 7 % k
if k % 2 == 0:
    print(-1)
else:
    ans = 1
    while mod != 0:
        mod = (10*mod + 7) % k
        ans += 1
        if ans >= 10**7:
            print(-1)
            break
    if ans < 10**7:
        print(ans)

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

int main(){
	int x1, y1, x2, y2;

	cin >> x1 >> y1 >> x2 >> y2;

	int x = x2 - x1;
	int y = y2 - y1;

	cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**7)
n,q=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n-1)]
px=[list(map(int,input().split())) for i in range(q)]

# def denpan(oya,ko):
#     for i in range(len(ne[ko])):
#         if ne[ko][i]!=oya:
#             cnt[ne[ko][i]]+=cnt[ko]
#             denpan(ko,ne[ko][i])

ne=[[] for i in range(n+1)]
for i in range(n-1):
    ne[ab[i][0]].append(ab[i][1])
    ne[ab[i][1]].append(ab[i][0])
# print(ne)
cnt=[0]*(n+1)
for i in range(q):
    cnt[px[i][0]]+=px[i][1]
par=[-1]*(n+1)
stack=deque([1])
while(stack):
    v=stack.pop()
    for i in range(len(ne[v])):
        if ne[v][i]!=par[v]:
            cnt[ne[v][i]]+=cnt[v]
            par[ne[v][i]]=v
            stack.append(ne[v][i])
cnt.remove(0)
print(' '.join(map(str,cnt)))

Measured memory_bytes: 150380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int n, k;
    cin >> n >> k;
    ll ans = 1;
    rep(i, n)
    {
        if (ans <= k)
        {
            ans *= 2;
        }
        else
        {
            ans += k;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<typename T>
struct BinaryIndexedTree{
    vector<T> data;
    int sz;

    BinaryIndexedTree(int n){
        sz = n + 2;
        data.assign(sz, 0);
    }

    void add(int i, T x){
        ++i;
        while(i < sz){
            data[i] += x;
            i += i & -i;
        }
    }

    // [0, i] の区間和
    T sum(int i){
        T res = 0;
        ++i;
        while(i > 0){
            res += data[i];
            i -= i & -i;
        }
        return res;
    }

    // [l, r) の区間和
    T sum(int l, int r){
        return sum(r - 1) - sum(l - 1);
    }

    // val 以上を満たす 0-indexed の位置を返す
    int lower_bound(T val){
        // if(val <= 0)    return -1;
        int res = 0;
        int n = 1;
        while(n < sz)   n <<= 1;
        for(int k = n >> 1; k > 0; k >>= 1){
            if(res + k < sz && data[res + k] < val){
                val -= data[res + k];
                res += k;
            }
        }
        return res;     // 1-indexed であれば、res + 1 を返す
    }
};

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

    int n, q;
    cin >> n >> q;
    vector<int> prev(n + 1, -1);
    vector<vector<int>> section(n);
    for(int i = 0; i < n; ++i){
        int c;
        cin >> c;
        if(prev[c] != -1)   section[prev[c]].emplace_back(i);
        prev[c] = i;
    }
    vector<vector<int>> qs(n);
    vector<vector<int>> idx(n);
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l, --r;
        qs[l].emplace_back(r);
        idx[l].emplace_back(i);
    }
    BinaryIndexedTree<int> bit(n);
    vector<int> ans(q);
    for(int L = n - 1; L >= 0; --L){
        for(int& R : section[L])    bit.add(R, 1);
        for(int i = 0; i < (int)qs[L].size(); ++i){
            int& R = qs[L][i];
            ans[idx[L][i]] = R - L + 1 - bit.sum(R);
        }
    }
    for(int x : ans)    cout << x << '\n';
}

Measured memory_bytes: 77576
n = int(input())
arr = []
max_index = 0
max_num = 0
for i in range(n):
  tmp = int(input())
  arr.append(tmp)
  if tmp > max_num:
    max_num = tmp
    max_index = i

list.sort(arr, reverse=True)
if arr[0] == arr[1]:
  for i in range(n):
    print(max_num)

else:
  for i in range(n):
    if max_index == i:
      print(arr[1])
    else:
      print(max_num)

Measured memory_bytes: 12532
//package B;
//B - Echo
import java.util.Scanner;

public class Main {
    private Main(int n,String st){
        int flag = 0;
        if (n%2==0) {
            for (int i = 0, j = n / 2; i < n / 2; i++, j++) {
                if (st.charAt(i) == st.charAt(j)) {
                    flag++;
                }
            }
        }
        if (flag==n/2&&n%2==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String st = scanner.next();
        Main echObj = new Main(n,st);
    }
}


Measured memory_bytes: 35392
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }

    // public static String[] <T> ToStringArray(T[] arr) {
    // String[] res = new String[arr.length];
    // for(int i = 0; i < arr.length; ++i) {
    // res[i] = String.valueOf(arr[i]);
    // }

    // return res;
    // }

    private static List<Integer> asIntergerList(int[] arr) {
        List<Integer> intList = new ArrayList<Integer>();
        for (int i = 0; i < arr.length; i++) {
            intList.add(arr[i]);
        }

        return intList;
    }

    private static int[][] deepCopy(int[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; ++i) {
            res[i] = arr[i].clone();
        }

        return res;
    }

    private static String asString(int[][] arr) {
        String str = new String();

        for (int i = 0; i < 2; ++i) {
            str += "" + arr[i][0] + arr[i][1] + arr[i][2] + arr[i][3];
        }

        return str;
    }

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        try {
            int cnt = scanner.nextInt();
            Set<String> set = new HashSet<String>();

            for (int i = 0; i < cnt; ++i) {
                String query = scanner.next();
                String str = scanner.next();

                if ("insert".equals(query)) {
                    set.add(str);
                } else {
                    System.out.println(set.contains(str) ? "yes" : "no");
                }
            }
        } catch (Exception e) {
        }
    }

}



Measured memory_bytes: 251240
unittest
{
	assert( [ "10" ].solve == 170 );		// 追加ケース
	
	assert( [ "4" ].solve == 23 );
	assert( [ "100" ].solve == 26879 );
	assert( [ "10000000" ].solve == 838627288460105 );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	auto ans = n * ( n + 1 ) / 2;
	for( auto i = 2L; i <= n; i++ )
	{
		for( auto j = 1L; i * j <= n; j++ )
		{
			ans += i * j;
		}
	}
	return ans;
}


Measured memory_bytes: 2764
import numpy as np

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

for i in range(n):
    b = int(input())

    for j in range(3):
        if b in a[j]:
            idx = a[j].index(b)
            a[j][idx] = 0

np_a = np.array(a)
np_t = np_a.T
d = 0
u = 0

for i in range(3):
    r = np_a[i]
    c = np_t[i]
    d += r[i]
    u += r[2-i]

    if r.sum() and c.sum():
        continue

    print("Yes")
    exit()


if d and u:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 27196
import java.util.Scanner;

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

		String S = scan.next();

		long count = 0;
		int n = S.length();
		String[] Srow = new String[n];

		for (int i = 0; i < n; i++) {
			Srow[i] = S.substring(i, i+1);
		}

		for (int bit = 0; bit < Math.pow(2, n-1); bit++) {

			String number = Srow[0];			//countに足す数字を作っていく（初期値は最大桁の数字）

			for (int shift = 0; shift < n-1; shift++) {		//全ビット探索：1が+を入れることに対応

				if ((1&bit>>shift) == 1) {				
					count += Long.parseLong(number);
					number = Srow[shift+1];
				} else {
					number += Srow[shift+1];
				}
				
			}

			count += Long.parseLong(number);
			
		}

		System.out.println(count);

	}
}

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

int main(){
  ll n,i,k;
  ll min = 3000000000000;
  cin >> n;
  k = sqrt(n)/1 + 1;
  for(i = 1 ;i <= k ;i++){
  	if(n % i == 0 && (n/i + i) < min){
    	min = n/i + i -2;
    }
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
cnt = Hash.new(0)
n.times do |i|
    cnt[a[i]] += 1
end
b = cnt.keys.sort
if !((b[-1].even? && b[0] == b[-1]/2 && cnt[b[0]] == 1) || (b[-1].odd? && b[0] == (b[-1]+1)/2 && cnt[b[0]] == 2)) || b.size-1 != b[-1]-b[0] || (b[-1] == 1 && n > 2)
    puts "Impossible"
    exit
end
b[1..-1].each do |num|
    if cnt[num] < 2
        puts "Impossible"
        exit
    end
end
puts "Possible"

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

int main(int argc, char *argv[]) {
#ifdef VLAD_LOCAL
    //FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
#else
    //FILE *f = stdin;
    istream &f = cin;
#endif
    int n, m, x;
    f >> n >> m >> x;
    vector<vector<int>> a(n);
    for (int i = 0; i < n; i++) {
        a[i].resize(m + 1);
        for (int j = 0; j <= m; j++)
            f >> a[i][j];
    }
    int size = 1 << n;
    vector<vector<int>> d(m + 1);
    for (int i = 0; i <= m; i++) {
        d[i].resize(size);
        d[i][0] = 0;
    }
    for (int i = 0; i < n; i++) {
        size = 1 << i;
        for (int j = 0; j <= m; j++) {
            for (int u = 0; u < size; u++)
                d[j][size + u] = d[j][u] + a[i][j];
        }
    }
    size = 1 << n;
    int answer = -1;
    for (int i = 0; i < size; i++) {
        bool yes = true;
        for (int j = 1; j <= m; j++) {
            if (d[j][i] < x) {
                yes = false;
                break;
            }
        }
        if (yes) {
            if (answer < 0 || d[0][i] < answer)
                answer = d[0][i];
        }
    }
    printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 3936
#include<stdio.h>
main()
{   int N,a,b,c,d,e;
scanf("%d",&N);
     if (N < 10)
        printf("%d",N);
    else if (N / 10 < 10)
        {   a=9;
            printf("%d",a);}
    else if (N / 100 < 10)
        {
            b=(9 + N - 99);
            printf("%d",b);
        }
    else if (N / 1000 < 10)
        {
            c=(9+900);
            printf("%d",c);
        }
    else if (N / 10000 < 10)
       {

        d= (909 + N - 9999);
    printf("%d",d);
       }
        else {e=90909;
        printf("%d",e);
        }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include <cstdlib>
using namespace std;

typedef unsigned long long ull;

const ull X = 100001;
const ull Y = 9973;
const int MAX = 1005;

ull hash1[MAX][MAX];
ull hash2[MAX][MAX];

void hashCalc(char T[MAX][MAX],int H,int W,int R, int  C) {
	//x???X???C???
	ull x = 1;
	for (int i = 0; i < C; i++) {
		x *= X;
	}

	ull y = 1;
	for (int i = 0; i < R; i++) {
		y *= Y;
	}
	
	for (int i = 0; i < H; i++) {
		ull h = 0;
		for (int j = 0; j < C; j++) {
			h = h*X + T[i][j];
		}
		for (int k = 0; k + C <= W; k++) {
			hash1[i][k] = h;
			h = h*X + T[i][k + C] - T[i][k] * x;
		}
	}

	for (int j = 0; j + C <= W; j++) {
		ull h = 0;
		for (int i = 0; i < R; i++) {
			h=h*Y+hash1[i][j];
		}
		for (int k = 0; k + R <= H; k++) {
			hash2[k][j] = h;
			h = h*Y + hash1[k + R][j] - hash1[k][j] * y;
		}
	}
}

int main() {
	string s,t;
	
	int H, W;
	cin >> H >> W;
	char T[MAX][MAX];
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> T[i][j];
		}
	}

	int R, C;
	cin >> R >> C;
	char P[R][C];
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) {
			cin >> P[i][j];
		}
	}

	ull tmp[R];

	hashCalc(T, H, W, R, C);
	
	for (int i = 0; i < R; i++) {
		ull h = 0;
		for (int j = 0; j < C; j++) {
			h = h*X + P[i][j];
		}
		tmp[i] = h;
	}

	ull hs = 0;
	for (int i = 0; i < R; i++) {
		hs = hs*Y + tmp[i];
	}

	for (int i = 0; i + R <= H; i++) {
		for (int j = 0; j + C <= W; j++) {
			if (hash2[i][j]==hs) {
				cout << i << " " << j << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 17900
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int x,y;
    cin >> x >> y;
    int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
    if(a[x]==a[y])cout << "Yes" << endl;
    else puts("No");
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,x,i,j,k,sum=0;
    for(;;){
        scanf("%d %d",&n,&x);
        if(n==0 && x==0){break;}

    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
                //if(i==j) {continue;}
            for(k=j+1;k<=n;k++){
                    //if(i==k || j==k){ continue;}
                if(i+j+k==x){ sum++;}
            }
        }
    }
    printf("%d\n",sum);
    sum=0;
    }



    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
namespace LCY{
    #define double long double
    const double EPS=1e-10;
    inline int dcmp(double x){if(fabs(x)<EPS)return 0;return (x<0)?-1:1;}
    struct Point{double x,y;Point(double _x=0,double _y=0){x=_x;y=_y;}};
    struct Vector{double x,y;Vector(double _x=0,double _y=0){x=_x;y=_y;}};
     
    Vector operator - (Point a,Point b){return Vector(a.x-b.x,a.y-b.y);}
    Vector operator * (Vector a,double d){return Vector(a.x*d,a.y*d);}
    Point operator + (Point a,Vector b){return Point(a.x+b.x,a.y+b.y);}
     
    inline double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
    inline double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
    inline double norm(Vector a){return dot(a,a);}
     
    struct Line{
        Point p1,p2;
        Line(Point _p1=Point(0,0),Point _p2=Point(0,0)){p1=_p1;p2=_p2;}
    };
     
    Point project(Line l,Point p){
        Vector base=l.p2-l.p1;
        double r=dot(p-l.p1,base)/norm(base);
        return l.p1+base*r;
    }
}
using namespace LCY;
int main(){
    Point p1,p2;cin>>p1.x>>p1.y>>p2.x>>p2.y;
    int n;cin>>n;while(n--){
        Point q;cin>>q.x>>q.y;Point res=project(Line(p1,p2),q);
        cout<<setiosflags(ios::fixed)<<setprecision(10)<<res.x<<" "<<res.y<<endl;
    }
    return 0;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return t*t;
    return t*t*a;
}
//library end
int n,m;
int c[7];
signed main(){
    cin>>n>>m;
    rep(i,n+1)c[i]=-1;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        if(c[x]==-1||c[x]==y)c[x]=y;
        else{
            cout<<-1<<endl;
            return 0;
        }
        
    }
    if(m==0){
        if(n==1)cout<<0;
        else{
            cout<<1;
            rep(i,n-1)cout<<0;
            cout<<endl;
        }
        return 0;
    }
    if(c[1]==0&&n!=1){
        cout<<-1<<endl;
        return 0;
    }
    if(c[1]==-1&&n!=1){
        c[1]=1;
    }
    rep(i,n){
        if(c[i+1]==-1)cout<<0;
        else cout<<c[i+1];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

void solve(){
    int n; cin >> n;
    vector<tuple<string, int, int>> vt;
    REP(i, n){
        string s;
        int p;
        cin >> s >> p;
        vt.pb(make_tuple(s, -p, i+1));
    }
    sort(vt.begin(), vt.end());

    for(auto x : vt){
        cout << abs(get<2>(x)) << endl;
    }
}

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

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

int main() {
  int n;
  cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for (auto& p : mp) {
    int s = p.second;
    ans += (ll)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll a, b, c;
  cin >> a >> b >> c;

  cout << min(c, b / a) << endl;

  return 0;
}


Measured memory_bytes: 256
#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;
using P = pair<int,int>;

int main() {
    int A, B, m;
    cin >> A >> B >> m;
    vector<int> a(A), b(B);
    rep(i, A) cin >> a[i];
    rep(i, B) cin >> b[i];
    int ans = 1001001001;
    rep(i, m) {
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x]+b[y]-c);
    } 
    sort(all(a));
    sort(all(b));
    ans = min(ans, a[0]+b[0]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

    def roots(self):
        return [self.root(i) for i in range(self.N)]

    def groupcount(self):
        return len(set(self.roots()))

N, M = map(int, input().split())
edges = [[int(x) - 1 for x in input().split()] for _ in range(M)]

ans = 0

# 全てのedgeに対して
for i in range(M):
    # UnionFind木を初期化
    forest = UnionFind(N)

    # i番目のエッジを除いたものをつなぐ
    for i, j in edges[:i] + edges[i+1:]:
        forest.unite(i, j)

    # 全てのノードがつながっている <=> グループ数は1
    # グループ数（島の数）が１ではない <=> グラフは２つ以上の島から成る
    if forest.groupcount() != 1:
        ans += 1

print(ans)

Measured memory_bytes: 9276
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int n,i;
string s,t;

int main(){
  cin >> n >> s >> t;
  for (i = 0; i < n; i++) {
    if(s.substr(i,n-i) == t.substr(0,n-i)) break;
  }
  cout << i+n << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=3;i<=n;i++)
using namespace std;
int main(){
  int n,P[10000],cnt=0;
  int x;
  scanf("%d",&n);
  REP(i,n){
    scanf("%d",&x);
    if(x==2) cnt++;
    else if(x%2==0) continue;
    else{
      int a=1;
      REPP(j,sqrt(x)){
        if(x%j==0) a=0;
      }
      if(a==1) cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

bool comp(pair<pair<int,int>,pair<int,int>> a, pair<pair<int,int>,pair<int,int>> b){
    return a.sc.fs < b.sc.fs;
}

int main(void){
    int n;
    cin >> n;
    vector<pair<pair<int,int>,pair<int,int>>> edge;
    vector<vector<int>> tree(n, vector<int>());
    int a,b;
    rep(i,n-1){
        cin >> a >> b;
        edge.push_back(make_pair(make_pair(a-1,b-1),make_pair(i,0)));
    }
    sort(all(edge));
    rep(i,n-1){
        tree[edge[i].fs.fs].push_back(edge[i].fs.sc);
    }
    int color = tree[0].size();
    rep(i,n-1){
        color = max(color, (int)tree[i+1].size()+1);
    }
    vector<int> used(n,1);
    vector<int> par(n,0);
    cout << color << endl;
    rep(i,n-1){
        a = edge[i].fs.fs;
        b = edge[i].fs.sc;
        if(used[a] == par[a]){
            used[a]++;
        }
        par[b] = used[a];
        edge[i].sc.sc = used[a]++;
    }
    sort(all(edge), comp);
    rep(i,n-1){
        cout << edge[i].sc.sc << endl;
    }
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    bool can = false;
    REP(i,9){
        int a = 9-i;
        if(N % a == 0){
            if(N / a < 10) can = true;
            break;
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int a, b;
  cin >> a >> b;
  for(int i = a * 5; i < a * 100; i++) {
    if((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
#define fr(c,a,b) for(int c=a;c<=b;c++)
#define rf(c,a,b) for(int c=a;c>=b;c--)
const int Max=100010;
const int Min=-1;
using std::sort;
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
int abs(int x){return x>0?x:-x;}
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
int n=read(),t=read(),sum,ans,maxn1,maxn2;
int a[Max];
int main()
{
	fr(i,1,n)a[i]=read();
	rf(i,n,1)
	{
		maxn1=max(a[i],maxn1);
		sum=max(maxn1-a[i],sum);
	}
	rf(i,n,1)
	{
		maxn2=max(a[i],maxn2);
		if(maxn2-a[i]==sum)++ans;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <complex>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <sstream>
#include <numeric>
#include <functional>
#include <bitset>
#include <iomanip>

using namespace std;

// INF
#define IINF (INT_MAX/2)
#define INF (1<<29)

// math
#define SQ(x) ((x)*(x))

// container utility
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair
#define PB push_back
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

// rep
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) REP(i,0,n)

// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;

typedef long long ll;

// conversion
template<class T> inline string toStr(T a) { ostringstream oss; oss << a; return oss.str(); }
inline int toInt(string s) { return atoi(s.c_str()); }

// prime
bool isPrime(int a) { for(int i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

// dx, dy
int const dx[] = {-1,0,1,0,-1,1,1,-1};
int const dy[] = {0,-1,0,1,-1,-1,1,1};

// inRange
inline bool inRange(int x, int y, int W, int H) {
  return 0<=x && x<W && 0<=y && y<H;
}

// isPalindrome
inline bool isPalindrome(string s) {
  return equal(s.begin(), s.end(), s.rbegin());
}

int check(char grid[2][2]) {
  if(grid[0][0] == '#'
     && grid[0][1] == '.'
     && grid[1][0] == '.'
     && grid[1][1] == '.') {
    return +1;
  }
  
  if(grid[0][0] == '.'
     && grid[0][1] == '#'
     && grid[1][0] == '#'
     && grid[1][1] == '#'
  ) {
    return +1;
  }
  
  if(grid[0][0] == '#'
     && grid[0][1] == '#'
     && grid[1][0] == '#'
     && grid[1][1] == '.'
  ) {
    return -1;
  }

  if(grid[0][0] == '.'
     && grid[0][1] == '.'
     && grid[1][0] == '.'
     && grid[1][1] == '#'
  ) {
    return -1;
  }
  
  return 0;
}

int main() {
  
  int H, W;
  while(cin >> H >> W) {
    H+=2, W+=2;
    vector<vector<char>> G(H, vector<char>(W, '.'));
    REP(i, 1, H-1) {
      REP(j, 1, W-1) {
        cin >> G[i][j];
      }
    }
    
    vector<pair<double, int>> event;
    
    // rep(i, H) {rep(j, W) {cout << G[i][j];}cout << endl;}
    
    rep(i, H-1) {
      rep(j, W-1) {
        
        char grid[2][2];
        grid[0][0] = G[i][j];
        grid[0][1] = G[i][j+1];
        grid[1][0] = G[i+1][j];
        grid[1][1] = G[i+1][j+1];
        
        int num = check(grid);
        if(num!=0) {
          double ang = atan2((H-2)-i, j);
          event.PB(MP(atan2((H-2)-i, j), num));
        }
        
      }
    }
    
    sort(ALL(event));
    
    int mx = 1;
    int cnt = 1;
    for(auto e : event) {
      cnt += e.second;
      mx = max(mx, cnt);
    }
    cout << mx << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3580
N,M = map(int,input().split())
ans = ('IMPOSSIBLE')
f1tob = []
fbtoN = []
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        f1tob.append(b)
    elif b == N:
        fbtoN.append(a)
f1toba = set(f1tob)
fbtoNa = set(fbtoN)
if bool(fbtoNa & f1toba):
    ans = 'POSSIBLE'
print(ans)

Measured memory_bytes: 27708
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define fi first
#define se second
#define vec vector
const double eps=1e-6;
const int inf=0x3f3f3f3f;
#define N int(1e5+5)

int cnt[N],n;

void solve(){
	scanf("%d",&n);
	for (int i = 0; i < n; ++i){
		int t;
		scanf("%d",&t);
		cnt[t]++;cnt[t+1]++;
		cnt[t+2]++;
	}
	int c=0,num=0;
	for (int i = 0; i < N; ++i){
		if(c<cnt[i]){
			c=cnt[i];
			num=i-1;
		}
	}
	printf("%d\n",c);
}

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


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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int mod;
typedef vector<vint>mat;
mat mul(mat A,mat B){
    mat C(A.size(),vint(B[0].size()));
    rep(i,C.size()){
        rep(j,C[0].size()){
            rep(k,A[0].size()){
                (C[i][j]+=A[i][k]*B[k][j])%=mod;
            }
        }
    }
    return C;
}
mat mat_pow(mat A,int m){
    mat B(A.size(),vint(A.size()));
    rep(i,B.size())B[i][i]=1;
    while(m){
        if(m&1)B=mul(B,A);
        A=mul(A,A);
        m>>=1;
    }
    return B;
}

int N,A,B,C,T;
int S[50];
void solve(){
    rep(i,N)cin>>S[i];
    mat M(N,vint(N));
    rep(i,N){
        if(i)M[i][i-1]=A;
        M[i][i]=B;
        if(i+1<N)M[i][i+1]=C;
    }

    mat X(N,vint(1));
    rep(i,N)X[i][0]=S[i];



    X=mul(mat_pow(M,T),X);
    rep(i,N){
        if(i)cout<<" ";
        cout<<X[i][0];
    }cout<<endl;
}

signed main(){
    while(cin>>N>>mod>>A>>B>>C>>T,N||mod||A||B||C||T)solve();
    return 0;
}

Measured memory_bytes: 3280
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<int, int> iP;

typedef pair<double, double> dP;

int main(){
  
  string line;
  int l[10];
  
  while(~scanf("%d,", l)){
    int v1, v2;
    vector <dP> t1(10);
    vector <dP> t2(10);
    int l1[10] = {}, l2[10] = {};
    
    for(int i = 1; i < 10; i++) 
      scanf("%d,", l + i);
    scanf("%d,%d", &v1, &v2);
    
    l1[0] = l[0], l2[9] = l[9];
    for(int i = 1; i < 10; i++){
      l1[i] += l1[i - 1] + l[i];
      l2[9 - i] += l2[9 - i + 1] + l[9 - i];
    }
     
    double begin = 0;
    for(int i = 0; i < 10; i++){
      t1[i].fr = begin;
      t1[i].sc = (double)l1[i] / v1;
      begin = (double)l1[i] / v1;
    }

    begin = 0;
    for(int i = 9; i >= 0; i--){
      t2[i].fr = begin;
      t2[i].sc = (double)l2[i] / v2;
      begin = (double)l2[i] / v2;
    }

    for(int i = 0; i < 10; i++){
      if(!(t1[i].fr > t2[i].sc || t2[i].fr > t1[i].sc)){
        cout << i + 1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 1208
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll X;
  cin >> X;
  ll Y = 100;
  ll cnt = 0;
  while(Y < X){
    cnt++;
    Y = Y*1.01;
  }
  cout << cnt << endl;
 }


Measured memory_bytes: 3612
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Control.Monad.ST
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int
solve !n =
  sum
    $ filter (\m -> n `div` m == n `mod` m)
    $ map (\k -> n `div` k - 1)
    $ takeWhile (\k -> k + k ^ 2 <= n) [1 ..]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  print $ solve n


Measured memory_bytes: 380