akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string S;
  cin >> S;
  ll N = S.size();
  vl A(N + 1, 0);
  REP(i, N) {
    if (S[i] == '<' && A[i + 1] <= A[i])
      A[i + 1] = A[i] + 1;
  }
  REP(i, N) {
    if (S[N - 1 - i] == '>' && A[N - i] >= A[N - i - 1])
      A[N - i - 1] = A[N - i] + 1;
  }
  ll ans = 0;
  REP(i, N + 1) ans += A[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4764
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000000000000;
const double PI = acos(-1);

int main() {
	int x, t;
	cin >> x >> t;
	cout << (x - t < 0 ? 0 : x - t) << endl;
}

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

public class Main {

  private static void solve() {
    int n = ni();
    int m = ni();
    char[] s = ns();

    List<Integer> ret = new ArrayList<>();
    int cur = n;
    outer: while (cur > 0) {
      for (int i = Math.max(0, cur - m); i < cur; i++) {
        if (s[i] == '0') {
          ret.add(Math.abs(i - cur));
          cur = i;
          continue outer;
        }
      }
      System.out.println(-1);
      return;
    }

    Collections.reverse(ret);
    StringBuilder sb = new StringBuilder();
    for (int v : ret) {
      sb.append(v + " ");
    }
    System.out.println(sb);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 32468
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

ifstream in("data.txt");
ofstream out("result.txt");

int main(int argc, const char * argv[]) {
    // insert code here...
    int n, a;
    cin >> n >> a;
    
    int div = n % 500;
    
    if (div <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		scn.nextLine();
		char[] str = scn.nextLine().toCharArray();
		int N = str.length;
		int[] e_num = new int[N];
		int num = 0;
		for (int i = 0; i < N; i++) {
			if (str[i] == 'E') {
				num++;
			}
			e_num[i] = num;
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
			if (i == 0) {
				ans = e_num[N-1] - e_num[i];
			} else {
				ans = Math.min(ans, e_num[N - 1] - e_num[i] + i - e_num[i - 1]);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 30804
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;
using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    int ans=0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=a; j++){
            int k=b-i-j;
            if(0<=k&&k<=a)ans++;
            
        }
    }
    cout<<ans<<endl;
    
}


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

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<long long> A(X);
    for (int i = 0; i < X; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    vector<long long> B(Y);
    for (int i = 0; i < Y; i++)
    {
        cin >> B[i];
    }
    sort(B.begin(), B.end());

    vector<long long> C(Z);
    for (int i = 0; i < Z; i++)
    {
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    vector<int> num{X, Y, Z};
    vector<vector<long long>> cake{A, B, C};
    vector<vector<vector<bool>>> used(X, vector<vector<bool>>(Y, vector<bool>(Z, false)));

    priority_queue<pair<long long, vector<int>>> que;
    que.push(make_pair(
        A.back() + B.back() + C.back(),
        vector<int>{X - 1, Y - 1, Z - 1}));

    for (int i = 0; i < K; i++)
    {
        long long cost = que.top().first;
        int x = que.top().second[0];
        int y = que.top().second[1];
        int z = que.top().second[2];
        que.pop();

        if (used[x][y][z])
        {
            i--;
            continue;
        }
        else
        {
            used[x][y][z] = true;
        }

        for (int j = 0; j < 3; j++)
        {
            vector<int> idx{x, y, z};
            if (idx[j] > 0)
            {
                idx[j]--;
                que.push(make_pair(
                    cost + cake[j][idx[j]] - cake[j][idx[j] + 1],
                    idx));
            }
        }
        cout << cost << endl;
    }
}


Measured memory_bytes: 180352
n, m = map(int, input().split())

s = []
e = []
for _ in range(m):
  a, b = map(int, input().split())
  if a == 1:
    s.append(b)
  if b == n:
    e.append(a)

if set(s) & set(e):
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    map<string, int> m;
    int mx = 0;
    rep(i, n) {
        m[s[i]]++;
        mx = max(mx, m[s[i]]);
    }
    vector<string> ans;
    rep(i, n) {
        if (m[s[i]] == mx) {
            ans.push_back(s[i]);
            m[s[i]]--;
        }
    }
    sort(ans.begin(), ans.end());
    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 28404
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int i,j,data;
	for(i = 1;i <= 9;i ++){
		for(j = 1; j <= 9;j++){
			data = i * j;
			printf("%dx%d=%d\n",i,j,data);
		}
	}
	return 0;
}

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

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

  int A, B; cin >> A >> B;

  cout << 100 << " " << 100 << "\n";

  vector<string> ans;
  int count;

  ans.assign(50, string(100, '#'));
  count = 0;
  for (int i = 0; i < 50; i++) {
    if (count < A - 1 && i % 2 == 0) {
      for (int j = 0; j < 100; j += 2) {
        ans[i][j] = '.';
        if (++count == A - 1) break;
      }
    }
    cout << ans[i] << "\n";
  }

  ans.assign(50, string(100, '.'));
  count = 0;
  for (int i = 0; i < 50; i++) {
    if (count < B - 1 && i % 2) {
      for (int j = 0; j < 100; j += 2) {
        ans[i][j] = '#';
        if (++count == B - 1) break;
      }
    }
    cout << ans[i] << "\n";
  }
}

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

input_list = input().split()

cnt7 = 0
cnt5 = 0

for n in input_list:
    if int(n) == 7:
        cnt7 += 1
    elif int(n) == 5:
        cnt5 += 1
    else:
        continue
if cnt7 == 1 and cnt5 == 2:
    print("YES")
else:
    print("NO")
  

Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        boolean bool = true;
        for (long a=-118;a<=119&&bool;a++){
            for (long b=-119;b<=118&&bool;b++){
                if (a*a*a*a*a-b*b*b*b*b==x){
                    System.out.println(a+" "+b);
                    bool=false;
                }
            }
        }
    }
}


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

ll N;
vector<ll> v;

int main() { 
    cin >> N;
    v.resize(N);
    for(int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    ll out = v[0];
    for (int i = 1; i < N; i++){
      out = (out + v[i]) / 2;
    }
    cout <<fixed << setprecision(5) << out << endl;
    return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<string>
#include<map>
#include<cstdlib>
using namespace std;

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

const int inf = 100000000;
int dist[205][205];

int main() {
  int N,i,c,j,k;
  string s,t,u,v,eq;
  while(cin>>N, N) {
    map<string,int> mp;

    rep(i,205) {
      rep(j,205) dist[i][j] = inf;
      dist[i][i] = 0;
    }

    c = 0;
    rep(i,N) {
      cin>>v>>s>>eq>>u>>t;
      u = u.substr(3);
      int w = atoi(u.c_str());
      if(mp.find(s) == mp.end()) {
	mp[s] = c;
	c++;
      }
      if(mp.find(t) == mp.end()) {
	mp[t] = c;
	c++;
      }
      dist[mp[s]][mp[t]] = w;
      dist[mp[t]][mp[s]] = -w;
    }

    rep(k,c)
      rep(i,c) rep(j,c)
        dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);

    rep(i,c) {
      if(dist[i][i] < 0) {
	cout<<"No"<<endl;
	goto NEXT;
      }
    }

    cout<<"Yes"<<endl;
  NEXT:
    ;
  }
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------


signed main(){
string s;
int a,b,c,ans=0;
	cin>>s;
	int l=s.length();
	b=-3,
	a=10000;
	
	for(int i=0;i<l;i++){
		if(s[i]=='C') a=min(a,i);
		if(s[i]=='F') b=max(b,i);
	}
	if(a<b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
//	cout<<ans<<endl;
	return 0;
}

//printf("%.10f\n",ans);


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void print(T x){cout << x << endl;}
template<class T>void printvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
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; }
 
int main()
{
    int k, n; cin >> k >> n;
    vector<int> a(n), next_dist(n);
    rep(i, n) cin >> a[i];

    int max_dist=0;
    rep(i, n-1) {
        next_dist[i] = a[i+1] - a[i];
        chmax(max_dist, next_dist[i]);
    }
    next_dist[n-1] = k+a[0] - a[n-1];
    chmax(max_dist, next_dist[n-1]);

    print(k-max_dist);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;
  ll ans = 0;
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for(int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    pq.push(a);
    ans += a;
  }
  
  vector<pair<ll, ll>> list(M); // 値,件数
  for(int i = 0; i < M; i++) {
    cin >> list[i].second >> list[i].first;
  }
  sort(list.begin(), list.end(), greater<>());
//  cout << ans << endl;
  
  for(int i = 0; i < M; i++) {
    ll v = pq.top();
    for (int j = 0; j < list[i].second; j++) {
      if (v < list[i].first) {
        pq.pop();
        pq.push(list[i].first);
        ans -= v;
        ans += list[i].first;
        v = pq.top();
//        cout << v << " " << list[i].first << " " << ans << endl;
      } else {
        break;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2676
#define NDEBUG

#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <random>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <tuple>
#include <set>
#include <map>

// [0, max)
#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
// [min, max)
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
// [min, max)
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))

#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

// a < b < c
#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
// a <= b < c
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
// a < b <= c
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
// a <= b <= c
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

#ifndef NDEBUG
#  define MASSERT(cond) m_assert(cond, __LINE__, #cond);
#else
#  define MASSERT(...)
#endif

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;
using ull = __uint128_t;

using sc = signed char;
using si = signed int;
using sl = signed long long int;
using sll = __int128_t;

using ld = long double;

void m_assert(const bool& cond, const sl& line, const char *condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}

namespace std {
  template <>
  struct is_integral<__int128_t> {
    constexpr static bool value = true;
  };
};

static sl N;
static vector<string> Si;

void solve(void) {
  map<string, sl> F;
  sl max_count = 0;
  FOR0(i, N) {
    if (F.count(Si[i]) == 0) {
      F.emplace(Si[i], 0);
    }
    F[Si[i]]++;
    max_count = max(max_count, F[Si[i]]);
  }
  FORITER(F, it) {
    if (it->second == max_count) {
      cout << it->first << endl;
    }
  }
}

int main(void) {
  cin >> N;
  Si.resize(N);
  FOR0(i, N) {
    cin >> Si[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int n, k;
    cin >> n >> k;
    map<int, int> mp;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        mp[a]++;
    }

    int typs = 0;
    priority_queue<int, vector<int>, greater<int>> pq;
    for(int i=0; i<=200000; i++){
        if(mp[i] > 0){
            typs++;
            pq.push(mp[i]);
        }
    }

    int ans = 0;
    while(typs > k){
        typs -= 1;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);
  int ans = 0;
  rep(i, n){
    rep2(j, i+1, n){
      rep2(k, j+1, n){
        if(l.at(i) < l.at(j)+l.at(k) && l.at(j) < l.at(i) + l.at(k) && l.at(k) < l.at(i) + l.at(j)){
          if(l.at(i) == l.at(j) || l.at(j) == l.at(k) || l.at(k) == l.at(i)) continue;
          // cerr << l.at(i) << " " << l.at(j) << " " << l.at(k) << endl;
          // cerr << i << " " << j << " " << k << endl;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n; cin >> n;
    int k = n % 10;
    if (k == 2 || k == 4 || k == 5 || k == 7 || k == 9) {
        cout << "hon" << endl;
    } else if (k == 0 || k == 1 || k == 6 || k == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
    double a,b,c,d,e,f;
    double x,y;
     
    while(cin >> a >> b >> c >> d >> e >> f){
        y = (f*a-c*d)/(e*a-b*d);
        x = (c-b*y)/a;
        printf("%.3lf %.3lf\n",x,y);
    }
}

Measured memory_bytes: 1236
#include<stdio.h>
int main()
{
  long int c;
    scanf("%ld",&c);

   long int A=c/500;
    long int ModA=c%500;
    long int B=ModA/5;

    long int C=(A*1000)+(B*5);

    printf("%ld\n",C);
    return 0;
}


Measured memory_bytes: 128
import queue
N,M = map(int,input().split())
adj = [[]for i in range(N+1)] #どこの部屋とどこの部屋が繋がっているかを表す、N＋1の理由は、部屋番号とインデックスが一個ずれてるから
parent = [-1] * (N+1) #-1なら未訪問、N+1な理由は同様である
for m in range(M):
    a,b = map(int,input().split())
    adj[a].append(b) #お互いの場所を書く、繋がっているかを記録する
    adj[b].append(a) #こっちにもお互いの場所を書く
q = queue.Queue() #記録するようのトンネルみたいなもの、入ったものから出ていく感じ、自分の部屋番号、親の部屋番号（ただ作っただけ）
q.put((1,0)) # 部屋1の親は部屋0と考える（二個ぶち込んでる) 
while(not q.empty()): #もう探索の候補がqueueに入ってこなくなったら終わり
    x, p = q.get() #探索の候補を受け取る、一回取り出したらもう抜ける
    if parent[x] != -1: #-1じゃなくて変えられていたら訪問済みでスキップ
        continue
    parent[x] = p #親を示しているリストを更新する
    for next in adj[x]: #今いる場所に繋がっている部屋を全てループする
        if parent[next] == -1: # 未訪問なら
            q.put((next,x)) # 探索候補に追加、これがもう全て-1じゃなくて回りきったら終わりとする
print ('Yes') # 必ず目標は達成できる
for p in parent[2:]: # 部屋2以降の親（前の部屋）
    print(p)

Measured memory_bytes: 40064
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int max;
    if(a>b)max=a;
    if(a<=b)max=b;
    int ok=0;
    int answer;
    for(int i =0;i<max;i++){
        if(a-i==i-b){
            ok++;
            answer=i;
        }else if(i-a==i-b){
            ok++;
            answer=i;
        }
    }
    if(ok!=0)cout<<answer;
    else cout<<"IMPOSSIBLE";
}

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

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 *
 */
public class Main implements Runnable { //クラス名はCountABC

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerCountABC sc = new FastScannerCountABC(System.in);

		try {
			int N = sc.nextInt();
			String S = sc.nextLine().trim();

			S = S.replace("ABC", "0");

			int count = 0;

			for (int i = 0; i < S.length(); i++) {
				//System.out.println(S.substring(i, i + 1));
				if (S.substring(i, i + 1).equals("0")) {
					count++;
				}
			}

			System.out.println(count);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerCountABC {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerCountABC(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

int main() {
    int N, Q;
    std::string S;
    std::cin >> N >> Q >> S;

    std::vector<uint64_t> points;
    for (std::size_t i = 0; i < S.size() - 1; ++i) { 
        if (S[i] == 'A' && S[i+1] == 'C') {
            points.push_back(i);
        }
    }

    int l, r;
    for (std::size_t i = 0; i < Q; ++i) {
        std::cin >> l >> r;
        l -= 1;
        r -= 2;

        auto begin = std::lower_bound(points.begin(), points.end(), l);
        auto end   = std::upper_bound(points.begin(), points.end(), r);

        std::cout << std::distance(begin, end) << std::endl;
    }

    return 0;
}


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

int main()
{
  int N, L[10];
  cin >> N;
  for(int i = 0; i < N; i++)
  {
    cin >> L[i];
  }
  
  int M = 0; int sum = 0;
  
  for(int i = 0; i < N; i++)
  {
    sum += L[i];
    if(M < L[i])
    {
      M = L[i];
    }
  }
  
  if(M < sum - M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string s;
    int K;
    cin >> s >> K;
    vector<string> str;
    for(int i=0;i<s.length();i++){
        for(int j=1;j<=5;j++){
            str.push_back(s.substr(i,j));
        }
    }
    sort(str.begin(),str.end());
    str.erase(unique(str.begin(),str.end()));
    cout << str[K-1] << endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Here your code !
    int N, buf;
    cin >> N;
    vector<int> b = vector<int>(N);
    for(int i=0; i<N; i++){
        cin >> buf;
        if(i%2 == 0){
            b[N/2 + i/2] = buf;
        }else{
            b[N/2 - i/2 - 1] = buf;
        }
    }
    if(N%2 == 1){
        for(int i =N-1; i>=0; i--){
            cout << b[i] << " "; 
        }
    }else{
        for(int i=0; i<N; i++){
            cout << b[i] << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#61 カードゲーム

n = int(input())
a1 = b1 = 0

for i in range(n):
    
    a,b = input().split()
    
    if a > b:
        a1 += 3
        
    elif a < b:
        b1 += 3
        
    elif a == b:
        a1 += 1
        b1 += 1
        
print(a1, b1)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s; cin >> s;
    int ans = 10000;
    rep(i, sz(s)-2) {
        int num = 100*(s[i]-'0')+(s[i+1]-'0')*10+s[i+2]-'0';
        chmin(ans, abs(753-num));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	a[0]-=32;
	b[0]-=32;
	c[0]-=32;
	cout<<a[0]<<b[0]<<c[0]<<endl;
}


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

struct edge{int from,to,cost;};
const int INF = 1000000000;
int v,e,r;
vector<edge> E;
int d[1000];

int main(){
  scanf("%d %d %d",&v,&e,&r);
  for(int i=0;i<e;i++){
    edge tmp;
    scanf("%d %d %d",&tmp.from,&tmp.to,&tmp.cost);
    E.push_back(tmp);
  }
  fill(d,d+v,INF);
  d[r] = 0;
  int t = 0;
  while(true){
    bool flag = true;
    for(int i=0;i<E.size();i++){
      if(d[E[i].from]!=INF&&d[E[i].from]+E[i].cost<d[E[i].to]){
        d[E[i].to] = d[E[i].from]+E[i].cost;
        flag = false;
      }
    }
    if(flag) break;
    if(t>v+5){
      printf("NEGATIVE CYCLE\n");
      return 0;
    }
    t++;
  }
  for(int i=0;i<v;i++){
    if(d[i]==INF) printf("INF\n");
    else printf("%d\n",d[i]);
  }
  return 0;
}

Measured memory_bytes: 2788
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();

        int n = sc.nextInt();
        for (int i=0; i<n; i++) {
            A.add(sc.nextInt());
        }
        for (int i=n-1; i>=0; i--) {
            System.out.print(A.get(i));
            if (i != 0)
                System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26356
#include <bits/stdc++.h>
#define endl '\n'


//This solution is  recursive but slow

using namespace std;

int main() { 
    int n; cin >> n;
    int jumps[n];
    vector<int> dp(n, 0); // dp[i] : Minimum cost for the frog to reach position i.
    for (int i = 0; i < n; i++) cin >> jumps[i];
    dp[1] = abs(jumps[1] - jumps[0]); // Base value
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(jumps[i] - jumps[i - 1]) + dp[i - 1], abs(jumps[i] - jumps[i - 2]) + dp[i - 2]);
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 4020
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n = Scanf.sscanf (read_line ()) "%d" ( fun n -> n)

let rec f lst n =
        match lst with
                  [] -> 0
                | first :: [] -> 0 
                | first :: second :: rest -> 
                        let luca = first + second in
                                if n = 0 then
                                        luca
                                else
                                        f (luca :: lst) (n - 1)

let () =
        (
                if n = 0 then
                        2
                else
                if n = 1 then
                        1
                else
                        f [1; 2] (n - 2)
        )
        |> Printf.printf "%d\n"


Measured memory_bytes: 1024
from fractions import gcd
from functools import reduce

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

my_gcd = reduce(gcd, A)
A = [a // my_gcd for a in A]

flag = False
my_gcd_2 = 0
my_gcd_3 = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

for i in range(N):
    a = A[i]
    if my_gcd_2 == 0:
        my_gcd_2 = a
    else:
        if gcd(my_gcd_2, a) == 1:
            if flag is False:
                if i == 1:
                    my_gcd_3 = a
                else:
                    divisors = make_divisors(a)
                    for d in divisors[::-1]:
                        if len([j for j in A[:i] if j % d]) == 1:
                            my_gcd_3 = d
                            break
                flag = True
                continue
            else:
                my_gcd_2 = -1
        if my_gcd_3 and gcd(my_gcd_3, a) == 1:
            my_gcd_3 = -1
        if my_gcd_2:
            my_gcd_2 = gcd(my_gcd_2, a)
        if my_gcd_3:
            my_gcd_3 = gcd(my_gcd_3, a)

else:
    ans_1 = my_gcd * my_gcd_2
    ans_2 = my_gcd * my_gcd_3
    print(max(ans_1, ans_2, my_gcd))

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n,num=0;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        num ^= a[i];
    }
    rep(i,n) print((num^a[i]));
    return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N, K; cin >> N >> K;
  int maxK[N], tmp=0;
  int p[N];
  rep(i,N){
    cin >> p[i];
    if (i<K) tmp += p[i]+1;

    if (i==K-1) maxK[i] = tmp;
    else if (i>=K) maxK[i] = maxK[i-1] + p[i] - p[i-K];
  }

  int retval = 0;
  for (int i=K-1;i<N;i++) retval = max(maxK[i], retval);

  cout << fixed << setprecision(7);
  cout << retval/2.0 << endl;

  
  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 1792
n = int(input())
a = [int(_) for _ in input().split()]
q = int(input())

cnt = [0] * 100001
for i in a:
    cnt[i] += 1

s = sum(a)

bc = [[0] * 2 for _ in range(q)]

for i in range(q):
    bc[i][0], bc[i][1] = map(int, input().split())

for i in range(q):
    b, c = bc[i][0], bc[i][1]
    b_cnt = cnt[b]
    cnt[b] = 0
    cnt[c] = cnt[c] + b_cnt
    s = s - b_cnt * b + b_cnt * c
    print(s)


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

using namespace std;
int n,a[100005];
vector<int> k;
map<int,int> mp;

int main()
{
	cin >> n;a[0]=1000000;
	for(int i=1;i<=n;i++) cin >> a[i];
	
	sort(a+1,a+n+1);
	
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=a[i-1]) k.push_back(a[i]);
		mp[a[i]]++;
	}
	
	int sum=0,res=0;
	for(int i=0;i<=int(k.size()-3);i++)
	{
		sum=mp[k[i]];
		if(k[i+1]==k[i]+1 && k[i+2]==k[i]+2) sum+=(mp[k[i+1]]+mp[k[i+2]]);
		else if (k[i+1]==k[i]+1) sum+=mp[k[i+1]];
		res=max(res,sum);
	}
	
	if(k.size()==1) res=mp[k[0]];
	if(k.size()==2)
	{
		if(k[0]+1==k[1]) res=mp[k[0]]+mp[k[1]];
		else res=max(mp[k[0]],mp[k[1]]);
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 3836
N,K = gets.split.map &:to_i
M = (N-1)*(N-2)/2
if K > M
  p -1; exit
end

def r
  g = []
  (2..N).each{ |v| g << "1 #{v}" }

  k = M - K
  (2..N).each{ |u|
    (u+1..N).each{ |v|
      return g if k <= 0
      k -= 1
      g << "#{u} #{v}"  
    }
  }
  g
end

G = r
puts G.size, G


Measured memory_bytes: 2172
<?php
// Context
class LieDetector
{
    public $algorithm = null;

    private $number_of_bills = 0;
    private $total_amount = 0;

    public function setElements()
    {
        $input = explode(" ", trim(fgets(STDIN)));
        $this->number_of_bills = $input[0];
        $this->total_amount = $input[1];
    }

    public function execLieDitect()
    {
        return $this->algorithm->lieDitect($this->number_of_bills, $this->total_amount);
    }
}

// Strategy
interface Algorithm
{
    public function lieDitect($number_of_bills, $total_amount);
}

// ConcreteStrategy
class doubleLoop implements Algorithm
{
    public function lieDitect($number_of_bills, $total_amount)
    {
        $number_of_10000_yen_bills = 0;
        $number_of_5000_yen_bills = 0;
        $number_of_1000_yen_bills = 0;

        for (
            $number_of_10000_yen_bills = $number_of_bills;
            $number_of_10000_yen_bills >= 0;
            $number_of_10000_yen_bills--
        ) {
            for (
                $number_of_5000_yen_bills = $number_of_bills - $number_of_10000_yen_bills;
                $number_of_5000_yen_bills >= 0;
                $number_of_5000_yen_bills--
            ) {
                $number_of_1000_yen_bills = $number_of_bills - ($number_of_10000_yen_bills + $number_of_5000_yen_bills);
                $sum_amount = 10000 * $number_of_10000_yen_bills + 5000 * $number_of_5000_yen_bills + 1000 * $number_of_1000_yen_bills;
                if ($sum_amount == $total_amount) {
                    return "${number_of_10000_yen_bills} ${number_of_5000_yen_bills} ${number_of_1000_yen_bills}";
                }
            }
        }
        return "-1 -1 -1";
    }
}

// Main
$machine = new LieDetector();

$machine->algorithm = new doubleLoop();
$machine->setElements();
echo $machine->execLieDitect();


Measured memory_bytes: 3956
#include<stdio.h>
signed main(){
  int x[6];
  scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
  if(x[0]==0){
    printf("%d\n",1);
  }
  if(x[1]==0){
    printf("%d\n",2);
  }
  if(x[2]==0){
    printf("%d\n",3);
  }
  if(x[3]==0){
    printf("%d\n",4);
  }
  if(x[4]==0){
    printf("%d\n",5);
  }
  return(0);
}

Measured memory_bytes: 1728
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>
#include<iomanip>

using namespace std;

int main()
{
	double x_1,y_1,x_2,y_2;
	double a,b,c;
	while(cin>>x_1>>y_1>>x_2>>y_2)
	{
		a=x_1-x_2;
		b=y_1-y_2;
		c=a*a+b*b;
		cout<<setiosflags(ios::fixed)<<setprecision(8);
		cout<<sqrt(c);


	
	
	
	}







}

Measured memory_bytes: 3276
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (true) {
            if (ok(n)) {
                System.out.println(n);
                return;
            }
            n++;
        }
    }
    public static boolean ok(int x) {
        boolean ret = true;
        int r = x % 10;
        while (x / 10 > 0) {
            x /= 10;
            if (x % 10 != r) ret = false;
            else r = x % 10;
        }
        return ret;
    }
}

Measured memory_bytes: 21332
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import copy
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]

MOD = 10 ** 9 + 7

def getinvmod(n):
    return [pow(i, MOD-2, MOD) for i in range(n+1)]

def judge(monsters, n_attack, a, b):
    attack = 0
    for monster in monsters:
        # monster -= n_attack * b
        if monster > 0:
            attack += math.ceil(max(0, (monster - b*n_attack)/(a-b)))

    return attack <= n_attack


def main():
    n, a, b = getList()
    monsters = []
    for i in range(n):
        monsters.append(getN())

    mn = 0
    mx = 10 ** 15
    while(mx - mn > 1):
        mid = (mn + mx) // 2
        if judge(monsters, mid, a, b):
            mx = mid
        else:
            mn = mid
        # print(monsters)

    if judge(monsters, mn, a, b):
        print(mn)
    else:
        print(mx)



if __name__ == "__main__":
    main()

Measured memory_bytes: 44508
#include<bits/stdc++.h>
#define REP(i, n) for (int i=0; i<n; ++i)
#define print(x) cout << x << endl;
typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    map<int, int> m;
    REP(i, N) {
        if (m.count(A[i])) {
            m[A[i]]++;
        } else {
            m[A[i]] = 1;
        }
    }

    int ans = 0;
    for (auto item : m) {
        if (item.second % 2 != 0) ans++;
    }
    print(ans);
}

int main() {

    solve();
    return 0;
}


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

int main() {
  int64_t a, b, c, d, s = 1;
  cin >> a >> b;
  if(a < b){
    c = a;
    a = b;
    b = c;
  }
  d = a % b;
  while(d != 0){
    a = b;
    b = d;
    d = a % b;
  }
  int64_t e = b;
  if(e % 2 == 0){
    while(e % 2 == 0) e /= 2;
    s++;
  }
  for(int i = 3; i <= pow(b, 0.5); i += 2){
    if(e % i == 0){
      while(e % i == 0) e /= i;
      s++;
    }
  }
  if(e > pow(b, 0.5)) s++;
  cout << s << endl;
}


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


#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

using namespace std;

inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
unordered_map < int, int > cnt;

int main () {               
    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
    	cnt[a[i]] ++;
    }

    int ans = 0;
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);

    for (int pw = 30; pw >= 0; pw --) {
    	int cur = (1 << pw);
    	for (int i = 1; i <= n; i ++) {
    		if (cnt[a[i]] == 0) continue;
    		if (cur > a[i] && cnt.count(cur - a[i]) && cnt[cur - a[i]] > 0) {
    			if (a[i] + a[i] == cur && cnt[a[i]] == 1) continue;
    			ans ++;
    			cnt[a[i]] --;
    			cnt[cur - a[i]] --;
    		}
    	}
    }
    cout << ans;
    return Accepted;
}

// Coded By OB

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

void solve() {
    ll n;
    cin >> n;
    if(n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) cout << "hon";
    else if(n % 10 == 3) cout << "bon";
    else cout << "pon";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

import sys

def solve(xs):
    xs.sort()
    ans = float('inf')
    for p in range(xs[0], xs[-1] + 1):
        distance = 0
        for x in xs:
            distance += (p - x)**2
        if distance < ans:
            ans = distance
    return ans


def read_int_list():
    return [int(s) for s in sys.stdin.readline().rstrip().split(" ")]


def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)


def main():
    n = int(sys.stdin.readline().rstrip())
    print(solve(read_int_list()))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000


int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;
    rep(i,100){
        if( A*(i+1) % B == C ){
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

n = i_inpl()

# a, bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

# リストnumbers最大公約数
def gcdlist(numbers):
    a = numbers[0]
    for i in range(len(numbers)):
        a = gcd(a, numbers[i])
    return a

a = [0]+l_inpl()+[0]
l = [0]*(n+2)
r = [0]*(n+2)
for i in range(1, n+1):
	l[i] = gcd(l[i-1], a[i])
for i in range(n, 0, -1):
	r[i] = gcd(r[i+1], a[i])

print(max(gcd(l[i-1], r[i+1]) for i in range(1, n+1)))


Measured memory_bytes: 15224
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

const int INF = 10000005;

int main() {
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v(m + 1, {0, 0});
    for(int i = 1; i <= m; i ++)
        cin >> v[i].first >> v[i].second;
    sort(v.begin() + 1, v.end());

    int ans = 1;
    int l = -INF, r = INF;
    for(int i = 1; i <= m; i ++) {
        l = max(l, v[i].first);
        r = min(r, v[i].second);
    }

    if(l > r)
        cout << 0;
    else
        cout << r - l + 1;

    return 0;
}


Measured memory_bytes: 1024