akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n,k; cin >> n >> k; vector<bool> iscame(n,false);
  vector<ll> gototown(n);
  bool isloopin = false; 
  
  rep(i,n){
    ll x; cin >> x; x--;
    gototown[i] = x;
  }
  
  ll now = 0;
  while(!isloopin and k > 0){
    now = gototown[now];
    k--;
    if(!iscame[now]) iscame[now] = true;
    else isloopin = true;
  }
  
  ll towncnt = 0; vector<ll> looptown;
  while(isloopin and k > 0){
    looptown.push_back(now);
    iscame[now] = false;
    now = gototown[now];
    k--;
    towncnt++;
    if(!iscame[now]) isloopin = false;
  }
  
  if(k == 0) cout << now + 1 << endl;
  else cout << looptown[k % towncnt] + 1 << endl;
  
  
}

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

#define N 24
#define SQ(X) \
  ( (int)(X) * (int)(X) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

static unsigned char x[ N ];
static unsigned char y[ N ];
static unsigned char r[ N ];
static unsigned char c[ N ];
static int           n;

static signed char k_operafan[ 1 << N ];

static signed char
dpFSA (
  const unsigned int rq
  )
{
  int i, j, k;

  if ( ~k_operafan[ rq ] ) ;
  else
  {
    k_operafan[ rq ] = 0;

    for ( i = 0; i < n; ++i )
    {
      if ( !( rq & ( 1 << i ) ) ) continue ;
      for ( j = i + 1; j < n; ++j )
      {
        if ( !( rq & ( 1 << j ) ) ) continue ;
        if ( c[ i ] != c[ j ] )     continue ;

        for ( k = 0; k < j; ++k )
        {
          if ( !( rq & ( 1 << k ) ) ) continue ;
          if ( SQ( x[ k ] - x[ j ] ) + SQ( y[ k ] - y[ j ] )
             < SQ( r[ k ] + r[ j ] ) ) break ;
          if ( k < i
            && SQ( x[ k ] - x[ i ] ) + SQ( y[ k ] - y[ i ] )
             < SQ( r[ k ] + r[ i ] ) ) break ;
        }
        if ( k == j )
        {
          const unsigned char res
            = dpFSA ( rq & ~( 1 << i ) & ~( 1 << j ) ) + 2;

          k_operafan[ rq ] = MAX( k_operafan[ rq ], res );
        }
      }
    }
  }

  return ( k_operafan[ rq ] );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      unsigned int tx, ty, tr, tc;

      scanf ( "%u%u%u%u", &tx, &ty, &tr, &tc );
      x[ i ] = tx; y[ i ] = ty; r[ i ] = tr; c[ i ] = tc;
    }

    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    printf ( "%d\n", dpFSA ( ( 1 << n ) - 1 ) );
  }

  return ( 0 );
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  int a, b, c;std::cin >> a >> b >> c;
  if((a*100+b*10+c)%4==0) std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
  int N;
  cin >> N;
  int a[2][N];
  rep(i,N) cin >> a[0][i];
  rep(i,N) cin >> a[1][i];

  rep(i,N-1) a[0][i+1] += a[0][i];
  rep(i,N-1) a[1][i+1] += a[1][i];

  int ans = 0;
  rep(i,N){
    int bScore;
    if(i-1 >= 0) bScore = a[1][N-1] - a[1][i-1];
    else         bScore = a[1][N-1];
    ans = max(ans, a[0][i] + bScore);
  }
  cout << ans << endl;
  return 0;
}


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

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

struct E {
	string n;
	int b, w;
	bool operator < (const E &a) const { return w < a.w; }
};

int main() {
	for (int N, Q; N = in, Q = in;) {
		vector<E> e(N);
		for (auto &i: e)
			i = {in, in, in};
		sort(begin(e), end(e));
		times(i, Q) {
			int q {in};
			auto r = lower_bound(begin(e), end(e), E{"", 0, q});
			if (r == end(e) || q + r->b <= r->w)
				outl("Unknown");
			else
				outl(r->n, ' ', q + r->b - r->w);
		}
	}
}


Measured memory_bytes: 2796
#include<stdio.h>
#include<iostream>
using namespace std;

int MOD = 1000000007;
int x[112345];
int dp[112345];

int N,M;
int main (){
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        cin >> x[i];
        dp[x[i]]=-1;
    }
    dp[0] = 1;
    for(int i=0; i<N; i++) {
        if(dp[i]<0) continue;
        if(dp[i+1]>=0) (dp[i+1] += dp[i]) %= MOD;
        if(dp[i+2]>=0) (dp[i+2] += dp[i]) %= MOD;
    }
    cout << dp[N] << endl;
    return 0;
}


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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;


int gcd(int x, int y) {
   if(x < y) swap(x, y);
   if(x % y == 0) return y;
   else return gcd(y, x % y);
}

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

   vector<int> l(n), r(n);
   l[0] = a[0];
   r[n-1] = a[n-1];
   for (int i = 1; i < n; ++i) {
      l[i] = gcd(l[i-1], a[i]);
   }
   for (int i = n-2; i >= 0; --i) {
      r[i] = gcd(r[i+1], a[i]);
   }

   int ans = 0;
   chmax(ans, l[n-2]);
   chmax(ans, r[1]);
   for (int i = 1; i < n-1; ++i) {
      chmax(ans, gcd(l[i-1], r[i+1]));
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
long area=1;
vector<int> v;
bool find_a_pair(){
    int s=v.size()-1;
    while(s+1){
        if(s<=0){
            area=0;
            return 0;
        }
        if(v[s]==v[s-1]){
            area*=v[s];
            //printf("area%d---v[s]%d\n",area,v[s]);
            v.erase(v.begin()+s);
            v.erase(v.begin()+s-1);
            return 1;
        }
        s--;
    }
}
int main(){

    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    if(find_a_pair()) find_a_pair();
    printf("%ld",area);
}


Measured memory_bytes: 892
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int n;
    string s;
    cin >> n >> s;

    int lbcnt = 0;
    int rwcnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '.'){
            rwcnt++;
        }
    }

    int ans = lbcnt + rwcnt;

    for(int i = 0; i < n; i++){
        if(s[i] == '#'){
            lbcnt++;
        } else {
            rwcnt--;
        }

        ans = min(ans, lbcnt + rwcnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 100001;

int main(){
	string s;
	cin>>s;
	bool a,b;
	
	a=s[0]==s[1]&&s[1]==s[2];
	b=(s[1]==s[2]&&s[2]==s[3]);

	if(a||b){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  string s;
  scan(s);
  int n = s.length();
  rep (i, n) {
    if (s[i] == '?') {
      s[i] = 'D';
    }
  }
  print(s);
}

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


Measured memory_bytes: 3500
"""
チルノ（無色）のプログラミング教室～☆

こんなの無色コーダーのレベルじゃないよ～
え？　ABC D-Pairs とほとんど同じ方針？
こんな典型問題も解けないから灰色にすらなれない無色なんだよ、だって？
うわーん、無色っていうなー！！！
"""


def get_count(x):
    """
    :return: x 以上となる組の数
    """
    cnt = 0
    for i in range(N):
        cnt += bisect_left(A, x-A[i])
    res = N**2 - cnt
    return res

def binary_search_int(ok, ng, test):
    """
    :param ok: solve(x) = True を必ず満たす点
    :param ng: solve(x) = False を必ず満たす点
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if test(mid):
            ok = mid
        else:
            ng = mid
    return ok

def test(x):
    return get_count(x) >= M

def get_sum(x):
    res = 0
    cnt = 0
    for i in range(N):
        temp = bisect_left(A, x-A[i])
        res += A[i]*(N - temp) + B[-1] - B[temp]
        cnt += N - temp
    return res - x*(cnt-M)

################################################################

from bisect import *
from itertools import accumulate

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
B = list(accumulate([0] + A))

print(get_sum(binary_search_int(0, 2*10**5+10, test)))

Measured memory_bytes: 90948
#include<stdio.h>

int main() {
    int a, b, k;

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

    // AとBの中間値以上の値がKだった場合、AからBまでを出力
    if ((b - a) / 2 < k) {
	for (int i = 0; a + i <= b; i++)
	    printf("%d\n", a + i);
	return 0;
    }

    for (int i = 0; i < k; i++) {
        printf("%d\n", a + i);
    }
    for (int i = k - 1; i >= 0; i--) {
        printf("%d\n", b - i);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int A[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n-1;i++)
    {
        int t;
        cin>>t;
        A[t]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<A[i]<<endl;
    }
}


Measured memory_bytes: 4372
#include<stdio.h>

void main()
{
	int scanCheck;
	int cnt = 0;
	char tenki[10];
	scanCheck = scanf("%s", tenki);
	if ((tenki[0] == 'R') && (tenki[1] == 'R') && (tenki[2] == 'R')) {
		cnt = 3;
	}
	else if ((tenki[0] == 'R') && (tenki[1] == 'R')) {
		cnt = 2;
	}
	else if ((tenki[1] == 'R') && (tenki[2] == 'R')) {
		cnt = 2;
	}
	else {
		for (int i = 0; i < 3; i++) {
			if (tenki[i] == 'R') {
				cnt = 1;
			}
		}
	}
	printf("%d", cnt);

}

Measured memory_bytes: 1736
#include <stdio.h>

int main(){
	int n,m;
	int i,j;
	int num;
	
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		
		int used[n];
		for(i=0;i<n;i++) used[i] = 0;
		
		for(num=1,j=0;num<n;num++){
			for(i=0;i<m;){
				if(used[j]==0){
					i++;
					if(i==m) break;
				}
				j++;
				if(j>=n) j-=n;
			}
			//printf("%d:%d\n",num,j+1);
			used[j] = 1;
		}
		
		for(i=0;i<n;i++){
			if(used[i]==0){
				printf("%d\n",i+1);
				break;
			}
		}
		
	}
	
	return 0;
}

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

main(){
  int N;
  cin >> N;
  int A[N];
  for(int ii=0;ii<N;ii++){
    cin >> A[ii];
  }
  pair<int,int>tmp[N];
  for(int ii=0;ii<N;ii++){
    tmp[ii].second=ii;
    tmp[ii].first=A[ii];
  }
  sort(tmp,tmp+N);
  for(int ii=0;ii<N;ii++){
    cout << tmp[ii].second+1 << endl;
  }
}


Measured memory_bytes: 1920
s = int(input())

list ={"AC":0,"WA":0,"TLE":0,"RE":0}

for i in range(s):
  word = input()
  list[word]+=1

print("AC x "+str(list["AC"]))
print("WA x "+ str(list["WA"]))
print("TLE x " + str(list["TLE"]))
print("RE x "+str(list["RE"]))


Measured memory_bytes: 9192
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
dp = [0 for _ in range(N+1)]
for _ in range(M):
    a = int(input())
    dp[a] = -1
dp[0] = 1
if dp[1] == 0:
    dp[1] = 1

for i in range(2, N+1):
    if dp[i] != -1:
        if dp[i-1] != -1:
            dp[i] += dp[i-1]
        if dp[i-2] != -1:
            dp[i] += dp[i-2]

print(dp[N] % MOD)

Measured memory_bytes: 462744
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)

std::string highlight(std::string s) {
#ifdef _MSC_VER
    return s;
#else
    return "\033[33m" + s + "\033[0m";
#endif
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        print_to(os, ", ", "\n", __VA_ARGS__);            \
        std::cerr << highlight(os.str());                 \
    } while (0)
#define dump_(a)                                          \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #a << " = [";          \
        print_to_(os, ", ", "]\n", all(a));               \
        std::cerr << highlight(os.str());                 \
    } while (0)
#else
#define dump(...)
#define dump_(...)
#endif

template <typename T>
void print_to(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void print_to(std::ostream &os, const char *del, const char *tail, const Fst &fst, const Rst &... rst) {
    os << fst << del;
    print_to(os, del, tail, rst...);
}
template <typename Iter>
void print_to_(std::ostream &os, const char *del, const char *tail, Iter bgn, Iter end) {
    for (Iter it = bgn; it != end;) {
        os << *it;
        if (++it != end) {
            os << del;
        } else {
            os << tail;
        }
    }
}
template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    print_to(std::cout, " ", "\n", fst, rst...);
}
template <typename Iter>
void println_(Iter bgn, Iter end) {
    print_to_(std::cout, "\n", "\n", bgn, end);
}
template <typename Iter>
void print_(Iter bgn, Iter end) {
    print_to_(std::cout, " ", "\n", bgn, end);
}

// const int MOD = 1000000007;
namespace trush {
    int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
             std::ios::sync_with_stdio(0), 0);
}

using namespace std;

int main() {
    int n, k;
    while (cin >> n >> k) {
        ll ans = 1e18;
        rep(S, 1<<n) {
            ll cur = 1;
            rep(i, n) {
                if (S>>i&1) cur += k;
                else cur *= 2;
            }
            ans = min(ans, cur);
        }
        print(ans);
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stdint.h>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int ,int> pp;
typedef long long ll;
const ll MOD = 1000000007;

ll mod(ll a){
    ll t = floor((double) a / (double) MOD);
    t = a - MOD * t;
    return t; 
}

ll inverse(ll a, ll p)
{
    ll b = p;
    ll u = 1;
    ll v = 0;

    while(a < 0) a += p;

    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= p;
    if (u < 0) u += p;
    return u;
}

ll comb(ll n, ll k) {
    if(k == 0 || k == n) return 1;
    ll a = 1;
    ll b = 1;
    for(ll i = 1; i <= k; i++){
        a = mod(a * (n - i + 1));
        b = mod(b * i);
    }
    ll ret = inverse(b, MOD);
    ret = mod(ret * a);
    return ret;
}

int main(){
    ll x, y;
    cin>>x>>y;
    if((x + y) % 3 != 0){
        printf("0\n");
        return 0;
    }
    ll t = (x + y) / 3;
    ll xx = x - t;
    ll yy = y - t;
    if(xx < 0 || yy < 0){
        printf("0\n");
        return 0;
    }
    ll ret = comb(xx + yy, xx);
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 764
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
        mut l: [i64; n],
    }

    let mut ans = 0;

    for (i, x) in l.iter().enumerate() {
        for (j, y) in l.iter().enumerate().take(i) {
            for z in l.iter().take(j) {
                if *x == *y || *y == *z || *z == *x {
                    continue;
                } else if *x + *y > *z && *y + *z > *x && *z + *x > *y {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2200
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに実装したソースコード
 */
public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			// 階乗を保存する配列
			long[] factorial = new long[m + 1];
			factorial[0] = 1;
			IntStream.rangeClosed(1, m).forEach(i -> factorial[i] = factorial[i - 1] * i % MOD);
			// 階乗^-1を保存する配列
			long[] revFactorial = new long[m + 1];
			revFactorial[m] = modPow(factorial[m], MOD - 2);
			IntStream.rangeClosed(1, m).map(i -> m - i)
					.forEach(i -> revFactorial[i] = revFactorial[i + 1] * (i + 1) % MOD);
			long answer = 0L;
			for (int i = 0; i <= n; i++) {
				// (−1)^i × n_C_i
				long result = ((0 == (i & 1)) ? 1 : -1) * factorial[n] % MOD * revFactorial[i] % MOD
						* revFactorial[n - i] % MOD;
				if (result < 0) {
					result += MOD;
				}
				// m_P_i × (m-i_P_n-i)^2
				result = result * factorial[m] % MOD * revFactorial[m - i] % MOD * factorial[m - i] % MOD
						* factorial[m - i] % MOD * revFactorial[m - n] % MOD * revFactorial[m - n] % MOD;
				answer = (answer + result) % MOD;
			}
			System.out.println(answer);
		}
	}

	/**
	 * n^m mod MOD を計算する
	 * 
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long modPow(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (m & 1)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}
}


Measured memory_bytes: 46284
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

ll N, K;

int main() {
  scanf("%lld%lld", &N, &K);

  vector<ll> num(K);
  // Kで割ってiあまる数字の数
  for (int i = 0; i < K; ++i) {
    int n = (N + i) / K;
    //printf("%d: %d\n", i, n);
    num[i] = n;
  }

  // 注意：選ばれる数字は重複を許す

  ll cnt = 0;
  // すべてKで割り切れる
  cnt += (num[0] * num[0] * num[0]);

  // すべてがKで割った時にK/2余る数
  if (K % 2 == 0) {
    cnt += (num[K/2] * num[K/2] * num[K/2]);
  }
  
  printf("%lld\n", cnt);
  return 0;
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;

	repd(i, 1, 10) {
		ll a = 111 * i;
		if(n <= a) {
			cout << a << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

a_list.sort()
c_list.sort()
result = 0

for b in b_list:
    a_count = bisect.bisect_left(a_list, b)
    c_count = bisect.bisect_right(c_list, b)
    result += a_count*(len(c_list)-c_count)

print(result)


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


bool vector_finder(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}


int main() {
    ll N, K;

    cin >> N >> K;

    vector<ll> d(K);
    // vector<ll> snuke;

    vector<bool> snuke(110, false);

    for (ll i = 0; i < K; i++) {
        cin >> d.at(i);

        ll tmp;
        for (ll j = 1; j <= d.at(i); j++) {
            cin >> tmp;
            snuke.at(tmp) = true;
        }
    }

    ll ans = 0;


    for (ll i = 1; i <= N; i++) {

        if (snuke.at(i) == false) {
            ans++;
        }
    }


    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

map<string,int>m;

int main()
{
    weewoo;
    string x;
    cin >> x;
    for(int i=0;i<x.size();i++)
        cout << 'x';
    return 0;
}


Measured memory_bytes: 256
const teststr = 
"""
10 10 1
1 10 9 1
"""

function lines()
  Channel{String}(32) do ch
    ll = readlines()
    lines = isempty(ll) ? split(teststr, "\n") : ll
    for s in lines
      put!(ch, s)
    end
  end
end

quit() = exit(0)
in_1(ch) = parse(Int, take!(ch))
in_a(ch) = parse.(Int, split(take!(ch)))

function main()
  ch = lines()
  N,M,Q = in_a(ch)
  abcq = map(1:Q) do i
    (in_a(ch)...,)
  end

  A = ones(Int, N)
  smax = 0
  while true
    s = sum([q for (a, b, c, q) in abcq if A[b] - A[a] == c])
    s > smax && (smax = s)
    f = false
    for i in N:-1:1
      if A[i] < M
        f = true
        A[i] += 1
        A[i+1:N] .= A[i]
        break
      end
    end
    f || break
  end    
  println(smax)
end

main()


Measured memory_bytes: 235796
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int N=11;

int mp[N][N];


int bfs(int n,int p){
  vector<int> time(n);
  queue<int> que;
  rep(i,n)time[i]=INF;
  time[p]=0;
  que.push(p);
  int u;
  while(!que.empty()){
    u=que.front(),que.pop();
    rep(i,n){
      if(time[i]>time[u]+mp[u][i]){
        time[i]=time[u]+mp[u][i];
        que.push(i);
      }
    }
  }
  int sum=0;
  rep(i,time.size())sum+=time[i];
  return sum;
}

signed main(){
  int n;
  while(cin>>n,n!=0){
    rep(i,N)rep(j,N)mp[i][j]=i==j?0:INF;
    int city[N]={};
    rep(i,n){
      int a,b,c;
      cin>>a>>b>>c;
      mp[a][b]=mp[b][a]=c;
      city[a]++;
      city[b]++;
    }
    vector<int> d;
    rep(i,N)if(city[i]>0)d.pb(i);
    int e=d.size();
    int ans1,ans2=INF;
    rep(i,e){
      int temp=bfs(e,d[i]);
      if(ans2>temp){
        ans2=temp;
        ans1=i;
      }
    }
    cout<<ans1<<' '<<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n; string s;
lli cnt[26];
lli mod = 1e9 + 7;
int main() {
  cin >> n >> s;

  for (char c : s) cnt[c-'a']++;

  lli ans = 0;
  for (lli i=0; i<26; ++i) {
    ans = (ans + cnt[i] + ans * cnt[i]) % mod;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   int a = sc.nextInt();
   int b = sc.nextInt();
   if (a <= 8 && b <= 8) {
     System.out.println("Yay!");
   }else{
     System.out.println(":(");
   }
  }
}


Measured memory_bytes: 23252
using System;
using System.Collections.Generic;
using System.Linq;

namespace A___Grouping
{
    class Program
    {
        static void Main(string[] args)
        {
            var x_y = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var group = new List<int[]>();
            group.Add(new int[] { 1, 3, 5, 7, 8, 10, 12 });
            group.Add(new int[] { 4, 6, 9, 11 });
            group.Add(new int[] { 2 });

            foreach (var g in group)
            {
                if (g.Contains(x_y[0]) && g.Contains(x_y[1]))
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
import math

n = int(input())

p = []

g = 1

for i in range(n):
    g *= (i+1)
    x, y = map(int, input().split())
    p.append((x, y))

d = [[0]*n for _ in range(n)]

for i in range(n):
    for j in range(n):
        dd = math.sqrt(pow(p[i][0]-p[j][0], 2)+pow(p[i][1]-p[j][1], 2))
        d[i][j] = dd
        d[j][i] = dd


def hoge(s, i, dd):
    if not s:
        return dd
    sum_ = 0
    for ss in s:
        v = s.copy()
        v.remove(ss)
        sum_ += hoge(v, ss, dd+d[i][ss])
    return sum_


res = 0
for ii in range(n):
    c = set(range(n))
    c.remove(ii)
    res += hoge(c, ii, 0)

print(res/g)

Measured memory_bytes: 53596
#include<iostream>
#include<cstring>
using namespace std;
int num1[10];
int num2[10];

int op[10][10];

int main() {
	memset(op,-1,sizeof(op));
	//freopen("in","r",stdin);

	for(int i=1;i<=6;i++)
		cin>>num1[i];

	for(int i=1;i<=6;i++)
		cin>>num2[i];

	op[1][2] = 3;
	op[1][3] = 5;
	op[1][4] = 2;
	op[1][5] = 4;

	op[2][1] = 4;
	op[2][4] = 6;
	op[2][3] = 1;
	op[2][6] = 3;

	op[3][2] = 6;
	op[3][1] = 2;
	op[3][6] = 5;
	op[3][5] = 1;

	op[4][1] = 5;
	op[4][5] = 6;
	op[4][6] = 2;
	op[4][2] = 1;

	op[5][1] = 3;
	op[5][3] = 6;
	op[5][4] = 1;
	op[5][6] = 4;

	op[6][2] = 4;
	op[6][3] = 2;
	op[6][4] = 5;
	op[6][5] = 3;

	for(int i=1;i<=6;i++) {
		for(int j=1;j<=6;j++) {
			bool flag = 0;
			int a = num1[i], b = num1[j];
			int c, d;
			
			for(int k=1;k<=6;k++) {
				if(a==num2[k]) {
					c = k;

					for(int k=1;k<=6;k++) {
						if(b==num2[k]) {
							d = k;
							
							if(num1[op[i][j]]==num2[op[c][d]]) {
								flag = 1;
							}
						}
					}
				}
			}

			if(!flag) {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main() {
    int h, w; cin >> h >> w;
    vector<int> a(h), b(h);
    for (int i = 0; i < h; i++) { cin >> a[i] >> b[i]; a[i]--; b[i]--; }

    set<pair<int,int>> st;
    multiset<int> mst;
    for (int i = 0; i < w; i++) {
        st.insert(make_pair(i,i));
        mst.insert(0);
    }
    st.insert(make_pair(w,w));
    mst.insert(200200);

    for (int i = 0; i < h; i++) {
        while (true) {
            auto iter = st.lower_bound(make_pair(a[i],-1));
            if (iter->first >= b[i] + 1) break;
            int from = iter->second, to = b[i] + 1;
            if (next(iter)->first > b[i] + 1) {
                st.insert(make_pair(to, from));
                mst.insert(to - from);
            }
            mst.erase(mst.find(iter->first - iter->second));
            st.erase(iter);
        }
        int save = *mst.begin();
        cout << (save == 200200 ? -1 : save + i + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 23596
#!/usr/bin/env python3
import sys


def solve(K: int):
    if K % 2 == 0:
        print((K//2)**2)
    else:
        print(((K+1) * (K-1))//4)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()


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

int main(void){
  int n;
  cin >> n;
  
  while(n != 0){   
    vector<int> w(n);
    for(int i=0; i<n; i++)
      cin >> w[i];

    vector< vector<int> > dp(n, vector<int>(n));

    if(n == 1){
      cout << 0 << endl;
      cin >> n;
      continue;
    }

    for(int i=0; i<n-1; i++)
      if(abs(w[i] - w[i+1]) <= 1)
	dp[i][i+1] = 2;

    for(int k=3; k<n; k+=2){
      for(int i=0; i<n; i++){
	if(i+k >= n)
	  break;

	int nmax = 0;	
	if(dp[i+1][i+k-1] == k-1){
	  if(abs(w[i] - w[i+k]) <= 1){
	    dp[i][i+k] = dp[i+1][i+k-1] + 2;
	    continue;
	  }
	  nmax = dp[i+1][i+k-1];
	}

	for(int j=i+1; j<i+k; j+=2){
	  int temp = dp[i][j] + dp[j+1][i+k];
	  if(temp > nmax){
	    nmax = temp;
	  }
	}
	dp[i][i+k] = nmax;
      }
    }    

    if(n%2 != 0){
      int nmax = max(dp[1][n-1], dp[0][n-2]);
      for(int i=2; i<n-1; i+=2){
	int temp = dp[0][i-1] + dp[i+1][n-1];
	if(temp > nmax)
	  nmax = temp;
      }
      dp[0][n-1] = nmax;
    }
    
    cout << dp[0][n-1] << endl;

    cin >> n;
  }

  return 0;
}

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

int main() {

	int N,K,tmp,sum=0;
	cin >> N >> K;
	vector<int> p(N);
	//bool flag = true;

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (p[i] < p[j]) {
				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}

	for (int i = 0; i < K; i++) {
		sum = sum + p[i];
	}

		cout << sum << endl;

}


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

#define N 100000

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int aa[N + 1];
	int n, m, i, j;
	long long ans;

	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)
		scanf("%lld", &aa[i]), aa[i] = (aa[i] + aa[i - 1]) % m;
	qsort(aa, n + 1, sizeof *aa, compare);
	ans = 0;
	for (i = 0; i <= n; i = j) {
		j = i + 1;
		while (j <= n && aa[j] == aa[i])
			j++;
		ans += (long long) (j - i) * (j - i - 1) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		for(int i = 0; i < N; i++) {
				scan.nextInt();
		}
		scan.close();
		int t = 0;
		if((N - 1) % (K - 1) == 0) {
			t = (N - 1) / (K - 1);
			System.out.println(t);
		}else {
			t = (N - 1) / (K - 1) + 1;
			System.out.println(t);
		}

	}
}

Measured memory_bytes: 48272
#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define ull unsigned long long
#define si short int
#define ll long long
#define piii pair<pair<int, int>, int>
#define piiii pair<pair<int, int>, pair<int, int>>

/*-----------------------------------------------------MATH------------------------------------------------*/
inline ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

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

inline int pwm(ll xx, ll pow, int MD) {
    if (pow < 0) { pow = pow % (MD - 1) + MD - 1; }
    ll mlt = 1;
    while (pow) {
        if (pow & 1) {
            mlt *= xx;
            mlt %= MD;
        }
        xx *= xx;
        pow >>= 1;
        xx %= MD;
    }
    return (int) mlt;
}

inline ll gcdex(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll xx, yy;
    ll gc = gcdex(b, a % b, yy, xx);
    x = xx;
    y = yy - (a / b) * xx;
    return gc;
}

inline int inv(ll r, int _mod) { return pwm(r % _mod, _mod - 2, _mod); }

inline int64_t hilbertOrder(int x, int y, int pow, int rotate) {
    if (pow == 0) {
        return 0;
    }
    int hpow = 1 << (pow-1);
    int seg = (x < hpow) ? (
            (y < hpow) ? 0 : 3
    ) : (
                      (y < hpow) ? 1 : 2
              );
    seg = (seg + rotate) & 3;
    const int rotateDelta[4] = {3, 0, 0, 1};
    int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
    int nrot = (rotate + rotateDelta[seg]) & 3;
    int64_t subSquareSize = int64_t(1) << (2*pow - 2);
    int64_t ans = seg * subSquareSize;
    int64_t add = hilbertOrder(nx, ny, pow-1, nrot);
    ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
    return ans;
}
/*-----------------------------------------------------MATH------------------------------------------------*/

void solve() {
    int n,k,s;
    cin>>n>>k>>s;
    if(s!=1e9){
        for(int i=0;i<k;i++){
            cout<<s<<" ";
        }
        for(int i=k;i<n;i++){
            cout<<(int)1e9<<" ";
        }
    }
    else{
        for(int i=0;i<k;i++){
            cout<<s<<" ";
        }
        for(int i=k;i<n;i++){
            cout<<(int)1<<" ";
        }
    }
}

int main() {
    /*ios::sync_with_stdio(false);
    cin.tie(nullptr);*/
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);
    unsigned int beg_time = clock();

    int n = 1;
    for (int i = 0; i < n; i++) solve();


    unsigned int end_time = clock();
    //cout<<endl<<endl<<end_time-beg_time;

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repf(i, a, b) for(ll i = (a); i < (b) ; i++ )
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
double ans = 0;
struct point{ll x, y;char h;};
ll n;

double solve(point *p,double time){
    double xmax=-INF,xmin=INF,ymax=-INF,ymin=INF;
    rep(i,n){
        double x=p[i].x,y=p[i].y;
        if(p[i].h=='R')x+=time;
        if(p[i].h=='L')x-=time;
        if(p[i].h=='U')y+=time;
        if(p[i].h=='D')y-=time;
        if(xmax<x)xmax=x;
        if(ymax<y)ymax=y;
        if(xmin>x)xmin=x;
        if(ymin>y)ymin=y;
    }
return (xmax-xmin)*(ymax-ymin);

}

int main()
{

cin >> n;
ll t[n] = {};

point p[n];
rep(i, n){
    cin >> p[i].x>> p[i].y>> p[i].h;
}

double lower=0,upper=1000000000;
double x1,x2;

while(true){
    x1=(upper-lower)/3+lower;
    x2=(upper-lower)*2/3+lower;
    if(solve(p,x1)>solve(p,x2))lower=x1;
    else upper=x2;

    if(x2-x1<0.00000000001){
        ans=(x1+x2)/2;
        break;
    }
}

cout<<fixed<<setprecision(10)<<solve(p,ans)<<endl;
return 0;
}

Measured memory_bytes: 3328
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import static java.util.stream.IntStream.range;

public class Main {
	final static PrintStream so = System.out;
	final static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int[] digits = sc.next().chars().map(i -> i-'0').toArray(); // 125 -> {1, 2, 5}

		int pattern = (int) Math.pow(2, digits.length-1);

		so.println(range(0, pattern).mapToLong(i -> calc(digits, i)).sum());
	}
	
	static long calc(int[] nums, int bits) {
		String eq = range(0, nums.length).
				    mapToObj(
				      i -> nums[i] + ((bits >> i & 1) == 1 ? "p" : "")
				    ).collect(Collectors.joining());
		
		return Arrays.stream(eq.split("p")).mapToLong(Long::parseLong).sum();
	}
}

Measured memory_bytes: 28884
def IsTri(a, b, c):
    return (a != b) & (b != c) & (c != a) & ((a + b) > c) & ((b + c) > a) & ((c + a) > b)

N = int(input())
L = [int(a) for a in input().split()]

if N <= 2:
    print(0)
else:
    count = 0
    for i in range(0, N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                if IsTri(L[i], L[j], L[k]):
                    count += 1
    print(count)

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

void solve() {
  string s; cin >> s;
  int ans = 0;
  for (int b = 0, e = s.size()-1; b < e;) {
    if (s[b] == s[e]) {
      ++b; --e;
    } else if (s[b] == 'x') {
      ++b; ++ans;
    } else if (s[e] == 'x') {
      --e; ++ans;
    } else {
      cout << -1;
      return;
    }
  }
  cout << ans;
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

int main() {
  int n, a = 0;
  cin >> n;

  for (int i = 1; i < n + 1; i++) {
    a = i;
    if (a % 3 == 0) {
      printf(" %d", i);
    } else if (a % 10 == 3) {
      printf(" %d", i);
    } else {
      while (a /= 10) {
        if (a % 10 == 3) {
          printf(" %d", i);
          break;
        }
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3220
n=int(input())
a1=list(map(int,input().split()))
a2=sorted([a1[i-1]-i for i in range(1,n+1)])
if len(a2)%2==0:
    m1=a2[len(a2)//2]
    m2=a2[len(a2)//2-1]
else:
    m1=a2[len(a2)//2]
    m2=m1
ans1,ans2=0,0
for i in a2:
    ans1+=abs(i-m1)
    ans2+=abs(i-m2)
print(min(ans1,ans2))

Measured memory_bytes: 25744
N = int(input())

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)
    divisors.sort()
    return divisors

divisors = make_divisors(N)
length = len(divisors)
if length % 2 == 1:
    ans = (divisors[length // 2] * 2) - 2
    print(ans)
    exit()

if length % 2 == 0:
    ans = divisors[(length // 2)-1] + divisors[length // 2] - 2
    print(ans)
    exit()

Measured memory_bytes: 3268
a, b, c = gets.split.map(&:to_i)
ans = [
  (a * b * (c / 2.0).ceil - a * b * (c / 2.0).floor).abs,
  ((a / 2.0).ceil * b * c - (a / 2.0).floor * b * c).abs,
  (a * (b / 2.0).ceil * c - a * (b / 2.0).floor * c).abs
].min

puts ans


Measured memory_bytes: 1916